CreateReader() публичный Метод

public CreateReader ( ) : XmlReader
Результат XmlReader
    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;
    }
 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;
       }
     }
 }
    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;
    }
 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;
 }
Пример #5
0
        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());
        }
Пример #6
0
        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());
        }
Пример #7
0
        public void SqlXml_fromZeroLengthStream_CreateReaderTest()
        {
            MemoryStream stream = new MemoryStream();
            SqlXml xmlSql = new SqlXml(stream);

            XmlReader xrdr = xmlSql.CreateReader();

            Assert.Equal(false, xrdr.Read());
        }
Пример #8
0
		public void CreateReader_Stream_Null ()
		{
			SqlXml xmlSql = new SqlXml ((Stream) null);
			try {
				xmlSql.CreateReader ();
				Assert.Fail ("#1");
			} catch (SqlNullValueException) {
			}
		}
Пример #9
0
        //[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());
        }
Пример #10
0
        /// <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);
            }
        }
        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");
                        return null;
                    }

                    // Verify state after Read().
                    if ((XmlNodeType.Element != xmlReader.NodeType) || (0 != String.Compare(xmlReader.LocalName, MessageNode, StringComparison.OrdinalIgnoreCase))) {
                        Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                        return null;
                    }

                    // Proceed to the Text Node.
                    if (!xmlReader.Read()) {
                        Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                        return null;
                    }

                    // Verify state after Read().
                    if (xmlReader.NodeType != XmlNodeType.Text) {
                        Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                        return null;
                    }

                    // Create a new XmlTextReader on the Message node value.
                    using (XmlTextReader xmlMessageReader = new XmlTextReader(xmlReader.Value, XmlNodeType.Element, null)) {
                        // Proceed to the Text Node.
                        if (!xmlMessageReader.Read()) {
                            Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                            return null;
                        }                            

                        if (xmlMessageReader.NodeType == XmlNodeType.Text) {
                            key = xmlMessageReader.Value;
                            xmlMessageReader.Close();  
                        }
                        else {
                            Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                            return null;
                        }
                    }

                    return new SqlNotification(info, source, type, key);
                }
                else {
                    Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                    return null; // failure
                }
            }
        }
Пример #12
0
 public void CreateReader_XmlReader_Null()
 {
     SqlXml xmlSql = new SqlXml((XmlReader)null);
     try
     {
         xmlSql.CreateReader();
         Assert.False(true);
     }
     catch (SqlNullValueException)
     {
     }
 }
Пример #13
0
 /// <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(); }
    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();
        }
    }
Пример #15
0
        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);
        }
    public static String XMLRecordsReplace(SqlXml AXml, SqlXml AReplacement)
    {
        if(AXml.IsNull && AReplacement.IsNull)
          return null;
        if(AReplacement.IsNull)
          return AXml.Value;
        if(AXml.IsNull)
          return AReplacement.Value;

        List<String> LTags = new List<String>();
        StringBuilder LResult = new StringBuilder();

        XmlReader LReader = AReplacement.CreateReader();
        LReader.Read();
        while(!LReader.EOF)
        {
          if(LReader.NodeType == XmlNodeType.Element)
          {
        LTags.Add(LReader.Name);
        LResult.Append(LReader.ReadOuterXml());
          }
          else
        LReader.Read();
        }

        LReader.Close();
        LReader = AXml.CreateReader();

        LReader.Read();
        while(!LReader.EOF)
        {
          if(LReader.NodeType == XmlNodeType.Element)
          {
        if (!LTags.Contains(LReader.Name))
          LResult.Append(LReader.ReadOuterXml());
        else if (!LReader.IsEmptyElement)
          LReader.Skip();
        else
          LReader.Read();
          }
          else
        LReader.Read();
        }

        return LResult.Length > 0 ? LResult.ToString() : null;
    }
Пример #17
0
 public static SqlBoolean ExecXSD(SqlXml Source, SqlXml XSD)
 {
     try
     {
         var settings = new XmlReaderSettings();
         settings.Schemas.Add(null, XSD.CreateReader());
         settings.ConformanceLevel = ConformanceLevel.Auto;
         settings.ValidationType = ValidationType.Schema;
         var reader = XmlReader.Create(Source.CreateReader(), settings);
         while (reader.Read()) { }
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #18
0
        public static SqlXml ExecXSLT(SqlXml Source, SqlXml XSLT)
        {
            var XslCompiledTransform = new XslCompiledTransform();
            XslCompiledTransform.Load(XSLT.CreateReader());

            var buffer = new MemoryStream();
            var stream = new StreamWriter(buffer);
            XslCompiledTransform.Transform(Source.CreateReader(), XmlWriter.Create(stream));
            stream.Close();
            return new SqlXml(buffer);
        }
Пример #19
0
		// SqlTypes
		// 
		/// <summary>Converts the value from <c>SqlXml</c> to an equivalent <c>XmlReader</c> value.</summary>
		public static XmlReader ToXmlReader(SqlXml p)          { return p.IsNull? null: p.CreateReader(); }
 private static void SetSqlXml_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlXml value)
 {
     if (value.IsNull)
     {
         setters.SetDBNull(sink, ordinal);
     }
     else
     {
         XmlReader reader = value.CreateReader();
         XmlWriterSettings settings = new XmlWriterSettings {
             CloseOutput = false,
             ConformanceLevel = ConformanceLevel.Fragment,
             Encoding = Encoding.Unicode,
             OmitXmlDeclaration = true
         };
         Stream output = new SmiSettersStream(sink, setters, ordinal, SmiMetaData.DefaultXml);
         XmlWriter writer = XmlWriter.Create(output, settings);
         reader.Read();
         while (!reader.EOF)
         {
             writer.WriteNode(reader, true);
         }
         writer.Flush();
     }
     sink.ProcessMessagesAndThrow();
 }
Пример #21
0
 private static void SetSqlXml_Unchecked(SmiEventSink_Default sink, ITypedSettersV3 setters, int ordinal, SqlXml value) {
     if (value.IsNull) {
         setters.SetDBNull(sink, ordinal);
         sink.ProcessMessagesAndThrow();
     }
     else {
         SetXmlReader_Unchecked(sink, setters, ordinal, value.CreateReader());
     }
 }
 internal static SqlNotification ProcessMessage(SqlXml xmlMessage)
 {
     using (XmlReader reader = xmlMessage.CreateReader())
     {
         MessageAttributes none = MessageAttributes.None;
         SqlNotificationType unknown = SqlNotificationType.Unknown;
         SqlNotificationInfo options = SqlNotificationInfo.Unknown;
         SqlNotificationSource source2 = SqlNotificationSource.Unknown;
         string key = string.Empty;
         reader.Read();
         if (((XmlNodeType.Element == reader.NodeType) && ("QueryNotification" == reader.LocalName)) && (3 <= reader.AttributeCount))
         {
             while ((MessageAttributes.All != none) && reader.MoveToNextAttribute())
             {
                 try
                 {
                     string localName = reader.LocalName;
                     if (localName != null)
                     {
                         if (!(localName == "type"))
                         {
                             if (localName == "source")
                             {
                                 goto Label_00F4;
                             }
                             if (localName == "info")
                             {
                                 goto Label_014F;
                             }
                         }
                         else
                         {
                             try
                             {
                                 SqlNotificationType type = (SqlNotificationType) Enum.Parse(typeof(SqlNotificationType), reader.Value, true);
                                 if (Enum.IsDefined(typeof(SqlNotificationType), type))
                                 {
                                     unknown = type;
                                 }
                             }
                             catch (Exception exception3)
                             {
                                 if (!ADP.IsCatchableExceptionType(exception3))
                                 {
                                     throw;
                                 }
                                 ADP.TraceExceptionWithoutRethrow(exception3);
                             }
                             none |= MessageAttributes.Type;
                         }
                     }
                     continue;
                 Label_00F4:;
                     try
                     {
                         SqlNotificationSource source = (SqlNotificationSource) Enum.Parse(typeof(SqlNotificationSource), reader.Value, true);
                         if (Enum.IsDefined(typeof(SqlNotificationSource), source))
                         {
                             source2 = source;
                         }
                     }
                     catch (Exception exception2)
                     {
                         if (!ADP.IsCatchableExceptionType(exception2))
                         {
                             throw;
                         }
                         ADP.TraceExceptionWithoutRethrow(exception2);
                     }
                     none |= MessageAttributes.Source;
                     continue;
                 Label_014F:;
                     try
                     {
                         SqlNotificationInfo info2;
                         string str3 = reader.Value;
                         string str = str3;
                         if (str == null)
                         {
                             goto Label_019D;
                         }
                         if (!(str == "set options"))
                         {
                             if (str == "previous invalid")
                             {
                                 goto Label_0191;
                             }
                             if (str == "query template limit")
                             {
                                 goto Label_0197;
                             }
                             goto Label_019D;
                         }
                         options = SqlNotificationInfo.Options;
                         goto Label_01EA;
                     Label_0191:
                         options = SqlNotificationInfo.PreviousFire;
                         goto Label_01EA;
                     Label_0197:
                         options = SqlNotificationInfo.TemplateLimit;
                         goto Label_01EA;
                     Label_019D:
                         info2 = (SqlNotificationInfo) Enum.Parse(typeof(SqlNotificationInfo), str3, true);
                         if (Enum.IsDefined(typeof(SqlNotificationInfo), info2))
                         {
                             options = info2;
                         }
                     }
                     catch (Exception exception)
                     {
                         if (!ADP.IsCatchableExceptionType(exception))
                         {
                             throw;
                         }
                         ADP.TraceExceptionWithoutRethrow(exception);
                     }
                 Label_01EA:
                     none |= MessageAttributes.Info;
                     continue;
                 }
                 catch (ArgumentException exception4)
                 {
                     ADP.TraceExceptionWithoutRethrow(exception4);
                     Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> Exception thrown - Enum.Parse failed to parse the value '%ls' of the attribute '%ls'.\n", reader.Value, reader.LocalName);
                     return null;
                 }
             }
             if (MessageAttributes.All != none)
             {
                 Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> Not all expected attributes in Message; messageAttributes = '%d'.\n", (int) none);
                 return null;
             }
             if (!reader.Read())
             {
                 Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                 return null;
             }
             if ((XmlNodeType.Element != reader.NodeType) || (string.Compare(reader.LocalName, "Message", StringComparison.OrdinalIgnoreCase) != 0))
             {
                 Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                 return null;
             }
             if (!reader.Read())
             {
                 Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                 return null;
             }
             if (reader.NodeType != XmlNodeType.Text)
             {
                 Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                 return null;
             }
             using (XmlTextReader reader2 = new XmlTextReader(reader.Value, XmlNodeType.Element, null))
             {
                 if (!reader2.Read())
                 {
                     Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                     return null;
                 }
                 if (reader2.NodeType == XmlNodeType.Text)
                 {
                     key = reader2.Value;
                     reader2.Close();
                 }
                 else
                 {
                     Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
                     return null;
                 }
             }
             return new SqlNotification(options, source2, unknown, key);
         }
         Bid.Trace("<sc.SqlDependencyProcessDispatcher.ProcessMessage|DEP|ERR> unexpected Read failure on xml or unexpected structure of xml.\n");
         return null;
     }
 }