Exemple #1
0
        private int GetName(PIActionReference reference, IntPtr cstrValue, uint maxLength)
        {
            if (cstrValue != IntPtr.Zero)
            {
                ActionReferenceContainer container;
                if (actionReferences.TryGetValue(reference, out container))
                {
                    ActionReferenceItem item = container.GetReference();
                    if (item != null)
                    {
                        if (maxLength > 0)
                        {
                            byte[] bytes = (byte[])item.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);
        }
Exemple #2
0
        private unsafe int GetContainer(PIActionReference reference, PIActionReference *value)
        {
            if (reference == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                try
                {
                    ActionReferenceContainer nextContainer = container.GetNextContainer();
                    if (nextContainer != null)
                    {
                        *value = GenerateDictionaryKey();
                        actionReferences.Add(*value, nextContainer);
                    }
                    else
                    {
                        *value = PIActionReference.Null;
                    }
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #3
0
        private unsafe int GetEnumerated(PIActionReference reference, uint *type, uint *enumValue)
        {
            if (enumValue == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                ActionReferenceItem item = container.GetReference();
                if (item != null)
                {
                    EnumeratedValue enumerated = (EnumeratedValue)item.Value;

                    if (type != null)
                    {
                        *type = enumerated.Type;
                    }
                    *enumValue = enumerated.Value;

                    return(PSError.kSPNoError);
                }
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #4
0
        private int PutName(PIActionReference reference, uint desiredClass, IntPtr cstrValue)
        {
            if (cstrValue != IntPtr.Zero)
            {
                try
                {
                    if (StringUtil.TryGetCStringLength(cstrValue, out int length))
                    {
                        byte[] bytes = new byte[length];
                        Marshal.Copy(cstrValue, bytes, 0, length);

                        actionReferences[reference].Add(new ActionReferenceItem(ActionReferenceForm.Name, desiredClass, bytes));
                    }
                    else
                    {
                        // The string length exceeds int.MaxValue.
                        return(PSError.memFullErr);
                    }
                }
                catch (OutOfMemoryException)
                {
                    return(PSError.memFullErr);
                }

                return(PSError.kSPNoError);
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #5
0
        private int Free(PIActionReference reference)
        {
            actionReferences.Remove(reference);
            if (actionReferencesIndex == reference.Index)
            {
                actionReferencesIndex--;
            }

            return(PSError.kSPNoError);
        }
Exemple #6
0
        private int PutClass(PIActionReference reference, uint desiredClass)
        {
            try
            {
                actionReferences[reference].Add(new ActionReferenceItem(ActionReferenceForm.Class, desiredClass, null));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Exemple #7
0
        private int PutProperty(PIActionReference reference, uint desiredClass, uint value)
        {
            try
            {
                actionReferences[reference].Add(new ActionReferenceItem(ActionReferenceForm.Property, desiredClass, value));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Exemple #8
0
        private int PutEnumerated(PIActionReference reference, uint desiredClass, uint type, uint value)
        {
            try
            {
                actionReferences[reference].Add(new ActionReferenceItem(ActionReferenceForm.Enumerated, desiredClass, new EnumeratedValue(type, value)));
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Exemple #9
0
        PIActionReference IActionReferenceSuite.CreateFromActionDescriptor(ActionDescriptorReference descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            PIActionReference reference = GenerateDictionaryKey();

            actionReferences.Add(reference, new ActionReferenceContainer(descriptor.References));

            return(reference);
        }
Exemple #10
0
        bool IActionReferenceSuite.ConvertToActionDescriptor(PIActionReference reference, out ActionDescriptorReference descriptor)
        {
            descriptor = null;

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                descriptor = container.ConvertToActionDescriptor();

                return(true);
            }

            return(false);
        }
Exemple #11
0
        private int PutReference(PIActionList list, PIActionReference reference)
        {
            try
            {
                ActionDescriptorReference value;
                if (actionReferenceSuite.ConvertToActionDescriptor(reference, out value))
                {
                    actionLists[list].Add(new ActionListItem(DescriptorTypes.ObjectReference, value));
                }
                else
                {
                    return(PSError.kSPBadParameterError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }
Exemple #12
0
        private unsafe int GetProperty(PIActionReference reference, uint *value)
        {
            if (value == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                ActionReferenceItem item = container.GetReference();
                if (item != null)
                {
                    *value = (uint)item.Value;

                    return(PSError.kSPNoError);
                }
            }

            return(PSError.kSPBadParameterError);
        }
Exemple #13
0
        private unsafe int GetNameLength(PIActionReference reference, uint *stringLength)
        {
            if (stringLength == null)
            {
                return(PSError.kSPBadParameterError);
            }

            ActionReferenceContainer container;

            if (actionReferences.TryGetValue(reference, out container))
            {
                ActionReferenceItem item = container.GetReference();
                if (item != null)
                {
                    byte[] bytes        = (byte[])item.Value;
                    *      stringLength = (uint)bytes.Length;

                    return(PSError.kSPNoError);
                }
            }

            return(PSError.kSPBadParameterError);
        }