/// <summary>
 /// For loading from a string (created by ToString())
 /// </summary>
 public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, CswDelimitedString PropertyString)
     : base(CswNbtResources, View)
 {
     if (PropertyString[0] == CswEnumNbtViewNodeType.CswNbtViewProperty.ToString())
     {
         if (PropertyString[1] != string.Empty)
         {
             Type = PropertyString[1];
         }
         if (PropertyString[2] != string.Empty)
         {
             NodeTypePropId = CswConvert.ToInt32(PropertyString[2]);
         }
         if (PropertyString[3] != string.Empty)
         {
             Name = PropertyString[3];
         }
         //if( Values[4] != string.Empty )
         //    ArbitraryId = Values[4];
         if (PropertyString[5] != string.Empty)
         {
             SortBy = Convert.ToBoolean(PropertyString[5]);
         }
         if (PropertyString[6] != string.Empty)
         {
             SortMethod = PropertyString[6];
         }
         if (PropertyString[7] != string.Empty)
         {
             FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(PropertyString[7]);
         }
         if (PropertyString[8] != string.Empty)
         {
             Order = CswConvert.ToInt32(PropertyString[8]);
         }
         if (PropertyString[9] != string.Empty)
         {
             Width = CswConvert.ToInt32(PropertyString[9]);
         }
         if (PropertyString[10] != string.Empty)
         {
             ObjectClassPropId = CswConvert.ToInt32(PropertyString[10]);
         }
         if (PropertyString[11] != string.Empty)
         {
             ShowInGrid = CswConvert.ToBoolean(PropertyString[11]);
         }
     }
 }
 /// <summary>
 /// View property constructor
 /// </summary>
 public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, ICswNbtMetaDataProp Prop)
     : base(CswNbtResources, View)
 {
     if (Prop is CswNbtMetaDataNodeTypeProp)
     {
         this.Type           = CswEnumNbtViewPropType.NodeTypePropId;
         this.NodeTypePropId = ((CswNbtMetaDataNodeTypeProp)Prop).FirstPropVersionId;
     }
     else if (Prop is CswNbtMetaDataObjectClassProp)
     {
         this.Type = CswEnumNbtViewPropType.ObjectClassPropId;
         this.ObjectClassPropId = ((CswNbtMetaDataObjectClassProp)Prop).PropId;
     }
     this.FieldType = Prop.getFieldTypeValue();
     this.Name      = Prop.PropName;
 }
        /// <summary>
        /// For loading from JSON
        /// </summary>
        public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, JObject PropObj)
            : base(CswNbtResources, View)
        {
            try
            {
                string _Type = CswConvert.ToString(PropObj["type"]);
                if (!string.IsNullOrEmpty(_Type))
                {
                    Type = _Type;
                }

                Int32 _Value = CswConvert.ToInt32(PropObj["value"]);
                if (Int32.MinValue != _Value)  //backwards compatibility
                {
                    if (Type == CswEnumNbtViewPropType.NodeTypePropId)
                    {
                        NodeTypePropId = _Value;
                    }
                    else
                    {
                        ObjectClassPropId = _Value;
                    }
                }

                Int32 _NtPropId = CswConvert.ToInt32(PropObj["nodetypepropid"]);
                if (Int32.MinValue != _NtPropId)
                {
                    NodeTypePropId = _NtPropId;
                }

                Int32 _OcPropId = CswConvert.ToInt32(PropObj["objectclasspropid"]);
                if (Int32.MinValue != _OcPropId)
                {
                    ObjectClassPropId = _OcPropId;
                }

                string _Name = CswConvert.ToString(PropObj["name"]);
                if (!string.IsNullOrEmpty(_Name))
                {
                    Name = _Name;
                }

                if (PropObj["sortby"] != null)
                {
                    bool _Sort = CswConvert.ToBoolean(PropObj["sortby"]);
                    SortBy = _Sort;
                }

                string _SortedMethod = CswConvert.ToString(PropObj["sortmethod"]);
                if (!string.IsNullOrEmpty(_SortedMethod))
                {
                    SortMethod = _SortedMethod;
                }


                string _FieldType = CswConvert.ToString(PropObj["fieldtype"]);
                if (!string.IsNullOrEmpty(_FieldType))
                {
                    FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(_FieldType);
                }

                Int32 _Order = CswConvert.ToInt32(PropObj["order"]);
                if (Int32.MinValue != _Order)
                {
                    Order = _Order;
                }

                Int32 _Width = CswConvert.ToInt32(PropObj["width"]);
                if (Int32.MinValue != _Width)
                {
                    Width = _Width;
                }

                ShowInGrid = CswConvert.ToBoolean(PropObj["showingrid"]);
            }
            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                          "CswViewProperty.constructor(xmlnode) encountered an invalid attribute value",
                                          ex);
            }
            try
            {
                JProperty FiltersProp = PropObj.Property(_FiltersName);
                if (null != FiltersProp)
                {
                    JObject FiltersObj = (JObject)FiltersProp.Value;
                    foreach (CswNbtViewPropertyFilter Filter in
                             from FilterProp
                             in FiltersObj.Properties()
                             select(JObject) FilterProp.Value
                             into FilterObj
                             let NodeName = CswConvert.ToString(FilterObj["nodename"])
                                            where NodeName == CswEnumNbtViewXmlNodeName.Filter.ToString().ToLower()
                                            select new CswNbtViewPropertyFilter(CswNbtResources, _View, FilterObj))
                    {
                        this.addFilter(Filter);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                          "CswViewProperty.constructor(xmlnode) encountered an invalid filter definition",
                                          ex);
            }
        }
 /// <summary>
 /// For loading from XML
 /// </summary>
 public CswNbtViewProperty(CswNbtResources CswNbtResources, CswNbtView View, XmlNode PropNode)
     : base(CswNbtResources, View)
 {
     try
     {
         if (PropNode.Attributes["type"] != null)
         {
             Type = PropNode.Attributes["type"].Value;
         }
         if (PropNode.Attributes["value"] != null)    //backwards compatibility
         {
             if (Type == CswEnumNbtViewPropType.NodeTypePropId)
             {
                 NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
             else
             {
                 ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["value"].Value);
             }
         }
         if (PropNode.Attributes["nodetypepropid"] != null)
         {
             NodeTypePropId = CswConvert.ToInt32(PropNode.Attributes["nodetypepropid"].Value);
         }
         if (PropNode.Attributes["objectclasspropid"] != null)
         {
             ObjectClassPropId = CswConvert.ToInt32(PropNode.Attributes["objectclasspropid"].Value);
         }
         if (PropNode.Attributes["name"] != null)
         {
             Name = PropNode.Attributes["name"].Value;
         }
         //if( PropNode.Attributes["arbitraryid"] != null )
         //    ArbitraryId = PropNode.Attributes["arbitraryid"].Value;
         if (PropNode.Attributes["sortby"] != null)
         {
             SortBy = Convert.ToBoolean(PropNode.Attributes["sortby"].Value);
         }
         if (PropNode.Attributes["sortmethod"] != null)
         {
             SortMethod = PropNode.Attributes["sortmethod"].Value;
         }
         if (PropNode.Attributes["fieldtype"] != null && PropNode.Attributes["fieldtype"].Value != string.Empty)
         {
             FieldType = CswNbtMetaDataFieldType.getFieldTypeFromString(PropNode.Attributes["fieldtype"].Value);
         }
         if (PropNode.Attributes["order"] != null && PropNode.Attributes["order"].Value != string.Empty)
         {
             Order = CswConvert.ToInt32(PropNode.Attributes["order"].Value);
         }
         if (PropNode.Attributes["width"] != null && PropNode.Attributes["width"].Value != string.Empty)
         {
             Width = CswConvert.ToInt32(PropNode.Attributes["width"].Value);
         }
         if (PropNode.Attributes["showingrid"] != null && PropNode.Attributes["showingrid"].Value != string.Empty)
         {
             ShowInGrid = CswConvert.ToBoolean(PropNode.Attributes["showingrid"].Value);
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid attribute value",
                                   ex);
     }
     try
     {
         foreach (XmlNode ChildNode in PropNode.ChildNodes)
         {
             if (ChildNode.Name.ToLower() == CswEnumNbtViewXmlNodeName.Filter.ToString().ToLower())
             {
                 CswNbtViewPropertyFilter Filter = new CswNbtViewPropertyFilter(CswNbtResources, _View, ChildNode);
                 this.addFilter(Filter);
             }
         }
     }
     catch (Exception ex)
     {
         throw new CswDniException(CswEnumErrorType.Error, "Misconfigured CswViewProperty",
                                   "CswViewProperty.constructor(xmlnode) encountered an invalid filter definition",
                                   ex);
     }
 }