static AttachedMembersRegistration()
 {
     DebbugerAttached         = Debugger.IsAttached;
     ExplicitParentTypes      = new HashSet <Type>();
     CommandParameterInternal = AttachedBindingMember.CreateAutoProperty <object, object>("~#@cmdparam");
     AttachedParentMember     = AttachedBindingMember.CreateAutoProperty <object, ParentValue>("#" + AttachedMemberConstants.Parent);
 }
Ejemplo n.º 2
0
        public void BindingTargetShouldUseDelegateIsEnabledProperty()
        {
            bool isEnabled = false;
            IAttachedBindingMemberInfo <object, bool> member =
                AttachedBindingMember.CreateMember <object, bool>(AttachedMemberConstants.Enabled,
                                                                  (info, o) => isEnabled,
                                                                  (info, o, v) => isEnabled = v);
            var memberProvider = new BindingMemberProvider();

            memberProvider.Register(typeof(object), member, false);
            BindingServiceProvider.MemberProvider = memberProvider;

            var mock = new ObserverMock {
                PathMembers = new BindingPathMembersMock(new object(), BindingPath.Empty)
            };
            var bindingTarget = (BindingTarget)CreateBindingSource(mock);

            bindingTarget.IsEnabled.ShouldBeFalse();
            bindingTarget.IsEnabled = true;
            isEnabled.ShouldBeTrue();
            bindingTarget.IsEnabled.ShouldBeTrue();

            bindingTarget.IsEnabled = false;
            isEnabled.ShouldBeFalse();
            bindingTarget.IsEnabled.ShouldBeFalse();
        }
Ejemplo n.º 3
0
        static PlatformDataBindingModule()
        {
            AddViewValue    = new object();
            RemoveViewValue = new object[] { null };
            //Menu
            MenuItemsSourceMember   = AttachedBindingMember.CreateAutoProperty <IMenu, IEnumerable>(AttachedMemberConstants.ItemsSource, MenuItemsSourceChanged);
            IsCheckedMenuItemMember = AttachedBindingMember.CreateNotifiableMember <IMenuItem, bool>("IsChecked",
                                                                                                     (info, item) => item.IsChecked, (info, item, value) =>
            {
                if (value == item.IsChecked)
                {
                    return(false);
                }
                item.SetChecked(value);
                return(true);
            });
#if !API8
            MenuItemActionViewMember = AttachedBindingMember
                                       .CreateNotifiableMember <IMenuItem, object>("ActionView", (info, item) => item.GetActionView(), MenuItemUpdateActionView);
            MenuItemActionViewSelectorMember = AttachedBindingMember
                                               .CreateAutoProperty <IMenuItem, IDataTemplateSelector>("ActionViewTemplateSelector", (o, args) => RefreshValue(o, MenuItemActionViewMember));

            MenuItemActionProviderMember = AttachedBindingMember
                                           .CreateNotifiableMember <IMenuItem, object>("ActionProvider", (info, item) => item.GetActionProvider(), MenuItemUpdateActionProvider);
            MenuItemActionProviderSelectorMember = AttachedBindingMember
                                                   .CreateAutoProperty <IMenuItem, IDataTemplateSelector>("ActionProviderTemplateSelector", (o, args) => RefreshValue(o, MenuItemActionProviderMember));

            AddToBackStackMember = AttachedBindingMember.CreateAutoProperty <ViewGroup, bool>("AddToBackStack");
#endif
            //ViewGroup
            ContentMember = AttachedBindingMember
                            .CreateAutoProperty <ViewGroup, object>(AttachedMemberConstants.Content, ContentMemberChanged, ContentMemberAttached);
            ContentTemplateIdMember = AttachedBindingMember
                                      .CreateAutoProperty <ViewGroup, int?>(AttachedMemberConstants.ContentTemplate, ContentTemplateIdChanged);
            ContentTemplateSelectorMember = AttachedBindingMember
                                            .CreateAutoProperty <ViewGroup, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplateSelector, ContentTemplateSelectorChanged);

            //AdapterView
            AdapterViewSelectedPositionMember =
                AttachedBindingMember.CreateAutoProperty <AdapterView, int>("SelectedItemPosition",
                                                                            AdapterViewSelectedItemPositionChanged, AdapterViewSelectedMemberAttached, (view, info) => view.SelectedItemPosition);
            AdapterViewSelectedItemMember = AttachedBindingMember.CreateAutoProperty <AdapterView, object>(
                AttachedMemberConstants.SelectedItem, AdapterViewSelectedItemChanged);
            ScrollToSelectedItemMember = AttachedBindingMember.CreateAutoProperty <AdapterView, bool>("ScrollToSelectedItem");

            //TabHost
            TabHostSelectedItemMember = AttachedBindingMember.CreateAutoProperty <TabHost, object>(AttachedMemberConstants.SelectedItem, TabHostSelectedItemChanged);

#if !API8
            //Action bar
            ActionBarItemsSourceMember  = AttachedBindingMember.CreateAutoProperty <ActionBar, IEnumerable>(AttachedMemberConstants.ItemsSource, (bar, args) => ActionBarUpdateItemsSource(bar));
            ActionBarSelectedItemMember = AttachedBindingMember.CreateAutoProperty <ActionBar, object>(AttachedMemberConstants.SelectedItem, ActionBarSelectedItemChanged);
            //Context action bar
            ActionBarContextActionBarTemplateMember = AttachedBindingMember.CreateAutoProperty <ActionBar, int?>("ContextActionBarTemplate");
            ActionBarContextActionBarVisibleMember  = AttachedBindingMember.CreateAutoProperty <ActionBar, bool>("ContextActionBarVisible", ActionBarContextActionBarVisibleChanged);

            //ActioBar.Tab
            ActionBarTabContentMember = AttachedBindingMember.CreateAutoProperty <ActionBar.Tab, object>(AttachedMemberConstants.Content);
#endif
        }
Ejemplo n.º 4
0
 public static void Register <TTarget, TType>([NotNull] this IBindingMemberProvider memberProvider, string path,
                                              [NotNull] IAttachedBindingMemberInfo <TTarget, TType> member, bool rewrite = true)
     where TTarget : class
 {
     Should.NotBeNull(memberProvider, nameof(memberProvider));
     memberProvider.Register(typeof(TTarget), path, member, rewrite);
 }
        static PlatformDataBindingModule()
        {
            //Object
            ItemsSourceMember           = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged);
            CollectionViewManagerMember = AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>("CollectionViewManager");
            ContentViewManagerMember    = AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>("ContentViewManager");

            //Control
            ContentMember         = AttachedBindingMember.CreateAutoProperty <Control, object>(AttachedMemberConstants.Content, ContentChanged);
            ContentTemplateMember = AttachedBindingMember.CreateAutoProperty <Control, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplate, ContentTemplateChanged);
        }
        public static bool TrySetRaiseAction <TTarget, TType>(IAttachedBindingMemberInfo <TTarget, TType> bindingMember,
                                                              [NotNull] Action <IBindingMemberInfo, TTarget, object> raiseAction) where TTarget : class
        {
            Should.NotBeNull(raiseAction, nameof(raiseAction));
            var memberInternal = bindingMember as AttachedBindingMemberInfo <TTarget, TType>;

            if (memberInternal == null || memberInternal.RaiseAction != null)
            {
                return(false);
            }
            memberInternal.RaiseAction = raiseAction;
            return(true);
        }
        public void AutoPropertyTest()
        {
            var          source = new BindingSourceModel();
            const string path   = "path";
            Type         type   = typeof(string);
            IAttachedBindingMemberInfo <object, object> property = AttachedBindingMember.CreateAutoProperty(path, type);

            property.Path.ShouldEqual(path);
            property.Type.ShouldEqual(type);
            property.CanRead.ShouldBeTrue();
            property.CanWrite.ShouldBeTrue();
            property.Member.ShouldBeNull();
            property.MemberType.ShouldEqual(BindingMemberType.Attached);

            property.GetValue(source, null).ShouldBeNull();
            property.SetValue(source, new object[] { path });
            property.GetValue(source, null).ShouldEqual(path);
        }
        public void AutoPropertyMemberChangeTest()
        {
            bool         isInvoked = false;
            var          source    = new BindingSourceModel();
            const string path      = "path";
            IAttachedBindingMemberInfo <object, object> property = AttachedBindingMember.CreateAutoProperty(path, typeof(string),
                                                                                                            (o, args) =>
            {
                isInvoked = true;
                o.ShouldEqual(source);
                args.OldValue.ShouldBeNull();
                args.NewValue.ShouldEqual(path);
            });

            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            property.SetValue(source, new object[] { path });
            isInvoked.ShouldBeFalse();
        }
Ejemplo n.º 9
0
        public void AccessorShouldToggleEnabledFalse()
        {
            bool canExecute = false;
            bool isInvoked  = false;
            var  parameter  = new object();
            var  command    = new RelayCommand(o => { }, o =>
            {
                o.ShouldEqual(parameter);
                isInvoked = true;
                return(canExecute);
            }, this);
            bool isEnabled = true;
            IAttachedBindingMemberInfo <object, bool> member =
                AttachedBindingMember.CreateMember <object, bool>(AttachedMemberConstants.Enabled,
                                                                  (info, o) => isEnabled,
                                                                  (info, o, v) => isEnabled = v);
            var memberProvider = new BindingMemberProvider();

            memberProvider.Register(typeof(object), member, false);
            BindingServiceProvider.MemberProvider = memberProvider;

            var srcAccessor = new BindingSourceAccessorMock();
            var source      = new BindingSourceModel();
            var accessor    = GetAccessor(source, BindingSourceModel.EventName, new DataContext(BindingBuilderConstants.ToggleEnabledState.ToValue(false)), false, d => parameter);

            srcAccessor.GetValue = (info, context, arg3) => command;

            isEnabled.ShouldBeTrue();
            accessor.SetValue(srcAccessor, EmptyContext, true);
            isInvoked.ShouldBeFalse();
            isEnabled.ShouldBeTrue();

            isInvoked  = false;
            canExecute = true;
            command.RaiseCanExecuteChanged();
            isInvoked.ShouldBeFalse();
            isEnabled.ShouldBeTrue();
        }
Ejemplo n.º 10
0
 static VisualTreeManager()
 {
     RootMember = AttachedBindingMember.CreateMember <object, object>(AttachedMemberConstants.RootElement, GetRootElement, null, ObserveRootElement);
 }
 static WinFormsModule()
 {
     BusyViewMember = AttachedBindingMember.CreateAutoProperty<Control, BusyIndicator>("#busyView",
         getDefaultValue: (control, info) => new BusyIndicator());
 }
 static VisualTreeManager()
 {
     RootMember = AttachedBindingMember.CreateMember<object, object>(AttachedMemberConstants.RootElement, GetRootElement, null, ObserveRootElement);
 }
Ejemplo n.º 13
0
 static AndroidModule()
 {
     ProgressDialogAttachedProperty = AttachedBindingMember.CreateAutoProperty <View, ProgressDialog>("pd");
 }
 static AndroidModule()
 {
     ProgressDialogAttachedProperty = AttachedBindingMember.CreateAutoProperty<View, ProgressDialog>("pd");
 }
Ejemplo n.º 15
0
 static DataBindingModule()
 {
     DebbugerAttached         = Debugger.IsAttached;
     ImplicitParentTypes      = new HashSet <Type>();
     CommandParameterInternal = AttachedBindingMember.CreateAutoProperty <object, object>("~#@cmdparam");
 }
 static MvvmFragmentMediator()
 {
     FragmentViewMember = AttachedBindingMember.CreateAutoProperty <View, Fragment>("!$fragment");
     CurrentFragment    = DataConstant.Create(() => CurrentFragment, true);
 }
 static DataBindingModule()
 {
     DebbugerAttached = Debugger.IsAttached;
     ExplicitParentTypes = new HashSet<Type>();
     CommandParameterInternal = AttachedBindingMember.CreateAutoProperty<object, object>("~#@cmdparam");
     AttachedParentMember = AttachedBindingMember.CreateAutoProperty<object, ParentValue>("#" + AttachedMemberConstants.Parent);
 }
Ejemplo n.º 18
0
 public static void Register <TTarget, TType>([NotNull] this IBindingMemberProvider memberProvider,
                                              [NotNull] IAttachedBindingMemberInfo <TTarget, TType> member, bool rewrite = true)
     where TTarget : class
 {
     memberProvider.Register(member.Path, member, rewrite);
 }
Ejemplo n.º 19
0
 static TouchModule()
 {
     BusyViewMember = AttachedBindingMember.CreateAutoProperty <UIView, LoadingOverlay>("#busyView",
                                                                                        getDefaultValue: CreateLoadingOverlay);
 }
        static PlatformDataBindingModule()
        {
            SelecectedControllerChangedHandler = TabBarOnViewControllerSelected;

            //Object
            ItemsSourceMember           = AttachedBindingMember.CreateAutoProperty <object, IEnumerable>(AttachedMemberConstants.ItemsSource, ObjectItemsSourceChanged);
            CollectionViewManagerMember = AttachedBindingMember.CreateAutoProperty <object, ICollectionViewManager>("CollectionViewManager");
            ContentViewManagerMember    = AttachedBindingMember.CreateAutoProperty <object, IContentViewManager>("ContentViewManager");

            //UIView
            ContentMember         = AttachedBindingMember.CreateAutoProperty <UIView, object>(AttachedMemberConstants.Content, ContentChanged);
            ContentTemplateMember = AttachedBindingMember.CreateAutoProperty <UIView, IDataTemplateSelector>(AttachedMemberConstants.ContentTemplate, ContentTemplateChanged);

            //UITableView
            TableViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UITableView>("SelectedItemChanged");

            TableViewReadOnlyMember         = AttachedBindingMember.CreateAutoProperty <UITableView, bool>("ReadOnly");
            TableViewUseAnimationsMember    = AttachedBindingMember.CreateAutoProperty <UITableView, bool?>("UseAnimations");
            TableViewCellBindMember         = AttachedBindingMember.CreateAutoProperty <UITableView, Action <UITableViewCell> >("CellBind");
            TableViewAddAnimationMember     = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("AddAnimation");
            TableViewRemoveAnimationMember  = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("RemoveAnimation");
            TableViewReplaceAnimationMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewRowAnimation?>("ReplaceAnimation");
            TableViewScrollPositionMember   = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewScrollPosition?>("ScrollPosition");
            TableViewDefaultCellStyleMember = AttachedBindingMember.CreateAutoProperty <UITableView, UITableViewCellStyle?>("CellStyle");

            //UITableViewCell
            TableViewCellAccessoryButtonTappedEvent = AttachedBindingMember.CreateEvent <UITableViewCell>("AccessoryButtonTapped");
            TableViewCellDeleteClickEvent           = AttachedBindingMember.CreateEvent <UITableViewCell>("DeleteClick");
            TableViewCellInsertClickEvent           = AttachedBindingMember.CreateEvent <UITableViewCell>("InsertClick");
            TableViewCellMoveableMember             = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("Moveable");
            TitleForDeleteConfirmationMember        = AttachedBindingMember.CreateAutoProperty <UITableViewCell, string>("TitleForDeleteConfirmation");
            TableViewCellEditingStyleMember         = AttachedBindingMember.CreateAutoProperty <UITableViewCell, UITableViewCellEditingStyle?>("EditingStyle");
            TableViewCellShouldHighlightMember      = AttachedBindingMember.CreateAutoProperty <UITableViewCell, bool?>("ShouldHighlight");

            TableViewCellSelectedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Selected", (info, cell) =>
            {
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    return(cell.Selected);
                }
                return(cellBindable.SelectedBind);
            }, (info, cell, arg3) =>
            {
                var cellBindable = cell as UITableViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3;
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            });
            TableViewCellHighlightedMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Highlighted", (info, cell) => cell.Highlighted,
                (info, cell, arg3) =>
            {
                if (cell.Highlighted == arg3)
                {
                    return(false);
                }
                cell.Highlighted = arg3;
                return(true);
            });
            TableViewCellEditingMember = AttachedBindingMember.CreateNotifiableMember <UITableViewCell, bool>(
                "Editing", (info, cell) => cell.Editing,
                (info, cell, arg3) =>
            {
                if (cell.Editing == arg3)
                {
                    return(false);
                }
                cell.Editing = arg3;
                return(true);
            });

            //UICollectionView
            CollectionViewUseAnimationsMember      = AttachedBindingMember.CreateAutoProperty <UICollectionView, bool?>("UseAnimations");
            CollectionViewScrollPositionMember     = AttachedBindingMember.CreateAutoProperty <UICollectionView, UICollectionViewScrollPosition?>("ScrollPosition");
            CollectionViewSelectedItemChangedEvent = AttachedBindingMember.CreateEvent <UICollectionView>("SelectedItemChanged");

            //UICollectionViewCell
            CollectionViewCellShouldSelectMember    = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldSelect");
            CollectionViewCellShouldDeselectMember  = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldDeselect");
            CollectionViewCellShouldHighlightMember = AttachedBindingMember.CreateAutoProperty <UICollectionViewCell, bool?>("ShouldHighlight");

            CollectionViewCellSelectedMember = AttachedBindingMember
                                               .CreateNotifiableMember <UICollectionViewCell, bool>("Selected", (info, cell) => cell.Selected,
                                                                                                    (info, cell, arg3) =>
            {
                var cellBindable = cell as UICollectionViewCellBindable;
                if (cellBindable == null)
                {
                    cell.Selected = arg3;
                }
                else
                {
                    cellBindable.SelectedBind = arg3;
                }
                return(true);
            });
            CollectionViewCellHighlightedMember = AttachedBindingMember
                                                  .CreateNotifiableMember <UICollectionViewCell, bool>("Highlighted", (info, cell) => cell.Highlighted,
                                                                                                       (info, cell, arg3) =>
            {
                cell.Highlighted = arg3;
                return(true);
            });

            //UITabBarController
            TabBarSelectedItemMember = AttachedBindingMember.CreateAutoProperty <UITabBarController, object>(AttachedMemberConstants.SelectedItem, TabBarSelectedItemChanged, TabBarSelectedItemAttached);
        }
Ejemplo n.º 21
0
 static WinFormsModule()
 {
     BusyViewMember = AttachedBindingMember.CreateAutoProperty <Control, BusyIndicator>("#busyView",
                                                                                        getDefaultValue: (control, info) => new BusyIndicator());
 }