private void applyToProperty(object model, PropertyInfo property, IBindManager binder, string prefix, string remainder)
 {
     // If (after taking the prefix into account) this is a complex property change
     // Recurse, using the object referred to by the first part of the property name
     // as the new model to apply the change to.
     if (split(remainder).Count() > 1)
     {
         var value = getValue(model, property);
         applyTo(value, binder, property.PropertyType, ExpressionHelper.Join(prefix, property.Name));
     }
     // Otherwise, if we are now at a simple property change, just bind the value
     // and set the appropriate property
     else
     {
         var existingValue = property.GetValue(model, null);
         var value         = binder.Bind(wrapped.Value, property.PropertyType, existingValue);
         if (isEntityCollection(property) && existingValue != null)
         {
             // do nothing, its contents were already updated by the binder,
             // and it's an error to use the property setter for an entity collection
         }
         else
         {
             property.SetValue(model, value, null);
         }
     }
 }
예제 #2
0
 public CollectionTranslator(IBindManager bindManager,
                             ISerializationManager serializationManager, IHistoryContext db)
 {
     this.bindManager          = bindManager;
     this.serializationManager = serializationManager;
     this.db = db;
 }
예제 #3
0
 public HistoryExplorer(IHistoryContext<TChangeSet, TPrincipal> historyContext, IBindManager binder = null, 
     HistoryExplorerCloneStrategies cloneStrategy = HistoryExplorerCloneStrategies.Default)
 {
     this.binder = (binder ?? new ValueTranslationManager(historyContext));
     this.cloneStrategy = cloneStrategy;
     this.historyContext = historyContext;
 }
예제 #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataProvider">DataProvider</param>
        /// <param name="planManager">Execute plan Manager</param>
        /// <param name="bindManager">Bind Manager</param>
        /// <param name="mappingManager">Mapping Manager</param>
        /// <param name="typeRegister">Types register</param>
        public GenericDomainsRepository(IDataProvider dataProvider, IExecutionPlanManager planManager,
                                        IBindManager bindManager, IMappingManager mappingManager,
                                        ITypeRegister typeRegister)
        {
            this._dataProvider   = dataProvider;
            this._planManager    = planManager;
            this._bindManager    = bindManager;
            this._mappingManager = mappingManager;
            this._typeRegister   = typeRegister;

            this._mapedType = this._mappingManager.GetMapping(typeof(T));
        }
        private void applyTo(object model, IBindManager binder, Type modelType, string prefix)
        {
            string remainder     = stripPrefix(prefix);
            var    propertyParts = split(remainder);
            string propertyName  = propertyParts.First();

            var property = modelType.GetProperty(propertyName, BindingFlags.Public
                                                 | BindingFlags.NonPublic | BindingFlags.Instance);

            if (property != null)
            {
                applyToProperty(model, property, binder, prefix, remainder);
            }
            else
            {
                throw new UnknownPropertyInLogException <TPrincipal>(wrapped);
            }
        }
 /// <summary>
 /// Apply the property change to the given model.
 /// So if the IPropertyChange has property name "Foo", then model.Foo
 /// will be set to the bound value of the IPropertyChange's value.
 /// </summary>
 /// <param name="prefix">
 /// The prefix is used to apply a property change to an object that is an intermediate
 /// part of a complex property change. For example, if you have a property change
 /// "Foo.Bar", that relates to an object change on an object of type Example. To
 /// apply the property change directly to the Example object, you would use an empty
 /// prefix: "". However, if you instead had the object referenced by Example.Foo, you
 /// could apply the property change directly to Foo, by using the prefix "Foo". Then,
 /// this method will treat the property change as if it's name were just "Bar",
 /// removing the "Foo." prefix.
 /// </param>
 public void ApplyTo <TModel>(TModel model, IBindManager binder, string prefix)
 {
     applyTo(model, binder, typeof(TModel), prefix);
 }
예제 #7
0
 public NullableBinder(IBindManager bindManager)
 {
     this.bindManager = bindManager;
 }
예제 #8
0
 public NullableBinder(IBindManager bindManager)
 {
     this.bindManager = bindManager;
 }