コード例 #1
0
        public void HelpSummary_SetProperty_ResultIsEmptySection(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Section = actual;
            Assert.IsEmpty(attribute.Section);
        }
コード例 #2
0
        public void HelpSummary_SetProperty_ResultIsEmptyHeading(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Heading = actual;
            Assert.IsEmpty(attribute.Heading);
        }
コード例 #3
0
        public void HelpSummary_SetProperty_TrimmedHeading(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Heading = actual;
            Assert.AreEqual(attribute.Heading, "Hello World");
        }
コード例 #4
0
        public void HelpSummary_SetProperty_ResultIsEmptyContent(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Content = actual;
            Assert.IsEmpty(attribute.Content);
        }
コード例 #5
0
        public void HelpSummary_SetProperty_TrimmedContent(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Content = actual;
            Assert.AreEqual(attribute.Content, "Hello World");
        }
コード例 #6
0
        public void HelpSummary_SetProperty_TrimmedOptions(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Options = actual;
            Assert.AreEqual(attribute.Options, "Hello World");
        }
コード例 #7
0
        public void HelpSummary_SetProperty_ResultIsEmptyOptions(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute();

            attribute.Options = actual;
            Assert.IsEmpty(attribute.Options);
        }
コード例 #8
0
        public void HelpSummary_Construction_ResultIsEmptyContent(String actual)
        {
            HelpSummaryAttribute attribute = new HelpSummaryAttribute(actual);

            Assert.IsEmpty(attribute.Content);
        }
コード例 #9
0
 /// <summary>
 /// Standard construction.
 /// </summary>
 /// <remarks>
 /// The only one and default constructor of this class.
 /// </remarks>
 /// <param name="property">
 /// An instance of property information to be applied.
 /// </param>
 /// <param name="setting">
 /// An instance of a parameter object attribute to be applied.
 /// </param>
 /// <param name="summary">
 /// An instance of a help summary attribute to be applied.
 /// </param>
 public HelpProcessorSetting(PropertyInfo property, ParameterObjectAttribute setting, HelpSummaryAttribute summary)
     : base()
 {
     this.Property = property ?? throw new ArgumentNullException(nameof(property));
     this.Setting  = setting ?? throw new ArgumentNullException(nameof(setting));
     this.Summary  = summary ?? throw new ArgumentNullException(nameof(summary));
 }
コード例 #10
0
        /// <summary>
        /// Initializes this instance with its default values.
        /// </summary>
        /// <remarks>
        /// This method initializes this instance with its default values.
        /// </remarks>
        public void Initialize()
        {
            this.License  = null;
            this.Preface  = null;
            this.Closure  = null;
            this.Utilizes = new List <HelpUtilizeAttribute>();
            this.Settings = new List <HelpProcessorSetting>();

            foreach (Attribute current in Attribute.GetCustomAttributes(this.Instance.GetType()))
            {
                if (current is HelpLicenseAttribute)
                {
                    this.License = this.FixupLicense(current as HelpLicenseAttribute);
                }
                else if (current is HelpPrefaceAttribute)
                {
                    this.Preface = this.FixupPreface(current as HelpPrefaceAttribute);
                }
                else if (current is HelpClosureAttribute)
                {
                    this.Closure = current as HelpClosureAttribute;
                }
                else if (current is HelpUtilizeAttribute)
                {
                    this.Utilizes.Add(this.FixupUtilize(current as HelpUtilizeAttribute));
                }
            }

            BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty;

            PropertyInfo[] properties = this.Instance.GetType().GetProperties(flags);

            if (properties != null)
            {
                foreach (PropertyInfo property in properties)
                {
                    HelpSummaryAttribute     summary   = null;
                    ParameterObjectAttribute parameter = null;

                    IEnumerable <Attribute> attributes = property.GetCustomAttributes();

                    if (attributes != null)
                    {
                        foreach (Attribute attribute in attributes)
                        {
                            if (attribute is ParameterObjectAttribute)
                            {
                                parameter = attribute as ParameterObjectAttribute;
                            }
                            else if (attribute is HelpSummaryAttribute)
                            {
                                summary = attribute as HelpSummaryAttribute;
                            }
                        }
                    }

                    if (property != null && parameter != null && summary != null)
                    {
                        this.Settings.Add(this.FixupSetting(new HelpProcessorSetting(property, parameter, summary)));
                    }
                }
            }
        }