Files
Umbraco-CMS/src/UmbracoExamine/LegacyLibrary.cs
Shannon Deminick 8b49d2d377 Removes all MyGet dependencies for UmbracoExamine (since it is in the core now).
Converts UmbracoContextService and UmbracoMediaService for UmbracoExamine to use the new data api's
to extract latest data. Currently had to hack a bit with a new class called LegacyLibrary because at the moment
we'll have a circular dependency with Umbraco.Web which needs to be fixed. Moves all Examine event management to
Umbraco.Web (again mainly because of circular dependencies, but makes sense to have it there). Fixes the ExamineEvents
to implement IApplicationEventHandler instead of IApplicationStartupHandler to ensure that all resolvers have been
initialized before attempting to initialize examine indexes. Updates Examine ILogService to use the LogHelper.
Adds some new ContentExtensions for IMedia since currently Examine needs xml structures, but have kept it internal.
2013-01-05 22:46:50 +03:00

58 lines
1.9 KiB
C#

using System;
using System.Reflection;
using System.Xml.XPath;
namespace UmbracoExamine
{
/// <summary>
/// This is only used for backward compatibility to get access to the umbraco.library object but this needs to be done
/// via reflection because of the circular reference we have between Umbraco.Web and UmbracoExamine.
/// </summary>
internal static class LegacyLibrary
{
private static volatile Type _libraryType;
private static readonly object Locker = new object();
private static Type LibraryType
{
get
{
if (_libraryType == null)
{
lock (Locker)
{
if (_libraryType == null)
{
var ass = Assembly.Load("umbraco");
if (ass == null)
throw new InvalidOperationException("Could not load assembly umbraco.dll, the umbraco.dll needs to be loaded in the current app domain");
var lib = ass.GetType("umbraco.library");
if (lib == null)
throw new InvalidOperationException("Could not load type umbraco.library, the umbraco.dll needs to be loaded in the current app domain");
_libraryType = lib;
}
}
}
return _libraryType;
}
}
internal static XPathNodeIterator GetXmlNodeById(string id)
{
var meth = LibraryType.GetMethod("GetXmlNodeById", BindingFlags.Public | BindingFlags.Static);
return (XPathNodeIterator)meth.Invoke(null, new object[] { id });
}
internal static XPathNodeIterator GetMember(int id)
{
var meth = LibraryType.GetMethod("GetMember", BindingFlags.Public | BindingFlags.Static);
return (XPathNodeIterator)meth.Invoke(null, new object[] { id });
}
internal static XPathNodeIterator GetXmlNodeByXPath(string xpathQuery)
{
var meth = LibraryType.GetMethod("GetXmlNodeByXPath", BindingFlags.Public | BindingFlags.Static);
return (XPathNodeIterator)meth.Invoke(null, new object[] { xpathQuery });
}
}
}