/// <summary> /// i will change the XmlNode to caseParameterizationContent[获取由xml表示的caseParameterizationContent结构,为了扩展性任何时候都应该考虑优先使用该方法解析caseParameterizationContent] /// </summary> /// <param name="sourceNode">source Node (please make sure the sourceNode not null)</param> /// <returns> caseParameterizationContent you want</returns> public static caseParameterizationContent GetXmlParametContent(XmlNode sourceNode) { caseParameterizationContent myParameContent = new caseParameterizationContent(); if (sourceNode != null)//if it is null caseParameterizationContent.contentData will be null { if (sourceNode.Attributes["isHaveParameters"] != null) { if (sourceNode.Attributes["isHaveParameters"].Value == "true") { myParameContent.hasParameter = true; } } if (sourceNode.Attributes["additionalEncoding"] != null) { try { myParameContent.encodetype = (ParameterizationContentEncodingType)Enum.Parse(typeof(ParameterizationContentEncodingType), sourceNode.Attributes["additionalEncoding"].Value); } catch { myParameContent.encodetype = ParameterizationContentEncodingType.encode_default; } } myParameContent.contentData = sourceNode.InnerText; } return(myParameContent); }
/// <summary> /// i will change the XmlNode 's child to caseParameterizationContent use his name (if has same tagName,olny use fist one) /// </summary> /// <param name="sourceNode">source Node (please make sure the sourceNode not null)</param> /// <param name="tagName">child name</param> /// <returns>caseParameterizationContent you want</returns> public static caseParameterizationContent GetXmlParametContent(XmlNode sourceNode, string tagName) { caseParameterizationContent myParameContent = new caseParameterizationContent(); if (sourceNode != null) { XmlNode tempCantent = sourceNode[tagName]; if (tempCantent != null) { return(GetXmlParametContent(tempCantent)); } } return(myParameContent); }
public new static MyActiveMQExecutionContent GetRunContent(XmlNode yourContentNode) { MyActiveMQExecutionContent myRunContent = new MyActiveMQExecutionContent(); if (yourContentNode != null) { if (yourContentNode.Attributes["protocol"] != null && yourContentNode.Attributes["actuator"] != null) { //Content try { myRunContent.caseProtocol = (CaseProtocol)Enum.Parse(typeof(CaseProtocol), yourContentNode.Attributes["protocol"].Value); } catch { myRunContent.errorMessage = "Error :error protocol in Content"; return(myRunContent); } myRunContent.caseActuator = yourContentNode.Attributes["actuator"].Value; //Subscribe List #region Subscribe List <string[]> tempSubscribeRawList = CaseTool.GetXmlInnerMetaDataList(yourContentNode, "Subscribe", new string[] { "type", "durable" }); foreach (string[] tempOneSubscribeRaw in tempSubscribeRawList) { if (tempOneSubscribeRaw[1] != null && tempOneSubscribeRaw[0] != "") { myRunContent.consumerSubscribeList.Add(new MyActiveMQExecutionContent.ConsumerData(tempOneSubscribeRaw[0], tempOneSubscribeRaw[1], tempOneSubscribeRaw[2])); } else { myRunContent.errorMessage = string.Format("Error :error data in Subscribe List with [{0}]", tempOneSubscribeRaw[0]); return(myRunContent); } } #endregion //UnSubscribe List #region UnSubscribe List <string[]> tempUnSubscribeRawList = CaseTool.GetXmlInnerMetaDataList(yourContentNode, "UnSubscribe", new string[] { "type" }); foreach (string[] tempOneUnSubscribeRaw in tempUnSubscribeRawList) { if (tempOneUnSubscribeRaw[1] != null && tempOneUnSubscribeRaw[0] != "") { myRunContent.unConsumerSubscribeList.Add(new MyActiveMQExecutionContent.ConsumerData(tempOneUnSubscribeRaw[0], tempOneUnSubscribeRaw[1], null)); } else { myRunContent.errorMessage = string.Format("Error :error data in UnSubscribe List with [{0}]", tempOneUnSubscribeRaw[0]); return(myRunContent); } } #endregion //Message Send List #region Message Send List <KeyValuePair <XmlNode, string[]> > tempMessageSendList = CaseTool.GetXmlInnerMetaDataListEx(yourContentNode, "Send", new string[] { "name", "type", "isHaveParameters" }); foreach (KeyValuePair <XmlNode, string[]> tempOneMessageSendRaw in tempMessageSendList) { if (!string.IsNullOrEmpty(tempOneMessageSendRaw.Value[1]) && tempOneMessageSendRaw.Value[2] != null && tempOneMessageSendRaw.Value[0] != "") { MyActiveMQExecutionContent.ProducerData tempProducerData = new MyActiveMQExecutionContent.ProducerData(tempOneMessageSendRaw.Value[1], tempOneMessageSendRaw.Value[2], "TextMessage"); caseParameterizationContent tempProducerMessage = CaseTool.GetXmlParametContent(tempOneMessageSendRaw.Key); myRunContent.producerDataSendList.Add(new KeyValuePair <MyActiveMQExecutionContent.ProducerData, caseParameterizationContent>(tempProducerData, tempProducerMessage)); } else { myRunContent.errorMessage = string.Format("Error :error data in Send List with [{0}]", tempOneMessageSendRaw.Value[0]); return(myRunContent); } } #endregion //Receive #region Receive List <string[]> tempConsumerReceiveList = CaseTool.GetXmlInnerMetaDataList(yourContentNode, "Receive", new string[] { "type" }); foreach (string[] tempOneConsumerReceiveRaw in tempConsumerReceiveList) { if (tempOneConsumerReceiveRaw[0] == "") { myRunContent.consumerMessageReceiveList.Add(new MyActiveMQExecutionContent.ConsumerData(null, null, null)); } else { if (tempOneConsumerReceiveRaw[1] != null) { myRunContent.consumerMessageReceiveList.Add(new MyActiveMQExecutionContent.ConsumerData(tempOneConsumerReceiveRaw[0], tempOneConsumerReceiveRaw[1], null)); } else { myRunContent.errorMessage = string.Format("Error :error data in Receive List with [{0}]", tempOneConsumerReceiveRaw[0]); return(myRunContent); } } } #endregion } else { myRunContent.errorMessage = "Error :can not find protocol or actuator in Content "; } } else { myRunContent.errorMessage = "Error :yourContentNode is null"; } return(myRunContent); }