Переименование UOI в COI

This commit is contained in:
2025-03-10 21:56:22 +03:00
parent 96aa828808
commit 5e21d941df
11 changed files with 123 additions and 115 deletions
+45 -45
View File
@@ -65,6 +65,50 @@ namespace mROA.Cbor
return Convert.ChangeType(nonCasted, type);
}
public void Inject<T>(T dependency)
{
}
public byte[] Serialize<T>(T objectToSerialize)
{
return Serialize(objectToSerialize, typeof(T));
}
public byte[] Serialize(object objectToSerialize, Type type)
{
return Serialize(objectToSerialize, context: null);
}
public T Deserialize<T>(byte[] rawData)
{
return Deserialize<T>(rawData: rawData, context: null);
}
public object? Deserialize(byte[] rawData, Type type)
{
return Deserialize(rawData: rawData, type, context: null);
}
public T Deserialize<T>(Span<byte> rawData)
{
return Deserialize<T>(rawData.ToArray().AsMemory(), context: null);
}
public object? Deserialize(Span<byte> rawData, Type type)
{
return Deserialize(rawData: rawData.ToArray(), type: type);
}
public T Cast<T>(object nonCasted)
{
return Cast<T>(nonCasted: nonCasted, context: null);
}
public object Cast(object nonCasted, Type type)
{
return Cast(nonCasted: nonCasted, type: type, context: null);
}
private void WriteData(object? obj, CborWriter writer, IEndPointContext? context)
{
switch (obj)
@@ -322,7 +366,7 @@ namespace mROA.Cbor
var identifier = reader.ReadUInt64();
reader.ReadEndArray();
so.Identifier = UniversalObjectIdentifier.FromFlat(identifier);
so.Identifier = ComplexObjectIdentifier.FromFlat(identifier);
return so.UniversalValue;
}
@@ -387,49 +431,5 @@ namespace mROA.Cbor
return finalProperties;
}
public void Inject<T>(T dependency)
{
}
public byte[] Serialize<T>(T objectToSerialize)
{
return Serialize(objectToSerialize, typeof(T));
}
public byte[] Serialize(object objectToSerialize, Type type)
{
return Serialize(objectToSerialize, context: null);
}
public T Deserialize<T>(byte[] rawData)
{
return Deserialize<T>(rawData: rawData, context: null);
}
public object? Deserialize(byte[] rawData, Type type)
{
return Deserialize(rawData: rawData, type, context: null);
}
public T Deserialize<T>(Span<byte> rawData)
{
return Deserialize<T>(rawData.ToArray().AsMemory(), context: null);
}
public object? Deserialize(Span<byte> rawData, Type type)
{
return Deserialize(rawData: rawData.ToArray(), type: type);
}
public T Cast<T>(object nonCasted)
{
return Cast<T>(nonCasted: nonCasted, context: null);
}
public object Cast(object nonCasted, Type type)
{
return Cast(nonCasted: nonCasted, type: type, context: null);
}
}
}
+10 -8
View File
@@ -12,16 +12,15 @@ namespace mROA.Cbor
public class PreParsedValue : IPreParsedValue
{
private List<object> _properties { get; set; }
public PreParsedValue(List<object> properties)
{
_properties = properties;
}
private List<object> _properties { get; set; }
public object? ToObject(Type type, IEndPointContext? context)
{
if (type.IsInterface)
{
var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(type);
@@ -31,10 +30,10 @@ namespace mROA.Cbor
if (context != null)
so.EndPointContext = context;
so.Identifier = UniversalObjectIdentifier.FromFlat((ulong)_properties[0]);
so.Identifier = ComplexObjectIdentifier.FromFlat((ulong)_properties[0]);
return so.UniversalValue;
}
var instance = Activator.CreateInstance(type);
if (instance == null)
return null;
@@ -48,7 +47,10 @@ namespace mROA.Cbor
for (var index = 0; index < properties.Count; index++)
{
var property = properties[index];
property.SetValue(instance, _properties[index] is IPreParsedValue ppv ? ppv.ToObject(property.PropertyType, context) : _properties[index]);
property.SetValue(instance,
_properties[index] is IPreParsedValue ppv
? ppv.ToObject(property.PropertyType, context)
: _properties[index]);
}
return instance;
@@ -57,13 +59,13 @@ namespace mROA.Cbor
public class ParsedValue : IPreParsedValue
{
private object? _value;
public ParsedValue(object? value)
{
_value = value;
}
private object? _value;
public object? ToObject(Type type, IEndPointContext? context)
{