當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。