Esempio n. 1
0
        PropertyProcs IPropertySuite.CreatePropertySuite()
        {
            PropertyProcs suite = new PropertyProcs
            {
                propertyProcsVersion = PSConstants.kCurrentPropertyProcsVersion,
                numPropertyProcs     = PSConstants.kCurrentPropertyProcsCount,
                getPropertyProc      = Marshal.GetFunctionPointerForDelegate(getPropertyProc),
                setPropertyProc      = Marshal.GetFunctionPointerForDelegate(setPropertyProc)
            };

            return(suite);
        }
        private int AllocatePICASuite(ActivePICASuites.PICASuiteKey suiteKey, ref IntPtr suitePointer)
        {
            try
            {
                string suiteName = suiteKey.Name;
                int    version   = suiteKey.Version;

                if (suiteName.Equals(PSConstants.PICA.BufferSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (bufferSuite == null)
                    {
                        bufferSuite = new PICABufferSuite();
                    }

                    PSBufferSuite1 suite = bufferSuite.CreateBufferSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.HandleSuite, StringComparison.Ordinal))
                {
                    if (version != 1 && version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (handleSuite == null)
                    {
                        handleSuite = new PICAHandleSuite();
                    }

                    if (version == 1)
                    {
                        PSHandleSuite1 suite = handleSuite.CreateHandleSuite1();
                        suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                    }
                    else if (version == 2)
                    {
                        PSHandleSuite2 suite = handleSuite.CreateHandleSuite2();
                        suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                    }
                }
                else if (suiteName.Equals(PSConstants.PICA.PropertySuite, StringComparison.Ordinal))
                {
                    // The property suite can be null when the filter is showing its about box.
                    if (propertySuite == null || version != PSConstants.kCurrentPropertyProcsVersion)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    PropertyProcs suite = propertySuite.CreatePropertySuite();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.UIHooksSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (uiHooksSuite == null)
                    {
                        uiHooksSuite = new PICAUIHooksSuite(picaSuiteData.ParentWindowHandle, pluginName, ASZStringSuite);
                    }

                    PSUIHooksSuite1 suite = uiHooksSuite.CreateUIHooksSuite1(picaSuiteData);
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, suite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionDescriptorSuite, StringComparison.Ordinal))
                {
                    if (version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.DescriptorSuiteCreated)
                    {
                        CreateActionDescriptorSuite();
                    }

                    PSActionDescriptorProc actionDescriptor = actionSuites.DescriptorSuite.CreateActionDescriptorSuite2();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, actionDescriptor);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionListSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.ListSuiteCreated)
                    {
                        actionSuites.CreateListSuite(ASZStringSuite);
                    }

                    PSActionListProcs listSuite = actionSuites.ListSuite.CreateActionListSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, listSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ActionReferenceSuite, StringComparison.Ordinal))
                {
                    if (version != 2)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }
                    if (!actionSuites.ReferenceSuiteCreated)
                    {
                        actionSuites.CreateReferenceSuite();
                    }

                    PSActionReferenceProcs referenceSuite = actionSuites.ReferenceSuite.CreateActionReferenceSuite2();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, referenceSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ASZStringSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    ASZStringSuite1 stringSuite = ASZStringSuite.CreateASZStringSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, stringSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ColorSpaceSuite, StringComparison.Ordinal))
                {
                    // The color picker can be null when the filter is showing its about box.
                    if (colorPicker == null || version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (colorSpaceSuite == null)
                    {
                        colorSpaceSuite = new PICAColorSpaceSuite(ASZStringSuite, colorPicker);
                    }

                    PSColorSpaceSuite1 csSuite = colorSpaceSuite.CreateColorSpaceSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, csSuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.DescriptorRegistrySuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (descriptorRegistrySuite == null)
                    {
                        if (!actionSuites.DescriptorSuiteCreated)
                        {
                            CreateActionDescriptorSuite();
                        }

                        descriptorRegistrySuite = new DescriptorRegistrySuite(actionSuites.DescriptorSuite);
                        if (pluginSettings != null)
                        {
                            descriptorRegistrySuite.SetPluginSettings(pluginSettings);
                        }
                    }

                    PSDescriptorRegistryProcs registrySuite = descriptorRegistrySuite.CreateDescriptorRegistrySuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, registrySuite);
                }
                else if (suiteName.Equals(PSConstants.PICA.ErrorSuite, StringComparison.Ordinal))
                {
                    if (version != 1)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    if (errorSuite == null)
                    {
                        errorSuite = new ErrorSuite(ASZStringSuite);
                    }

                    PSErrorSuite1 errorProcs = errorSuite.CreateErrorSuite1();
                    suitePointer = activePICASuites.AllocateSuite(suiteKey, errorProcs);
                }
#if PICASUITEDEBUG
                else if (suiteName.Equals(PSConstants.PICA.SPPluginsSuite, StringComparison.Ordinal))
                {
                    if (version != 4)
                    {
                        return(PSError.kSPSuiteNotFoundError);
                    }

                    SPPluginsSuite4 plugs = PICASPPluginsSuite.CreateSPPluginsSuite4();

                    suitePointer = this.activePICASuites.AllocateSuite(suiteKey, plugs);
                }
#endif
                else
                {
                    return(PSError.kSPSuiteNotFoundError);
                }
            }
            catch (OutOfMemoryException)
            {
                return(PSError.memFullErr);
            }

            return(PSError.kSPNoError);
        }