private static IService DiscoverService(string serviceName, string serviceVersion) { // Create the discovery URL var discoveryURL = string.Format(GoogleServiceGenerator.GoogleDiscoveryURL, serviceName, serviceVersion); var device = new CachedWebDiscoveryDevice(new Uri(discoveryURL)); // Discover the servi2ce using the hand-coded discovery service var discovery = new DiscoveryService(device); return discovery.GetService(DiscoveryVersion.Version_1_0); }
public void SystemTestCompilationWithDefaultDecorators_Discovery() { const string serviceName = "discovery"; const string serviceVersion = "v1"; var clientNamespace = "Google.Apis.Samples.CommandLineGeneratedService.Discovery"; // Generate the discovery URL for that service string url = string.Format(GoogleServiceGenerator.GoogleDiscoveryURL, serviceName, serviceVersion); var discovery = new DiscoveryService(new WebDiscoveryDevice(new Uri(url))); // Build the service based on discovery information. var service = discovery.GetService(DiscoveryVersion.Version_1_0); Assert.AreEqual(serviceName, service.Name); Assert.AreEqual(serviceVersion, service.Version); // Generate code var generator = new GoogleServiceGenerator(service, clientNamespace); var codeCompileUnit = generator.GenerateCode(); // Full Compile we should not have any warnings. CheckCompile(codeCompileUnit, true, "Failed To compile resultant code with default decorators."); }
protected IService CreateAdSenseV1_0Service() { var buzzTestFetcher = new StringDiscoveryDevice { Document = AdSenseDiscoveryV1 }; var discovery = new DiscoveryService(buzzTestFetcher); // Build the service based on discovery information. return discovery.GetService(DiscoveryVersion.Version_1_0); }
protected IService CreateBuzzService() { var buzzTestFetcher = new StringDiscoveryDevice { Document = BuzzServiceAsJson }; var discovery = new DiscoveryService(buzzTestFetcher); // Build the service based on discovery information. return discovery.GetService(DiscoveryVersion.Version_0_3, new FactoryParameters("http://test.server.example.com", "/testService")); }
public void Create() { var d = new DiscoveryService(new StubDiscoveryDevice()); Assert.IsNotNull(d); }
public void ConstructWithDiscoveryDevice() { var d = new DiscoveryService(new StubDiscoveryDevice()); Assert.IsInstanceOf<StubDiscoveryDevice>(d.DiscoveryDevice); }
/// <summary> /// Checks all the parameters and calls the GoogleServiceGenerator. /// </summary> protected override void ExecuteTask() { DiscoveryUrl.ThrowIfNullOrEmpty("DiscoveryUrl"); OutputFile.ThrowIfNull("OutputFile"); ClientNamespace.ThrowIfNullOrEmpty("ClientNamespace"); ApiVersion.ThrowIfNullOrEmpty("ApiVersion"); BaseUrl.ThrowIfNullOrEmpty("BaseUrl"); Project.Log(Level.Info, "Fetching Discovery " + DiscoveryUrl); var fetcher = new WebDiscoveryDevice(new Uri(DiscoveryUrl)); var discovery = new DiscoveryService(fetcher); var param = new FactoryParameterV1_0(BaseUrl, null); var service = discovery.GetService(DiscoveryVersion.Version_1_0, param); var generator = new GoogleServiceGenerator(service, ClientNamespace); var provider = CodeDomProvider.CreateProvider("CSharp"); Project.Log(Level.Info, "Generating To File " + OutputFile.FullName); using (StreamWriter sw = new StreamWriter(OutputFile.FullName, false)) { IndentedTextWriter tw = new IndentedTextWriter(sw, " "); provider.GenerateCodeFromCompileUnit(generator.GenerateCode(), tw, new CodeGeneratorOptions()); tw.Close(); } }