public void FromBinary(BinaryReader br, AssetIndexBase obj)
        {
            obj.Clear();
            var resourceGroupInfoSerializer = new ResourceGroupInfoSerializer();
            var resourceBasicInfoSerializer = new ResourceBasicInfoSerializer();
            var assetInfoSerializer         = new AssetInfoSerializer();
            var resourceInfoSerializer      = new ResourceInfoSerializer();

            var header = br.ReadString();

            if (header != obj.ObsoleteHeader)
            {
                throw new InvalidOperationException(
                          Utility.Text.Format("Expected header is '{0}', but actual header is '{1}'.", obj.ObsoleteHeader, header));
            }

            obj.DeserializeAugmentedData(br);

            var resourceGroupInfoCount = br.ReadInt32();

            obj.ResourceGroupInfos.Clear();
            for (var i = 0; i < resourceGroupInfoCount; i++)
            {
                var resourceGroupInfo = new ResourceGroupInfo();
                resourceGroupInfoSerializer.FromBinary(br, resourceGroupInfo);
                obj.ResourceGroupInfos.Add(resourceGroupInfo);
            }

            var resourceBasicInfoCount = br.ReadInt32();

            obj.ResourceBasicInfos.Clear();
            for (var i = 0; i < resourceBasicInfoCount; i++)
            {
                var resourceBasicInfo = new ResourceBasicInfo();
                resourceBasicInfoSerializer.FromBinary(br, resourceBasicInfo);
                obj.ResourceBasicInfos.Add(resourceBasicInfo.Path, resourceBasicInfo);
            }

            var assetInfoCount = br.ReadInt32();

            obj.AssetInfos.Clear();
            for (var i = 0; i < assetInfoCount; i++)
            {
                var assetInfo = new AssetInfo();
                assetInfoSerializer.FromBinary(br, assetInfo);
                obj.AssetInfos.Add(assetInfo.Path, assetInfo);
            }

            var resourceInfoCount = br.ReadInt32();

            obj.ResourceInfos.Clear();
            for (var i = 0; i < resourceInfoCount; i++)
            {
                var resourceInfo = new ResourceInfo();
                resourceInfoSerializer.FromBinary(br, resourceInfo);
                obj.ResourceInfos.Add(resourceInfo.Path, resourceInfo);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads from binary.
        /// </summary>
        /// <param name="br">Binary reader.</param>
        public void FromBinary(BinaryReader br)
        {
            var header = br.ReadString();

            if (header != Header)
            {
                throw new InvalidOperationException(
                          Utility.Text.Format("Expected header is '{0}', but actual header is '{1}'.", Header, header));
            }

            DeserializeAugmentedData(br);

            int resourceGroupInfoCount = br.ReadInt32();

            m_ResourceGroupInfos.Clear();
            for (int i = 0; i < resourceGroupInfoCount; i++)
            {
                var resourceGroupInfo = new ResourceGroupInfo();
                resourceGroupInfo.FromBinary(br);
                m_ResourceGroupInfos.Add(resourceGroupInfo);
            }

            int resourceBasicInfoCount = br.ReadInt32();

            m_ResourceBasicInfos.Clear();
            for (int i = 0; i < resourceBasicInfoCount; i++)
            {
                var resourceBasicInfo = new ResourceBasicInfo();
                resourceBasicInfo.FromBinary(br);
                m_ResourceBasicInfos.Add(resourceBasicInfo.Path, resourceBasicInfo);
            }

            int assetInfoCount = br.ReadInt32();

            m_AssetInfos.Clear();
            for (int i = 0; i < assetInfoCount; i++)
            {
                var assetInfo = new AssetInfo();
                assetInfo.FromBinary(br);
                m_AssetInfos.Add(assetInfo.Path, assetInfo);
            }

            int resourceInfoCount = br.ReadInt32();

            m_ResourceInfos.Clear();
            for (int i = 0; i < resourceInfoCount; i++)
            {
                var resourceInfo = new ResourceInfo();
                resourceInfo.FromBinary(br);
                m_ResourceInfos.Add(resourceInfo.Path, resourceInfo);
            }
        }