internal static FY3L2L3HdfProductDef Parse(XElement ele) { string identify = ele.Attribute("identify").Value; if (string.IsNullOrWhiteSpace(identify)) { return(null); } string defaultDatasets = ele.Element("DefaultDatasets").Value; if (string.IsNullOrWhiteSpace(defaultDatasets)) { return(null); } string name = ele.Attribute("name").Value; XElement matchXml = ele.Element("MatchCondition"); if (matchXml == null) { return(null); } string matchFilename = matchXml.Attribute("filename").Value; string matchDatasets = matchXml.Element("DataSets").Value; XElement attributesXml = matchXml.Element("Attributes"); Dictionary <string, string> dic = new Dictionary <string, string>(); if (attributesXml != null) { IEnumerable <XElement> eles = attributesXml.Elements("Attribute"); foreach (XElement aele in eles) { string aname = aele.Attribute("name").Value; string avalue = aele.Attribute("value").Value; if (string.IsNullOrWhiteSpace(aname)) { dic.Add(aname, avalue); } } } if (string.IsNullOrWhiteSpace(matchFilename) && string.IsNullOrWhiteSpace(matchDatasets) && dic.Count == 0) { return(null); } FY3L2L3HdfProductDef hdf = new FY3L2L3HdfProductDef(); hdf.Identify = identify; hdf.Name = name; hdf.MatchFilename = matchFilename; hdf.MatchDatasets = ParseDatasets(matchDatasets); hdf.MatchAttributes = dic; hdf.DefaultDataSets = ParseDatasets(defaultDatasets); return(hdf); }
private static FY3L2L3HdfProductDef[] Parse() { string filename = System.AppDomain.CurrentDomain.BaseDirectory + "FY3L2L3ProductDef.xml"; XDocument doc = XDocument.Load(filename); XElement root = doc.Root; IEnumerable <XElement> eles = root.Elements("Product"); List <FY3L2L3HdfProductDef> list = new List <FY3L2L3HdfProductDef>(); foreach (XElement ele in eles) { FY3L2L3HdfProductDef hdfDef = FY3L2L3HdfProductDef.Parse(ele); if (hdfDef != null) { list.Add(hdfDef); } } return(list.ToArray()); }