public ObjectPropertyCollection(IObjectInstance objectInstance, ClassProperty classProperty)
            : base(objectInstance, classProperty)
        {
            if (ClassProperty.CanRead)
            {
                // When the collection is out of date, update it from the wrapped object.
                _depCollection = new Dependent(OnUpdateCollection);

                // When the property becomes out of date, trigger an update.
                _depCollection.Invalidated += TriggerUpdate;
            }
        }
        public ObjectPropertyCollection(IObjectInstance objectInstance, ClassProperty classProperty, bool hasChildObjects)
            : base(objectInstance, classProperty)
        {
            _hasChildObjects = hasChildObjects;

            if (ClassProperty.CanRead)
            {
                // Bind to the observable collection.
                ClassProperty.SetUserOutput(ObjectInstance, _collection);

                // When the collection is out of date, update it from the wrapped object.
                _depCollection = new Dependent(OnUpdateCollection);
            }
        }
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Dependent(delegate
         {
             object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
             value = TranslateOutgoingValue(value);
             if (!Object.Equals(_value, value))
                 _value = value;
             if (_firePropertyChanged)
                 ObjectInstance.FirePropertyChanged(ClassProperty.Name);
             _firePropertyChanged = true;
         });
         // When the property becomes out of date, trigger an update.
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     }
 }
        protected override void SetValue(object value)
        {
            // Use reflection to convert the collection to the ViewModel type
            // (which must be compatible with List<T>, e.g. IEnumerable<T> or IList)
            if (_translateIncomingList == null)
            {
                Type propType = ClassProperty.UnderlyingType;
                Type elemType = (propType.GetInterfaces().Concat(new Type[] { propType })
                                 .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable <>)) ?? typeof(IEnumerable <object>))
                                .GetGenericArguments()[0];
                MethodInfo mi = GetType().GetMethod("TranslateIncomingList").MakeGenericMethod(new Type[] { elemType });
                _translateIncomingList = (Func <IEnumerable, IEnumerable>)Delegate.CreateDelegate(typeof(Func <IEnumerable, IEnumerable>), this, mi);
            }
            value = _translateIncomingList((IEnumerable)value);
            ClassProperty.SetObjectValue(ObjectInstance.WrappedObject, value);

            // If the UI object switches to a new collection, we can expect it to
            // cancel its subscription to _collection.CollectionChanged and subscribe
            // to the new collection instead. So let's adopt the collection as our
            // own, if it happens to be ObservableCollection<object>.
            _collection = value as ObservableCollection <object>;
        }
Esempio n. 5
0
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Dependent(delegate
         {
             object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
             value        = TranslateOutgoingValue(value);
             if (!Object.Equals(_value, value))
             {
                 _value = value;
             }
             if (_firePropertyChanged)
             {
                 ObjectInstance.FirePropertyChanged(ClassProperty.Name);
             }
             _firePropertyChanged = true;
         });
         // When the property becomes out of date, trigger an update.
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     }
 }
 public ObjectPropertyAtomNative(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
 }
 public ObjectPropertyCollectionObject(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
 }
Esempio n. 8
0
 public ObjectProperty LookupProperty(ClassProperty classProperty)
 {
     return(_properties.Single(p => p.ClassProperty == classProperty));
 }
Esempio n. 9
0
 public static ObjectProperty From(IObjectInstance objectInstance, ClassProperty classProperty)
 {
     return(classProperty.MakeObjectProperty(objectInstance));
 }
Esempio n. 10
0
 public ObjectProperty(IObjectInstance objectInstance, ClassProperty classProperty)
 {
     ObjectInstance = objectInstance;
     ClassProperty  = classProperty;
 }
Esempio n. 11
0
 public static ObjectProperty From(IObjectInstance objectInstance, ClassProperty classProperty)
 {
     return classProperty.MakeObjectProperty(objectInstance);
 }
Esempio n. 12
0
 public ObjectProperty(IObjectInstance objectInstance, ClassProperty classProperty)
 {
     ObjectInstance = objectInstance;
     ClassProperty = classProperty;
 }
 public ObjectPropertyCollectionNative(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
 }
 public ObjectPropertyAtomNative(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
 }