当前位置: 首页>>代码示例>>C#>>正文


C# BigEndianReader.Seek方法代码示例

本文整理汇总了C#中BlueSheep.Common.IO.BigEndianReader.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# BigEndianReader.Seek方法的具体用法?C# BigEndianReader.Seek怎么用?C# BigEndianReader.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlueSheep.Common.IO.BigEndianReader的用法示例。


在下文中一共展示了BigEndianReader.Seek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init(string filePath)
        {
            FileInfo fileInfo = new FileInfo(filePath);

            if (!fileInfo.Exists)
                throw new Exception("I18n file not readable.");

            if (m_Indexes == null)
                m_Indexes = new Dictionary<int, int>();

            if (m_UnDiacriticalIndex == null)
                m_UnDiacriticalIndex = new Dictionary<int, int>();

            if (m_TextIndexes == null)
                m_TextIndexes = new Dictionary<string, int>();

            if (m_TextIndexesOverride == null)
                m_TextIndexesOverride = new Dictionary<string, string>();

            if (m_TextSortIndex == null)
                m_TextSortIndex = new Dictionary<int, int>();

            byte[] fileContent = new byte[fileInfo.Length];
            FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            fileStream.Read(fileContent, 0, fileContent.Length);
            fileStream.Dispose();

            m_Stream = new BigEndianReader(fileContent);

            int position = m_Stream.ReadInt();
            m_Stream.Seek(position);

            int indexCount = m_Stream.ReadInt();

            for (int index = 0; index < indexCount; index += 9)
            {
                int key = m_Stream.ReadInt();
                bool diacriticalText = m_Stream.ReadBoolean();
                int pointeur = m_Stream.ReadInt();
                m_Indexes.Add(key, pointeur);

                if (diacriticalText)
                {
                    index += 4;
                    m_UnDiacriticalIndex.Add(key, m_Stream.ReadInt());
                }
                else
                    m_UnDiacriticalIndex.Add(key, pointeur);
            }

            int textIndexesCount = m_Stream.ReadInt();

            while (textIndexesCount > 0)
            {
                position = (int) m_Stream.Position;
                m_TextIndexes.Add(m_Stream.ReadUTF(), m_Stream.ReadInt());
                textIndexesCount -= (int) (m_Stream.Position - position);
            }

            textIndexesCount = m_Stream.ReadInt();

            int i = 0;

            while (textIndexesCount > 0)
            {
                position = (int)m_Stream.Position;
                m_TextSortIndex.Add(m_Stream.ReadInt(), ++i);
                textIndexesCount -= (int)(m_Stream.Position - position);
            }
        }
开发者ID:DjTrilogic,项目名称:BlueSheep,代码行数:70,代码来源:I18nFileAccessor.cs


注:本文中的BlueSheep.Common.IO.BigEndianReader.Seek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。