/// <summary> /// Setzt einen Wert. /// </summary> /// <param name="node">Die Beschreibung der Eigenschaft.</param> /// <param name="PropertyData">Die neuen Daten.</param> public void Set(KsPNode node, DataType PropertyData) { // Unmap var propertySetIdentifier = node.Property.Set; // Allocate the memory for explicit marshalling var dataMemory = Marshal.AllocHGlobal(SizeOf); try { // Lock in memory var nodeMemory = Marshal.AllocHGlobal(KsPNode.SizeOf); try { // Fill - must box to support enumerations Marshal.StructureToPtr(typeof(DataType).IsEnum ? Convert.ToInt32(PropertyData) : (object)PropertyData, dataMemory, false); Marshal.StructureToPtr(node, nodeMemory, false); // Update the property m_Instance.Object.Set(ref propertySetIdentifier, node.Property.Id, nodeMemory, (uint)KsPNode.SizeOf, dataMemory, (uint)SizeOf); } finally { // Cleanup Marshal.FreeHGlobal(nodeMemory); } } finally { // Cleanup Marshal.FreeHGlobal(dataMemory); } }
/// <summary> /// Prüft, in welchem Umfang eine bestimmte Eigenschaft unterstützt wird. /// </summary> /// <param name="set">Die zu erweiternde Schnittstelle.</param> /// <param name="node">Die Beschreibung der Eigenschaft.</param> /// <param name="types">Die benötigte Art der Unterstützung.</param> /// <returns>Gesetzt, wenn die gewünschte Unterstützung möglich ist.</returns> public static bool DoesSupport <T>(this IKsPropertySet <T> set, KsPNode node, PropertySetSupportedTypes types) where T : struct { // Process if (set == null) { throw new ArgumentNullException("set"); } else { return(set.DoesSupport(node.Property, types)); } }