示例#1
0
        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);
        }
示例#2
0
        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);
        }