コード例 #1
0
        public AssemblyCodeGenerator(AssemblyAndTranspilationOptions assembly, CodeGenerator codeGenerator)
        {
            this.assembly      = assembly;
            this.codeGenerator = codeGenerator;
            var ToProcessCount = assembly.Assembly.DefinedTypes.Count();
            var ProcessedCount = assembly.Assembly.DefinedTypes.Count();

            Console.WriteLine($"{ToProcessCount} type to process");

            foreach (var type in assembly.Assembly.DefinedTypes)
            {
                if (type.Name != "<PrivateImplementationDetails>" && type.IsNestedPrivate == false)
                {
                    try
                    {
                        bool canTypeBeAdded = true;
                        var  ns             = type.Namespace;
                        if (type.Namespace == null)
                        {
                            canTypeBeAdded = false;
                        }
                        else if (assembly.Options != null && assembly.Options.FilterNamespace != null && assembly.Options.FilterNamespace.Count > 0)
                        {
                            if (assembly.Options.FilterNamespace.Find(fn => ns.StartsWith(fn)) == null)
                            {
                                canTypeBeAdded = false;
                            }
                            else
                            {
                                canTypeBeAdded = true;
                            }
                        }
                        // todo: trouver d'ou viennent les classes foireuses.
                        if (canTypeBeAdded)
                        {
                            AddType(type);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"[ERROR] Namespace: {(type.Namespace == null ? "<none>" : type.Namespace)}, class: {type.Name}");
                        Console.WriteLine($"{e.GetType().Name}:: {e.Message}");
                        Console.WriteLine($"{e.StackTrace}");
                        ProcessedCount--;
                    }
                }
            }
        }
コード例 #2
0
 public void AddAssembly(AssemblyAndTranspilationOptions assembly)
 {
     CodeGeneratorByAssembly.Add(assembly.Assembly.GetName().Name, new AssemblyCodeGenerator(assembly, this));
 }