我开始用Unity做越来越多的工作.我注意到解析方法需要一个PARAMS参数ResolverOverride.
有人可以给我一个例子,我可以如何使用ResolverOverride或指向我一些其他来源,我可以得到更多的线索.
在Visual Studio中添加新类时,它始终创建时不使用修饰符,并使类成为内部类.
class MyClass
{
}
Run Code Online (Sandbox Code Playgroud)
我希望我的类默认创建为公共类.
为什么默认是内部的?
你更喜欢什么?
在我的应用程序中,如果特定类的属性为null或为空(如果它是一个字符串),我需要抛出异常.我不确定在这种情况下使用的最佳例外是什么.我不想创建一个新的异常,我不确定ArgumentNullException在这种情况下是否合适.
我应该创建一个新的例外还是我可以使用的例外?
我不介意抛出一个ApplicationException.
我试图使用VS 2010 RC创建动态数据网站.尝试创建一个我将放置LINQ to SQL类的App_Code文件夹失败.当我选择"添加ASP.NET文件夹"来添加文件夹时,我可以选择仅创建以下文件夹:
App_Code文件夹发生了什么变化?
下面是进行身份验证的代码,生成Authorization标头并调用API.
不幸的是,我在API上发出请求后收到401 Unauthorized错误GET.
但是,当我捕获Fiddler中的流量并重放它时,对API的调用成功,我可以看到所需的200 OK状态代码.
[Test]
public void RedirectTest()
{
HttpResponseMessage response;
var client = new HttpClient();
using (var authString = new StringContent(@"{username: ""theUser"", password: ""password""}", Encoding.UTF8, "application/json"))
{
response = client.PostAsync("http://host/api/authenticate", authString).Result;
}
string result = response.Content.ReadAsStringAsync().Result;
var authorization = JsonConvert.DeserializeObject<CustomAutorization>(result);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(authorization.Scheme, authorization.Token);
client.DefaultRequestHeaders.Add("Accept", "application/vnd.host+json;version=1");
response =
client.GetAsync("http://host/api/getSomething").Result;
Assert.True(response.StatusCode == HttpStatusCode.OK);
}
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,Authorization标头丢失.
但是,在Fiddler中,标题成功传递.
知道我做错了什么吗?
任何想法我怎么能做出background-image与linear-gradient对IE 11的工作?
以下代码在IE 10上运行正常,但在IE 11上不起作用.
background-image: url(IMAGE), -ms-linear-gradient(top, #ffffff, #BEE38F);
Run Code Online (Sandbox Code Playgroud)
我可以linear-gradient使用以下内容在IE 6-9,11上工作,filter但在这种情况下不显示背景图像.
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#BEE38F',GradientType=0 )
Run Code Online (Sandbox Code Playgroud)
我愿意接受一个想法.
更新:这是我目前的代码.
background-image: url(IMAGE), -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#BEE38F));
background-image: url(IMAGE), -webkit-linear-gradient(top, #ffffff, #BEE38F);
background-image: url(IMAGE), -moz-linear-gradient(top, #ffffff, #BEE38F);
background-image: url(IMAGE), -ms-linear-gradient(top, #ffffff, #BEE38F);
background-image: url(IMAGE), -o-linear-gradient(top, #ffffff, #BEE38F);
background-image: url(IMAGE), linear-gradient(to bottom, #ffffff, #BEE38F);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#BEE38F',GradientType=0 );
Run Code Online (Sandbox Code Playgroud) 我创建了一些web apis,当发生错误时,api返回使用CreateErrorResponse消息创建的HttpResponseMessage.像这样的东西:
return Request.CreateErrorResponse(
HttpStatusCode.NotFound, "Failed to find customer.");
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法弄清楚如何在消费者应用程序中检索消息(在这种情况下" 找不到客户. ").
以下是消费者的样本:
private static void GetCustomer()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
string data =
"{\"LastName\": \"Test\", \"FirstName\": \"Test\"";
var content = new StringContent(data, Encoding.UTF8, "application/json");
var httpResponseMessage =
client.PostAsync(
new Uri("http://localhost:55202/api/Customer/Find"),
content).Result;
if (httpResponseMessage.IsSuccessStatusCode)
{
var cust = httpResponseMessage.Content.
ReadAsAsync<IEnumerable<CustomerMobil>>().Result;
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏.
.net ×3
c# ×3
asp.net ×1
consumer ×1
css ×1
dynamic-data ×1
exception ×1
if-statement ×1
rest ×1
unity2.0 ×1