DatastoreManager 类
更新:2007 年 11 月
访问数据存储中的信息,并提供方法来枚举和获取台式计算机数据存储中的 Platform 对象。
命名空间: Microsoft.SmartDevice.Connectivity
程序集: Microsoft.SmartDevice.Connectivity(在 Microsoft.SmartDevice.Connectivity.dll 中)
语法
声明
Public Class DatastoreManager
用法
Dim instance As DatastoreManager
public class DatastoreManager
public ref class DatastoreManager
public class DatastoreManager
备注
它始终是此命名空间中使用的第一个类。
数据存储包含有关在台式计算机上注册的平台和设备的信息。有关数据存储的更多信息,请参见通过智能设备连接 API 控制设备。
示例
Imports System
Imports System.Collections.ObjectModel
Imports Microsoft.SmartDevice.Connectivity
Class Example
Shared Sub Main(ByVal args() As String)
' Get datastore object
Dim dsmgr As New DatastoreManager(1033)
' Get the platforms in the Datastore
Dim platforms As Collection(Of Platform) = dsmgr.GetPlatforms()
' For each platform, output name and ID
Console.WriteLine("Get all platforms with the GetPlatforms method: " + vbCr + vbLf)
Dim platform As Platform
For Each platform In platforms
Console.WriteLine("Platform Name: " + platform.Name + " ID: " + _
platform.Id.ToString())
Next platform
' Get the Windows Mobile 5.0 Smartphone platform
Dim wm5sp As New ObjectId(New Guid("BD0CC567-F6FD-4ca3-99D2-063EFDFC0A39"))
Dim p As Platform = dsmgr.GetPlatform(wm5sp)
' Output information
Console.WriteLine(vbCr + vbLf + vbCr + vbLf + _
"Get the WM5 Smartphone platform using the GetPlatform method: " + _
vbCr + vbLf)
Console.WriteLine("Platform Name: " + p.Name + " ID: " + p.Id.ToString())
Console.ReadLine()
End Sub 'Main
End Class 'Example
using System;
using System.Collections.ObjectModel;
using Microsoft.SmartDevice.Connectivity;
class Example
{
static void Main(string[] args)
{
// Get datastore object
DatastoreManager dsmgr = new DatastoreManager(1033);
// Get the platforms in the Datastore
Collection<Platform> platforms = dsmgr.GetPlatforms();
// For each platform, output name and ID
Console.WriteLine("Get all platforms with the GetPlatforms method: \r\n");
foreach (Platform platform in platforms)
{
Console.WriteLine("Platform Name: " + platform.Name + " ID: " + platform.Id);
}
// Get the Windows Mobile 5.0 Smartphone platform
ObjectId wm5sp = new ObjectId(new Guid("BD0CC567-F6FD-4ca3-99D2-063EFDFC0A39"));
Platform p = dsmgr.GetPlatform(wm5sp);
// Output information
Console.WriteLine("\r\n\r\nGet the WM5 Smartphone platform using the GetPlatform method: \r\n");
Console.WriteLine("Platform Name: " + p.Name + " ID: " + p.Id);
Console.ReadLine();
}
}
继承层次结构
System.Object
Microsoft.SmartDevice.Connectivity.DatastoreManager
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。