小编Anu*_*bis的帖子

更改XML序列化的XmlElement名称

我们有以下代码:

[Serializable]
public class Class1
{
    [XmlElement("description")]
    public string Description { get; set; }
}
class Program
{
    static void Main(string[] args)
    {
        var list = new List<Class1> {new Class1() {Description = "Desc1"}, new Class1() {Description = "Desc2"}};
        var serializer = new XmlSerializer(typeof(List<Class1>), new XmlRootAttribute("root"));
        var ms = new MemoryStream();
        serializer.Serialize(ms, list);
        ms.Position = 0;
        var result = new StreamReader(ms).ReadToEnd();
    }
}
Run Code Online (Sandbox Code Playgroud)

执行后,我们将在'result'变量中包含以下内容:

<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Class1>
    <description>Desc1</description>
  </Class1>
  <Class1>
    <description>Desc2</description>
  </Class1>
</root>
Run Code Online (Sandbox Code Playgroud)

问题是:如何在不更改类名的情况下将xml元素名称从"Class1"更改为"Item1"?

.net c# xml serialization

13
推荐指数
2
解决办法
2万
查看次数

Google Drive API身份验证

我想创建一个可以随时访问我自己的Google云端硬盘的应用程序,在那里创建文件,共享它们等等.根据https://developers.google.com/drive/service-accounts "使用常规Google帐户作为应用程序拥有的帐户"我认为我需要的唯一一步是获取access_token和refresh_token一次,将它们存储在我的应用程序中并使用refresh_token I可以刷新我的access_token(不知何故).

我可以使用https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive.file&redirect_uri=http://localhost;response_type=等请求获取access_token 令牌CLIENT_ID =

在用户对话框中批准此应用程序请求后,我将被重定向到我的localhost,我将获得在3600秒内到期的access_token.

问题是:

1.如何获得refresh_token?
2.如何使用refresh_token刷新access_token?

我不想使用Google的API客户端库,因为它很糟糕(.NET).

google-drive-api google-api-dotnet-client

12
推荐指数
1
解决办法
9226
查看次数

在Android SDK Manager中找不到支持包

我需要Support Package jar文件.我打开页面http://developer.android.com/sdk/compatibility-library.html#Downloading并按照他们的说法做:

  1. 启动SDK和AVD Manager.
  2. 在Eclipse中,您可以选择Window> Android SDK和AVD Manager.或者,从/目录(仅限Windows)或/ tools /目录中的android启动SDK Manager.exe.
  3. 展开Android Repository,检查Android Support包,然后单击Install selected.

但是我的SDK管理器已经更新,并且没有"Android Repository"了,我找不到Android支持包. 在此输入图像描述

请给我任何建议.

android

4
推荐指数
1
解决办法
5038
查看次数

NHibernate QueryOver在很多表上

有一个实体Effort有一个属性List和一个属性AdType 我们有几个adTypes枚举对象和specialLists枚举对象来选择IList<Effort>

我是这样做的:

    return NHibernateSession.QueryOver<Effort>()
        .JoinQueryOver(effort => effort.AdType)
                .WhereRestrictionOn(adType => adType.Id)
                .IsIn(adTypes.Select(adt => (long)adt).ToList())
            .Clone()
            .JoinQueryOver(effort => effort.List)
                .WhereRestrictionOn(list => list.Id)
                .IsIn(specialLists.Select(sl => (long)sl).ToList())
            .List<Effort>();
Run Code Online (Sandbox Code Playgroud)

你可以看到我使用了一个没有任何描述的奇怪的Clone()方法.它很棒.

您以何种方式使用QueryOver进行此类查询?

nhibernate queryover

2
推荐指数
1
解决办法
3721
查看次数