18 using erminas.SmartAPI.CMS.Project;
 
   19 using erminas.SmartAPI.CMS.Project.Keywords;
 
   20 using erminas.SmartAPI.Exceptions;
 
   21 using erminas.SmartAPI.Utils;
 
   23 namespace erminas.SmartAPI.CMS.Converter
 
   25     internal class CategoryConverter : AbstractGuidElementConverter<ICategory>
 
   27         private const string ARBITRARY_CATEGORY_VALUE = 
"-1";
 
   31             var stringValue = element.GetAttributeValue(attribute.ElementName);
 
   33             if (
string.IsNullOrEmpty(stringValue))
 
   38             return stringValue == 
"-1" ? null : base.ConvertFrom(parent, element, attribute);
 
   41         public override void WriteTo(
IProjectObject parent, IXmlReadWriteWrapper element, RedDotAttribute attribute,
 
   44             CheckReadOnly(parent.
Project, attribute);
 
   46             if (value == ArbitraryCategory.INSTANCE)
 
   48                 element.SetAttributeValue(attribute.ElementName, ARBITRARY_CATEGORY_VALUE);
 
   52                 base.WriteTo(parent, element, attribute, value);
 
   66                                                  RedDotAttribute attribute, 
ICategory value)
 
   72                                             string.Format(
"Cannot find category {0} in project {1}", value.
Name, parent));