public bool IsValid(object caller, Condition condition)
        {
            IObjectExplorer objectExplorer = caller as IObjectExplorer;

            if (objectExplorer == null)
            {
                return(false);
            }

            TreeNode node = objectExplorer.GetSelectedNode();

            //Might be the one. Check it's root parent
            if (node.Level >= 1)
            {
                TreeNode root = node.Parent;
                while (root.Level > 0)
                {
                    root = root.Parent;
                }

                TreeNode rootCmp = objectExplorer.GetRootNode(FdoObjectExplorerExtender.RootNodeName);
                if (root == rootCmp)
                {
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
                    FdoConnection        conn    = connMgr.GetConnection(connNode.Name);
                    if (conn != null)
                    {
                        try
                        {
                            var applicable                     = (Array.IndexOf <string>(applicableProviders, conn.Provider.ToUpper()) >= 0);
                            var supportsSchemaMappings         = conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSchemaOverrides);
                            var supportsDescribeSchemaMappings = conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList).Cast <CommandType>().Contains(CommandType.CommandType_DescribeSchemaMapping);

                            return(supportsSchemaMappings && supportsDescribeSchemaMappings);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        public bool IsValid(object caller, Condition condition)
        {
            IObjectExplorer objectExplorer = caller as IObjectExplorer;

            if (objectExplorer == null)
            {
                return(false);
            }

            TreeNode node = objectExplorer.GetSelectedNode();

            //Might be the one. Check it's root parent
            if (node.Level >= 1)
            {
                TreeNode root = node.Parent;
                while (root.Level > 0)
                {
                    root = root.Parent;
                }

                TreeNode rootCmp = objectExplorer.GetRootNode(FdoObjectExplorerExtender.RootNodeName);
                if (root == rootCmp)
                {
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    FdoConnection conn = connMgr.GetConnection(connNode.Name);
                    if (conn != null)
                    {
                        string cmd = "CommandType_" + condition.Properties["command"];
                        try
                        {
                            OSGeo.FDO.Commands.CommandType ctype = (OSGeo.FDO.Commands.CommandType)Enum.Parse(typeof(OSGeo.FDO.Commands.CommandType), cmd);
                            Array commands = conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList);
                            return(Array.IndexOf(commands, ctype) >= 0);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }