Beispiel #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();
            }
        }