/// <inheritdoc/>
        public bool ExecuteHook(
            object source, object target,
            Func <IObservedChange <object, object>[]> getCurrentViewModelProperties,
            Func <IObservedChange <object, object>[]> getCurrentViewProperties,
            BindingDirection direction)
        {
            var viewProperties   = getCurrentViewProperties();
            var lastViewProperty = viewProperties.LastOrDefault();
            var itemsControl     = lastViewProperty?.Sender as ItemsControl;

            if (itemsControl == null)
            {
                return(true);
            }

            var propertyName = viewProperties.Last().GetPropertyName();

            if (propertyName != "Items" &&
                propertyName != "ItemsSource")
            {
                return(true);
            }

            if (itemsControl.ItemTemplate != null)
            {
                return(true);
            }

            itemsControl.ItemTemplate = DefaultItemTemplate;
            return(true);
        }
Example #2
0
        internal Saml2FormBinding(IdentityHttpRequest request, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;
            string samlEncoded = this.BindingDirection switch
            {
                BindingDirection.Request => request.Form[Saml2Names.RequestParameterName],
                BindingDirection.Response => request.Form[Saml2Names.ResponseParameterName],
                _ => throw new NotImplementedException(),
            };
            var samlRequestDecoded = DecodeSaml(samlEncoded);

            this.Document = new XmlDocument();
            this.Document.LoadXml(samlRequestDecoded);

            this.HasSignature = X509XmlSigner.HasSignature(this.Document.DocumentElement);
            if (this.HasSignature)
            {
                this.SignatureAlgorithm = X509XmlSigner.GetSignatureAlgorithm(this.Document.DocumentElement);
                this.DigestAlgorithm    = X509XmlSigner.GetDigestAlgorithm(this.Document.DocumentElement);
            }

            this.HasEncryption = X509XmlEncryptor.HasEncryptedDataElements(this.Document.DocumentElement);
            if (this.HasEncryption)
            {
                this.EncryptionAlgorithm = X509XmlEncryptor.GetEncryptionAlgorithm(this.Document.DocumentElement);
            }
        }
        /// <summary>
        /// Creates an instance from the specified raw metadata.
        /// </summary>
        /// <param name="raw">The raw binding metadata.</param>
        /// <returns>The new <see cref="BindingMetadata"/> instance.</returns>
        public static BindingMetadata Create(JObject raw)
        {
            BindingMetadata  bindingMetadata       = null;
            string           bindingDirectionValue = (string)raw["direction"];
            string           connection            = (string)raw["connection"];
            string           bindingType           = (string)raw["type"];
            BindingDirection bindingDirection      = default(BindingDirection);

            if (!string.IsNullOrEmpty(bindingDirectionValue) &&
                !Enum.TryParse <BindingDirection>(bindingDirectionValue, true, out bindingDirection))
            {
                throw new FormatException(string.Format(CultureInfo.InvariantCulture, "'{0}' is not a valid binding direction.", bindingDirectionValue));
            }

            // TODO: Validate the binding type somehow?

            switch (bindingType.ToLowerInvariant())
            {
            case "httptrigger":
                bindingMetadata = raw.ToObject <HttpTriggerBindingMetadata>();
                break;

            default:
                bindingMetadata = raw.ToObject <BindingMetadata>();
                break;
            }

            bindingMetadata.Type       = bindingType;
            bindingMetadata.Direction  = bindingDirection;
            bindingMetadata.Connection = connection;
            bindingMetadata.Raw        = raw;

            return(bindingMetadata);
        }
Example #4
0
        /// <summary>
        /// Creates a new instance of the Binding class.
        /// </summary>
        /// <param name="target">A reference to the control to bind to.</param>
        /// <param name="targetProperty">The name of the property on the view to bind to.</param>
        /// <param name="source">A reference to the object that will be bound to the control.</param>
        /// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
        /// <param name="convert">A reference to a function to do a custom conversion from the source property to the target property.</param>
        /// <param name="convertBack">A reference to a function to do a custom conversion from the target property to the source property.</param>
        /// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
        public Binding(UIView target, string targetProperty, object source, string sourceProperty, Func <object, object> convert, Func <object, object> convertBack, BindingDirection bindingDirection)
        {
            BindingDirection = bindingDirection;
            Target           = target;
            Source           = source;
            TargetProperty   = Target.GetType().GetProperty(targetProperty);
            SourceProperty   = Source.GetType().GetProperty(sourceProperty);
            Convert          = convert;
            ConvertBack      = convertBack;

            var editableControl = Target as UIControl;

            if (editableControl != null)
            {
                editableControl.EditingDidEnd += Target_EditingDidEnd;
            }

            var inpc = Source as INotifyPropertyChanged;

            if (inpc != null)
            {
                inpc.PropertyChanged += Source_PropertyChanged;
            }

            UpdateTarget();
        }
Example #5
0
        public void AddProperty(Property <T> property, BindingDirection direction)
        {
            BindingsCleaner.Check();
            if (property.GetType() != typeof(LabelProperty))
            {
//								Debug.Log (_type + "," + property.GetPropertyType ());
                if (_type == property.GetPropertyType())
                {
                    if (direction == BindingDirection.BiDirectional || direction == BindingDirection.PropertyToBinding)
                    {
//												property.AddBinding (this);
                        property.AddListener(OnNewValue);
//												Debug.Log ("Bound ");
                    }

                    if (direction == BindingDirection.BiDirectional || direction == BindingDirection.BindingToProperty)
                    {
                        if (!propertyListeners.Contains(property))
                        {
                            propertyListeners.Add(property);
                        }
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        ///     Простое связывание
        /// </summary>
        /// <param name="source">источник</param>
        /// <param name="field">поле</param>
        /// <param name="direction">направление</param>
        /// <returns>Признак успешного связывания</returns>
        public bool BindSimple(object source, string field, BindingDirection direction)
        {
            if (source == null || field.Length == 0)
            {
                return(false);
            }
            bool changed;

            if (field.Equals("this"))
            {
                changed = DirectBind(ref source, source.GetType(), direction);
            }
            else
            {
                var t = source.GetType();
                var p = t.GetProperty(field);
                if (p == null)
                {
                    throw new Exception("Object has no field: " + field);
                }

                var val = p.GetValue(source, null);

                changed = DirectBind(ref val, p.PropertyType, direction);
                if (direction == BindingDirection.ToSource)
                {
                    p.SetValue(source, val, null);
                }
            }

            return(changed);
        }
Example #7
0
        internal Saml2QueryBinding(IdentityHttpRequest request, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;
            string samlEncoded = this.BindingDirection switch
            {
                BindingDirection.Request => request.Query[Saml2Names.RequestParameterName],
                BindingDirection.Response => request.Query[Saml2Names.ResponseParameterName],
                _ => throw new NotImplementedException(),
            };

            //var relayState = (string)request.Query[Saml2Names.RelayStateParameterName];
            var sigAlg = (string)request.Query[Saml2Names.SignatureAlgorithmParameterName];

            this.Signature = request.Query[Saml2Names.SignatureParameterName];

            this.singingInput = request.QueryString.Substring(1, request.QueryString.IndexOf("&" + Saml2Names.SignatureParameterName + "=") - 1);

            if (samlEncoded == null)
            {
                return;
            }

            var samlRequestDecoded = DecodeSaml(samlEncoded);

            this.Document = new XmlDocument();
            this.Document.LoadXml(samlRequestDecoded);

            this.SignatureAlgorithm = Algorithms.GetSignatureAlgorithmFromUrl(sigAlg);
        }
Example #8
0
        public void Constructor_builds_correct_object(string name, bool bindable, BindingDirection direction)
        {
            var expected                = new BindableAttribute(bindable, direction);
            var propertyInfo            = typeof(ClassWithAttributes).GetProperty(name);
            var propertyInfoDescription = new PropertyInfoDescription(propertyInfo);

            propertyInfoDescription.Attribute.ShouldBeEquivalentTo(expected);
        }
Example #9
0
        /// <summary>
        /// Makes a new instance of <see cref="Bindable{T}"/> class.
        /// </summary>
        /// <param name="initialValue">Initial value.</param>
        /// <param name="readOnly">Sets readonly mode for this property.</param>
        /// <param name="allowedDirections">Describes the allowed binding directions for this property.</param>
        public Bindable(T initialValue, bool readOnly = false, BindingDirection allowedDirections = BindingDirection.Both)
            : base(initialValue, readOnly)
        {
            // - Exclude write permission if the property is readonly
            AllowedDirections = readOnly ? allowedDirections & ~BindingDirection.Write : allowedDirections;

            Bindings = new Dictionary <object, Action>();
        }
Example #10
0
        public void GetAttribute_returns_attribute(string name, bool bindable, BindingDirection direction)
        {
            var expected     = new BindableAttribute(bindable, direction);
            var propertyInfo = typeof(ClassWithAttributes).GetProperty(name);
            var attribute    = propertyInfo.GetAttribute <BindableAttribute>();

            attribute.Should().BeEquivalentTo(expected);
        }
        public NotificationHubBinding(ScriptHostConfiguration config, NotificationHubBindingMetadata metadata, FileAccess access) :
            base(config, metadata, access)
        {
            TagExpression = metadata.TagExpression;
            ConnectionString = metadata.Connection;
            HubName = metadata.HubName;

            _bindingDirection = metadata.Direction;
        }
Example #12
0
 private BindingMetadata GetBindingMetadata(string name, string type, BindingDirection dir)
 {
     return(new BindingMetadata()
     {
         Name = name,
         Type = type,
         Direction = dir
     });
 }
Example #13
0
        public void Constructor_use_default_if_not_found(string name, bool bindable, BindingDirection direction)
        {
            var expected                = new BindableAttribute(bindable, direction);
            var defaultAttribute        = new BindableAttribute(false, BindingDirection.TwoWay);
            var propertyInfo            = typeof(ClassWithAttributes).GetProperty(name);
            var propertyInfoDescription = new PropertyInfoDescription(propertyInfo, defaultAttribute);

            propertyInfoDescription.Attribute.ShouldBeEquivalentTo(expected);
        }
Example #14
0
 public NotificationHubBinding(ScriptHostConfiguration config, NotificationHubBindingMetadata metadata, FileAccess access) :
     base(config, metadata, access)
 {
     TagExpression     = metadata.TagExpression;
     Platform          = metadata.Platform;
     ConnectionString  = metadata.Connection;
     HubName           = metadata.HubName;
     _bindingDirection = metadata.Direction;
 }
        /// <summary>
        /// Sets the bindingContext for the current thread.
        /// </summary>
        /// <param name="source">The source object</param>
        /// <param name="target">The target object</param>
        /// <param name="variables">Variables to be used during binding</param>
        /// <param name="direction">The current binding's direction</param>
        public void SetBindingContext(object source, object target, IDictionary<string, object> variables, BindingDirection direction)
        {
            // Extract dataSource from source object
            IEnumerable dataSource = DataBinder.GetPropertyValue(source, this._dataSourceFieldName) as IEnumerable;
            // Extract dataItemKeyField from source object
            string dataItemKeyField = DataBinder.GetPropertyValue(source, this._dataValueFieldName) as String;

            Initialize(dataSource, dataItemKeyField, direction);
        }
Example #16
0
        public void Ctor_Bindable_BindingDirection(bool bindable, BindingDirection direction)
        {
            var attribute = new BindableAttribute(bindable, direction);

            Assert.Equal(bindable, attribute.Bindable);
            Assert.Equal(direction, attribute.Direction);

            Assert.Equal(!bindable, attribute.IsDefaultAttribute());
        }
Example #17
0
        public void Ctor_BindableSupport_BindingDirection(BindableSupport support, BindingDirection direction, bool expectedBindable)
        {
            var attribute = new BindableAttribute(support, direction);

            Assert.Equal(expectedBindable, attribute.Bindable);
            Assert.Equal(direction, attribute.Direction);

            Assert.Equal(!expectedBindable || support == BindableSupport.Default, attribute.IsDefaultAttribute());
        }
Example #18
0
        public EasyTableBinding(ScriptHostConfiguration config, EasyTableBindingMetadata metadata, FileAccess access) :
            base(config, metadata, access)
        {
            TableName    = metadata.TableName;
            Id           = metadata.Id;
            MobileAppUri = metadata.Connection;
            ApiKey       = metadata.ApiKey;

            _bindingDirection = metadata.Direction;
        }
Example #19
0
        internal OAuth2FormBinding(IdentityHttpRequest request, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;

            this.Document = new JObject();
            foreach (var formItem in request.Form)
            {
                this.Document.Add(formItem.Key, JToken.FromObject((string)formItem.Value));
            }
        }
 public DocumentDBBinding(ScriptHostConfiguration config, DocumentDBBindingMetadata metadata, FileAccess access) :
     base(config, metadata, access)
 {
     DatabaseName      = metadata.DatabaseName;
     CollectionName    = metadata.CollectionName;
     CreateIfNotExists = metadata.CreateIfNotExists;
     ConnectionString  = metadata.Connection;
     Id = metadata.Id;
     _bindingDirection = metadata.Direction;
 }
Example #21
0
        internal OpenIDQueryBinding(IdentityHttpRequest request, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;

            this.Document = new JObject();
            foreach (var queryItem in request.Query)
            {
                this.Document.Add(queryItem.Key, JToken.FromObject((string)queryItem.Value));
            }
        }
 public DocumentDBBinding(ScriptHostConfiguration config, DocumentDBBindingMetadata metadata, FileAccess access) :
     base(config, metadata, access)
 {
     DatabaseName = metadata.DatabaseName;
     CollectionName = metadata.CollectionName;
     CreateIfNotExists = metadata.CreateIfNotExists;
     ConnectionString = metadata.Connection;
     Id = metadata.Id;
     _bindingDirection = metadata.Direction;
 }
        public EasyTableBinding(ScriptHostConfiguration config, EasyTableBindingMetadata metadata, FileAccess access) :
            base(config, metadata, access)
        {
            TableName = metadata.TableName;
            Id = metadata.Id;
            MobileAppUri = metadata.Connection;
            ApiKey = metadata.ApiKey;

            _bindingDirection = metadata.Direction;
        }
 ///<summary>
 /// Creates a new instance of this binding.
 ///</summary>
 ///<param name="sourceExpression">The expression that will evaluate to the <see cref="ListControl"/> acting as the source</param>
 ///<param name="targetExpression">The expression that will evaluate to an <see cref="IList"/> property acting as the target</param>
 /// <param name="direction">Binding's direction</param>
 ///<param name="itemFormatter">An optional formatter converting target items into <see cref="ListItem.Value"/> and back</param>
 /// <remarks>
 /// If no formatter is specified, a <see cref="DataSourceItemFormatter"/> will be used.
 /// </remarks>
 public MultipleSelectionListControlBinding(string sourceExpression, string targetExpression, BindingDirection direction,
                                            IFormatter itemFormatter)
     :base(sourceExpression, targetExpression, itemFormatter)
 {
     this.Direction = direction;
     if (itemFormatter == null)
     {
         this.Formatter = new DataSourceItemFormatter("DataSource", "DataValueField");
     }
 }
Example #25
0
        internal OpenIDJwtStreamBinding(WebResponse response, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;

            var stream = response.GetResponseStream();
            var sr     = new System.IO.StreamReader(stream);
            var body   = sr.ReadToEnd();

            response.Close();

            this.Document = JObject.Parse(body);

            string token;

            if (this.Document.ContainsKey(OpenIDJwtBinding.IdTokenFormName))
            {
                token       = this.Document[OpenIDJwtBinding.IdTokenFormName]?.ToObject <string>();
                accessToken = token;
            }
            else if (this.Document.ContainsKey(OpenIDJwtBinding.AccessTokenFormName))
            {
                token       = this.Document[OpenIDJwtBinding.AccessTokenFormName]?.ToObject <string>();
                accessToken = token;
            }
            else
            {
                throw new IdentityProviderException("Missing JWT Token");
            }

            var parts            = token.Split(OpenIDJwtFormBinding.tokenDelimiter);
            var jwtHeaderString  = DecodeJwt(parts[0]);
            var jwtPayloadString = DecodeJwt(parts[1]);

            if (parts.Length > 2 && !String.IsNullOrWhiteSpace(parts[2]))
            {
                this.Signature = parts[2];
            }

            this.singingInput = parts[0] + OpenIDJwtFormBinding.tokenDelimiter + parts[1];

            var jwtHeader = JsonConvert.DeserializeObject <JwtHeader>(jwtHeaderString);

            DeserializeJwtPayload(jwtPayloadString);

            if (!this.Document.ContainsKey(nameof(JwtHeader.X509Thumbprint)) && jwtHeader.X509Thumbprint != null)
            {
                this.Document.Add(nameof(JwtHeader.X509Thumbprint), JToken.FromObject(jwtHeader.X509Thumbprint));
            }
            if (!this.Document.ContainsKey(nameof(JwtHeader.KeyID)) && jwtHeader.KeyID != null)
            {
                this.Document.Add(nameof(JwtHeader.KeyID), JToken.FromObject(jwtHeader.KeyID));
            }

            this.SignatureAlgorithm = Algorithms.GetSignatureAlgorithmFromJwt(jwtHeader.Algorithm);
        }
        /// <summary>
        /// Adds the <see cref="SimpleExpressionBinding"/> binding.
        /// </summary>
        /// <param name="sourceExpression">
        /// The source expression.
        /// </param>
        /// <param name="targetExpression">
        /// The target expression.
        /// </param>
        /// <param name="direction">
        /// Binding direction.
        /// </param>
        /// <param name="formatter">
        /// <see cref="IFormatter"/> to use for value formatting and parsing.
        /// </param>
        /// <returns>
        /// Added <see cref="SimpleExpressionBinding"/> instance.
        /// </returns>
        public virtual IBinding AddBinding(string sourceExpression, string targetExpression,
                                           BindingDirection direction, IFormatter formatter)
        {
            SimpleExpressionBinding binding = new SimpleExpressionBinding(sourceExpression, targetExpression);

            binding.Direction = direction;
            binding.Formatter = formatter;
            bindings.Add(binding);

            return(binding);
        }
Example #27
0
 public static Saml2Binding GetBindingForRequest(IdentityHttpRequest request, BindingDirection bindingDirection)
 {
     if (request.HasFormContentType)
     {
         return(new Saml2FormBinding(request, bindingDirection));
     }
     else
     {
         return(new Saml2QueryBinding(request, bindingDirection));
     }
 }
Example #28
0
        internal OpenIDStreamBinding(WebResponse response, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;

            var stream = response.GetResponseStream();
            var sr     = new System.IO.StreamReader(stream);
            var body   = sr.ReadToEnd();

            response.Close();

            this.Document = JObject.Parse(body);
        }
Example #29
0
 public void AddToBinding(string bindingName, BindingDirection direction, AssignmentOnAdd assignmentIfExists)
 {
     if (Binding <T> .BindingExists(bindingName))
     {
         Binding <T> .GetBinding(bindingName).AddProperty(this, direction, assignmentIfExists);
     }
     else
     {
         Binding <T> newBinding = new Binding <T> (_value, bindingName);
         newBinding.AddProperty(this, direction);
     }
 }
        public ReactiveBinding(TView view, TViewModel viewModel, Expression viewExpression, Expression viewModelExpression,
                               IObservable <TValue> changed, BindingDirection direction, IDisposable bindingDisposable)
        {
            this.View                = view;
            this.ViewModel           = viewModel;
            this.ViewExpression      = viewExpression;
            this.ViewModelExpression = viewModelExpression;
            this.Direction           = direction;
            this.Changed             = changed;

            this.bindingDisposable = bindingDisposable;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AppliedBindingInfo{TViewModel}" /> class.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="viewPath">The view path.</param>
        /// <param name="viewModelPath">The view model path.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="bindingDisposable">The binding disposable.</param>
        public ReactiveBinding(TView view, TViewModel viewModel, string[] viewPath, string[] viewModelPath,
                               IObservable <TValue> changed, BindingDirection direction, IDisposable bindingDisposable)
        {
            this.View          = view;
            this.ViewModel     = viewModel;
            this.ViewPath      = viewPath;
            this.ViewModelPath = viewModelPath;
            this.Direction     = direction;
            this.Changed       = changed;

            this.bindingDisposable = bindingDisposable;
        }
Example #32
0
        /// <summary>
        /// Applies the binding.
        /// </summary>
        /// <param name="direction">
        /// The direction of the data flow.
        /// </param>
        public virtual void ApplyBinding(BindingDirection direction)
        {
            // If not initialized, ignore
            if (!IsInitialized)
            {
                return;
            }

            // Get the value
            var value = GetValue(direction);

            // Set the value
            SetValue(direction, value);
        }
Example #33
0
 public void AddProperty(Property <T> property, BindingDirection direction, AssignmentOnAdd assignment)
 {
     if (_type == property.GetPropertyType())
     {
         if (assignment == AssignmentOnAdd.TakeBindingValue)
         {
             property.SetValue(_value);
         }
         else if (assignment == AssignmentOnAdd.TakePropertyValue)
         {
             OnNewValue(property.value);
         }
     }
     AddProperty(property, direction);
 }
Example #34
0
        internal Saml2StreamBinding(WebResponse response, BindingDirection bindingDirection)
        {
            this.BindingDirection = bindingDirection;

            var stream = response.GetResponseStream();
            var sr     = new System.IO.StreamReader(stream);
            var body   = sr.ReadToEnd();

            response.Close();

            this.Document = new XmlDocument();
            this.Document.LoadXml(body);

            this.HasSignature = X509XmlSigner.HasSignature(this.Document.DocumentElement);
        }
Example #35
0
        public void ToBindingInfo_Converts_Correctly(BindingDirection bindingDirection, string type, DataType dataType)
        {
            BindingMetadata bindingMetadata = new BindingMetadata
            {
                Direction = bindingDirection,
                Type      = type,
                DataType  = dataType
            };

            BindingInfo bindingInfo = bindingMetadata.ToBindingInfo();

            Assert.Equal(bindingInfo.Direction, (BindingInfo.Types.Direction)bindingMetadata.Direction);
            Assert.Equal(bindingInfo.Type, bindingMetadata.Type);
            Assert.Equal(bindingInfo.DataType, (BindingInfo.Types.DataType)bindingMetadata.DataType);
        }
Example #36
0
        /// <summary>
        /// Creates a new instance of the Binding class.
        /// </summary>
        /// <param name="target">A reference to the control to bind to.</param>
        /// <param name="targetProperty">The name of the property on the view to bind to.</param>
        /// <param name="source">A reference to the object that will be bound to the control.</param>
        /// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
        /// <param name="convert">A reference to a function to do a custom conversion from the source property to the target property.</param>
        /// <param name="convertBack">A reference to a function to do a custom conversion from the target property to the source property.</param>
        /// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
        public Binding(UIView target, string targetProperty, object source, string sourceProperty, Func<object, object> convert, Func<object, object> convertBack, BindingDirection bindingDirection)
        {
            BindingDirection = bindingDirection;
              Target = target;
              Source = source;
              TargetProperty = Target.GetType().GetProperty(targetProperty);
              SourceProperty = Source.GetType().GetProperty(sourceProperty);
              Convert = convert;
              ConvertBack = convertBack;

              var editableControl = Target as UIControl;
              if (editableControl != null)
            editableControl.EditingDidEnd += Target_EditingDidEnd;

              var inpc = Source as INotifyPropertyChanged;
              if (inpc != null)
            inpc.PropertyChanged += Source_PropertyChanged;

              UpdateTarget();
        }
        /// <summary>
        /// Initialize a new instance.
        /// </summary>
        /// <param name="dataSource">The datasource containing list items</param>
        /// <param name="dataItemKeyField">The name of the listitem's property that evaluates to the item's key</param>
        /// <param name="direction">The direction of the current binding</param>
        private void Initialize(IEnumerable dataSource, string dataItemKeyField, BindingDirection direction)
        {
            _dataItemKeyField = dataItemKeyField;

            // if we are binding from target to source only, we can save some performance 
            // here because only Format() will be called.
            if (direction != (direction&BindingDirection.TargetToSource))
            {
                if(dataSource == null)
                {
                    throw new ArgumentNullException(
                        string.Format("DataSource must not be null."));
                }

                _dataItemsByKey = new Hashtable();
                foreach(object dataItem in dataSource)
                {
                    string key = Format(dataItem);
                    this._dataItemsByKey.Add(key, dataItem);
                }
            }
        }
Example #38
0
 /// <summary>
 /// <para>
 /// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
 /// </para>
 /// </summary>
 public BindableAttribute(BindableSupport flags, BindingDirection direction)
 {
     Bindable = (flags != BindableSupport.No);
     _isDefault = (flags == BindableSupport.Default);
     Direction = direction;
 }
Example #39
0
 public bool ExecuteHook(object source, object target, Func<IObservedChange<object, object>[]> getCurrentViewModelProperties, Func<IObservedChange<object, object>[]> getCurrentViewProperties, BindingDirection direction)
 {
     return true;
 }
        /// <summary>
        /// Adds the <see cref="SimpleExpressionBinding"/> binding.
        /// </summary>
        /// <param name="sourceExpression">
        /// The source expression.
        /// </param>
        /// <param name="targetExpression">
        /// The target expression.
        /// </param>
        /// <param name="direction">
        /// Binding direction.
        /// </param>
        /// <param name="formatter">
        /// <see cref="IFormatter"/> to use for value formatting and parsing.
        /// </param>
        /// <returns>
        /// Added <see cref="SimpleExpressionBinding"/> instance.
        /// </returns>
        public virtual IBinding AddBinding(string sourceExpression, string targetExpression,
                                           BindingDirection direction, IFormatter formatter)
        {
            SimpleExpressionBinding binding = new SimpleExpressionBinding(sourceExpression, targetExpression);
            binding.Direction = direction;
            binding.Formatter = formatter;
            bindings.Add(binding);

            return binding;
        }
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public TemplateContainerAttribute(Type containerType, BindingDirection bindingDirection) {
     _containerType = containerType;
     _bindingDirection = bindingDirection;
 }
 public BindableAttribute(BindableSupport flags, BindingDirection direction)
 {
     this.bindable = flags != BindableSupport.No;
     this.isDefault = flags == BindableSupport.Default;
     this.direction = direction;
 }
 public BindableAttribute(bool bindable, BindingDirection direction)
 {
     this.bindable = bindable;
     this.direction = direction;
 }
Example #44
0
		public BindableAttribute (BindableSupport flags, BindingDirection direction): this (flags)
		{
			this.direction = direction;
		}
		public TemplateContainerAttribute (Type containerType, BindingDirection direction)
		{
			this.containerType = containerType;
			this.direction = direction;
		}
	public BindableAttribute(bool bindable, BindingDirection direction) {}
	public BindableAttribute(BindableSupport flags, BindingDirection direction) {}
Example #48
0
 /// <summary>
 /// Creates a new instance of the Binding class.
 /// </summary>
 /// <param name="target">A reference to the control to bind to.</param>
 /// <param name="targetProperty">The name of the property on the view to bind to.</param>
 /// <param name="source">A reference to the object that will be bound to the control.</param>
 /// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
 /// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
 public Binding(UIView target, string targetProperty, object source, string sourceProperty, BindingDirection bindingDirection)
     : this(target, targetProperty, source, sourceProperty, null, null, bindingDirection)
 {
 }
Example #49
0
 /// <summary>
 /// Adds a new binding to be managed.
 /// </summary>
 /// <param name="control">A reference to the control to bind to.</param>
 /// <param name="targetProperty">The name of the property on the view to bind to.</param>
 /// <param name="source">A reference to the object that will be bound to the control.</param>
 /// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
 /// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
 public void Add(UIView control, string targetProperty, object source, string sourceProperty, BindingDirection bindingDirection)
 {
     Add(new Binding(control, targetProperty, source, sourceProperty, bindingDirection));
 }
 /// <summary>
 /// Adds the <see cref="SimpleExpressionBinding"/> binding.
 /// </summary>
 /// <param name="sourceExpression">
 /// The source expression.
 /// </param>
 /// <param name="targetExpression">
 /// The target expression.
 /// </param>
 /// <param name="direction">
 /// Binding direction.
 /// </param>
 /// <returns>
 /// Added <see cref="SimpleExpressionBinding"/> instance.
 /// </returns>
 public IBinding AddBinding(string sourceExpression, string targetExpression, BindingDirection direction)
 {
     return AddBinding(sourceExpression, targetExpression, direction, null);
 }
Example #51
0
 /// <summary>
 /// <para>
 /// Initializes a new instance of the <see cref='System.ComponentModel.BindableAttribute'/> class.
 /// </para>
 /// </summary>
 public BindableAttribute(bool bindable, BindingDirection direction)
 {
     Bindable = bindable;
     Direction = direction;
 }
 /// <summary>
 /// Adds the <see cref="SimpleExpressionBinding"/> binding.
 /// </summary>
 /// <remarks>
 /// This is a convinience method for adding <b>SimpleExpressionBinding</b>,
 /// one of the most often used binding types, to the bindings list.
 /// </remarks>
 /// <param name="sourceExpression">
 /// The source expression.
 /// </param>
 /// <param name="targetExpression">
 /// The target expression.
 /// </param>
 /// <param name="direction">
 /// Binding direction.
 /// </param>
 /// <param name="formatter">
 /// <see cref="IFormatter"/> to use for value formatting and parsing.
 /// </param>
 /// <returns>
 /// Added <see cref="SimpleExpressionBinding"/> instance.
 /// </returns>
 public override IBinding AddBinding(string sourceExpression, string targetExpression, BindingDirection direction,
                                     IFormatter formatter)
 {
     // setup variable for each HTTP request parameter
     return base.AddBinding("#" + sourceExpression, targetExpression, direction, formatter);
 }
Example #53
0
 /// <summary>
 /// Creates a new instance of the Binding class.
 /// </summary>
 /// <param name="target">A reference to the control to bind to.</param>
 /// <param name="targetProperty">The name of the property on the view to bind to.</param>
 /// <param name="source">A reference to the object that will be bound to the control.</param>
 /// <param name="sourceProperty">The name of the property on the object that will be bound to the target property.</param>
 /// <param name="convert">A reference to a function to do a custom conversion from the source property to the target property.</param>
 /// <param name="bindingDirection">Indicates if the binding is one way or two way.</param>
 public Binding(UIView target, string targetProperty, object source, string sourceProperty, Func<object, object> convert, BindingDirection bindingDirection)
     : this(target, targetProperty, source, sourceProperty, convert, null, bindingDirection)
 {
 }