本文整理汇总了C#中HttpError.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# HttpError.GetPropertyValue方法的具体用法?C# HttpError.GetPropertyValue怎么用?C# HttpError.GetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpError
的用法示例。
在下文中一共展示了HttpError.GetPropertyValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToODataInnerError
private static ODataInnerError ToODataInnerError(HttpError httpError)
{
string innerErrorMessage = httpError.GetPropertyValue<string>(HttpErrorKeys.ExceptionMessageKey);
if (innerErrorMessage == null)
{
string messageDetail = httpError.GetPropertyValue<string>(HttpErrorKeys.MessageDetailKey);
if (messageDetail == null)
{
HttpError modelStateError = httpError.GetPropertyValue<HttpError>(HttpErrorKeys.ModelStateKey);
return (modelStateError == null) ? null
: new ODataInnerError { Message = ConvertModelStateErrors(modelStateError) };
}
else
{
return new ODataInnerError() { Message = messageDetail };
}
}
else
{
ODataInnerError innerError = new ODataInnerError();
innerError.Message = innerErrorMessage;
innerError.TypeName = httpError.GetPropertyValue<string>(HttpErrorKeys.ExceptionTypeKey);
innerError.StackTrace = httpError.GetPropertyValue<string>(HttpErrorKeys.StackTraceKey);
HttpError innerExceptionError = httpError.GetPropertyValue<HttpError>(HttpErrorKeys.InnerExceptionKey);
if (innerExceptionError != null)
{
innerError.InnerError = ToODataInnerError(innerExceptionError);
}
return innerError;
}
}
示例2: GetPropertyValue_GetsDefault_IfPropertyMissing
public void GetPropertyValue_GetsDefault_IfPropertyMissing()
{
HttpError error = new HttpError();
Assert.Null(error.GetPropertyValue<string>("key"));
Assert.Equal(0, error.GetPropertyValue<int>("key"));
}
示例3: GetPropertyValue_GetsDefault_IfTypeDoesNotMatch
public void GetPropertyValue_GetsDefault_IfTypeDoesNotMatch()
{
HttpError error = new HttpError();
error["key"] = "x";
Assert.Null(error.GetPropertyValue<Uri>("key"));
Assert.Equal(0, error.GetPropertyValue<int>("key"));
}
示例4: GetPropertyValue_GetsValue_IfTypeMatches
public void GetPropertyValue_GetsValue_IfTypeMatches()
{
HttpError error = new HttpError();
error["key"] = "x";
Assert.Equal("x", error.GetPropertyValue<string>("key"));
Assert.Equal("x", error.GetPropertyValue<object>("key"));
}