Esempio n. 1
0
        /// <summary>
        /// Gets a table from the same workspace as any other table
        /// </summary>
        /// <param name="siblingClass">Any object class from the same workspace</param>
        /// <param name="tableName">Name of desired table (no db or owner)</param>
        /// <returns>ESRI.ArcGIS.Geodatabase.ITable</returns>
        //public static ESRI.ArcGIS.Geodatabase.ITable GetTable(ESRI.ArcGIS.Geodatabase.IObjectClass siblingClass, string tableName)
        //{
        //    if (null == siblingClass)
        //    {
        //        throw new ArgumentNullException("siblingClass");
        //    }

        //    if (1 > tableName.Length)
        //    {
        //        throw new ArgumentException("tableName not specified");
        //    }
        //    ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)siblingClass;
        //    ESRI.ArcGIS.Geodatabase.IFeatureWorkspace workspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)dataset.Workspace;
        //    ESRI.ArcGIS.Geodatabase.ISQLSyntax sqlSyntax = (ESRI.ArcGIS.Geodatabase.ISQLSyntax)workspace;

        //    string owner = string.Empty;
        //    string table = string.Empty;
        //    string db = string.Empty;

        //    // Get the db and owner from the sibling class
        //    sqlSyntax.ParseTableName(dataset.Name, out db, out owner, out table);

        //    // Use that to qualify the requested tableName
        //    string qualifiedName = sqlSyntax.QualifyTableName(db, owner, tableName);
        //    return workspace.OpenTable(qualifiedName);
        //}

        /// <summary>
        /// Gets a feature class from the same workspace as any other table
        /// </summary>
        /// <param name="siblingClass">Any object class from the same workspace</param>
        /// <param name="tableName">Name of desired table (no db or owner)</param>
        /// <returns>ESRI.ArcGIS.Geodatabase.IFeatureClass</returns>
        //public static ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClass(ESRI.ArcGIS.Geodatabase.IObjectClass siblingClass, string ftClassName)
        //{
        //    if (null == siblingClass)
        //    {
        //        throw new ArgumentException("siblingClass");
        //    }

        //    if (1 > ftClassName.Length)
        //    {
        //        throw new ArgumentException("ftClassName");
        //    }

        //    return GdbUtils.GetTable(siblingClass, ftClassName) as ESRI.ArcGIS.Geodatabase.IFeatureClass;
        //}

        /// <summary>
        /// Gets a feature class from a workspace
        /// </summary>
        /// <param name="workspace">Workspace in which FC exists</param>
        /// <param name="tableName">Name of desired table (no db or owner)</param>
        /// <returns>ESRI.ArcGIS.Geodatabase.IFeatureClass</returns>
        //public static ESRI.ArcGIS.Geodatabase.IFeatureClass GetFeatureClass(IFeatureWorkspace workspace, string ftClassName)
        //{
        //    if (null == workspace)
        //    {
        //        throw new ArgumentException("workspace");
        //    }

        //    if (1 > ftClassName.Length)
        //    {
        //        throw new ArgumentException("ftClassName");
        //    }

        //    return workspace.OpenFeatureClass(ftClassName);
        //}

        /// <summary>
        /// Gets a relationship class from the same workspace as any other object class
        /// </summary>
        /// <param name="siblingClass">Any object class from the same workspace</param>
        /// <param name="tableName">Name of desired relationship class (no db or owner)</param>
        /// <returns>ESRI.ArcGIS.Geodatabase.IRelationshipClass</returns>
        public static ESRI.ArcGIS.Geodatabase.IRelationshipClass GetRelationshipClass(ESRI.ArcGIS.Geodatabase.IObjectClass siblingClass, string name)
        {
            if (null == siblingClass)
            {
                throw new ArgumentNullException("siblingClass");
            }

            if (1 > name.Length)
            {
                throw new ArgumentException("name");
            }

            ESRI.ArcGIS.Geodatabase.IDataset          dataset   = (ESRI.ArcGIS.Geodatabase.IDataset)siblingClass;
            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace workspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)dataset.Workspace;
            ESRI.ArcGIS.Geodatabase.ISQLSyntax        sqlSyntax = (ESRI.ArcGIS.Geodatabase.ISQLSyntax)workspace;

            string owner     = string.Empty;
            string tableName = string.Empty;
            string db        = string.Empty;

            // Get the db and owner from the sibling class
            sqlSyntax.ParseTableName(dataset.Name, out db, out owner, out tableName);

            // Qualify the requested relationship class name using that db and owner
            string qualifiedName = sqlSyntax.QualifyTableName(db, owner, name);

            return(workspace.OpenRelationshipClass(qualifiedName));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets just the tableName part of a dataset's Name
        /// </summary>
        /// <param name="dataset">IDataset to check</param>
        /// <returns>string</returns>
        public static string ParseTableName(ESRI.ArcGIS.Geodatabase.IDataset dataset)
        {
            if (null == dataset)
            {
                throw new ArgumentNullException("dataset");
            }

            string dbName    = string.Empty;
            string tableName = string.Empty;
            string ownerName = string.Empty;

            ESRI.ArcGIS.Geodatabase.ISQLSyntax syntax = (ESRI.ArcGIS.Geodatabase.ISQLSyntax)dataset.Workspace;
            syntax.ParseTableName(dataset.Name, out dbName, out ownerName, out tableName);

            return(tableName);
        }
        /// <summary>
        /// Caches a string representation of the feature based on feature class, display field, and / or OID
        /// </summary>
        private void CacheToString()
        {
            string result = base.ToString();

            if (null != _feature)
            {
                string displayValue = string.Format("OID {0}", _feature.OID);
                if (-1 < _displayFieldIdx)
                {
                    object objValue = _feature.get_Value(_displayFieldIdx);
                    if (DBNull.Value != objValue)
                    {
                        displayValue = objValue.ToString();
                    }
                }

                string ftClassName = "Unknown Ft. Class";

                ESRI.ArcGIS.Geodatabase.IDataset dataset = _feature.Class as ESRI.ArcGIS.Geodatabase.IDataset;
                if (null != dataset)
                {
                    ESRI.ArcGIS.Geodatabase.ISQLSyntax syntax = dataset.Workspace as ESRI.ArcGIS.Geodatabase.ISQLSyntax;
                    if (null != syntax)
                    {
                        string dbName    = string.Empty;
                        string ownerName = string.Empty;
                        string tableName = string.Empty;
                        syntax.ParseTableName(dataset.Name, out dbName, out ownerName, out tableName);
                        ftClassName = tableName;
                    }
                }

                result = string.Format("{0} ({1})", displayValue, ftClassName);
            }

            _toString = result;
        }