Esempio n. 1
0
        public override void OnSetValue(LocationInterceptionArgs args)
        {
            var holder = (MauComponent)args.Instance;
            MauPropertyHolder mauPropHolder = holder.GetMauPropHolder(PropertyName);
            object            curValue      = args.GetCurrentValue();

            // Mark this property as it's changed by .Net
            mauPropHolder.Touched = true;

            // Set value first, so i can reflect it
            base.OnSetValue(args);

            // Todo: make that 'callBackMethod' an global var
            mauPropHolder.SetCallBackMethod ??= holder.GetType().GetMethod($"{args.LocationName}OnSet", BindingFlags.NonPublic | BindingFlags.Static);
            if (mauPropHolder.SetCallBackMethod != null && args.Value?.Equals(curValue) == false)
            {
                mauPropHolder.SetCallBackMethod.Invoke(null, new object[] { holder });
            }

            // HandleOnSet .?
            if (!mauPropHolder.HandleOnSet)
            {
                return;
            }

            // if it's set from angular side then will not hit this part
            // because of 'HandleOnSet' will be 'false'
            if (PropStatus == MauPropertyStatus.ReadOnly)
            {
                throw new Exception($"This prop '{holder.MauId}.{PropertyName}' is 'ReadOnly'.");
            }

            SendMauProp(holder, PropertyName);
        }
 public void OnValueChange(LocationInterceptionArgs args)
 {
     if (!this.IsFrozen)
     {
         args.ProceedSetValue();
     }
 }
        public void OnPropertySet(LocationInterceptionArgs args)
        {
            var vmInstance = args.Instance as ViewModelBase;
            var convention = conventionManager.Convention(vmInstance, args.Location.Name);

            convention.OnPropertySet(new PostSharpPropertyInfo(args));
        }
        public void OnFieldGet(LocationInterceptionArgs args)
        {
            if (runningConstructors != null && runningConstructors.Contains(args.Instance))
            {
                return;
            }

            ReaderWriterLockSlim myLock = ((IReaderWriterSynchronized)args.Instance).Lock;

            if (myLock.IsReadLockHeld || myLock.IsUpgradeableReadLockHeld || myLock.IsWriteLockHeld)
            {
                return;
            }

            Dictionary <ReaderWriterLockSlim, ReadCheckNode> myRunningMethods = runningMethods;
            ReadCheckNode node;

            if (myRunningMethods == null || !myRunningMethods.TryGetValue(myLock, out node))
            {
                // The field is read from outside an instance method of the current instance.
                // This can happen. This would not be a good practice, but this should be checked using an architectural constraint.

                // TODO: Verify with architectural constraint.
                return;
            }

            if (node.Count > 0)
            {
                throw new LockNotHeldException("A reader lock is necessary to access more than one field.");
            }

            node.Count = 1;
        }
Esempio n. 5
0
        public void OnSetField( LocationInterceptionArgs args )
        {
            if ( this.IsFrozen )
                throw new InvalidOperationException("The object is frozen.");

            args.ProceedSetValue();
        }
    private void GetValue(LocationInterceptionArgs args, bool propagate = false)
    {
        var properties = args.Instance.GetType().GetProperties();
        // JSONObject is just an object with string KEY and string VALUE, you can add dummy data here using a Dictionary<string, string>
        IEnumerable <JSONObject> result = API.Methods.GetCharsetData(id, Charset).Result;

        if (result.Count() > 0)
        {
            foreach (PropertyInfo propertyInfo in properties)
            {
                CatalogueLazyLoad attribute = propertyInfo.GetCustomAttribute <CatalogueLazyLoad>();
                if (attribute != null && attribute.Charset == Charset)
                {
                    propertyInfo.SetValue(args.Instance,
                                          Convert.ChangeType(result.Where(x => x.Key == attribute.Name).Select(x => x.Value).FirstOrDefault(), propertyInfo.PropertyType, CultureInfo.CurrentCulture),
                                          null);
                }
            }
            if (propagate)
            {
                this.LoadedCategoriesProperty.Get().Add(this.Charset);
            }
            args.ProceedGetValue();
        }
    }
        object GetValueFor([NotNull] LocationInterceptionArgs args, LazyEntity parent, Func <LazyEntity, Type, ICollection <IDataCriterion>, IEnumerable <object> > read)
        {
            var criterion = CriterionFor(args);

            if (criterion == null)
            {
                return(null);
            }



            // var collection = GetLazy.Entity(RealLocationType, (ILazyEntity)args.Instance).By(criterion);
            var collection = read(parent, RealLocationType, new[] { criterion });

            if (IsCollection)
            {
                var targetCollection = (IList)Activator.CreateInstance(TargetCollectionType);
                foreach (var item in collection)
                {
                    targetCollection.Add(item);
                }

                return(targetCollection);
            }

            return(collection.FirstOrDefault());
        }
Esempio n. 8
0
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     args.ProceedSetValue();
     Console.WriteLine("Writing to registry");
     Registry.SetValue(this.keyName, this.valueName, Convert.ToString(args.Value));
     this.isFetched = true;
 }
        public void OnPropertySet(LocationInterceptionArgs args)
        {
            var fireEvents   = EventSettings.BubblingEnabled && FireOnPropertyChange;
            var instance     = Instance;
            var locationName = args.LocationName;

            if (fireEvents)
            {
                EditActionAttribute.FireBeforeEventCall(instance, true);
                OnEntityEventMethod(instance, new PropertyChangingEventArgs(locationName),
                                    EntityEventType.PropertyChanging);
            }

            try
            {
                args.ProceedSetValue();
            }
            finally
            {
                if (fireEvents)
                {
                    try
                    {
                        OnEntityEventMethod(instance, new PropertyChangedEventArgs(locationName),
                                            EntityEventType.PropertyChanged);
                    }
                    finally
                    {
                        EditActionAttribute.FireAfterEventCall(instance, true, false);
                    }
                }
            }
        }
        public void OnFieldSet(LocationInterceptionArgs args)
        {
            //If a thread-unsafe field is accessed in a way which ignores checks (e.g. from static method or other instance), an exception should be thrown

            if (runningConstructors != null && runningConstructors.Contains(args.Instance))
            {
                return;
            }

            //Fields marked with ThreadSafe have already been exluded

            object key = this.GetRunningThreadSafeMethodsKey(args.Instance, args.Location.DeclaringType);

            if (IsContextThreadSafe(key))
            {
                return;
            }


            object sync = GetSyncObject(this.policy, args.Instance, args.Location.DeclaringType);

            ThreadHandle threadHandle;

            if (!locks.TryGetValue(sync, out threadHandle) || threadHandle.Thread != Thread.CurrentThread)
            {
                throw new LockNotHeldException(
                          "Fields not marked with ThreadSafe attribute can only be accessed from monitored ThreadUnsafe methods or methods marked as ThreadSafe.");
            }

            args.ProceedSetValue();
        }
        public void OnPropertySet(LocationInterceptionArgs args)
        {
            // Don't go further if the new value is equal to the old one.
            // (Possibly use object.Equals here).
            if (args.Value == args.GetCurrentValue())
            {
                return;
            }

            // Actually sets the value.
            args.ProceedSetValue();

            // Ignore properties with AutoDirtyIgnoreAttribute.
            var propertyInfo = args.Location.PropertyInfo;

            if (propertyInfo.GetCustomAttributes(typeof(AutoDirtyIgnoreAttribute), true).Any())
            {
                return;
            }

            if (Instance is IDirty dirtyObject)
            {
                dirtyObject.SetDirty();
            }
        }
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (args.GetCurrentValue() == null)
     {
         Console.WriteLine("Property ({0}) not initialized", args.LocationFullName);
     }
 }
Esempio n. 13
0
        public override void OnSetValue(LocationInterceptionArgs args)
        {
            var locationInfo = args.Location;

            if (locationInfo.LocationType == typeof(string))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (string)args.Value);
                args.ProceedSetValue();
                return;
            }

            if (locationInfo.LocationType == typeof(double))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (double)args.Value);
                args.ProceedSetValue();

                return;
            }

            if (locationInfo.LocationType == typeof(Int32))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (Int32)args.Value);
                args.ProceedSetValue();

                return;
            }

            if (locationInfo.LocationType == typeof(Int64))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (Int64)args.Value);
                args.ProceedSetValue();

                return;
            }

            if (locationInfo.LocationType == typeof(bool))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (bool)args.Value);
                args.ProceedSetValue();

                return;
            }

            if (locationInfo.LocationType == typeof(decimal))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (decimal)args.Value);
                args.ProceedSetValue();

                return;
            }

            if (locationInfo.LocationType == typeof(DateTime))
            {
                CrossSettings.Current.AddOrUpdateValue(args.LocationFullName, (DateTime)args.Value);

                args.ProceedSetValue();

                return;
            }
        }
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            args.ProceedGetValue();
            if (AlreadyLoaded)
            {
                return;
            }

            if (IsValueAlreadySpecified(args))
            {
                AlreadyLoaded = true;
                return;
            }

            var lazyEntity = (LazyEntity)args.Instance;

            if (!lazyEntity.Context.IsLoadingAllowed)
            {
                if (!IsCollection || args.Value != null)
                {
                    return;
                }

                //? then property is collection - we initialize it with empty collection if it now initialized yet, to avoid null reference exceptions
                InitializeCollectionPropertyWithEmptyCollection(args);
                return;
            }


            LazyLoadValueFromDatabase(args, lazyEntity);
        }
Esempio n. 15
0
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     Console.WriteLine("OnSetValue" + args.Value ?? "Nil");
     // 可在此把欲設定的值換掉。
     args.Value = "I am deamon.";
     base.OnSetValue(args);
 }
Esempio n. 16
0
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            if (this.isFetched)
            {
                args.ProceedGetValue();
                return;
            }
            else
            {
                this.isFetched = true;

                Console.WriteLine("Reading from registry");
                string stringValue = Registry.GetValue(this.keyName, this.valueName, null) as string;
                if (stringValue != null )
                {
                    object value = Convert.ChangeType(stringValue, args.Location.LocationType);
                    args.SetNewValue(value);
                    args.Value = value;
                }
                else
                {
                    args.ProceedGetValue();
                }
            }
        }
        void LazyLoadValueFromDatabase(LocationInterceptionArgs args, LazyEntity lazyEntity)
        {
            lock (_writeLock) {
                args.ProceedGetValue();

                if (AlreadyLoaded)
                {
                    return;
                }

                if (IsValueAlreadySpecified(args))
                {
                    AlreadyLoaded = true;
                    return;
                }

                if (lazyEntity.Read == null)
                {
                    AlreadyLoaded = true; //?if Read callback is null - it means that entity was created by the client code, and not was getted from db, so it's not persisted at all.
                    return;
                }

                var value = GetValueFor(args, lazyEntity, lazyEntity.Read);
                args.SetNewValue(value);
                AlreadyLoaded = true;
                args.ProceedGetValue();
            }
        }
Esempio n. 18
0
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            base.OnGetValue(args);

            if (DefaultProvider != null && !_defaultProviderSet)
            {
                _defaultProvider    = (TypedValueProvider)Activator.CreateInstance(DefaultProvider);
                _defaultProviderSet = true;
            }
            if (Get)
            {
                if (ConvertType == null)
                {
                    ConvertType = args.Location.LocationType;
                }
                try
                {
                    args.Value = Json ? JsonConvert.DeserializeObject(FlashUtil.Call(Name), ConvertType) : FlashUtil.Call(Name, ConvertType);
                }
                catch
                {
                    args.Value = _defaultProvider.Provide(ConvertType);
                }
            }
        }
Esempio n. 19
0
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     Console.WriteLine("OnGetValue" + args.Value ?? "Nil");
     base.OnGetValue(args);
     // 可在此把取回的值換掉。
     args.Value = "I am god!";
 }
Esempio n. 20
0
 /// <summary>
 /// Method invoked <i>instead</i> of the <c>Get</c> semantic of the field or property to which the current aspect is applied,
 /// i.e. when the value of this field or property is retrieved.
 /// </summary>
 /// <param name="args">Advice arguments.</param>
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     args.ProceedGetValue();
     if (args.Value == null)
     {
         if (string.IsNullOrEmpty(this.Token))
         {
             if (string.IsNullOrEmpty(this.TokenProperty))
             {
                 args.Value = IoC.Get(args.Location.LocationType);
             }
             else
             {
                 object value = ObjectProxyFactory.Get(args.Instance).GetValue(args.Instance, this.TokenProperty);
                 if (value == null)
                 {
                     args.Value = IoC.Get(args.Location.LocationType);
                 }
                 else
                 {
                     args.Value = IoC.Get(args.Location.LocationType, value.ToString());
                 }
             }
         }
         else
         {
             args.Value = IoC.Get(args.Location.LocationType, this.Token);
         }
         args.ProceedSetValue();
     }
 }
        public bool RefreshPropertyBindings(LocationInterceptionArgs args)
        {
            bool bindingFound = false;
            List <FieldValueBinding> sourceFields;

            if (this.TryGetSourceFieldBindings(args.LocationName, out sourceFields))
            {
                foreach (FieldValueBinding fieldValueBinding in sourceFields.OrderBy(f => f.IsActive))
                {
                    object value = fieldValueBinding.Field.GetValue(args.Instance);

                    if (this.fieldValueComparer.AreEqual(args.LocationFullName, value, args.Value))
                    {
                        // field and property values are equal, mark source field binding as active and if there is a handler hooked to the property un hook it
                        bindingFound = true;
                        if (fieldValueBinding.IsActive)
                        {
                            break;
                        }

                        fieldValueBinding.IsActive = true;
                    }
                    else
                    {
                        // field and property values differ, mark source field binding as inactive and re hook a handler to the property
                        fieldValueBinding.IsActive = false;
                    }
                }
            }

            return(bindingFound);
        }
Esempio n. 22
0
 public UndoItem(UndoableAttribute parent, object newValue, object oldValue, LocationInterceptionArgs args)
 {
     this.newValue = newValue;
     this.parent   = parent;
     this.oldValue = oldValue;
     this.args     = args;
 }
Esempio n. 23
0
 /// <summary>
 /// Method invoked <i>instead</i> of the <c>Get</c> semantic of the field or property to which the current aspect is applied,
 /// i.e. when the value of this field or property is retrieved.
 /// </summary>
 /// <param name="args">Advice arguments.</param>
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     args.ProceedGetValue();
     if (args.Value == null)
     {
         if (string.IsNullOrEmpty(this.Token))
         {
             if (string.IsNullOrEmpty(this.TokenProperty))
             {
                 args.Value = IoC.Get(args.Location.LocationType);
             }
             else
             {
                 object value = ObjectProxyFactory.Get(args.Instance).GetValue(args.Instance, this.TokenProperty);
                 if (value == null)
                 {
                     args.Value = IoC.Get(args.Location.LocationType);
                 }
                 else
                 {
                     args.Value = IoC.Get(args.Location.LocationType, value.ToString());
                 }
             }
         }
         else
         {
             args.Value = IoC.Get(args.Location.LocationType, this.Token);
         }
         args.ProceedSetValue();
     }
 }
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            if (this.isFetched)
            {
                args.ProceedGetValue();
                return;
            }
            else
            {
                this.isFetched = true;

                var stringValue = ConfigurationManager.AppSettings[this.settingName];

                if (!string.IsNullOrEmpty(stringValue))
                {
                    var value = Convert.ChangeType(stringValue, args.Location.LocationType);
                    args.SetNewValue(value);
                    args.Value = value;
                }
                else
                {
                    args.ProceedGetValue();
                }
            }
        }
Esempio n. 25
0
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     base.OnGetValue(args);
     if (args.Value == null)
     {
     }
 }
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     var resources = (args.Instance as FrameworkElement).Resources;
     if (!resources.Contains(ResourceKey))
         throw new KeyNotFoundException("The key '{0}' was not found in the resource dictionary.".FormatWith(ResourceKey));
     resources[ResourceKey] = args.Value;
 }
        /// <summary>
        ///   Method executed when the field or property is being read.
        /// </summary>
        /// <param name="args">Description of the current operation.</param>
        public void OnSetValue(LocationInterceptionArgs args)
        {
            RequirePermission(args.Location.FieldInfo ?? (MemberInfo)args.Location.PropertyInfo, OperationSemantic.Write, 0,
                              args.Instance);

            args.ProceedSetValue();
        }
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (!_valueSet)
     {
         _valueSet = true;
         if (IsGuid)
         {
             //Console.WriteLine("Initializing Guid"); 
             if (args.Location.LocationType == typeof(string))
                 args.SetNewValue(Guid.NewGuid().ToString());
             else if (args.Location.LocationType == typeof(Guid))
                 args.SetNewValue(Guid.NewGuid());
         }
         else if (_defaultValue != null)
         {
             args.SetNewValue(_defaultValue);
             //Console.WriteLine("Initialized {0} to |{1}|", args.LocationName, args.GetCurrentValue()); 
         }
         else if (args.Location.PropertyInfo.GetType().IsClass)
         {
             var t = args.Location.PropertyInfo.PropertyType;
             if (t.GetConstructor(Type.EmptyTypes) != null)
             {
                 //Console.WriteLine("Initializing {0}", args.LocationName);
                 args.SetNewValue(Activator.CreateInstance(t));
             }
             else throw new InvalidOperationException(string.Format("The property {0} (type {1}) has no default constructor and must either be provided with a default value or have the [Initialize] attribute removed", args.LocationFullName, t));
         }
     }
     //Console.WriteLine("Before get called.  Current value is |{0}|", args.GetCurrentValue());
     args.ProceedGetValue();
     //Console.WriteLine("After get called.  Current value is |{0}|", args.Value);
 }
Esempio n. 29
0
 public UndoItem( UndoableAttribute parent, object newValue, object oldValue, LocationInterceptionArgs args )
 {
     this.newValue = newValue;
     this.parent = parent;
     this.oldValue = oldValue;
     this.args = args;
 }
Esempio n. 30
0
        public override void OnSetValue(LocationInterceptionArgs Args)
        {
            this.Args = Args;

            if (HasAValue) Value = KeyMaker.Encrypt(Value.ToString());

            SetValue();
        }
Esempio n. 31
0
 /// <inheritdoc />
 public sealed override void OnGetValue(LocationInterceptionArgs args)
 {
     ReactiveManagerWithList.Evaluate(() =>
     {
         base.OnGetValue(args);
         return((INotifyCollectionChanged)args.GetCurrentValue());
     });
 }
Esempio n. 32
0
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (_backingField == null)
         lock (_syncRoot)
             if (_backingField == null)
                 _backingField = Activator.CreateInstance(args.Location.LocationType);
     args.Value = _backingField;
 }
Esempio n. 33
0
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     if (null != GetEncryptedValues())
         if (!GetEncryptedValues().ContainsKey(propname))
             GetEncryptedValues().Add(propname, args.Value.ToString());
         else
             GetEncryptedValues()[propname] = args.Value.ToString();
 }
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (args.GetCurrentValue() == null)
     {
         args.SetNewValue(_value);
     }
     args.ProceedGetValue();
 }
 /// <summary>
 /// Method invoked <i>instead</i> of the <c>Get</c> semantic of the field or property to which the current aspect is applied,
 /// i.e. when the value of this field or property is retrieved.
 /// </summary>
 /// <param name="args">Advice arguments.</param>
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (null == args.GetCurrentValue())
     {
         Console.WriteLine(string.Format("Property ({0}) not initialized",
                                         args.LocationFullName));
     }
 }
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     if (HashedValuesStore.Get().ContainsKey(propname))
         HashedValuesStore.Get()[propname] = HashValue(args.Value.ToString());
     else
         HashedValuesStore.Get().Add(propname, HashValue(args.Value.ToString()));
     args.ProceedSetValue();
 }
Esempio n. 37
0
 public sealed override void OnGetValue(LocationInterceptionArgs args)
 {
     ReactiveManager.Evaluate(new CompositeReactiveObject(args.Instance, property), () =>
     {
         args.ProceedGetValue();
         return(true);
     });
 }
Esempio n. 38
0
 public void OnSetValue(LocationInterceptionArgs args)
 {
     if (args.Value != args.GetCurrentValue())
     {
         args.ProceedSetValue();
         this.OnPropertyChanged(args.Location.Name);
     }
 }
 public void OnSetValue( LocationInterceptionArgs args )
 {
     if ( args.Value != args.GetCurrentValue() )
     {
         args.ProceedSetValue();
         this.OnPropertyChanged( args.Location.Name );
     }
 }
Esempio n. 40
0
 public void OnSetValue(LocationInterceptionArgs args)
 {
     if (ValidateDelegate((T)args.Value)?.Any() == true)
     {
         throw new ArgumentException("...");
     }
     args.ProceedSetValue();
 }
Esempio n. 41
0
        public override void OnSetValue(LocationInterceptionArgs Args)
        {
            this.Args = Args;

            if (Value == UserSetting) return;

            UserSetting = Value;
            Save();
        }
Esempio n. 42
0
 /// <summary>
 /// Method invoked <i>instead</i> of the <c>Get</c> semantic of the field or property to which the current aspect is applied,
 /// i.e. when the value of this field or property is retrieved.
 /// </summary>
 /// <param name="args">Advice arguments.</param>
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     args.ProceedGetValue();
     if (args.Value == null)
     {
         args.Value = LogManager.GetLogger(args.Location.DeclaringType);
         args.ProceedSetValue();
     }
 }
Esempio n. 43
0
        /// <summary>
        ///    Method invoked when (instead of) the target field or property is retrieved.
        /// </summary>
        /// <param _name="args">Context information.</param>
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            object value = _viewState.Get()[_name];

            if (value != null)
            {
                args.Value = value;
            }
        }
        public void OnPropertySet(LocationInterceptionArgs args)
        {
            if (!this.propertySetList.Contains(args.LocationName))
            {
                this.propertySetList.Add(args.LocationName);
            }

            args.ProceedSetValue();
        }
Esempio n. 45
0
        /// <summary>
        ///   Method invoked when (instead of) the target field or property is retrieved.
        /// </summary>
        /// <param name="args">Context information.</param>
        public override void OnGetValue(LocationInterceptionArgs args)
        {
            var value = ViewState.Get()[name];

            if (value != null)
            {
                args.Value = value;
            }
        }
        public override void OnSetValue(LocationInterceptionArgs args)
        {
            if (args.Value != null)
            {
                args.Value = ((string)args.Value).Trim().ToLowerInvariant();
            }

            args.ProceedSetValue();
        }
Esempio n. 47
0
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     args.ProceedGetValue();
     if (args.Value == null)
     {
         args.Value = IoCContainer.Resolver.TryGetInstance(args.Location.LocationType);
     }
     args.ProceedGetValue();
 }
 public void OnObservedCollectionPropertySet(LocationInterceptionArgs args)
 {
     var oldInstance = args.GetCurrentValue() as INotifyCollectionChanged;
     var newInstance = args.Value as INotifyCollectionChanged;
     if (oldInstance != null)
         oldInstance.CollectionChanged -= ObservedCollectionHandlers[args.LocationName];
     if (newInstance != null)
         newInstance.CollectionChanged += ObservedCollectionHandlers[args.LocationName];
     args.ProceedSetValue();
 }
 public void OnObservedReferencePropertySet(LocationInterceptionArgs args)
 {
     var oldInstance = args.GetCurrentValue() as INotifyPropertyChanged;
     var newInstance = args.Value as INotifyPropertyChanged;
     if (oldInstance != null)
         oldInstance.PropertyChanged -= ObservedPropertyHandlers[args.LocationName].Invoke;
     if (newInstance != null)
         newInstance.PropertyChanged += ObservedPropertyHandlers[args.LocationName].Invoke;
     args.ProceedSetValue();
 }
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     var symmetric = SymmetricMetaData.NewRandom();
     var encrypted = string.Format("{0}\0{1}",EncryptSymmetricKey(symmetric.Key.KeyBytes),EncryptData(args.Value.ToString(),symmetric));
     if (null != EncryptedValuesStore.Get())
         if (!EncryptedValuesStore.Get().ContainsKey(propname))
             EncryptedValuesStore.Get().Add(propname, encrypted);
         else
             EncryptedValuesStore.Get()[propname] = encrypted;
 }
        public override void OnSetValue( LocationInterceptionArgs args )
        {
            string s = (string) args.Value;
            if ( s == null )
                throw new ArgumentNullException( args.Location.Name );
            if ( !regex.IsMatch( s ) )
                throw new ArgumentOutOfRangeException( args.Location.Name );

            base.OnSetValue( args );
        }
        public void OnPropertyGet(LocationInterceptionArgs args)
        {
            if (args.Location.PropertyInfo.GetSetMethod(true) != null &&
                !this.propertySetList.Contains(args.LocationName))
            {
                throw new PropertyNotInitializedException(args.LocationFullName);
            }

            args.ProceedGetValue();
        }
        public void OnPropertySet( LocationInterceptionArgs args )
        {
            // Don't go further if the new value is equal to the old one.
            // (Possibly use object.Equals here).
            if ( args.Value == args.GetCurrentValue() ) return;

            // Actually sets the value.
            args.ProceedSetValue();

            this.OnPropertyChangedMethod.Invoke( args.Location.Name );
        }
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     args.ProceedGetValue(); // this actually fetches the field and populates the args.Value
     if (args.Value == null)
     {
         var activity = args.Instance as Activity;
         if (activity == null) throw new ArgumentException("LazyViewAttribute can only be used within Activities");
         args.SetNewValue(activity.FindViewById(_viewId));
         args.ProceedGetValue();
     }
 }
Esempio n. 55
0
 public override void OnGetValue(LocationInterceptionArgs args)
 {
     if (_backingField == null)
         lock (_syncRoot)
             if (_backingField == null)
             {
                 var locationType = args.Location.PropertyInfo.PropertyType;
                 _backingField = ObjectFactory.GetInstance(locationType);
             }
     args.Value = _backingField;
 }
        public void OnLocationSetValue(LocationInterceptionArgs args)
        {
            var proxy = GetProxy(args);

            if (proxy != null)
            {
                proxy.InterceptSet(args.Binding, args.Value);
                return;
            }

            args.ProceedSetValue();
        }
        public void OnSetValue( LocationInterceptionArgs args )
        {
            if ( args.Value != args.GetCurrentValue() )
            {
                args.ProceedSetValue();

               // We don't pass the property name because the UI is bound to
               // derived properties (DisplayName). We should track property
               // dependencies to do this correctly.
               this.OnPropertyChangedMethod(null);
            }
        }
 public override void OnSetValue(LocationInterceptionArgs args)
 {
     if(EncryptionKeysStore.Get().ContainsKey(propname))
     {
         string keyName = EncryptionKeysStore.Get()[propname];
         var encrypted = Encrypt(args.Value.ToString(), KeyServer.Get().GetKey(keyName));
         if (null != EncryptedValuesStore.Get())
             if (!EncryptedValuesStore.Get().ContainsKey(propname))
                 EncryptedValuesStore.Get().Add(propname, encrypted);
             else
                 EncryptedValuesStore.Get()[propname] = encrypted;
     }
 }
        public void OnPropertySet(LocationInterceptionArgs args)
        {
            if (args.Location.PropertyInfo.GetSetMethod(true) != null &&
                args.Location.PropertyInfo.DeclaringType != typeof(ContextSpecificationBase) &&
                this.propertySetList.Contains(args.LocationName))
            {
                throw new PropertyAlreadyInitializedException(args.LocationFullName);
            }

            this.propertySetList.Add(args.LocationName);

            args.ProceedSetValue();
        }
        /// <summary>
        /// Method intercepting all changes on field, making sure that the
        /// setting value matches the regular expression
        /// </summary>
        /// <param name="locationInterceptionArgs">Location Interception Arguments</param>
        //[OnLocationSetValueAdvice]
        //[MulticastPointcut(Targets = MulticastTargets.Property,
        //                    Attributes = MulticastAttributes.Public)]
        public override void OnSetValue(LocationInterceptionArgs locationInterceptionArgs)
        {
            bool isValid = RegEXPatterns.MatchFound(
                locationInterceptionArgs.Value.ToString(),
                this.Pattern);

            if (isValid == false)
            {
                return;
            }

            locationInterceptionArgs.ProceedSetValue();
        }