Example #1
0
        internal static async Task <StringFileInfo> LoadAsync(Stream stream)
        {
            var count = 3 * sizeof(ushort);
            var len   = await stream.ReadUInt16Async().ConfigureAwait(false);

            var valLen = await stream.ReadUInt16Async().ConfigureAwait(false);

            var type = await stream.ReadUInt16Async().ConfigureAwait(false);

            var key = await stream.ReadUnicodeStringAsync().ConfigureAwait(false);

            count += (key.Length + 1) * sizeof(ushort);
            count += await VersionResource.AlignWordBoundaryAsync(stream).ConfigureAwait(false);

            var tables = new List <VersionStringTable>();
            var buffer = await stream.ReadBytesAsync(len - count).ConfigureAwait(false);

            using (var mem = new MemoryStream(buffer))
            {
                while (mem.Position < mem.Length)
                {
                    var table = await LoadTableAsync(mem).ConfigureAwait(false);

                    tables.Add(table);
                }
            }

            var result = new StringFileInfo(key, tables.ToArray());

            return(result);
        }
Example #2
0
 internal VersionInfo(VersionResource resource, uint languageId, FixedFileInfo fixedInfo, StringFileInfo stringInfo, VarFileInfo varInfo)
 {
     Resource  = resource;
     Language  = languageId;
     Fixed     = fixedInfo;
     Strings   = stringInfo;
     Variables = varInfo;
 }
Example #3
0
        private static async Task <VersionVariable> LoadVariableAsync(Stream stream)
        {
            var count = 3 * sizeof(ushort);

            await stream.ReadBytesAsync(count).ConfigureAwait(false);

            var key = await stream.ReadUnicodeStringAsync().ConfigureAwait(false);

            await VersionResource.AlignWordBoundaryAsync(stream).ConfigureAwait(false);

            var value = await stream.ReadUInt32Async().ConfigureAwait(false);

            var result = new VersionVariable(key, value);

            return(result);
        }
Example #4
0
        private static async Task <VersionString> LoadStringAsync(Stream stream)
        {
            var len = await stream.ReadUInt16Async().ConfigureAwait(false);

            var valLen = await stream.ReadUInt16Async().ConfigureAwait(false);

            var type = await stream.ReadUInt16Async().ConfigureAwait(false);

            var key = await stream.ReadUnicodeStringAsync().ConfigureAwait(false);

            await VersionResource.AlignWordBoundaryAsync(stream).ConfigureAwait(false);

            var value = await stream.ReadUnicodeStringAsync(valLen).ConfigureAwait(false);

            var result = new VersionString(key, value);

            return(result);
        }
Example #5
0
        private static async Task <VersionStringTable> LoadTableAsync(Stream stream)
        {
            var count = 3 * sizeof(ushort);
            var len   = await stream.ReadUInt16Async().ConfigureAwait(false);

            var valLen = await stream.ReadUInt16Async().ConfigureAwait(false);

            var type = await stream.ReadUInt16Async().ConfigureAwait(false);

            var key = await stream.ReadUnicodeStringAsync().ConfigureAwait(false);

            count += (key.Length + 1) * sizeof(ushort);
            count += await VersionResource.AlignWordBoundaryAsync(stream).ConfigureAwait(false);

            var strings = new List <VersionString>();
            var buffer  = await stream.ReadBytesAsync(len - count).ConfigureAwait(false);

            using (var mem = new MemoryStream(buffer))
            {
                while (mem.Position < mem.Length)
                {
                    var str = await LoadStringAsync(mem).ConfigureAwait(false);

                    strings.Add(str);

                    if (mem.Position % 4 != 0 && mem.Position < mem.Length)
                    {
                        await VersionResource.AlignWordBoundaryAsync(mem).ConfigureAwait(false);
                    }
                }
            }

            var result = new VersionStringTable(key, strings.ToArray());

            return(result);
        }