private unsafe int GetZString(PIActionList list, uint index, ASZString *zstring) { if (zstring == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { ActionDescriptorZString value = (ActionDescriptorZString)items[(int)index].Value; try { *zstring = zstringSuite.CreateFromActionDescriptor(value); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int PutObject(PIActionList list, uint type, PIActionDescriptor descriptor) { if (actionDescriptorSuite == null) { // The plug-in called this method before acquiring the Action Descriptor suite. return(PSError.kSPLogicError); } try { ReadOnlyDictionary <uint, AETEValue> descriptorValues; if (actionDescriptorSuite.TryGetDescriptorValues(descriptor, out descriptorValues)) { ActionListDescriptor item = new ActionListDescriptor(type, descriptorValues); actionLists[list].Add(new ActionListItem(DescriptorTypes.Object, item)); } else { return(PSError.kSPBadParameterError); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutAlias(PIActionList list, Handle aliasHandle) { try { IntPtr hPtr = HandleSuite.Instance.LockHandle(aliasHandle, 0); try { int size = HandleSuite.Instance.GetHandleSize(aliasHandle); byte[] data = new byte[size]; Marshal.Copy(hPtr, data, 0, size); actionLists[list].Add(new ActionListItem(DescriptorTypes.Alias, data)); } finally { HandleSuite.Instance.UnlockHandle(aliasHandle); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private unsafe int GetList(PIActionList list, uint index, PIActionList *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { ReadOnlyCollection <ActionListItem> value = (ReadOnlyCollection <ActionListItem>)items[(int)index].Value; try { *data = GenerateDictionaryKey(); actionLists.Add(*data, new ActionListItemCollection(value)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private unsafe int GetAlias(PIActionList list, uint index, Handle *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { byte[] bytes = (byte[])items[(int)index].Value; * data = HandleSuite.Instance.NewHandle(bytes.Length); if (*data == Handle.Null) { return(PSError.kSPOutOfMemoryError); } Marshal.Copy(bytes, 0, HandleSuite.Instance.LockHandle(*data, 0), bytes.Length); HandleSuite.Instance.UnlockHandle(*data); return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int PutIntegers(PIActionList list, uint count, IntPtr arrayPointer) { if (arrayPointer == IntPtr.Zero) { return(PSError.kSPBadParameterError); } try { unsafe { ActionListItemCollection items = actionLists[list]; int *ptr = (int *)arrayPointer; for (uint i = 0; i < count; i++) { items.Add(new ActionListItem(DescriptorTypes.Integer, *ptr)); ptr++; } } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutString(PIActionList list, IntPtr cstrValue) { if (cstrValue == IntPtr.Zero) { return(PSError.kSPBadParameterError); } try { if (StringUtil.TryGetCStringLength(cstrValue, out int length)) { byte[] data = new byte[length]; Marshal.Copy(cstrValue, data, 0, length); actionLists[list].Add(new ActionListItem(DescriptorTypes.Char, data)); } else { // The string length exceeds int.MaxValue. return(PSError.kSPOutOfMemoryError); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private unsafe int GetReference(PIActionList list, uint index, PIActionReference *reference) { if (reference == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { ReadOnlyCollection <ActionReferenceItem> value = (ReadOnlyCollection <ActionReferenceItem>)items[(int)index].Value; try { *reference = actionReferenceSuite.CreateReference(value); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private unsafe int GetUnitFloat(PIActionList list, uint index, uint *unit, double *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { UnitFloat unitFloat = (UnitFloat)items[(int)index].Value; if (unit != null) { *unit = unitFloat.Unit; } *data = unitFloat.Value; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int GetString(PIActionList list, uint index, IntPtr cstrValue, uint maxLength) { if (cstrValue == IntPtr.Zero) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { if (maxLength > 0) { byte[] bytes = (byte[])items[(int)index].Value; // Ensure that the buffer has room for the null terminator. int length = (int)Math.Min(bytes.Length, maxLength - 1); Marshal.Copy(bytes, 0, cstrValue, length); Marshal.WriteByte(cstrValue, length, 0); } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int Free(PIActionList list) { actionLists.Remove(list); if (actionListsIndex == list.Index) { actionListsIndex--; } return(PSError.kSPNoError); }
private int PutFloat(PIActionList list, double data) { try { actionLists[list].Add(new ActionListItem(DescriptorTypes.Float, data)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutInteger(PIActionList list, int data) { try { actionLists[list].Add(new ActionListItem(DescriptorTypes.Integer, data)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private unsafe int GetCount(PIActionList list, uint *count) { if (count == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; *count = (uint)items.Count; return(PSError.kSPNoError); }
PIActionList IActionListSuite.CreateList(ReadOnlyCollection <ActionListItem> values) { if (values == null) { throw new ArgumentNullException(nameof(values)); } PIActionList list = GenerateDictionaryKey(); actionLists.Add(list, new ActionListItemCollection(values)); return(list); }
private int PutGlobalClass(PIActionList list, uint data) { try { actionLists[list].Add(new ActionListItem(DescriptorTypes.GlobalClass, data)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutBoolean(PIActionList list, byte data) { try { actionLists[list].Add(new ActionListItem(DescriptorTypes.Boolean, data)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutEnumerated(PIActionList list, uint type, uint data) { try { EnumeratedValue item = new EnumeratedValue(type, data); actionLists[list].Add(new ActionListItem(DescriptorTypes.Enumerated, item)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
bool IActionListSuite.TryGetListValues(PIActionList list, out ReadOnlyCollection <ActionListItem> values) { values = null; ActionListItemCollection items; if (actionLists.TryGetValue(list, out items)) { values = items.GetListAsReadOnly(); return(true); } return(false); }
private int PutUnitFloat(PIActionList list, uint unit, double data) { try { UnitFloat item = new UnitFloat(unit, data); actionLists[list].Add(new ActionListItem(DescriptorTypes.UintFloat, item)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private unsafe int GetType(PIActionList list, uint index, uint *type) { if (type == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { *type = items[(int)index].Type; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private unsafe int GetClass(PIActionList list, uint index, uint *data) { if (data == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { *data = (uint)items[(int)index].Value; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private unsafe int GetDataLength(PIActionList list, uint index, int *length) { if (length == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { byte[] bytes = (byte[])items[(int)index].Value; *length = bytes.Length; return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int GetData(PIActionList list, uint index, IntPtr blob) { if (blob == IntPtr.Zero) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { byte[] data = (byte[])items[(int)index].Value; Marshal.Copy(data, 0, blob, data.Length); return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int PutReference(PIActionList list, PIActionReference reference) { try { ReadOnlyCollection <ActionReferenceItem> value; if (actionReferenceSuite.TryGetReferenceValues(reference, out value)) { actionLists[list].Add(new ActionListItem(DescriptorTypes.ObjectReference, value)); } else { return(PSError.kSPBadParameterError); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutList(PIActionList list, PIActionList data) { try { ActionListItemCollection items; if (actionLists.TryGetValue(data, out items)) { actionLists[list].Add(new ActionListItem(DescriptorTypes.ValueList, items.GetListAsReadOnly())); } else { return(PSError.kSPBadParameterError); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutZString(PIActionList list, ASZString zstring) { try { ActionDescriptorZString value; if (zstringSuite.ConvertToActionDescriptor(zstring, out value)) { actionLists[list].Add(new ActionListItem(DescriptorTypes.Char, value)); } else { return(PSError.kSPBadParameterError); } } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private int PutData(PIActionList list, int length, IntPtr blob) { if (blob == IntPtr.Zero || length < 0) { return(PSError.kSPBadParameterError); } try { byte[] data = new byte[length]; Marshal.Copy(blob, data, 0, length); actionLists[list].Add(new ActionListItem(DescriptorTypes.RawData, data)); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); }
private unsafe int GetObject(PIActionList list, uint index, uint *retType, PIActionDescriptor *descriptor) { if (actionDescriptorSuite == null) { // The plug-in called this method before acquiring the Action Descriptor suite. return(PSError.kSPLogicError); } if (descriptor == null) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (index < items.Count) { ActionListDescriptor item = (ActionListDescriptor)items[(int)index].Value; if (retType != null) { *retType = item.Type; } try { *descriptor = actionDescriptorSuite.CreateDescriptor(item.DescriptorValues); } catch (OutOfMemoryException) { return(PSError.kSPOutOfMemoryError); } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }
private int GetIntegers(PIActionList list, uint count, IntPtr data) { if (data == IntPtr.Zero) { return(PSError.kSPBadParameterError); } ActionListItemCollection items = actionLists[list]; if (count <= items.Count) { int valueCount = (int)count; unsafe { int *ptr = (int *)data.ToPointer(); for (int i = 0; i < valueCount; i++) { ActionListItem item = items[i]; // The first through valueCount items in the list are required to be integers. if (item.Type != DescriptorTypes.Integer) { return(PSError.kSPLogicError); } *ptr = (int)item.Value; ptr++; } } return(PSError.kSPNoError); } return(PSError.kSPBadParameterError); }