Esempio n. 1
0
        public DeviceInformations(Hashtable settings)
        {
            // Remember
            Settings = settings;

            // Attach to the current application
            FileInfo exe = new FileInfo(Application.ExecutablePath);

            // Get the root
            string root = exe.DirectoryName;

            // Check for override
            if (Settings.ContainsKey(PathKey))
            {
                // Merge
                root = Path.Combine(root, (string)Settings[PathKey]);

                // Remove
                Settings.Remove(PathKey);
            }

            // Attach to the provider configuration file
            FileInfo path = new FileInfo(Path.Combine(root, "DVBNetProviders.xml"));

            // Process
            if (path.Exists)
            {
                // Load the DOM from file
                m_File.Load(path.FullName);
            }
            else
            {
                // Me
                Type me = GetType();

                // Load the DOM from resource
                using (Stream providers = me.Assembly.GetManifestResourceStream(me.Namespace + ".DVBNETProviders.xml"))
                {
                    // Load
                    m_File.Load(providers);
                }
            }

            // Verify
            if (!m_File.DocumentElement.Name.Equals("DVBNETProviders")) throw new ArgumentException("bad provider definition", "file");
            if (!Equals(m_File.DocumentElement.GetAttribute("SchemaVersion"), "2.6")) throw new ArgumentException("invalid schema version", "file");

            // All providers
            foreach (XmlElement provider in m_File.DocumentElement.SelectNodes("DVBNETProvider"))
            {
                // Create new
                DeviceInformation info = new DeviceInformation(provider);

                // Register
                m_Devices[info.UniqueIdentifier] = info;
            }
        }
Esempio n. 2
0
 public IDeviceProvider Create(DeviceInformation provider)
 {
     // Forward
     return provider.Create(Settings);
 }
Esempio n. 3
0
        public IDeviceProvider Create(DeviceInformation provider, Hashtable parameterOverwrites)
        {
            // Clone hashtable
            Hashtable settings = new Hashtable(Settings);

            // Merge
            foreach (DictionaryEntry parameter in parameterOverwrites)
            {
                // Merge in
                settings[parameter.Key] = parameter.Value;
            }

            // Forward
            return provider.Create(settings);
        }
Esempio n. 4
0
        public void ChangeActive(DeviceInformation device)
        {
            // No change at all
            if (device == ActiveProvider) return;

            // Attach to registry
            using (RegistryKey key = Tools.GetConfiguration(true))
            {
                // Not found
                if (null == key) return;

                // Check
                if (null == device)
                {
                    // Store
                    key.SetValue("ProviderName", string.Empty);
                }
                else
                {
                    // Store
                    key.SetValue("ProviderName", device.UniqueIdentifier);
                }
            }
        }