private static T NewWorkItemCore <T>(string projectName, NewWorkItemOptions options) where T : GenericWorkItem, new() { if (projectName == null) { throw new ArgumentNullException(nameof(projectName)); } var typeName = GenericWorkItemHelpers <T> .WorkItemTypeName; if (string.IsNullOrWhiteSpace(typeName)) { throw new ArgumentException($"The type {typeof(T).FullName} is not linked to an workitem type"); } var result = new T { WorkItemType = typeName, Project = projectName }; if ((options & NewWorkItemOptions.FillAreaPath) == NewWorkItemOptions.FillAreaPath) { result.Area = projectName; } if ((options & NewWorkItemOptions.FillIterationPath) == NewWorkItemOptions.FillIterationPath) { result.Iteration = projectName; } return(result); }
public static T New <T>(this TeamProject project, NewWorkItemOptions options = NewWorkItemOptions.Nothing) where T : GenericWorkItem, new() { return(NewWorkItemCore <T>(project.Name, options)); }