ClassOfDevice.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 » ClassOfDevice.cs
// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Bluetooth.ClassOfDevice
// 
// Copyright (c) 2003-2006 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 InTheHand.Net.Bluetooth;

namespace InTheHand.Net.Bluetooth{
    /// <summary>
    /// Describes the device and service capabilities of a device.
    /// </summary>
    /// -
    /// <remarks>
    /// <para>Is returned by the properties
    /// <see cref="P:InTheHand.Net.Sockets.BluetoothDeviceInfo.ClassOfDevice">BluetoothDeviceInfo.ClassOfDevice</see>
    /// and
    /// <see cref="P:InTheHand.Net.Bluetooth.BluetoothRadio.ClassOfDevice">BluetoothRadio.ClassOfDevice</see>.
    /// </para>
    /// </remarks>
#if !NETCF
    [Serializable]
#endif
    public class ClassOfDevice
#if !V1
        : IEquatable<ClassOfDevice>
#endif
    {
        private uint cod;

        /// <summary>
        /// Initialize a new instance of class <see cref="T:ClassOfDevice"/>.
        /// </summary>
        /// -
        /// <remarks>
        /// <para>An example raw value is 0x00020104, which stands for
        /// device: DesktopComputer, service: Network.
        /// </para>
        /// </remarks>
        /// -
        /// <param name="cod">A <see cref="T:System.UInt32"/> containing the
        /// raw Class of Device value.
        /// </param>
        [CLSCompliant(false)] // Not meant for public use, only for factories.
        public ClassOfDevice(uint cod)
        {
            this.cod = cod;
        }

        /*
        /// <summary>
        /// 
        /// </summary>
        /// <param name="device"></param>
        public ClassOfDevice(DeviceClass device)
        {
            this.cod = (uint)device;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="device"></param>
        /// <param name="service"></param>
        public ClassOfDevice(DeviceClass device, ServiceClass service)
        {
            this.cod = (uint)device | ((uint)service << 13);
        }*/

        //experimental
        /*internal ClassOfDevice(Sockets.IrDAHints hints)
        {
            switch (hints)
            {
                
                case InTheHand.Net.Sockets.IrDAHints.FileServer:
                    cod | ((uint)ServiceClass.Information << 13);
                
                case InTheHand.Net.Sockets.IrDAHints.Obex:
                    cod | ((uint)ServiceClass.ObjectTransfer << 13);

                case InTheHand.Net.Sockets.IrDAHints.PdaAndPalmtop:
                    cod | DeviceClass.PdaComputer;
                    break;
                case InTheHand.Net.Sockets.IrDAHints.Computer:
                    cod | DeviceClass.Computer;
                    break;
                case InTheHand.Net.Sockets.IrDAHints.Printer:
                    cod | DeviceClass.ImagingPrinter;
                    break;
                case InTheHand.Net.Sockets.IrDAHints.Fax:
                case InTheHand.Net.Sockets.IrDAHints.Modem:
                case InTheHand.Net.Sockets.IrDAHints.Telephony:
                    cod | DeviceClass.Phone;
                    break;
                case InTheHand.Net.Sockets.IrDAHints.LanAccess:
                    cod | DeviceClass.AccessPointAvailable;
                    break;
            }
        }*/

        /// <summary>
        /// Returns the device type.
        /// </summary>
        public DeviceClass Device
        {
            get
            {
                return (DeviceClass)(cod & 0x001ffc);
            }
        }

        /// <summary>
        /// Returns the major device type.
        /// </summary>
        public DeviceClass MajorDevice
        {
            get
            {
                return (DeviceClass)(cod & 0x001f00);
            }
        }

        /// <summary>
        /// Returns supported service types.
        /// </summary>
        public ServiceClass Service
        {
            get
            {
                return (ServiceClass)(cod >> 13);
            }
        }

        /// <summary>
        /// Gets the numerical value.
        /// </summary>
        /// <seealso cref="P:InTheHand.Net.Bluetooth.ClassOfDevice.ValueAsInt32"/>
        [CLSCompliant(false)]//use ValueAsInt32
        public uint Value
        {
            get { return cod; }
        }

        /// <summary>
        /// Gets the numerical value, suitable for CLS Compliance.
        /// </summary>
        /// <seealso cref="P:InTheHand.Net.Bluetooth.ClassOfDevice.Value"/>
        public int ValueAsInt32
        {
            get { return unchecked((int)cod); }
        }

        /*
        /// <summary>
        /// 
        /// </summary>
        public byte FormatType
        {
            get
            {
                return (byte)(cod & 0x03);
            }
        }*/

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return Convert.ToInt32(cod);
        }

        /// <summary>
        /// Returns the numerical value represented in a hexadecimal.
        /// </summary>
        public override string ToString()
        {
            return cod.ToString("X");
        }

        /// <summary>
        /// Returns a value indicating whether this instance is equal to a specified 
        /// object.
        /// </summary>
        /// <param name="obj">An object
        /// value to compare with the current instance.
        /// </param>
        /// <returns>true if <paramref name="obj"/> is an instance of <see cref="T:InTheHand.Net.Bluetooth.ClassOfDevice"/>
        /// and equals the value of this instance; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            return Equals(obj as ClassOfDevice);
        }

        /// <summary>
        /// Returns a value indicating whether this instance is equal to a specified 
        /// <see cref="T:InTheHand.Net.Bluetooth.ClassOfDevice"/> value.
        /// </summary>
        /// <param name="other">An <see cref="T:InTheHand.Net.Bluetooth.ClassOfDevice"/>
        /// value to compare with the current instance.
        /// </param>
        /// <returns>true if <paramref name="other"/>
        /// has the same value as this instance; otherwise, false.
        /// </returns>
        public bool Equals(ClassOfDevice other)
        {
            if (other == null)
                return false;
            return this.cod == other.cod;
        }

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