public static void Serialize <TResource>(TResource resource, Stream stream)
            where TResource : SerializedResource, new()
        {
            var serializer = new WriteResourceSerializer(stream);

            serializer.Serialize(ref resource);
        }
Exemple #2
0
        public override bool Serialize <TSerializedResource>(KeyedResource owner, ref TSerializedResource[] serializedResources, ref short length, params Type[] expectedTypes)
        {
            var ownerLength = _totalWritten - owner.Offset;

            using (var memoryStream = new MemoryStream())
                using (var writer = new WriteResourceSerializer(memoryStream))
                {
                    foreach (var serializedResource in serializedResources)
                    {
                        var localSerializedResource = serializedResource;
                        writer.Serialize(ref localSerializedResource);
                    }
                    var bytes = memoryStream.ToArray();
                    length = (short)(ownerLength + bytes.Length);
                    return(Write(bytes));
                }
        }