private void AppendArgDetailsToBuff(CmdArgAttribute attr, StringBuilder usagebuff) { if (!string.IsNullOrEmpty(attr.Description)) { usagebuff.Append("\n\n"); usagebuff.Append(" "); if (!attr.IsOrdinal()) { usagebuff.Append("/"); } //if the arg is keyed print the key before the description //otherwise if the arg is ordinal print the valuemoniker if it isn't null //if the value moniker is null print %index usagebuff.Append(attr.IsKeyed() ? attr.Key : attr.ValueMoniker ?? "%" + attr.Index.ToString()); //if there are alternate keys append them if (attr.AlternateKeys != null && attr.AlternateKeys.Length > 0) { usagebuff.Append(" (/"); usagebuff.Append(string.Join(" | /", attr.AlternateKeys)); usagebuff.Append(")"); } usagebuff.Append(":\n "); usagebuff.Append(attr.Description); } }
protected bool FindArgValue(CmdArgAttribute argAttr, out object val) { bool found = false; val = null; if (found = this.settings.ContainsKey(argAttr.Key)) { val = this.GetSettingValue(argAttr.Key, argAttr.Type); } if (!found && (argAttr.AlternateKeys != null)) { for (int i = 0; i < argAttr.AlternateKeys.Length && !found; i++) { if (found = this.settings.ContainsKey(argAttr.AlternateKeys[i])) { val = this.GetSettingValue(argAttr.AlternateKeys[i], argAttr.Type); } } } return(found); }