private void AssertConverter(IPropertyMappingProvider propertyMappingProvider)
 {
     if (propertyMappingProvider.ConverterType == null)
     {
         _log.Warning("Entity {0}: missing converter for property {1}", _currentType, propertyMappingProvider);
     }
 }
Example #2
0
 public ContentTypeCreator(IPropertyDefinitionCreator propertyDefinitionCreator, ICoreInterfaceProvider coreInterfaceProvider, IPropertyMappingProvider propertyMappingRepository, IComponentProvider componentProvider)
 {
     PropertyDefinitionCreator = propertyDefinitionCreator;
     CoreInterfaceProvider     = coreInterfaceProvider;
     PropertyMappingRepository = propertyMappingRepository;
     ComponentProvider         = componentProvider;
 }
        public PropertyDefinitionProvider(IContentTypeProvider contentTypeProvider, IPropertyMappingProvider propertyMappingProvider, IPropertyDefinitionCreator propertyDefinitionCreator)
        {
            foreach (var contentType in contentTypeProvider.GetAll())
            {
                var propertyDefinitions = new List <PropertyDefinitionDescriptor>();

                foreach (var property in contentType.Type.GetProperties())
                {
                    var mapping = propertyMappingProvider.Get(property);

                    if (mapping.PropertyMappingType == PropertyMappingType.Ignored)
                    {
                        continue;
                    }

                    if (mapping.PropertyMappingType == PropertyMappingType.CoreInterface)
                    {
                        continue;
                    }

                    if (mapping.PropertyMappingType == PropertyMappingType.Incomplete)
                    {
                        continue;
                    }

                    propertyDefinitions.Add(propertyDefinitionCreator.Create(property));
                }

                Values[contentType.Id] = propertyDefinitions.AsReadOnly();
            }
        }
Example #4
0
        /// <summary>
        /// Map Properties between two objects
        /// </summary>
        /// <param name="entity">Entity received from the client code, <see cref="System.Object"/></param>
        /// <param name="LINQEntity">Entity retrieved from DB</param>
        /// <param name="LINQProperty"><see cref="System.Reflection.PropertyInfo"/> from LINQ entity
        /// retrieved from DB to be mapped</param>
        /// <remarks>This class will get the provider dynamically and will map the properties
        /// using that provider, so if you want to implement your own provider, you dont
        /// have to modify anything in the code</remarks>
        public static void MapProperties(object entity, object LINQEntity, PropertyInfo LINQProperty)
        {
            IPropertyMappingProvider provider = null;

            //Get All Types in the current assembly which have MappingPropertyTypeNameAttribute defined
            Type[] currentProviders = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttributes(typeof(MappingPropertyTypeNameAttribute), false).ToArray().Length > 0).ToArray();

            if (null != currentProviders && currentProviders.Length > 0)
            {
                //Get the provider type,first try to get from its type
                //the mechanism used is to get the MappingPropertyTypeNameAttribute and compare
                //the string defined there with the LINQProperty type
                Type providerType = currentProviders.Where(p =>
                                                           (p.GetCustomAttributes(typeof(MappingPropertyTypeNameAttribute), false).ToArray()[0]
                                                            as MappingPropertyTypeNameAttribute).PropertyTypeName == LINQProperty.PropertyType.ToString()).SingleOrDefault();

                //if no provider found,Try to get it from comparing LINQproperty base type with MappingPropertyTypeNameAttribute
                if (null == providerType)
                {
                    providerType = currentProviders.Where(p =>
                                                          (p.GetCustomAttributes(typeof(MappingPropertyTypeNameAttribute), false).ToArray()[0]
                                                           as MappingPropertyTypeNameAttribute).PropertyTypeName == LINQProperty.PropertyType.BaseType.ToString()).SingleOrDefault();
                }

                if (null != providerType)
                {
                    //Call the provider factory to get our instance
                    provider = ProviderFactory.CreatePropertyMappingProvider(providerType);
                    //Map Properties
                    provider.MapProperties(entity, LINQEntity, LINQProperty);
                }
            }
        }
        private TypeBuilder EmitOwnerMappingType(IPropertyMappingProvider map, ModuleBuilder defineDynamicModule, string ownerTypeName)
        {
            var owner = defineDynamicModule.DefineType(
                    ownerTypeName,
                    TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract,
                    null,
                    new[] { typeof(IRdfListOwner) }).CreateType();
            var ownerMapType = typeof(ListOwnerMap<>).MakeGenericType(new[] { owner });

            var mapBuilderHelper = defineDynamicModule.DefineType(ownerTypeName + "Map", TypeAttributes.Public, ownerMapType);
            var propertyBuilder = mapBuilderHelper.DefineProperty("ListPredicate", PropertyAttributes.None, typeof(Uri), null);
            var getMethod = mapBuilderHelper.DefineMethod(
                "get_ListPredicate",
                MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                typeof(Uri),
                Type.EmptyTypes);
            propertyBuilder.SetGetMethod(getMethod);

            var ilGenerator = getMethod.GetILGenerator();
            ilGenerator.Emit(OpCodes.Nop);
            ilGenerator.Emit(OpCodes.Ldstr, map.GetTerm(_ontologyProvider).ToString());
            ilGenerator.Emit(OpCodes.Newobj, typeof(Uri).GetConstructor(new[] { typeof(string) }));
            ilGenerator.Emit(OpCodes.Ret);

            return mapBuilderHelper;
        }
Example #6
0
        private TypeBuilder EmitOwnerMappingType(IPropertyMappingProvider map, ModuleBuilder defineDynamicModule, string ownerTypeName)
        {
            var owner = defineDynamicModule.DefineType(
                ownerTypeName,
                TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract,
                null,
                new[] { typeof(IRdfListOwner) }).CreateTypeInfo().AsType();
            var ownerMapType = typeof(ListOwnerMap <>).MakeGenericType(new[] { owner });

            var mapBuilderHelper = defineDynamicModule.DefineType(ownerTypeName + "Map", TypeAttributes.Public, ownerMapType);
            var propertyBuilder  = mapBuilderHelper.DefineProperty("ListPredicate", PropertyAttributes.None, typeof(Uri), null);
            var getMethod        = mapBuilderHelper.DefineMethod(
                "get_ListPredicate",
                MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.SpecialName,
                typeof(Uri),
                Type.EmptyTypes);

            propertyBuilder.SetGetMethod(getMethod);

            var ilGenerator = getMethod.GetILGenerator();

            ilGenerator.Emit(OpCodes.Nop);
            ilGenerator.Emit(OpCodes.Ldstr, map.GetTerm(_ontologyProvider).ToString());
            ilGenerator.Emit(OpCodes.Newobj, typeof(Uri).GetConstructor(new[] { typeof(string) }));
            ilGenerator.Emit(OpCodes.Ret);

            return(mapBuilderHelper);
        }
Example #7
0
        internal RoundTripperBase(
            Func <ConnectionSettings, ConnectionSettings> settingsModifier     = null,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
            IPropertyMappingProvider propertyMappingProvider = null,
            bool preserveNullInExpected = false
            )
        {
            PreserveNullInExpected = preserveNullInExpected;
            if (settingsModifier == null && sourceSerializerFactory == null && propertyMappingProvider == null)
            {
                Tester = SerializationTester.Default;
            }
            else
            {
                var settings =
                    new AlwaysInMemoryConnectionSettings(sourceSerializerFactory: sourceSerializerFactory,
                                                         propertyMappingProvider: propertyMappingProvider)
                    .ApplyDomainSettings();

                if (settingsModifier != null)
                {
                    settings = settingsModifier(settings);
                }
                Tester = new SerializationTester(new ElasticClient(settings));
            }
        }
Example #8
0
 internal JsonRoundTripper(object expectedJson,
                           Func <ConnectionSettings, ConnectionSettings> settingsModifier     = null,
                           ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
                           IPropertyMappingProvider propertyMappingProvider = null,
                           bool preserveNullInExpected = false
                           )
     : base(settingsModifier, sourceSerializerFactory, propertyMappingProvider, preserveNullInExpected) => _expectedJson = expectedJson;
Example #9
0
        protected ConnectionSettingsBase(
            IConnectionPool connectionPool,
            IConnection connection,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory,
            IPropertyMappingProvider propertyMappingProvider
            )
            : base(connectionPool, connection, null, NestElasticsearchProductRegistration.DefaultForNest)
        {
            var formatterResolver           = new NestFormatterResolver(this);
            var defaultSerializer           = new DefaultHighLevelSerializer(formatterResolver);
            var sourceSerializer            = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer;
            var serializerAsMappingProvider = sourceSerializer as IPropertyMappingProvider;

            _propertyMappingProvider = propertyMappingProvider ?? serializerAsMappingProvider ?? new PropertyMappingProvider();

            //We wrap these in an internal proxy to facilitate serialization diagnostics
            _sourceSerializer = new JsonFormatterAwareDiagnosticsSerializerProxy(sourceSerializer, "source");
            UseThisRequestResponseSerializer = new JsonFormatterAwareDiagnosticsSerializerProxy(defaultSerializer);
            _defaultFieldNameInferrer        = p => p.ToCamelCase();
            _defaultIndices       = new FluentDictionary <Type, string>();
            _defaultRelationNames = new FluentDictionary <Type, string>();
            _inferrer             = new Inferrer(this);

            UserAgent(ConnectionSettings.DefaultUserAgent);
        }
Example #10
0
 public ElasticsearchClientSettings(
     NodePool nodePool,
     ITransportClient connection,
     SourceSerializerFactory sourceSerializer,
     IPropertyMappingProvider propertyMappingProvider) : base(nodePool, connection, sourceSerializer, propertyMappingProvider)
 {
 }
 private void AssertConverter(IPropertyMappingProvider propertyMappingProvider)
 {
     if (propertyMappingProvider.ConverterType == null)
     {
         LogTo.Warn("Entity {0}: missing converter for property {1}", _currentType, propertyMappingProvider);
     }
 }
Example #12
0
 internal ObjectRoundTripper(T @object,
                             Func <ConnectionSettings, ConnectionSettings> settingsModifier     = null,
                             ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
                             IPropertyMappingProvider propertyMappingProvider = null)
     : base(settingsModifier, sourceSerializerFactory, propertyMappingProvider, preserveNullInExpected: false)
 {
     _object = @object;
 }
Example #13
0
 public ConnectionSettings(
     IConnectionPool connectionPool,
     IConnection connection,
     SourceSerializerFactory sourceSerializer,
     IPropertyMappingProvider propertyMappingProvider
     ) : base(connectionPool, connection, sourceSerializer, propertyMappingProvider)
 {
 }
Example #14
0
 public static IElasticClient GetInMemoryClientWithSourceSerializer(
     Func <ConnectionSettings, ConnectionSettings> modifySettings,
     ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
     IPropertyMappingProvider propertyMappingProvider = null) =>
 new ElasticClient(
     CreateSettings(modifySettings, forceInMemory: true, sourceSerializerFactory: sourceSerializerFactory,
                    propertyMappingProvider: propertyMappingProvider)
     );
Example #15
0
 public TestElasticsearchClientSettings(
     Func <ICollection <Uri>, NodePool> createPool    = null,
     SourceSerializerFactory sourceSerializerFactory  = null,
     IPropertyMappingProvider propertyMappingProvider = null,
     bool forceInMemory = false,
     int port           = 9200,
     byte[] response    = null
     ) : base(CreatePool(createPool, port), TestConfiguration.Instance.CreateConnection(forceInMemory, response), CreateSerializerFactory(sourceSerializerFactory), propertyMappingProvider) =>
 private PropertyMapping BuildPropertyMapping(IPropertyMappingProvider provider)
 {
     var propertyMapping = new PropertyMapping(
         provider.PropertyInfo.DeclaringType,
         provider.PropertyInfo.PropertyType,
         provider.PropertyInfo.Name,
         provider.GetTerm(_mappingContext.OntologyProvider));
     SetConverter(propertyMapping, provider);
     return propertyMapping;
 }
Example #17
0
        private PropertyMapping BuildPropertyMapping(IPropertyMappingProvider provider)
        {
            var propertyMapping = new PropertyMapping(
                provider.PropertyInfo.DeclaringType,
                provider.PropertyInfo.PropertyType,
                provider.PropertyInfo.Name,
                provider.GetTerm(_mappingContext.OntologyProvider));

            SetConverter(propertyMapping, provider);
            return(propertyMapping);
        }
Example #18
0
        private bool SetConverter(PropertyMapping propertyMapping, IPropertyMappingProvider provider)
        {
            bool result = false;

            if ((provider.ConverterType != null) && (!provider.ConverterType.GetTypeInfo().ContainsGenericParameters) && (!provider.ConverterType.GetTypeInfo().IsInterface))
            {
                propertyMapping.Converter = _converterCatalog.GetConverter(provider.ConverterType);
                result = true;
            }

            return(result);
        }
Example #19
0
 internal static PropertyMapping CreateFrom(
     IEntityMapping entityMapping,
     IPropertyMappingProvider propertyMappingProvider,
     IConverter valueConverter,
     IEnumerable <QIriMapping> qiriMappings)
 {
     return(new PropertyMapping(
                entityMapping,
                propertyMappingProvider.Property,
                propertyMappingProvider.GetGraph(qiriMappings),
                propertyMappingProvider.GetTerm(qiriMappings),
                valueConverter));
 }
Example #20
0
 public TestConnectionSettings(
     Func <ICollection <Uri>, IConnectionPool> createPool = null,
     SourceSerializerFactory sourceSerializerFactory      = null,
     IPropertyMappingProvider propertyMappingProvider     = null,
     bool forceInMemory = false,
     int port           = 9200
     )
     : base(
         CreatePool(createPool, port),
         TestConfiguration.Instance.CreateConnection(forceInMemory),
         CreateSerializerFactory(sourceSerializerFactory),
         propertyMappingProvider
         ) =>
        private PropertyMapping BuildMapping(IPropertyMappingProvider mapping)
        {
            if (mapping is IDictionaryMappingProvider)
            {
                return BuildDictionaryMapping((IDictionaryMappingProvider)mapping);
            }

            if (mapping is ICollectionMappingProvider)
            {
                return BuildCollectionMapping((ICollectionMappingProvider)mapping);
            }

            return BuildPropertyMapping(mapping);
        }
Example #22
0
        internal RoundTripper(object expected,
                              Func <ConnectionSettings, ConnectionSettings> settings             = null,
                              ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
                              IPropertyMappingProvider propertyMappingProvider = null)
        {
            this.ExpectJson = expected;
            this.ConnectionSettingsModifier = settings;
            this.SourceSerializerFactory    = sourceSerializerFactory;
            this.PropertyMappingProvider    = propertyMappingProvider;

            var expectedString = JsonConvert.SerializeObject(expected, NullValueSettings);

            this.ExpectedJsonJObject = JToken.Parse(expectedString);
        }
 public AlwaysInMemoryConnectionSettings(
     Func <ICollection <Uri>, IConnectionPool> createPool = null,
     SourceSerializerFactory sourceSerializerFactory      = null,
     IPropertyMappingProvider propertyMappingProvider     = null,
     int port = 9200)
     : base(
         createPool,
         sourceSerializerFactory,
         propertyMappingProvider,
         forceInMemory: true,
         port: port
         )
 {
 }
Example #24
0
        private PropertyMapping BuildMapping(IPropertyMappingProvider mapping)
        {
            if (mapping is IDictionaryMappingProvider)
            {
                return(BuildDictionaryMapping((IDictionaryMappingProvider)mapping));
            }

            if (mapping is ICollectionMappingProvider)
            {
                return(BuildCollectionMapping((ICollectionMappingProvider)mapping));
            }

            return(BuildPropertyMapping(mapping));
        }
Example #25
0
 public AlwaysInMemoryElasticsearchClientSettings(
     Func <ICollection <Uri>, NodePool> createPool    = null,
     SourceSerializerFactory sourceSerializerFactory  = null,
     IPropertyMappingProvider propertyMappingProvider = null,
     int port = 9200
     )
     : base(
         createPool,
         sourceSerializerFactory,
         propertyMappingProvider,
         true,
         port
         )
 {
 }
Example #26
0
        public static IPropertyMappingProvider CreatePropertyMappingProvider(Type providerType)
        {
            IPropertyMappingProvider provider = null;

            //Check if the provider already exists in the cahce
            if (providers.ContainsKey(providerType.ToString()))
            {
                provider = providers[providerType.ToString()] as IPropertyMappingProvider;
            }
            else
            {
                //Instaniate a new provider and add it to the cache
                provider = AppDomain.CurrentDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().ToString(), providerType.ToString()) as IPropertyMappingProvider;
                providers.Add(provider.GetType().ToString(), provider as IPropertyMappingProvider);
            }
            return(provider);
        }
Example #27
0
        public static ConnectionSettings CreateSettings(
            Func <ConnectionSettings, ConnectionSettings> modifySettings = null,
            int port           = 9200,
            bool forceInMemory = false,
            bool forceSsl      = false,
            Func <Uri, IConnectionPool> createPool = null,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
            IPropertyMappingProvider propertyMappingProvider = null
            )
        {
            createPool = createPool ?? (u => new SingleNodeConnectionPool(u));

            var connectionPool = createPool(CreateUri(port, forceSsl));
            var connection     = CreateConnection(forceInMemory: forceInMemory);
            var s = new ConnectionSettings(connectionPool, connection, (builtin, values) =>
            {
                if (sourceSerializerFactory != null)
                {
                    return(sourceSerializerFactory(builtin, values));
                }

                return(!Configuration.Random.SourceSerializer
                        ? null
                        : new TestSourceSerializerBase(builtin, values));
            }, propertyMappingProvider);

            var defaultSettings = DefaultSettings(s);

            modifySettings = modifySettings ?? ((m) =>
            {
                //only enable debug mode when running in DEBUG mode (always) or optionally wheter we are executing unit tests
                //during RELEASE builds tests
#if !DEBUG
                if (TestClient.Configuration.RunUnitTests)
#endif
                m.EnableDebugMode();
                return(m);
            });

            var settings = modifySettings(defaultSettings);
            return(settings);
        }
Example #28
0
        /// <inheritdoc />
        public void Visit(IPropertyMappingProvider propertyMappingProvider)
        {
            if (propertyMappingProvider == null)
            {
                throw new ArgumentNullException(nameof(propertyMappingProvider));
            }

            if (propertyMappingProvider.ValueConverterType != null)
            {
                return;
            }

            var valueType = propertyMappingProvider.Property.PropertyType.GetItemType();

            if (typeof(IEntity).IsAssignableFrom(valueType))
            {
                return;
            }

            propertyMappingProvider.ValueConverterType = _converterProvider.FindLiteralConverter(valueType).GetType();
        }
Example #29
0
        public static ConnectionSettings CreateSettings(
            Func <ConnectionSettings, ConnectionSettings> modifySettings = null,
            int port           = 9200,
            bool forceInMemory = false,
            bool forceSsl      = false,
            Func <Uri, IConnectionPool> createPool = null,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
            IPropertyMappingProvider propertyMappingProvider = null
            )
        {
            createPool = createPool ?? (u => new SingleNodeConnectionPool(u));

            var connectionPool = createPool(CreateUri(port, forceSsl));
            var connection     = CreateConnection(forceInMemory: forceInMemory);
            var s = new ConnectionSettings(connectionPool, connection, sourceSerializerFactory, propertyMappingProvider);

            var defaultSettings = DefaultSettings(s);
            var settings        = modifySettings != null?modifySettings(defaultSettings) : defaultSettings;

            return(settings);
        }
        protected ConnectionSettingsBase(
            IConnectionPool connectionPool,
            IConnection connection,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory,
            IPropertyMappingProvider propertyMappingProvider
            )
            : base(connectionPool, connection, null)
        {
            var defaultSerializer = new InternalSerializer(this);

            _sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer;
            UseThisRequestResponseSerializer = defaultSerializer;
            _propertyMappingProvider         = propertyMappingProvider ?? new PropertyMappingProvider();

            _defaultTypeNameInferrer  = t => !_defaultTypeName.IsNullOrEmpty() ? _defaultTypeName : t.Name.ToLowerInvariant();
            _defaultFieldNameInferrer = p => p.ToCamelCase();
            _defaultIndices           = new FluentDictionary <Type, string>();
            _defaultTypeNames         = new FluentDictionary <Type, string>();
            _defaultRelationNames     = new FluentDictionary <Type, string>();

            _inferrer = new Inferrer(this);
        }
Example #31
0
        public static ConnectionSettings CreateSettings(
            Func <ConnectionSettings, ConnectionSettings> modifySettings,
            IConnection connection,
            IConnectionPool connectionPool,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory = null,
            IPropertyMappingProvider propertyMappingProvider = null
            )
        {
            var s = new ConnectionSettings(connectionPool, connection, (builtin, values) =>
            {
                if (sourceSerializerFactory != null)
                {
                    return(sourceSerializerFactory(builtin, values));
                }

                return(!Configuration.Random.SourceSerializer
                                        ? null
                                        : new TestSourceSerializerBase(builtin, values));
            }, propertyMappingProvider);

            var defaultSettings = DefaultSettings(s);

            modifySettings = modifySettings ?? ((m) =>
            {
                //only enable debug mode when running in DEBUG mode (always) or optionally wheter we are executing unit tests
                //during RELEASE builds tests
#if !DEBUG
                if (TestClient.Configuration.RunUnitTests)
#endif
                m.EnableDebugMode();
                return(m);
            });

            var settings = modifySettings(defaultSettings);
            return(settings);
        }
        protected ConnectionSettingsBase(
            IConnectionPool connectionPool,
            IConnection connection,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory,
            IPropertyMappingProvider propertyMappingProvider
            )
            : base(connectionPool, connection, null)
        {
            var defaultSerializer = new JsonNetSerializer(this);

            this._sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer;
            this.UseThisRequestResponseSerializer = defaultSerializer;
            this._propertyMappingProvider         = propertyMappingProvider ?? new PropertyMappingProvider();

            this._defaultTypeNameInferrer  = (t => t.Name.ToLowerInvariant());
            this._defaultFieldNameInferrer = (p => p.ToCamelCase());
            this._defaultIndices           = new FluentDictionary <Type, string>();
            this._defaultTypeNames         = new FluentDictionary <Type, string>();
            this._defaultRelationNames     = new FluentDictionary <Type, string>();

            this.SerializerFactory = new StatefulSerializerFactory();

            this._inferrer = new Inferrer(this);
        }
        protected ConnectionSettingsBase(
            IConnectionPool connectionPool,
            IConnection connection,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory,
            IPropertyMappingProvider propertyMappingProvider
            )
            : base(connectionPool, connection, null)
        {
            var formatterResolver = new NestFormatterResolver(this);
            //Utf8Json.JsonSerializer.SetDefaultResolver(formatterResolver);
            var defaultSerializer = new InternalSerializer(this, formatterResolver);

            _sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer;
            UseThisRequestResponseSerializer = defaultSerializer;
            var serializerAsMappingProvider = _sourceSerializer as IPropertyMappingProvider;

            _propertyMappingProvider = propertyMappingProvider ?? serializerAsMappingProvider ?? new PropertyMappingProvider();

            _defaultFieldNameInferrer = p => p.ToCamelCase();
            _defaultIndices           = new FluentDictionary <Type, string>();
            _defaultTypeNames         = new FluentDictionary <Type, string>();
            _defaultRelationNames     = new FluentDictionary <Type, string>();
            _inferrer = new Inferrer(this);
        }
 public PropertyMapping(IPropertyMappingProvider openGeneric, PropertyInfo property)
 {
     _inner = openGeneric;
     _property = property;
 }
 /// <summary>
 /// Validates the specified property mapping provider.
 /// </summary>
 public void Visit(IPropertyMappingProvider propertyMappingProvider)
 {
     AssertTermMapped(propertyMappingProvider);
     AssertConverter(propertyMappingProvider);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DictionaryMappingProvider"/> class.
 /// </summary>
 /// <param name="key">The key mapping provider.</param>
 /// <param name="value">The value mapping provider.</param>
 /// <param name="property">The property.</param>
 public DictionaryMappingProvider(IPropertyMappingProvider property, ITermMappingProvider key, ITermMappingProvider value)
 {
     _property = property;
     _key = key;
     _value = value;
 }
 /// <summary>Initializes a new instance of the <see cref="CollectionMappingProvider" /> class.</summary>
 /// <param name="propertyMapping">The property mapping.</param>
 /// <param name="storeAs">The storage strategy.</param>
 public CollectionMappingProvider(IPropertyMappingProvider propertyMapping, StoreAs storeAs)
 {
     _propertyMapping = propertyMapping;
     ((ICollectionMappingProvider)this).StoreAs = storeAs;
 }
 private void Accept(IPropertyMappingProvider provider, IMappingProviderVisitor mappingProviderVisitor)
 {
     mappingProviderVisitor.Visit(provider);
 }
 /// <inheritdoc/>
 public bool ShouldApply(IPropertyMappingProvider target)
 {
     return target.ConverterType == null
            && typeof(IEntity).IsAssignableFrom(target.PropertyInfo.PropertyType.FindItemType());
 }
        private bool SetConverter(PropertyMapping propertyMapping, IPropertyMappingProvider provider)
        {
            bool result = false;
            if ((provider.ConverterType != null) && (!provider.ConverterType.ContainsGenericParameters) && (!provider.ConverterType.IsInterface))
            {
                propertyMapping.Converter = (INodeConverter)Activator.CreateInstance(provider.ConverterType);
                result = true;
            }

            return result;
        }
 public void Visit(IPropertyMappingProvider propertyMappingProvider)
 {
 }
 /// <inheritdoc/>
 public void Apply(IPropertyMappingProvider target)
 {
     target.ConverterType = typeof(AsEntityConverter<>).MakeGenericType(target.PropertyInfo.PropertyType.FindItemType());
 }
Example #43
0
 /// <summary>Applies property conventions to <paramref name="propertyMappingProvider"/>.</summary>
 public void Visit(IPropertyMappingProvider propertyMappingProvider)
 {
     SelectAndApplyConventions <IPropertyConvention, IPropertyMappingProvider>(propertyMappingProvider);
 }
 public void Visit(IPropertyMappingProvider propertyMappingProvider)
 {
     PropertyMappingProviders.Add(new PropertyMapping(propertyMappingProvider, _currentEntityMapping.EntityType.MakeGenericType(_genricArguments).FindProperty(propertyMappingProvider.PropertyInfo.Name)));
 }