コード例 #1
0
        public void FrameworkDependencyVisitor_By_DependencyAssemblyCatalog()
        {
            var catalog = new FrameworkAssemblyCatalog(Assembly.GetExecutingAssembly());
            var visitor = new FrameworkDependencyVisitor(catalog);
            var root = visitor.VisitTypes();

            WriteToSerialization(root);
        }
コード例 #2
0
        public void DependencyAssemblyCatalog_Basic_Test()
        {
            var assembly = new FrameworkAssemblyCatalog(Assembly.GetExecutingAssembly());
            var types = assembly.GetMatchingTypes();

            foreach (var type in types)
            {
                Debug.WriteLine(type.AssemblyQualifiedName);
            }

            Assert.IsTrue(types.Count() > 0, "현재 테스트 어셈블리에 Mock개체가 1개 이상이지만 Mock DependencyContrac타입의 개수가 0개여서 실패");
        }
コード例 #3
0
        public void DependencyAssemblyCatalog_Basic_Test()
        {
            var assembly = new FrameworkAssemblyCatalog(Assembly.GetExecutingAssembly());
            var types    = assembly.GetMatchingTypes();

            foreach (var type in types)
            {
                Debug.WriteLine(type.AssemblyQualifiedName);
            }

            Assert.IsTrue(types.Count() > 0, "현재 테스트 어셈블리에 Mock개체가 1개 이상이지만 Mock DependencyContrac타입의 개수가 0개여서 실패");
        }
コード例 #4
0
        /// <summary>	
        /// 	관리되는 대상 목록의 조건에 만족하는 타입을 반환합니다. 
        /// </summary>
        /// <returns>	
        /// 	조건에 만족하는 타입 목록입니다. 
        /// </returns>
        /// <exception cref="FrameworkDependencyException">어셈블리를 찾을 수 없는 경우 발생하는 예외 입니다.</exception>
        public override IEnumerable<Type> GetMatchingTypes()
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.AssemblyLoad    += CurrentDomain_AssemblyLoad;

            try
            {
                var files = Directory.GetFiles(this.Path, this.SearchPattern);

                foreach (var file in files)
                {
                    if (File.Exists(file) == false)
                    {
                        throw new FileNotFoundException(file);
                    }

                    var assemblyBytes = File.ReadAllBytes(file);
                    Assembly assembly = null;
                    try
                    {
                        assembly = Assembly.Load(assemblyBytes);
                    }
                    catch ( BadImageFormatException ex )
                    {
                        Debug.WriteLine(ex.FileName);
                        continue;
                    }

                    var catalog       = new FrameworkAssemblyCatalog(assembly);
                    var types         = catalog.GetMatchingTypes();

                    foreach (var type in types)
                    {
                        yield return type;
                    }
                }

            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyLoad    -= CurrentDomain_AssemblyLoad;
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }
コード例 #5
0
        /// <summary>
        ///     관리되는 대상 목록의 조건에 만족하는 타입을 반환합니다.
        /// </summary>
        /// <returns>
        ///     조건에 만족하는 타입 목록입니다.
        /// </returns>
        /// <exception cref="FrameworkDependencyException">어셈블리를 찾을 수 없는 경우 발생하는 예외 입니다.</exception>
        public override IEnumerable <Type> GetMatchingTypes()
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.AssemblyLoad    += CurrentDomain_AssemblyLoad;

            try
            {
                var files = Directory.GetFiles(this.Path, this.SearchPattern);

                foreach (var file in files)
                {
                    if (File.Exists(file) == false)
                    {
                        throw new FileNotFoundException(file);
                    }

                    var      assemblyBytes = File.ReadAllBytes(file);
                    Assembly assembly      = null;
                    try
                    {
                        assembly = Assembly.Load(assemblyBytes);
                    }
                    catch (BadImageFormatException ex)
                    {
                        Debug.WriteLine(ex.FileName);
                        continue;
                    }

                    var catalog = new FrameworkAssemblyCatalog(assembly);
                    var types   = catalog.GetMatchingTypes();

                    foreach (var type in types)
                    {
                        yield return(type);
                    }
                }
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyLoad    -= CurrentDomain_AssemblyLoad;
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }