Powershell似乎无法正确地往返这个JSON对象:
{
"settings": {
"minimumApproverCount": 2,
"creatorVoteCounts": false,
"scope": [
{
"refName": "refs/heads/d14rel",
"matchKind": "Exact",
"repositoryId": "a290117c-5a8a-40f7-bc2c-f14dbe3acf6d"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
假设$json是一个字符串,这个命令:
$json | ConvertFrom-Json | ConvertTo-Json
Run Code Online (Sandbox Code Playgroud)
从中产生错误的JSON:
{
"settings": {
"minimumApproverCount": 2,
"creatorVoteCounts": false,
"scope": [
"@{refName=refs/heads/d14rel; matchKind=Exact; repositoryId=a290117c-5a8a-40f7-bc2c-f14db
e3acf6d}"
]
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,它会使"范围"变量错误.有没有办法来解决这个问题?
我想WaitHandle.WaitOne(TimeSpan)在.NET中调用,但我在STA线程上,它在等待时抽取消息.由于超出此问题范围的原因,我需要等待而不需要抽水.如何在不抽取消息的情况下等待WaitHandle发出信号?
在某些情况下WaitHandle.WaitOne似乎不会消息.但它有时会发生一些消息.有关详细信息,请参阅以下链接:
我已成功创建了一个启动活动的本地通知,但由于某种原因,当从远程通知的处理程序中创建此本地通知时,当用户点击本地通知时,活动不会启动.似乎没有抛出任何错误或异常.
以下是创建本地通知的代码.注意我正在使用Xamarin.我想知道它是否可能以某种方式与权限相关(远程通知处理程序可能无法创建意图来启动活动?).
private void CreateNotification(string title, string desc) {
var uiIntent = new Intent(this, typeof(ConversationActivity));
var stackBuilder = TaskStackBuilder.Create(this);
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(ConversationActivity)));
stackBuilder.AddNextIntent(uiIntent);
PendingIntent pendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
var notification = new NotificationCompat.Builder(this)
.SetAutoCancel(true) // Remove the notification once the user touches it
.SetContentIntent(pendingIntent)
.SetContentTitle(title)
.SetSmallIcon(Resource.Drawable.AppIcon)
.SetContentText(desc)
.SetDefaults((int)(NotificationDefaults.Sound | NotificationDefaults.Vibrate))
;
// Set the notification info
// we use the pending intent, passing our ui intent over which will get called
// when the notification is tapped.
var …Run Code Online (Sandbox Code Playgroud) 我的一些mstest单元测试有助于检测多线程竞争条件,因此它们在连续多次运行时最有用,但我只想在特定的测试运行中执行此操作 - 而不是所有时间.
有没有办法配置mstest(最好在测试列表编辑器中)多次运行测试?
使用DotNetOpenId使ClaimsResponse工作的秘诀是什么?
例如,在这段代码中(来自Scott Hanselman的博客),ClaimsResponse对象应该有很多很好的小东西,比如'nickname'和'email address',但ClaimsResponse对象本身就是'null':
OpenIdRelyingParty openid = new OpenIdRelyingParty();
if (openid.Response != null)
{
// Stage 3: OpenID Provider sending assertion response
switch (openid.Response.Status)
{
case AuthenticationStatus.Authenticated:
ClaimsResponse fetch = openid.Response.GetExtension(typeof(ClaimsResponse)) as ClaimsResponse;
string nick = fetch.Nickname;
string homepage = openid.Response.ClaimedIdentifier;
string email = fetch.Email;
string comment = Session["pendingComment"] as string;
string entryId = Session["pendingEntryId"] as string;
if (String.IsNullOrEmpty(comment) == false && String.IsNullOrEmpty(entryId) == false)
{
AddNewComment(nick, email, homepage, comment, entryId, true);
}
break; …Run Code Online (Sandbox Code Playgroud) 既然DNOA可以进行呼叫家庭报告,我想调查源以查看正确传输到DNOA服务器的内容.
Source Forge上的链接仅为我提供了"应用程序块"的一些示例和一个已编译的DLL.
来源在哪里?我只是俯视它吗?
我的包裹HttpRequestBase作为HttpRequestMessage,这就要求所有的头被复制.但由于HttpRequestMessage特定于哪些头应用于请求对象与Content对象,httpRequest.Headers.Add下面的行有时会抛出InvalidOperationException.
public static HttpRequestMessage AsHttpRequestMessage(this HttpRequestBase request) {
Requires.NotNull(request, "request");
var httpRequest = new HttpRequestMessage(new HttpMethod(request.HttpMethod), request.Url);
foreach (string header in request.Headers) {
httpRequest.Headers.Add(header, request.Headers.GetValues(header));
}
if (request.Form != null) {
// Avoid a request message that will try to read the request stream twice for already parsed data.
httpRequest.Content = new FormUrlEncodedContent(request.Form.AsKeyValuePairs());
} else if (request.InputStream != null) {
httpRequest.Content = new StreamContent(request.InputStream);
}
return httpRequest;
}
Run Code Online (Sandbox Code Playgroud)
显然,我希望我的代码不会抛出异常,而是将每个标头适当地应用于适当的对象.我怎么预测呢?我是否可以使用任何方法来测试标题的适用性,而不是生成和捕获异常的标题?
我工作的公司想要向外界发布内部网站,但也希望以一种简单的方式识别访问者.某些功能对所有访问者都可见,但大多数访问者必须可见.(并且一些功能仅限于管理员访问者.)虽然管理层正在考虑实施我们自己的身份验证系统,但我建议只使用已有的现有技术,并使用户名/密码的管理远离我们.(因为当我们讨论安全问题时,我们只是业余爱好者.身份验证需要非常好.)
所以我从Google 开始使用OpenID并检查了他们提供的库.看起来很容易使用,我可以获得告诉我用户已通过身份验证的令牌.但是,如何识别此用户,以便将我们的个人资料信息链接到他的ID /令牌/随便?
我知道我错过了一些东西,所以要保持简单:我只需要一些示例,说明如何使用Google验证访问者,然后获取一些可以用来永久链接到此用户的令牌.(因此,没有会话令牌.)然后,此令牌可用于用户填写他/她的个人资料.
当我的Razor视图调用时,@Html.OpenIdSelector(...我得到一个InvalidOperationException:
当前的IHttpHandler不是以下类型之一:System.Web.UI.Page,DotNetOpenAuth.IEmbeddedResourceRetrieval.必须在.config文件中设置嵌入式资源URL提供程序.
我应该在config文件中设置什么?
我一直在尝试使用ASP.Net MVC 4 Developer Preview的DotNetOpenAuth示例.
我可以从我的测试页面成功调用我的Action,但由于一行代码而遇到了一个奇怪的问题:
var request = _openid.CreateRequest(openIdUrl);
var fetch = new FetchRequest();
fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
request.AddExtension(fetch);
//return RedirectToAction("Login");
return request.RedirectingResponse.AsActionResult(); // <-- This is the line throwing the error
Run Code Online (Sandbox Code Playgroud)
如果我注释掉有问题的代码行并在此之前取消注释,我再也看不到运行时错误了.
到目前为止,我尝试过:
1)确保我有正确的重定向:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
</dependentAssembly>
</assemblyBinding>
<legacyHMACWarning enabled="0" />
</runtime>
Run Code Online (Sandbox Code Playgroud)
2)拥有正确的命名空间:
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; …Run Code Online (Sandbox Code Playgroud) .net ×4
asp.net ×3
c# ×3
openid ×3
android ×1
asp.net-mvc ×1
com ×1
httpclient ×1
json ×1
mstest ×1
oauth ×1
powershell ×1
razor ×1
security ×1
xamarin ×1