我创建了一个示例项目.我正在序列化以下类型:
[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) Google云端硬盘具有很酷的功能:可以将"与我共享"中的文件或文件夹添加到"我的云端硬盘".

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

但是,我在尝试使用Google Drive API删除此文件时收到403 Forbidden错误(由于我不是此文件的所有者,因为权限不足).因此,正如人们所看到的,这不是一个简单的删除请求.我该如何实现此功能?
这就是问题所在.我的测试框架中有以下代码变体(假设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的变通方法.有帮助吗?