public static StringToHGlobalUtf8 ( string aStr ) : |
||
aStr | string | |
return |
/// <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); }
/// <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); }
public unsafe ParameterRelated(String aName, OpenHome.Net.Core.Property aProperty) { IntPtr name = InteropUtils.StringToHGlobalUtf8(aName); iHandle = ServiceParameterCreateRelated(name, aProperty.Handle()); Marshal.FreeHGlobal(name); }
/// <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); }
/// <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); }
/// <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); }
/// <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>(); }
/// <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); }
/// <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); }
/// <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); }