Beispiel #1
0
        protected virtual object GetAssemblyTitle(HelpParts parts)
        {
            string title = EffectiveAssembly?.GetCustomAttributes <AssemblyTitleAttribute>().FirstOrDefault()?.Title
                           ?? EffectiveAssembly?.GetName().Name;
            string version = EffectiveAssembly?.GetCustomAttributes <AssemblyInformationalVersionAttribute>().FirstOrDefault()?.InformationalVersion
                             ?? EffectiveAssembly?.GetName().Version.ToString();
            string line = string.Join(" ",
                                      parts.Has(HelpParts.AssemblyTitle) ? title : null,
                                      parts.Has(HelpParts.AssemblyVersion) ? version : null).Trim();

            return(new Div(line));
        }
Beispiel #2
0
 private object GetOptionsCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.Options) || !Info.Parts.Has(HelpParts.Options) || !Info.Options.Any(IsOptionVisible(parts)))
     {
         return(null);
     }
     return(GetOptions(parts));
 }
Beispiel #3
0
 private object GetErrorsCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.Errors) || !Info.Parts.Has(HelpParts.Errors) || Info.Errors.All(e => e.Message == null))
     {
         return(null);
     }
     return(GetErrors(parts));
 }
Beispiel #4
0
 private object GetExamplesCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.Examples) || !Info.Parts.Has(HelpParts.Examples) || !Info.Examples.SelectMany(e => e).Any())
     {
         return(null);
     }
     return(GetExamples(parts));
 }
Beispiel #5
0
 private object GetUsageCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.AssemblyUsage))
     {
         return(null);
     }
     return(GetUsage(parts));
 }
Beispiel #6
0
 private object GetAssemblyLicenseCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.AssemblyLicense))
     {
         return(null);
     }
     return(GetAssemblyLicense(parts));
 }
Beispiel #7
0
 private object GetAssemblyCopyrightCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.AssemblyCopyright))
     {
         return(null);
     }
     return(GetAssemblyCopyright(parts));
 }
Beispiel #8
0
 private object GetAssemblyTitleCore(HelpParts parts)
 {
     if (!parts.Has(HelpParts.AssemblyTitle | HelpParts.AssemblyVersion))
     {
         return(null);
     }
     return(GetAssemblyTitle(parts));
 }
Beispiel #9
0
        protected virtual object GetOption(OptionInfo option, HelpParts parts, bool isSubOption)
        {
            var m          = isSubOption ? SubOptionMargin : OptionMargin;
            var marginName = new Thickness(m.Left, m.Top, 1, m.Bottom);
            var marginText = new Thickness(0, m.Top, m.Right, m.Bottom);

            string values = parts.Has(HelpParts.OptionsValues) && option.HasHelpValues
                ? string.Join(", ", option.HelpValues) : null;
            string defaultValue = parts.Has(HelpParts.OptionsDefaultValue) && option.DefaultValue != null
                ? GetOptionDefault(option) : null;

            object subOptions = parts.Has(HelpParts.SubOptions) && option.SubOptions.Any(IsOptionVisible(parts))
                ? GetSubOptions(option, parts) : null;

            return(new[] {
                new Div {
                    Margin = marginName,
                    Color = isSubOption ? SubOptionNameColor : OptionNameColor,
                    TextWrap = TextWrap.WordWrapSpace,
                    Children = { option.HelpNameWithValue }
                },
                new Div {
                    Margin = marginText,
                    Color = OptionTextColor,
                    Children =
                    {
                        option.HelpText,
                        option.IsRequired ? " (Required)" : null,
                        values != null ? $"\nValid values: {values}" : null,
                        defaultValue != null ? $"\nDefault: {defaultValue}" : null
                    }
                },
                subOptions != null
                    ? new Div {
                    [Grid.ColumnSpanProperty] = 2,
                    Children = { subOptions }
                }
                    : null
            });
        }
Beispiel #10
0
 protected static Func <OptionInfo, bool> IsOptionVisible(HelpParts parts) =>
 option => (option.IsVisible || parts.Has(HelpParts.HiddenOptions)) && (!option.IsBuiltIn || parts.Has(HelpParts.BuiltInOptions));