示例#1
0
        private AttributeChange AvpToAttributeChange(KeyValuePair <string, IList <string> > kvp, AttributeModificationType modificationType)
        {
            ExtendedAttributeType type = ActiveConfig.DB.GetAttribute(kvp.Key).Type;

            switch (modificationType)
            {
            case AttributeModificationType.Replace:
                if (kvp.Value == null)
                {
                    return(AttributeChangeDetached.CreateAttributeDelete(kvp.Key));
                }
                else
                {
                    return(AttributeChangeDetached.CreateAttributeReplace(kvp.Key, kvp.Value.Select(t => TypeConverter.ConvertData(t, type)).ToList <object>()));
                }

            case AttributeModificationType.Add:
                return(AttributeChangeDetached.CreateAttributeAdd(kvp.Key, kvp.Value.Select(t => TypeConverter.ConvertData(t, type)).ToList <object>()));

            case AttributeModificationType.Delete:
                return(AttributeChangeDetached.CreateAttributeDelete(kvp.Key));

            default:
            case AttributeModificationType.Update:
            case AttributeModificationType.Unconfigured:
                throw new InvalidOperationException();
            }
        }
 private void DB_OnAttributeRename(AcmaSchemaAttribute attribute, string oldName)
 {
     foreach (var item in this.ToList())
     {
         if (item.Model.Name == oldName)
         {
             AttributeChange change = new AttributeChangeDetached(attribute.Name, item.Model.ModificationType, item.Model.ValueChanges);
             this.Remove(item);
             this.Add(change);
         }
     }
 }