示例#1
0
文件: Field.cs 项目: ogazitt/zaplify
        public void Copy(Field obj)
        {
            if (obj == null)
                return;

            // copy all of the properties
            foreach (PropertyInfo pi in this.GetType().GetProperties())
            {
                var val = pi.GetValue(obj, null);
                pi.SetValue(this, val, null);
            }
        }
示例#2
0
文件: Field.cs 项目: ogazitt/zaplify
 public Field(Field field)
 {
     Copy(field);
 }
示例#3
0
文件: Item.cs 项目: ogazitt/zaplify
        public object GetFieldValue(Field field)
        {
            PropertyInfo pi = null;
            object currentValue = null;

            // get the current field value.
            // the value can either be in a strongly-typed property on the item (e.g. Name),
            // or in one of the FieldValues
            try
            {
                // get the strongly typed property
                pi = this.GetType().GetProperty(field.Name);
                if (pi != null)
                    currentValue = pi.GetValue(this, null);
            }
            catch (Exception)
            {
                // an exception indicates this isn't a strongly typed property on the Item
                // this is NOT an error condition
            }

            // if couldn't find a strongly typed property, this property could be stored as a
            // FieldValue on the item
            if (pi == null)
            {
                // get current item's value for this field
                FieldValue fieldValue = this.FieldValues.FirstOrDefault(fv => fv.FieldName == field.Name);
                if (fieldValue != null)
                    currentValue = fieldValue.Value;
            }

            return currentValue;
        }