コード例 #1
0
        public static BioCodexMap Load(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var reader = new BioCodexMapReader(stream))
            {
                var map = new BinaryBioCodexMap();

                // Sections
                var sectionsCount = reader.ReadInt32();
                map.Sections = new Dictionary <int, BioCodexSection>();

                for (var i = 0; i < sectionsCount; i++)
                {
                    var id      = reader.ReadInt32();
                    var section = reader.ReadCodexSection();

                    if (!map.Sections.ContainsKey(id))
                    {
                        map.Sections.Add(id, section);
                    }
                    else
                    {
                        map.Sections[id] = section;
                    }
                }

                // Pages
                var pagesCount = reader.ReadInt32();
                map.Pages = new Dictionary <int, BioCodexPage>();

                for (var i = 0; i < pagesCount; i++)
                {
                    var id   = reader.ReadInt32();
                    var page = reader.ReadCodexPage();

                    if (!map.Pages.ContainsKey(id))
                    {
                        map.Pages.Add(id, page);
                    }
                    else
                    {
                        map.Pages[id] = page;
                    }
                }

                return(map);
            }
        }
コード例 #2
0
		public static BioCodexMap Load(Stream stream)
		{
			if (stream == null)
			{
				throw new ArgumentNullException(nameof(stream));
			}

			using (var reader = new BioCodexMapReader(stream))
			{
				var map = new BinaryBioCodexMap();

				// Sections
				var sectionsCount = reader.ReadInt32();
				map.Sections = new Dictionary<int, BioCodexSection>();

				for (var i = 0; i < sectionsCount; i++)
				{
					var id = reader.ReadInt32();
					var section = reader.ReadCodexSection();

					if (!map.Sections.ContainsKey(id))
					{
						map.Sections.Add(id, section);
					}
					else
					{
						map.Sections[id] = section;
					}
				}

				// Pages
				var pagesCount = reader.ReadInt32();
				map.Pages = new Dictionary<int, BioCodexPage>();

				for (var i = 0; i < pagesCount; i++)
				{
					var id = reader.ReadInt32();
					var page = reader.ReadCodexPage();

					if (!map.Pages.ContainsKey(id))
					{
						map.Pages.Add(id, page);
					}
					else
					{
						map.Pages[id] = page;
					}
				}

				return map;
			}
		}