Added dynamic wrapper support to IFileSystem to allow context specific implementations from which to hang extension methods upon (ie IMediaFileSystem)

This commit is contained in:
Matt@MBP13-PC
2012-08-20 09:42:32 -01:00
parent 847b3523a8
commit 3a2ed918de
18 changed files with 386 additions and 19 deletions

View File

@@ -0,0 +1,24 @@
namespace Umbraco.Core
{
public static class ObjectExtensions
{
internal static T As<T>(this object realObject) where T : class
{
if (realObject is T)
return realObject as T;
return DynamicWrapper.CreateWrapper<T>(realObject);
}
internal static T AsReal<T>(this object wrapper) where T : class
{
if (wrapper is T)
return wrapper as T;
if (wrapper is DynamicWrapper.DynamicWrapperBase)
return (T)(wrapper as DynamicWrapper.DynamicWrapperBase).RealObject;
return null;
}
}
}