예제 #1
0
        public void Test()
        {
            IDictionary <Type, Type> storage =
                ReflectExtension.GetTypesMarkedAttribute <TesticAttribute>(Assembly.GetAssembly(this.GetType()));

            Assert.That(storage, Is.Not.Null);
            Assert.That(storage.Count, Is.EqualTo(2));
            Assert.That(storage[typeof(MyClass1)] == typeof(MyClass2));
            Assert.That(storage[typeof(MyClass2)] == typeof(MyClass1));
        }
예제 #2
0
        private IEnumerable <Type> GetAllAutoMapperProfile()
        {
            var profiles = new List <Type>();

            ReflectExtension.GetTypesMarkedAttribute <AutoMapperProfileAttribute>(
                Assembly.GetAssembly(typeof(Buisness.Workflows.ConfigureWorkflow)),
                (type, attribute) => profiles.Add(type));

            return(profiles);
        }
예제 #3
0
        private IEnumerable <object[]> GetAFilteringStrategies()
        {
            var list = new List <object[]>();

            ReflectExtension.GetTypesMarkedAttribute <FilterForEntityAttribute>(
                Assembly.GetAssembly(typeof(CertificateQualityFilterStrategy)),
                (type, attribute) => list.Add(new object[] { attribute.RegisterAsType, type }));

            return(list);
        }
예제 #4
0
        private IEnumerable <object[]> GetService()
        {
            var dictionary = new Dictionary <Type, Type>();

            ReflectExtension.GetTypesMarkedAttribute <RegisterAttribute>(
                typeof(CommonService).Assembly,
                (type, attribute) => dictionary.Add(type, attribute.RegisterAsType));

            return(dictionary.Select(keyValuePair => new object[] { keyValuePair.Value, keyValuePair.Key }));
        }
예제 #5
0
        static ServiceFactory()
        {
            _storage =
                ReflectExtension.GetTypesMarkedAttribute <RegisterAttribute>(
                    Assembly.GetAssembly(typeof(ServiceFactory)),
                    Assembly.GetAssembly(typeof(PolicyService)));

            FilterStrategyFactory.Assemblies = new[]
            {
                Assembly.GetAssembly(typeof(AgnlistFilteringStrategy)),
                Assembly.GetAssembly(typeof(AcatalogFilterStrategy))
            };
        }
예제 #6
0
        public void RegisterAndResolve()
        {
            var dictionary = new Dictionary <Type, RegisterAttribute>();

            ReflectExtension.GetTypesMarkedAttribute <RegisterAttribute>(Assembly.Load("Halfblood.UnitTests"), dictionary.Add);

            Assert.That(dictionary.Count, Is.EqualTo(2));
            Assert.That(dictionary[typeof(Test_1)], Is.InstanceOf <RegisterAttribute>());
            Assert.That(dictionary[typeof(Test_1)].RegisterAsType, Is.EqualTo(typeof(ITest_1)));

            Assert.That(dictionary[typeof(Test_2)], Is.InstanceOf <RegisterAttribute>());
            Assert.That(dictionary[typeof(Test_2)].RegisterAsType, Is.EqualTo(typeof(ITest_2)));
        }
예제 #7
0
        /// <summary>
        /// The get type dto by section of system.
        /// </summary>
        /// <param name="sectionOfSystem">
        /// The section of system.
        /// </param>
        /// <returns>
        /// The <see cref="Type"/>.
        /// </returns>
        public static Type GetTypeDtoBySectionOfSystem(string sectionOfSystem)
        {
            Type expectedType = null;

            ReflectExtension.GetTypesMarkedAttribute <RelationEntityToDtoAttribute>(
                new[] { Assembly.GetAssembly(typeof(CertificateQualityDto)) },
                (type, attribute) => { if (attribute.TypeOfDto == sectionOfSystem)
                                       {
                                           expectedType = type;
                                       }
                });

            return(expectedType);
        }
예제 #8
0
        /// <summary>
        /// The load profiles.
        /// </summary>
        public void LoadProfiles()
        {
            ReflectExtension.GetTypesMarkedAttribute <AutoMapperProfileAttribute>(
                Assembly.GetAssembly(GetType()),
                (type, attribute) => Mapper.AddProfile((Profile)Activator.CreateInstance(type)));

            foreach (TypeMap typeMap in Mapper.GetAllTypeMaps())
            {
                if (typeMap.SourceType.HasInterface <IDto>() && typeMap.DestinationType.HasInterface <IUiEntity>())
                {
                    ProcessRelation.Instance.Relation(typeMap.SourceType, typeMap.DestinationType);
                }
            }
        }
예제 #9
0
        /// <summary>
        /// The load profiles.
        /// </summary>
        /// <param name="container">
        /// The container.
        /// </param>
        public void LoadProfiles(CompositionContainer container)
        {
            ReflectExtension.GetTypesMarkedAttribute <AutoMapperProfileAttribute>(
                Assembly.GetAssembly(this.GetType()),
                (type, attribute) => Mapper.AddProfile((Profile)Activator.CreateInstance(type)));

            foreach (TypeMap typeMap in Mapper.GetAllTypeMaps())
            {
                if (typeMap.SourceType.HasInterface <IDto>() && typeMap.DestinationType.HasInterface <IEntity>())
                {
                    if (typeMap.SourceType == typeof(TaxDto))
                    {
                    }

                    BusinessRelation.Instance.Relation(typeMap.SourceType, typeMap.DestinationType);
                }
            }

            ServiceLocator.Container = container;
        }
예제 #10
0
 static RepositoryFactory()
 {
     _storage =
         ReflectExtension.GetTypesMarkedAttribute <RepositoryForEntityAttribute>(
             Assembly.GetAssembly(typeof(PlanCertificateRepository)));
 }