public string Write(T target) { var sb = new StringBuilder(); var props = target.InstanceProperties().ToList(); if (ArgsInfo.CommandProperty != null) { var value = ArgsInfo.CommandProperty.GetValue(target, null); sb.AppendFormat("\"{0}\" ", value); } foreach (var pe in ArgsInfo.SwitchProperties.ForInstance(target)) { var value = pe.Value; if (value != null) { var name = ArgsInfo.GetSwitchNames(pe.Property).First(); sb.Append("/"); sb.Append(name); sb.Append("="); sb.Append(value); sb.Append(" "); } } return(sb.ToString()); }
public void Generate(TextWriter writer) { writer.WriteLine("Usage:"); if (Info.CommandProperty != null) { writer.Write("[{0}]", Info.CommandProperty.Name); } foreach (var pe in Info.SwitchProperties) { writer.Write(" "); var name = Info.GetSwitchNames(pe).First(); if (name != pe.Name) { writer.Write("/[{0} ({1})]", name, pe.Name); } else { writer.Write("/[{0}]", name, pe.Name); } } writer.WriteLine(); }