Exclude System.Runtime.CompilerServices.NullableContextAttribute (#66)
* HttpClient * . * . * .
This commit is contained in:
@@ -1,86 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using DifferentNamespace;
|
||||
using System.Threading.Tasks;
|
||||
using ProxyInterfaceConsumer.Http;
|
||||
|
||||
namespace ProxyInterfaceConsumer
|
||||
namespace ProxyInterfaceConsumer;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public class Program
|
||||
private static JsonSerializerOptions JsonSerializerOptions = new ()
|
||||
{
|
||||
private static JsonSerializerOptions JsonSerializerOptions = new ()
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
public static async Task Main()
|
||||
{
|
||||
var h = new HttpClient();
|
||||
var ph = new HttpClientProxy(h);
|
||||
|
||||
var result = await ph.GetAsync("https://www.google.nl");
|
||||
var todo = await ph.GetFromJsonAsync<Todo>("https://jsonplaceholder.typicode.com/todos/1");
|
||||
|
||||
var postResult = await h.PostAsJsonAsync<Todo>("https://jsonplaceholder.typicode.com/todos", new Todo { Id = 123 });
|
||||
|
||||
var t = new TestProxy(new Test());
|
||||
|
||||
IPersonT<int> pT = new PersonTProxy<int>(new PersonT<int>());
|
||||
pT.TVal = 1;
|
||||
Console.WriteLine(JsonSerializer.Serialize(pT, JsonSerializerOptions));
|
||||
Console.WriteLine(new string('-', 80));
|
||||
|
||||
//IPersonTT<int, Program> pTT = new PersonTTProxy<int, Program>(new PersonTT<int, Program>());
|
||||
//pTT.TVal1 = 42;
|
||||
//pTT.TVal2 = new Program();
|
||||
//Console.WriteLine(JsonSerializer.Serialize(pTT, JsonSerializerOptions));
|
||||
//Console.WriteLine(new string('-', 80));
|
||||
|
||||
var ap = new AddressProxy(new Address { HouseNumber = 42 });
|
||||
ap.HouseNumber = -1;
|
||||
ap.MyEvent += delegate (object x, EventArgs a)
|
||||
{
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
var t = new TestProxy(new Test());
|
||||
IPerson p = new PersonProxy(new Person());
|
||||
p.Name = "test";
|
||||
p.HelloWorld("stef");
|
||||
// p.Address = ap;
|
||||
|
||||
IPersonT<int> pT = new PersonTProxy<int>(new PersonT<int>());
|
||||
pT.TVal = 1;
|
||||
Console.WriteLine(JsonSerializer.Serialize(pT, JsonSerializerOptions));
|
||||
Console.WriteLine(new string('-', 80));
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue());
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue(42));
|
||||
|
||||
//IPersonTT<int, Program> pTT = new PersonTTProxy<int, Program>(new PersonTT<int, Program>());
|
||||
//pTT.TVal1 = 42;
|
||||
//pTT.TVal2 = new Program();
|
||||
//Console.WriteLine(JsonSerializer.Serialize(pTT, JsonSerializerOptions));
|
||||
//Console.WriteLine(new string('-', 80));
|
||||
|
||||
var ap = new AddressProxy(new Address { HouseNumber = 42 });
|
||||
ap.HouseNumber = -1;
|
||||
ap.MyEvent += delegate (object x, EventArgs a)
|
||||
{
|
||||
};
|
||||
|
||||
IPerson p = new PersonProxy(new Person());
|
||||
p.Name = "test";
|
||||
p.HelloWorld("stef");
|
||||
// p.Address = ap;
|
||||
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue());
|
||||
Console.WriteLine("DefaultValue " + p.DefaultValue(42));
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(p, JsonSerializerOptions));
|
||||
}
|
||||
Console.WriteLine(JsonSerializer.Serialize(p, JsonSerializerOptions));
|
||||
}
|
||||
}
|
||||
|
||||
public class Test
|
||||
public class Todo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public class Test
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public Clazz C { get; }
|
||||
|
||||
public IList<Clazz> Cs { get; set; }
|
||||
|
||||
public int AddString(string s)
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public Clazz C { get; }
|
||||
|
||||
public IList<Clazz> Cs { get; set; }
|
||||
|
||||
public int AddString(string s)
|
||||
{
|
||||
return 600;
|
||||
}
|
||||
|
||||
public Test AddTest(Test t)
|
||||
{
|
||||
return new Test();
|
||||
}
|
||||
|
||||
public Clazz AddClazz(Clazz c)
|
||||
{
|
||||
return new Clazz();
|
||||
}
|
||||
return 600;
|
||||
}
|
||||
|
||||
public sealed class Clazz
|
||||
public Test AddTest(Test t)
|
||||
{
|
||||
public string Name { get; set; }
|
||||
return new Test();
|
||||
}
|
||||
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(Test))]
|
||||
public partial interface ITest
|
||||
public Clazz AddClazz(Clazz c)
|
||||
{
|
||||
return new Clazz();
|
||||
}
|
||||
}
|
||||
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(Clazz))]
|
||||
public partial interface IClazz
|
||||
{
|
||||
}
|
||||
public sealed class Clazz
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(Test))]
|
||||
public partial interface ITest
|
||||
{
|
||||
}
|
||||
|
||||
[ProxyInterfaceGenerator.Proxy(typeof(Clazz))]
|
||||
public partial interface IClazz
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user