本文整理汇总了C#中Provider.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Provider.Set方法的具体用法?C# Provider.Set怎么用?C# Provider.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Provider
的用法示例。
在下文中一共展示了Provider.Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadDevice
/// <summary>
/// Processes the XML element containing the device attributes.
/// </summary>
/// <param name="provider">A list of loaded devices.</param>
/// <param name="reader">The XML stream readers.</param>
/// <returns>An empty device.</returns>
private static BaseDeviceInfo LoadDevice(Provider provider, XmlReader reader)
{
// Create the next device using the fallback device if available.
string deviceId = reader.GetAttribute(Constants.IdAttributeName, string.Empty);
string userAgent = reader.GetAttribute(Constants.UserAgentAttributeName, string.Empty);
string fallbackDeviceId = reader.GetAttribute(Constants.ParentAttributeName, string.Empty);
// If the device already exists then use the previous one. This may happen
// when an earlier device referenced a fallback device that had not yet
// been created.
var device = provider.GetDeviceInfoFromID(deviceId);
if (device == null)
{
// Create the new device.
device = new BaseDeviceInfo(provider, deviceId, userAgent ?? String.Empty);
}
else if (userAgent != null)
{
// Ensure the correct UserAgent string is assigned to this device.
device.InternalUserAgent = userAgent;
provider.Set(device);
}
// Check the fallback device is different to the device being loaded.
if (fallbackDeviceId != null && device.DeviceId != fallbackDeviceId)
{
// Does the fallback device already exist?
device.Parent = provider.GetDeviceInfoFromID(fallbackDeviceId);
if (device.Parent == null)
{
// No. So create new fallback device.
device.Parent = new BaseDeviceInfo(provider, fallbackDeviceId);
// Add it to the available devices.
provider.Set(device.Parent);
}
}
return device;
}
示例2: ProcessDevices
/// <summary>
/// Uses the xml reader to load data into the provider.
/// </summary>
/// <param name="availableCapabilities">List of capabilities that are available.</param>
/// <param name="provider">Provider to have data loaded into.</param>
/// <param name="reader">XmlReader for the source data stream.</param>
private static void ProcessDevices(StringCollection availableCapabilities, Provider provider, XmlReader reader)
{
BaseDeviceInfo device = null;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case Constants.ProfileElementName:
// Load Device Data
if (reader.IsStartElement())
{
// If a device has already been created ensure it's saved.
if (device != null)
provider.Set(device);
// Create or get the device related to the current XML element.
device = LoadDevice(provider, reader);
}
break;
case Constants.PropertyElementName:
// Load the device capability.
if (reader.IsStartElement())
{
LoadCapabilityData(
reader,
device,
availableCapabilities);
}
break;
}
}
}
// If a device has not been written ensure it's added to the device dataset.
if (device != null)
provider.Set(device);
}