Exemplo n.º 1
0
        private static bool TryToGetImplementationTypeNameFromMappingConfig <T>(Country country,
                                                                                out string implementationTypeName) where T : IDataComponent
        {
            string interfaceName = typeof(T).Name;

            MultiMapping mapping =
                (MultiMapping)GetInstance().typesMapping[interfaceName.ToLower()];

            implementationTypeName = mapping.Implementations
                                     .FirstOrDefault(impl => impl.Discriminator == country).Implementation;

            return(implementationTypeName != null);
        }
Exemplo n.º 2
0
        private void DoMappings()
        {
            var VatImplementationsDic = new Dictionary <Country, string>
            {
                { Country.Belgium, "VATBelgium" },
                { Country.Netherlands, "VATNetherlands" },
                { Country.Spain, "VATSpain" }
            };

            implementationsMapping.Add(typeof(IVat).Name, VatImplementationsDic);

            MultiMapping mapping = new MultiMapping
            {
                Interface           = "IVat",
                MultiImplementation = true,
                Implementations     = new List <SpecificImplementation>()
                {
                    new SpecificImplementation()
                    {
                        Discriminator  = Country.Belgium,
                        Implementation = "VatBelgium"
                    },
                    new SpecificImplementation()
                    {
                        Discriminator  = Country.Netherlands,
                        Implementation = "VatNetherlands"
                    },
                    new SpecificImplementation()
                    {
                        Discriminator  = Country.Spain,
                        Implementation = "VatSpain"
                    }
                }
            };

            typesMapping.Add(typeof(IVat).Name.ToLower(), mapping);
        }