当前位置: 首页>>代码示例>>C#>>正文


C# ESRI.GetAllProperties方法代码示例

本文整理汇总了C#中ESRI.GetAllProperties方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.GetAllProperties方法的具体用法?C# ESRI.GetAllProperties怎么用?C# ESRI.GetAllProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ESRI的用法示例。


在下文中一共展示了ESRI.GetAllProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenFeatureClass

        public ESRI.ArcGIS.Geodatabase.IFeatureClass OpenFeatureClass(ESRI.ArcGIS.esriSystem.IPropertySet DatabasePropertySet, string FeatureclassName)
        {
            ESRI.ArcGIS.Geodatabase.IWorkspace        sourceWorkspace        = null;
              ESRI.ArcGIS.Geodatabase.IFeatureWorkspace sourceFeatureWorkspace = null;

              try
              {
            //  Establish a Connection to the Geodatabase that houses the Feature Class.
            int propertiesCount = DatabasePropertySet.Count;
            System.Object[] propNamesArray = new System.Object[1];
            System.Object[] propValuesArray = new System.Object[1];
            DatabasePropertySet.GetAllProperties(out propNamesArray[0], out propValuesArray[0]);
            System.Object[] propertyNames = (System.Object[])propNamesArray[0];
            System.Object[] propertyValues = (System.Object[])propValuesArray[0];
            bool itsEnterprise = false;
            for (int i = 0; i < propertiesCount; i++)
            {
              if (System.String.Compare("INSTANCE", propertyNames[i].ToString(), System.StringComparison.CurrentCultureIgnoreCase) == 0)
              {
            if (!System.String.IsNullOrEmpty(propertyValues[i].ToString()))
            {
              itsEnterprise = true;
            }
              }
            }
            if (itsEnterprise)
            {
              //  The Property Set is an Enterprise Geodatabase Property Set, so establish an Enterprise Geodatabase Connection.
              sourceWorkspace = EstablishEnterpriseGeoDBConnection(DatabasePropertySet);
            }
            else
            {
              //  The Property Set is a File Geodatabase Property Set, so establish a File Geodatabase Connection.
              sourceWorkspace = EstablishFileGeodatabaseConnection(DatabasePropertySet);
            }

            //  Make sure the Source Workspace was opened successfully.
            if (sourceWorkspace == null)
            {
              //  Let the User know that this method failed.
              if (ErrorMessage != null)
              {
            ErrorMessage("Could not establish a connection to the Specified Source Geodatabase. Aborting the MaintTools.FeatureClassUtilities.OpenFeatureClass() Method!");
              }

              //  Return a NULL Pointer to the calling Method to indicate that this Method failed.
              return null;

            }

            //  Attempt to open the Feature Class.
            sourceFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)sourceWorkspace;
            return sourceFeatureWorkspace.OpenFeatureClass(FeatureclassName);

              }
              catch (System.Runtime.InteropServices.COMException comException)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(comException, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this method failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The MaintTools.FeatureClassUtilities.OpenFeatureClass() Method failed while opening the Feature Class in the Geodatabase Workspace with COM Exception - " + comException.Message + " (" + comException.ErrorCode + " Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return a NULL Pointer to the calling method to indicate that this methdo failed.
            return null;

              }
              catch (System.Exception caught)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(caught, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this method failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The MaintTools.FeatureClassUtilities.OpenFeatureClass() Method failed with error message - " + caught.Message + " (Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return a NULL Pointer to the calling Method to indicate that this Method failed.
            return null;

              }
              finally
              {
            //  If the ESRI Source Geodatabase Feature Workspace Object was instantiated, close it.
            if (sourceFeatureWorkspace != null)
            {
              sourceFeatureWorkspace = null;
            }
            //  If the ESRI Source Goedatabase Workspace Object was instantiated, close it.
            if (sourceWorkspace != null)
            {
              sourceWorkspace = null;
//.........这里部分代码省略.........
开发者ID:MitchVan,项目名称:DataMaintenanceUtilities,代码行数:101,代码来源:FeatureClassUtilities.cs


注:本文中的ESRI.GetAllProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。