Validator.TryValidateObject 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.
Belirtilen nesnenin geçerli olup olmadığını belirler.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>) |
Belirtilen nesnenin doğrulama bağlamı ve doğrulama sonuçları koleksiyonu kullanılarak geçerli olup olmadığını belirler. |
| TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean) |
Belirtilen nesnenin doğrulama bağlamı, doğrulama sonuçları koleksiyonu ve tüm özelliklerin doğrulanıp doğrulanmayacağını belirten bir değer kullanılarak geçerli olup olmadığını belirler. |
TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>)
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
Belirtilen nesnenin doğrulama bağlamı ve doğrulama sonuçları koleksiyonu kullanılarak geçerli olup olmadığını belirler.
public:
static bool TryValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults);
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> -> bool
Public Shared Function TryValidateObject (instance As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult)) As Boolean
Parametreler
- instance
- Object
Doğrulanması gereken nesne.
- validationContext
- ValidationContext
Doğrulanan nesneyi açıklayan bağlam.
- validationResults
- ICollection<ValidationResult>
Başarısız olan her doğrulamayı tutacak bir koleksiyon.
Döndürülenler
true nesne doğrularsa; aksi takdirde , false.
- Öznitelikler
Özel durumlar
instance, null'e eşittir.
instanceüzerinde ObjectInstanceile validationContexteşleşmiyor.
Açıklamalar
Bu yöntem, nesne türüne bağlı her ValidationAttribute örneği değerlendirir. Ayrıca, ile RequiredAttribute işaretlenen her özelliğin sağlanıp sağlanmadığını denetler. Nesnenin özellik değerlerini yinelemeli olarak doğrulamaz.
Şunlara uygulanır
TryValidateObject(Object, ValidationContext, ICollection<ValidationResult>, Boolean)
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
- Kaynak:
- Validator.cs
Belirtilen nesnenin doğrulama bağlamı, doğrulama sonuçları koleksiyonu ve tüm özelliklerin doğrulanıp doğrulanmayacağını belirten bir değer kullanılarak geçerli olup olmadığını belirler.
public:
static bool TryValidateObject(System::Object ^ instance, System::ComponentModel::DataAnnotations::ValidationContext ^ validationContext, System::Collections::Generic::ICollection<System::ComponentModel::DataAnnotations::ValidationResult ^> ^ validationResults, bool validateAllProperties);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")]
public static bool TryValidateObject(object instance, System.ComponentModel.DataAnnotations.ValidationContext validationContext, System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult>? validationResults, bool validateAllProperties);
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Constructing a ValidationContext without a display name is not trim-safe because it uses reflection to discover the type of the instance being validated in order to resolve the DisplayNameAttribute when a display name is not provided.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of instance cannot be statically discovered and the Type's properties can be trimmed.")>]
static member TryValidateObject : obj * System.ComponentModel.DataAnnotations.ValidationContext * System.Collections.Generic.ICollection<System.ComponentModel.DataAnnotations.ValidationResult> * bool -> bool
Public Shared Function TryValidateObject (instance As Object, validationContext As ValidationContext, validationResults As ICollection(Of ValidationResult), validateAllProperties As Boolean) As Boolean
Parametreler
- instance
- Object
Doğrulanması gereken nesne.
- validationContext
- ValidationContext
Doğrulanan nesneyi açıklayan bağlam.
- validationResults
- ICollection<ValidationResult>
Başarısız olan her doğrulamayı tutacak bir koleksiyon.
- validateAllProperties
- Boolean
true tüm özellikleri doğrulamak için; if ise false, yalnızca gerekli öznitelikler doğrulanır.
Döndürülenler
true nesne doğrularsa; aksi takdirde , false.
- Öznitelikler
Özel durumlar
instance, null'e eşittir.
instanceüzerinde ObjectInstanceilevalidationContexteşleşmiyor.
Açıklamalar
Bu yöntem, nesne türüne bağlı her ValidationAttribute örneği değerlendirir. Ayrıca, ile RequiredAttribute işaretlenen her özelliğin sağlanıp sağlanmadığını denetler. Nesnenin özellik değerlerini doğrular ancak validateAllPropertiestrue özellikler tarafından döndürülen nesnelerin özelliklerini özyinelemeli olarak doğrulamaz.