A provider with methods designed to be called from within web applications where HttpRequest objects can be used to provide the necessary evidence for detection.
Inheritance: Provider, IDisposable
 /// <summary>
 /// The application is being disposed of either due to a recycle event or 
 /// shutdown. Ensure the active provider is disposed of to release resources.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void OnProcessExit(object sender, EventArgs e)
 {
     try
     {
         var provider = _activeProvider;
         if (provider != null)
         {
             provider.Dispose();
         }
     }
     finally
     {
         _activeProvider = null;
         _activeProviderCreated = false;
     }
 }
        /// <summary>
        /// Forces the provider to update current ActiveProvider with new data.
        /// </summary>
        private static WebProvider Create()
        {
            WebProvider provider = null;
            CleanTemporaryFiles();
            try
            {
                // Does a binary file exist?
                if (Manager.BinaryFilePath != null)
                {
                    // Log API version for diagnosis.
                    var assembly = Assembly.GetExecutingAssembly().GetName();
                    EventLog.Info(String.Format(
                        "Creating data set from '{0}' version '{1}'",
                        assembly.Name,
                        assembly.Version));

                    if (File.Exists(Manager.BinaryFilePath))
                    {
                        if (Manager.MemoryMode)
                        {
                            EventLog.Info(String.Format(
                                "Creating memory byte array dataset and provider from binary data file '{0}'.",
                                Manager.BinaryFilePath));
                            provider = new WebProvider(StreamFactory.Create(File.ReadAllBytes(Manager.BinaryFilePath)));
                        }
                        else
                        {
                            provider = new WebProvider(GetTempFileDataSet());
                        }
                        EventLog.Info(String.Format(
                            "Created provider from version '{0}' format '{1}' data published on '{2:u}' in master file '{3}'.",
                            provider.DataSet.Version,
                            provider.DataSet.Name,
                            provider.DataSet.Published,
                            Manager.BinaryFilePath));
                    }
                    else
                    {
                        EventLog.Info("Data file at '{0}' could not be found. Either it does not exist or " +
                            "there is insufficient permission to read it. Check the AppPool has read permissions " +
                            "and the application is not running in medium trust if the data file is not in the " +
                            "application directory.", Manager.BinaryFilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                // Record the exception in the log file.
                EventLog.Fatal(
                    new MobileException(String.Format(
                        "Exception processing device data from binary file '{0}'. " +
                        "Enable debug level logging and try again to help identify cause.",
                        Manager.BinaryFilePath),
                        ex));
            }

            // Does the provider exist and has data been loaded?
            if (provider == null || provider.DataSet == null)
            {
                EventLog.Fatal("No data source available to create provider.");
            }

            return provider;
        }
 /// <summary>
 /// Forces the application to reload the active provider on the next
 /// request.
 /// </summary>
 public static void Refresh()
 {
     var provider = _activeProvider;
     _activeProvider = null;
     _activeProviderCreated = false;
     if (provider != null)
     {
         // Dispose of the old provider.
         provider.Dispose();
     }
 }
        /// <summary>
        /// A reference to the active provider.
        /// </summary>
        internal static WebProvider GetActiveProvider()
        {
            if (_activeProviderCreated == false)
            {
                lock (_lock)
                {
                    if (_activeProviderCreated == false)
                    {
                        _activeProvider = Create();

                        // The DetectorModule should set to listen for the
                        // application reycling or shutting down. This is belt
                        // and braces in case thte HttpModule method fails to
                        // fire the application end event.
                        AppDomain.CurrentDomain.ProcessExit += OnProcessExit;

                        _activeProviderCreated = true;
                    }
                }
            }
            return _activeProvider;
        }
 /// <summary>
 /// Writes information about the data set being used by the provider.
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="provider"></param>
 private static void WriteProvider(XmlWriter writer, WebProvider provider)
 {
     if (provider != null)
     {
         writer.WriteStartElement("DataSet");
         writer.WriteElementString("Version", provider.DataSet.Version.ToString());
         writer.WriteElementString("Name", provider.DataSet.Name);
         writer.WriteEndElement();
     }
 }