示例#1
0
        /* Traverse the feature tree, displaying all categories and all features. */
        private static void handleCategory(NODE_HANDLE hRoot, string indentation)
        {
            uint numfeat, i;

            string rootname = GenApi.NodeGetName(hRoot);

            /* Get the number of feature nodes in this category. */
            numfeat = GenApi.CategoryGetNumFeatures(hRoot);

            Console.WriteLine("{0} category has {1} children:", indentation + rootname, numfeat);

            indentation += "  ";

            /* Now loop over all feature nodes. */
            for (i = 0; i < numfeat; ++i)
            {
                NODE_HANDLE     hNode;
                EGenApiNodeType nodeType;

                /* Get next feature node and check its type. */
                hNode    = GenApi.CategoryGetFeatureByIndex(hRoot, i);
                nodeType = GenApi.NodeGetType(hNode);

                if (EGenApiNodeType.Category != nodeType)
                {
                    /* A regular feature. */
                    EGenApiAccessMode am;
                    string            amode;

                    string name = GenApi.NodeGetName(hNode);

                    am = GenApi.NodeGetAccessMode(hNode);

                    switch (am)
                    {
                    case EGenApiAccessMode.NI:
                        amode = "not implemented";
                        break;

                    case EGenApiAccessMode.NA:
                        amode = "not available";
                        break;

                    case EGenApiAccessMode.WO:
                        amode = "write only";
                        break;

                    case EGenApiAccessMode.RO:
                        amode = "read only";
                        break;

                    case EGenApiAccessMode.RW:
                        amode = "read and write";
                        break;

                    default:
                        amode = "undefined";
                        break;
                    }

                    Console.WriteLine("{0} feature - access: {1}", indentation + name, amode);
                }
                else
                {
                    /* Another category node. */
                    handleCategory(hNode, indentation + "  ");
                }
            }
        }