Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public void AddAssembly(Assembly asm)
        {
            _generator.AddFollowAssembly(asm);

            foreach (var type in asm.GetExportedTypes())
            {
                if (type.GetTypeInfo().IsEnum)
                {
                    if (Settings.ConstEnumsEnabled)
                    {
                        _generator.AddEnumeration(type);
                    }
                    continue;
                }


                _generator.AddInterface(type);
            }
        }