private static Type CreateStubType(this System.Type type)
        {
            var assembly   = type.Assembly.CreateStubAssembly();
            var namespc    = type.Namespace.CreateStubNamespace();
            var visibility = type.GetVisibility();

            return(new Type(type.FullName, type.Name, assembly, namespc, visibility, type.IsNested));
        }
        private static Visibility GetVisibility(this System.Type type)
        {
            if (type == null)
            {
                return(NotAccessible);
            }

            if (type.IsPublic || type.IsNestedPublic)
            {
                return(Public);
            }

            if (type.IsNestedPrivate)
            {
                return(Private);
            }

            if (type.IsNestedFamily)
            {
                return(Protected);
            }

            if (type.IsNestedFamORAssem)
            {
                return(ProtectedInternal);
            }

            if (type.IsNestedFamANDAssem)
            {
                return(PrivateProtected);
            }

            if (type.IsNestedAssembly || type.IsNotPublic)
            {
                return(Internal);
            }

            throw new ArgumentException("The provided type seems to have no visibility.");
        }
        public static Class CreateStubClass(this System.Type type)
        {
            var classType = type.CreateStubType();

            return(new Class(classType, type.IsAbstract, type.IsSealed, type.IsValueType, type.IsEnum));
        }