Esempio n. 1
0
 public bool ClearOwnValue(FieldKey key)
 {
     if (OwnValues != null)
     {
         var index = OwnValues.IndexOfKey(key);
         if (index >= 0)
         {
             OwnValues.RemoveAt(index);
             if (OwnValues.Count == 0)
             {
                 OwnValues = null;
             }
             return(true);
         }
     }
     return(false);
 }
Esempio n. 2
0
        public void Merge(FieldList other)
        {
            var fieldKey = SystemField.DeletedKeys.ToFieldKey();

            if (other.TryGetValue(fieldKey, out object value))
            {
                var deletedKeys = value as List <FieldKey>;
                if (deletedKeys != null)
                {
                    foreach (var key in deletedKeys)
                    {
                        this.Remove(key);
                    }
                }
                other.Remove(fieldKey);
            }

            foreach (var pair in other)
            {
                this[pair.Key] = pair.Value;
            }
        }
Esempio n. 3
0
        public void SetValue(FieldKey key, object value)
        {
            var type         = value.GetType();
            var fieldMeta    = FieldMeta.Get(key);
            var expectedType = fieldMeta.FieldType;

            if (type != expectedType)
            {
                var producerInterace = typeof(IValueProducer <>).MakeGenericType(expectedType);
                if (!type.IsImplementInterface(producerInterace))
                {
                    throw new System.Exception("Field type doesn't match!");
                }
            }

            if (OwnValues == null)
            {
                OwnValues = new FieldList();
            }

            OwnValues[key] = value;
        }