public NamespaceAssemblyReader(Assembly assembly)
        {
            _generator = new TSGenerator(assembly)
            {
                Modules = true
            };

            _namespaces = new Dictionary <string, TSModule>();
            foreach (var type in assembly.ExportedTypes)
            {
                var ns = type.Namespace.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).ToList();

                var root = ns.First();

                if (!_namespaces.ContainsKey(root))
                {
                    var module = new TSModule(root, _generator.GenerateLookupTypeName)
                    {
                        IsDeclared = true
                    };
                    _namespaces.Add(root, module);
                }
                ns.RemoveAt(0);
                _namespaces[root].AddSubNamespaceType(ns, type);
            }
        }
Пример #2
0
        public AssemblyReader(string dllPath)
        {
            if (!File.Exists(dllPath))
            {
                throw new Exception("DLL attempting to generate " + dllPath + " Does NOT EXIST");
            }

            _resolveDirectory = Path.GetDirectoryName(dllPath);
            var files = Directory.EnumerateFiles(_resolveDirectory, "*.dll");
            var fi    = new FileInfo(dllPath);

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            //AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = dir;
            AppDomain.CurrentDomain.AppendPrivatePath(_resolveDirectory);
            Assembly asm = Assembly.LoadFile(dllPath);//null;

            //foreach (var file in files)
            //{

            //    var tasm =  Assembly.LoadFile(file);
            //    if (fi.FullName == new FileInfo(file).FullName)
            //    {
            //        asm = tasm;
            //    }
            //}


            //var asm = Assembly.LoadFile(dllPath);
            //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            _generator = new TSGenerator(asm);


            foreach (var type in asm.GetTypes().Where(t => t.IsPublic))
            {
                if (type.IsEnum)
                {
                    if (Settings.ConstEnumsEnabled)
                    {
                        _generator.AddEnumeration(type);
                    }
                    continue;
                }


                _generator.AddInterface(type);
            }
        }
Пример #3
0
        public AssemblyReader()
        {
            //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            //AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = dir;
            //AppDomain.CurrentDomain.AppendPrivatePath(_resolveDirectory);

            //   Assembly asm = Assembly.Load(.LoadFile(dllPath);//null;
            //foreach (var file in files)
            //{

            //    var tasm =  Assembly.LoadFile(file);
            //    if (fi.FullName == new FileInfo(file).FullName)
            //    {
            //        asm = tasm;
            //    }
            //}


            //var asm = Assembly.LoadFile(dllPath);
            //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            _generator = new TSGenerator();
        }