开发者

How can I find regional translations of built-in SharePoint list names?

There are PublishingWeb.PagesList and PublishingWeb.PagesListName properties, but other list's urls also vary by site language. Those that I found are translated are:

  • Documents
  • Images
  • Pages
  • Workflow Tasks

There is addi开发者_如何学运维tional API in SP2010, but how can I handle this in 2007?


This data is available with internal methods. So I have an invoke helper method:

[NotNull]
public static T Call<T>([CanBeNull] ref T cachedInvoker, [NotNull] Type subject, [NotNull] string methodName) where T : class
{
    if (cachedInvoker == null)
    {
        var method = subject.GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
        cachedInvoker = Delegate.CreateDelegate(typeof(T), method) as T;
        if (cachedInvoker == null)
            throw new ApplicationException(string.Format("Unable to create invoker for [{0}].[{1}].", subject, methodName));
    }
    return cachedInvoker;
}

And then I get the data:

[NotNull]
public static SPFolder Documents([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetDocumentsListId()].RootFolder;
}

[NotNull]
public static string GetDocumentsListName([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetDocumentsListId()].Title;
}

private static Func<PublishingWeb, Guid> getDocumentsListIdInvoker;

[NotNull]
public static Guid GetDocumentsListId([NotNull] this PublishingWeb web)
{
    return
        Internal.Call(ref getDocumentsListIdInvoker, typeof (PublishingWeb), 
            "get_DocumentsListId")(web);
}

[NotNull]
public static string GetImagesListName([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetImagesListId()].Title;
}

private static Func<PublishingWeb, Guid> getImagesListIdInvoker;

[NotNull]
public static Guid GetImagesListId([NotNull] this PublishingWeb web)
{
    return
        Internal.Call(ref getImagesListIdInvoker, typeof(PublishingWeb), 
        "get_ImagesListId")(web);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜