/// <summary> /// Returns the Feed Content information for a content object /// </summary> /// <param name="de">Parent DE</param> /// <param name="co">Content Object</param> /// <returns>Feed Content Interface</returns> public static IFeedContent FeedContent(DEv1_0 de, ContentObject co) { IFeedContent myContent = null; XElement xmlContent = co.XMLContent.EmbeddedXMLContent[0]; //TODO: Fix this hack caused by fix to gml pos element name string contentString = xmlContent.ToString(); contentString = contentString.Replace("gml:Pos", "gml:pos"); var document = XDocument.Parse(contentString); xmlContent = document.Root; string deHash = DEUtilities.ComputeDELookupID(de).ToString(); //TODO: Update FeedContent method to support all supported standards //content is a SensorThings Observation //if (xmlContent.Name.LocalName.Equals("Observation", StringComparison.InvariantCultureIgnoreCase) && // xmlContent.Name.NamespaceName.Equals(EDXLSharp.MQTTSensorThingsLib.Constants.STApiNamespace, StringComparison.InvariantCultureIgnoreCase) ) //{ // XmlSerializer serializer = new XmlSerializer(typeof(Observation)); // Observation observation = (Observation)serializer.Deserialize(xmlContent.CreateReader()); // myContent = new STContent(observation, deHash); //} //content could be CoT or NIEM EMLC, need to check the namespace to know for sure if (xmlContent.Name.LocalName.Equals("event", StringComparison.InvariantCultureIgnoreCase)) { //content could be CoT or NIEM EMLC, need to check the namespace to know for sure //if (xmlContent.Name.NamespaceName.Equals(@"urn:cot:mitre:org", StringComparison.InvariantCultureIgnoreCase)) //{ // string cotString = xmlContent.ToString(); // //remove namespace or CoTLibrary blows up // //brute force method // int index, end, len; // index = cotString.IndexOf("xmlns="); // while (index != -1) // { // end = cotString.IndexOf('"', index); // end++; // end = cotString.IndexOf('"', end); // end++; // len = end - index; // cotString = cotString.Remove(index, len); // index = cotString.IndexOf("xmlns="); // } // CoT_Library.CotEvent anEvent = new CoT_Library.CotEvent(cotString); // CoTContent mCC = new CoTContent(anEvent, deHash); // myContent = mCC; //} if (xmlContent.Name.NamespaceName.Equals(@"http://release.niem.gov/niem/domains/emergencyManagement/3.1/emevent/0.1/emlc/", StringComparison.InvariantCultureIgnoreCase)) { XmlSerializer serializer = new XmlSerializer(typeof(Event)); Event emlc = (Event)serializer.Deserialize(xmlContent.CreateReader()); myContent = new EMLCContent(emlc, deHash); } } return(myContent); }
/// <summary> /// Returns the expiration time of a content object /// </summary> /// <param name="de">Parent DE</param> /// <param name="co">Content Object</param> /// <returns>Expiration time</returns> public static DateTime?GetExpirationTime(DEv1_0 de, ContentObject co) { IFeedContent myContent = FeedContent(de, co); DateTime? expires = null; if (myContent != null) { expires = myContent.Expires(); } if (!expires.HasValue) { expires = de.DateTimeSent.AddDays(1.0); } return(expires); }