DataContractSerializer.IsStartObject Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Okuyucunun seri durumdan çıkarılabilir bir nesne üzerinde konumlandırılıp konumlandırılmadığını belirler.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| IsStartObject(XmlReader) |
öğesinin XmlReader seri durumdan çıkarılabilen bir nesneye yerleştirilip yerleştirilmeyeceğini belirler. |
| IsStartObject(XmlDictionaryReader) |
öğesinin XmlDictionaryReader seri durumdan çıkarılabilen bir nesneye yerleştirilip yerleştirilmeyeceğini belirler. |
IsStartObject(XmlReader)
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
öğesinin XmlReader seri durumdan çıkarılabilen bir nesneye yerleştirilip yerleştirilmeyeceğini belirler.
public:
override bool IsStartObject(System::Xml::XmlReader ^ reader);
public override bool IsStartObject(System.Xml.XmlReader reader);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public override bool IsStartObject(System.Xml.XmlReader reader);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public override bool IsStartObject(System.Xml.XmlReader reader);
override this.IsStartObject : System.Xml.XmlReader -> bool
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
override this.IsStartObject : System.Xml.XmlReader -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
override this.IsStartObject : System.Xml.XmlReader -> bool
Public Overrides Function IsStartObject (reader As XmlReader) As Boolean
Parametreler
Döndürülenler
true okuyucu okunacak akışın başlangıç öğesindeyse; aksi takdirde , false.
- Öznitelikler
Şunlara uygulanır
IsStartObject(XmlDictionaryReader)
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
- Kaynak:
- DataContractSerializer.cs
öğesinin XmlDictionaryReader seri durumdan çıkarılabilen bir nesneye yerleştirilip yerleştirilmeyeceğini belirler.
public:
override bool IsStartObject(System::Xml::XmlDictionaryReader ^ reader);
public override bool IsStartObject(System.Xml.XmlDictionaryReader reader);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public override bool IsStartObject(System.Xml.XmlDictionaryReader reader);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public override bool IsStartObject(System.Xml.XmlDictionaryReader reader);
override this.IsStartObject : System.Xml.XmlDictionaryReader -> bool
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
override this.IsStartObject : System.Xml.XmlDictionaryReader -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
override this.IsStartObject : System.Xml.XmlDictionaryReader -> bool
Public Overrides Function IsStartObject (reader As XmlDictionaryReader) As Boolean
Parametreler
- reader
- XmlDictionaryReader
XmlDictionaryReader XML akışını okumak için kullanılan.
Döndürülenler
true okuyucu okunacak akışın başlangıç öğesindeyse; aksi takdirde , false.
- Öznitelikler
Örnekler
Aşağıdaki örnek, verilerin başlangıcının IsStartObject bulunup bulunmadığını belirlemek için özelliğini kullanır.
public static void ReadObjectData(string path)
{
// Create the reader.
FileStream fs = new FileStream(path, FileMode.Open);
XmlDictionaryReader reader =
XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas());
// Create the DataContractSerializer specifying the type,
// root and namespace to use. The root value corresponds
// to the DataContract.Name value, and the namespace value
// corresponds to the DataContract.Namespace value.
DataContractSerializer ser =
new DataContractSerializer(typeof(Person),
"Customer", @"http://www.contoso.com");
// Test if the serializer is on the start of the
// object data. If so, read the data and write it
// to the console.
while (reader.Read())
{
if (ser.IsStartObject(reader))
{
Console.WriteLine("Found the element");
Person p = (Person)ser.ReadObject(reader);
Console.WriteLine("{0} {1} id:{2}",
p.FirstName, p.LastName, p.ID);
}
Console.WriteLine(reader.Name);
break;
}
fs.Flush();
fs.Close();
}
Public Shared Sub ReadObjectData(ByVal path As String)
' Create the reader.
Dim fs As New FileStream(path, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
' Create the DataContractSerializer specifying the type,
' root and namespace to use. The root value corresponds
' to the DataContract.Name value, and the namespace value
' corresponds to the DataContract.Namespace value.
Dim ser As New DataContractSerializer(GetType(Person), _
"Customer", "http://www.contoso.com")
' Test if the serializer is on the start of the
' object data. If so, read the data and write it
' to the console.
While reader.Read()
If ser.IsStartObject(reader) Then
Console.WriteLine("Found the element")
Dim p As Person = CType(ser.ReadObject(reader), Person)
Console.WriteLine("{0} {1} id:{2}", p.FirstName, p.LastName, p.ID)
End If
Console.WriteLine(reader.Name)
End While
fs.Flush()
fs.Close()
End Sub
Açıklamalar
, IsStartObject xml öğesinde konumlandırılıp konumlandırılmadığını denetleyerek bir nesneyi okuyup okuyamayacağını belirler. Ayrıca okuyucunun konumlandırılmış olduğu XML öğesinin adını ve ad alanını inceler ve değerleri beklenen ad alanıyla karşılaştırır. Beklenen ad ve ad alanı şu şekilde ayarlanabilir: oluşturucuya geçirilen türün veri sözleşmesi adı ve ad alanı veya rootName oluşturucuya geçirilen ve rootNamespace değerleri (varsa).