diff --git a/NuGet.Config b/NuGet.Config
index 7d786702f4..64425091dc 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -7,6 +7,6 @@
-->
-
+
diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj
index a3adcb56b7..047fb7813e 100644
--- a/src/Umbraco.Examine/Umbraco.Examine.csproj
+++ b/src/Umbraco.Examine/Umbraco.Examine.csproj
@@ -49,7 +49,12 @@
-
+
+ 2.0.0
+
+
+ 2.0.0
+
1.0.0-beta2-19554-01
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
index 8594b07692..f913d1c9b8 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedMediaCache.cs
@@ -43,6 +43,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private readonly IEntityXmlSerializer _entitySerializer;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly IVariationContextAccessor _variationContextAccessor;
+ private readonly IExamineManager _examineManager = new ExamineManager();
// must be specified by the ctor
private readonly IAppCache _appCache;
@@ -229,29 +230,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override bool HasContent(bool preview) { throw new NotImplementedException(); }
- private static IExamineManager GetExamineManagerSafe()
- {
- try
- {
- return ExamineManager.Instance;
- }
- catch (TypeInitializationException)
- {
- return null;
- }
- }
-
private ISearcher GetSearchProviderSafe()
{
if (_searchProvider != null)
return _searchProvider;
- var eMgr = GetExamineManagerSafe();
- if (eMgr == null) return null;
-
try
{
- return eMgr.TryGetIndex(Constants.UmbracoIndexes.InternalIndexName, out var index) ? index.GetSearcher() : null;
+ return _examineManager.TryGetIndex(Constants.UmbracoIndexes.InternalIndexName, out var index) ? index.GetSearcher() : null;
}
catch (FileNotFoundException)
{
diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
index 9ba5c4bb91..27113bdc79 100644
--- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
+++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs
@@ -108,7 +108,7 @@ namespace Umbraco.Tests.Runtimes
composition.RegisterUnique(f => new DistributedCache(f.GetInstance(), f.GetInstance()));
composition.WithCollectionBuilder().Append();
composition.RegisterUnique();
- composition.RegisterUnique(f => ExamineManager.Instance);
+ composition.RegisterUnique();
composition.RegisterUnique();
composition.RegisterUnique();
composition.RegisterUnique(_ => new MediaUrlProviderCollection(Enumerable.Empty()));
diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
index d664b4823c..93a3e52446 100644
--- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
+++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
@@ -393,7 +393,7 @@ namespace Umbraco.Tests.Testing
Composition.RegisterUnique(factory => factory.GetInstance().Content);
Composition.RegisterUnique(factory => factory.GetInstance().WebRouting);
- Composition.RegisterUnique(factory => ExamineManager.Instance);
+ Composition.RegisterUnique();
Composition.RegisterUnique();
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index a06c0c0b25..2892e39b49 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -78,13 +78,14 @@
-
+
+ 2.0.0
+
1.8.14
-
@@ -146,6 +147,7 @@
+
diff --git a/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs b/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs
new file mode 100644
index 0000000000..9cca58719e
--- /dev/null
+++ b/src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs
@@ -0,0 +1,134 @@
+using Examine;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace Umbraco.Tests.UmbracoExamine
+{
+ ///
+ /// LEGACY!! Static methods to help query umbraco xml
+ ///
+ ///
+ /// This should be deleted when we remove the old xml published content with tests which should be replaced with nucache tests
+ ///
+ internal static class ExamineExtensions
+ {
+ ///
+ /// Returns true if the XElement is recognized as an umbraco xml NODE (doc type)
+ ///
+ ///
+ ///
+ internal static bool IsExamineElement(this XElement x)
+ {
+ var id = (string)x.Attribute("id");
+ if (string.IsNullOrEmpty(id))
+ return false;
+ int parsedId;
+ if (int.TryParse(id, out parsedId))
+ if (parsedId > 0)
+ return true;
+ return false;
+ }
+
+ ///
+ /// This takes into account both schemas and returns the node type alias.
+ /// If this isn't recognized as an element node, this returns an empty string
+ ///
+ ///
+ ///
+ internal static string ExamineNodeTypeAlias(this XElement x)
+ {
+ return string.IsNullOrEmpty((string)x.Attribute("nodeTypeAlias"))
+ ? x.Name.LocalName
+ : (string)x.Attribute("nodeTypeAlias");
+ }
+
+ ///
+ /// Returns umbraco value for a data element with the specified alias.
+ ///
+ ///
+ ///
+ ///
+ internal static string SelectExamineDataValue(this XElement xml, string alias)
+ {
+ XElement nodeData = null;
+
+ //if there is data children with attributes, we're on the old
+ if (xml.Elements("data").Any(x => x.HasAttributes))
+ nodeData = xml.Elements("data").SingleOrDefault(x => string.Equals((string)x.Attribute("alias"), alias, StringComparison.InvariantCultureIgnoreCase));
+ else
+ nodeData = xml.Elements().FirstOrDefault(x => string.Equals(x.Name.ToString(), alias, StringComparison.InvariantCultureIgnoreCase));
+
+ if (nodeData == null)
+ return string.Empty;
+
+ if (!nodeData.HasElements)
+ return nodeData.Value;
+
+ //it has sub elements so serialize them
+ var reader = nodeData.CreateReader();
+ reader.MoveToContent();
+ return reader.ReadInnerXml();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static ValueSet ConvertToValueSet(this XElement xml, string indexCategory)
+ {
+ if (!xml.IsExamineElement())
+ throw new InvalidOperationException("Not a supported Examine XML structure");
+ var allVals = xml.SelectExamineAllValues();
+ var id = (string)xml.Attribute("id");
+ //we will use this as the item type, but we also need to add this as the 'nodeTypeAlias' as part of the properties
+ //since this is what Umbraco expects
+ var nodeTypeAlias = xml.ExamineNodeTypeAlias();
+ var set = new ValueSet(id, indexCategory, nodeTypeAlias, allVals);
+ set.Set("nodeTypeAlias", nodeTypeAlias);
+ return set;
+ }
+
+ internal static Dictionary SelectExamineAllValues(this XElement xml)
+ {
+ var attributeValues = xml.Attributes().ToDictionary(x => x.Name.LocalName, x => x.Value);
+ var dataValues = xml.SelectExamineDataValues();
+ foreach (var v in attributeValues)
+ //override the data values with attribute values if they do match, otherwise add
+ dataValues[v.Key] = v.Value;
+ return dataValues;
+ }
+
+ internal static Dictionary SelectExamineDataValues(this XElement xml)
+ {
+ //resolve all element data at once since it is much faster to do this than to relookup all of the XML data
+ //using Linq and the node.Elements() methods re-gets all of them.
+ var elementValues = new Dictionary();
+ foreach (var x in xml.Elements())
+ {
+ if (x.Attribute("id") != null)
+ continue;
+
+ string key;
+ if (x.Name.LocalName == "data")
+ //it's the legacy schema
+ key = (string)x.Attribute("alias");
+ else
+ key = x.Name.LocalName;
+
+ if (string.IsNullOrEmpty(key))
+ continue;
+
+ if (!x.HasElements)
+ elementValues[key] = x.Value;
+ else
+ //it has sub elements so serialize them
+ using (var reader = x.CreateReader())
+ {
+ reader.MoveToContent();
+ elementValues[key] = reader.ReadInnerXml();
+ }
+ }
+ return elementValues;
+ }
+ }
+}
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index ae42f0dd75..56bd423678 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -86,7 +86,6 @@
-
diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs
index d02e5a3197..223b7dbaf1 100644
--- a/src/Umbraco.Web/PublishedContentExtensions.cs
+++ b/src/Umbraco.Web/PublishedContentExtensions.cs
@@ -28,6 +28,7 @@ namespace Umbraco.Web
private static UmbracoContext UmbracoContext => Current.UmbracoContext;
private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance();
private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor;
+ private static IExamineManager ExamineManager => Current.Factory.GetInstance();
#region IsComposedOf
@@ -198,7 +199,7 @@ namespace Umbraco.Web
// TODO: inject examine manager
indexName = string.IsNullOrEmpty(indexName) ? Constants.UmbracoIndexes.ExternalIndexName : indexName;
- if (!ExamineManager.Instance.TryGetIndex(indexName, out var index))
+ if (!ExamineManager.TryGetIndex(indexName, out var index))
throw new InvalidOperationException("No index found with name " + indexName);
var searcher = index.GetSearcher();
@@ -219,7 +220,7 @@ namespace Umbraco.Web
// TODO: inject examine manager
indexName = string.IsNullOrEmpty(indexName) ? Constants.UmbracoIndexes.ExternalIndexName : indexName;
- if (!ExamineManager.Instance.TryGetIndex(indexName, out var index))
+ if (!ExamineManager.TryGetIndex(indexName, out var index))
throw new InvalidOperationException("No index found with name " + indexName);
var searcher = index.GetSearcher();
diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs
index 4cb256e44a..d34398e066 100644
--- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs
+++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs
@@ -149,7 +149,7 @@ namespace Umbraco.Web.Runtime
composition.RegisterUnique();
- composition.RegisterUnique(factory => ExamineManager.Instance);
+ composition.RegisterUnique();
// configure the container for web
composition.ConfigureForWeb();
diff --git a/src/Umbraco.Web/Search/ExamineComposer.cs b/src/Umbraco.Web/Search/ExamineComposer.cs
index d62fc97efb..9d8af5f3a0 100644
--- a/src/Umbraco.Web/Search/ExamineComposer.cs
+++ b/src/Umbraco.Web/Search/ExamineComposer.cs
@@ -48,11 +48,6 @@ namespace Umbraco.Web.Search
composition.RegisterUnique, MediaValueSetBuilder>();
composition.RegisterUnique, MemberValueSetBuilder>();
composition.RegisterUnique();
-
- //We want to manage Examine's AppDomain shutdown sequence ourselves so first we'll disable Examine's default behavior
- //and then we'll use MainDom to control Examine's shutdown - this MUST be done in Compose ie before ExamineManager
- //is instantiated, as the value is used during instantiation
- ExamineManager.DisableDefaultHostingEnvironmentRegistration();
}
}
}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index f577f212d6..cac8dd0704 100755
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -1,4 +1,4 @@
-
+
@@ -62,7 +62,6 @@
-
2.7.0.100