小编Ale*_*yov的帖子

使用Json.NET从Dictionary <string,T>派生类型T的序列化和反序列化

我创建了一个示例项目.我正在序列化以下类型:

[JsonObject(IsReference = true, ItemReferenceLoopHandling = ReferenceLoopHandling.Serialize)]
public class SampleTree : Dictionary<string, SampleTree>
{
    [JsonProperty(ReferenceLoopHandling = ReferenceLoopHandling.Serialize)]
    public SampleClass Value { get; set; }

    [JsonProperty(IsReference = true, ReferenceLoopHandling = ReferenceLoopHandling.Serialize)]
    public SampleTree Parent { get; set; }
}

[JsonObject(IsReference = true)]
public class SampleClass
{
    public string A { get; set; }

    public int B { get; set; }

    public bool C { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

程序代码(简化控制台应用程序):

static void Main(string[] args)
{
    var tree = new SampleTree
    {
        Value …
Run Code Online (Sandbox Code Playgroud)

c# dictionary json.net

7
推荐指数
1
解决办法
594
查看次数

删除以前从"与我共享"添加到"我的云端硬盘"中的文件

Google云端硬盘具有很酷的功能:可以将"与我共享"中的文件或文件夹添加到"我的云端硬盘".

在此输入图像描述

然后我可以以相同的方式从我的驱动器中删除此文件(请注意,如果我删除网络版中的共享文件,它将不会转到垃圾箱)

在此输入图像描述

但是,我在尝试使用Google Drive API删除此文件时收到403 Forbidden错误(由于我不是此文件的所有者,因为权限不足).因此,正如人们所看到的,这不是一个简单的删除请求.我该如何实现此功能?

google-drive-api

7
推荐指数
1
解决办法
1万
查看次数

如何以编程方式单击ApplicationBarIconButton?

这就是问题所在.我的测试框架中有以下代码变体(假设appBarButton是ApplicationBarIconButton):

var bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic;
var method = typeof(ApplicationBarIconButton)
             .GetMethod("ClickEvent", bindingFlags);

if (method != null)
{
    method.Invoke(appBarButton, null);
}
Run Code Online (Sandbox Code Playgroud)

要么

IInvokeProvider invokableButton;
var isInvokable = (invokableButton = appBarButton as IInvokeProvider) != null;
if (isInvokable)
{
    invokableButton.Invoke();
}
Run Code Online (Sandbox Code Playgroud)

两件都不起作用.所以我想找到一些以编程方式单击ApplicationBarIconButton的变通方法.有帮助吗?

c# appbar windows-phone windows-phone-8

6
推荐指数
1
解决办法
450
查看次数