BluetoothFactorySection.cs :  » Business-Application » 32feet.NET » InTheHand » Net » Bluetooth » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Business Application » 32feet.NET 
32feet.NET » InTheHand » Net » Bluetooth » BluetoothFactorySection.cs
// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Bluetooth.BluetoothFactorySection
// 
// Copyright (c) 2003-2010 In The Hand Ltd, All rights reserved.
// This source code is licensed under the In The Hand Community License - see License.txt

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace InTheHand.Net.Bluetooth{
    class BluetoothFactorySection : ConfigurationSection
    {
        internal const string GlobalSectionGroupName = "InTheHand.Net.Personal/";
        internal const string SectionName = "BluetoothFactory";

        //--------
        static BluetoothFactorySection s_instance;

        internal static BluetoothFactorySection Instance
        {
            get
            {
                if (s_instance == null) {
                    object s0 = ConfigurationManager.GetSection(GlobalSectionGroupName + SectionName);
                    s_instance = (BluetoothFactorySection)s0;
                    //Console.WriteLine(s_instance);
                    if (s_instance == null) {
                        s_instance = new BluetoothFactorySection();
                    }
                }
                return s_instance;
            }
        }

        private BluetoothFactorySection()
        {
        }

        //--------
        public override string ToString()
        {
            BluetoothStackConfigElement[] arr = new BluetoothStackConfigElement[StackList.Count];
            StackList.CopyTo(arr, 0);
            string slConcat = "{" + string.Join(", ", Array.ConvertAll<BluetoothStackConfigElement, string>(arr,
                delegate(BluetoothStackConfigElement inp) { return (inp == null) ? "(null)" : inp.Name; })) + "}";
            //
            return string.Format(System.Globalization.CultureInfo.InvariantCulture,
                "[BluetoothFactorySection: OneStackOnly: {0}, ReportAllErrors: {1}, StackList: {2}, FooBar1: {3}]",
                this.OneStackOnly, this.ReportAllErrors, slConcat, this.FooBar1);
        }

        //--------
        [ConfigurationProperty("reportAllErrors", DefaultValue = BluetoothFactoryConfig.Default_reportAllErrors)]
        [ApplicationScopedSettingAttribute]
        public bool ReportAllErrors
        {
            get { return (bool)this["reportAllErrors"]; }
        }

        [ConfigurationProperty("oneStackOnly", DefaultValue = BluetoothFactoryConfig.Default_oneStackOnly)]
        [ApplicationScopedSettingAttribute]
        public bool OneStackOnly
        {
            get { return (bool)this["oneStackOnly"]; }
        }

        [ConfigurationProperty("firstStack", DefaultValue = "defaultValue2")]
        [ApplicationScopedSetting]
        public string FooBar1
        {
            get { return (string)this["firstStack"]; }
        }

        [ConfigurationProperty("widcommICheckIgnorePlatform", DefaultValue = false)]
        [ApplicationScopedSettingAttribute]
        public bool WidcommICheckIgnorePlatform
        {
            get { return (bool)this["widcommICheckIgnorePlatform"]; }
        }

        [ConfigurationProperty("stackList")]
        [ApplicationScopedSetting]
        public BluetoothStackCollection StackList
        {
            get { return (BluetoothStackCollection)this["stackList"]; }
        }

        public string[] StackList2
        {
            get
            {
                List<string> ls = new List<string>();
                foreach (BluetoothStackConfigElement cur in StackList) {
                    ls.Add(cur.Name);
                }//for
                return ls.ToArray();
            }
        }
    }


    class BluetoothStackConfigElement : ConfigurationElement
    {
        internal BluetoothStackConfigElement()
        {
        }

        internal BluetoothStackConfigElement(string name)
        {
            this["name"] = name;
        }

        [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
        [ApplicationScopedSetting]
        public string Name
        {
            get
            {
                string name = (string)this["name"];
                if (name.ToUpperInvariant() == "WIDCOMM")
                    name = BluetoothFactoryConfig.WidcommFactoryType.FullName;
                else if (name.ToUpperInvariant() == "MSFT")
                    name = BluetoothFactoryConfig.MsftFactoryType.FullName;
                return name;
            }
        }
    }


    [ConfigurationCollection(typeof(BluetoothStackConfigElement))]
    class BluetoothStackCollection : ConfigurationElementCollection
    {
        private BluetoothStackCollection()
        {
            // Is the right place to do this??
            // Add the default set.
            foreach (string cur in BluetoothFactoryConfig.s_knownStacks) {
                BaseAdd(new BluetoothStackConfigElement(cur));
            }
        }

        //--
        protected override ConfigurationElement CreateNewElement()
        {
            return new BluetoothStackConfigElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            BluetoothStackConfigElement e2 = (BluetoothStackConfigElement)element;
            return e2.Name;
        }
    }

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.