diff --git a/ClientSamples.Runner/App.config b/ClientSamples.Runner/App.config new file mode 100644 index 0000000..151cc15 --- /dev/null +++ b/ClientSamples.Runner/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ClientSamples.Runner/ClientSamples.Runner.csproj b/ClientSamples.Runner/ClientSamples.Runner.csproj new file mode 100644 index 0000000..651d56a --- /dev/null +++ b/ClientSamples.Runner/ClientSamples.Runner.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {0CDA3AB5-3C7A-43D2-875C-66ED734CF864} + Exe + Vsts.ClientSamples.Runner + Vsts.ClientSamples.Runner + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.VisualStudio.Services.Client.15.113.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll + + + ..\packages\Microsoft.VisualStudio.Services.Client.15.113.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll + + + ..\packages\Microsoft.VisualStudio.Services.Client.15.113.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll + + + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll + + + + + + + + + + + + + + + + + + + {545851e1-9bd9-4939-8af4-9a8910cf5c34} + ClientSamples + + + + \ No newline at end of file diff --git a/ClientSamples.Runner/Program.cs b/ClientSamples.Runner/Program.cs new file mode 100644 index 0000000..8365b36 --- /dev/null +++ b/ClientSamples.Runner/Program.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Vsts.ClientSamples.Runner +{ + public class ClientSampleProgram + { + + public static int Main(string[] args) + { + if (args.Length == 0) + { + ShowUsage(); + return 0; + } + + Uri connectionUrl; + string area, resource; + + try + { + CheckArguments(args, out connectionUrl, out area, out resource); + } + catch (ArgumentException ex) + { + Console.WriteLine(ex.Message); + return -1; + } + + Dictionary> runnableMethodsBySample = ClientSampleUtils.GetRunnableMethods(area, resource); + if (runnableMethodsBySample.Any()) + { + ClientSampleContext context = new ClientSampleContext(connectionUrl); + + foreach (var item in runnableMethodsBySample) + { + ClientSample clientSample = item.Key; + clientSample.Context = context; + + foreach (var runnableMethod in item.Value) + { + try + { + context.Log("Running client sample {0}/{1}/{2}:", runnableMethod.Area, runnableMethod.Resource, runnableMethod.MethodBase.Name); + context.Log(""); + + runnableMethod.MethodBase.Invoke(clientSample, null); + } + catch (Exception ex) + { + context.Log(" Excception during run: " + ex.Message); + } + finally + { + context.Log("--------------------------------------"); + context.Log(""); + } + } + } + } + + return 0; + } + + private static void CheckArguments(string[] args, out Uri connectionUrl, out string area, out string resource) + { + try + { + connectionUrl = new Uri(args[0]); + } + catch (Exception) + { + throw new ArgumentException("Invalid URL"); + } + + if (args.Length > 1) + { + area = args[1]; + //if (!IsValidArea(area)) + //{ + // throw new ArgumentException("Invalid area. Supported areas: {0}.", String.Join(", ", GetSupportedAreas())); + //} + + if (args.Length > 2) + { + resource = args[2]; + // if (!IsValidResource(area, resource)) + // { + // throw new ArgumentException("Invalid resource. Supported resources for {0}: {1}.", area, String.Join(", ", GetSupportedAreas())); + // } + } + else + { + resource = null; + } + } + else + { + area = null; + resource = null; + } + } + + private static void ShowUsage() { + Console.WriteLine("Runs the client samples on a Team Services account or Team Foundation Server instance."); + Console.WriteLine(""); + Console.WriteLine("WARNING: Some samples are destructive. Always run on a test account or collection."); + Console.WriteLine(""); + Console.WriteLine("Usage: ClientSampleProgram url [area [resource]]"); + Console.WriteLine(""); + Console.WriteLine(" url URL for the account or collection to run the samples on"); + Console.WriteLine(" Example: https://fabrikam.visualstudio.com"); + Console.WriteLine(" area Run only samples for this area, otherwise run the samples for all areas."); + Console.WriteLine(" resource Run only samples for this resource, otherwise run the samples for all resources under this area (or all areas)."); + Console.WriteLine(""); + } + + } + +} \ No newline at end of file diff --git a/ClientSamples.Runner/Properties/AssemblyInfo.cs b/ClientSamples.Runner/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..866f4f5 --- /dev/null +++ b/ClientSamples.Runner/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ClientSamples.Runner")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClientSamples.Runner")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0cda3ab5-3c7a-43d2-875c-66ed734cf864")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ClientSamples.Runner/packages.config b/ClientSamples.Runner/packages.config new file mode 100644 index 0000000..182f3c4 --- /dev/null +++ b/ClientSamples.Runner/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ClientSamples.Tests.Integration/Notification/SubscriptionsTest.cs b/ClientSamples.Tests.Integration/Notification/SubscriptionsTest.cs index fcadfa3..0e1a366 100644 --- a/ClientSamples.Tests.Integration/Notification/SubscriptionsTest.cs +++ b/ClientSamples.Tests.Integration/Notification/SubscriptionsTest.cs @@ -2,11 +2,11 @@ using System.Text; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; -using VstsSamples.Client.Tests.Integration; -using VstsSamples.Client.Notification; +using Vsts.ClientSamples.Tests.Integration; +using Vsts.ClientSamples.Notification; using Microsoft.VisualStudio.Services.Notifications.WebApi; -namespace VstsSamples.Client.Tests.Integration.Notification +namespace Vsts.ClientSamples.Tests.Integration.Notification { [TestClass] public class SubscriptionTests : TestBase diff --git a/ClientSamples.Tests.Integration/TestBase.cs b/ClientSamples.Tests.Integration/TestBase.cs index 663c429..8f34a09 100644 --- a/ClientSamples.Tests.Integration/TestBase.cs +++ b/ClientSamples.Tests.Integration/TestBase.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace VstsSamples.Client.Tests.Integration +namespace Vsts.ClientSamples.Tests.Integration { public class TestBase where T : ClientSample, new() { @@ -51,10 +51,10 @@ namespace VstsSamples.Client.Tests.Integration string userName = TestContext.Properties["password"] as string; string password = TestContext.Properties["password"] as string; - ClientSampleConfiguration configuration = new ClientSampleConfiguration(new Uri(connectionUrl), new VssBasicCredential(userName, password)); + ClientSampleContext context = new ClientSampleContext(new Uri(connectionUrl), new VssBasicCredential(userName, password)); ClientSample = new T(); - ClientSample.Configuration = configuration; + ClientSample.Context = configuration; } protected Guid GetCurrentUserId() diff --git a/ClientSamples.sln b/ClientSamples.sln index d5b696a..fa3d33c 100644 --- a/ClientSamples.sln +++ b/ClientSamples.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26223.1 +VisualStudioVersion = 15.0.26228.9 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSamples", "ClientSamples\ClientSamples.csproj", "{545851E1-9BD9-4939-8AF4-9A8910CF5C34}" EndProject @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientSamples.Runner", "ClientSamples.Runner\ClientSamples.Runner.csproj", "{0CDA3AB5-3C7A-43D2-875C-66ED734CF864}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {AAA30379-02BF-447C-829C-225E2D2B1069}.Debug|Any CPU.Build.0 = Debug|Any CPU {AAA30379-02BF-447C-829C-225E2D2B1069}.Release|Any CPU.ActiveCfg = Release|Any CPU {AAA30379-02BF-447C-829C-225E2D2B1069}.Release|Any CPU.Build.0 = Release|Any CPU + {0CDA3AB5-3C7A-43D2-875C-66ED734CF864}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CDA3AB5-3C7A-43D2-875C-66ED734CF864}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CDA3AB5-3C7A-43D2-875C-66ED734CF864}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CDA3AB5-3C7A-43D2-875C-66ED734CF864}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ClientSamples/Auth/InteractiveAuthSample.cs b/ClientSamples/Auth/InteractiveAuthSample.cs index aca3456..fe0b88f 100644 --- a/ClientSamples/Auth/InteractiveAuthSample.cs +++ b/ClientSamples/Auth/InteractiveAuthSample.cs @@ -9,7 +9,7 @@ using System.Linq; using System.Net.Http; using AadAuthenticationContext = Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext; -namespace VstsSamples.Client.Auth +namespace Vsts.ClientSamples.Auth { public class InteractiveAuthSample { @@ -23,7 +23,7 @@ namespace VstsSamples.Client.Auth // https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code internal const string RedirectUri = "urn:ietf:wg:oauth:2.0:oob"; - public Authentication() + public InteractiveAuthSample() { } diff --git a/ClientSamples/Build/BuildsSample.cs b/ClientSamples/Build/BuildsSample.cs index 0d96033..7e9b46e 100644 --- a/ClientSamples/Build/BuildsSample.cs +++ b/ClientSamples/Build/BuildsSample.cs @@ -6,19 +6,19 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace VstsSamples.Client.Build +namespace Vsts.ClientSamples.Build { [ClientSample] public class BuildsSample : ClientSample { - public BuildsSample(ClientSampleConfiguration configuration) : base(configuration) + public BuildsSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public IEnumerable ListBuildDefinitions(string projectName = null) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; BuildHttpClient buildClient = connection.GetClient(); return buildClient.GetDefinitionsAsync2(project: projectName).Result; diff --git a/ClientSamples/ClientSample.cs b/ClientSamples/ClientSample.cs index 85d8ac1..5e1882b 100644 --- a/ClientSamples/ClientSample.cs +++ b/ClientSamples/ClientSample.cs @@ -1,64 +1,27 @@ using System; -using System.Reflection; -using System.Collections.Generic; -using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition; using Microsoft.VisualStudio.Services.WebApi; using System.Net.Http; using Microsoft.VisualStudio.Services.Common; -namespace VstsSamples.Client +namespace Vsts.ClientSamples { /// /// Base class that all client samples extend from. /// public abstract class ClientSample { - public ClientSampleConfiguration Configuration { get; set; } - - private VssConnection _connection; - - public VssConnection Connection - { - get - { - if (_connection == null) - { - ClientSampleHttpLogger loggerHandler = new ClientSampleHttpLogger(); - - VssHttpMessageHandler vssHandler = new VssHttpMessageHandler(Configuration.Credentials, VssClientHttpRequestSettings.Default.Clone()); - - _connection = new VssConnection(Configuration.Url, vssHandler, new DelegatingHandler[] { loggerHandler }); - } - - return this._connection; - } - private set - { - _connection = value; - } - } + public ClientSampleContext Context { get; set; } [ImportingConstructor] - public ClientSample() + public ClientSample(): this(null) { } - public ClientSample(ClientSampleConfiguration configuration) + public ClientSample(ClientSampleContext context) { - this.Configuration = configuration; + this.Context = context; } - - protected void Log(String message) - { - this.Log(message, null); - } - - protected void Log(String message, params object[] args) - { - System.Console.WriteLine(message, args); - } - } /// @@ -119,8 +82,4 @@ namespace VstsSamples.Client this.Operation = operation; } } - - - - } \ No newline at end of file diff --git a/ClientSamples/ClientSampleConfiguration.cs b/ClientSamples/ClientSampleConfiguration.cs deleted file mode 100644 index afd0fca..0000000 --- a/ClientSamples/ClientSampleConfiguration.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualStudio.Services.Common; - -namespace VstsSamples.Client -{ - /// - /// Configuration data for client samples. Includes the target URL, credentials, and any other properties. - /// - public class ClientSampleConfiguration - { - public VssCredentials Credentials { get; private set; } - - public Uri Url { get; private set; } - - protected Dictionary Properties { get; set; } = new Dictionary(); - - public ClientSampleConfiguration(Uri url): this(url, new VssCredentials()) - { - - } - - public ClientSampleConfiguration(Uri url, VssCredentials credentials) - { - this.Url = url; - this.Credentials = credentials; - } - - public T Get(string name, T defaultValueIfMissing) - { - T result; - if (Properties.TryGetValue(name, out result)) - { - return result; - } - else - { - return defaultValueIfMissing; - } - } - - public void Set(string name, T value) - { - Properties[name] = value; - } - - /// - /// Creates a new client sample configuration from the supplied Team Services account name and personal access token. - /// - /// - /// - /// - public static ClientSampleConfiguration NewInstanceFromAccountName(string accountName, string personalAccessToken) - { - return new ClientSampleConfiguration( - new Uri(String.Format(s_accountUrlPattern, accountName)), - new VssBasicCredential("pat", personalAccessToken)); - } - - private static readonly string s_accountUrlPattern = "http://{0}.visualstudio.com"; - } -} diff --git a/ClientSamples/ClientSampleContext.cs b/ClientSamples/ClientSampleContext.cs new file mode 100644 index 0000000..d5c7fae --- /dev/null +++ b/ClientSamples/ClientSampleContext.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.Services.Common; +using Microsoft.VisualStudio.Services.WebApi; +using System.Net.Http; + +namespace Vsts.ClientSamples +{ + /// + /// Configuration data for client samples. Includes the target URL, credentials, and any other properties. + /// + public class ClientSampleContext + { + protected VssCredentials Credentials { get; private set; } + + protected Uri Url { get; private set; } + + protected Dictionary Properties { get; set; } = new Dictionary(); + + private VssConnection _connection; + + public VssConnection Connection + { + get + { + if (_connection == null) + { + ClientSampleHttpLogger loggerHandler = new ClientSampleHttpLogger(); + + VssHttpMessageHandler vssHandler = new VssHttpMessageHandler( + Credentials, + VssClientHttpRequestSettings.Default.Clone()); + + _connection = new VssConnection( + Url, + vssHandler, + new DelegatingHandler[] { loggerHandler }); + } + + return this._connection; + } + private set + { + _connection = value; + } + } + + public ClientSampleContext(Uri url) + { + this.Url = url; + this.Credentials = new VssCredentials(); + } + + public ClientSampleContext(Uri url, VssCredentials credentials) + { + this.Url = url; + this.Credentials = credentials; + } + + public ClientSampleContext(VssConnection connection) + { + this.Connection = connection; + } + + public T Get(string name, T defaultValueIfMissing) + { + T result; + if (Properties.TryGetValue(name, out result)) + { + return result; + } + else + { + return defaultValueIfMissing; + } + } + + public void Set(string name, T value) + { + Properties[name] = value; + } + + public void Log(String message) + { + this.Log(message, null); + } + + public void Log(String message, params object[] args) + { + System.Console.WriteLine(message, args); + } + + /// + /// Creates a new client sample configuration from the supplied Team Services account name and personal access token. + /// + /// + /// + /// + public static ClientSampleContext NewInstanceFromAccountName(string accountName, string personalAccessToken) + { + return new ClientSampleContext( + new Uri(String.Format(s_accountUrlPattern, accountName)), + new VssBasicCredential("pat", personalAccessToken)); + } + + private static readonly string s_accountUrlPattern = "http://{0}.visualstudio.com"; + } +} diff --git a/ClientSamples/ClientSampleUtils.cs b/ClientSamples/ClientSampleUtils.cs index 9353815..0a3b4c5 100644 --- a/ClientSamples/ClientSampleUtils.cs +++ b/ClientSamples/ClientSampleUtils.cs @@ -2,25 +2,15 @@ using System; using System.Reflection; using System.Collections.Generic; using System.ComponentModel.Composition.Hosting; -using System.ComponentModel.Composition; -using Microsoft.VisualStudio.Services.WebApi; using System.Net.Http; -using Microsoft.VisualStudio.Services.Common; -using System; -using System.Collections.Generic; using System.Linq; -using System.Net.Http; using System.Runtime.Serialization; -using System.Text; using System.Threading.Tasks; -using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Linq; -using System.Diagnostics; -using System.Reflection; -namespace VstsSamples.Client +namespace Vsts.ClientSamples { /// @@ -60,10 +50,9 @@ namespace VstsSamples.Client if (!string.IsNullOrEmpty(ma.Area) && !string.IsNullOrEmpty(ma.Resource) && !string.IsNullOrEmpty(ma.Operation)) { RunnableClientSampleMethod r = new RunnableClientSampleMethod(); - r.Instance = cs.Value; - r.Method = m; + r.MethodBase = m; r.Area = ma.Area; - r.Resource = ma.Resorce; + r.Resource = ma.Resource; runnableMethods.Add(r); } @@ -87,7 +76,6 @@ namespace VstsSamples.Client } } - return results; } } @@ -203,9 +191,7 @@ namespace VstsSamples.Client public Dictionary ResponseHeaders; [DataMember(EmitDefaultValue = false)] - public Object ResponseBody; - - + public Object ResponseBody; } } diff --git a/ClientSamples/ClientSamples.csproj b/ClientSamples/ClientSamples.csproj index f2d3337..424d3f8 100644 --- a/ClientSamples/ClientSamples.csproj +++ b/ClientSamples/ClientSamples.csproj @@ -7,8 +7,8 @@ {545851E1-9BD9-4939-8AF4-9A8910CF5C34} Library Properties - VstsSamples.Client - VstsSamples.Client + Vsts.ClientSamples + Vsts.ClientSamples v4.5.2 512 @@ -115,14 +115,13 @@ + - - - - + + + - diff --git a/ClientSamples/Core/ProcessesSample.cs b/ClientSamples/Core/ProcessesSample.cs index b655f23..00c6058 100644 --- a/ClientSamples/Core/ProcessesSample.cs +++ b/ClientSamples/Core/ProcessesSample.cs @@ -3,19 +3,19 @@ using Microsoft.VisualStudio.Services.WebApi; using System; using System.Collections.Generic; -namespace VstsSamples.Client.Core +namespace Vsts.ClientSamples.Core { [ClientSample(CoreConstants.AreaName, CoreConstants.ProcessesRouteName)] public class ProcessesSample : ClientSample { - public ProcessesSample(ClientSampleConfiguration configuration) : base(configuration) + public ProcessesSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public List GetProcesses() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProcessHttpClient processClient = connection.GetClient(); List processes = processClient.GetProcessesAsync().Result; @@ -26,7 +26,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public Process GetProcess(System.Guid processId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProcessHttpClient processClient = connection.GetClient(); Process process = processClient.GetProcessByIdAsync(processId).Result; diff --git a/ClientSamples/Core/ProjectCollectionsSample.cs b/ClientSamples/Core/ProjectCollectionsSample.cs index eb5309e..c9e01d0 100644 --- a/ClientSamples/Core/ProjectCollectionsSample.cs +++ b/ClientSamples/Core/ProjectCollectionsSample.cs @@ -3,14 +3,14 @@ using Microsoft.VisualStudio.Services.Common; using Microsoft.VisualStudio.Services.WebApi; using System; using System.Collections.Generic; -using VstsSamples.Client; +using Vsts.ClientSamples; -namespace VstsSamples.Client.Core +namespace Vsts.ClientSamples.Core { [ClientSample(CoreConstants.AreaName, CoreConstants.ProjectCollectionsResource)] public class ProjectCollectionsSample : ClientSample { - public ProjectCollectionsSample(ClientSampleConfiguration configuration) : base(configuration) + public ProjectCollectionsSample(ClientSampleContext context) : base(context) { } @@ -18,7 +18,7 @@ namespace VstsSamples.Client.Core public IEnumerable GetProjectCollections() { // Create instance of VssConnection using passed credentials - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectCollectionHttpClient projectCollectionClient = connection.GetClient(); IEnumerable projectCollections = projectCollectionClient.GetProjectCollections().Result; @@ -29,7 +29,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public TeamProjectCollectionReference GetProjectCollection(string collectionName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectCollectionHttpClient projectCollectionClient = connection.GetClient(); TeamProjectCollectionReference teamProjectCollectionReference = projectCollectionClient.GetProjectCollection(collectionName).Result; diff --git a/ClientSamples/Core/ProjectsSample.cs b/ClientSamples/Core/ProjectsSample.cs index 54e9781..023df53 100644 --- a/ClientSamples/Core/ProjectsSample.cs +++ b/ClientSamples/Core/ProjectsSample.cs @@ -5,12 +5,12 @@ using Microsoft.VisualStudio.Services.WebApi; using System; using System.Collections.Generic; -namespace VstsSamples.Client.Core +namespace Vsts.ClientSamples.Core { [ClientSample(CoreConstants.AreaName, CoreConstants.ProjectsRouteName)] public class ProjectsSample: ClientSample { - public ProjectsSample(ClientSampleConfiguration configuration) : base(configuration) + public ProjectsSample(ClientSampleContext context) : base(context) { } @@ -21,7 +21,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public void ListAllProjectsAndTeams() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); TeamHttpClient teamClient = connection.GetClient(); @@ -29,13 +29,13 @@ namespace VstsSamples.Client.Core foreach(var project in projects) { - Log("Teams for project {0}:", project.Name); - Log("--------------------------------------------------"); + Context.Log("Teams for project {0}:", project.Name); + Context.Log("--------------------------------------------------"); IEnumerable teams = teamClient.GetTeamsAsync(project.Name).Result; foreach (var team in teams) { - Log(" {0}: {1}", team.Name, team.Description); + Context.Log(" {0}: {1}", team.Name, team.Description); } } } @@ -48,7 +48,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public IEnumerable GetProjectsByState(ProjectState state = ProjectState.All) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); IEnumerable projects = projectClient.GetProjects(state).Result; @@ -59,7 +59,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public TeamProjectReference GetProjectDetails(string projectName = "Fabrikam") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); TeamProject project = projectClient.GetProject(projectName, includeCapabilities: true, includeHistory: true).Result; @@ -77,7 +77,7 @@ namespace VstsSamples.Client.Core SourceControlTypes.Git.ToString(); // Setup process properties - ProcessHttpClient processClient = this.Connection.GetClient(); + ProcessHttpClient processClient = Context.Connection.GetClient(); Guid processId = processClient.GetProcessesAsync().Result.Find(process => { return process.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase); }).Id; Dictionary processProperaties = new Dictionary(); @@ -100,7 +100,7 @@ namespace VstsSamples.Client.Core Capabilities = capabilities }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); OperationReference createProjectOperationStatus = projectClient.QueueCreateProject(projectCreateParameters).Result; @@ -112,7 +112,7 @@ namespace VstsSamples.Client.Core public OperationReference GetOperationStatus(Guid operationId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; OperationsHttpClient operationsClient = connection.GetClient(); OperationReference operationStatus = operationsClient.GetOperation(operationId).Result; @@ -123,7 +123,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public OperationReference RenameProject(String currentName = "Fabrikam", string newName = "Fabrikam (renamed)") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); Guid projectId = projectClient.GetProject(currentName).Result.Id; @@ -146,7 +146,7 @@ namespace VstsSamples.Client.Core Description = newDescription }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); Guid projectId = projectClient.GetProject(projectName).Result.Id; @@ -158,7 +158,7 @@ namespace VstsSamples.Client.Core public OperationReference DeleteTeamProject(Guid projectId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient(); OperationReference operationStatus = projectClient.QueueDeleteProject(projectId).Result; diff --git a/ClientSamples/Core/TeamsSample.cs b/ClientSamples/Core/TeamsSample.cs index 1716489..1956a31 100644 --- a/ClientSamples/Core/TeamsSample.cs +++ b/ClientSamples/Core/TeamsSample.cs @@ -4,19 +4,19 @@ using System; using System.Collections.Generic; using System.Linq; -namespace VstsSamples.Client.Core +namespace Vsts.ClientSamples.Core { [ClientSample(CoreConstants.AreaName, CoreConstants.TeamsResource)] public class TeamsSample : ClientSample { - public TeamsSample(ClientSampleConfiguration configuration) : base(configuration) + public TeamsSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public IEnumerable GetOrderedTeamsList(string projectName = "Fabrikam") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); IEnumerable teams = teamClient.GetTeamsAsync(projectName).Result; @@ -29,7 +29,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public WebApiTeam GetTeam(string projectName, string teamName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); WebApiTeam team = teamClient.GetTeamAsync(projectName, teamName).Result; @@ -40,7 +40,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod(resource:CoreConstants.TeamMembersResource)] public IEnumerable GetTeamMembers(string projectName, string teamName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); IEnumerable results = teamClient.GetTeamMembersAsync(projectName, teamName).Result; @@ -51,7 +51,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public WebApiTeam CreateTeam(string projectName = "Fabikam", string name = "Fabrikam Ops Team", string description = "Team focused on operations for Fabrikam") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); WebApiTeam newTeamCreateParameters = new WebApiTeam() @@ -68,7 +68,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public WebApiTeam RenameTeam(string projectName = "Fabrikam", string currentTeamName = "Fabrikam Ops Team", string newTeamName = "Fabrikam Ops Team (renamed)") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); WebApiTeam teamUpdateParameters = new WebApiTeam() @@ -84,7 +84,7 @@ namespace VstsSamples.Client.Core [ClientSampleMethod] public bool DeleteTeam(string projectName = "Fabrikam", string teamName = "Fabrikam Ops Team") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); try diff --git a/ClientSamples/Notification/EventTypesSample.cs b/ClientSamples/Notification/EventTypesSample.cs index 0af38e1..0c81f19 100644 --- a/ClientSamples/Notification/EventTypesSample.cs +++ b/ClientSamples/Notification/EventTypesSample.cs @@ -1,10 +1,9 @@ - using System.Collections.Generic; using Microsoft.VisualStudio.Services.Notifications.WebApi; using Microsoft.VisualStudio.Services.Notifications.WebApi.Clients; using Microsoft.VisualStudio.Services.WebApi; -namespace VstsSamples.Client.Notification +namespace Vsts.ClientSamples.Notification { /// /// Samples for getting details about available notification event types. @@ -12,7 +11,7 @@ namespace VstsSamples.Client.Notification [ClientSample(NotificationApiConstants.AreaName)] public class EventTypesSample : ClientSample { - public EventTypesSample(ClientSampleConfiguration configuration): base(configuration) + public EventTypesSample(ClientSampleContext context): base(context) { } @@ -23,7 +22,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public List GetAllEventTypes() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); List eventTypes = notificationClient.ListEventTypesAsync().Result; @@ -38,7 +37,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public List GetEventTypesAvailableForCustomSubscriptions() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); List eventTypes = notificationClient.ListEventTypesAsync().Result; diff --git a/ClientSamples/Notification/SubscriptionsSample.cs b/ClientSamples/Notification/SubscriptionsSample.cs index 6c4ea9e..e3d310f 100644 --- a/ClientSamples/Notification/SubscriptionsSample.cs +++ b/ClientSamples/Notification/SubscriptionsSample.cs @@ -9,7 +9,7 @@ using Microsoft.TeamFoundation.Core.WebApi; using System; using System.Linq; -namespace VstsSamples.Client.Notification +namespace Vsts.ClientSamples.Notification { /// /// @@ -23,10 +23,9 @@ namespace VstsSamples.Client.Notification { public SubscriptionsSample() { - } - public SubscriptionsSample(ClientSampleConfiguration configuration): base(configuration) + public SubscriptionsSample(ClientSampleContext context): base(context) { } @@ -37,7 +36,7 @@ namespace VstsSamples.Client.Notification public NotificationSubscription CreateUpdateDeleteSubscription() { // Get the client - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); // @@ -74,10 +73,10 @@ namespace VstsSamples.Client.Notification }; // Scope to only events from one project - ProjectHttpClient projectClient = this.Connection.GetClient(); + ProjectHttpClient projectClient = this.Context.Connection.GetClient(); Guid projectId; - String projectName = this.Configuration.Get("projectName", null); + String projectName = this.Context.Get("projectName", null); if (String.IsNullOrEmpty(projectName)) { @@ -95,7 +94,7 @@ namespace VstsSamples.Client.Notification NotificationSubscription newSubscription = notificationClient.CreateSubscriptionAsync(createParams).Result; String subscriptionId = newSubscription.Id; - Log("New subscription created! ID: {0}", subscriptionId); + Context.Log("New subscription created! ID: {0}", subscriptionId); // // Part 2: disable and delete the subscription @@ -109,7 +108,7 @@ namespace VstsSamples.Client.Notification newSubscription = notificationClient.UpdateSubscriptionAsync(updateParams, subscriptionId).Result; - Log("Is subscription disabled? {0}", newSubscription.Status < 0); + Context.Log("Is subscription disabled? {0}", newSubscription.Status < 0); // Delete the subscription notificationClient.DeleteSubscriptionAsync(subscriptionId).SyncResult(); @@ -120,7 +119,7 @@ namespace VstsSamples.Client.Notification newSubscription = notificationClient.GetSubscriptionAsync(subscriptionId, SubscriptionQueryFlags.IncludeFilterDetails).Result; } catch (Exception e) { - Log("Unable to get the deleted subscription:" + e.Message); + Context.Log("Unable to get the deleted subscription:" + e.Message); } // Try again (the default query flags says to return deleted subscriptions so this should work) @@ -131,7 +130,7 @@ namespace VstsSamples.Client.Notification public IEnumerable> GetSubscriptionsGroupedByEventType() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); // Get existing subscriptions @@ -148,16 +147,16 @@ namespace VstsSamples.Client.Notification eventType => { return eventType.Id; }); // Show the subscriptions grouped by event type - Log("Custom subscriptions by event type"); + Context.Log("Custom subscriptions by event type"); foreach (IGrouping group in groupedSubscriptions) { NotificationEventType eventType; if (eventTypes.TryGetValue(group.Key, out eventType)) { - Log("Event type {0}:", eventType.Name); + Context.Log("Event type {0}:", eventType.Name); foreach (NotificationSubscription subscription in group) { - Log(" {0}, last modified: {1} by {2}", + Context.Log(" {0}, last modified: {1} by {2}", subscription.Description, subscription.ModifiedDate, subscription.LastModifiedBy?.DisplayName); @@ -175,13 +174,13 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public IEnumerable GetCustomSubscriptions() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); List subscriptions = notificationClient.ListSubscriptionsAsync().Result; - Log("Custom subscriptions"); - Log("--------------------"); + Context.Log("Custom subscriptions"); + Context.Log("--------------------"); foreach (var subscription in subscriptions) { @@ -210,13 +209,13 @@ namespace VstsSamples.Client.Notification } }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); List subscriptions = notificationClient.QuerySubscriptionsAsync(query).Result; - Log("Default subscriptions"); - Log("---------------------"); + Context.Log("Default subscriptions"); + Context.Log("---------------------"); foreach (var subscription in subscriptions) { @@ -237,7 +236,7 @@ namespace VstsSamples.Client.Notification // Get the event type from the arguments, configuration, or just fallback and use "work item change" if (String.IsNullOrEmpty(eventType)) { - eventType = this.Configuration.Get("notification.subscriptions.eventType", "ms.vss-work.workitem-changed-event"); + eventType = this.Context.Get("notification.subscriptions.eventType", "ms.vss-work.workitem-changed-event"); } // Setup the query @@ -252,13 +251,13 @@ namespace VstsSamples.Client.Notification } }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); IEnumerable subscriptions = notificationClient.QuerySubscriptionsAsync(query).Result; - Log("Custom subscriptions for event type: {0}", eventType); - Log("------------------------------------------------------------"); + Context.Log("Custom subscriptions for event type: {0}", eventType); + Context.Log("------------------------------------------------------------"); foreach(NotificationSubscription subscription in subscriptions) { @@ -275,7 +274,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public NotificationSubscription CreateCustomPersonalSubscription() { - NotificationHttpClient notificationClient = this.Connection.GetClient(); + NotificationHttpClient notificationClient = Context.Connection.GetClient(); // Query the available event types and find the first that can be used in a custom subscription List eventTypes = notificationClient.ListEventTypesAsync().Result; @@ -303,7 +302,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public IEnumerable GetSubscriptionsForTeam(string projectName, string teamName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); WebApiTeam team = teamClient.GetTeamAsync(projectName, teamName).Result; @@ -312,8 +311,8 @@ namespace VstsSamples.Client.Notification IEnumerable subscriptions = notificationClient.ListSubscriptionsAsync(subscriber: team.Id).Result; - Log("Subscriptions for {0} in {1}", teamName, projectName); - Log("-------------------------------------------------------------------"); + Context.Log("Subscriptions for {0} in {1}", teamName, projectName); + Context.Log("-------------------------------------------------------------------"); foreach (var subscription in subscriptions) { @@ -326,7 +325,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public IEnumerable GetSubscriptionsForGroup(Guid groupId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; NotificationHttpClient notificationClient = connection.GetClient(); // Return all subscriptions, includuing minimal details for subscriptions the caller doesn't have access to @@ -342,7 +341,7 @@ namespace VstsSamples.Client.Notification public void ShowAllTeamSubscriptions(String projectName = null) { // Get clients - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; TeamHttpClient teamClient = connection.GetClient(); NotificationHttpClient notificationClient = connection.GetClient(); @@ -352,7 +351,7 @@ namespace VstsSamples.Client.Notification if (String.IsNullOrEmpty(projectName)) { - projectName = this.Configuration.Get("projectName", null); + projectName = this.Context.Get("projectName", null); } // Get all teams in the project @@ -386,8 +385,8 @@ namespace VstsSamples.Client.Notification // Find the corresponding team for this group WebApiTeam team = teams.First(t => { return t.Id.Equals(group.Key); }); - Log("Subscriptions for team {0} (subscriber ID: {1})", team.Name, team.Id); - Log("--------------------------------------------------------------------------------------"); + Context.Log("Subscriptions for team {0} (subscriber ID: {1})", team.Name, team.Id); + Context.Log("--------------------------------------------------------------------------------------"); // Show the details for each subscription owned by this team foreach (NotificationSubscription subscription in group) @@ -406,7 +405,7 @@ namespace VstsSamples.Client.Notification [ClientSampleMethod] public NotificationSubscription FollowWorkItem(int workItemId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient witClient = connection.GetClient(); WorkItem workItem = witClient.GetWorkItemAsync(workItemId).Result; @@ -428,7 +427,7 @@ namespace VstsSamples.Client.Notification protected void LogSubscription(NotificationSubscription subscription) { - Log(" {0}: {1}, last modified on {2} by {3}", + Context.Log(" {0}: {1}, last modified on {2} by {3}", subscription.Id, subscription.Description, subscription.ModifiedDate, diff --git a/ClientSamples/Work/TeamSettingsSample.cs b/ClientSamples/Work/TeamSettingsSample.cs index 0dc5260..a3c8440 100644 --- a/ClientSamples/Work/TeamSettingsSample.cs +++ b/ClientSamples/Work/TeamSettingsSample.cs @@ -4,19 +4,19 @@ using Microsoft.TeamFoundation.Work.WebApi; using System; using System.Collections.Generic; -namespace VstsSamples.Client.Work +namespace Vsts.ClientSamples.Work { public class TeamSettingsSample : ClientSample { - public TeamSettingsSample(ClientSampleConfiguration configuration) : base(configuration) + public TeamSettingsSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public TeamSetting GetTeamSettings(string project) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkHttpClient workClient = connection.GetClient(); var context = new TeamContext(project); @@ -40,7 +40,7 @@ namespace VstsSamples.Client.Work BacklogVisibilities = backlogVisibilities }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkHttpClient workClient = connection.GetClient(); var context = new TeamContext(project); diff --git a/ClientSamples/WorkItemTracking/AttachmentsSample.cs b/ClientSamples/WorkItemTracking/AttachmentsSample.cs index 29bbe5b..482de40 100644 --- a/ClientSamples/WorkItemTracking/AttachmentsSample.cs +++ b/ClientSamples/WorkItemTracking/AttachmentsSample.cs @@ -5,7 +5,7 @@ using Microsoft.VisualStudio.Services.WebApi; using System; using System.IO; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { /// /// @@ -17,15 +17,14 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSample(WitConstants.WorkItemTrackingWebConstants.RestAreaName, WitConstants.WorkItemTrackingRestResources.Attachments)] public class AttachmentsSample : ClientSample { - - public AttachmentsSample(ClientSampleConfiguration configuration) : base(configuration) + public AttachmentsSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public void DownloadAttachment(Guid attachmentId, string saveToFile) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); Stream attachmentStream = workItemTrackingClient.GetAttachmentContentAsync(attachmentId).Result; @@ -39,7 +38,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public AttachmentReference UploadTextFile(string filePath) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); AttachmentReference attachmentReference = workItemTrackingClient.CreateAttachmentAsync(@filePath).Result; @@ -50,7 +49,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public AttachmentReference UploadBinaryFile(string filePath) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); AttachmentReference attachmentReference = workItemTrackingClient.CreateAttachmentAsync(@filePath).Result; diff --git a/ClientSamples/WorkItemTracking/BatchSample.cs b/ClientSamples/WorkItemTracking/BatchSample.cs index 9f5d5c8..edc23e5 100644 --- a/ClientSamples/WorkItemTracking/BatchSample.cs +++ b/ClientSamples/WorkItemTracking/BatchSample.cs @@ -6,14 +6,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { public class BatchSample : ClientSample { public void Run() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); diff --git a/ClientSamples/WorkItemTracking/ClassificationNodesSample.cs b/ClientSamples/WorkItemTracking/ClassificationNodesSample.cs index 08ce678..3378933 100644 --- a/ClientSamples/WorkItemTracking/ClassificationNodesSample.cs +++ b/ClientSamples/WorkItemTracking/ClassificationNodesSample.cs @@ -4,7 +4,7 @@ using Microsoft.VisualStudio.Services.WebApi; using System; using System.Collections.Generic; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { /// /// @@ -17,14 +17,14 @@ namespace VstsSamples.Client.WorkItemTracking public class ClassificationNodesSample : ClientSample { - public ClassificationNodesSample(ClientSampleConfiguration configuration) : base(configuration) + public ClassificationNodesSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public WorkItemClassificationNode GetAreas(string project, int depth) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.GetClassificationNodeAsync(project, TreeStructureGroup.Areas, null, depth).Result; @@ -35,7 +35,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemClassificationNode GetIterations(string project, int depth) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.GetClassificationNodeAsync(project, TreeStructureGroup.Iterations, null, depth).Result; @@ -46,7 +46,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemClassificationNode GetArea(string project, string path) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.GetClassificationNodeAsync(project, TreeStructureGroup.Areas, path, 0).Result; @@ -57,7 +57,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemClassificationNode GetIteration(string project, string path) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.GetClassificationNodeAsync(project, TreeStructureGroup.Iterations, path, 0).Result; @@ -74,7 +74,7 @@ namespace VstsSamples.Client.WorkItemTracking StructureType = TreeNodeStructureType.Area }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Areas, "").Result; @@ -96,7 +96,7 @@ namespace VstsSamples.Client.WorkItemTracking //Attributes = dict }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.CreateOrUpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, "").Result; @@ -112,7 +112,7 @@ namespace VstsSamples.Client.WorkItemTracking StructureType = TreeNodeStructureType.Area }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.UpdateClassificationNodeAsync(node, project, TreeStructureGroup.Areas, path).Result; @@ -129,7 +129,7 @@ namespace VstsSamples.Client.WorkItemTracking StructureType = TreeNodeStructureType.Iteration }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.UpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, path).Result; @@ -150,7 +150,7 @@ namespace VstsSamples.Client.WorkItemTracking Attributes = dict }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.UpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, name).Result; @@ -166,7 +166,7 @@ namespace VstsSamples.Client.WorkItemTracking StructureType = TreeNodeStructureType.Area }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.UpdateClassificationNodeAsync(node, project, TreeStructureGroup.Areas, targetArea).Result; @@ -182,7 +182,7 @@ namespace VstsSamples.Client.WorkItemTracking StructureType = TreeNodeStructureType.Iteration }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode result = workItemTrackingClient.UpdateClassificationNodeAsync(node, project, TreeStructureGroup.Iterations, targetIteration).Result; @@ -193,7 +193,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public bool DeleteArea(string project, string areaPath, int reclassifyId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); try @@ -212,7 +212,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public bool DeleteIteration(string project, string iterationPath, int reclassifyId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); try @@ -230,7 +230,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public List GetFullTree(string project, TreeStructureGroup type) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemClassificationNode rootNode = workItemTrackingClient.GetClassificationNodeAsync(project, type, null, 1000).Result; diff --git a/ClientSamples/WorkItemTracking/FieldsSample.cs b/ClientSamples/WorkItemTracking/FieldsSample.cs index 68d197a..bd74966 100644 --- a/ClientSamples/WorkItemTracking/FieldsSample.cs +++ b/ClientSamples/WorkItemTracking/FieldsSample.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { /// /// @@ -18,14 +18,14 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSample(WitConstants.WorkItemTrackingWebConstants.RestAreaName, WitConstants.WorkItemTrackingRestResources.Fields)] public class FieldsSample : ClientSample { - public FieldsSample(ClientSampleConfiguration configuration) : base(configuration) + public FieldsSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public WorkItemField GetFieldDetails(string fieldName = "System.Title") { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List result = workItemTrackingClient.GetFieldsAsync().Result; @@ -38,7 +38,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public IEnumerable GetReadOnlyWorkItemFields() { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List result = workItemTrackingClient.GetFieldsAsync().Result; diff --git a/ClientSamples/WorkItemTracking/QueriesSample.cs b/ClientSamples/WorkItemTracking/QueriesSample.cs index b114abc..0c46632 100644 --- a/ClientSamples/WorkItemTracking/QueriesSample.cs +++ b/ClientSamples/WorkItemTracking/QueriesSample.cs @@ -5,20 +5,20 @@ using System; using System.Collections.Generic; using System.Linq; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { [ClientSample(WitConstants.WorkItemTrackingWebConstants.RestAreaName, WitConstants.WorkItemTrackingRestResources.Queries)] public class QueriesSample : ClientSample { - public QueriesSample(ClientSampleConfiguration configuration) : base(configuration) + public QueriesSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public QueryHierarchyItem GetQueryByName(string project, string queryName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); QueryHierarchyItem query = workItemTrackingClient.GetQueryAsync(project, queryName).Result; @@ -36,7 +36,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemQueryResult ExecuteQuery(Guid queryId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemQueryResult queryResult = workItemTrackingClient.QueryByIdAsync(queryId).Result; @@ -54,7 +54,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemQueryResult ExecuteByWiql(Wiql wiql, string project) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemQueryResult queryResult = workItemTrackingClient.QueryByWiqlAsync(wiql, project).Result; @@ -65,7 +65,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public IEnumerable GetWorkItemsFromQuery(string projectName, string queryName) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); QueryHierarchyItem queryItem; @@ -120,7 +120,7 @@ namespace VstsSamples.Client.WorkItemTracking "Order By [State] Asc, [Changed Date] Desc" : wiqlString) }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); // execute the query diff --git a/ClientSamples/WorkItemTracking/RecycleBinSample.cs b/ClientSamples/WorkItemTracking/RecycleBinSample.cs index 08249e2..cd57c2c 100644 --- a/ClientSamples/WorkItemTracking/RecycleBinSample.cs +++ b/ClientSamples/WorkItemTracking/RecycleBinSample.cs @@ -5,20 +5,20 @@ using Microsoft.VisualStudio.Services.WebApi; using System; using System.Collections.Generic; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { [ClientSample(WitConstants.WorkItemTrackingWebConstants.RestAreaName, WitConstants.WorkItemTrackingRestResources.WorkItems)] public class RecycleBinSample : ClientSample { - public RecycleBinSample(ClientSampleConfiguration configuration) : base(configuration) + public RecycleBinSample(ClientSampleContext context) : base(context) { } [ClientSampleMethod] public List GetDeletedItems(string project) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List results = workItemTrackingClient.GetDeletedWorkItemsAsync(project).Result; @@ -29,7 +29,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemDelete GetDeletedItem(int workItemId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemDelete result = workItemTrackingClient.GetDeletedWorkItemAsync(workItemId).Result; @@ -40,7 +40,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemDelete RestoreItem(int workItemId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemDeleteUpdate updateParameters = new WorkItemDeleteUpdate() { @@ -55,7 +55,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public void PermenentlyDeleteItem(int workItemId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); workItemTrackingClient.DestroyWorkItemAsync(workItemId); diff --git a/ClientSamples/WorkItemTracking/ReportingSample.cs b/ClientSamples/WorkItemTracking/ReportingSample.cs index 2e32141..542e57e 100644 --- a/ClientSamples/WorkItemTracking/ReportingSample.cs +++ b/ClientSamples/WorkItemTracking/ReportingSample.cs @@ -1,9 +1,9 @@ -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { [ClientSample] public class ReportingSample : ClientSample { - public ReportingSample(ClientSampleConfiguration configuration) : base(configuration) + public ReportingSample(ClientSampleContext context) : base(context) { } diff --git a/ClientSamples/WorkItemTracking/WorkItemsSample.cs b/ClientSamples/WorkItemTracking/WorkItemsSample.cs index 07c46c3..8e79aa4 100644 --- a/ClientSamples/WorkItemTracking/WorkItemsSample.cs +++ b/ClientSamples/WorkItemTracking/WorkItemsSample.cs @@ -5,9 +5,9 @@ using Microsoft.VisualStudio.Services.WebApi.Patch; using Microsoft.VisualStudio.Services.WebApi.Patch.Json; using System; using System.Collections.Generic; -using VstsSamples.Client; +using Vsts.ClientSamples; -namespace VstsSamples.Client.WorkItemTracking +namespace Vsts.ClientSamples.WorkItemTracking { [ClientSample(WitConstants.WorkItemTrackingWebConstants.RestAreaName, WitConstants.WorkItemTrackingRestResources.WorkItems)] public class WorkItemsSample : ClientSample @@ -16,7 +16,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public List GetWorkItemsByIDs(IEnumerable ids) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List results = workItemTrackingClient.GetWorkItemsAsync(ids).Result; @@ -34,7 +34,7 @@ namespace VstsSamples.Client.WorkItemTracking "Microsoft.VSTS.Scheduling.RemainingWork" }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List results = workItemTrackingClient.GetWorkItemsAsync(ids, fields).Result; @@ -52,7 +52,7 @@ namespace VstsSamples.Client.WorkItemTracking "Microsoft.VSTS.Scheduling.RemainingWork" }; - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List results = workItemTrackingClient.GetWorkItemsAsync(ids, fields, asOfDate).Result; @@ -63,7 +63,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public List GetWorkItemsWithLinksAndAttachments(IEnumerable ids) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); List results = workItemTrackingClient.GetWorkItemsAsync(ids, null, null, WorkItemExpand.All).Result; @@ -74,7 +74,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItem GetWorkItem(int id) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.GetWorkItemAsync(id).Result; @@ -85,7 +85,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItem GetWorkItemWithLinksAndAttachments(int id) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.GetWorkItemAsync(id, null, null, WorkItemExpand.Relations).Result; @@ -96,7 +96,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItem GetWorkItemFullyExpanded(int id) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.GetWorkItemAsync(id, null, null, WorkItemExpand.All).Result; @@ -118,7 +118,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.CreateWorkItemAsync(patchDocument, projectName, "Task").Result; @@ -184,7 +184,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.CreateWorkItemAsync(patchDocument, projectName, "Task").Result; @@ -224,7 +224,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.CreateWorkItemAsync(patchDocument, projectName, "Task", null, true).Result; @@ -264,7 +264,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -301,7 +301,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -330,7 +330,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -352,7 +352,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -363,7 +363,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItem AddLinkToOtherWorkItem(int id, int targetId) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); // Get work target work item @@ -411,7 +411,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -438,7 +438,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -449,7 +449,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItem AddAttachment(int id, string filePath) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); // upload attachment to store and get a reference to that file @@ -516,7 +516,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -552,7 +552,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -588,7 +588,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id).Result; @@ -609,7 +609,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItem result = workItemTrackingClient.UpdateWorkItemAsync(patchDocument, id, null, true).Result; @@ -620,7 +620,7 @@ namespace VstsSamples.Client.WorkItemTracking [ClientSampleMethod] public WorkItemDelete DeleteWorkItem(int id) { - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); WorkItemDelete results = workItemTrackingClient.DeleteWorkItemAsync(id, false).Result; @@ -663,7 +663,7 @@ namespace VstsSamples.Client.WorkItemTracking } ); - VssConnection connection = this.Connection; + VssConnection connection = Context.Connection; WorkItemTrackingHttpClient workItemTrackingClient = connection.GetClient(); foreach (WorkItemReference workItemReference in workItemQueryResult.WorkItems)