private object GetFormatter(XElement element) { string formatterType = GetAttribute(element, "Type"); string formatterName = GetAttribute(element, "Name"); IObjectWithName returnFormatter = null; if (formatterType == "ByteArrayFormatter") { ByteArrayFormatter formatter = null; if (element.Attribute("TypeId") != null && !string.IsNullOrEmpty(element.Attribute("TypeId").Value)) { formatter = new ByteArrayFormatter(formatterName, byte.Parse(element.Attribute("TypeId").Value)); } else { formatter = new ByteArrayFormatter(formatterName); } foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else if (formatterType == "StringFormatter") { StringFormatter formatter = new StringFormatter(formatterName); foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else { throw new UnknownElementException("Unkown formatter type:" + formatterType); } _adapterObjects[_currentAdapterName].Add(returnFormatter.Name, returnFormatter); return(returnFormatter); }
private object GetFormatter(XElement element) { string formatterType = GetAttribute(element, "Type"); string formatterName = GetAttribute(element, "Name"); IObjectWithName returnFormatter = null; if (formatterType == "ByteArrayFormatter") { ByteArrayFormatter formatter = null; if (element.Attribute("TypeId") != null && !string.IsNullOrEmpty(element.Attribute("TypeId").Value)) { formatter = new ByteArrayFormatter(formatterName, byte.Parse(element.Attribute("TypeId").Value)); } else { formatter = new ByteArrayFormatter(formatterName); } foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else if (formatterType == "StringFormatter") { StringFormatter formatter = new StringFormatter(formatterName); foreach (var itemElement in element.Elements("Item")) { formatter.AddItem(GetItem(itemElement)); } returnFormatter = formatter; } else { throw new UnknownElementException("Unkown formatter type:" + formatterType); } _adapterObjects[_currentAdapterName].Add(returnFormatter.Name, returnFormatter); return returnFormatter; }