public void LoadElementsByXElement(XElement rootNode) { Elements.Clear(); foreach (var node in rootNode.Elements("EleModel")) { string type = node.Attribute("Type").Value; IElementInitializeModel model; if (type == string.Format("Bit")) { model = new BitElementModel(); } else { model = new WordElementModel(); } model.LoadByXElement(node); Elements.Add(model); } }
private IElementInitializeModel GenerateElementModel(bool isBit, string Base, uint Offset, int DataType) { IElementInitializeModel model; if (isBit) { model = new BitElementModel(); model.ShowValue = string.Format("OFF"); } else { model = new WordElementModel(); model.ShowValue = 0.ToString(); } model.Base = Base; model.Offset = Offset; model.Value = 0; model.DataType = DataType; return(model); }