Example #1
0
        public object ESRI_Attributes_Get(ResultBuffer rb)
        {
            object result;

            try
            {
                ObjectId argument = LspUtil.GetArgument(rb, 0, ObjectId.Null);
                if (argument == ObjectId.Null)
                {
                    result = null;
                }
                else
                {
                    string          assocParam   = LspUtil.GetAssocParam(rb, "FCNAME", null);
                    string          assocParam2  = LspUtil.GetAssocParam(rb, "STNAME", null);
                    string          fieldName    = LspUtil.GetAssocParam(rb, "FIELDNAME", null);
                    MSCFeatureClass featureClass = this.GetFeatureClass(assocParam, assocParam2);
                    List <CadField> list;
                    if (featureClass == null)
                    {
                        list = CadField.EntityCadFields(argument);
                    }
                    else
                    {
                        list = featureClass.GetEntityFields(argument);
                    }
                    if (!string.IsNullOrEmpty(fieldName))
                    {
                        list = (from x in list
                                where x.Name == fieldName
                                select x).ToList <CadField>();
                    }
                    if (list.Count == 0)
                    {
                        result = null;
                    }
                    else
                    {
                        List <TypedValue> list2 = new List <TypedValue>();
                        list2.Add(new TypedValue(5016, null));
                        foreach (CadField current in list)
                        {
                            LspUtil.AppendDottedPair(ref list2, current.Name, current.Value.Value);
                        }
                        list2.Add(new TypedValue(5017, null));
                        ResultBuffer resultBuffer = new ResultBuffer(list2.ToArray());
                        result = resultBuffer;
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Example #2
0
        public object ESRI_DeleteFeatureClassAttributes(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 1)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5006)
                    {
                        result = null;
                    }
                    else
                    {
                        ObjectId      id   = (ObjectId)typedValue.Value;
                        List <string> list = new List <string>();
                        if (array.Count <TypedValue>() > 1)
                        {
                            TypedValue[] array2 = array;
                            for (int i = 0; i < array2.Length; i++)
                            {
                                TypedValue typedValue2 = array2[i];
                                if (typedValue2.TypeCode == 5005)
                                {
                                    list.Add(typedValue2.Value.ToString());
                                }
                            }
                        }
                        List <CadField> list2 = CadField.EntityCadFields(id);
                        if (list2.Count == 0)
                        {
                            result = LspUtil.LispTrue;
                        }
                        else
                        {
                            List <CadField> list3 = null;
                            if (list.Count == 0)
                            {
                                list3 = list2;
                            }
                            else
                            {
                                list3 = new List <CadField>();
                                foreach (CadField current in list2)
                                {
                                    foreach (string current2 in list)
                                    {
                                        if (string.Equals(current2, current.Name, StringComparison.CurrentCultureIgnoreCase) && !list3.Contains(current))
                                        {
                                            list3.Add(current);
                                        }
                                    }
                                }
                            }
                            if (list3.Count == 0)
                            {
                                result = LspUtil.LispTrue;
                            }
                            else
                            {
                                Document document = AfaDocData.ActiveDocData.Document;
                                Database database = document.Database;
                                using (document.LockDocument((DocumentLockMode)4, null, null, false))
                                {
                                    using (Transaction transaction = database.TransactionManager.StartTransaction())
                                    {
                                        foreach (CadField current3 in list3)
                                        {
                                            if (!current3.ReadOnly && current3.Visible)
                                            {
                                                CadField.RemoveCadAttribute(database, transaction, id, current3);
                                            }
                                        }
                                        transaction.Commit();
                                    }
                                }
                                result = LspUtil.LispTrue;
                            }
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }