public IEnumerable <String> Enum(EnumDef e) { var Name = GetEscapedIdentifier(e.DefinitionName()); foreach (var _Line in Combine(Combine(Combine(Begin(), "class "), Name), "(IntFlag):")) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), " "), GetXmlComment(e.Description))) { yield return(_Line); } yield return(""); var k = 0; foreach (var l in e.Literals) { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), GetEscapedIdentifier(l.Name)), " = "), l.Value)) { yield return(_Line == "" ? "" : " " + _Line); } k += 1; } if (e.Literals.Count == 0) { yield return(" " + "pass"); } }
public ActorValueFormat(DefinitionManager manager, JObject src) : base(manager, src) { var enumSrc = manager.ResolveDefSource("ActorValueEnum"); actorValueEnum = (EnumDef)manager.BuildDef(enumSrc); }
public IEnumerable <String> JsonTranslator_Enum(EnumDef e, String NamespaceName) { var Name = e.GetTypeSpec().SimpleName(NamespaceName); foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "FromJson"))), "(j : Dynamic) : "), GetTypeString(e.UnderlyingType, NamespaceName))) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " return cast(j, "), GetTypeString(e.UnderlyingType, NamespaceName)), ");")) { yield return(_Line); } yield return("}"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "ToJson"))), "(o : "), GetTypeString(e.UnderlyingType, NamespaceName)), ") : Dynamic")) { yield return(_Line); } yield return("{"); yield return(" return o;"); yield return("}"); }
public IEnumerable <String> BinaryTranslator_Enum(EnumDef e, String NamespaceName) { foreach (var _Line in Combine(Begin(), BinaryTranslator_Enum(e.GetTypeSpec().SimpleName(NamespaceName), GetTypeString(e.GetTypeSpec(), NamespaceName), e.UnderlyingType.SimpleName(NamespaceName), GetTypeString(e.UnderlyingType, NamespaceName), NamespaceName))) { yield return(_Line); } }
public EnumDef Find(Guid id) { var cached = EnumDefCache.Find(id); if (cached != null) { return(Clone(cached.CachedObject)); } var dbEnumDef = DataContext.GetEntityDataContext().Entities.Object_Defs.OfType <Enum_Def>().FirstOrDefault(e => e.Id == id); if (dbEnumDef == null) { return(null); } var enumDef = new EnumDef { Id = dbEnumDef.Id, Caption = dbEnumDef.Full_Name, Description = dbEnumDef.Description, Name = dbEnumDef.Name, EnumItems = new List <EnumValue>(LoadEnumItems(id)) }; EnumDefCache.Add(enumDef, id); return(Clone(enumDef)); }
private void ParseEnum(string namespace_, EnumDeclarationSyntax enumSyntax, SemanticModel semanticModel) { var enumDef = new EnumDef(); // 名称 enumDef.Name = enumSyntax.Identifier.ValueText; // ネームスペース enumDef.Namespace = namespace_; // swig enumDef.IsDefinedBySWIG = namespace_.Contains(swig_namespace_keyword); foreach (var member in enumSyntax.Members) { var def = ParseEnumMember(member, semanticModel); enumDef.Members.Add(def); } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(enumSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); enumDef.Summary = SummaryComment.Parse(xml); definitions.Enums.Add(enumDef); }
public IEnumerable <String> Enum(EnumDef e) { var Name = GetEscapedIdentifier(e.DefinitionName()); foreach (var _Line in Combine(Begin(), GetXmlComment(e.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), "public final class "), Name)) { yield return(_Line); } yield return("{"); var k = 0; foreach (var l in e.Literals) { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Combine(Combine(Begin(), "public static final "), GetTypeString(e.UnderlyingType, e.NamespaceName())), " "), GetEscapedIdentifier(l.Name)), " = "), l.Value), ";")) { yield return(_Line == "" ? "" : " " + _Line); } k += 1; } yield return("}"); }
private void CekIndukAkun() { if (_IdInduk.Length == 0) { return; } Akun ak = new Akun(); if (ak.FastLoadEntity("Posting,JenisAkun", "IdAkun=@0", new FieldParam("0", _IdInduk))) { if (ak.Posting) { AddError("IdInduk", "Akun Induk adalah Akun Posting"); } if (_JenisAkun != ak._JenisAkun) { AddError("JenisAkun", string.Concat( "Jenis akun harus sama dengan jenis akun induk (", EnumDef.GetEnumName <enJenisAkun> (ak._JenisAkun), ")")); } } else { AddError("IdInduk", "Akun Induk tidak ada di database"); } }
public void FillTranslatorEnumTo(Dictionary <String, TypeDef> VersionedNameToType, EnumDef e, List <String> l, String NamespaceName) { var Name = e.FullName(); EnumDef eHead = null; if (VersionedNameToType.ContainsKey(Name)) { var tHead = VersionedNameToType[Name]; if (tHead.OnEnum) { eHead = tHead.Enum; } } var VersionedSimpleName = e.GetTypeSpec().SimpleName(NamespaceName); var TypeString = GetTypeString(Nonversioned(e.GetTypeSpec()), NamespaceName); var VersionedTypeString = GetTypeString(e.GetTypeSpec(), NamespaceName); if (eHead == null) { FillTranslatorEnumTo(VersionedSimpleName, TypeString, VersionedTypeString, e.Literals, new List <LiteralDef> { }, l, NamespaceName); } else { FillTranslatorEnumTo(VersionedSimpleName, TypeString, VersionedTypeString, e.Literals, eHead.Literals, l, NamespaceName); } }
public Model(string ns, EnumDef def, Option <Document> document, Lst <AttributeDef> attributes) { Namespace = ns; Enum = def; Document = document; Attributes = attributes; }
public GameObject CreateEnumPropertyFilterPanel(PropertyDef property) { GameObject newPanel = Instantiate(enumPropertyPanel.gameObject, propertyFiltersContent); newPanel.gameObject.SetActive(true); SearchPropertyPanel config = newPanel.GetComponent <SearchPropertyPanel>(); config.nameLabelText.text = !string.IsNullOrEmpty(property.Display) ? property.Display : property.Name; int storedFilter; Filters.EnumProperties.TryGetValue(property.Name, out storedFilter); EnumDef enumDef = CardGameManager.Current.Enums.First(def => def.Property.Equals(property.Name)); Vector3 localPosition = config.enumToggle.transform.localPosition; float panelWidth = 0; foreach (KeyValuePair <string, string> enumValue in enumDef.Values) { int lookupKey; if (!enumDef.Lookup.TryGetValue(enumValue.Key, out lookupKey)) { lookupKey = enumDef.CreateLookup(enumValue.Key); } Toggle newToggle = Instantiate(config.enumToggle.gameObject, config.enumContent).GetOrAddComponent <Toggle>(); newToggle.isOn = (storedFilter & lookupKey) != 0; newToggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(property.Name, lookupKey, isOn)); newToggle.GetComponentInChildren <Text>().text = enumValue.Value; newToggle.transform.localPosition = localPosition; float width = newToggle.GetComponentInChildren <Text>().preferredWidth + 25; RectTransform imageTransform = (RectTransform)newToggle.GetComponentInChildren <Image>().transform; imageTransform.sizeDelta = new Vector2(width, imageTransform.sizeDelta.y); localPosition.x += width; panelWidth += width; } if (!string.IsNullOrEmpty(property.Empty)) { int lookupKey; if (!enumDef.Lookup.TryGetValue(property.Empty, out lookupKey)) { lookupKey = enumDef.CreateLookup(property.Empty); } Toggle newToggle = Instantiate(config.enumToggle.gameObject, config.enumContent).GetOrAddComponent <Toggle>(); newToggle.isOn = (storedFilter & lookupKey) != 0; newToggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(property.Name, lookupKey, isOn)); newToggle.GetComponentInChildren <Text>().text = property.Empty; newToggle.transform.localPosition = localPosition; float width = newToggle.GetComponentInChildren <Text>().preferredWidth + 25; RectTransform imageTransform = (RectTransform)newToggle.GetComponentInChildren <Image>().transform; imageTransform.sizeDelta = new Vector2(width, imageTransform.sizeDelta.y); localPosition.x += width; panelWidth += width; } config.enumToggle.gameObject.SetActive(false); config.enumContent.sizeDelta = new Vector2(panelWidth, config.enumContent.sizeDelta.y); return(newPanel); }
public override void LoadData(BinaryReader reader, StructInstance instance) { int offset = (int)reader.BaseStream.Position; uint value = ReadIntValue(reader, instance).ToUInt32(CultureInfo.CurrentCulture); EnumDef enumDef = GetEnumAttribute("enum"); AddCell(instance, new EnumValue(value, enumDef), enumDef.ValueToString(value), offset); }
[Test] public void EnumWithValue() { StructFile structFile = new StructParser().LoadStructs("enum a { b=5, c=8 }"); EnumDef enumDef = structFile.GetEnumByName("a"); Assert.AreEqual("b", enumDef.ValueToString(5)); Assert.AreEqual("c", enumDef.ValueToString(8)); }
[Test] public void Enum() { StructFile structFile = new StructParser().LoadStructs("enum a { b, c }"); EnumDef enumDef = structFile.GetEnumByName("a"); Assert.IsNotNull(enumDef); Assert.AreEqual("b", enumDef.ValueToString(0)); Assert.AreEqual("c", enumDef.ValueToString(1)); }
public override void LoadData(BinaryReader reader, StructInstance instance) { int offset = (int)reader.BaseStream.Position; IConvertible iValue = ReadIntValue(reader, instance); ulong value = iValue.ToUInt64(CultureInfo.CurrentCulture); EnumDef enumDef = GetEnumAttribute("enum"); AddCell(instance, new SetValue((uint)value, enumDef, _size), offset); }
/*public AttrDef(Attribute_Def source) * { * if (source == null) return; * * Id = source.Id; * Name = source.Name ?? String.Empty; * Caption = source.Full_Name ?? String.Empty; * IsNotNull = source.Is_Not_Null ?? false; * IsUnique = source.Is_Unique ?? false; * MaxLength = source.Max_Length ?? 0; * MaxValue = source.Max_Value; * MinValue = source.Min_Value; * DefaultValue = source.Default_Value ?? String.Empty; * OrgTypeId = source.Org_Type_Id; * * if (!source.Data_TypesReference.IsLoaded) source.Data_TypesReference.Load(); * if (source.Data_Types != null) * { * Type = new TypeDef(source.Data_Types); * } * if (source.Enum_Id != null) * { * if (!source.Enum_DefsReference.IsLoaded) source.Enum_DefsReference.Load(); * * EnumDefType = new EnumDef * { * Description = source.Enum_Defs.Description, * Id = (Guid)source.Enum_Id, * Name = source.Enum_Defs.Name ?? String.Empty, * Caption = source.Enum_Defs.Full_Name ?? String.Empty * }; * } * if (source.Document_Id != null) * { * if (!source.Document_DefsReference.IsLoaded) source.Document_DefsReference.Load(); * DocDefType = new DocDef * { * Id = source.Document_Defs.Id, * Name = source.Document_Defs.Name ?? String.Empty, * Caption = source.Document_Defs.Full_Name ?? String.Empty, * AncestorId = source.Document_Defs.Ancestor_Id, * IsInline = source.Document_Defs.Is_Inline ?? false, * IsPublic = source.Document_Defs.Is_Public ?? false * }; * } * Script = source.CalculateScript; * BlobInfo = new BlobInfo * { * MaxHeight = source.BlobMaxHeight ?? 0, * MaxWidth = source.BlobMaxWidth ?? 0, * MaxSizeBytes = source.BlobMaxSizeBytes ?? 0, * IsImage = source.BlobIsImage ?? false * }; * }*/ public AttrDef(AttrDef source) { if (source == null) { return; } Id = source.Id; Name = source.Name; Caption = source.Caption; IsNotNull = source.IsNotNull; IsUnique = source.IsUnique; MaxLength = source.MaxLength; MaxValue = source.MaxValue; MinValue = source.MinValue; DefaultValue = source.DefaultValue; OrgTypeId = source.OrgTypeId; if (source.Type != null) { Type = new TypeDef { Id = source.Type.Id, Name = source.Type.Name } } ; if (source.EnumDefType != null) { EnumDefType = new EnumDef { Description = source.EnumDefType.Description, Id = source.EnumDefType.Id, Name = source.EnumDefType.Name, Caption = source.EnumDefType.Caption }; } if (source.DocDefType != null) { DocDefType = new DocDef { Id = source.DocDefType.Id, Name = source.DocDefType.Name, Caption = source.DocDefType.Caption, AncestorId = source.DocDefType.AncestorId, IsInline = source.DocDefType.IsInline, IsPublic = source.DocDefType.IsPublic }; } Script = source.Script; BlobInfo = new BlobInfo { MaxHeight = source.BlobInfo != null ? source.BlobInfo.MaxHeight : 0, MaxWidth = source.BlobInfo != null ? source.BlobInfo.MaxWidth : 0, MaxSizeBytes = source.BlobInfo != null ? source.BlobInfo.MaxSizeBytes : 0, IsImage = source.BlobInfo != null && source.BlobInfo.IsImage }; }
public GameObject CreateEnumPropertyFilterPanel(string propertyName, PropertyDef property) { GameObject newPanel = Instantiate(toggleFilterPanel.gameObject, propertyFiltersContent); newPanel.gameObject.SetActive(true); SearchFilterPanel config = newPanel.GetComponent <SearchFilterPanel>(); config.nameLabelText.text = !string.IsNullOrEmpty(property.Display) ? property.Display : propertyName; int storedFilter = 0; Filters.EnumProperties.TryGetValue(propertyName, out storedFilter); EnumDef enumDef = CardGameManager.Current.Enums.First(def => def.Property.Equals(propertyName)); float toggleWidth = 0; Vector3 toggleLocalPosition = config.toggle.transform.localPosition; float panelWidth = 0; if (property.DisplayEmptyFirst) { toggleWidth = CreateEmptyEnumToggle(propertyName, property, enumDef, config, storedFilter, toggleLocalPosition); toggleLocalPosition.x += toggleWidth; panelWidth += toggleWidth; } foreach (KeyValuePair <string, string> enumValue in enumDef.Values) { int lookupKey = 0; if (!enumDef.Lookups.TryGetValue(enumValue.Key, out lookupKey)) { lookupKey = enumDef.CreateLookup(enumValue.Key); } Toggle toggle = Instantiate(config.toggle.gameObject, config.toggleGroupContainer).GetOrAddComponent <Toggle>(); toggle.isOn = (storedFilter & lookupKey) != 0; toggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(propertyName, lookupKey, isOn)); toggle.GetComponentInChildren <Text>().text = enumValue.Value; toggle.transform.localPosition = toggleLocalPosition; toggleWidth = toggle.GetComponentInChildren <Text>().preferredWidth + 25; RectTransform toggleImageTransform = (RectTransform)toggle.GetComponentInChildren <Image>().transform; toggleImageTransform.sizeDelta = new Vector2(toggleWidth, toggleImageTransform.sizeDelta.y); toggleLocalPosition.x += toggleWidth; panelWidth += toggleWidth; } if (!property.DisplayEmptyFirst && !string.IsNullOrEmpty(property.DisplayEmpty)) { toggleWidth = CreateEmptyEnumToggle(propertyName, property, enumDef, config, storedFilter, toggleLocalPosition); toggleLocalPosition.x += toggleWidth; panelWidth += toggleWidth; } config.toggle.gameObject.SetActive(false); config.toggleGroupContainer.sizeDelta = new Vector2(panelWidth, config.toggleGroupContainer.sizeDelta.y); return(newPanel); }
EnumDef MkEnumDef(object name, object elems) { FastToken ft = (FastToken)name; Check(char.IsUpper(ft.text[0]), ft.Location, "Invalid Enum type name '{0}', must start with upper case letter", ft.text); Cons <FastToken> members = (Cons <FastToken>)elems; EnumDef enumdef = new EnumDef(ft); foreach (var token in members) { enumdef.Add(token); } return(enumdef); }
[Test] public void IncludeStructFile() { StructSourceContext context = new StructSourceContext(); context.AddSourceText("a.strs", "include b.strs; struct A { enum8 [enum=E] q; }"); context.AddSourceText("b.strs", "enum E { z, x, c }"); StructParser parser = new StructParser(); StructFile file = parser.LoadStructs("a.strs", context); Assert.IsNotNull(file); Assert.AreEqual(0, parser.Errors.Count); EnumDef e = file.GetEnumByName("E"); Assert.AreEqual("c", e.ValueToString(2)); }
public IEnumerable <String> EnumFunctor(EnumDef e) { var TypeString = GetTypeString(e.GetTypeSpec(), "std"); yield return("template <>"); foreach (var _Line in Combine(Combine(Combine(Begin(), "struct hash<"), TypeString), ">")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " size_t operator()(const "), TypeString), " &x) const")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " return hash<"), GetTypeString(e.UnderlyingType, e.NamespaceName())), ">()(static_cast<"), GetTypeString(e.UnderlyingType, e.NamespaceName())), ">(x));")) { yield return(_Line); } yield return(" }"); yield return("};"); yield return("template <>"); foreach (var _Line in Combine(Combine(Combine(Begin(), "struct less<"), TypeString), ">")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " bool operator()(const "), TypeString), " &x, const "), TypeString), " &y) const")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Combine(Combine(Begin(), " return less<"), GetTypeString(e.UnderlyingType, "std")), ">()(static_cast<"), GetTypeString(e.UnderlyingType, "std")), ">(x), static_cast<"), GetTypeString(e.UnderlyingType, "std")), ">(y));")) { yield return(_Line); } yield return(" }"); yield return("};"); }
public EnumDef Clone(EnumDef def) { return(new EnumDef { Id = def.Id, Name = def.Name, Caption = def.Caption, Description = def.Description, EnumItems = def.EnumItems.Select(item => new EnumValue { Id = item.Id, Code = item.Code, Value = item.Value, DefaultValue = item.DefaultValue }).ToList() }); }
public IEnumerable <String> Enum(EnumDef e) { var Name = GetEscapedIdentifier(e.TypeFriendlyName()); var ParserName = GetEscapedIdentifier(e.TypeFriendlyName() + "Parser"); var WriterName = GetEscapedIdentifier(e.TypeFriendlyName() + "Writer"); foreach (var _Line in Combine(Begin(), GetXmlComment(e.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), "public enum "), Name), " : "), GetEnumTypeString(e.UnderlyingType))) { yield return(_Line); } yield return("{"); var k = 0; foreach (var l in e.Literals) { if (k == e.Literals.Count - 1) { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), GetEscapedIdentifier(l.Name)), " = "), l.Value)) { yield return(_Line == "" ? "" : " " + _Line); } } else { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), GetEscapedIdentifier(l.Name)), " = "), l.Value), ",")) { yield return(_Line == "" ? "" : " " + _Line); } } k += 1; } yield return("}"); }
public override string ToString() { var result = new StringBuilder(); for (int i = 0; i < _size * 8; i++) { if ((_value & (1ul << i)) != 0) { if (result.Length > 0) { result.Append(", "); } result.Append(EnumDef.ValueToString((uint)i)); } } return(result.ToString()); }
public bool Read() { if (rdr == null) { rdr = Dp.ExecuteReader(SqlSelect, Parameters); BuildSetter(); } if (rdr.Read()) { if (ReadOnNewEntity) { _Entity = new TEntity(); } for (int i = 0; i < Setter.Length; i++) { if (Setter[i] != null) { object obj = rdr.GetValue(i); if (obj == null || obj == DBNull.Value) { obj = GetDefaultValue(rdr.GetFieldType(i)); } if (EnumType[i] == null) { Setter[i](_Entity, obj); } else { Setter[i](_Entity, EnumDef.GetEnumValue( EnumType[i], obj)); } } } return(true); } return(false); }
public float CreateEmptyEnumToggle(string propertyName, PropertyDef property, EnumDef enumDef, SearchFilterPanel config, int storedFilter, Vector3 toggleLocalPosition) { int lookupKey = 0; if (!enumDef.Lookups.TryGetValue(property.DisplayEmpty, out lookupKey)) { lookupKey = enumDef.CreateLookup(property.DisplayEmpty); } Toggle toggle = Instantiate(config.toggle.gameObject, config.toggleGroupContainer).GetOrAddComponent <Toggle>(); toggle.isOn = (storedFilter & lookupKey) != 0; toggle.onValueChanged.AddListener(isOn => SetEnumPropertyFilter(propertyName, lookupKey, isOn)); toggle.GetComponentInChildren <Text>().text = property.DisplayEmpty; toggle.transform.localPosition = toggleLocalPosition; float toggleWidth = toggle.GetComponentInChildren <Text>().preferredWidth + 25; RectTransform toggleImageTransform = (RectTransform)toggle.GetComponentInChildren <Image>().transform; toggleImageTransform.sizeDelta = new Vector2(toggleWidth, toggleImageTransform.sizeDelta.y); return(toggleWidth); }
public SetValue(uint intValue, EnumDef enumDef, int size) : base(intValue, enumDef) { _size = size; }
public IEnumerable <String> Enum(EnumDef e) { var Name = GetEscapedIdentifier(e.DefinitionName()); var ParserName = GetEscapedIdentifier(GetSuffixedTypeName(e.Name, e.Version, "Parser", e.NamespaceName())); var WriterName = GetEscapedIdentifier(GetSuffixedTypeName(e.Name, e.Version, "Writer", e.NamespaceName())); foreach (var _Line in Combine(Begin(), GetXmlComment(e.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), "public enum "), Name), " : "), GetEnumTypeString(e.UnderlyingType, e.NamespaceName()))) { yield return(_Line); } yield return("{"); var k = 0; foreach (var l in e.Literals) { if (k == e.Literals.Count - 1) { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), GetEscapedIdentifier(l.Name)), " = "), l.Value)) { yield return(_Line == "" ? "" : " " + _Line); } } else { foreach (var _Line in Combine(Begin(), GetXmlComment(l.Description))) { yield return(_Line == "" ? "" : " " + _Line); } foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), GetEscapedIdentifier(l.Name)), " = "), l.Value), ",")) { yield return(_Line == "" ? "" : " " + _Line); } } k += 1; } yield return("}"); foreach (var _Line in Combine(Begin(), GetXmlComment(e.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), "public static class "), ParserName)) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " private static Dictionary<String, "), Name), "> d = new Dictionary<String, "), Name), ">();")) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), " static "), ParserName), "()")) { yield return(_Line); } yield return(" {"); var LiteralDict = e.Literals.ToDictionary(l => l.Name); var LiteralNameAdds = e.Literals.Select(l => new { Name = l.Name, NameOrDescription = l.Name }); var LiteralDescriptionAdds = e.Literals.GroupBy(l => l.Description).Where(l => l.Count() == 1).Select(l => l.Single()).Where(l => !LiteralDict.ContainsKey(l.Description)).Select(l => new { Name = l.Name, NameOrDescription = l.Description }); foreach (var l in LiteralNameAdds.Concat(LiteralDescriptionAdds)) { foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Combine(Combine(Begin(), "d.Add("), GetEscapedStringLiteral(l.NameOrDescription)), ", "), Name), "."), GetEscapedIdentifier(l.Name)), ");")) { yield return(_Line == "" ? "" : " " + _Line); } } yield return(" }"); foreach (var _Line in Combine(Combine(Combine(Begin(), " public static "), Name), "? TryParse(String Value)")) { yield return(_Line); } yield return(" {"); yield return(" if (d.ContainsKey(Value)) { return d[Value]; }"); yield return(" return null;"); yield return(" }"); yield return("}"); foreach (var _Line in Combine(Begin(), GetXmlComment(e.Description))) { yield return(_Line); } foreach (var _Line in Combine(Combine(Begin(), "public static class "), WriterName)) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " private static Dictionary<"), Name), ", String> d = new Dictionary<"), Name), ", String>();")) { yield return(_Line); } foreach (var _Line in Combine(Combine(Combine(Begin(), " static "), WriterName), "()")) { yield return(_Line); } yield return(" {"); foreach (var l in e.Literals) { foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Combine(Combine(Combine(Combine(Combine(Combine(Begin(), "if (!d.ContainsKey("), Name), "."), GetEscapedIdentifier(l.Name)), ")) { d.Add("), Name), "."), GetEscapedIdentifier(l.Name)), ", "), GetEscapedStringLiteral(l.Description)), "); }")) { yield return(_Line == "" ? "" : " " + _Line); } } yield return(" }"); foreach (var _Line in Combine(Combine(Combine(Begin(), " public static String GetDescription("), Name), " Value)")) { yield return(_Line); } yield return(" {"); yield return(" return d[Value];"); yield return(" }"); yield return("}"); }
public List <String> GetEnum(EnumDef e) { return(GetTemplate("DataAccessEnum").Substitute("EnumName", e.Name)); }
public CTDATypeFormat(DefinitionManager manager, JObject src) : base(manager, src) { ctdaTypeFlags = (FlagsDef)manager.ResolveDef("CtdaTypeFlags"); ctdaTypeEnum = (EnumDef)manager.ResolveDef("CtdaTypeEnum"); }
public EnumValue(uint intValue, EnumDef enumDef) : base(intValue) { _enumDef = enumDef; }