コード例 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="PropertyAccessor{T}"/> with a specific underlying property value.
        /// </summary>
        /// <param name="value">The value of the property.</param>
        /// <param name="propertyAccessController">The access controller to use.</param>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="allowedAccess">The allowed access of the property.</param>
        internal PropertyAccessor(T value, PropertyAccessController propertyAccessController, string propertyName, BindingAccess allowedAccess)
        {
            this.propertyAccessController = propertyAccessController;
            this.allowedAccess            = allowedAccess;
            this.propertyName             = propertyName;

            this.value = value; //This bypasses change tracking and locking - but it's okay since we're in the constructor
        }
コード例 #2
0
        /// <summary>
        /// Executes the specified <paramref name="propertyWriteAction"/>
        /// </summary>
        /// <param name="propertyWriteAction">The write action.</param>
        /// <param name="allowedAccess">The allowed access of the particular property.</param>
        /// <param name="propertyName">The name of the property.</param>
        public void WriteProperty(Action propertyWriteAction, BindingAccess allowedAccess, string propertyName)
        {
            if (!this.IsAccessAllowed(BindingAccess.Write, allowedAccess))
            {
                throw new InvalidOperationException(string.Format(BatchErrorMessages.PropertiesWriteAccessViolation, propertyName, this.bindingState.ToString()));
            }

            propertyWriteAction();
        }
コード例 #3
0
        /// <summary>
        /// Executes the specified <paramref name="propertyReadAction"/>.
        /// </summary>
        /// <typeparam name="T">The type of the property to read.</typeparam>
        /// <param name="propertyReadAction">The property read action to execute.</param>
        /// <param name="allowedAccess">The allowed access of the particular property.</param>
        /// <param name="propertyName">The name of the property.</param>
        /// <returns>The result of the <paramref name="propertyReadAction"/>.</returns>
        public T ReadProperty <T>(Func <T> propertyReadAction, BindingAccess allowedAccess, string propertyName)
        {
            if (!this.IsAccessAllowed(BindingAccess.Read, allowedAccess))
            {
                throw new InvalidOperationException(string.Format(BatchErrorMessages.PropertiesReadAccessViolation, propertyName, this.bindingState.ToString()));
            }

            return(propertyReadAction());
        }
コード例 #4
0
        private void SetValue(T value, bool overrideReadOnly, bool overrideAccessControl)
        {
            T originalValue = this.value;

            BindingAccess access = overrideAccessControl ? BindingAccess.Write : this.allowedAccess;

            this.propertyAccessController.WriteProperty(() =>
            {
                this.ThrowIfReadOnly(overrideReadOnly);
                this.value = value;
            },
                                                        access,
                                                        this.propertyName);

            //It makes sense to set this to true even if the value didn't change because in some cases the current client state of the property
            //doesn't actually match the real server state (for example in cases where a select clause is used). In cases like this, the client has made
            //a property assignment, and they want their property assignment to propagate to the server.
            this.valueHasChanged = true;
        }
コード例 #5
0
        public static string GenerateBindingAccessString(BindingAccess access)
        {
            List <string> allowedAccesses = new List <string>();

            if (access.HasFlag(BindingAccess.Read))
            {
                allowedAccesses.Add("BindingAccess.Read");
            }

            if (access.HasFlag(BindingAccess.Write))
            {
                allowedAccesses.Add("BindingAccess.Write");
            }

            if (!allowedAccesses.Any())
            {
                allowedAccesses.Add("BindingAccess.None");
            }

            return(string.Join(" | ", allowedAccesses));
        }
コード例 #6
0
 public DummyPropertyCollection(BindingState bindingState, BindingAccess access) : base(bindingState)
 {
     this.DummyProperty = this.CreatePropertyAccessor <int>(string.Empty, access);
 }
コード例 #7
0
        private bool IsAccessAllowed(BindingAccess requestedAccess, BindingAccess allowedAccess)
        {
            bool accessAllowed = allowedAccess.HasFlag(requestedAccess);

            return(accessAllowed);
        }
コード例 #8
0
ファイル: PropertyCollection.cs プロジェクト: QITIE/ADLSTool
        /// <summary>
        /// Creates a <see cref="PropertyAccessor{T}"/> included in this <see cref="PropertyCollection"/>.
        /// </summary>
        /// <typeparam name="T">The type of the underlying property.</typeparam>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="allowedAccess">The allowed access of the <see cref="PropertyAccessor{T}"/>.</param>
        /// <returns>A <see cref="PropertyAccessor{T}"/> included in this <see cref="PropertyCollection"/>.</returns>
        internal PropertyAccessor <T> CreatePropertyAccessor <T>(string propertyName, BindingAccess allowedAccess)
        {
            var result = new PropertyAccessor <T>(this.propertyAccessController, propertyName, allowedAccess);

            this.propertyMetadata.Add(result);

            return(result);
        }
コード例 #9
0
 /// <summary>
 /// Creates a new instance of <see cref="PropertyAccessor{T}"/> with the default underlying property value.
 /// </summary>
 /// <param name="propertyAccessController">The access controller to use.</param>
 /// <param name="propertyName">The name of the property.</param>
 /// <param name="allowedAccess">The allowed access of the property.</param>
 internal PropertyAccessor(PropertyAccessController propertyAccessController, string propertyName, BindingAccess allowedAccess)
 {
     this.propertyAccessController = propertyAccessController;
     this.allowedAccess            = allowedAccess;
     this.propertyName             = propertyName;
 }
コード例 #10
0
        private T GetValue(bool overrideAccessControl)
        {
            BindingAccess access = overrideAccessControl ? BindingAccess.Read : this.allowedAccess;

            return(this.propertyAccessController.ReadProperty(() => this.value, access, this.propertyName));
        }