public IValueTypeMergingStrategy Create(ValueTypeMergingStrategy strategyType)
 {
     return(_createStrategyIsCalled?.Invoke() ??
            new ValueTypeMergingStrategyMock(
                _markValueTypePropertyAsDirtyIsCalled,
                _notifyEntityWasReadIsCalled,
                _notifyEntityWasWrittenIsCalled,
                _getEntityPropertyIsCalled));
 }
        /// <summary>
        /// Registers the given <paramref name="strategy"/> for the given entity type <paramref name="type"/>
        /// </summary>
        /// <param name="type">Entuty type</param>
        /// <param name="strategy">Value type merging strategy</param>
        public ImperativeMetamodelProvider UseValueTypesMergingStrategy(Type type, ValueTypeMergingStrategy strategy)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (!typeof(AzureTableEntity).IsAssignableFrom(type))
            {
                throw new ArgumentException($"The type {type} should be descendant of the {typeof(AzureTableEntity)}");
            }

            _valueTypeMergingStrategies = _valueTypeMergingStrategies.Add(type, strategy);

            return(this);
        }
        public IValueTypeMergingStrategy Create(ValueTypeMergingStrategy strategyType)
        {
            switch (strategyType)
            {
            case ValueTypeMergingStrategy.Forbid:
                return(new ForbidValueTypeMergingStrategy());

            case ValueTypeMergingStrategy.UpdateAlways:
                return(new UpdateAlwaysValueTypeMergingStrategy());

            case ValueTypeMergingStrategy.UpdateIfDirty:
                return(new UpdateIfDirtyValueTypeMergingStrategy());

            default:
                throw new ArgumentOutOfRangeException(nameof(strategyType), strategyType, null);
            }
        }
 /// <summary>
 /// Registers the given <paramref name="strategy"/> for the given entity type <typeparamref name="TEntity"/>
 /// </summary>
 /// <typeparam name="TEntity">Entity type</typeparam>
 /// <param name="strategy">Value type merging strategy</param>
 public ImperativeMetamodelProvider UseValueTypesMergingStrategy <TEntity>(ValueTypeMergingStrategy strategy)
     where TEntity : AzureTableEntity
 {
     return(UseValueTypesMergingStrategy(typeof(TEntity), strategy));
 }
예제 #5
0
 /// <summary>
 /// Marks an entity type to use specific <see cref="ValueTypeMergingStrategy"/>
 /// when performing InsertOrMerge operation
 /// </summary>
 public ValueTypeMergingStrategyAttribute(ValueTypeMergingStrategy strategy)
 {
     Strategy = strategy;
 }