private static MoreOptionsHavingBuilder GetMoreOptions(Action <IMoreOptionsHavingBuilder> moreOptionsAction) { var moreOptions = new MoreOptionsHavingBuilder(); if (moreOptionsAction == null) { return(moreOptions); } moreOptionsAction(moreOptions); return(moreOptions); }
private static string CreateTriggerBody(string buildConfigId, int?agentId, List <Property> properties = null, MoreOptionsHavingBuilder moreOptions = null) { var bodyBuilder = new StringBuilder(); bodyBuilder.Append(@"<build"); if (moreOptions != null) { if (moreOptions.TriggeringOptions.Personal == true) { bodyBuilder.Append(@" personal=""true"""); } if (moreOptions.HasBranch()) { var encodedName = SecurityElement.Escape(moreOptions.GetBranchName()); bodyBuilder.AppendFormat(@" branchName=""{0}""", encodedName); } } bodyBuilder.Append(@">").AppendLine(); bodyBuilder.AppendFormat(@"<buildType id=""{0}""/>", buildConfigId).AppendLine(); if (agentId.HasValue) { bodyBuilder.AppendFormat(@"<agent id=""{0}""/>", agentId).AppendLine(); } if (moreOptions != null && moreOptions.GetComment() != null) { var encodedName = SecurityElement.Escape(moreOptions.GetComment()); bodyBuilder.AppendFormat(@"<comment><text>{0}</text></comment>", encodedName).AppendLine(); } if (moreOptions != null && (moreOptions.TriggeringOptions.CleanSources == true || moreOptions.TriggeringOptions.QueueAtTop == true || moreOptions.TriggeringOptions.RebuildAllDependencies == true)) { bodyBuilder.Append(@"<triggeringOptions "); if (moreOptions.TriggeringOptions.CleanSources == true) { bodyBuilder.Append(@"cleanSources=""true"" "); } if (moreOptions.TriggeringOptions.RebuildAllDependencies == true) { bodyBuilder.Append(@"rebuildAllDependencies=""true"" "); } if (moreOptions.TriggeringOptions.QueueAtTop == true) { bodyBuilder.Append(@"queueAtTop=""true"" "); } bodyBuilder.Append(@"/>").AppendLine(); } if (properties != null && properties.Any()) { bodyBuilder.Append(@"<properties>").AppendLine(); foreach (var property in properties) { bodyBuilder.AppendFormat(@"<property name=""{0}"" value=""{1}""", property.Name, property.Value); if (property.Type != null && !string.IsNullOrEmpty(property.Type.RawValue)) { bodyBuilder.Append(">").AppendLine(); bodyBuilder.AppendFormat(@"<type rawValue=""{0}""/>", property.Type.RawValue).AppendLine(); bodyBuilder.Append("</property>").AppendLine(); } else { bodyBuilder.Append("/>").AppendLine(); } } bodyBuilder.Append(@"</properties>").AppendLine(); } if (moreOptions != null && moreOptions.HasChangeId()) { bodyBuilder.Append(@"<lastChanges>").AppendLine(); bodyBuilder.AppendFormat(@"<change id=""{0}""/>", moreOptions.GetChangeId()).AppendLine(); bodyBuilder.Append(@"</lastChanges>").AppendLine(); } bodyBuilder.Append("</build>").AppendLine(); return(bodyBuilder.ToString()); }