SPUserResource.Value 属性
获取或设置的资源的线程的区域性的值。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Property Value As String
Get
Set
用法
Dim instance As SPUserResource
Dim value As String
value = instance.Value
instance.Value = value
public string Value { get; set; }
属性值
类型:System.String
一个字符串,包含当前线程CurrentUICulture属性的值。如果尚未为该区域性解释资源或网站不支持该区域性,使用网站的默认区域性的值。
示例
下面的示例是一个控制台应用程序演示如何根据当前线程的区域性更改Value属性的值。应用程序枚举网站支持的区域性的列表、 将线程的CurrentUICulture设置为每个受支持的企业文化,并将打印语言中的线程的CurrentUICulture通知列表的标题的用户资源的值。
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)
{
SPUserResource resource = list.TitleResource;
foreach (CultureInfo culture in web.SupportedUICultures)
{
Thread.CurrentThread.CurrentUICulture = culture;
Console.WriteLine("{0}: {1}", culture.Name, resource.Value);
}
}
}
}
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 resource As SPUserResource = list.TitleResource
For Each culture As CultureInfo In web.SupportedUICultures
Thread.CurrentThread.CurrentUICulture = culture
Console.WriteLine("{0}: {1}", culture.Name, resource.Value)
Next
End If
End Using
End Using
Console.Write(vbCrLf & "Press ENTER to continue....")
Console.Read()
End Sub
End Module