public AggregatorQueryNode(IBindable query)
 {
     _aggregate = query;
     _events = new ObservableCollection<IQueryNodeEvent>();
     _childNodes = new ObservableCollection<IQueryNode>();
     _aggregate.PropertyChanged += new PropertyChangedEventHandler(Aggregate_PropertyChanged);
 }
Beispiel #2
0
 /// <summary>
 /// Adds the bindings and binds them.
 /// </summary>
 public void Add(IBindable[] bindables)
 {
     foreach (var exp in bindables)
     {
         this.Add(exp);
     }
 }        
 public void ApplyBindableItem(IBindable bindable)
 {
     this.ID = bindable.ID;
     this.Value = bindable.Value;
     this.ColumnName = bindable.ColumnName;
     this.Caption = bindable.Caption;
     this.CaptionCssClass = bindable.CaptionCssClass;
 }
Beispiel #4
0
        private void load(IBindable <WorkingBeatmap> beatmap)
        {
            // Try first with the full name, then attempt with no path
            channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null));

            if (channel != null)
            {
                channel.Volume.Value = sample.Volume / 100;
            }
        }
        private void load(OverlayColourProvider colourProvider, OsuConfigManager config)
        {
            background.Colour = colourProvider.Dark6;

            allowExplicitContent = config.GetBindable <bool>(OsuSetting.ShowOnlineExplicitContent);
            allowExplicitContent.BindValueChanged(allow =>
            {
                ExplicitContent.Value = allow.NewValue ? SearchExplicit.Show : SearchExplicit.Hide;
            }, true);
        }
Beispiel #6
0
        public Binding(IBindable bindable, IExchange exchange, string routingKey)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckNotNull(routingKey, "routingKey");

            Bindable   = bindable;
            Exchange   = exchange;
            RoutingKey = routingKey;
        }
Beispiel #7
0
        public void Remove(IBindable bindable)
        {
            if (bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }

            bindable.Dispose();
            this.bindables.Remove(bindable);
        }
Beispiel #8
0
        /// <summary>
        /// Adds a new binding to the control with an indirect binding to the provided <paramref name="objectValue"/>
        /// </summary>
        /// <param name="bindable">Bindable object to add the binding to</param>
        /// <param name="controlBinding">Binding to get/set the value from the control.</param>
        /// <param name="objectValue">Object value to bind to.</param>
        /// <param name="objectBinding">Binding to get/set the value from the <paramref name="objectValue"/>.</param>
        /// <param name="mode">Mode of the binding.</param>
        /// <param name="defaultControlValue">Default control value to set to the objectValue, if the value of the control property is null.</param>
        /// <param name="defaultContextValue">Default context value to set to the control, if the objectValue or value of the objectBinding is null.</param>
        public static DualBinding <T> Bind <T>(this IBindable bindable, IndirectBinding <T> controlBinding, object objectValue, IndirectBinding <T> objectBinding, DualBindingMode mode = DualBindingMode.TwoWay, T defaultControlValue = default(T), T defaultContextValue = default(T))
        {
            var valueBinding = new ObjectBinding <object, T>(objectValue, objectBinding)
            {
                SettingNullValue = defaultContextValue,
                GettingNullValue = defaultControlValue
            };

            return(Bind(bindable, controlBinding, valueBinding, mode));
        }
Beispiel #9
0
        /// <summary>
        /// Adds the binding and binds it.
        /// </summary>
        public void Add(IBindable bindable)
        {
            if (bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }

            this.bindables.Add(bindable);
            bindable.Bind();
        }
        private void load()
        {
            API.Logout();

            localUser = API.LocalUser.GetBoundCopy();
            localUser.BindValueChanged(user => { userPanelArea.Child = new UserGridPanel(user.NewValue)
                                                 {
                                                     Width = 200
                                                 }; }, true);
        }
Beispiel #11
0
        private void load(ShaderManager shaders, IBindable <WorkingBeatmap> beatmap, IAPIProvider api, SkinManager skinManager)
        {
            this.beatmap.BindTo(beatmap);
            shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
            user   = api.LocalUser.GetBoundCopy();
            skin   = skinManager.CurrentSkin.GetBoundCopy();

            user.ValueChanged += _ => updateColour();
            skin.BindValueChanged(_ => updateColour(), true);
        }
Beispiel #12
0
        private void load([CanBeNull] IBindable <ManiaAction> action, [NotNull] IScrollingInfo scrollingInfo)
        {
            if (action != null)
            {
                Action.BindTo(action);
            }

            Direction.BindTo(scrollingInfo.Direction);
            Direction.BindValueChanged(OnDirectionChanged, true);
        }
            public ItemContent(BeatmapCollection collection)
            {
                this.collection = collection;

                RelativeSizeAxes = Axes.X;
                Height           = item_height;
                Masking          = true;

                collectionName = collection.Name.GetBoundCopy();
            }
Beispiel #14
0
        public Binding(IBindable bindable, IExchange exchange, string routingKey)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckNotNull(routingKey, "routingKey");

            Bindable = bindable;
            Exchange = exchange;
            RoutingKey = routingKey;
        }
Beispiel #15
0
        private void load(OsuConfigManager config)
        {
            FlowContent.Spacing = new Vector2(0, 5);
            Children            = new Drawable[]
            {
                skinDropdown = new SkinSettingsDropdown(),
                new SettingsSlider <float, SizeSlider>
                {
                    LabelText    = "Menu cursor size",
                    Bindable     = config.GetBindable <float>(OsuSetting.MenuCursorSize),
                    KeyboardStep = 0.01f
                },
                new SettingsSlider <float, SizeSlider>
                {
                    LabelText    = "Gameplay cursor size",
                    Bindable     = config.GetBindable <float>(OsuSetting.GameplayCursorSize),
                    KeyboardStep = 0.01f
                },
                new SettingsCheckbox
                {
                    LabelText = "Adjust gameplay cursor size based on current beatmap",
                    Bindable  = config.GetBindable <bool>(OsuSetting.AutoCursorSize)
                },
                new SettingsCheckbox
                {
                    LabelText = "Beatmap skins",
                    Bindable  = config.GetBindable <bool>(OsuSetting.BeatmapSkins)
                },
                new SettingsCheckbox
                {
                    LabelText = "Beatmap hitsounds",
                    Bindable  = config.GetBindable <bool>(OsuSetting.BeatmapHitsounds)
                },
            };

            managerAdded = skins.ItemAdded.GetBoundCopy();
            managerAdded.BindValueChanged(itemAdded);

            managerRemoved = skins.ItemRemoved.GetBoundCopy();
            managerRemoved.BindValueChanged(itemRemoved);

            config.BindWith(OsuSetting.Skin, configBindable);

            skinDropdown.Bindable = dropdownBindable;
            skinDropdown.Items    = skins.GetAllUsableSkins().ToArray();

            // Todo: This should not be necessary when OsuConfigManager is databased
            if (skinDropdown.Items.All(s => s.ID != configBindable.Value))
            {
                configBindable.Value = 0;
            }

            configBindable.BindValueChanged(id => dropdownBindable.Value   = skinDropdown.Items.Single(s => s.ID == id.NewValue), true);
            dropdownBindable.BindValueChanged(skin => configBindable.Value = skin.NewValue.ID);
        }
Beispiel #16
0
        public override bool Initialize(GameHost host)
        {
            if (!base.Initialize(host))
            {
                return(false);
            }

            if (!(host.Window is SDL2DesktopWindow desktopWindow))
            {
                return(false);
            }

            window = desktopWindow;

            isActive = window.IsActive.GetBoundCopy();
            isActive.BindValueChanged(_ => updateRelativeMode());

            cursorInWindow = host.Window.CursorInWindow.GetBoundCopy();
            cursorInWindow.BindValueChanged(_ => updateRelativeMode());

            cursorState = desktopWindow.CursorStateBindable.GetBoundCopy();
            cursorState.BindValueChanged(_ => updateRelativeMode());

            UseRelativeMode.BindValueChanged(_ =>
            {
                if (window != null)
                {
                    updateRelativeMode();
                }
            });

            Enabled.BindValueChanged(enabled =>
            {
                updateRelativeMode();

                if (enabled.NewValue)
                {
                    window.MouseMove         += HandleMouseMove;
                    window.MouseMoveRelative += HandleMouseMoveRelative;
                    window.MouseDown         += handleMouseDown;
                    window.MouseUp           += handleMouseUp;
                    window.MouseWheel        += handleMouseWheel;
                }
                else
                {
                    window.MouseMove         -= HandleMouseMove;
                    window.MouseMoveRelative -= HandleMouseMoveRelative;
                    window.MouseDown         -= handleMouseDown;
                    window.MouseUp           -= handleMouseUp;
                    window.MouseWheel        -= handleMouseWheel;
                }
            }, true);

            return(true);
        }
Beispiel #17
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (null != context)
         {
             context.UnBind();
             context = null;
         }
     }
 }
        public void TestParse(Type type, object input, object output)
        {
            IBindable bindable = (IBindable)Activator.CreateInstance(typeof(Bindable <>).MakeGenericType(type), type == typeof(string) ? "" : Activator.CreateInstance(type));

            Debug.Assert(bindable != null);

            bindable.Parse(input);
            object value = bindable.GetType().GetProperty(nameof(Bindable <object> .Value), BindingFlags.Public | BindingFlags.Instance)?.GetValue(bindable);

            Assert.That(value, Is.EqualTo(output));
        }
Beispiel #19
0
        public Binding(IBindable bindable, IExchange exchange, params string[] routingKeys)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckAny(routingKeys, "routingKeys", "There must be at least one routingKey");
            Preconditions.CheckFalse(routingKeys.Any(string.IsNullOrEmpty), "routingKeys", "RoutingKey is null or empty");

            Bindable = bindable;
            Exchange = exchange;
            RoutingKeys = routingKeys;
        }
Beispiel #20
0
        /// <summary>
        /// Adds a new dual binding between the control and the specified source binding
        /// </summary>
        /// <param name="bindable">Bindable object to add the binding to</param>
        /// <param name="widgetPropertyName">Property on the control to update</param>
        /// <param name="sourceBinding">Binding to get/set the value to from the control</param>
        /// <param name="mode">Mode of the binding</param>
        /// <returns>A new instance of the DualBinding class that is used to control the binding</returns>
        public static DualBinding <T> Bind <T>(this IBindable bindable, string widgetPropertyName, DirectBinding <T> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
        {
            var binding = new DualBinding <T>(
                sourceBinding,
                new BindableBinding <IBindable, T>(bindable, Binding.Property <T>(widgetPropertyName)),
                mode
                );

            bindable.Bindings.Add(binding);
            return(binding);
        }
            private void updateValue()
            {
                Value = manager.GetLocalisedString(text);

                if (parameters == null && text.Data is ILocalisableStringData)
                {
                    parameters = new Bindable <LocalisationParameters>();
                    parameters.BindTo(manager.currentParameters);
                    parameters.BindValueChanged(_ => updateValue());
                }
            }
        public static List <TObjectToBind> Bind <TObjectToBind>(IBindable <TObjectToBind> binder, DataTable dt)
        {
            List <TObjectToBind> col = new List <TObjectToBind>();

            foreach (DataRow dr in dt.Rows)
            {
                TObjectToBind item = binder.Bind(dr);
                col.Add(item);
            }
            return(col);
        }
Beispiel #23
0
        private void load(ILocalUserPlayInfo localUserInfo, OsuConfigManager config)
        {
            localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();
            localUserPlaying.BindValueChanged(_ => updateBlocking());

            isActive = host.IsActive.GetBoundCopy();
            isActive.BindValueChanged(_ => updateBlocking());

            disableWinKey = config.GetBindable <bool>(OsuSetting.GameplayDisableWinKey);
            disableWinKey.BindValueChanged(_ => updateBlocking(), true);
        }
Beispiel #24
0
        public Binding(IBindable bindable, IExchange exchange, params string[] routingKeys)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckAny(routingKeys, "routingKeys", "There must be at least one routingKey");
            Preconditions.CheckFalse(routingKeys.Any(string.IsNullOrEmpty), "routingKeys", "RoutingKey is null or empty");

            Bindable    = bindable;
            Exchange    = exchange;
            RoutingKeys = routingKeys;
        }
Beispiel #25
0
        private void load([CanBeNull] IBindable <WorkingBeatmap> workingBeatmap, [CanBeNull] BeatmapDifficultyCache difficultyCache)
        {
            if (workingBeatmap == null || difficultyCache == null)
            {
                return;
            }

            var beatmapDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo).Value;

            LoadComponentAsync(new BeatmapInfoWedge(workingBeatmap.Value, mods.Value, beatmapDifficulty ?? new StarDifficulty()), Add);
        }
Beispiel #26
0
 public void ApplyToPlayer(Player player)
 {
     isBreakTime = player.IsBreakTime.GetBoundCopy();
     isBreakTime.ValueChanged += e =>
     {
         if (e.NewValue)
         {
             lastActionPressed = null;
         }
     };
 }
        public static IBinding BindDataContextProperty(this IBindable bindable, string bindingPropertyName, Type valueType, IBinding binding)
        {
            var type            = bindable.GetType();
            var bindingProperty = GetFirstDeclaredProperty(type, bindingPropertyName).GetValue(bindable);
            var types           = new Type[] { typeof(IndirectBinding <>).MakeGenericType(valueType), typeof(DualBindingMode), valueType, valueType };

            var bindDataContextMethod = bindingProperty.GetType().GetRuntimeMethod("BindDataContext", types);
            var defaultValue          = Activator.CreateInstance(valueType);

            return((IBinding)bindDataContextMethod.Invoke(bindingProperty, new object[] { binding, DualBindingMode.TwoWay, defaultValue, defaultValue }));
        }
Beispiel #28
0
 public SaleViewModel()
 {
     _lineItems = new ObservableCollection<LineItem>();
     _total = _lineItems.AsBindable()
                 .Sum(lineItem => lineItem.TotalPrice)
                 .Project(total => total * (1M + Discount / 100M))
                 .Switch()
                     .Case(total => total < 10M, total => 10M)
                     .Default(total => total)
                 .EndSwitch();
 }
Beispiel #29
0
        /// <summary>
        ///     Instantiates a new binder for the provided <see cref="IBindable{TBind}"/>.
        /// </summary>
        /// <param name="bindable"> The bindable to wrap. </param>
        /// <param name="check"> The optional check used for throwing exceptions. </param>
        /// <param name="allowRebinding"> Whether rebinding should be allowed. </param>
        public Binder(IBindable <TBind> bindable, Action <TBind> check = null, bool allowRebinding = false)
        {
            if (bindable == null)
            {
                throw new ArgumentNullException(nameof(bindable));
            }

            _bindable       = bindable;
            _check          = check;
            _allowRebinding = allowRebinding;
        }
Beispiel #30
0
        public Binding(IBindable bindable, IExchange exchange, string routingKey, IDictionary <string, object> arguments)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckNotNull(routingKey, "routingKey");

            Bindable   = bindable;
            Exchange   = exchange;
            RoutingKey = routingKey;
            Arguments  = arguments;
        }
Beispiel #31
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            SelectedItem.BindValueChanged(_ => Scheduler.AddOnce(selectedItemChanged));

            managerUpdated = beatmapManager.ItemUpdated.GetBoundCopy();
            managerUpdated.BindValueChanged(beatmapUpdated);

            UserMods.BindValueChanged(_ => Scheduler.AddOnce(UpdateMods));
        }
Beispiel #32
0
        private void load(APIAccess api, IBindable <RulesetInfo> parentRuleset)
        {
            this.api = api;

            ruleset.BindTo(parentRuleset);
            ruleset.ValueChanged += _ => updateScores();

            if (api != null)
            {
                api.OnStateChange += handleApiStateChange;
            }
        }
        /// <summary>
        /// Projects a single bindable object into another bindable object, using a lambda to select the new
        /// type of object.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <param name="source">The source colection.</param>
        /// <param name="projector">The projector function used to turn the source type into the result type.</param>
        /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param>
        /// <returns>
        /// An object created by the <paramref name="projector"/>. If the source value changes, the item will be projected again.
        /// </returns>
        public static IBindable <TResult> Project <TSource, TResult>(this IBindable <TSource> source, Expression <Func <TSource, TResult> > projector, DependencyDiscovery dependencyAnalysisMode)
        {
            source.ShouldNotBeNull("source");
            projector.ShouldNotBeNull("projector");
            var result = new ProjectOperator <TSource, TResult>(source, projector.Compile(), source.Dispatcher);

            if (dependencyAnalysisMode == DependencyDiscovery.Enabled)
            {
                return(result.DependsOnExpression(projector.Body, projector.Parameters[0]));
            }
            return(result);
        }
        private void load(IBindable <WorkingBeatmap> beatmap, TextureStore textureStore)
        {
            var path = beatmap.Value.BeatmapSetInfo.Files.Find(f => f.Filename.Equals(Sprite.Path, StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath;

            if (path == null)
            {
                return;
            }

            Texture = textureStore.Get(path);
            Sprite.ApplyTransforms(this);
        }
Beispiel #35
0
 /// <summary>
 /// Register a forwarding listener to another bindable
 /// </summary>
 /// <param name="originalDispatcher">The bindable to forward from</param>
 public void ForwardOnChange(IBindable originalDispatcher)
 {
     if (!ForwardedBindables.ContainsKey(originalDispatcher))
     {
         // create an anonymous function the is used for forwarding
         var forwarding = (BindableCallback)((c, o) => Dispatch(o));
         // add it and dont immediatly dispatch
         originalDispatcher.OnChange(forwarding, false);
         // remember the anonymous function
         ForwardedBindables[originalDispatcher] = forwarding;
     }
 }
Beispiel #36
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            sliderPosition = slider.PositionBindable.GetBoundCopy();
            sliderPosition.BindValueChanged(_ => updateConnectingPath());

            pathVersion = slider.Path.Version.GetBoundCopy();
            pathVersion.BindValueChanged(_ => updateConnectingPath());

            updateConnectingPath();
        }
Beispiel #37
0
        private void load()
        {
            itemUpdated = scores.ItemUpdated.GetBoundCopy();
            itemUpdated.BindValueChanged(scoreChanged);

            itemRemoved = scores.ItemRemoved.GetBoundCopy();
            itemRemoved.BindValueChanged(scoreChanged);

            ruleset.ValueChanged += _ => fetchAndLoadTopScore();

            fetchAndLoadTopScore();
        }
Beispiel #38
0
        private void load(ILocalUserPlayInfo localUserInfo, FrameworkConfigManager frameworkConfigManager, OsuConfigManager osuConfigManager)
        {
            frameworkConfineMode = frameworkConfigManager.GetBindable <ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
            frameworkWindowMode  = frameworkConfigManager.GetBindable <WindowMode>(FrameworkSetting.WindowMode);
            frameworkWindowMode.BindValueChanged(_ => updateConfineMode());

            osuConfineMode   = osuConfigManager.GetBindable <OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
            localUserPlaying = localUserInfo.IsPlaying.GetBoundCopy();

            osuConfineMode.ValueChanged += _ => updateConfineMode();
            localUserPlaying.BindValueChanged(_ => updateConfineMode(), true);
        }
Beispiel #39
0
 public override void Subscribe(object target, IBindable bindable)
 {
     var type = target.GetType();
     var eventInfo = type.GetEvent(EventName);
     EventHandler eventHandler = null;
     eventHandler = new EventHandler((o, e) => {
         if (bindable.IsDisposed) {
             eventInfo.RemoveEventHandler(target, eventHandler);
             return;
         }
         bindable.NotifyChange();
     });
     eventInfo.AddEventHandler(target, eventHandler);
 }
Beispiel #40
0
        public Binding(IBindable bindable, IExchange exchange, params string[] routingKeys)
        {
            if(bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }
            if(exchange == null)
            {
                throw new ArgumentNullException("exchange");
            }
            if (routingKeys.Any(string.IsNullOrEmpty))
            {
                throw new ArgumentException("RoutingKey is null or empty");
            }
            if (routingKeys.Length == 0)
            {
                throw new ArgumentException("There must be at least one routingKey");
            }

            Bindable = bindable;
            Exchange = exchange;
            RoutingKeys = routingKeys;
        }
		public void Get_ShouldCallAccept(
			Mock<IObservableViewModelVisitor> visitor,
			IBindable parent,
			ISchedulers schedulers,
			Mock<IObservableViewModelBuilder> ovmBuilder,
			Mock<IObservableViewModel> ovm
			)
		{
			//arrange
			Action<IObservableViewModel> action = null;
			var sut = new ObservableViewModelBuilderProvider(() => schedulers, (a, scheduler, arg3) =>
			{
				action = a;
				return ovmBuilder.Object;
			});
			sut.AddVisitor(visitor.Object);

			//act
			sut.Get("test");
			action(ovm.Object);

			//assert
			ovm.Verify(o => o.Accept(visitor.Object));
		}
Beispiel #42
0
        public void CreateBinding(IBindable bindable, IExchange exchange, string[] routingKeys)
        {
            if(bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }
            if(exchange == null)
            {
                throw new ArgumentNullException("exchange");
            }
            if (routingKeys.Any(string.IsNullOrEmpty))
            {
                throw new ArgumentException("RoutingKey is null or empty");
            }
            if (routingKeys.Length == 0)
            {
                throw new ArgumentException("There must be at least one routingKey");
            }

            var queue = bindable as IQueue;
            if(queue != null)
            {
                foreach (var routingKey in routingKeys)
                {
                    model.QueueBind(queue.Name, exchange.Name, routingKey);
                }
            }
            var targetExchange = bindable as IExchange;
            if (targetExchange != null)
            {
                foreach (var routingKey in routingKeys)
                {
                    model.ExchangeBind(targetExchange.Name, exchange.Name, routingKey);
                }
            }
        }
        public PizzaCustomizer(Pizza pizza)
        {
            _pizza = pizza;

            _availableToppings = _pizza.AvailableToppings
                                    .AsBindable()
                                    .Select(topping => new SelectableTopping(topping));

            _selectedToppings = _availableToppings
                                    .Where(selectableTopping => selectableTopping.IsSelected)
                                    .Select(selectableTopping => selectableTopping.Topping);

            _healthWarningMessage = _selectedToppings.Count()
                                    .Switch()
                                        .Case(0,
                                            "Surely you would like more toppings?")
                                        .Case(toppings => toppings >= 3,
                                            "Too many toppings!")
                                        .Default(
                                            "Perfecto!")
                                    .EndSwitch();

            _totalPrice = _selectedToppings.Sum(topping => topping.Price).Project(toppingsTotal => toppingsTotal + pizza.BasePrice);
        }
        public void CreateBinding(IBindable bindable, IExchange exchange, string[] routingKeys)
        {
            Preconditions.CheckNotNull(bindable, "bindable");
            Preconditions.CheckNotNull(exchange, "exchange");
            Preconditions.CheckAny(routingKeys, "routingKeys", "There must be at least one routingKey");
            Preconditions.CheckFalse(routingKeys.Any(string.IsNullOrEmpty), "routingKeys", "RoutingKey is null or empty");

            var queue = bindable as IQueue;
            if(queue != null)
            {
                foreach (var routingKey in routingKeys)
                {
                    model.QueueBind(queue.Name, exchange.Name, routingKey);
                }
            }
            var targetExchange = bindable as IExchange;
            if (targetExchange != null)
            {
                foreach (var routingKey in routingKeys)
                {
                    model.ExchangeBind(targetExchange.Name, exchange.Name, routingKey);
                }
            }
        }
Beispiel #45
0
 protected void CreateBindings(IBindable bindable, String attributeName)
 {
     bindable.Changed += value => UpdateAttribute(attributeName, value);
     RegisterAttributeObserver(attributeName, value => bindable.Update(value));
 }
		public static IBindingExpression SetBinding(IBindable target, Binding binding)
		{
			if (target == null)
				throw new ArgumentNullException("target");

			if (binding == null)
				throw new ArgumentNullException("binding");
			
			var targetProperty = binding.TargetPath;

			IBindingExpression bindingExpression = null;
			
			object dataBinding = target.DataBinding;
			object nestedTarget = dataBinding;
			var element = target as IElement;

			MemberInfo memberInfo = null;
			FieldInfo bindablePropertyInfo = null;

			if (dataBinding != null)
			{
				var name = string.Concat(targetProperty, "Property");
				bindablePropertyInfo = dataBinding.GetType().GetField(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
				
				name = string.Concat(name, ".ControlValue");			
				memberInfo = dataBinding.GetType().GetNestedMember(ref nestedTarget, name, false);
				if (memberInfo != null)
				{
					binding.TargetPath = name;
					binding.Target = nestedTarget;
				}
			}

			var targetReady = memberInfo != null && nestedTarget != null && binding.Source != null;

			if (targetReady)
			{
				if (_BindingExpressions == null)
					_BindingExpressions = new List<IBindingExpression>();
				
				bindingExpression = GetBindingExpression(binding);

				if (bindingExpression != null)
				{
					_BindingExpressions.Remove(bindingExpression);
				}
			
				bindingExpression = new BindingExpression(binding, memberInfo, nestedTarget) { Element = element };

				_BindingExpressions.Add(bindingExpression);
					
				var vmINPC = bindingExpression.Binding.Source as INotifyPropertyChanged;
				if (vmINPC != null)
				{
					vmINPC.PropertyChanged -= HandleDataContextPropertyChanged;
					vmINPC.PropertyChanged += HandleDataContextPropertyChanged;
				}

				var viewINPC = bindingExpression.Binding.ViewSource as INotifyPropertyChanged;
				if (viewINPC != null)
				{
					viewINPC.PropertyChanged -= HandleDataContextPropertyChanged;
					viewINPC.PropertyChanged += HandleDataContextPropertyChanged;
				}
				
				var sourceValue = bindingExpression.GetSourceValue();
				 
				var sourceCollection = sourceValue as INotifyCollectionChanged;
				if (sourceCollection != null)
				{	
					SetNotificationCollectionHandler(bindingExpression, sourceCollection);
				}	
			}
			else
			{
				var binderKey =_Bindings.SingleOrDefault((kvp)=>kvp.Key.Object == target && kvp.Key.Property == targetProperty).Key;

				if (binderKey == null)
					_Bindings.Add(new PropertyBinder() { Object = target, Property = targetProperty }, binding);
				else
					_Bindings[binderKey] = binding;
			}
			
			if (bindablePropertyInfo != null)
			{
				var bindableProperty = bindablePropertyInfo.GetValue(dataBinding) as BindableProperty;
				if (bindableProperty != null)
					bindableProperty.BindingExpression = bindingExpression;
			}

			return bindingExpression;
		}
		public static IBindingExpression SetBinding(IBindable target, string targetProperty, object dataContext)
		{
			Binding binding = dataContext as Binding;
			if (dataContext == null)
			{
				binding = new Binding(targetProperty, "DataContext") { Source = dataContext } ;
			}
			return SetBinding(target, binding);
		}
		public static bool IsDataBound(IBindable target, string property) { return false; }
Beispiel #49
0
 public static void RemoveBinding(IBindable Bindable1, IBindable Bindable2)
 {
     Bindable1.ValueChanged -= Bindable2.BindedValueChanged;
     Bindable2.ValueChanged -= Bindable1.BindedValueChanged;
 }
		public static IBindingExpression SetBinding(IBindable target, string targetProperty, Binding binding)
		{
			if (target == null)
				throw new ArgumentNullException("target");

			if (string.IsNullOrEmpty(targetProperty))
				throw new ArgumentNullException("targetProperty");


			if (binding == null)
				throw new ArgumentNullException("binding");

			var binderKey =_Bindings.SingleOrDefault((kvp)=>kvp.Key.Object == target && kvp.Key.Property == targetProperty).Key;

			IBindingExpression bindingExpression = null;

			object nestedTarget = target;
			var element = target as IElement;
			
			var name = string.Concat(targetProperty, "Property.Value");
			MemberInfo memberInfo = target.GetType().GetNestedMember(ref nestedTarget, name, false);
			if (memberInfo != null)
			{
				binding.TargetPath = name;
				binding.Target = nestedTarget;
			}
			else
			{
				nestedTarget = target;
				memberInfo = target.GetType().GetNestedMember(ref nestedTarget, targetProperty, false);
			}
	
			var targetReady = memberInfo != null && nestedTarget != null;

			if (targetReady)
			{
				if (_BindingExpressions == null)
					_BindingExpressions = new List<IBindingExpression>();

				bindingExpression = GetBindingExpression(target, targetProperty);

				if (bindingExpression == null)
				{
					bindingExpression = new BindingExpression(binding, memberInfo, nestedTarget) { Element = element };

					_BindingExpressions.Add(bindingExpression);
					
					var vmINPC = bindingExpression.Binding.Source as INotifyPropertyChanged;
					if (vmINPC != null)
					{
						vmINPC.PropertyChanged -= HandleDataContextPropertyChanged;
						vmINPC.PropertyChanged += HandleDataContextPropertyChanged;
					}

					var viewINPC = bindingExpression.Binding.ViewSource as INotifyPropertyChanged;
					if (viewINPC != null)
					{
						viewINPC.PropertyChanged -= HandleDataContextPropertyChanged;
						viewINPC.PropertyChanged += HandleDataContextPropertyChanged;
					}
				}
			}
			else
			{
				if (binderKey == null)
					_Bindings.Add(new PropertyBinder() { Object = target, Property = targetProperty }, binding);
				else
					_Bindings[binderKey] = binding;
			}

			return bindingExpression;
		}
Beispiel #51
0
		public IBindingExpression SetBinding(IBindable target, string targetProperty, Binding binding)
		{
			return BindingOperations.SetBinding(target, targetProperty, binding);
		}
Beispiel #52
0
        /// <summary>
        /// Initializes a new <see cref="Binding"/>.
        /// </summary>
        /// <param name="bindable">The <see cref="IBindable"/> to (un)bind.</param>
        public Binding(IBindable bindable)
        {
            Contract.Requires<ArgumentNullException>(bindable != null);

            this.bindable = bindable;
        }
Beispiel #53
0
        public Binding(IBindable bindable, IExchange exchange)
            : this(bindable, exchange, new string[0])
        {

        }
 /// <summary>
 /// Adds a bindable value to the current value and automatically wires up any dependencies.
 /// </summary>
 /// <param name="source">The source value to add.</param>
 /// <param name="toAdd">To item to add.</param>
 /// <returns>
 /// A bindable value representing the sum of the two items.
 /// </returns>
 public static IBindable<long> Add(this IBindable<long> source, IBindable<long> toAdd)
 {
     return source.Project(s => s + toAdd.Current, DependencyDiscovery.Enabled);
 }
Beispiel #55
0
 public Binding(IBindable bindable, IExchange exchange, string[] routingKeys)
 {
     Bindable = bindable;
     Exchange = exchange;
     RoutingKeys = routingKeys;
 }
 public OperatorQueryNode(IBindable query)
 {
     _operator = query;
 }
Beispiel #57
0
 public override void Subscribe(object target, IBindable bindable)
 {
     _modes.ForEach(x => x.Subscribe(target, bindable));
 }
Beispiel #58
0
 public static void CreateBinding(IBindable Bindable1, IBindable Bindable2)
 {
     Bindable1.ValueChanged += Bindable2.BindedValueChanged;
     Bindable2.ValueChanged += Bindable1.BindedValueChanged;
 }
Beispiel #59
0
 public void BindTo(IBindable b)
 {
     BindTo(b.getBindNode());
 }
 /// <summary>
 /// Subtracts a bindable value from the current value and automatically wires up any dependencies.
 /// </summary>
 /// <param name="source">The source value to subtract.</param>
 /// <param name="toSubtract">To item to subtract.</param>
 /// <returns>
 /// A bindable value representing the result of the two items.
 /// </returns>
 public static IBindable<long> Subtract(this IBindable<long> source, IBindable<long> toSubtract)
 {
     return source.Project(s => s + toSubtract.Current, DependencyDiscovery.Enabled);
 }