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


C# SqlXml.CreateReader方法代码示例

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


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

示例1: XMLRecordInnerXml

    public static String XMLRecordInnerXml(SqlXml AXml, String ATag)
    {
        XmlReader LReader = AXml.CreateReader();
        LReader.Read();
        while(!LReader.EOF)
        {
          if(LReader.NodeType == XmlNodeType.Element)
          {
        if (LReader.Name == ATag)
        {
          String LInnerXml = LReader.ReadInnerXml();
          if (String.IsNullOrWhiteSpace(LInnerXml))
            return null;
          else
            return LInnerXml;
        }
        else
        {
          if (!LReader.IsEmptyElement)
            LReader.Skip();
          else
            LReader.Read();
        }
          }
          else
        LReader.Read();
        }

        return null;
    }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:30,代码来源:XmlRecords.cs

示例2: XMLRecordAttributes

 public static IEnumerable XMLRecordAttributes(SqlXml AXml)
 {
     if (AXml.IsNull) yield break;
     XmlReader LReader = AXml.CreateReader();
     XMLRecordAttribute LAttribute;
     if (LReader.Read() && LReader.NodeType == XmlNodeType.Element)
     {
       LAttribute.Index = 0;
       while (LReader.MoveToNextAttribute())
       {
     LAttribute.Index++;
     LAttribute.Name  = LReader.Name;
     LAttribute.Value = LReader.Value;
     yield return LAttribute;
       }
     }
 }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:17,代码来源:XmlRecords.cs

示例3: fnXMLGetMessageValue

    public static SqlString fnXMLGetMessageValue(SqlXml doc, SqlInt32 lcid, SqlInt32 defaultLcid)
    {
        SqlString defaultValue = SqlString.Null;

        if (doc.IsNull)
        {
            return SqlString.Null;
        }

        using (XmlReader xr = doc.CreateReader())
        {
            while (xr.ReadToFollowing("message"))
            {
                int localLcid;
                if (xr.HasAttributes && int.TryParse(xr.GetAttribute("lcid"), out localLcid))
                {
                    if ((lcid == localLcid) && (!xr.IsEmptyElement))
                    {
                        xr.Read();
                        if (xr.NodeType == XmlNodeType.Text || xr.NodeType == XmlNodeType.Whitespace) //Message element contains text
                        {
                            return new SqlString(xr.Value);
                        }
                        return xr.NodeType == XmlNodeType.EndElement ? string.Empty : SqlString.Null;
                    }
                    if ((defaultLcid == localLcid) && (!xr.IsEmptyElement))
                    {
                        xr.Read();
                        if (xr.NodeType == XmlNodeType.Text || xr.NodeType == XmlNodeType.Whitespace) //Message element contains text
                        {
                            defaultValue = xr.Value;
                        }
                        else if (xr.NodeType == XmlNodeType.EndElement) //Message element contains no text
                        {
                            defaultValue = string.Empty;
                        }
                        else
                        {
                            defaultValue = SqlString.Null;
                        }
                    }
                }
            }
        }
        return defaultValue;
    }
开发者ID:jandppw,项目名称:ppwcode-recovered-from-google-code,代码行数:46,代码来源:fnXMLGetValue.cs

示例4: fnXMLGetContextValue

 public static SqlString fnXMLGetContextValue(SqlXml context, SqlString param)
 {
     if (context.IsNull || param.IsNull)
     {
         return SqlString.Null;
     }
     using (XmlReader xr = context.CreateReader())
     {
         while (xr.ReadToFollowing("contextparam"))
         {
             //                if(true) return xr.GetAttribute("key").Equals(Param.Value).ToString();
             if (xr.HasAttributes && xr.GetAttribute("key") == param.Value)
             {
                 xr.Read();
                 if (xr.NodeType == XmlNodeType.Text || xr.NodeType == XmlNodeType.Whitespace) //Message element contains text
                 {
                     return new SqlString(xr.Value);
                 }
                 return xr.NodeType == XmlNodeType.EndElement ? string.Empty : SqlString.Null;
             }
         }
     }
     return SqlString.Null;
 }
开发者ID:jandppw,项目名称:ppwcode-recovered-from-google-code,代码行数:24,代码来源:fnXMLGetValue.cs

示例5: SqlXml_fromZeroLengthXmlReader_CreateReaderTest_withFragment

        public void SqlXml_fromZeroLengthXmlReader_CreateReaderTest_withFragment()
        {
            XmlReaderSettings xs = new XmlReaderSettings();
            xs.ConformanceLevel = ConformanceLevel.Fragment;

            XmlReader rdr = XmlReader.Create(new StringReader(string.Empty), xs);
            SqlXml xmlSql = new SqlXml(rdr);

            XmlReader xrdr = xmlSql.CreateReader();

            Assert.Equal(false, xrdr.Read());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:SqlXmlTest.cs

示例6: SqlXml_fromXmlReader_CreateReaderTest

        public void SqlXml_fromXmlReader_CreateReaderTest()
        {
            string xmlStr = "<Employee><FirstName>Varadhan</FirstName><LastName>Veerapuram</LastName></Employee>";
            XmlReader rdr = new XmlTextReader(new StringReader(xmlStr));
            SqlXml xmlSql = new SqlXml(rdr);

            XmlReader xrdr = xmlSql.CreateReader();
            xrdr.MoveToContent();

            Assert.Equal(xmlStr, xrdr.ReadOuterXml());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:SqlXmlTest.cs

示例7: SqlXml_fromZeroLengthStream_CreateReaderTest

        public void SqlXml_fromZeroLengthStream_CreateReaderTest()
        {
            MemoryStream stream = new MemoryStream();
            SqlXml xmlSql = new SqlXml(stream);

            XmlReader xrdr = xmlSql.CreateReader();

            Assert.Equal(false, xrdr.Read());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:SqlXmlTest.cs

示例8: CreateReader_Stream_Null

		public void CreateReader_Stream_Null ()
		{
			SqlXml xmlSql = new SqlXml ((Stream) null);
			try {
				xmlSql.CreateReader ();
				Assert.Fail ("#1");
			} catch (SqlNullValueException) {
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:SqlXmlTest.cs

示例9: CreateReader_Stream_Unicode

        //[Category ("NotDotNet")] // Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 2
        public void CreateReader_Stream_Unicode()
        {
            string xmlStr = "<Employee><FirstName>Varadhan</FirstName><LastName>Veerapuram</LastName></Employee>";
            MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(xmlStr));
            SqlXml xmlSql = new SqlXml(stream);

            XmlReader xrdr = xmlSql.CreateReader();
            xrdr.MoveToContent();

            Assert.Equal(xmlStr, xrdr.ReadOuterXml());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:SqlXmlTest.cs

示例10: UpdateShardingSchemaInfo

        /// <summary>
        /// Update sharding schma info with a given name.
        /// </summary>
        /// <param name="name">Name associated with the schma info.</param>
        /// <param name="si">The schma info in XML format.</param>
        /// <returns>Storage operation result.</returns>
        public IStoreResults UpdateShardingSchemaInfo(string name, SqlXml si)
        {
            try
            {
                SqlResults result = new SqlResults();

                using (SqlCommand cmd = SqlTransactionScopeGlobal.CreateSqlCommand())
                {
                    cmd.CommandText = @"__ShardManagement.smm_updateShardingSchemaInfo";
                    cmd.CommandType = CommandType.StoredProcedure;

                    XElement input = new XElement(cmd.CommandText,
                        new XElement("gsm_version", SqlStoreGsmVersion.ToString()),
                        new XElement("metadata_name", name),
                        new XElement("schema_info",
                            XElement.Load(si.CreateReader())));

                    SqlStore.AddCommandParameter(cmd, "@input", SqlDbType.Xml, ParameterDirection.Input, 0, input.ToString());
                    SqlParameter resultParam = SqlStore.AddCommandParameter(cmd, "@result", SqlDbType.Int, ParameterDirection.Output, 0, 0);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        result.Fetch(reader);
                    }

                    result.Result = (StoreResult)resultParam.Value;
                }

                return result;
            }
            catch (SqlException se)
            {
                throw new StoreException(
                    Errors.SqlStore_SchemaInfo_SqlException,
                    se,
                    "updating",
                    name);
            }
        }
开发者ID:CrossPoint,项目名称:elastic-db-tools,代码行数:45,代码来源:SqlStore.cs

示例11: ProcessMessage

        internal static SqlNotification ProcessMessage(SqlXml xmlMessage) {
            using (XmlReader xmlReader = xmlMessage.CreateReader()) {
                string keyvalue = String.Empty;

                MessageAttributes messageAttributes = MessageAttributes.None;

                SqlNotificationType   type   = SqlNotificationType.Unknown;
                SqlNotificationInfo   info   = SqlNotificationInfo.Unknown;
                SqlNotificationSource source = SqlNotificationSource.Unknown;

                string key = string.Empty;

                // Move to main node, expecting "QueryNotification".
                xmlReader.Read();
                if ( (XmlNodeType.Element == xmlReader.NodeType) &&
                     (RootNode == xmlReader.LocalName) &&
                     (3 <= xmlReader.AttributeCount) ) {
                    // Loop until we've processed all the attributes.
                    while ((MessageAttributes.All != messageAttributes) && (xmlReader.MoveToNextAttribute())) {
                        try {
                            switch (xmlReader.LocalName) {
                                case TypeAttribute:
                                    try {
                                        SqlNotificationType temp = (SqlNotificationType)Enum.Parse(typeof(SqlNotificationType), xmlReader.Value, true);
                                        if (Enum.IsDefined(typeof(SqlNotificationType), temp)) {
                                            type = temp;
                                        }
                                    }
                                    catch (Exception e) {
                                        if (!ADP.IsCatchableExceptionType(e)) {
                                            throw;
                                        }
                                        ADP.TraceExceptionWithoutRethrow(e); // Discard failure, if it should occur.
                                    }
                                    messageAttributes |= MessageAttributes.Type;
                                    break;
                                case SourceAttribute:
                                    try {
                                        SqlNotificationSource temp = (SqlNotificationSource)Enum.Parse(typeof(SqlNotificationSource), xmlReader.Value, true);
                                        if (Enum.IsDefined(typeof(SqlNotificationSource), temp)) {
                                            source = temp;
                                        }
                                    }
                                    catch (Exception e) {
                                        if (!ADP.IsCatchableExceptionType(e)) {
                                            throw;
                                        }
                                        ADP.TraceExceptionWithoutRethrow(e); // Discard failure, if it should occur.
                                    }
                                    messageAttributes |= MessageAttributes.Source;
                                    break;
                                case InfoAttribute:
                                    try {
                                        string value = xmlReader.Value;
                                        // SQL BU DT 390529 - 3 of the server info values do not match client values - map.
                                        switch (value) {
                                            case "set options":
                                                info = SqlNotificationInfo.Options;
                                                break;
                                            case "previous invalid":
                                                info = SqlNotificationInfo.PreviousFire;
                                                break;
                                            case "query template limit":
                                                info = SqlNotificationInfo.TemplateLimit;
                                                break;
                                            default:
                                                SqlNotificationInfo temp = (SqlNotificationInfo)Enum.Parse(typeof(SqlNotificationInfo), value, true);
                                                if (Enum.IsDefined(typeof(SqlNotificationInfo), temp)) {
                                                    info = temp;
                                                }
                                                break;
                                        }
                                    }
                                    catch (Exception e) {
                                        if (!ADP.IsCatchableExceptionType(e)) {
                                            throw;
                                        }
                                        ADP.TraceExceptionWithoutRethrow(e); // Discard failure, if it should occur.
                                    }
                                    messageAttributes |= MessageAttributes.Info;
                                    break;
                                default:
                                    break;
                            }
                        }
                        catch (ArgumentException e) {
                            ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace.
                            Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> Exception thrown - Enum.Parse failed to parse the value '%ls' of the attribute '%ls'.\n", xmlReader.Value, xmlReader.LocalName);
                            return null;
                        }
                    }

                    if (MessageAttributes.All != messageAttributes) {
                        Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> Not all expected attributes in Message; messageAttributes = '%d'.\n", (int)messageAttributes);
                        return null;
                    }

                    // Proceed to the "Message" node.
                    if (!xmlReader.Read()) {
                        Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:SqlDependencyListener.cs

示例12: CreateReader_XmlReader_Null

 public void CreateReader_XmlReader_Null()
 {
     SqlXml xmlSql = new SqlXml((XmlReader)null);
     try
     {
         xmlSql.CreateReader();
         Assert.False(true);
     }
     catch (SqlNullValueException)
     {
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:12,代码来源:SqlXmlTest.cs

示例13: ToXmlReader

 /// <summary>
 /// Converts the value of the specified SqlXml to its equivalent XmlReader representation.
 /// </summary>
 /// <param name="value">An SqlXml.</param>
 /// <returns>The equivalent XmlReader.</returns>
 public static XmlReader ToXmlReader(SqlXml value) { return value.IsNull ? null : value.CreateReader(); }
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:6,代码来源:Convert.cs

示例14: XMLRecordsCopyInternal

    private static void XMLRecordsCopyInternal(SqlXml AXml, String ATags, Boolean AIntersect, ref StringBuilder AResult)
    {
        String[] LTags = ATags.Split(new Char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
        if(AResult == null)
          AResult = new StringBuilder();

        XmlReader LReader = AXml.CreateReader();
        LReader.Read();
        while(!LReader.EOF)
        {
          if(LReader.NodeType == XmlNodeType.Element)
          {
        if (LTags.Contains(LReader.Name) == AIntersect)
          AResult.Append(LReader.ReadOuterXml());
        else if (!LReader.IsEmptyElement)
          LReader.Skip();
        else
          LReader.Read();
          }
          else
        LReader.Read();
        }
    }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:23,代码来源:XmlRecords.cs

示例15: Remains

        public static IEnumerable Remains(SqlXml arrival, SqlXml deliv)
        {
            var input = new Stack<A>();
            if (!arrival.IsNull) {
                var reader = arrival.CreateReader();
                while (reader.Read()) {
                    if (reader.NodeType != XmlNodeType.Element) continue;
                    input.Push(GetElement(reader));
                }
            }

            var output = new List<A>();
            if (!deliv.IsNull) {
                var reader = deliv.CreateReader();
                while (reader.Read()) {
                    if (reader.NodeType != XmlNodeType.Element) continue;
                    output.Add(GetElement(reader));
                }
            }
            return Difference(input, output);
        }
开发者ID:ubozov,项目名称:Remains,代码行数:21,代码来源:Remains.cs


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