示例#1
0
        protected void SetValue(string propertyName, object value)
        {
            if (this.RecordState == RecordState.Deleted)
            {
                throw new InvalidOperationException();
            }
            if (propertyName == null)
            {
                throw new ArgumentNullException();
            }
            var fieldInfo = Resource.GetFieldInfo(typeof(TRecord), propertyName);

            if (fieldInfo == null)
            {
                throw new InvalidDefinitionException();
            }
            if ((fieldInfo.IsPrimaryKeySegment ||
                 !fieldInfo.IsModifiable) &&
                this.RecordState != RecordState.Detached)
            {
                throw new InvalidOperationException();
            }
            fieldInfo.ConvertBack(value, this.DataBuffer);
            this.ChangeState(RecordStateTransitions.Modify);
        }
示例#2
0
        public static FieldInfo GetFieldInfo(this BinaryExpression fixedExpression, ParameterExpression argument)
        {
            FieldInfo result = null;
            var       memberAccessExpression = fixedExpression.Left as MemberExpression;

            if (memberAccessExpression != null &&
                memberAccessExpression.Expression.Equals(argument))
            {
                result = Resource.GetFieldInfo(memberAccessExpression.Member);
            }
            return(result);
        }
示例#3
0
        protected object GetValue()
        {
            var method    = new StackFrame(1).GetMethod();
            var fieldInfo = Resource.GetFieldInfo(method);

            if (fieldInfo == null)
            {
                throw new InvalidDefinitionException();
            }
            var result = fieldInfo.Convert(this.DataBuffer);

            return(result);
        }
示例#4
0
        public static FieldInfo GetField(this Expression expression, ParameterExpression argument)
        {
            var memberExpression = expression as MemberExpression;

            if (memberExpression != null &&
                memberExpression.Expression.Equals(argument))
            {
                return(Resource.GetFieldInfo(memberExpression.Member));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        protected object GetValue(string propertyName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException();
            }
            var fieldInfo = Resource.GetFieldInfo(typeof(TRecord), propertyName);

            if (fieldInfo == null)
            {
                throw new InvalidDefinitionException();
            }
            var result = fieldInfo.Convert(this.DataBuffer);

            return(result);
        }
示例#6
0
        protected void SetValue(object value)
        {
            if (this.RecordState == RecordState.Deleted)
            {
                throw new InvalidOperationException();
            }
            var method    = new StackFrame(1).GetMethod();
            var fieldInfo = Resource.GetFieldInfo(method);

            if (fieldInfo == null)
            {
                throw new InvalidDefinitionException();
            }
            if ((fieldInfo.IsPrimaryKeySegment ||
                 !fieldInfo.IsModifiable) &&
                this.RecordState != RecordState.Detached)
            {
                throw new InvalidOperationException();
            }
            fieldInfo.ConvertBack(value, this.DataBuffer);
            this.ChangeState(RecordStateTransitions.Modify);
        }