CommandMeta(TypeMeta owner, MethodInfo method, MemberMeta condition) : base(owner, method.Name, typeof(ICommand)) { Method = method; Condition = condition; HasParameter = method.GetParameters().Any(); }
internal static MemberSlot Create(ViewProxy proxy, MemberMeta member) { if (member.IsCollection) return new CollectionSlot(proxy, member); else return new AtomSlot(proxy, member); }
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)); } }
internal static MemberMeta Intercept(MemberMeta member) { var unwrapped = UnwrapObservableType(member.MemberType, typeof(Observable<>)); if (unwrapped != null) return new ObservableMeta(member, unwrapped); else return member; }
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); }
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); }
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; }
internal static MemberMeta Intercept(MemberMeta member) { var unwrapped = UnwrapObservableType(member.MemberType, typeof(Observable <>)); if (unwrapped != null) { return(new ObservableMeta(member, unwrapped)); } else { return(member); } }
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); } }
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); } }
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); } }
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); } } }); }
protected ValuePropertyMeta(MemberMeta observable, Type unwrappedType) : base(observable.DeclaringType, observable.Name, unwrappedType) { UnderlyingMember = observable; _valueProperty = observable.MemberType.GetPropertyPortable("Value"); }
ObservableMeta(MemberMeta observable, Type unwrappedType) : base(observable, unwrappedType) { }
public MemberSlot LookupSlot(MemberMeta member) { return(_slots.FirstOrDefault(s => s.Member == member)); }
internal AtomSlot(ViewProxy proxy, MemberMeta member) : base(proxy, member) { }
public PassThroughSlot(ViewProxy proxy, MemberMeta member) : base(proxy, member) { }
public CollectionSlot(ViewProxy proxy, MemberMeta member) : base(proxy, member) { }
public ProxyXamlMember(IXamlType owner, MemberMeta meta) { _owner = owner; _meta = meta; }
internal static MemberMeta InterceptAny(MemberMeta member) { return(ComputedMeta.Intercept(ObservableMeta.Intercept(member))); }
public static bool AppliesTo(MemberMeta member) { return(GetNewItemMethod(member) != null); }