public static T CreateWrapper <T>(object realObject) where T : class { DynamicWrapperBase dynamicWrapperBase = (DynamicWrapperBase)Activator.CreateInstance(DynamicWrapper.GetWrapper(typeof(T), realObject.GetType())); dynamicWrapperBase.UnderlyingObject = realObject; return(dynamicWrapperBase as T); }
public static object GetUnderlyingObject(object wrapper) { DynamicWrapperBase dynamicWrapperBase = wrapper as DynamicWrapperBase; if (dynamicWrapperBase == null) { throw new ArgumentException("Object is not a wrapper.", "wrapper"); } return(dynamicWrapperBase.UnderlyingObject); }