Download YamlDotNetTypeConverter.zip, last updated 01/04/2017 (27.73 KB)

Download
  • md5: 66fdcbddcff158af2b4d7d8756150c2a
  • sha1: a31655e072b0d1cebb4a03a51c3780cadaaf3d24
  • sha256: 70865eff552b26245c036320b92b2d2f010b0e62cffb0b7f9b4728e972509a6a
using System.Collections.Specialized;
using System.ComponentModel;

// Using custom type converters with C# and YamlDotNet, part 1
// http://www.cyotek.com/blog/using-custom-type-converters-with-csharp-and-yamldotnet-part-1

// This work is licensed under the Creative Commons Attribution 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

namespace YamlDotNetTypeConverter
{
  internal sealed class ContentCategory
  {
    #region Fields

    private ContentCategoryCollection _categories;

    private ContentCategory _parent;

    private StringCollection _topics;

    #endregion

    #region Properties

    [Browsable(false)]
    //[YamlMember(Order = 4)]
    public ContentCategoryCollection Categories
    {
      get
      {
        return _categories ?? (_categories = new ContentCategoryCollection
                                             {
                                               Parent = this
                                             });
      }
      set { _categories = value; }
    }

    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [DefaultValue(false)]
    //[YamlIgnore]
    public bool HasCategories
    {
      get { return _categories != null && _categories.Count != 0; }
    }

    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [DefaultValue(false)]
    //[YamlIgnore]
    public bool HasTopics
    {
      get { return _topics != null && _topics.Count != 0; }
    }

    //[YamlMember(Order = 1)]
    public string Name { get; set; }

    [Browsable(false)]
    //[YamlIgnore]
    public ContentCategory Parent
    {
      get { return _parent; }
      set { _parent = value; }
    }

    //[YamlMember(Order = 2)]
    public string Title { get; set; }

    [Browsable(false)]
    //[YamlMember(Order = 3)]
    public StringCollection Topics
    {
      get { return _topics ?? (_topics = new StringCollection()); }
      set { _topics = value; }
    }

    #endregion
  }
}

Donate

Donate