示例#1
0
        public static object GetUninitializedObject(Type type)
        {
#if COREFX
            return(ProfilerInterceptor.GetUninitializedObjectImpl(type));
#else
            if (typeof(ContextBoundObject).IsAssignableFrom(type))
            {
                throw new MockException("Cannot mock constructors of ContextBoundObject descendants.");
            }
            if (type == typeof(string))
            {
                return(string.Empty);
            }
            return(FormatterServices.GetUninitializedObject(type));
#endif
        }
示例#2
0
        public static object TryGetUninitializedObject(Type type)
        {
#if COREFX
            return(ProfilerInterceptor.GetUninitializedObjectImpl(type));
#else
            if (typeof(ContextBoundObject).IsAssignableFrom(type) ||
                type.IsAbstract || type.IsInterface)
            {
                return(null);
            }
            if (type == typeof(string))
            {
                return(string.Empty);
            }
            return(FormatterServices.GetUninitializedObject(type));
#endif
        }