예제 #1
0
 public void RemoveFieldValue(FieldValue fv)
 {
     fieldValues.Remove(fv);
     fieldValueDict.Remove(fv.FieldName);
 }
예제 #2
0
파일: Item.cs 프로젝트: ogazitt/zaplify
 public void RemoveFieldValue(FieldValue fv)
 {
     fieldValues.Remove(fv);
     fieldValueDict.Remove(fv.FieldName);
 }
예제 #3
0
파일: Item.cs 프로젝트: ogazitt/zaplify
        // get FieldValue of this Item for the given Field
        // if create == true, a new FieldValue with for this Field will be created if none exists
        public FieldValue GetFieldValue(Field field, bool create = false)
        {
            FieldValue fieldValue = null;

            // initialize the dictionary if necessary
            if (fieldValueDict == null)
                fieldValueDict = new Dictionary<string, FieldValue>();

            // try to get the FieldValue out of the dictionary (if it was already retrieved)
            if (fieldValueDict.TryGetValue(field.Name, out fieldValue) == true)
                return fieldValue;

            // get the fieldvalue associated with this field
            // this may fail if this item doesn't have this field set yet
            fieldValue = fieldValues.FirstOrDefault(fv => fv.FieldName == field.Name);
            if (fieldValue != null)
            {
                // store the new FieldValue in the dictionary
                fieldValueDict[field.Name] = fieldValue;
            }
            else
            {
                // if the caller wishes to create a new FieldValue, do so now
                if (create)
                {
                    fieldValue = new FieldValue()
                    {
                        FieldName = field.Name,
                        ItemID = this.ID,
                        Value = FieldTypes.DefaultValue(field.FieldType)
                    };

                    // store the new FieldValue in the dictionary
                    fieldValueDict[field.Name] = fieldValue;

                    if (fieldValues == null)
                        fieldValues = new ObservableCollection<FieldValue>();

                    // add the new FieldValue in the FieldValues collection
                    fieldValues.Add(fieldValue);
                }
            }

            return fieldValue;
        }
예제 #4
0
 public FieldValue(FieldValue fieldValue)
 {
     Copy(fieldValue);
 }
예제 #5
0
 public FieldValue(FieldValue fieldValue)
 {
     Copy(fieldValue);
 }
예제 #6
0
        public void Copy(FieldValue obj)
        {
            if (obj == null)
                return;

            // copy all of the properties
            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                // get the value of the property
                var val = pi.GetValue(obj, null);
                pi.SetValue(this, val, null);
            }
        }