コード例 #1
0
        bool generateClassToSb(XClass xclass, StringBuilder sbOut, Chilkat.Log log)
        {
            // We're just going to generate some pseudo-code...
            sbOut.Append("class " + xclass.GenericName + " {\r\n\r\n");

            // We could generate constructors, destructors, creation functions, etc. here...

            // Loop over properties and generate each..
            int i;

            for (i = 0; i < xclass.NumProperties; i++)
            {
                XProperty xprop = xclass.GetProperty(i);

                // Skip some properties we may not want..
                // (What you do here depends on your needs..)
                if (xprop.Deprecated)
                {
                    continue;
                }
                if (!xprop.AxEnabled)
                {
                    continue;                       // We don't want properties that do not exist in the ActiveX..
                }
                if (xprop.IsBytes)
                {
                    continue;                 // maybe we don't want to deal with the few properties that are binary data.
                }
                if (xprop.IsEventRelated())
                {
                    continue;
                }
                // ...

                if (!generateProperty(xprop, xclass, sbOut, log))
                {
                    return(false);
                }
            }

            // Loop over methods and generate each...
            for (i = 0; i < xclass.NumMethods; i++)
            {
                XMethod xmethod = xclass.GetMethod(i);

                // Skip some properties we may not want..
                // (What you do here depends on your needs..)
                if (xmethod.Deprecated)
                {
                    continue;
                }
                if (!xmethod.AxEnabled)
                {
                    continue;                         // We don't want properties that do not exist in the ActiveX..
                }
                if (xmethod.IsBytes || xmethod.HasArgWithGt(ChilkatTypes.GT_BYTES))
                {
                    continue;                                                                  // Maybe we don't want to deal with binary return values or args..
                }
                // ...

                if (!generateMethod(xmethod, xclass, sbOut, log))
                {
                    return(false);
                }
            }



            sbOut.Append("};\r\n");
            return(true);
        }