Ejemplo n.º 1
0
        public void Generate( )
        {
            MethodsTemplates.Clear( );
            Methods.Clear( );
            Constructors.Clear( );

            GenerateReadBlockTemplateMethod( );
            GenerateReadDataMethod( );
            GenerateBinaryReaderConstructor( );
        }
Ejemplo n.º 2
0
        public void GenerateReadBlockTemplateMethod( )
        {
            MethodsTemplates.Add(new MethodInfo( )
            {
                Arguments       = { "BinaryReader binaryReader" },
                AccessModifiers = AccessModifiers.Internal | AccessModifiers.Virtual,
                ClassName       = "Read{0}Array",
                Body            =
                    @"var elementSize = Deserializer.SizeOf(typeof({0}));
var blamPointer = binaryReader.ReadBlamPointer(elementSize);
var array = new {0}[blamPointer.Count];
using (binaryReader.BaseStream.Pin())
{{
    for (int i = 0; i < blamPointer.Count; ++i)
    {{
        binaryReader.BaseStream.Position = blamPointer[i];
        array[i] = new {0}(binaryReader);
    }}
}}
return array;",
                Returns = "{0}[]"
            });
        }