Пример #1
0
        internal string[] GenerateClassModule()
        {
            string name = (ProxyInterface.Name.StartsWith("I") ? ProxyInterface.Name.Substring(1) : ProxyInterface.Name) + "Duck_" + AquireCounter().ToString();

            StringBuilder classBuilder = new StringBuilder();
            StringBuilder issueBuilder = new StringBuilder();

            using (DuckTypeIssueClassGenerator issueClassGenerator = new DuckTypeIssueClassGenerator(issueBuilder, ProxyInterface, name))
            {
                using (DuckTypeClassGenerator classGenerator = new DuckTypeClassGenerator(classBuilder, ProxyInterface, name, issueClassGenerator.ImplementationName))
                {
                    if (ProxyInterface.IsValidEventClass)
                    {
                        EventInfo[] events = ProxyInterface.Events;
                        using (DuckTypeEventsGenerator eventsBuilder = new DuckTypeEventsGenerator(classBuilder, events))
                        {

                        }
                    }

                    HasIndexPropertyAttribute indexAttribute = ProxyInterface.GetHasIndexPropertyAttribute();
                    PropertyInfo[] indexProperties = ProxyInterface.PropertiesIndexer;
                    using (DuckTypeIndexerGenerator indexGenerator = new DuckTypeIndexerGenerator(classBuilder, indexProperties, indexAttribute))
                    {

                    }

                    PropertyInfo[] properties = ProxyInterface.Properties;
                    using (DuckTypePropertiesGenerator propertiesGenerator = new DuckTypePropertiesGenerator(classBuilder, properties))
                    {

                    }

                    MethodInfo[] methods = ProxyInterface.Methods;
                    using (DuckTypeMethodsGenerator methodsGenerator = new DuckTypeMethodsGenerator(classBuilder, methods))
                    {

                    }

                    EnumeratorAttribute enumAttribute = ProxyInterface.GetEnumeratorAttribute();
                    MethodInfo[] enumeratorMethods = ProxyInterface.MethodsWithEnumerator;
                    using (DuckTypeEnumeratorGenerator enumeratorGenerator = new DuckTypeEnumeratorGenerator(classBuilder, enumeratorMethods, enumAttribute))
                    {

                    }

                    MethodInfo[] issueMethods = ProxyInterface.MethodsWithSyntaxIssue;
                    using (DuckTypeMethodsGenerator methodsGenerator = new DuckTypeMethodsGenerator(issueBuilder, issueMethods))
                    {

                    }
                }
            }

            return new string[] { classBuilder.ToString(), issueBuilder.ToString() };
        }
Пример #2
0
        internal DuckTypeEnumeratorGenerator(StringBuilder builder, MethodInfo[] methods, EnumeratorAttribute info)
        {
            HasMethods = null != methods && methods.Length > 0;
            if (!HasMethods)
            {
                return;
            }

            Builder = builder;
            Info    = info;
            Builder.AppendLine(Environment.NewLine + "\t\t#region IEnumerable" + Environment.NewLine + Environment.NewLine);

            foreach (MethodInfo item in methods)
            {
                if (Info.Invoke == EnumeratorInvoke.Custom)
                {
                    BuildCustomEnumeratorMethods(item);
                }
                else
                {
                    BuildEnumeratorMethods(item);
                }
            }
        }