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);
}