Как то худо-бедно начинает работать лучше

This commit is contained in:
2025-03-08 23:22:59 +03:00
parent 0e09b479af
commit 493f56c99a
6 changed files with 16 additions and 6 deletions
+2 -1
View File
@@ -10,7 +10,7 @@ namespace Example.Backend
{ {
public string Name; public string Name;
public decimal Resource { get; set; } public double Resource { get; set; } = 100d;
public string GetName() public string GetName()
{ {
@@ -22,6 +22,7 @@ namespace Example.Backend
// throw new Exception("The method or operation is not implemented."); // throw new Exception("The method or operation is not implemented.");
var page = new Page { Text = text }; var page = new Page { Text = text };
OnPrint?.Invoke(page); OnPrint?.Invoke(page);
Resource /= 1.5;
return page; return page;
} }
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Example.Frontend
{ {
public class ClientBasedPrinter : IPrinter public class ClientBasedPrinter : IPrinter
{ {
public decimal Resource { get; set; } public double Resource { get; set; }
public string GetName() public string GetName()
{ {
+6
View File
@@ -75,6 +75,12 @@ class Program
var page = disposingPrinter.Print("Test Page", false, CancellationToken.None).GetAwaiter().GetResult(); var page = disposingPrinter.Print("Test Page", false, CancellationToken.None).GetAwaiter().GetResult();
Console.WriteLine("Page printed"); Console.WriteLine("Page printed");
Console.WriteLine(page.ToString()); 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(); var data = page.GetData();
Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data)); Console.WriteLine("Data : {0}", Encoding.UTF8.GetString(data));
+1 -1
View File
@@ -9,7 +9,7 @@ namespace Example.Shared
[SharedObjectInterface] [SharedObjectInterface]
public interface IPrinter : IDisposable, IShared public interface IPrinter : IDisposable, IShared
{ {
decimal Resource { get; set; } double Resource { get; set; }
string GetName(); string GetName();
Task<IPage> Print(string text, bool someParameter, CancellationToken cancellationToken); Task<IPage> Print(string text, bool someParameter, CancellationToken cancellationToken);
event Action<IPage> OnPrint; event Action<IPage> OnPrint;
+4 -2
View File
@@ -62,7 +62,7 @@ namespace mROA.Cbor
if (nonCasted is PreParsedValue preParsed) if (nonCasted is PreParsedValue preParsed)
return preParsed.ToObject(type, context); return preParsed.ToObject(type, context);
return null; return Convert.ChangeType(nonCasted, type);
} }
private void WriteData(object? obj, CborWriter writer, IEndPointContext? context) private void WriteData(object? obj, CborWriter writer, IEndPointContext? context)
@@ -214,6 +214,9 @@ namespace mROA.Cbor
return reader.ReadDouble(); return reader.ReadDouble();
case CborReaderState.SinglePrecisionFloat: case CborReaderState.SinglePrecisionFloat:
return reader.ReadSingle(); return reader.ReadSingle();
case CborReaderState.HalfPrecisionFloat:
return type == typeof(float) ? reader.ReadSingle() : reader.ReadDouble();
case CborReaderState.StartArray: case CborReaderState.StartArray:
if (type == null) if (type == null)
return ReadList(reader, null, context); return ReadList(reader, null, context);
@@ -308,7 +311,6 @@ namespace mROA.Cbor
if (type.IsInterface) if (type.IsInterface)
{ {
var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(type); var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(type);
var so = var so =
Activator.CreateInstance(sharedShell) as Activator.CreateInstance(sharedShell) as
+1
View File
@@ -436,6 +436,7 @@ namespace mROA.Codegen
{level}{{ {level}{{
{level} IsVoid = false, {level} IsVoid = false,
{level} ReturnType = typeof({method.ReturnType.ToDisplayString()}), {level} ReturnType = typeof({method.ReturnType.ToDisplayString()}),
{level} ParameterTypes = new Type[] {{ typeof({method.Parameters.First().Type.ToDisplayString()}) }},
{level} SuitableType = typeof({method.ContainingType.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} Invoking = (i, parameters, _) => (i as {method.ContainingType.ToDisplayString()}).{(method.AssociatedSymbol as IPropertySymbol)!.Name} = {Caster((method.AssociatedSymbol as IPropertySymbol)!.Type, "parameters[0]")},
{level}}}"; {level}}}";