/// <summary> /// 解析服务器接收到的微信服务器推送过来的消息。 /// </summary> /// <param name="message">服务器接收到的请求消息。</param> /// <returns>接收请求消息对象。</returns> public static IRequestMessage Parse(string message) { #region 参数校验 if (string.IsNullOrEmpty(message)) { throw new StringNullOrEmptyException(nameof(message)); } #endregion #region 获取消息类型 dynamic xmlMsgObj = new DynamicXml(message); string msgTypeText = xmlMsgObj.MsgType.Value; RequestMsgType msgType = EnumExtension.GetEnumItemByDescription <RequestMsgType>(msgTypeText); #endregion //如果不是 事件推送 则, if (msgType != RequestMsgType.Event) { return(GetRequestMessageByMsgType(msgType, message)); } else { string eventTypeText = xmlMsgObj.Event.Value; RequestMsgEventType eventType = EnumExtension.GetEnumItemByDescription <RequestMsgEventType>(eventTypeText); return(GetRequestEventMessageByEventType(eventType, message)); } }
/// <summary> /// 审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Hyperlink_Audit_Click(object sender, RoutedEventArgs e) { if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Customer_Points_Audit)) { Window.Alert(ResCustomerPointsAddRequest.rightMsg_NoRight_Audit); return; } //审核顾客加积分申请操作: DynamicXml selectedModel = this.QueryResultGrid.SelectedItem as DynamicXml; if (null != selectedModel) { CustomerPointsAddRequestDetailInfo detailInfoCtrl = new CustomerPointsAddRequestDetailInfo(selectedModel, "Audit"); detailInfoCtrl.Dialog = Window.ShowDialog( ResCustomerPointsAddRequest.AuditPointsAddRequest_Header , detailInfoCtrl , (s, args) => { if (args.DialogResult == DialogResultType.OK && args.Data != null) { QueryResultGrid.PageIndex = 0; QueryResultGrid.SelectedIndex = -1; QueryResultGrid.Bind(); } } , new Size(600, 530) ); } }
/// <summary> /// Inits the specified current node id. /// </summary> /// <param name="CurrentNodeId">The current node id.</param> /// <param name="PropertyData">The property data.</param> /// <param name="instance">The instance.</param> /// <returns></returns> public bool Init(int CurrentNodeId, string PropertyData, out object instance) { if (!Settings.RazorModelBindingEnabled) { if (Helper.Xml.CouldItBeXml(PropertyData)) { #pragma warning disable 0618 instance = new DynamicXml(PropertyData); #pragma warning restore 0618 return(true); } instance = PropertyData; return(true); } MultiUrlPickerState state = null; if (!string.IsNullOrEmpty(PropertyData)) { state = MultiUrlPickerState.Deserialize(PropertyData); } instance = state; return(true); }
private static string ImageUrlFromXml(RazorLibraryCore ctx, DynamicXml media, string cropProperty, string cropName) { string url = null; if (media != null) { var crop = new DynamicXml(media.DescendantsOrSelf(x => x.Name == cropProperty).FirstOrDefault().ToXml()); try { if (crop != null) { dynamic c = crop.Find("@name", cropName); url = (string)c.url; } } catch { } if (string.IsNullOrWhiteSpace(url)) { var f = media.Descendants(x => x.Name == "umbracoFile").FirstOrDefault(); if (f != null) { url = f.InnerText; } } } return(url ?? ""); }
public string Test_conversion( string text) { var obj = DynamicXml.Parse(text); return(JsonConvert.SerializeObject(obj)); }
private void Hyperlink_EditConsign_Click(object sender, RoutedEventArgs e) { DynamicXml getSelectedItem = this.QueryResultGrid.SelectedItem as DynamicXml; //编辑代收结算单: Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/GatherMaintain/{0}", getSelectedItem["SysNo"]), null, true); }
private void hlbtnEdit_Click(object sender, RoutedEventArgs e) { if (!AuthMgr.HasFunctionPoint(AuthKeyConst.Vendor_UserMgmt_Edit)) { Window.Alert(ResVendorInfo.Msg_HasNoRight); return; } DynamicXml selectedModel = this.dataGrid.SelectedItem as DynamicXml; if (null != selectedModel) { UserProcessor newRequestCtrl = new UserProcessor((int)selectedModel["SysNo"]); newRequestCtrl.Dialog = Window.ShowDialog( ResVendorInfo.Header_EditVendorUser , newRequestCtrl , (s, args) => { if (args.DialogResult == DialogResultType.OK) { dataGrid.Bind(); } } , new Size(850, 550) ); } }
public static void ParseXMLtoDynamic() { //string xml = @"<?xml version=""1.0"" encoding=""utf - 8""?><entry xml:base=""http://sp-devbox2013/_api/"" xmlns=""http://www.w3.org/2005/Atom"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices"" xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns:georss=""http://www.georss.org/georss"" xmlns:gml=""http://www.opengis.net/gml""><id>http://sp-devbox2013/_api/Web/GetUserById(79)</id><category term=""SP.User"" scheme=""http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"" /><link rel=""edit"" href=""Web/GetUserById(79)"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/Groups"" type=""application/atom+xml;type=feed"" title=""Groups"" href=""Web/GetUserById(79)/Groups"" /><title /><updated>2016-12-20T03:01:16Z</updated><author><name /></author><content type=""application/xml""><m:properties><d:Id m:type=""Edm.Int32"">79</d:Id><d:IsHiddenInUI m:type=""Edm.Boolean"">false</d:IsHiddenInUI><d:LoginName>i:0#.w|rbvhsp\hm-common</d:LoginName><d:Title>HM ComUser1</d:Title><d:PrincipalType m:type=""Edm.Int32"">1</d:PrincipalType><d:Email>[email protected]</d:Email><d:IsSiteAdmin m:type=""Edm.Boolean"">false</d:IsSiteAdmin><d:UserId m:type=""SP.UserIdInfo""><d:NameId>s-1-5-21-3464779960-3153506264-3595381425-1199</d:NameId><d:NameIdIssuer>urn:office:idp:activedirectory</d:NameIdIssuer></d:UserId></m:properties></content></entry>"; string xml2 = @"<?xml version=""1.0"" encoding=""utf - 8""?><feed xml:base=""http://sp-devbox2013/_api/"" xmlns=""http://www.w3.org/2005/Atom"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices"" xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns:georss=""http://www.georss.org/georss"" xmlns:gml=""http://www.opengis.net/gml""><id>b9e52242-fd4c-4eeb-8de0-c8306a0d0d94</id><title /><updated>2016-12-20T02:17:00Z</updated><entry m:etag="""1"""><id>8d2da3cf-1041-43be-8b7f-0ba122662ed5</id><category term=""SP.Data.EmployeeShiftTimeListItem"" scheme=""http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"" /><link rel=""edit"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject"" type=""application/atom+xml;type=entry"" title=""FirstUniqueAncestorSecurableObject"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/FirstUniqueAncestorSecurableObject"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments"" type=""application/atom+xml;type=feed"" title=""RoleAssignments"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/RoleAssignments"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles"" type=""application/atom+xml;type=feed"" title=""AttachmentFiles"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/AttachmentFiles"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType"" type=""application/atom+xml;type=entry"" title=""ContentType"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/ContentType"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml"" type=""application/atom+xml;type=entry"" title=""FieldValuesAsHtml"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/FieldValuesAsHtml"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText"" type=""application/atom+xml;type=entry"" title=""FieldValuesAsText"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/FieldValuesAsText"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit"" type=""application/atom+xml;type=entry"" title=""FieldValuesForEdit"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/FieldValuesForEdit"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/File"" type=""application/atom+xml;type=entry"" title=""File"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/File"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder"" type=""application/atom+xml;type=entry"" title=""Folder"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/Folder"" /><link rel=""http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList"" type=""application/atom+xml;type=entry"" title=""ParentList"" href=""Web/Lists(guid'eb7118bf-17ed-47e7-89c9-e92d0ad8b196')/Items(1)/ParentList"" /><title /><updated>2016-12-20T02:17:00Z</updated><author><name /></author><content type=""application/xml""><m:properties><d:FileSystemObjectType m:type=""Edm.Int32"">0</d:FileSystemObjectType><d:Id m:type=""Edm.Int32"">1</d:Id><d:ContentTypeId>0x010082B4587A9EFA47FCB1ADA5A1D1B8F0950090E4637C7267DB4BA42BD9C8C9CAE567</d:ContentTypeId><d:Title m:null=""true"" /><d:EmployeeId m:type=""Edm.Int32"">1</d:EmployeeId><d:StadaDate m:type=""Edm.DateTime"">2016-11-20T17:00:00Z</d:StadaDate><d:ShiftId m:type=""Edm.Int32"">1</d:ShiftId><d:IsValid m:type=""Edm.Boolean"">true</d:IsValid><d:ID m:type=""Edm.Int32"">1</d:ID><d:Modified m:type=""Edm.DateTime"">2016-12-19T12:11:08Z</d:Modified><d:Created m:type=""Edm.DateTime"">2016-12-19T12:11:08Z</d:Created><d:AuthorId m:type=""Edm.Int32"">53</d:AuthorId><d:EditorId m:type=""Edm.Int32"">53</d:EditorId><d:OData__UIVersionString>1.0</d:OData__UIVersionString><d:Attachments m:type=""Edm.Boolean"">false</d:Attachments><d:GUID m:type=""Edm.Guid"">0a16f7c5-fa5b-41fa-a54f-3883485cf4ef</d:GUID></m:properties></content></entry></feed>"; //string xml = @"<Students> // <Student ID=""100""> // <Name>Arul</Name> // <Mark>90</Mark> // </Student> // <Student> // <Name>Arul2</Name> // <Mark>80</Mark> // </Student> //</Students>"; dynamic data = DynamicXml.Parse(xml2); //var id = students.Student[0].ID; //var name1 = students.Student[1].Name; //foreach (var std in students.Student) //{ // Console.WriteLine(std.Mark); //} }
public void Test_get_property_thows_exception( string text) { var obj = DynamicXml.Parse(text); Assert.Catch(typeof(RuntimeBinderException), () => { var _ = obj.b; }); }
private void Hyperlink_EditPO_Click(object sender, RoutedEventArgs e) { //编辑采购单: DynamicXml getSelectedItem = this.QueryResultGrid.SelectedItem as DynamicXml; Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/PurchaseOrderMaintain/{0}", getSelectedItem["sysno"].ToString()), null, true); }
private void Hyperlink_Abandon_Click(object sender, RoutedEventArgs e) { //作废操作: DynamicXml getSelectedItem = this.QueryResultGrid.SelectedItem as DynamicXml; if (null != getSelectedItem) { ConsignSettlementRulesInfoVM editInfo = DynamicConverter <ConsignSettlementRulesInfoVM> .ConvertToVM(getSelectedItem); if (null != editInfo) { Window.Confirm(ResSettledProductsRuleQuery.AlertMsg_ConfirmAbandon, (obj, args) => { if (args.DialogResult == DialogResultType.OK) { ConsignSettlementRulesInfo info = EntityConverter <ConsignSettlementRulesInfoVM, ConsignSettlementRulesInfo> .Convert(editInfo); serviceFacade.AbandonConsignSettleRule(info, (obj2, args2) => { if (args2.FaultsHandle()) { return; } Window.Alert(ResSettledProductsRuleQuery.AlertMsg_AlertTitle, ResSettledProductsRuleQuery.AlertMsg_OprSuc, MessageType.Information, (obj3, args3) => { if (args3.DialogResult == DialogResultType.Cancel) { QueryResultGrid.Bind(); } }); }); } }); } } }
public Hat(int id) { this.id = id; string path = Character.Gdpath + "/Cap/" + id.ToString("D8") + ".img/"; try { top = Image.FromFile(path + "default.default.png"); dynamic xml = new DynamicXml(File.ReadAllText(path + "coord.xml")); if (File.Exists(path + "default.defaultAc.png")) { hasBack = true; back = Image.FromFile(path + "default.defaultAc.png"); try { backdx = Int32.Parse(xml._defaultAc.x.Value); backdy = Int32.Parse(xml._defaultAc.y.Value); } catch (Exception e) { // some items is AC instead // silly nexon not being consistent backdx = Int32.Parse(xml._defaultAC.x.Value); backdy = Int32.Parse(xml._defaultAC.y.Value); } } topdx = Int32.Parse(xml._default.x.Value); topdy = Int32.Parse(xml._default.y.Value); } catch (FileNotFoundException e) { isError = true; Console.WriteLine("File not found: " + e.FileName); } }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { int ndx = (int)indexes[0]; result = new DynamicXml(_elements[ndx]); return(true); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { result = null; if (binder.Name == "Value") { result = _elements[0].Value; } else if (binder.Name == "Count") { result = _elements.Count; } else { var attr = _elements[0].Attribute(XName.Get(binder.Name)); if (attr != null) { result = attr; } else { var items = _elements.Descendants(XName.Get(binder.Name)); if (items == null || items.Count() == 0) { return(false); } result = new DynamicXml(items); } } return(true); }
/// <summary> /// Inits the specified current node id. /// </summary> /// <param name="CurrentNodeId">The current node id.</param> /// <param name="PropertyData">The property data.</param> /// <param name="instance">The instance.</param> /// <returns></returns> public bool Init(int CurrentNodeId, string PropertyData, out object instance) { if (!Settings.RazorModelBindingEnabled) { #pragma warning disable 0618 instance = new DynamicXml(PropertyData); #pragma warning restore 0618 return(true); } var values = new List <string>(); if (!string.IsNullOrEmpty(PropertyData)) { var xml = new XmlDocument(); xml.LoadXml(PropertyData); foreach (XmlNode node in xml.SelectNodes("/values/value")) { values.Add(node.InnerText); } } instance = values; return(true); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { DynamicXml data = value as DynamicXml; if (data != null && parameter != null) { switch (parameter.ToString()) { case "IsVAT": switch (data["InvoiceType"].ToString()) { case "增票": return(Visibility.Collapsed); default: return(Visibility.Visible); } default: break; } } return(null); }
private void btnChooseVendor_Click(object sender, RoutedEventArgs e) { UCVendorQuery selectDialog = new UCVendorQuery(); selectDialog.Dialog = CPApplication.Current.CurrentPage.Context.Window.ShowDialog("供应商查询", selectDialog, (obj, args) => { if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK) { DynamicXml getSelectedVendor = args.Data as DynamicXml; if (null != getSelectedVendor) { this.SelectedVendorSysNo = getSelectedVendor["SysNo"].ToString(); this.txtVendorSysNo.Text = this.SelectedVendorSysNo; this.SelectedVendorName = getSelectedVendor["VendorName"].ToString(); serviceFacade.GetVendorBySysNo(SelectedVendorSysNo, (obj2, args2) => { if (args2.FaultsHandle()) { InitializeTextBox(); return; } OnVendorSelected(args2.Result); }); } } }, new Size(700, 580)); }
public bool SendMessage(string telphone, string message) { try { bool result = false; string apiurl = "http://123.57.51.191:8888/sms.aspx"; string userid = "845"; string account = "bjcrs"; string password = "******"; string sendtime = ""; string action = "send"; string extno = ""; string paramstr = string.Format("userid={0}&account={1}&password={2}&mobile={3}&content={4}&sendTime={5}&action={6}&extno={7}", userid, account, password, telphone, HttpUtility.UrlEncode(message), sendtime, action, extno); string retstr = HttpUtil.Post(apiurl, paramstr, "utf-8"); dynamic retObj = new DynamicXml(retstr); if ("Success".CompareTo(retObj.returnstatus.Value) == 0) { result = true; } return(result); } catch { return(false); } }
public void Deals_With_Hyphenated_Values() { var xml = @"<banner1Link> <url-picker some-attribute='Content'> <new-window>True</new-window> <node-id>1161</node-id> <url>/content/</url> <link-title>12 december Zorgbeurs Care</link-title> </url-picker> </banner1Link>"; var typedXml = new DynamicXml( XmlHelper.StripDashesInElementOrAttributeNames(xml), xml); dynamic dynamicXml = typedXml; var typedElement = typedXml.RawXmlElement.Element("url-picker"); var dynamicElementByCleanedName = dynamicXml.urlpicker; Assert.IsNotNull(typedElement); Assert.IsNotNull(dynamicElementByCleanedName); Assert.AreEqual( typedElement.Attribute("some-attribute").Value, dynamicElementByCleanedName.someattribute); }
private void Hyperlink_VSPOEdit_Click(object sender, RoutedEventArgs e) { //编辑虚库采购单 : DynamicXml getSelectedItem = this.QueryResultGrid.SelectedItem as DynamicXml; Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/VirtualStockPurchaseOrderMaintain/{0}", getSelectedItem["SysNo"]), null, true); }
public string Test_get_text_property( string text) { var obj = DynamicXml.Parse(text); return(obj.a._text); }
public void Test01() { string xml = @"<xml><e1>abc</e1></xml>"; dynamic obj = new DynamicXml(xml); Assert.NotNull(obj); Assert.Equal("abc", obj.e1.Value); }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { // you should check binder.CallInfo, but for the example I'm assuming [n] where n is int type indexing var idx = (int)indexes[0]; result = new DynamicXml(_xele.ElementAt(idx)); return(true); }
//审核 private void Hyperlink_Audit_Click(object sender, RoutedEventArgs e) { DynamicXml getSelectedItem = this.QueryResultGrid.SelectedItem as DynamicXml; if (null != getSelectedItem) { Window.Navigate(string.Format("/ECCentral.Portal.UI.PO/ConsignAdjustMaintain/{0}", getSelectedItem["SysNo"]), null, true); } }
public void XmlDeserializableTest() { dynamic doc = new DynamicXml(@"..\Debug\DynamicExpandoObject\Employees.xml"); foreach (var employee in doc.employees) { Console.WriteLine(employee.firstName); } }
public void Test_get_property_returns_null_and_not_thows_exception( string text) { var obj = DynamicXml.Parse(text, new DynamicXmlOptions { ThrowOnGet = false }); Assert.That(obj.b, Is.Null); }
public string Test_change_text_property_name( string text) { var obj = DynamicXml.Parse(text, new DynamicXmlOptions { TextFieldName = "__text" }); return(obj.a.__text); }
public void Convert_To_XmlDocument() { var xml = "<DAMP fullMedia=\"\" test-attribute=\"someValue\"><mediaItem><Image id=\"1057\" version=\"d58d5c16-153e-4896-892f-a722e45a69af\" parentID=\"-1\" level=\"1\" writerID=\"0\" nodeType=\"1032\" template=\"0\" sortOrder=\"1\" createDate=\"2012-11-05T16:55:29\" updateDate=\"2012-11-05T16:55:44\" nodeName=\"test12\" urlName=\"test12\" writerName=\"admin\" nodeTypeAlias=\"Image\" path=\"-1,1057\"><umbracoFile>/media/54/tulips.jpg</umbracoFile><umbracoWidth>1024</umbracoWidth><umbracoHeight>768</umbracoHeight><umbracoBytes>620888</umbracoBytes><umbracoExtension>jpg</umbracoExtension><newsCrops><crops date=\"2012-11-05T16:55:34\"><crop name=\"thumbCrop\" x=\"154\" y=\"1\" x2=\"922\" y2=\"768\" url=\"/media/54/tulips_thumbCrop.jpg\" /></crops></newsCrops></Image></mediaItem><mediaItem><Image id=\"1055\" version=\"4df1f08a-3552-45f2-b4bf-fa980c762f4a\" parentID=\"-1\" level=\"1\" writerID=\"0\" nodeType=\"1032\" template=\"0\" sortOrder=\"1\" createDate=\"2012-11-05T16:29:58\" updateDate=\"2012-11-05T16:30:27\" nodeName=\"Test\" urlName=\"test\" writerName=\"admin\" nodeTypeAlias=\"Image\" path=\"-1,1055\"><umbracoFile>/media/41/hydrangeas.jpg</umbracoFile><umbracoWidth>1024</umbracoWidth><umbracoHeight>768</umbracoHeight><umbracoBytes>595284</umbracoBytes><umbracoExtension>jpg</umbracoExtension><newsCrops><crops date=\"2012-11-05T16:30:18\"><crop name=\"thumbCrop\" x=\"133\" y=\"0\" x2=\"902\" y2=\"768\" url=\"/media/41/hydrangeas_thumbCrop.jpg\" /></crops></newsCrops></Image></mediaItem></DAMP>"; var dXml = new DynamicXml(xml); var result = dXml.TryConvertTo <XmlDocument>(); Assert.IsTrue(result.Success); Assert.AreEqual(xml, result.Result.InnerXml); }
private void hlbtnSOSysNo_Click(object sender, RoutedEventArgs e) { DynamicXml info = this.QueryResultGrid.SelectedItem as DynamicXml; if (info != null) { Window.Navigate(string.Format(ConstValue.SOMaintainUrlFormat, info["Soid"]), null, true); } }
//跳转到投诉回复 private void ComplainSysNo_Click(object sender, RoutedEventArgs e) { DynamicXml info = this.QueryResultGrid.SelectedItem as DynamicXml; if (info != null) { Window.Navigate(string.Format(ConstValue.SO_ComplainReplyUrl, info["SysNo"]), null, true); } }
/// <summary> /// Checks if the object is DynamicXml or DynamicNull and ensures that we return the legacy class not the new one /// as we want this class to always ensure we're dealing with the legacy classes /// </summary> /// <param name="result"></param> /// <returns></returns> internal static object ConvertToLegacy(object result) { if (result is Umbraco.Core.Dynamics.DynamicXml) { result = new DynamicXml(((Umbraco.Core.Dynamics.DynamicXml)result).BaseElement); } else if (result is Umbraco.Core.Dynamics.DynamicNull) { result = new DynamicNull(); } else if (result is Umbraco.Core.Dynamics.DynamicDictionary) { result = new DynamicDictionary(((Umbraco.Core.Dynamics.DynamicDictionary) result).SourceItems); } return result; }
public override bool TryGetMember(GetMemberBinder binder, out object result) { result = null; if (binder.Name == "Value") result = _elements[0].Value; else if (binder.Name == "Count") result = _elements.Count; else { var attr = _elements[0].Attribute(XName.Get(binder.Name)); if (attr != null) result = attr; else { var items = _elements.Descendants(XName.Get(binder.Name)); if (items == null || items.Count() == 0) return false; result = new DynamicXml(items); } } return true; }
protected string GetApplicableToOtherFunctionsXml() { DataTable DtIndustries = ddlmslFunctions.GetTable("FunctionsID", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtIndustries, "NAME", "FUNCTIONSID", "ApplicableToOtherFunctions.xml"); return RetXml; }
protected string GetSpecialitesXml() { DataTable DtIndustries = ddlmslSpecialities.GetTable("SpecialtiesID", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtIndustries, "NAME", "SPECIALTIESID", "Specialties.xml"); return RetXml; }
protected string GetIndustriesXml() { DataTable DtIndustries = ddlmslIndustries.GetTable("IndustriesID", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtIndustries, "NAME", "INDUSTRIESID", "Industries.xml"); return RetXml; }
protected string GetCurriculumKeywordsXml() { DataTable DtCurriculumKeywords = ddlmslAnalyzeSolution.GetTable("CurriculumId", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtCurriculumKeywords, "NAME", "CURRICULUMID", "CurriculumKeywords.xml"); return RetXml; }
private bool ConvertPropertyValueByDataType(ref object result, string name, Guid dataType) { //the resulting property is a string, but to support some of the nice linq stuff in .Where //we should really check some more types string sResult = string.Format("{0}", result).Trim(); //boolean if (dataType == DATATYPE_YESNO_GUID) { bool parseResult; if (string.IsNullOrEmpty(string.Format("{0}", result))) { result = false; return true; } if (Boolean.TryParse(sResult.Replace("1", "true").Replace("0", "false"), out parseResult)) { result = parseResult; return true; } } ////integer ////this will eat csv strings, so only do it if the decimal also includes a decimal seperator (according to the current culture) //if (dataType == DATATYPE_INTEGER_GUID) //{ // int iResult = 0; // if (int.TryParse(sResult, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.CurrentCulture, out iResult)) // { // result = iResult; // return true; // } //} //this will eat csv strings, so only do it if the decimal also includes a decimal seperator (according to the current culture) if (sResult.Contains(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)) { //decimal decimal dResult = 0; if (decimal.TryParse(sResult, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.CurrentCulture, out dResult)) { result = dResult; return true; } } if (dataType == DATATYPE_DATETIMEPICKER_GUID || dataType == DATATYPE_DATEPICKER_GUID) { //date DateTime dtResult = DateTime.MinValue; if (DateTime.TryParse(string.Format("{0}", result), out dtResult)) { result = dtResult; return true; } else { result = new DynamicNull(); return true; } } // Rich text editor (return IHtmlString so devs doesn't need to decode html if (dataType == DATATYPE_TINYMCE_GUID) { result = new HtmlString(result.ToString()); return true; } if (string.Equals("true", sResult, StringComparison.CurrentCultureIgnoreCase)) { result = true; return true; } if (string.Equals("false", sResult, StringComparison.CurrentCultureIgnoreCase)) { result = false; return true; } if (result != null) { //a really rough check to see if this may be valid xml if (sResult.StartsWith("<") && sResult.EndsWith(">") && sResult.Contains("/")) { try { XElement e = XElement.Parse(DynamicXml.StripDashesInElementOrAttributeNames(sResult), LoadOptions.None); if (e != null) { //check that the document element is not one of the disallowed elements //allows RTE to still return as html if it's valid xhtml string documentElement = e.Name.LocalName; if (!UmbracoSettings.NotDynamicXmlDocumentElements.Any(tag => string.Equals(tag, documentElement, StringComparison.CurrentCultureIgnoreCase))) { result = new DynamicXml(e); return true; } else { //we will just return this as a string return true; } } } catch (Exception) { //we will just return this as a string return true; } } } return true; }
public void TestSetup() { document= XDocument.Parse(SampleXml); wrapper = new DynamicXml(SampleXml); }
protected string GetRecomendedReviewerTypesXml() { DataTable DtRecomendedReviewerTypes = ddlmslRecomendedReviewerTypes.GetTable("ReviewerTypeId", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtRecomendedReviewerTypes, "NAME", "REVIEWERTYPEID", "ReviewerType.xml"); return RetXml; }
protected string GetAnalyzeSolutionXml() { DataTable DtAnalyzeSolution = ddlmslAnalyzeSolution.GetTable("AnalyzeSolutionId", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtAnalyzeSolution, "NAME", "ANALYZESOLUTIONID", "AnalyzeSolution.xml"); return RetXml; }
protected string GetResourcesStakeholderCanPotentiallyProvideXml() { DataTable DtStakeholderResources = ddlmslResStakCanPotProvide.GetTable("StakeholderResourcesID", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtStakeholderResources, "NAME", "STAKEHOLDERRESOURCESID", "StakeholderResources.xml"); return RetXml; }
protected string GetTargetAudienceByLevelXml() { DataTable DtTargetAudience = ddlmslTargetAudience.GetTable("TargetAudienceID", "Name"); DynamicXml DynXml=new DynamicXml(); string RetXml = DynXml.GetXml(DtTargetAudience, "NAME", "TARGETAUDIENCEID", "TargetAudience.xml"); return RetXml; }
protected string GetSignificantImpactOnTrainingXml() { DataTable DtSignificantImpactOnTraining = ddlmslImpactOnTraining.GetTable("TrainingImpactOnId", "Name"); DynamicXml DynXml = new DynamicXml(); string RetXml = DynXml.GetXml(DtSignificantImpactOnTraining, "NAME", "TRAININGIMPACTONID", "SignificantImpactOnTraining.xml"); return RetXml; }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { int ndx = (int)indexes[0]; result = new DynamicXml(_elements[ndx]); return true; }
protected string GetStakeholderXml() { DataTable DtStakeholder = ddlmslStakeholder.GetTable("StakeholderId", "Name"); DynamicXml DynXml=new DynamicXml(); string RetXml = DynXml.GetXml(DtStakeholder, "NAME", "STAKEHOLDERID", "Stakeholder.xml"); return RetXml; }
/// <summary>Parses the given 'auth_info' XML into an 'AuthenticationProfile' object.</summary> /// <param name="profileXml">The raw XML string.</param> public static AuthenticationProfile ToProfile(string profileXml) { // Setup initial conditions. if (profileXml.IsNullOrEmpty(true)) throw new ArgumentNullException("profileXml"); // Create the dynamic XML wrapper. dynamic root = new DynamicXml(profileXml); // Construct the profile object and determine if the request was successful. var userProfile = new AuthenticationProfile { Error = GetError(root) }; if (!userProfile.HasError) { var profile = root.profile; userProfile.Identifier = profile.identifier.Value; userProfile.DisplayName = profile.displayName.Value; userProfile.Email = profile.email.Value; userProfile.VerifiedEmail = profile.verifiedEmail.Value; userProfile.PreferredUserName = profile.preferredUsername.Value; userProfile.AuthenticationProvider = profile.providerName.Value; var name = profile.name; userProfile.Name.Given = name.givenName.Value; userProfile.Name.Family = name.familyName.Value; userProfile.Name.Formatted = name.formatted.Value; } // Finish up. return userProfile; }
public static DynamicXml ToDynamicXmlStream(this XElement xElement) { var dynamicXmlStream = new DynamicXml(xElement); return dynamicXmlStream; }