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


C# StringBuilder.AppendLineUnix方法代码示例

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


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

示例1: ToWriteString

		public string ToWriteString() {
			StringBuilder builder = new StringBuilder();
			builder.AppendLineUnix("\tTrade: {");

			if (Override != "100") {
				builder.AppendLineUnix("\t\toverride: " + Override);
			}

			if ((Flag & TradeFlag.Noauction) == TradeFlag.Noauction) builder.AppendLineUnix("\t\tnoauction: true");
			if ((Flag & TradeFlag.Nocart) == TradeFlag.Nocart) builder.AppendLineUnix("\t\tnocart: true");
			if ((Flag & TradeFlag.Nodrop) == TradeFlag.Nodrop) builder.AppendLineUnix("\t\tnodrop: true");
			if ((Flag & TradeFlag.Nogstorage) == TradeFlag.Nogstorage) builder.AppendLineUnix("\t\tnogstorage: true");
			if ((Flag & TradeFlag.Nomail) == TradeFlag.Nomail) builder.AppendLineUnix("\t\tnomail: true");
			if ((Flag & TradeFlag.Noselltonpc) == TradeFlag.Noselltonpc) builder.AppendLineUnix("\t\tnoselltonpc: true");
			if ((Flag & TradeFlag.Nostorage) == TradeFlag.Nostorage) builder.AppendLineUnix("\t\tnostorage: true");
			if ((Flag & TradeFlag.Notrade) == TradeFlag.Notrade) builder.AppendLineUnix("\t\tnotrade: true");
			if ((Flag & TradeFlag.Partneroverride) == TradeFlag.Partneroverride) builder.AppendLineUnix("\t\tpartneroverride: true");

			builder.Append("\t}");
			return builder.ToString();
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:21,代码来源:Trade.cs

示例2: ItemParser

		public ItemParser(string element) {
			List<string> lines = element.Split(TextFileHelper.SplitCharacter).ToList();

			for (int index = 0; index < lines.Count; index++) {
				string line = lines[index];
				int indexId = line.IndexOf(": ", StringComparison.Ordinal);

				if (indexId < 0)
					continue;

				string identifier = line.Substring(0, indexId + 2);

				switch (identifier) {
					case "Id: ":
						Id = line.Replace(identifier, "");

						// The .conf is actually quite confusing
						// Overriding values are not setup for some reason and the parser
						// has to guess and fix the issues.
						int ival;
						if (Int32.TryParse(Id, out ival)) {
							// Whips overrides the default property to 0
							if (ival >= 1950 && ival < 2000)
								Gender = "0";

							// Bride_Ring, I'm assuming it's hard coded in the client and
							// people thought it would be wise to ignore setting its gender
							if (ival == 2635)
								Gender = "0";

							// Bridegroom_Ring
							if (ival == 2634)
								Gender = "1";
						}
						break;
					case "Name: ": Name = line.Replace("Name: ", "").Trim('\"'); break;
					case "AegisName: ": AegisName = line.Replace("AegisName: ", "").Trim('\"'); break;
					case "Type: ":
						Type = line.Replace(identifier, "");

						// Refine: Refineable            (boolean, defaults to true)
						// ^ the most confusing line I've ever read, this is not true.
						// Defaults to false, default to true for item types 4 and 5
						if (Type == "4" || Type == "5") {
							Refineable = "true";
						}
						break;
					case "Sell: ": Sell = line.Replace(identifier, ""); break;
					case "Buy: ": Buy = line.Replace(identifier, ""); break;
					case "Weight: ": Weight = line.Replace(identifier, ""); break;
					case "Atk: ": Atk = line.Replace(identifier, ""); break;
					case "Matk: ": Matk = line.Replace(identifier, ""); break;
					case "Range: ": Range = line.Replace(identifier, ""); break;
					case "Def: ":
						Def = line.Replace(identifier, "");

						if (Def.Length > 0 && Def[0] == '-')
							Def = "0";

						break;
					case "Stack: ": Stack = line.Replace(identifier, ""); break;
					case "Sprite: ": Sprite = line.Replace(identifier, ""); break;
					case "Slots: ": Slots = line.Replace(identifier, ""); break;
					case "Job: ": Job = line.Replace(identifier, ""); break;
					case "Upper: ": Upper = line.Replace(identifier, ""); break;
					case "Gender: ": Gender = line.Replace(identifier, ""); break;
					case "Loc: ": Loc = line.Replace(identifier, ""); break;
					case "WeaponLv: ": WeaponLv = line.Replace(identifier, ""); break;
					case "EquipLv: ": EquipLv = line.Replace(identifier, ""); break;
					case "Refine: ": Refineable = line.Replace(identifier, ""); break;
					case "View: ": View = line.Replace(identifier, ""); break;
					case "BindOnEquip: ": BindOnEquip = line.Replace(identifier, ""); break;
					case "BuyingStore: ": BuyingStore = line.Replace(identifier, ""); break;
					case "Delay: ": Delay = line.Replace(identifier, ""); break;
					case "Trade: ":
						index++;
						line = lines[index];

						StringBuilder builderTrade = new StringBuilder();
						builderTrade.AppendLineUnix();

						while (line != "}" && line != null) {
							builderTrade.AppendLineUnix(line);
							index++;
							line = lines[index];
						}

						Trade.Set(builderTrade.ToString());
						break;
					case "Nouse: ":
						index++;
						line = lines[index];

						while (line != "}" && line != null) {
							indexId = line.IndexOf(": ", StringComparison.Ordinal);

							if (indexId < 0) {
								index++;
								line = index >= lines.Count ? null : lines[index];
								continue;
//.........这里部分代码省略.........
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:101,代码来源:ItemParser.cs

示例3: _trySet

		private static void _trySet(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute) {
			builder.Append("\t");
			builder.Append(attribute.AttributeName);
			builder.Append(": ");
			builder.AppendLineUnix(tuple.GetValue<string>(attribute));
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:6,代码来源:ItemParser.cs

示例4: _trySetIfDefaultEmptyToHex

		private static void _trySetIfDefaultEmptyToHex(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			int ival;

			if (Int32.TryParse(val, out ival)) {
				string sval = "0x" + ival.ToString("X").ToLower();

				if (val != defaultValue) {
					builder.Append("\t");
					builder.Append(attribute.AttributeName);
					builder.Append(": ");
					builder.AppendLineUnix(sval);
				}
			}
			else {
				Z.F();
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:19,代码来源:ItemParser.cs

示例5: _trySetIfDefaultEmptyAddHex

		private static void _trySetIfDefaultEmptyAddHex(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = "0x" + tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue && val.Length > 2 && val.ToLower() != "0xffffffff") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:10,代码来源:ItemParser.cs

示例6: _trySetIfRefineable

		private static void _trySetIfRefineable(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) {
			int type = tuple.GetValue<int>(ServerItemAttributes.Type);
			bool val = tuple.GetValue<bool>(attribute);

			if (type != 4 && type != 5) {
				if (val) {
					// This is not supposed to be allowed, but... we'll let it slide
					DbLoaderErrorHandler.Handle("The refineable status on the item ID [" + tuple.GetKey<int>() + "] has been set to true but the item type is not an equipment. This is suspicious.", ErrorLevel.Warning);
					builder.AppendLineUnix("\t" + attribute.AttributeName + ": true");
				}
				return;
			}

			if (val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val.ToString().ToLower());
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:20,代码来源:ItemParser.cs

示例7: _trySetIfDefaultBoolean

		private static void _trySetIfDefaultBoolean(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) {
			if (tuple.GetRawValue(attribute.Index) as string == "")
				return;

			bool val = tuple.GetValue<bool>(attribute);

			if (val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val.ToString().ToLower());
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:13,代码来源:ItemParser.cs

示例8: Format

		public static string Format(string val, int indent = 2, bool setBrackets = false) {
			StringBuilder builder = new StringBuilder();

			int index = 0;
			int level = indent;
			bool quotation = false;
			bool trim = false;
			int lines = 1;

			if (level == 2) {
				builder.AppendLineUnix();
				builder.AppendIndent(level);
			}

			while (index < val.Length) {
				char c = val[index];

				switch (c) {
					case ';':
						if (!quotation) {
							lines++;
							builder.Append(";\n");
							builder.AppendIndent(level);
							trim = true;
						}
						else {
							builder.Append(c);
						}
						break;
					case '{':
						if (!quotation) {
							lines++;
							builder.Append("{\n");
							level++;
							builder.AppendIndent(level);
							trim = true;
						}
						else {
							builder.Append(c);
						}
						break;
					case '}':
						if (!quotation) {
							level--;
							lines++;

							if (builder.Length > 0 && builder[builder.Length - 1] == '\t') {
								builder[builder.Length - 1] = '}';
							}
							else {
								builder.Append(c);
							}

							builder.Append('\n');
							builder.AppendIndent(level);
							trim = true;
						}
						else {
							builder.Append(c);
						}
						break;
					case ' ':
					case '\t':
						if (trim) {
							index++;
							continue;
						}
						builder.Append(c);
						break;
					case '\"':
						trim = false;
						quotation = !quotation;
						builder.Append(c);
						break;
					default:
						trim = false;
						builder.Append(c);
						break;
				}

				index++;
			}

			string toRet = builder.ToString();

			if (indent == 2) {
				toRet = toRet.Trim(new char[] { '\n', '\t' });

				if (lines <= 2)
					return " " + toRet + " ";

				return "\n\t\t" + toRet + "\n\t";
			}

			return toRet;
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:96,代码来源:ItemParser.cs

示例9: _trySetIfDefaultEmptyBracket

		private static void _trySetIfDefaultEmptyBracket(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": [");
				builder.Append(val);
				builder.AppendLineUnix("]");
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:11,代码来源:ItemParser.cs

示例10: _trySetGender

		private static void _trySetGender(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			int key = tuple.GetKey<int>();
			string val = tuple.GetValue<string>(attribute);

			if (key >= 1950 && key < 2000) {
				if (val == "0")
					return;
			}

			if (key == 2635) {
				if (val == "0")
					return;
			}

			if (val != "" && val != defaultValue && val != "-1") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:21,代码来源:ItemParser.cs

示例11: _trySetIfDefaultEmptyScript

		private static void _trySetIfDefaultEmptyScript(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": <\"");
				builder.Append(Format(val, 2, true));
				builder.AppendLineUnix("\">");
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:11,代码来源:ItemParser.cs

示例12: _trySetIfDefaultLocation

		private static void _trySetIfDefaultLocation(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != "0") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:10,代码来源:ItemParser.cs

示例13: _trySetIfDefault

		private static void _trySetIfDefault(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			if (tuple.GetValue<string>(attribute) != defaultValue) {
				builder.AppendLineUnix("\t" + attribute.AttributeName + ": " + tuple.GetValue<string>(attribute));
			}
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:5,代码来源:ItemParser.cs

示例14: ToHerculesEntry

		public static string ToHerculesEntry(BaseDb db, int itemId) {
			var dbItems = db.GetMeta<int>(ServerDbs.Items);

			StringBuilder builder = new StringBuilder();

			var tuple = dbItems.TryGetTuple(itemId);

			if (tuple != null) {
				builder.AppendLineUnix("{");
				builder.AppendLineUnix("\tId: " + tuple.GetKey<int>().ToString(CultureInfo.InvariantCulture));
				builder.AppendLineUnix("\tAegisName: \"" + tuple.GetValue<string>(ServerItemAttributes.AegisName) + "\"");
				builder.AppendLineUnix("\tName: \"" + tuple.GetValue<string>(ServerItemAttributes.Name) + "\"");

				builder.AppendLineUnix("\tType: " + tuple.GetValue<string>(ServerItemAttributes.Type));
				_trySet(tuple, builder, ServerItemAttributes.Buy);
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sell, (tuple.GetValue<int>(ServerItemAttributes.Buy) / 2).ToString(CultureInfo.InvariantCulture));
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Weight, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Attack, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Matk, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Defense, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Range, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.NumberOfSlots, "0");
				_trySetIfDefaultEmptyAddHex(tuple, builder, ServerItemAttributes.ApplicableJob, "");
				_trySetIfDefaultEmptyUpper(tuple, builder, ServerItemAttributes.Upper);
				_trySetGender(tuple, builder, ServerItemAttributes.Gender, "2");
				_trySetIfDefaultLocation(tuple, builder, ServerItemAttributes.Location);
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.WeaponLevel, "0");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.EquipLevel, "0");
				_trySetIfRefineable(tuple, builder, ServerItemAttributes.Refineable, true);
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.ClassNumber, "0");
				_trySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BindOnEquip, false);
				_trySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BuyingStore, false);
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Delay, "0");

				var trade = tuple.GetRawValue(ServerItemAttributes.Trade.Index) as Trade;
				if (trade != null && trade.NeedPrinting()) builder.AppendLineUnix(trade.ToWriteString());

				var nouse = tuple.GetRawValue(ServerItemAttributes.NoUse.Index) as NoUse;
				if (nouse != null && nouse.NeedPrinting()) builder.AppendLineUnix(nouse.ToWriteString());

				_trySetIfDefaultEmptyBracket(tuple, builder, ServerItemAttributes.Stack, "");
				_trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sprite, "0");
				_trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.Script, "");
				_trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnEquipScript, "");
				_trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnUnequipScript, "");
				builder.Append("},");
			}

			return builder.ToString();
		}
开发者ID:Tokeiburu,项目名称:RagnarokSDE,代码行数:50,代码来源:ItemParser.cs


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