SPList.TitleResource 属性
获取一个SPUserResource对象,表示列表的标题的翻译。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property TitleResource As SPUserResource
Get
用法
Dim instance As SPList
Dim value As SPUserResource
value = instance.TitleResource
public SPUserResource TitleResource { get; }
属性值
类型:Microsoft.SharePoint.SPUserResource
一个封装用户定义的本地化资源的对象。
备注
此属性是由Title属性,返回TitleResource.Value返回的字符串的源。由该表达式返回的值取决于当前线程CurrentUICulture的值。有关详细信息,请参阅SPUserResource.Value属性。
示例
下面的示例是一个控制台应用程序演示如何相关的TitleResource属性和Title属性,以及如何根据当前线程的区域性更改其值。应用程序枚举网站支持的区域性的列表,并将当前线程的Thread.CurrentUICulture属性设置为每个受支持的区域性。然后,应用程序打印TitleResource属性和通知列表中的线程的CurrentUICulture语言的Title属性的值。
using System;
using System.Globalization;
using System.Threading;
using Microsoft.SharePoint;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists.TryGetList("Announcements");
if (list != null)
{
string formatString = "{0, -20} {1, -20} {2}";
Console.WriteLine(formatString, "CurrentUICulture", "TitleResource", "Title");
SPUserResource resource = list.TitleResource;
foreach (CultureInfo culture in web.SupportedUICultures)
{
Thread.CurrentThread.CurrentUICulture = culture;
Console.WriteLine(formatString, culture.Name, resource.Value, list.Title);
}
}
}
}
Console.Write("\nPress ENTER to continue....");
Console.Read();
}
}
}
Imports System
Imports System.Globalization
Imports System.Threading
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
Dim list As SPList = web.Lists.TryGetList("Announcements")
If list IsNot Nothing Then
Dim formatString As String = "{0, -20} {1, -20} {2}"
Console.WriteLine(formatString, "CurrentUICulture", "TitleResource", "Title")
Dim resource As SPUserResource = list.TitleResource
For Each culture As CultureInfo In web.SupportedUICultures
Thread.CurrentThread.CurrentUICulture = culture
Console.WriteLine(formatString, culture.Name, resource.Value, list.Title)
Next
End If
End Using
End Using
Console.Write(vbCrLf & "Press ENTER to continue....")
Console.Read()
End Sub
End Module