/// <summary>
            /// Creates an instance of OptionDescription from a handle to IOptionDescription
            /// </summary>
            internal static OptionDescription Create(IOptionDescription optionDescription, bool shouldSuppressCOMExceptions = true, bool shouldReleaseCOMObject = true)
            {
                if (optionDescription == null)
                {
                    throw new ArgumentNullException(nameof(optionDescription));
                }

                var od = new OptionDescription(optionDescription.Id, optionDescription.Heading, optionDescription.Description);

                try
                {
                    od._labels = optionDescription.Labels.ToList();
                }
                catch (COMException) when(shouldSuppressCOMExceptions)
                {
                    // do nothing here - the exception filter does it all.
                }
                finally
                {
                    if (shouldReleaseCOMObject)
                    {
                        Marshal.ReleaseComObject(optionDescription);
                    }
                }

                return(od);
            }
Esempio n. 2
0
            private OptionDescription GetOptionDescriptionImpl(string optionId)
            {
                IOptionDescription iod = _speller.Value.GetOptionDescription(optionId);

                return((iod != null) ? OptionDescription.Create(iod, false, true) : null);
            }