Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aName">Parameter name</param>
        /// <param name="aMinValue">Minimum allowed value</param>
        /// <param name="aMaxValue">Maximum allowed value</param>
        /// <param name="aStep">Gap between allowed values</param>
        public unsafe ParameterUint(String aName, uint aMinValue = 0, uint aMaxValue = uint.MaxValue, uint aStep = 1)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServiceParameterCreateUint(name, aMinValue, aMaxValue, aStep);
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Claim a reference to the network adapter.
        /// </summary>
        /// <remarks>Can only be called from code that can guarantee another reference is already held.
        /// Each call to AddRef() must later have exactly one matching call to RemoveRef().</remarks>
        public void AddRef(string aCookie)
        {
            IntPtr cookie = InteropUtils.StringToHGlobalUtf8(aCookie);

            OhNetNetworkAdapterAddRef(iHandle, cookie);
            AddManagedCookie(aCookie, cookie);
        }
Ejemplo n.º 3
0
        public unsafe ParameterRelated(String aName, OpenHome.Net.Core.Property aProperty)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServiceParameterCreateRelated(name, aProperty.Handle());
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aName">Parameter name</param>
        public unsafe ParameterBinary(String aName)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServiceParameterCreateBinary(name);
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aName">Parameter name</param>
        /// <param name="aMinValue">Minimum allowed value</param>
        /// <param name="aMaxValue">Maximum allowed value</param>
        /// <param name="aStep">Gap between allowed values</param>
        public ParameterInt(String aName, int aMinValue = Int32.MinValue, int aMaxValue = Int32.MaxValue, int aStep = 1)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServiceParameterCreateInt(name, aMinValue, aMaxValue, aStep);
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the full name for a given network interface.
        /// </summary>
        /// <returns>String in the form a.b.c.d (name).</returns>
        public string FullName()
        {
            IntPtr cStr = OhNetNetworkAdapterFullName(iHandle);
            string name = InteropUtils.PtrToStringUtf8(cStr);

            Library.Free(cStr);
            return(name);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the name for a given network interface.
        /// </summary>
        /// <returns>String containing name of the adapter.</returns>
        public string Name()
        {
            IntPtr cStr = OhNetNetworkAdapterName(iHandle);
            string name = InteropUtils.PtrToStringUtf8(cStr);

            // Library.Free(cStr) not necessary because a copy is not allocated by the underlying NetworkAdapter object
            return(name);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Query the name of the action
        /// </summary>
        /// <returns>Action name</returns>
        public unsafe String Name()
        {
            IntPtr str;
            uint   len;

            ServiceActionGetName(iHandle, &str, &len);
            return(InteropUtils.PtrToStringUtf8(str, len));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Set the value of the property
        /// </summary>
        /// <param name="aValue">New value for the property</param>
        /// <returns>True if the property's value was changed; false otherwise</returns>
        public bool SetValue(string aValue)
        {
            IntPtr val     = InteropUtils.StringToHGlobalUtf8(aValue);
            uint   changed = ServicePropertySetValueString(iHandle, val);

            Marshal.FreeHGlobal(val);
            return(changed != 0);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aName">Action name</param>
        public unsafe Action(String aName)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServiceActionCreate(name);
            Marshal.FreeHGlobal(name);
            iInputParameters  = new List <Parameter>();
            iOutputParameters = new List <Parameter>();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor suitable for use by clients of the control point stack
        /// </summary>
        /// <param name="aName">Property name</param>
        /// <param name="aValueChanged">Action to run when the property's value changes</param>
        public unsafe PropertyBinary(String aName, System.Action aValueChanged)
            : base(aValueChanged)
        {
            IntPtr ptr  = GCHandle.ToIntPtr(iGch);
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            iHandle = ServicePropertyCreateBinaryCp(name, iCallbackValueChanged, ptr);
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Query the value of the property
        /// </summary>
        /// <returns>String property value</returns>
        public unsafe String Value()
        {
            IntPtr ptr;
            uint   len;

            ServicePropertyGetValueString(iHandle, &ptr, &len);
            String str = InteropUtils.PtrToStringUtf8(ptr, len);

            OhNetFree(ptr);
            return(str);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aName">Parameter name</param>
        /// <param name="aAllowedValues">List of allowed values for the string</param>
        public ParameterString(String aName, List <String> aAllowedValues)
        {
            IntPtr name = InteropUtils.StringToHGlobalUtf8(aName);

            IntPtr[] allowed = aAllowedValues.Select <string, IntPtr>(InteropUtils.StringToHGlobalUtf8).ToArray();
            iHandle = ServiceParameterCreateString(name, allowed, (uint)aAllowedValues.Count);
            foreach (IntPtr allowedValue in allowed)
            {
                Marshal.FreeHGlobal(allowedValue);
            }
            Marshal.FreeHGlobal(name);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Query which subnet is in use.
        /// </summary>
        /// <param name="aCookie">Identifier for NetworkAdapter reference.  Must be used in a later call to NetworkAdapter.RemoveRef()</param>
        /// <returns>Network adapter.  Or null if no subnet is selected or we're running the device stack on all subnets.</returns>
        public static NetworkAdapter CurrentAdapter(string aCookie)
        {
            IntPtr cookie = InteropUtils.StringToHGlobalUtf8(aCookie);
            IntPtr nif    = OhNetCurrentSubnetAdapter(cookie);

            if (nif == IntPtr.Zero)
            {
                return(null);
            }
            NetworkAdapter n = new NetworkAdapter(nif);

            n.AddManagedCookie(aCookie, cookie);
            return(n);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Query the value of the property
        /// </summary>
        /// <returns>String property value</returns>
        public unsafe String Value()
        {
            IntPtr ptr;
            uint   len;

            if (ServicePropertyGetValueString(iHandle, &ptr, &len) == -1)
            {
                throw new PropertyError();
            }
            String str = InteropUtils.PtrToStringUtf8(ptr, len);

            OhNetFree(ptr);
            return(str);
        }