コード例 #1
0
 public AggregatorQueryNode(IBindable query)
 {
     _aggregate = query;
     _events = new ObservableCollection<IQueryNodeEvent>();
     _childNodes = new ObservableCollection<IQueryNode>();
     _aggregate.PropertyChanged += new PropertyChangedEventHandler(Aggregate_PropertyChanged);
 }
コード例 #2
0
ファイル: BindingScope.cs プロジェクト: sgmunn/Mobile.Mvvm
 /// <summary>
 /// Adds the bindings and binds them.
 /// </summary>
 public void Add(IBindable[] bindables)
 {
     foreach (var exp in bindables)
     {
         this.Add(exp);
     }
 }        
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: BindingScope.cs プロジェクト: sgmunn/Mobile.Mvvm
        public void Remove(IBindable bindable)
        {
            if (bindable == null)
            {
                throw new ArgumentNullException("bindable");
            }

            bindable.Dispose();
            this.bindables.Remove(bindable);
        }
コード例 #5
0
ファイル: Binding.cs プロジェクト: KristofferV/EasyNetQ
        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;
        }
コード例 #6
0
ファイル: BindingScope.cs プロジェクト: sgmunn/Mobile.Mvvm
        /// <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();
        }
コード例 #7
0
ファイル: SaleViewModel.cs プロジェクト: PaulStovell/bindable
 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();
 }
コード例 #8
0
ファイル: Binding.cs プロジェクト: richard-green/EasyNetQ
        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;
        }
コード例 #9
0
ファイル: EventRaised.cs プロジェクト: GregRos/Patchwork
 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);
 }
コード例 #10
0
ファイル: Binding.cs プロジェクト: nslowes/EasyNetQ
        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;
        }
コード例 #11
0
        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);
                }
            }
        }
コード例 #12
0
		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));
		}
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: TopologyBuilder.cs プロジェクト: Hibame/EasyNetQ
        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);
                }
            }
        }
コード例 #15
0
ファイル: Bind.cs プロジェクト: NTUST-PTL/PTL-Project
 public static void CreateBinding(IBindable Bindable1, IBindable Bindable2)
 {
     Bindable1.ValueChanged += Bindable2.BindedValueChanged;
     Bindable2.ValueChanged += Bindable1.BindedValueChanged;
 }
コード例 #16
0
		public IBindingExpression SetBinding(IBindable target, string targetProperty, Binding binding)
		{
			return BindingOperations.SetBinding(target, targetProperty, binding);
		}
コード例 #17
0
ファイル: Item.cs プロジェクト: bludman/designAR
 public void BindTo(IBindable b)
 {
     BindTo(b.getBindNode());
 }
コード例 #18
0
		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;
		}
コード例 #19
0
ファイル: Binding.cs プロジェクト: jonnii/chinchilla
        public Binding(IBindable bindable, IExchange exchange)
            : this(bindable, exchange, new string[0])
        {

        }
コード例 #20
0
		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);
		}
コード例 #21
0
 public OperatorQueryNode(IBindable query)
 {
     _operator = query;
 }
コード例 #22
0
ファイル: Binding.cs プロジェクト: ScianGames/Engine
        /// <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;
        }
コード例 #23
0
ファイル: Bind.cs プロジェクト: NTUST-PTL/PTL-Project
 public static void RemoveBinding(IBindable Bindable1, IBindable Bindable2)
 {
     Bindable1.ValueChanged -= Bindable2.BindedValueChanged;
     Bindable2.ValueChanged -= Bindable1.BindedValueChanged;
 }
コード例 #24
0
ファイル: Element.cs プロジェクト: sparra/AngleSharp
 protected void CreateBindings(IBindable bindable, String attributeName)
 {
     bindable.Changed += value => UpdateAttribute(attributeName, value);
     RegisterAttributeObserver(attributeName, value => bindable.Update(value));
 }
コード例 #25
0
		public static bool IsDataBound(IBindable target, string property) { return false; }
コード例 #26
0
 /// <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);
 }
コード例 #27
0
		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;
		}
コード例 #28
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);
 }
コード例 #29
0
ファイル: AggregateMode.cs プロジェクト: GregRos/Patchwork
 public override void Subscribe(object target, IBindable bindable)
 {
     _modes.ForEach(x => x.Subscribe(target, bindable));
 }
コード例 #30
0
ファイル: Binding.cs プロジェクト: jonnii/chinchilla
 public Binding(IBindable bindable, IExchange exchange, string[] routingKeys)
 {
     Bindable = bindable;
     Exchange = exchange;
     RoutingKeys = routingKeys;
 }