Ejemplo n.º 1
0
 CommandMeta(TypeMeta owner, MethodInfo method, MemberMeta condition)
     : base(owner, method.Name, typeof(ICommand))
 {
     Method       = method;
     Condition    = condition;
     HasParameter = method.GetParameters().Any();
 }
Ejemplo n.º 2
0
 CommandMeta(TypeMeta owner, MethodInfo method, MemberMeta condition)
     : base(owner, method.Name, typeof(ICommand))
 {
     Method = method;
     Condition = condition;
     HasParameter = method.GetParameters().Any();
 }
Ejemplo n.º 3
0
 internal static MemberSlot Create(ViewProxy proxy, MemberMeta member)
 {
     if (member.IsCollection)
         return new CollectionSlot(proxy, member);
     else
         return new AtomSlot(proxy, member);
 }
Ejemplo n.º 4
0
        internal static MemberSlot Create(ViewProxy proxy, MemberMeta member)
        {
            if (member.IsCollection)
            {
                if (member.IsObservableCollection)
                {
                    return(new PassThroughSlot(proxy, member));
                }
                else if (member.IsList)
                {
                    return(new ListSlot(proxy, member));
                }
                else
                {
#if NETFRAMEWORK
                    if (BindingListSlot.AppliesTo(member))
                    {
                        return(new BindingListSlot(proxy, member));
                    }
                    else
                    {
                        return(new CollectionSlot(proxy, member));
                    }
#else
                    return(new CollectionSlot(proxy, member));
#endif
                }
            }
            else
            {
                return(new AtomSlot(proxy, member));
            }
        }
Ejemplo n.º 5
0
 internal static MemberMeta Intercept(MemberMeta member)
 {
     var unwrapped = UnwrapObservableType(member.MemberType, typeof(Observable<>));
     if (unwrapped != null)
         return new ObservableMeta(member, unwrapped);
     else
         return member;
 }
Ejemplo n.º 6
0
        private static Type GetElementType(MemberMeta member)
        {
            Type propType = member.MemberType;
            Type elemType = (propType.GetInterfacesPortable().Concat(new Type[] { propType })
                             .FirstOrDefault(i => i.IsGenericTypePortable() && i.GetGenericTypeDefinition() == typeof(IEnumerable <>)) ?? typeof(IEnumerable <object>))
                            .GetGenericArgumentsPortable().First();

            return(elemType);
        }
Ejemplo n.º 7
0
 internal static MemberSlot Create(ViewProxy proxy, MemberMeta member)
 {
     if (member.IsCollection)
     {
         return(new CollectionSlot(proxy, member));
     }
     else
     {
         return(new AtomSlot(proxy, member));
     }
 }
 public ProxyPropertyDescriptor(ProxyTypeDescriptor owner, MemberMeta meta)
     : base(meta.Name, null)
 {
     _owner = owner;
     _meta = meta;
     if (!meta.IsViewModel)
         _exposedType = meta.MemberType;
     else if (typeof(IEnumerable).IsAssignableFrom(meta.MemberType))
         _exposedType = typeof(IEnumerable);
     else
         _exposedType = typeof(object);
 }
Ejemplo n.º 9
0
        public BindingListSlot(ViewProxy proxy, MemberMeta member)
            : base(proxy, member)
        {
            _newItemMethod    = GetNewItemMethod(member);
            _deleteItemMethod = GetDeleteItemMethod(member);

            _bindingList.AllowNew     = true;
            _bindingList.AllowEdit    = true;
            _bindingList.AllowRemove  = true;
            _bindingList.AddingNew   += BindingList_AddingNew;
            _bindingList.ListChanged += BindingList_ListChanged;
        }
Ejemplo n.º 10
0
        internal static MemberMeta Intercept(MemberMeta member)
        {
            var unwrapped = UnwrapObservableType(member.MemberType, typeof(Observable <>));

            if (unwrapped != null)
            {
                return(new ObservableMeta(member, unwrapped));
            }
            else
            {
                return(member);
            }
        }
Ejemplo n.º 11
0
        private static MethodInfo GetNewItemMethod(MemberMeta member)
        {
            var method = member.DeclaringType.Type.GetMethodPortable($"NewItemIn{member.Name}");

            if (method != null &&
                method.GetParameters().Length == 0)
            {
                return(method);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 12
0
 protected MemberSlot(ViewProxy proxy, MemberMeta member)
 {
     Proxy = proxy;
     Member = member;
     if (member.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _computed = new Computed(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Ejemplo n.º 13
0
 protected MemberSlot(ViewProxy proxy, MemberMeta member)
 {
     Proxy  = proxy;
     Member = member;
     if (member.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _computed = new Computed(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Ejemplo n.º 14
0
        private MethodInfo GetDeleteItemMethod(MemberMeta member)
        {
            var method = member.DeclaringType.Type.GetMethodPortable($"DeleteItemFrom{member.Name}");

            if (method != null &&
                method.GetParameters().Length == 1 &&
                method.GetParameters()[0].ParameterType == GetElementType(member))
            {
                return(method);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 15
0
        public ListSlot(ViewProxy proxy, MemberMeta member)
            : base(proxy, member)
        {
            _collectionChangedFromUIEventHandler = new NotifyCollectionChangedEventHandler((s, e) =>
            {
                if (!_publishingChanges)
                {
                    switch (e.Action)
                    {
                    case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                        foreach (var item in e.NewItems)
                        {
                            _sourceCollection.Add(UnwrapValue(item));
                        }
                        _computed.MakeDependentsOutOfDate();
                        break;

                    case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                        foreach (var item in e.OldItems)
                        {
                            _sourceCollection.Remove(UnwrapValue(item));
                        }
                        _computed.MakeDependentsOutOfDate();
                        break;

                    case NotifyCollectionChangedAction.Reset:
                        _sourceCollection.Clear();
                        _computed.MakeDependentsOutOfDate();
                        break;

                    default:
                        break;
                    }

                    if (Proxy.IsNotifying)
                    {
                        // The view is modifying the list in response to another update.
                        // After it stops, notify it of other changes so that it can get the correct list.
                        Proxy.WasModified(this);
                    }
                }
            });
        }
Ejemplo n.º 16
0
 protected ValuePropertyMeta(MemberMeta observable, Type unwrappedType)
     : base(observable.DeclaringType, observable.Name, unwrappedType)
 {
     UnderlyingMember = observable;
     _valueProperty   = observable.MemberType.GetPropertyPortable("Value");
 }
Ejemplo n.º 17
0
 ObservableMeta(MemberMeta observable, Type unwrappedType)
     : base(observable, unwrappedType)
 {
 }
Ejemplo n.º 18
0
 public MemberSlot LookupSlot(MemberMeta member)
 {
     return(_slots.FirstOrDefault(s => s.Member == member));
 }
Ejemplo n.º 19
0
 internal AtomSlot(ViewProxy proxy, MemberMeta member)
     : base(proxy, member)
 {
 }
Ejemplo n.º 20
0
 internal AtomSlot(ViewProxy proxy, MemberMeta member)
     : base(proxy, member)
 {
 }
Ejemplo n.º 21
0
 public PassThroughSlot(ViewProxy proxy, MemberMeta member) : base(proxy, member)
 {
 }
Ejemplo n.º 22
0
 public CollectionSlot(ViewProxy proxy, MemberMeta member)
     : base(proxy, member)
 {
 }
Ejemplo n.º 23
0
 public ProxyXamlMember(IXamlType owner, MemberMeta meta)
 {
     _owner = owner;
     _meta = meta;
 }
Ejemplo n.º 24
0
 ObservableMeta(MemberMeta observable, Type unwrappedType)
     : base(observable, unwrappedType)
 {
 }
Ejemplo n.º 25
0
 internal static MemberMeta InterceptAny(MemberMeta member)
 {
     return(ComputedMeta.Intercept(ObservableMeta.Intercept(member)));
 }
Ejemplo n.º 26
0
 public static bool AppliesTo(MemberMeta member)
 {
     return(GetNewItemMethod(member) != null);
 }