зеркало из https://github.com/akkadotnet/Hyperion.git
Remove dynamic keyword
This commit is contained in:
Родитель
0d0ec2890c
Коммит
7f3f2fb46f
|
@ -6,7 +6,7 @@
|
|||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
.ionide/**
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Hyperion.SerializerFactories
|
|||
|
||||
public override bool CanDeserialize(Serializer serializer, Type type) => CanSerialize(serializer, type);
|
||||
|
||||
private static void WriteValues<T>(T[] array, Stream stream, Type elementType, ValueSerializer elementSerializer, SerializerSession session)
|
||||
private static void WriteValues(Array array, Stream stream, Type elementType, ValueSerializer elementSerializer, SerializerSession session)
|
||||
{
|
||||
Int32Serializer.WriteValueImpl(stream, array.Length, session);
|
||||
var preserveObjectReferences = session.Serializer.Options.PreserveObjectReferences;
|
||||
|
@ -30,12 +30,12 @@ namespace Hyperion.SerializerFactories
|
|||
stream.WriteObject(value, elementType, elementSerializer, preserveObjectReferences, session);
|
||||
}
|
||||
}
|
||||
private static void ReadValues<T>(int length, Stream stream, DeserializerSession session, T[] array)
|
||||
private static void ReadValues(int length, Stream stream, DeserializerSession session, Array array)
|
||||
{
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var value = (T)stream.ReadObject(session);
|
||||
array[i] = value;
|
||||
var value = stream.ReadObject(session);
|
||||
array.SetValue(value, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Hyperion.SerializerFactories
|
|||
session.TrackDeserializedObject(array);
|
||||
}
|
||||
|
||||
ReadValues(length, stream, session, (dynamic)array);
|
||||
ReadValues(length, stream, session, array);
|
||||
|
||||
return array;
|
||||
};
|
||||
|
@ -68,7 +68,7 @@ namespace Hyperion.SerializerFactories
|
|||
session.TrackSerializedObject(arr);
|
||||
}
|
||||
|
||||
WriteValues((dynamic)arr, stream, elementType, elementSerializer, session);
|
||||
WriteValues((Array)arr, stream, elementType, elementSerializer, session);
|
||||
};
|
||||
arraySerializer.Initialize(reader, writer);
|
||||
typeMapping.TryAdd(type, arraySerializer);
|
||||
|
|
|
@ -71,15 +71,16 @@ namespace Hyperion.ValueSerializers
|
|||
var elementSerializer = session.Serializer.GetSerializerByType(elementType);
|
||||
elementSerializer.WriteManifest(stream, session); //write array element type
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
WriteValues((dynamic)value, stream,elementSerializer,session);
|
||||
WriteValues((Array)value, stream,elementSerializer,session);
|
||||
}
|
||||
|
||||
private static void WriteValues<T>(T[] array, Stream stream, ValueSerializer elementSerializer, SerializerSession session)
|
||||
private static void WriteValues(Array array, Stream stream, ValueSerializer elementSerializer, SerializerSession session)
|
||||
{
|
||||
var tp = array.GetType();
|
||||
Int32Serializer.WriteValueImpl(stream,array.Length,session);
|
||||
if (typeof(T).IsFixedSizeType())
|
||||
if (tp.IsFixedSizeType())
|
||||
{
|
||||
var size = typeof(T).GetTypeSize();
|
||||
var size = tp.GetTypeSize();
|
||||
var result = new byte[array.Length * size];
|
||||
Buffer.BlockCopy(array, 0, result, 0, result.Length);
|
||||
stream.Write(result);
|
||||
|
|
Загрузка…
Ссылка в новой задаче