当前位置: 首页>>代码示例>>C#>>正文


C# Provider.GetDeviceInfoFromID方法代码示例

本文整理汇总了C#中Provider.GetDeviceInfoFromID方法的典型用法代码示例。如果您正苦于以下问题:C# Provider.GetDeviceInfoFromID方法的具体用法?C# Provider.GetDeviceInfoFromID怎么用?C# Provider.GetDeviceInfoFromID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Provider的用法示例。


在下文中一共展示了Provider.GetDeviceInfoFromID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
开发者ID:davelondon,项目名称:dontstayin,代码行数:44,代码来源:Reader.cs


注:本文中的Provider.GetDeviceInfoFromID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。