本文整理汇总了C#中Address.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Address.GetType方法的具体用法?C# Address.GetType怎么用?C# Address.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultipleValidationErrorsOnSameMemberReported
public void MultipleValidationErrorsOnSameMemberReported()
{
// Arrange
var model = new Address() { Street = "Microsoft Way" };
var testValidationContext = GetModelValidationContext(model, model.GetType());
var validationContext = testValidationContext.ModelValidationContext;
var topLevelValidationNode =
new ModelValidationNode(
string.Empty,
testValidationContext.ModelValidationContext.ModelExplorer.Metadata,
testValidationContext.ModelValidationContext.ModelExplorer.Model)
{
ValidateAllProperties = true
};
// Act (does not throw)
new DefaultObjectValidator(
testValidationContext.ExcludeFilters,
testValidationContext.ModelMetadataProvider)
.Validate(validationContext, topLevelValidationNode);
// Assert
Assert.Equal(1, validationContext.ModelState.Count);
Assert.Contains("Street", validationContext.ModelState.Keys);
var streetState = validationContext.ModelState["Street"];
Assert.Equal(2, streetState.Errors.Count);
var errorCollection = streetState.Errors.Select(e => e.ErrorMessage);
Assert.Contains(ValidationAttributeUtil.GetStringLengthErrorMessage(null, 5, "Street"), errorCollection);
Assert.Contains(ValidationAttributeUtil.GetRegExErrorMessage("hehehe", "Street"), errorCollection);
}
示例2: Equals
public override bool Equals(Address obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((LongAddress) obj);
}