Exemplo n.º 1
0
 public int TryCeateObjectClass(IFeatureDataSet dataset, string Name, IFieldInfoCollection fields, string[] indexField, out IObjectClass oc)
 {
     oc = null;
     if (((dataset == null) || string.IsNullOrEmpty(Name)) || (fields == null))
     {
         return(-1);
     }
     try
     {
         string[] namesByType = dataset.GetNamesByType(gviDataSetType.gviDataSetObjectClassTable);
         if ((namesByType != null) && (Array.IndexOf <string>(namesByType, Name) != -1))
         {
             oc = dataset.OpenObjectClass(Name);
             return(0);
         }
         oc = dataset.CreateObjectClass(Name, fields);
         if (dataset == null)
         {
             return(-1);
         }
         IDbIndexInfo index = null;
         if (indexField != null)
         {
             foreach (string str in indexField)
             {
                 try
                 {
                     index = new DbIndexInfoClass
                     {
                         Name = string.Format("Index_{0}_{1}", oc.Id, str)
                     };
                     index.AppendFieldDefine(str, true);
                     oc.AddDbIndex(index);
                 }
                 catch (Exception exception)
                 {
                 }
             }
         }
         return(1);
     }
     catch (Exception exception2)
     {
         return(-1);
     }
 }