public static FileSourceParameters ParseConfig(XDocument configDoc, string selectConfig) { FileSourceParameters parameters = new FileSourceParameters(); XElement root = configDoc.Root; string defConfig = root.Attribute("DefaultConfig").Value.ToString(); if (selectConfig == null) { selectConfig = defConfig; } IEnumerable <XElement> configs = from el in root.Elements(XName.Get("FileSourceConfig", "Scallop/FileSourceSchema.xsd")) where el.Attribute("ConfigName").Value == selectConfig select el; if (configs.Count <XElement>() != 1) { throw new ScallopException("Ambiguous config name, " + selectConfig); } XElement activeConfig = configs.First <XElement>(); parameters.SourceUri = new Uri(getParamValue(activeConfig, "SourceUri", "string"), UriKind.RelativeOrAbsolute); parameters.FrameFormat = getParamValue(activeConfig, "FrameFormat", "string"); return(parameters); }
//public void Register(System.Xml.XmlDocument config, string selectConfig) //{ // throw new NotImplementedException(); //} /// <summary> /// Registers a node with a sensor. /// </summary> /// <param name="config">The configuration XML document.</param> /// <param name="selectConfig">String identifying the configuration item to use.</param> public void Register(System.Xml.Linq.XDocument config, string selectConfig) { parameters = FileSourceParameters.ParseConfig(config, selectConfig); if (this.Info != null) { this.Info(this, new ScallopInfoEventArgs( this.ToString() + " " + this.Version + Environment.NewLine + this.parameters.SourceUri + " " + this.parameters.FrameFormat)); } return; }
public static FileSourceParameters ParseConfig(XDocument configDoc, string selectConfig) { FileSourceParameters parameters = new FileSourceParameters(); XElement root = configDoc.Root; string defConfig = root.Attribute("DefaultConfig").Value.ToString(); if (selectConfig == null) selectConfig = defConfig; IEnumerable<XElement> configs = from el in root.Elements(XName.Get("FileSourceConfig", "Scallop/FileSourceSchema.xsd")) where el.Attribute("ConfigName").Value == selectConfig select el; if (configs.Count<XElement>() != 1) throw new ScallopException("Ambiguous config name, " + selectConfig); XElement activeConfig = configs.First<XElement>(); parameters.SourceUri = new Uri(getParamValue(activeConfig, "SourceUri", "string"),UriKind.RelativeOrAbsolute); parameters.FrameFormat = getParamValue(activeConfig, "FrameFormat", "string"); return parameters; }
//public void Register(System.Xml.XmlDocument config, string selectConfig) //{ // throw new NotImplementedException(); //} /// <summary> /// Registers a node with a sensor. /// </summary> /// <param name="config">The configuration XML document.</param> /// <param name="selectConfig">String identifying the configuration item to use.</param> public void Register(System.Xml.Linq.XDocument config, string selectConfig) { parameters = FileSourceParameters.ParseConfig(config, selectConfig); if(this.Info != null) this.Info(this, new ScallopInfoEventArgs( this.ToString()+" "+this.Version+Environment.NewLine+ this.parameters.SourceUri+" "+this.parameters.FrameFormat)); return; }