public static void AddMethod <TArg1, TArg2, TResult>([NotNull] this IBindingResourceResolver resolver, [NotNull] string name, [NotNull] Func <TArg1, TArg2, IDataContext, TResult> method, bool rewrite = true) { Should.NotBeNull(resolver, nameof(resolver)); resolver.AddMethod(name, new BindingResourceMethod(method.AsResourceMethodDelegate, typeof(TResult)), rewrite); }
public static void AddType([NotNull] this IBindingResourceResolver resolver, [NotNull] Type type, bool rewrite = true) { Should.NotBeNull(resolver, nameof(resolver)); resolver.AddType(type.Name, type, rewrite); resolver.AddType(type.FullName, type, rewrite); }
public static void Initialize(IBindingProvider bindingProvider = null, IBindingManager bindingManager = null, IBindingResourceResolver resourceResolver = null, IBindingMemberProvider memberProvider = null, IVisualTreeManager visualTreeManager = null, IWeakEventManager weakEventManager = null, IObserverProvider observerProvider = null, IBindingContextManager contextManager = null, IBindingErrorProvider errorProvider = null, Func <IBindingMemberInfo, Type, object, object> converter = null, Func <string, IBindingPath> bindingPathFactory = null, Func <Type, string, IBindingMemberInfo> findUpdateEvent = null, Func <CultureInfo> bindingCultureInfo = null, IDictionary <string, IBindingBehavior> bindingModeBehaviors = null) { ValueConverter = converter ?? ((info, type, arg3) => arg3); BindingProvider = bindingProvider ?? new BindingProvider(); BindingManager = bindingManager ?? new BindingManager(); ResourceResolver = resourceResolver ?? new BindingResourceResolver(); MemberProvider = memberProvider ?? new BindingMemberProvider(); VisualTreeManager = visualTreeManager ?? new VisualTreeManager(); WeakEventManager = weakEventManager ?? new WeakEventManager(); ObserverProvider = observerProvider ?? new ObserverProvider(); ContextManager = contextManager ?? new BindingContextManager(); BindingPathFactory = bindingPathFactory ?? BindingPathFactoryDefaultImpl; UpdateEventFinder = findUpdateEvent ?? FindUpdateEventDefaultImpl; BindingCultureInfo = bindingCultureInfo ?? BindingCultureInfoDefaultImpl; ErrorProvider = errorProvider; if (bindingModeBehaviors == null) { InitializeDefaultBindingModeBehaviors(); } else { foreach (var behavior in bindingModeBehaviors) { BindingModeToBehavior[behavior.Key] = behavior.Value; } } }
public BindingResourcesViewModel() { IBindingResourceResolver resourceResolver = BindingServiceProvider.ResourceResolver; resourceResolver.AddObject("obj", new BindingResourceObject("String value")); resourceResolver.AddMethod("Method", new BindingResourceMethod(Method, typeof(object))); resourceResolver.AddType("CustomType", typeof(BindingResourcesViewModel)); }
public static BindingResourceObject AddObject([NotNull] this IBindingResourceResolver resolver, [NotNull] string name, object value, bool rewrite = true) { Should.NotBeNull(resolver, nameof(resolver)); var resourceObject = new BindingResourceObject(value); resolver.AddObject(name, resourceObject, rewrite); return(resourceObject); }
/// <summary> /// Loads the current module. /// </summary> protected override bool LoadInternal() { IBindingResourceResolver resolver = BindingServiceProvider.ResourceResolver; resolver.AddObject("buttonTemplate", new BindingResourceObject(new ButtonItemTemplate())); resolver.AddObject("tabItemTemplate", new BindingResourceObject(new TabItemTemplate())); resolver.AddObject("tableLayoutCollectionManager", new BindingResourceObject(new TableLayoutCollectionViewManager())); resolver.AddObject("contentViewManager", new BindingResourceObject(new ContentViewManager())); return(true); }
internal static void SetDefaultValues() { _valueConverter = BindingReflectionExtensions.Convert; _resourceResolver = new BindingResourceResolver(); _memberProvider = new BindingMemberProvider(); _visualTreeManager = new VisualTreeManager(); _weakEventManager = new WeakEventManager(); _bindingManager = new BindingManager(); _bindingProvider = new BindingProvider(); _observerProvider = new ObserverProvider(); _contextManager = new BindingContextManager(); }
/// <summary> /// Tries to add the specified converter /// </summary> public static bool TryAddConverter([CanBeNull] this IBindingResourceResolver resourceResolver, [NotNull] string name, [NotNull] IBindingValueConverter converter) { if (resourceResolver == null) { return(false); } if (resourceResolver.ResolveConverter(name, DataContext.Empty, false) != null) { return(false); } resourceResolver.AddConverter(name, converter, true); return(true); }
/// <summary> /// Loads the current module. /// </summary> protected override bool LoadInternal() { IBindingResourceResolver resolver = BindingServiceProvider.ResourceResolver; resolver.AddObject("buttonTemplate", new BindingResourceObject(new ButtonItemTemplateSelector())); resolver.AddObject("cellDataTemplate", new BindingResourceObject(new TableCellTemplateSelector())); resolver.AddObject("tabDataTemplate", new BindingResourceObject(new TabTemplateSelector())); resolver.AddObject("collectionViewCellTemplate", new BindingResourceObject(new CollectionViewCellTemplateSelector())); resolver.AddObject("collectionViewManager", new BindingResourceObject(new CollectionViewManager())); resolver.AddObject("labelItemTemplate", new BindingResourceObject(new LabelItemTemplateSelector())); resolver.AddObject("contentViewManager", new BindingResourceObject(new ContentViewManager())); return(true); }
internal static void SetDefaultValues() { BindingCultureInfo = null; _updateEventFinder = FindUpdateEvent; _bindingPathFactory = BindingPath.Create; _valueConverter = BindingReflectionExtensions.Convert; _resourceResolver = new BindingResourceResolver(); _memberProvider = new BindingMemberProvider(); _visualTreeManager = new VisualTreeManager(); _weakEventManager = new WeakEventManager(); _bindingManager = new BindingManager(); _bindingProvider = new BindingProvider(); _observerProvider = new ObserverProvider(); _contextManager = new BindingContextManager(); }
public static void AddConverter([NotNull] this IBindingResourceResolver resolver, [NotNull] IBindingValueConverter converter, Type type = null, bool rewrite = true) { Should.NotBeNull(resolver, nameof(resolver)); Should.NotBeNull(converter, nameof(converter)); if (type == null) { type = converter.GetType(); } string name = RemoveTail(RemoveTail(RemoveTail(type.Name, "BindingValueConverter"), "ValueConverter"), "Converter"); resolver.AddConverter(name, converter, rewrite); if (name != type.Name) { resolver.AddConverter(type.Name, converter, rewrite); } }
protected override bool LoadInternal() { if (Mode != LoadMode.Design) { IocContainer.BindToConstant <IRepository>(new FileRepository()); } IBindingResourceResolver resourceResolver = BindingServiceProvider.ResourceResolver; IBindingMemberProvider memberProvider = BindingServiceProvider.MemberProvider; //Registering tab template resource. resourceResolver.AddObject("tabTemplate", new BindingResourceObject(new ViewModelTabDataTemplate())); //Registering content manager to set content value in code-behind. resourceResolver.AddObject("editorContentManager", new BindingResourceObject(new WrapperContentManager())); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <Control, bool>("IsBusy", IsBusyChanged)); memberProvider.Register(AttachedBindingMember.CreateAutoProperty <Control, object>("BusyMessage", BusyMessageChanged)); return(true); }
internal static void SetDefaultValues() { BindingCultureInfo = null; _updateEventFinder = FindUpdateEvent; _bindingPathFactory = BindingPath.Create; _valueConverter = BindingReflectionExtensions.Convert; _resourceResolver = new BindingResourceResolver(); _memberProvider = new BindingMemberProvider(); _visualTreeManager = new VisualTreeManager(); _weakEventManager = new WeakEventManager(); _bindingManager = new BindingManager(); _bindingProvider = new BindingProvider(); _observerProvider = new ObserverProvider(); _contextManager = new BindingContextManager(); }