private static void AppendField(this StringBuilder builder, AdmField field, int depth) { string type = ""; switch (field.Type) { case AdmFieldType.Integer: type = "INTEGER"; break; case AdmFieldType.Float: type = "FLOAT"; break; case AdmFieldType.Double: type = "DOUBLE"; break; case AdmFieldType.UnsignedInteger: type = "UNSIGNED INT"; break; case AdmFieldType.String: type = "STRING"; break; case AdmFieldType.Boolean: type = "BOOLEAN"; break; case AdmFieldType.Integer64: type = "INTEGER64"; break; case AdmFieldType.Translate: type = "TRANSLATE"; break; } object value = field.Value; if (value is bool) { value = (bool)value ? "True" : "False"; } else if (value is float) { value = ((float)value).ToString(CultureInfo.InvariantCulture); } else if (value is double) { value = ((double)value).ToString(CultureInfo.InvariantCulture); } builder.AppendFormat("{0}<{1}>{2}:{3}\r\n", new String(' ', depth * 3), type, GetStringFromKeyTable(field.NameHash), value); }
private void WriteField(AdmField field) { _writer.Write(field.NameHash); _writer.Write((int)field.Type); switch(field.Type) { case AdmFieldType.Integer: WriteIntegerField((AdmIntegerField)field); break; case AdmFieldType.Float: WriteFloatField((AdmFloatField)field); break; case AdmFieldType.Double: WriteDoubleField((AdmDoubleField)field); break; case AdmFieldType.UnsignedInteger: WriteUnsignedIntegerField((AdmUnsignedIntegerField)field); break; case AdmFieldType.String: WriteStringField((AdmStringField)field); break; case AdmFieldType.Boolean: WriteBooleanField((AdmBooleanField)field); break; case AdmFieldType.Integer64: WriteInteger64Field((AdmInteger64Field)field); break; case AdmFieldType.Translate: WriteTranslateField((AdmTranslateField)field); break; default: throw new AdmWriterException("Unknown field type"); } }
private void GetString(ref Dictionary<int,string> result, AdmField field) { if(field is AdmStringField || field is AdmTranslateField) { int hash = HashUtility.GenerateHash((string)field.Value); if(!result.ContainsKey(hash)) { result.Add(hash, (string)field.Value); } } }