当前位置: 首页>>代码示例>>C#>>正文


C# XNode.XPathSelectElement方法代码示例

本文整理汇总了C#中XNode.XPathSelectElement方法的典型用法代码示例。如果您正苦于以下问题:C# XNode.XPathSelectElement方法的具体用法?C# XNode.XPathSelectElement怎么用?C# XNode.XPathSelectElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XNode的用法示例。


在下文中一共展示了XNode.XPathSelectElement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadAppDomain

        private void LoadAppDomain(XNode configRoot)
        {
            var mde = configRoot.XPathSelectElement("appdomain");
            var deleteShadowOnStartup = mde.Attribute("DeleteShadowDirectoryOnStartup")?.Value.ToBoolean() ?? true;
            var moduleDirectory = configRoot.XPathSelectElement("appdomain/modules")?.Attribute("Directory")?.Value ??
                                  "ModuleInstances";
            var moduleShadowCopyDirectory =
                configRoot.XPathSelectElement("appdomain/modules")?.Attribute("ShadowCopyDirectory")?.Value ??
                @"ModuleInstances\bin";
            var pluginsDirectory = configRoot.XPathSelectElement("appdomain/plugins")?.Attribute("Directory")?.Value ??
                                   "Plugins";
            var pluginsShadowCopyDirectory =
                configRoot.XPathSelectElement("appdomain/plugins")?.Attribute("ShadowCopyDirectory")?.Value ??
                @"Plugins\bin";

            AppDomainLoadData = new AppDomainLoadData(deleteShadowOnStartup,
                new DynamicLoadingData(pluginsDirectory, pluginsShadowCopyDirectory),
                new DynamicLoadingData(moduleDirectory, moduleShadowCopyDirectory));
        }
开发者ID:saturn72,项目名称:Saturn72.Core,代码行数:19,代码来源:XmlConfigManager.cs

示例2: Merge

 public XElement Merge(XElement masterElement, XNode sourceElement)
 {
     var masterElementsWithIds = masterElement.XPathSelectElements("//*[@id]");
     foreach (var masterElementWithId in masterElementsWithIds)
     {
         // ReSharper disable PossibleNullReferenceException
         var childElementWithSameId = sourceElement.XPathSelectElement("//*[@id='" + masterElementWithId.Attribute("id").Value + "']");
         // ReSharper restore PossibleNullReferenceException
         if (childElementWithSameId != null)
             masterElementWithId.ReplaceWith(childElementWithSameId);
     }
     return masterElement;
 }
开发者ID:joshski,项目名称:neffigy,代码行数:13,代码来源:IdMatchingXElementMerger.cs

示例3: valueOrEmpty

 static string valueOrEmpty( XNode node, string xpath )
 {
     XElement element = node.XPathSelectElement( xpath ) ;
     return element != null ? element.Value : string.Empty ;
 }
开发者ID:MingMZ,项目名称:treetrim,代码行数:5,代码来源:Settings.cs

示例4: XPathString

 private static string XPathString(XNode source, string expression, IXmlNamespaceResolver ns)
 {
     var result = source.XPathSelectElement(expression, ns);
     return result == null ? null : result.Value;
 }
开发者ID:CallWall,项目名称:CallWall.Web,代码行数:5,代码来源:GoogleContactProfileTranslator.cs

示例5: GetGuidValue

		private static string GetGuidValue(XNode xe, string xpath)
		{
			var xeObjsur = xe.XPathSelectElement(xpath);
			if (xeObjsur == null)
				return null;
			var xaGuid = xeObjsur.Attribute("guid");
			return xaGuid != null ? xaGuid.Value : null;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:8,代码来源:DataMigration7000042.cs

示例6: SearchProperty

        /// <summary>
        /// Searches the attribute value from the given <see cref="XNode"/>'s named property.
        /// </summary>
        /// <param name="node"><see cref="XNode"/></param>
        /// <param name="property">Property element's attribute name.</param>
        /// <exception cref="ArgumentNullException">Thrown if <see cref="XNode"/> or property element's name is null.</exception>
        /// <returns>Property attribute's value</returns>
        public static string SearchProperty(XNode node, string property)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            return
                node.XPathSelectElement(string.Format(CultureInfo.InvariantCulture, "property[@name='{0}']", property)).
                    Attributes("value").First().Value;
        }
开发者ID:slideep,项目名称:templategenerator,代码行数:22,代码来源:TemplateMetadata.cs

示例7: RssItem

 public RssItem(XNode xElement)
 {
     Url = xElement.XPathSelectElement("link").Value;
     Id = int.Parse(Url.Split('/').Skip(3).Take(1).First());
     Publicationdate = DateTime.Parse(xElement.XPathSelectElement("pubDate").Value);
 }
开发者ID:jonvanleuven,项目名称:DeCorrespondent,代码行数:6,代码来源:RssFeedResources.cs

示例8: ValueOrDefault

        private string ValueOrDefault(XNode node, string xpath, XmlNamespaceManager xmlns, string defaultValue)
        {
            var el = node.XPathSelectElement(xpath, xmlns);
            if (el != null && !string.IsNullOrWhiteSpace(el.Value))
            {
                return el.Value;
            }

            return defaultValue;
        }
开发者ID:JaredReisinger,项目名称:TreatyOfBabel.NET,代码行数:10,代码来源:GameModel.cs

示例9: valueOrEmpty

        static string valueOrEmpty( XNode node, string xpath )
        {
            XElement selectedElement = node.XPathSelectElement( xpath ) ;
            if( selectedElement == null )
            {
                return string.Empty ;
            }

            return selectedElement.Value ;
        }
开发者ID:nomailme,项目名称:treetrim,代码行数:10,代码来源:StaticSettings.cs

示例10: populateSmtpSettings

 void populateSmtpSettings( XNode node )
 {
     SmtpServerAddress = valueOrEmpty(node,@"Settings/Smtp/ServerAddress");
     SmtpUsername = valueOrEmpty(node, @"Settings/Smtp/Credentials/Username");
     SmtpPassword = valueOrEmpty(node, @"Settings/Smtp/Credentials/Password");
     XElement element = node.XPathSelectElement( @"Settings/Smtp/TimeoutInSeconds" ) ;
     TimeoutInSeconds = element == null
         ? 60
         : Convert.ToInt32( element.Value, CultureInfo.InvariantCulture ) ;
 }
开发者ID:nomailme,项目名称:treetrim,代码行数:10,代码来源:StaticSettings.cs

示例11: ExtractStatus

        // ReSharper restore InconsistentNaming
        private PaymentStatus ExtractStatus(XNode xml)
        {
            var returnCodeElement = xml.XPathSelectElement("Response/status");
            var returnCode = 0;
            if (Int32.TryParse(returnCodeElement.Value, out returnCode)) {
                switch (returnCode) {
                    #region Big tedious list of DataCash return values taken from https://testserver.datacash.com/software/returncodes.shtml

                    // Success Transaction accepted and logged.
                    case 1: return (PaymentStatus.Ok);
                    // Socket write error Communication was interrupted. The argument is e.g. 523/555 (523 bytes written but 555 expected).
                    case 2: return (PaymentStatus.Error); ;
                    // Timeout A timeout occurred while we were reading the transaction details.
                    case 3: return (PaymentStatus.Error); ;
                    // Edit error A field was specified twice, you sent us too much or invalid data, a pre-auth lookup failed during a fulfill transaction, the swipe field was incorrectly specified, or you omitted a field. The argument will give a better indication of what exactly went wrong.
                    case 5: return (PaymentStatus.Invalid);
                    // Comms error Error in communications link; resend.
                    case 6: return (PaymentStatus.Error);
                    // Not authorised Transaction declined. The arguments are as return code 1, except the first argument is the bank's reason for declining it (e.g. REFERRAL, CALL AUTH CENTRE, PICK UP CARD etc.) or the result from a failed fraud check (e.g. FRAUD DECLINED reason code)
                    case 7: return (PaymentStatus.Declined);
                    // Currency error The currency you specified does not exist
                    case 9: return (PaymentStatus.Invalid);
                    // Authentication error The vTID or password were incorrect
                    case 10: return (PaymentStatus.Error);
                    // Invalid authorisation code The authcode you supplied was invalid
                    case 12: return (PaymentStatus.Invalid);
                    // Type field missing You did not supply a transaction type.
                    case 13: return (PaymentStatus.Invalid);
                    // Database server error Transaction details could not be committed to our database.
                    case 14: return (PaymentStatus.Error);
                    // Invalid type You specified an invalid transaction type
                    case 15: return (PaymentStatus.Invalid);
                    // Cannot fulfill transaction You attempted to fulfill a transaction that either could not be fulfilled (e.g. auth, refund) or already has been.
                    case 19: return (PaymentStatus.Invalid);
                    // Duplicate transaction reference A successful transaction has already been sent using this vTID and reference number.
                    case 20: return (PaymentStatus.Invalid);
                    // Invalid card type This terminal does not accept transactions for this type of card (e.g. Diner's Club, American Express if the merchant does not take American Express, Domestic Maestro if multicurrency only).
                    case 21: return (PaymentStatus.Invalid);
                    // Invalid reference Reference numbers should be 16 digits for fulfill transactions, or between 6 and 30 digits for all others.
                    case 22: return (PaymentStatus.Invalid);
                    // Expiry date invalid The expiry dates should be specified as MM/YY or MM-YY.
                    case 23: return (PaymentStatus.Invalid);
                    // Card has already expired The supplied expiry date is in the past.
                    case 24: return (PaymentStatus.Invalid);
                    // Card number invalid The card number does not pass the standard Luhn checksum test.
                    case 25: return (PaymentStatus.Invalid);
                    // Card number wrong length The card number does not have the expected number of digits.
                    case 26: return (PaymentStatus.Invalid);
                    // Issue number error You did not supply an issue number when we expected one, or the issue number you supplied was non-numeric or too long
                    case 27: return (PaymentStatus.Invalid);
                    // Start date error The start date was missing or malformed (must be MM/YY)
                    case 28: return (PaymentStatus.Invalid);
                    // Card is not valid yet The supplied start date is in the future
                    case 29: return (PaymentStatus.Invalid);
                    // Start date after expiry date
                    case 30: return (PaymentStatus.Invalid);
                    // Invalid amount The amount is missing, is not fully specified to x.xx format
                    case 34: return (PaymentStatus.Invalid);
                    // Invalid cheque type Must be either "business" or "personal"
                    case 40: return (PaymentStatus.Invalid);
                    // Invalid cheque number Cheque number was missing or was not 6 digits
                    case 41: return (PaymentStatus.Invalid);
                    // Invalid sort code The sort code was missing or was not 6 digits
                    case 42: return (PaymentStatus.Invalid);
                    // Invalid account number The account number was missing or was not 8 digits
                    case 44: return (PaymentStatus.Invalid);
                    // Reference in use A transaction with this reference number is already going through the system.
                    case 51: return (PaymentStatus.Invalid);
                    // No free TIDs available for this vTID There are matching TIDs available, but they are all in use.
                    case 53: return (PaymentStatus.Error);
                    // Card used too recently
                    case 56: return (PaymentStatus.Invalid);
                    // Invalid velocity_check value The velocity_check value must be numeric and between 0 and 120
                    case 57: return (PaymentStatus.Invalid);
                    // This combination of currency, card type and environment is not supported by this vTID You either:
                    //  do not take the card type at all (eg. Amex card when you have no Amex TIDs)
                    //  take this currency for some card types, but not this one. (e.g. you wanted to process Domestic Maestro in USD)
                    //  do not take this card type and currency combination for the specified environment. (e.g. you specified capturemethod of 'cnp' when you are only setup for 'ecomm' transactions, or you specified capturemethod of 'cont_auth' or attempted a Historic CA transaction when you are not set up for CA transactions for the supplied card type and currency)
                    case 59: return (PaymentStatus.Invalid);
                    // Invalid XML The XML Document is not valid with our Request schema. The reason is detailed in the <information> element of the Response document.
                    case 60: return (PaymentStatus.Invalid);
                    // Configuration error An error in account configuration caused the transaction to fail. Contact DataCash Technical Support
                    case 61: return (PaymentStatus.Error);
                    // Unsupported protocol Please use the DataCash XML API
                    case 62: return (PaymentStatus.Error);
                    // Method not supported by acquirer The transaction type is not supported by the Acquirer
                    case 63: return (PaymentStatus.Invalid);
                    // APACS30: WRONG TID Error in bank authorization, where APACS30 Response message refers to different TID to that used in APACS30 Request message; resend.
                    case 104: return (PaymentStatus.Error);
                    // APACS30: MSG SEQ NUM ERR Error in bank authorization, where APACS30 Response message refers to different message number to that used in APACS30 Request message; resend.
                    case 105: return (PaymentStatus.Error);
                    // APACS30: WRONG AMOUNT Error in bank authorization, where APACS30 Response message refers to different amount to that used in APACS30 Request message; resend.
                    case 106: return (PaymentStatus.Error);
                    // No capture method specified Your vTID is capable of dealing with transactions from different environments (e.g. MoTo, e-comm), but you have not specified from which environment this transaction has taken place.
                    case 190: return (PaymentStatus.Error);
                    // Unknown format of datacash reference The datacash reference should be a 16 digit number. The first digit (2, 9, 3 or 4) indicates the format used and whether the txn was processed in a live or test environment.
                    case 280: return (PaymentStatus.Invalid);
                    // Datacash reference fails Luhn check The new format of datacash reference includes a luhn check digit. The number supplied failed to pass the luhn check.
                    case 281: return (PaymentStatus.Invalid);
//.........这里部分代码省略.........
开发者ID:Kurejito,项目名称:Kurejito,代码行数:101,代码来源:DataCashPaymentGateway.cs

示例12: GetDefinitionStyle

        private Style GetDefinitionStyle(XNode definitionElement)
        {
            const string xpath = "default/font";
            var fontElement = definitionElement.XPathSelectElement(xpath);
            var colors = GetDefinitionColors(fontElement);
            var font = GetDefinitionFont(fontElement);

            return new Style(colors, font);
        }
开发者ID:thomasjo,项目名称:highlight,代码行数:9,代码来源:XmlConfiguration.cs


注:本文中的XNode.XPathSelectElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。