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


C# GenericReader.End方法代码示例

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


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

示例1: Load

		public virtual void Load(XmlTextReader reader, GenericReader rcreader)
		{
			int version = Int32.Parse(reader.GetAttribute("version"));
			reader.ReadStartElement("ResourceData");

			switch (version)
			{
				case 0:
				{
					m_Name = reader.ReadElementString("Name");
					m_Type = Type.GetType(reader.ReadElementString("Type"));
					m_BunchName = reader.ReadElementString("BunchName");
					m_ResalePrice = Double.Parse(reader.ReadElementString("ResalePrice"));
					m_WholesalePrice = Double.Parse(reader.ReadElementString("WholesalePrice"));
					m_ItemID = Int32.Parse(reader.ReadElementString("ItemID"));
					m_Hue = Int32.Parse(reader.ReadElementString("Hue"));
					m_SmallestFirstFactor = Double.Parse(reader.ReadElementString("SmallestFirstFactor"));
					m_ValidFailsafe = bool.Parse(reader.ReadElementString("ValidFailsafe"));
					
					if (m_Type == null || m_Type.GetInterface("ICommodity", false) == null)
						throw new Exception(String.Format("Error: Type of resource '{0}' does not exist or does not implement ICommodity.", m_Name));
					
					m_ConsignmentList = new ArrayList();
					
					if (rcreader == null)// || !FindPosition(rcreader))
						break;

					((BinaryFileReader)rcreader).Seek(0, SeekOrigin.Begin);
					if (rcreader.End())
						break;
					int rcversion = rcreader.ReadInt();
					switch (rcversion)
					{
						case 0:
						{
							while (!rcreader.End())
							{
								ResourceConsignment rc = new ResourceConsignment(rcreader);
								if (rc.Type == m_Type)
									m_ConsignmentList.Add(rc);
							}

							break;
						}
						default:
							throw new Exception("ResourcePool error: Invalid file version for Consignments.dat");
					}
					/*if (!rcreader.End() && rcreader.ReadString() == m_Type.FullName)
							{
								int rcversion = rcreader.ReadInt();
								switch (rcversion)
								{
									case 0:
									{
										count = rcreader.ReadInt();
										for (; count > 0; count--)
											m_ConsignmentList.Add(new ResourceConsignment(rcreader));
										break;
									}
									default:
									{
										throw new Exception("ResourcePool error: Invalid ResourceData entry save version in Consignments.dat");
									}
								}
							}*/

					break;
				}
				default:
				{
					throw new Exception("Error loading ResourceData: Invalid saveversion");
				}
			}

			reader.ReadEndElement();
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:76,代码来源:ResourcePool.cs

示例2: FindPosition

		private bool FindPosition(GenericReader rcreader)
		{
			((BinaryFileReader)rcreader).Seek(0, SeekOrigin.Begin);
			if (rcreader.End())
				return false;

			int rcversion = rcreader.ReadInt();
			switch (rcversion)
			{
				case 0:
				{
					long tableposition = rcreader.ReadLong();
					Console.WriteLine("Tableposition: {0}", tableposition);
					((BinaryFileReader)rcreader).Seek(tableposition, SeekOrigin.Begin);
					while (!rcreader.End())
					{
						string typename = rcreader.ReadString();
						long location = rcreader.ReadLong();
						Console.WriteLine("{0}, {1}", typename, location);
						if (typename == m_Type.FullName)
						{
							((BinaryFileReader)rcreader).Seek(location, SeekOrigin.Begin);
							return true;
						}
					}

					break;
				}
				default:
				{
					throw new Exception("ResourcePool error: Invalid consignments.dat save version");
				}
			}

			return false;
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:36,代码来源:ResourcePool.cs


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