コード例 #1
0
        public static List <NamedValue> ConvertToNamedValueList(IntPtr pXmlSection)
        {
            if (IntPtr.Zero == pXmlSection)
            {
                return(null);
            }

            List <Rhino.Render.NamedValue> list = new List <NamedValue>();

            IntPtr pIterator = UnsafeNativeMethods.Rdk_XmlSection_GetIterator(pXmlSection);

            //Fill the property list from the XML section
            if (pIterator != IntPtr.Zero)
            {
                while (true)
                {
                    using (var sh = new StringHolder())
                    {
                        Variant variant = new Variant();

                        if (1 == UnsafeNativeMethods.Rdk_XmlSection_NextParam(pXmlSection, pIterator, sh.ConstPointer(), variant.ConstPointer()))
                        {
                            NamedValue nv = new NamedValue(sh.ToString(), variant.AsObject());
                            list.Add(nv);
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                UnsafeNativeMethods.Rdk_XmlSection_DeleteIterator(pIterator);
            }

            return(list);
        }