Beispiel #1
0
        public static InjectedProperty Register(
            string propertyName,
            Type propertyType,
            InjectedPropertyMetadata metadata
            )
        {
            InjectedProperty property = null;
            if (registeredProperties.TryGetValue(propertyName, out property))
            {
                // check type
                if (propertyType != property.PropertyType)
                {
                    throw new InvalidOperationException(string.Format("InjectedProperty \"{0}\" has already been registered as a different type \"{1}\"", propertyName, property.PropertyType.FullName));
                }
            }
            else
            {
                property = new  InjectedProperty
                {
                    PropertyName = propertyName,
                    PropertyType = propertyType,
                    Metadata = metadata,
                };

                registeredProperties.Add(propertyName, property);
            }

            return property;
        }
Beispiel #2
0
 public void RemoveInjectedProperty(object owner, InjectedProperty property)
 {
     var store = this.GetInjectedPropertyies(owner);
     if (store != null)
     {
         store.RemoveInjectedProperty(property);
     }
 }
Beispiel #3
0
        public object GetInjectedProperty(object owner, InjectedProperty property)
        {
            var store = this.GetInjectedPropertyies(owner);
            if (store != null)
            {
                return store.GetInjectedProperty(property);
            }

            return null;
        }
        public object GetInjectedProperty(InjectedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            
            object value = null;
            if (this.injectedProperties.TryGetValue(property.PropertyName, out value))
            {
                return value;
            }

            return property.Metadata.DefaultValue;
        }
        public void SetInjectedProperty(InjectedProperty property, object value)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            
            object oldValue = null;
            this.injectedProperties.TryGetValue(property.PropertyName, out oldValue);

            this.injectedProperties[property.PropertyName] = value;

            if (oldValue != value && property.Metadata.ChangeCallback != null)
            {
                property.Metadata.ChangeCallback(this.owner, new InjectedPropertyChangedEventArgs(property, value, oldValue));
            }
        }
Beispiel #6
0
        public void SetInjectedProperty(object owner, InjectedProperty property, object value)
        {
            var store = this.GetInjectedPropertyies(owner);

            if (store == null && this.factory != null)
            {
                store = this.factory(owner);
                if (store != null)
                {
                    this.AddInjectionStore(owner, store);
                }
            }

            if (store != null)
            {
                store.SetInjectedProperty(property, value);
            }
        }
        public void RemoveInjectedProperty(InjectedProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            
            object value = null;
            if (this.injectedProperties.TryGetValue(property.PropertyName, out value))
            {
                var disposable = value as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }

                this.injectedProperties.Remove(property.PropertyName);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Mobile.Mvvm.DataBinding.InjectedPropertyChangedEventArgs"/> class.
 /// </summary>
 public InjectedPropertyChangedEventArgs(InjectedProperty property, object newValue, object oldValue)
 {
     this.Property = property;
     this.NewValue = newValue;
     this.OldValue = oldValue;
 }