Beispiel #1
0
        internal string GetRelativeClassName(WrapperClassInfo wci)
        {
            if (!TypeIsWrapped(wci.WrappedType))
                throw new InvalidOperationException();

            return GetRelativeClassName(wci.WrappedType);
        }
Beispiel #2
0
        public bool GenerateForAllUsedIncomplete()
        {
            var allAssemblyTypes = new Dictionary<string, Type>();

            foreach (Type t in TargetAssembly.GetTypes().Where(t => t.IsPublic))
            {
                if (!allAssemblyTypes.ContainsKey(t.Name))
                    allAssemblyTypes.Add(t.Name, t);
            }

            bool added = false;

            foreach (Type type in UsedTypes.ToArray())
            {
                if (!TypeIsWrapped(type))
                    throw new InvalidOperationException();

                if (!CompleteTypes.ContainsKey(type))
                {
                    var wci = new WrapperClassInfo(type, this);
                    CompleteTypes.Add(type, wci);

                    foreach (
                        Type inheritedType in
                            allAssemblyTypes.Values.Where(t => t.IsSubclassOf(wci.WrappedType) && t.IsPublic)
                                .Where(TypeIsWrapped))
                    {
                        if (inheritedType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Count() == 0
                            && !UsedTypes.Contains(inheritedType))
                            UsedTypes.Add(inheritedType);
                    }

                    var sb = new StringBuilder();

                    if (wci.IsInterface)
                        wci.GenerateInterfaceCode(sb);
                    else
                        wci.GenerateClassCode(sb);

                    if (wci.FilePathBase.IndexOfAny(new[] { '\\', '/' }) != -1)
                        Directory.CreateDirectory(Path.GetDirectoryName(wci.FilePathBase));

                    WriteTextToFile(wci.FilePathBase + ".cs", sb.ToString(), true);

                    wci.GenerateUserClassFile();

                    added = true;
                }
            }

            return added;
        }
 public WrapperStaticPublicField(WrapperClassInfo wrapperClassInfo, FieldInfo targetFieldInfo)
 {
     this.targetFieldInfo = targetFieldInfo;
     this.classInfo = wrapperClassInfo;
 }
 public WrapperConstructorInfo(WrapperClassInfo classInfo, ConstructorInfo targetConstructorInfo)
 {
     this.targetConstructorInfo = targetConstructorInfo;
     this.classInfo             = classInfo;
 }
Beispiel #5
0
 public WrapperPropInfo(WrapperClassInfo wci, string propName, WrapperRepository wrapperRepository)
 {
     Name            = propName;
     this.classInfo  = wci;
     this.repository = wrapperRepository;
 }
 public WrapperMethodInfo(WrapperClassInfo classInfo, MethodInfo targetMethodInfo)
 {
     this.targetMethodInfo = targetMethodInfo;
     this.classInfo = classInfo;
 }
 public WrapperConstructorInfo(WrapperClassInfo classInfo, ConstructorInfo targetConstructorInfo)
 {
     this.targetConstructorInfo = targetConstructorInfo;
     this.classInfo = classInfo;
 }
Beispiel #8
0
 internal string GetTargetFullName(WrapperClassInfo wrapperClassInfo)
 {
     return(WrapperNamespace + "." + wrapperClassInfo.RelativeClassName);
 }
 public WrapperMethodInfo(WrapperClassInfo classInfo, MethodInfo targetMethodInfo)
 {
     this.targetMethodInfo = targetMethodInfo;
     this.classInfo        = classInfo;
 }
 public WrapperStaticPublicField(WrapperClassInfo wrapperClassInfo, FieldInfo targetFieldInfo)
 {
     this.targetFieldInfo = targetFieldInfo;
     this.classInfo       = wrapperClassInfo;
 }
 public WrapperPropInfo(WrapperClassInfo wci, string propName, WrapperRepository wrapperRepository)
 {
     this.name = propName;
     this.classInfo = wci;
     this.repository = wrapperRepository;
 }
Beispiel #12
0
 internal string GetTargetFullName(WrapperClassInfo wrapperClassInfo)
 {
     return WrapperNamespace + "." + wrapperClassInfo.RelativeClassName;
 }
Beispiel #13
0
        internal string GetRelativeClassName(WrapperClassInfo wci)
        {
            if (!TypeIsWrapped(wci.WrappedType))
                throw new InvalidOperationException();

            return GetRelativeClassName(wci.WrappedType);
        }
Beispiel #14
0
        public bool GenerateForAllUsedIncomplete()
        {
            var allAssemblyTypes = new Dictionary<string, Type>();

            foreach (Type t in TargetAssembly.GetTypes().Where(t => t.IsPublic))
            {
                if (!allAssemblyTypes.ContainsKey(t.Name))
                    allAssemblyTypes.Add(t.Name, t);
            }

            bool added = false;

            foreach (Type type in UsedTypes.ToArray())
            {
                if (!TypeIsWrapped(type))
                    throw new InvalidOperationException();

                if (!CompleteTypes.ContainsKey(type))
                {
                    var wci = new WrapperClassInfo(type, this);
                    CompleteTypes.Add(type, wci);

                    foreach (
                        Type inheritedType in
                            allAssemblyTypes.Values.Where(t => t.IsSubclassOf(wci.WrappedType) && t.IsPublic)
                                .Where(TypeIsWrapped))
                    {
                        if (inheritedType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Count() == 0
                            && !UsedTypes.Contains(inheritedType))
                            UsedTypes.Add(inheritedType);
                    }

                    var sb = new StringBuilder();

                    if (wci.IsInterface)
                        wci.GenerateInterfaceCode(sb);
                    else
                        wci.GenerateClassCode(sb);

                    if (wci.FilePathBase.IndexOfAny(new[] { '\\', '/' }) != -1)
                        Directory.CreateDirectory(Path.GetDirectoryName(wci.FilePathBase));

                    WriteTextToFile(wci.FilePathBase + ".cs", sb.ToString(), true);

                    wci.GenerateUserClassFile();

                    added = true;
                }
            }

            return added;
        }