public static string ConvertComplexValueAst(ComplexValueAst node, MofQuirks quirks = MofQuirks.None, string indent = "") { if (node.IsAlias) { return($"${node.Alias.Name}"); } else { var source = new StringBuilder(); // value of GOLF_PhoneNumber source.Append(node.Value.Extent.Text); source.Append(" "); source.Append(node.Of.Extent.Text); source.Append(" "); source.Append(node.TypeName.Name); source.AppendLine(); // { // AreaCode = { "9", "0", "7" }; // Number = { "7", "4", "7", "4", "8", "8", "4" }; // } source.Append(indent); source.Append(AstMofGenerator.ConvertPropertyValueListAst(node.PropertyValues, quirks, indent)); return(source.ToString()); } }
public static Instance FromAstNode(ComplexValueAst node) { if (node == null) { throw new ArgumentNullException("node"); } if (!node.IsInstance) { throw new ArgumentException("Value must represent an instance.", "node"); } var instance = new Instance { ClassName = node.TypeName, Alias = node.Alias }; foreach (var property in node.Properties) { var propertyValue = property.Value.Value; if ((propertyValue as LiteralValueArrayAst) != null) { var itemValues = ((LiteralValueArrayAst)propertyValue).Values .Select(Instance.GetLiteralValue) .ToArray(); instance.Properties.Add(property.Key, itemValues); } else if ((propertyValue as LiteralValueAst) != null) { instance.Properties.Add(property.Key, Instance.GetLiteralValue((LiteralValueAst)propertyValue)); } else if ((propertyValue as ReferenceTypeValueAst) != null) { instance.Properties.Add(property.Key, (((ReferenceTypeValueAst)propertyValue).Name)); } else { throw new InvalidOperationException(); } } return(instance); }
public static string ConvertToMof(ComplexValueAst node, MofQuirks quirks = MofQuirks.None) { return(string.Format("!!!!!{0}!!!!!", node.GetType().Name)); }