public void Load(XDocument stbDoc) { int index = 0; var stbSlabs = stbDoc.Root.Descendants("StbSlab"); foreach (var stbSlab in stbSlabs) { // 必須コード Id.Add((int)stbSlab.Attribute("id")); Name.Add((string)stbSlab.Attribute("name")); IdSection.Add((string)stbSlab.Attribute("id_section")); KindStructure.Add(KindsStructure.RC); // スラブはRCのみ // 必須ではないコード if (stbSlab.Attribute("kind_slab") != null) { if ((string)stbSlab.Attribute("kind_slab") == "NORMAL") { KindSlab.Add(KindsSlab.NORMAL); } else { KindSlab.Add(KindsSlab.CANTI); } } if (stbSlab.Attribute("level") != null) { Level.Add((double)stbSlab.Attribute("level") / 1000d); } else { Level.Add(0d); } // TODO // 必須ではないコードは未実装多め // 子要素 StbNodeid_List var stbNodeIdList = new StbNodeIdList(); NodeIdList.Add(stbNodeIdList.Load(stbSlab)); index++; } }
public void Load(XElement stbElem, StbVersion version) { switch (version) { case StbVersion.Ver1: IEnumerable <XElement> xOpens = stbElem.Elements("StbOpen"); foreach (XElement xOpen in xOpens) { if (xOpen.Attribute("id") != null) { Id.Add((int)xOpen.Attribute("id")); } else { Id.Add(0); } if (xOpen.Attribute("name") != null) { Name.Add((string)xOpen.Attribute("name")); } else { Name.Add(string.Empty); } IdSection.Add((int)xOpen.Attribute("id_section")); PositionX.Add((double)xOpen.Attribute("position_X")); PositionY.Add((double)xOpen.Attribute("position_Y")); LengthX.Add((double)xOpen.Attribute("length_X")); LengthY.Add((double)xOpen.Attribute("length_Y")); Rotate.Add((double)xOpen.Attribute("rotate")); } break; case StbVersion.Ver2: break; default: throw new ArgumentOutOfRangeException(nameof(version), version, "The STB version is not set"); } }
protected override void ElementLoader(XElement stbElem, StbVersion version, string xmlns) { base.ElementLoader(stbElem, version, xmlns); Id.Add((int)stbElem.Attribute("id")); IdSection.Add((int)stbElem.Attribute("id_section")); switch ((string)stbElem.Attribute("kind_structure")) { case "RC": KindStructure.Add(KindsStructure.Rc); break; case "S": KindStructure.Add(KindsStructure.S); break; case "SRC": KindStructure.Add(KindsStructure.Src); break; case "CFT": KindStructure.Add(KindsStructure.Cft); break; default: KindStructure.Add(KindsStructure.Other); break; } }