private PropertyMapping BuildDictionaryMapping(IDictionaryMappingProvider provider)
 {
     var dictionaryMapping = new DictionaryMapping(
         provider.PropertyInfo.DeclaringType,
         provider.PropertyInfo.PropertyType,
         provider.PropertyInfo.Name,
         provider.GetTerm(_mappingContext.OntologyProvider),
         provider.Key.GetTerm(_mappingContext.OntologyProvider),
         provider.Value.GetTerm(_mappingContext.OntologyProvider));
     SetConverter(dictionaryMapping, provider);
     return dictionaryMapping;
 }
Ejemplo n.º 2
0
        private PropertyMapping BuildDictionaryMapping(IDictionaryMappingProvider provider)
        {
            var dictionaryMapping = new DictionaryMapping(
                provider.PropertyInfo.DeclaringType,
                provider.PropertyInfo.PropertyType,
                provider.PropertyInfo.Name,
                provider.GetTerm(_mappingContext.OntologyProvider),
                provider.Key.GetTerm(_mappingContext.OntologyProvider),
                provider.Value.GetTerm(_mappingContext.OntologyProvider));

            SetConverter(dictionaryMapping, provider);
            return(dictionaryMapping);
        }
        private TypeBuilder EmitOwnerMap(IDictionaryMappingProvider map, ModuleBuilder defineDynamicModule, Type owner, Type ownerMapType)
        {
            var typeBuilderHelper = defineDynamicModule.DefineType(owner.Name + "Map", TypeAttributes.Public, ownerMapType);
            var methodBuilderHelper = typeBuilderHelper.DefineMethod(
                "SetupEntriesCollection",
                MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                typeof(void),
                new[] { typeof(ITermPart<ICollectionMap>) });

            var ilGenerator = methodBuilderHelper.GetILGenerator();
            ilGenerator.Emit(OpCodes.Nop);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldstr, map.GetTerm(_ontologyProvider).ToString());
            ilGenerator.Emit(OpCodes.Newobj, typeof(Uri).GetConstructor(new[] { typeof(string) }));
            ilGenerator.Emit(OpCodes.Callvirt, typeof(ITermPart<CollectionMap>).GetMethod("Is", new Type[] { typeof(Uri) }));
            ilGenerator.Emit(OpCodes.Pop);
            ilGenerator.Emit(OpCodes.Ret);
            return typeBuilderHelper;
        }
        private TypeBuilder EmitOwnerMap(IDictionaryMappingProvider map, ModuleBuilder defineDynamicModule, Type owner, Type ownerMapType)
        {
            var typeBuilderHelper   = defineDynamicModule.DefineType(owner.Name + "Map", TypeAttributes.Public, ownerMapType);
            var methodBuilderHelper = typeBuilderHelper.DefineMethod(
                "SetupEntriesCollection",
                MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                typeof(void),
                new[] { typeof(ITermPart <ICollectionMap>) });

            var ilGenerator = methodBuilderHelper.GetILGenerator();

            ilGenerator.Emit(OpCodes.Nop);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Ldstr, map.GetTerm(_ontologyProvider).ToString());
            ilGenerator.Emit(OpCodes.Newobj, typeof(Uri).GetConstructor(new[] { typeof(string) }));
            ilGenerator.Emit(OpCodes.Callvirt, typeof(ITermPart <CollectionMap>).GetMethod("Is", new Type[] { typeof(Uri) }));
            ilGenerator.Emit(OpCodes.Pop);
            ilGenerator.Emit(OpCodes.Ret);
            return(typeBuilderHelper);
        }