private static IEnumerable <T> GetFlattenedSymbolsOfKind <T>( IContainerSymbol parent, SymbolKind kind) { ImmutableArray <ISymbol> members = parent.GetMembers(); List <T> objList = new List <T>(); Stack <ISymbol> symbolStack = new Stack <ISymbol>(); foreach (ISymbol symbol1 in members) { symbolStack.Push(symbol1); while (symbolStack.Count > 0) { ISymbol symbol2 = symbolStack.Pop(); if (symbol2.Kind == kind) { objList.Add((T)symbol2); foreach (ISymbol member in ((IContainerSymbol)symbol2).GetMembers()) { symbolStack.Push(member); } } } } return((IEnumerable <T>)objList); }
//<LabelDef enabled="False" field="ADMIN_NAME" fields="FIPS_ADMIN,GMI_ADMIN,ADMIN_NAME,FIPS_CNTRY,GMI_CNTRY,CNTRY_NAME,POP_ADMIN,TYPE_ENG,TYPE_LOC,SQKM,SQMI,COLOR_MAP" ruler="Center" invalidvalue=""> // <Font font="Microsoft Sans Serif,9,Regular" color="255,0,0,0" maskcolor="0,0,0,0" /> // <DisplayScaleRange enabled="False" minscale="-1" maxscale="1" /> //</LabelDef> public static LabelDef FromXElement(XElement ele) { if (ele == null) { return(null); } enumLabelSource source = enumLabelSource.Label; if (ele.Attribute("source") != null) { string sourceString = ele.Attribute("source").Value; foreach (enumLabelSource s in Enum.GetValues(typeof(enumLabelSource))) { if (s.ToString() == sourceString) { source = s; break; } } } Font font = FontHelper.StringToFont(ele.Element("Font").Attribute("font").Value); ScaleRange range = ScaleRange.FromXElement(ele.Element("DisplayScaleRange")); Color color = ColorHelper.StringToColor(ele.Element("Font").Attribute("color").Value); Color maskcolor = ColorHelper.StringToColor(ele.Element("Font").Attribute("maskcolor").Value); string field = ele.Attribute("field").Value; string fields = ele.Attribute("fields").Value; bool enabled = bool.Parse(ele.Attribute("enabled").Value); bool autotonewline = false; if (ele.Attribute("autotonewline") != null) { autotonewline = bool.Parse(ele.Attribute("autotonewline").Value); } int charcount = 6; if (ele.Attribute("charcountperline") != null) { charcount = int.Parse(ele.Attribute("charcountperline").Value); } masLabelPosition ruler = masLabelPosition.Center; string rulerstring = ele.Attribute("ruler").Value; foreach (masLabelPosition r in Enum.GetValues(typeof(masLabelPosition))) { if (r.ToString() == rulerstring) { ruler = r; break; } } string invalidvalue = ele.Attribute("invalidvalue").Value; // IContainerSymbol csym = null; if (ele.Element("ContainerSymbol") != null) { csym = PersistObject.ReflectObjFromXElement(ele.Element("ContainerSymbol")) as IContainerSymbol; } // LabelDef def = new LabelDef(field, fields.Trim() != string.Empty ? fields.Split(',') : null); def.LabelFont = font; def.DisplayScaleRange = range; def.EnableLabeling = enabled; def.ForeColor = color; def.MaskColor = maskcolor; def.MasLabelRuler = ruler; def.InvalidValue = invalidvalue; def.LabelSource = source; def.ContainerSymbol = csym; def.AutoToNewline = autotonewline; def.CharcountPerLine = charcount; return(def); }