Updates to newer 2.0 version of Examine which has Examine.Core as netstandard
This commit is contained in:
@@ -7,6 +7,6 @@
|
||||
-->
|
||||
<packageSources>
|
||||
<add key="UmbracoCoreMyGet" value="https://www.myget.org/F/umbracocore/api/v3/index.json" />
|
||||
<add key="ExamineAppVeyor" value="https://ci.appveyor.com/nuget/examine-f73l6qv0oqfh/" />
|
||||
<add key="ExamineAzurePipelines" value="https://shazwazza.pkgs.visualstudio.com/Examine/_packaging/Examine-Beta/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
||||
@@ -49,7 +49,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- note: NuGet deals with transitive references now -->
|
||||
<PackageReference Include="Examine" Version="1.0.2" />
|
||||
<PackageReference Include="Examine.Core">
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Examine.Lucene">
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub">
|
||||
<Version>1.0.0-beta2-19554-01</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
composition.RegisterUnique(f => new DistributedCache(f.GetInstance<IServerMessenger>(), f.GetInstance<CacheRefresherCollection>()));
|
||||
composition.WithCollectionBuilder<UrlProviderCollectionBuilder>().Append<DefaultUrlProvider>();
|
||||
composition.RegisterUnique<IDistributedCacheBinder, DistributedCacheBinder>();
|
||||
composition.RegisterUnique<IExamineManager>(f => ExamineManager.Instance);
|
||||
composition.RegisterUnique<IExamineManager, ExamineManager>();
|
||||
composition.RegisterUnique<IUmbracoContextFactory, UmbracoContextFactory>();
|
||||
composition.RegisterUnique<IMacroRenderer, MacroRenderer>();
|
||||
composition.RegisterUnique<MediaUrlProviderCollection>(_ => new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()));
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace Umbraco.Tests.Testing
|
||||
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().WebRouting);
|
||||
|
||||
Composition.RegisterUnique<IExamineManager>(factory => ExamineManager.Instance);
|
||||
Composition.RegisterUnique<IExamineManager, ExamineManager>();
|
||||
|
||||
Composition.RegisterUnique<IJsonSerializer, JsonNetSerializer>();
|
||||
|
||||
|
||||
@@ -78,13 +78,14 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="4.3.1" />
|
||||
<PackageReference Include="Examine" Version="1.0.2" />
|
||||
<PackageReference Include="Examine.Core">
|
||||
<Version>2.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="HtmlAgilityPack">
|
||||
<Version>1.8.14</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LightInject" Version="5.4.0" />
|
||||
<PackageReference Include="LightInject.Annotation" Version="1.1.0" />
|
||||
<PackageReference Include="Lucene.Net" Version="3.0.3" />
|
||||
<PackageReference Include="Lucene.Net.Contrib" Version="3.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
|
||||
@@ -146,6 +147,7 @@
|
||||
<Compile Include="Persistence\Mappers\MapperTestBase.cs" />
|
||||
<Compile Include="Persistence\Repositories\DocumentRepositoryTest.cs" />
|
||||
<Compile Include="Persistence\Repositories\EntityRepositoryTest.cs" />
|
||||
<Compile Include="UmbracoExamine\ExamineExtensions.cs" />
|
||||
<Compile Include="PublishedContent\NuCacheChildrenTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedContentLanguageVariantTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedContentSnapshotTestBase.cs" />
|
||||
|
||||
134
src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs
Normal file
134
src/Umbraco.Tests/UmbracoExamine/ExamineExtensions.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// LEGACY!! Static methods to help query umbraco xml
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should be deleted when we remove the old xml published content with tests which should be replaced with nucache tests
|
||||
/// </remarks>
|
||||
internal static class ExamineExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the XElement is recognized as an umbraco xml NODE (doc type)
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
internal static string ExamineNodeTypeAlias(this XElement x)
|
||||
{
|
||||
return string.IsNullOrEmpty((string)x.Attribute("nodeTypeAlias"))
|
||||
? x.Name.LocalName
|
||||
: (string)x.Attribute("nodeTypeAlias");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns umbraco value for a data element with the specified alias.
|
||||
/// </summary>
|
||||
/// <param name="xml"></param>
|
||||
/// <param name="alias"></param>
|
||||
/// <returns></returns>
|
||||
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<string, object> 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<string, object> 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<string, object>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,6 @@
|
||||
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
|
||||
<PackageReference Include="ClientDependency" Version="1.9.8" />
|
||||
<PackageReference Include="ClientDependency-Mvc5" Version="1.9.3" />
|
||||
<PackageReference Include="Examine" Version="1.0.2" />
|
||||
<PackageReference Include="ImageProcessor.Web" Version="4.10.0.100" />
|
||||
<PackageReference Include="ImageProcessor.Web.Config" Version="2.5.0.100" />
|
||||
<PackageReference Include="Microsoft.AspNet.Identity.Owin" Version="2.2.2" />
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Umbraco.Web
|
||||
private static UmbracoContext UmbracoContext => Current.UmbracoContext;
|
||||
private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance<ISiteDomainHelper>();
|
||||
private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor;
|
||||
private static IExamineManager ExamineManager => Current.Factory.GetInstance<IExamineManager>();
|
||||
|
||||
#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();
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Umbraco.Web.Runtime
|
||||
|
||||
composition.RegisterUnique<IDashboardService, DashboardService>();
|
||||
|
||||
composition.RegisterUnique<IExamineManager>(factory => ExamineManager.Instance);
|
||||
composition.RegisterUnique<IExamineManager, ExamineManager>();
|
||||
|
||||
// configure the container for web
|
||||
composition.ConfigureForWeb();
|
||||
|
||||
@@ -48,11 +48,6 @@ namespace Umbraco.Web.Search
|
||||
composition.RegisterUnique<IValueSetBuilder<IMedia>, MediaValueSetBuilder>();
|
||||
composition.RegisterUnique<IValueSetBuilder<IMember>, MemberValueSetBuilder>();
|
||||
composition.RegisterUnique<BackgroundIndexRebuilder>();
|
||||
|
||||
//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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
@@ -62,7 +62,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ClientDependency" Version="1.9.8" />
|
||||
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
|
||||
<PackageReference Include="Examine" Version="1.0.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
|
||||
<PackageReference Include="ImageProcessor">
|
||||
<Version>2.7.0.100</Version>
|
||||
|
||||
Reference in New Issue
Block a user