Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        private int Free(PIActionList list)
        {
            actionLists.Remove(list);
            if (actionListsIndex == list.Index)
            {
                actionListsIndex--;
            }

            return(PSError.kSPNoError);
        }
Esempio n. 12
0
        private int PutFloat(PIActionList list, double data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Float, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
Esempio n. 13
0
        private int PutInteger(PIActionList list, int data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Integer, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        private int PutGlobalClass(PIActionList list, uint data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.GlobalClass, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
Esempio n. 17
0
        private int PutBoolean(PIActionList list, byte data)
        {
            try
            {
                actionLists[list].Add(new ActionListItem(DescriptorTypes.Boolean, data));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.kSPOutOfMemoryError);
            }

            return(PSError.kSPNoError);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        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);
        }