Skip to content

Commit b750bad

Browse files
committed
trying new things
1 parent 21a552f commit b750bad

File tree

19 files changed

+61
-54
lines changed

19 files changed

+61
-54
lines changed

samples/SampleApi/Controllers/ValuesController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
52
using Microsoft.AspNetCore.Mvc;
63

74
namespace SampleApi.Controllers

samples/SampleApi/Program.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
1+
using System.IO;
62
using Microsoft.AspNetCore.Hosting;
73
using Microsoft.AspNetCore.Builder;
84

samples/SampleApi/Startup.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore.Builder;
62
using Microsoft.AspNetCore.Hosting;
73
using Microsoft.Extensions.Configuration;
84
using Microsoft.Extensions.DependencyInjection;
95
using Microsoft.Extensions.Logging;
10-
using WebApiProxy.Middleware;
116

127
namespace SampleApi
138
{

src/WebApiProxy.Clients.JQuery/JQueryGenerator.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
namespace WebApiProxy.Generators.JQuery
1+
namespace WebApiProxy.Clients.JQuery
22
{
3-
using System;
4-
using System.Dynamic;
53
using System.Threading.Tasks;
6-
using Clients.Infrastructure;
74
using Core.Infrastructure;
85
using Core.Models;
9-
using Clients.Models;
106

117
public partial class JQueryGenerator: GeneratorBase
128
{

src/WebApiProxy.Clients.JQuery/JQueryGenerator.generated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* This file is automatically generated by WebApiProxy Parser Generator */
22

3-
namespace WebApiProxy.Generators.JQuery
3+
namespace WebApiProxy.Clients.JQuery
44
{
55
using System.Linq;
66
using WebApiProxy.Core.Infrastructure;

src/WebApiProxy.Clients.JQuery/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following

src/WebApiProxy.Clients.JQuery/project.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"WebApiProxy.Clients": "1.0.0-*",
66
"WebApiProxy.Core": "1.0.0-*"
77
},
8-
"scripts": { "precompile": "..\\..\\tools\\ttgen.exe create -s .\\JQuery.template -c JQueryGenerator -ns WebApiProxy.Generators.JQuery" },
8+
"scripts": { "precompile": "..\\..\\tools\\ttgen.exe create -s .\\JQuery.template -c JQueryGenerator -ns WebApiProxy.Clients.JQuery" },
99
"frameworks": {
1010
"netstandard1.3": {
1111
"imports": "dnx50"
1212
}
13-
},
13+
},
1414
"runtimes": {
15-
"win": {}
15+
"win10-x64": {}
1616
}
1717
}

src/WebApiProxy.Clients/Infrastructure/ExternalMetadataProvider.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
namespace WebApiProxy.Clients.Infrastructure
22
{
3-
using System.Net.Http;
43
using Newtonsoft.Json;
54
using Core.Infrastructure;
65
using Core.Models;
76
using Models;
7+
using System.Net;
8+
using System.IO;
89

910
public class ExternalMetadataProvider : IMetadataProvider
1011
{
@@ -14,15 +15,25 @@ public ExternalMetadataProvider(ClientConfiguration configuration)
1415
{
1516
this.configuration = configuration;
1617
}
18+
19+
20+
1721
public Metadata GetMetadata(string baseUrl = "")
1822
{
19-
using (var client = new HttpClient())
23+
var c = WebRequest.CreateHttp(configuration.MetadataEndpoint);
24+
c.Method = configuration.Method;
25+
var response = c.GetResponseAsync().Result;
26+
// var result = response.
27+
// using (var client = new HttpClient())
2028
{
21-
var response = client.SendAsync(new HttpRequestMessage(configuration.Method, configuration.MetadataEndpoint));
22-
var result = response.Result.Content.ReadAsStringAsync().Result;
23-
var metadata = JsonConvert.DeserializeObject<Metadata>(result);
24-
25-
return metadata;
29+
// var response = client.SendAsync(new HttpRequestMessage(new HttpMethod(configuration.Method), configuration.MetadataEndpoint));
30+
var result = response.GetResponseStream();
31+
using (StreamReader reader = new StreamReader(result))
32+
using (JsonTextReader jsonReader = new JsonTextReader(reader))
33+
{
34+
JsonSerializer ser = new JsonSerializer();
35+
return ser.Deserialize<Metadata>(jsonReader);
36+
}
2637
}
2738

2839
}

src/WebApiProxy.Clients/Infrastructure/GeneratorInterop.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
namespace WebApiProxy.NodeJs.Infrastructure
1+
namespace WebApiProxy.Clients
22
{
3-
using Clients.Infrastructure;
3+
using Infrastructure;
44
using Clients.Models;
55
using Core.Infrastructure;
66
using System;
77
using System.Dynamic;
88
using System.Threading.Tasks;
9+
using System.Collections.Generic;
910

1011
public class GeneratorInterop
1112
{
12-
public async Task<object> Process(object input)
13+
public async Task<object> Invoke(object input)
1314
{
15+
IDictionary<string, object> parameters = (ExpandoObject)input;
1416
var configuration = ((ExpandoObject)input).Map<ClientConfiguration>();
17+
18+
//var configuration = new ClientConfiguration
19+
//{
20+
// Generator = parameters["generator"]?.ToString(),
21+
// MetadataEndpoint = parameters["metadataEndpoint"]?.ToString(),
22+
// Method = parameters["method"]?.ToString(),
23+
// Name = parameters["name"]?.ToString(),
24+
// Namespace = parameters["namespace"]?.ToString(),
25+
// Suffix = parameters["suffix"]?.ToString(),
26+
//};
27+
28+
1529
var provider = new ExternalMetadataProvider(configuration);
16-
var generator = (IGenerator)Activator.CreateInstance(Type.GetType(configuration.Generator), provider, configuration);
30+
var metadata = provider.GetMetadata();
31+
var generator = (IGenerator)Activator.CreateInstance(Type.GetType(configuration.Generator), metadata);
1732

1833
return await generator.Process();
1934
}

src/WebApiProxy.Clients/Models/ClientConfiguration.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
using System.Net.Http;
2-
3-
namespace WebApiProxy.Clients.Models
1+
namespace WebApiProxy.Clients.Models
42
{
53
public class ClientConfiguration
64
{
75
public string MetadataEndpoint { get; set; }
8-
public HttpMethod Method { get; set; }
6+
public string Method { get; set; } = "OPTIONS";
97
public string Name { get; set; }
108
public string Namespace { get; set; }
119
public string Suffix { get; set; }

src/WebApiProxy.Clients/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following

src/WebApiProxy.Clients/project.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33

44
"dependencies": {
55
"Newtonsoft.Json": "9.0.1",
6-
"System.Net.Http": "4.1.0",
6+
//"System.Net.Http": "4.1.0",
7+
"System.Net.Requests": "4.0.11",
78
"WebApiProxy.Core": "1.0.0-*"
89
},
910

1011
"frameworks": {
11-
12-
"netstandard1.3": {
12+
13+
"netstandard1.6": {
1314
"dependencies": {
1415
"System.Reflection.TypeExtensions": "4.1.0"
16+
//"System.Net.Security": "4.0.0"
1517
}
16-
18+
1719
}
20+
},
21+
"runtimes": {
22+
"win10-x64": {}
1823
}
1924
}

src/WebApiProxy.Core/Infrastructure/StringExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
namespace WebApiProxy.Core.Infrastructure
22
{
33
using System;
4-
using System.Collections.Generic;
5-
using System.Reflection;
64
using System.Text.RegularExpressions;
75
public static class StringExtensions
86
{

src/WebApiProxy.Middleware.JQuery/JQueryClientProviderMiddleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
namespace WebApiProxy.Providers.JQuery
1+
namespace WebApiProxy.Middleware.JQuery
22
{
33
using Microsoft.AspNetCore.Http;
44
using System.Threading.Tasks;
55
using Core.Infrastructure;
6-
using Generators.JQuery;
6+
using Clients.JQuery;
77
using Microsoft.Extensions.Options;
88
using Middleware;
99

src/WebApiProxy.Middleware.JQuery/JQueryClientProviderOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace WebApiProxy.Providers.JQuery
1+
namespace WebApiProxy.Middleware.JQuery
22
{
33
using Middleware;
44
public class JQueryClientProviderOptions : WebApiProxyOptions

src/WebApiProxy.Middleware.JQuery/JQueryProviderBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.AspNetCore.Builder
22
{
3-
using WebApiProxy.Providers.JQuery;
3+
using WebApiProxy.Middleware.JQuery;
44

55
public static class JQueryProviderBuilderExtensions
66
{

src/WebApiProxy.Middleware.JQuery/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following

src/WebApiProxy.Middleware.JQuery/WebApiProxyServicesCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
using System;
44
using WebApiProxy.Middleware;
5-
using WebApiProxy.Providers.JQuery;
5+
using WebApiProxy.Middleware.JQuery;
66

77
public static class WebApiProxyServicesCollectionExtensions
88
{

src/WebApiProxy.Middleware/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following

0 commit comments

Comments
 (0)