Как то худо-бедно начинает работать лучше
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Example.Backend
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public decimal Resource { get; set; }
|
||||
public double Resource { get; set; } = 100d;
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
@@ -22,6 +22,7 @@ namespace Example.Backend
|
||||
// throw new Exception("The method or operation is not implemented.");
|
||||
var page = new Page { Text = text };
|
||||
OnPrint?.Invoke(page);
|
||||
Resource /= 1.5;
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Example.Frontend
|
||||
{
|
||||
public class ClientBasedPrinter : IPrinter
|
||||
{
|
||||
public decimal Resource { get; set; }
|
||||
public double Resource { get; set; }
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
|
||||
@@ -75,6 +75,12 @@ class Program
|
||||
var page = disposingPrinter.Print("Test Page", false, CancellationToken.None).GetAwaiter().GetResult();
|
||||
Console.WriteLine("Page printed");
|
||||
Console.WriteLine(page.ToString());
|
||||
|
||||
Console.WriteLine($"Printer resource : {disposingPrinter.Resource}");
|
||||
Console.WriteLine("Restoring resource");
|
||||
disposingPrinter.Resource = 100;
|
||||
Console.WriteLine($"Printer resource again : {disposingPrinter.Resource}");
|
||||
|
||||
var data = page.GetData();
|
||||
Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data));
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Example.Shared
|
||||
[SharedObjectInterface]
|
||||
public interface IPrinter : IDisposable, IShared
|
||||
{
|
||||
decimal Resource { get; set; }
|
||||
double Resource { get; set; }
|
||||
string GetName();
|
||||
Task<IPage> Print(string text, bool someParameter, CancellationToken cancellationToken);
|
||||
event Action<IPage> OnPrint;
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace mROA.Cbor
|
||||
{
|
||||
if (nonCasted == null)
|
||||
return null;
|
||||
|
||||
|
||||
if (nonCasted.GetType() == type)
|
||||
return nonCasted;
|
||||
|
||||
if (nonCasted is PreParsedValue preParsed)
|
||||
return preParsed.ToObject(type, context);
|
||||
return null;
|
||||
return Convert.ChangeType(nonCasted, type);
|
||||
}
|
||||
|
||||
private void WriteData(object? obj, CborWriter writer, IEndPointContext? context)
|
||||
@@ -214,6 +214,9 @@ namespace mROA.Cbor
|
||||
return reader.ReadDouble();
|
||||
case CborReaderState.SinglePrecisionFloat:
|
||||
return reader.ReadSingle();
|
||||
case CborReaderState.HalfPrecisionFloat:
|
||||
return type == typeof(float) ? reader.ReadSingle() : reader.ReadDouble();
|
||||
|
||||
case CborReaderState.StartArray:
|
||||
if (type == null)
|
||||
return ReadList(reader, null, context);
|
||||
@@ -308,7 +311,6 @@ namespace mROA.Cbor
|
||||
|
||||
if (type.IsInterface)
|
||||
{
|
||||
|
||||
var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(type);
|
||||
var so =
|
||||
Activator.CreateInstance(sharedShell) as
|
||||
|
||||
@@ -436,6 +436,7 @@ namespace mROA.Codegen
|
||||
{level}{{
|
||||
{level} IsVoid = false,
|
||||
{level} ReturnType = typeof({method.ReturnType.ToDisplayString()}),
|
||||
{level} ParameterTypes = new Type[] {{ typeof({method.Parameters.First().Type.ToDisplayString()}) }},
|
||||
{level} SuitableType = typeof({method.ContainingType.ToDisplayString()}),
|
||||
{level} Invoking = (i, parameters, _) => (i as {method.ContainingType.ToDisplayString()}).{(method.AssociatedSymbol as IPropertySymbol)!.Name} = {Caster((method.AssociatedSymbol as IPropertySymbol)!.Type, "parameters[0]")},
|
||||
{level}}}";
|
||||
|
||||
Reference in New Issue
Block a user