Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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;
        }
Exemple #3
0
 public Field(Field field)
 {
     Copy(field);
 }