using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Info;
namespace MicroBlogForWP7.Classes.Util
{
public class UserDeviceInfo
{
/// <summary>
/// 获取用户唯一标识
/// </summary>
/// <returns></returns>
public static string GetUserID()
{
object anid = new object();
string anonymousUserId = "";
if (UserExtendedProperties.TryGetValue("ANID", out anid))
{
if (null == anid)
{
return string.Empty;
}
anonymousUserId = anid as string;
anonymousUserId = anonymousUserId.Substring(2, 32);
}
return anonymousUserId;
}
/// <summary>
/// 获取设备唯一标识
/// </summary>
/// <returns></returns>
public static string GetDeviceUniqueId()
{
byte[] byteArray = DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[];
string strTemp = "";
string strDeviceUniqueID = "";
foreach (byte b in byteArray)
{
strTemp = b.ToString();
if (1 == strTemp.Length)
{
strTemp = "00" + strTemp;
}
else if (2 == strTemp.Length)
{
strTemp = "0" + strTemp;
}
strDeviceUniqueID += strTemp;
}
return strDeviceUniqueID;
}
/// <summary>
/// 获取设备生产厂商
/// </summary>
/// <returns></returns>
public static string GetDeviceManufacturer()
{
string strDeviceManufacturer = DeviceExtendedProperties.GetValue("DeviceManufacturer").ToString();
return strDeviceManufacturer;
}
/// <summary>
/// 获取当前应用程序使用的内存大小(单位是Byte)
/// </summary>
/// <returns></returns>
public static string GetApplicationCurrentMemoryUsage()
{
string strDeviceManufacturer = DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage").ToString();
return strDeviceManufacturer;
}
/// <summary>
/// 获取设备名称
/// </summary>
/// <returns></returns>
public static string GetDeviceName()
{
string strDeviceName = DeviceExtendedProperties.GetValue("DeviceName").ToString();
return strDeviceName;
}
/// <summary>
/// 获取设备固件版本
/// </summary>
/// <returns></returns>
public static string GetDeviceFirmwareVersion()
{
string strDeviceFirmwareVersion = DeviceExtendedProperties.GetValue("DeviceFirmwareVersion").ToString();
return strDeviceFirmwareVersion;
}
/// <summary>
/// 获取设备硬件版本
/// </summary>
/// <returns></returns>
public static string GetDeviceHardwareVersion()
{
string strDeviceHardwareVersion = DeviceExtendedProperties.GetValue("DeviceHardwareVersion").ToString();
return strDeviceHardwareVersion;
}
/// <summary>
/// 获取设备内存大小(单位是Byte)
/// </summary>
/// <returns></returns>
public static string GetDeviceTotalMemory()
{
string strDeviceTotalMemory = DeviceExtendedProperties.GetValue("DeviceTotalMemory").ToString();
return strDeviceTotalMemory;
}
/// <summary>
/// 获取应用程序峰值内存大小(单位是Byte)
/// </summary>
/// <returns></returns>
public static string GetApplicationPeakMemoryUsage()
{
string strApplicationPeakMemoryUsage = DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage").ToString();
return strApplicationPeakMemoryUsage;
}
}
}