Пример #1
0
        internal static void ProcessSetterSimpleTypes(PropertyInfoEx propEx, object parentObject, object newObjectValue, bool isNew = false)
        {
            if (isNew)
            {
                return;
            }
            string propName       = propEx.prop.Name;
            var    parentInstance = (IStateObject)parentObject;
            var    tracker        = StateManager.Current.Tracker;

            // Delta Tracking of modified property
            if (!tracker.IsDirtyModel(parentInstance))
            {
                tracker.MarkAsModified(parentInstance, propEx.propertyPositionIndex);
            }
            var stateManager = StateManager.Current;

            if (!stateManager.flagInBind)
            {
                var bindinguid     = UniqueIDGenerator.GetRelativeUniqueID(parentInstance, propName + StateManager.BindingKey);
                var bindingPointer = StateManager.Current.GetObject(bindinguid) as StateObjectPointer;
                if (bindingPointer != null)
                {
                    var bindingSurrogate = bindingPointer.Target as StateObjectSurrogate;
                    if (bindingSurrogate != null)
                    {
                        var binding = bindingSurrogate.Value as DataBinding;
                        if (binding != null)
                        {
                            var dataSource = binding.DataSourceReference;
                            if (dataSource is StateObjectSurrogate)
                            {
                                var surrogate      = (StateObjectSurrogate)dataSource;
                                var surrogateValue = surrogate.Value;
                                var setter         = SurrogatesDirectory.GetPropertySetter(surrogate.Value);
                                setter(surrogateValue, binding.DataSourceProperty, newObjectValue);
                            }
                            else
                            {
                                throw new NotImplementedException();
                            }
                        }
                    }
                }
            }
        }
 public Action <object, string, object> GetPropertySetter(object obj)
 {
     return(SurrogatesDirectory.GetPropertySetter(obj));
 }