TemplateElement Macro_Push_FirstCommit_MessageSummary(TemplateFragmentMacro fragment) { string macroName = fragment.MacroName; if (String.Compare("FirstCommit.MessageSummary", macroName, StringComparison.Ordinal) != 0) { throw new ArgumentException("Macro name must be 'FirstCommit.MessageSummary'", "fragment"); } var propref = new TemplateElementPropertyReference <Commit> ("Message"); return(new TemplateElementSynthetic <Push> (GetElementArgumentList(fragment), (Push data, List <TemplateElementArgument> args) => { List <Commit> commits = data.Commits; if (commits == null || commits.Count == 0) { return null; } Commit first = commits[0]; string ret = propref.Generate(first); if (String.IsNullOrEmpty(ret)) { return null; } return ShortenString(ret, args, 72); }) { SkipNewlineIfLineEmpty = true }); }
TemplateElement Macro_Push_FirstCommit(TemplateFragmentMacro fragment) { string macroName = fragment.MacroName; if (!macroName.StartsWith("FirstCommit", StringComparison.Ordinal)) { throw new ArgumentException("Macro name must start with FirstCommit", "fragment"); } string propName = macroName.Substring(12); if (String.IsNullOrEmpty(propName)) { throw new InvalidOperationException("A non-empty property name is required."); } var propref = new TemplateElementPropertyReference <Commit> (propName); return(new TemplateElementSynthetic <Push> (GetElementArgumentList(fragment), (Push data, List <TemplateElementArgument> args) => { List <Commit> commits = data.Commits; if (commits == null || commits.Count == 0) { return null; } Commit first = commits[0]; return ShortenString(propref.Generate(first), args, -1); }) { SkipNewlineIfLineEmpty = true }); }