/// <summary> /// Creates a <see cref="ProtocolConfigurationEx"/> object. /// </summary> /// <remarks> /// To configure the framework to extend a protocol configuration add /// 'configClassPath' to the app.config's 'protocols/item' section. Use the XML /// interior to configure your own configuration properties. /// </remarks> /// <param name="parent">The parent object. This parameter is not used.</param> /// <param name="configContext">The Configuration context object. This parameter /// is not used.</param> /// <param name="section">The XML section node.</param> /// <returns>A ProtocolConfigurationEx that contains the properties necessary /// for Reflection to load the protocol implementation and, if extended, /// properties read by the parent class.</returns> public object Create(object parent, object configContext, System.Xml.XmlNode section) { Dictionary <ushort, ProtocolConfiguration> retVal = new Dictionary <ushort, ProtocolConfiguration>(); foreach (XmlNode node in section.ChildNodes) { ushort id = ushort.Parse(node.Attributes["id"].Value); string assembly = node.Attributes["assembly"].Value; string classPath = node.Attributes["classPath"].Value; XmlNode cfgClassPathNode = node.Attributes["configClassPath"]; ProtocolConfigurationEx plc; if (cfgClassPathNode != null) { FileInfo fi = new FileInfo(Assembly.GetEntryAssembly().Location); string fullName = string.Format(@"{0}\{1}", fi.Directory.FullName, assembly); Assembly a = Assembly.LoadFrom(fullName); plc = (ProtocolConfigurationEx)a.CreateInstance(cfgClassPathNode.Value); if (plc == null) { throw new Exception(string.Format( "Unable to create instance. Assembly: {0} Type Name: {1}", fullName, cfgClassPathNode.Value)); } plc.Initialize(id, assembly, classPath, node); } else { plc = new ProtocolConfigurationEx(id, assembly, classPath); } retVal.Add(plc.Id, plc); } return(retVal); }
/// <summary> /// Creates a <see cref="ProtocolConfigurationEx"/> object. /// </summary> /// <remarks> /// To configure the framework to extend a protocol configuration add /// 'configClassPath' to the app.config's 'protocols/item' section. Use the XML /// interior to configure your own configuration properties. /// </remarks> /// <param name="parent">The parent object. This parameter is not used.</param> /// <param name="configContext">The Configuration context object. This parameter /// is not used.</param> /// <param name="section">The XML section node.</param> /// <returns>A ProtocolConfigurationEx that contains the properties necessary /// for Reflection to load the protocol implementation and, if extended, /// properties read by the parent class.</returns> public object Create(object parent, object configContext, System.Xml.XmlNode section) { Dictionary<ushort, ProtocolConfiguration> retVal = new Dictionary<ushort, ProtocolConfiguration>(); foreach (XmlNode node in section.ChildNodes) { ushort id = ushort.Parse(node.Attributes["id"].Value); string assembly = node.Attributes["assembly"].Value; string classPath = node.Attributes["classPath"].Value; XmlNode cfgClassPathNode = node.Attributes["configClassPath"]; ProtocolConfigurationEx plc; if (cfgClassPathNode != null) { FileInfo fi = new FileInfo(Assembly.GetEntryAssembly().Location); string fullName = string.Format(@"{0}\{1}", fi.Directory.FullName, assembly); Assembly a = Assembly.LoadFrom(fullName); plc = (ProtocolConfigurationEx)a.CreateInstance(cfgClassPathNode.Value); if (plc == null) { throw new Exception(string.Format( "Unable to create instance. Assembly: {0} Type Name: {1}", fullName, cfgClassPathNode.Value)); } plc.Initialize(id, assembly, classPath, node); } else { plc = new ProtocolConfigurationEx(id, assembly, classPath); } retVal.Add(plc.Id, plc); } return retVal; }