示例#1
0
        private CadField CreateAttributeValue(MSCFeatureClass fc, string fieldName, object value)
        {
            CadField result;

            try
            {
                CadField cadField = FeatureClassAPI.FindField(fc.Fields, fieldName);
                if (cadField == null)
                {
                    result = null;
                }
                else if (cadField.ReadOnly || !cadField.Visible)
                {
                    result = null;
                }
                else
                {
                    TypedValue value2 = CadField.CreateTypedValue(cadField.FieldType, value.ToString());
                    result = new CadField(cadField)
                    {
                        Value = value2
                    };
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
示例#2
0
        private CadField CreateAttributeValue(MSCFeatureClass fc, ref object firstValue, ref object secondValue)
        {
            TypedValue typedValue  = (TypedValue)firstValue;
            TypedValue typedValue2 = (TypedValue)secondValue;
            string     text        = typedValue.Value.ToString();
            object     value       = typedValue2.Value;
            string     fieldName   = text.ToString();
            CadField   cadField    = FeatureClassAPI.FindField(fc.Fields, fieldName);

            if (cadField == null)
            {
                firstValue  = null;
                secondValue = null;
                return(null);
            }
            if (cadField.ReadOnly || !cadField.Visible)
            {
                return(null);
            }
            TypedValue value2 = CadField.CreateTypedValue(cadField.FieldType, typedValue2.Value.ToString());

            if (value2.TypeCode != cadField.Value.TypeCode)
            {
                firstValue  = null;
                secondValue = null;
                return(null);
            }
            CadField cadField2 = new CadField(cadField);

            cadField2.Value = value2;
            if (cadField2.Value.TypeCode == 1)
            {
                string text2 = cadField2.Value.Value.ToString();
                if (text2.Length > (int)cadField.Length)
                {
                    firstValue  = null;
                    secondValue = null;
                    return(null);
                }
            }
            firstValue  = null;
            secondValue = null;
            return(cadField2);
        }
示例#3
0
        public object ESRI_RemoveFeatureClassFieldDefinition(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 2)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string          name = typedValue.Value.ToString();
                        MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(name);
                        if (localFeatureClass == null)
                        {
                            result = null;
                        }
                        else
                        {
                            TypedValue typedValue2 = array[1];
                            if (typedValue2.TypeCode != 5005)
                            {
                                result = null;
                            }
                            else
                            {
                                string fieldName = typedValue2.Value.ToString();
                                if (localFeatureClass.Fields.Count == 0)
                                {
                                    result = null;
                                }
                                else
                                {
                                    CadField cadField = FeatureClassAPI.FindField(localFeatureClass.Fields, fieldName);
                                    if (cadField == null)
                                    {
                                        result = null;
                                    }
                                    else if (cadField.ReadOnly)
                                    {
                                        result = null;
                                    }
                                    else if (localFeatureClass.Fields.Remove(cadField))
                                    {
                                        localFeatureClass.Write(AfaDocData.ActiveDocData.Document);
                                        result = LspUtil.LispTrue;
                                    }
                                    else
                                    {
                                        result = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }
示例#4
0
        public object ESRI_AddFeatureClassFieldDefinition(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 2)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string          name = typedValue.Value.ToString();
                        MSCFeatureClass localFeatureClass = this.GetLocalFeatureClass(name);
                        if (localFeatureClass == null)
                        {
                            result = null;
                        }
                        else
                        {
                            string       text   = null;
                            string       strVal = null;
                            object       obj    = null;
                            object       obj2   = null;
                            object       obj3   = null;
                            object       obj4   = null;
                            TypedValue[] array2 = array;
                            for (int i = 0; i < array2.Length; i++)
                            {
                                TypedValue typedValue2 = array2[i];
                                if (typedValue2.TypeCode == 5016)
                                {
                                    obj3 = null;
                                    obj4 = null;
                                }
                                else if (typedValue2.TypeCode == 5017)
                                {
                                    obj3 = null;
                                    obj4 = null;
                                }
                                else if (typedValue2.TypeCode == 5018)
                                {
                                    if (obj3 != null && obj4 != null)
                                    {
                                        TypedValue typedValue3 = (TypedValue)obj3;
                                        TypedValue typedValue4 = (TypedValue)obj4;
                                        string     a           = typedValue3.Value.ToString();
                                        object     value       = typedValue4.Value;
                                        if (string.Equals(a, "NAME", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            text = value.ToString();
                                        }
                                        else if (string.Equals(a, "VALUE", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            obj = value.ToString();
                                        }
                                        else if (string.Equals(a, "TYPE", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            strVal = value.ToString();
                                        }
                                        else if (string.Equals(a, "LENGTH", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            string s = value.ToString();
                                            obj2 = short.Parse(s);
                                        }
                                    }
                                }
                                else if (obj3 == null)
                                {
                                    obj3 = typedValue2;
                                }
                                else
                                {
                                    obj4 = typedValue2;
                                }
                            }
                            if (string.IsNullOrEmpty(text))
                            {
                                result = null;
                            }
                            else
                            {
                                CadField cadField = FeatureClassAPI.FindField(localFeatureClass.Fields, text);
                                if (cadField != null)
                                {
                                    result = null;
                                }
                                else
                                {
                                    CadField cadField2 = new CadField();
                                    cadField2.Name = text;
                                    CadField.CadFieldType cadFieldType = CadField.FieldTypeCode(strVal);
                                    if (obj == null)
                                    {
                                        if (cadFieldType == CadField.CadFieldType.Double)
                                        {
                                            obj = 0.0;
                                        }
                                        if (cadFieldType == CadField.CadFieldType.Integer)
                                        {
                                            obj = 0;
                                        }
                                        if (cadFieldType == CadField.CadFieldType.Short)
                                        {
                                            obj = 0;
                                        }
                                        if (cadFieldType == CadField.CadFieldType.String)
                                        {
                                            obj = "";
                                        }
                                    }
                                    if (obj != null)
                                    {
                                        cadField2.Value = new TypedValue((int)cadFieldType, obj);
                                    }
                                    if (obj2 == null && cadFieldType == CadField.CadFieldType.String)
                                    {
                                        obj2 = 255;
                                    }
                                    if (obj2 != null)
                                    {
                                        short num = short.Parse(obj2.ToString());
                                        if (num > 0 && num < 256)
                                        {
                                            obj2 = num;
                                        }
                                        cadField2.Length = (short)obj2;
                                    }
                                    cadField2.ReadOnly  = false;
                                    cadField2.TypeField = false;
                                    cadField2.Visible   = true;
                                    localFeatureClass.Fields.Add(cadField2);
                                    localFeatureClass.Write(AfaDocData.ActiveDocData.Document);
                                    result = cadField2.Name;
                                }
                            }
                        }
                    }
                }
            }
            catch (SystemException)
            {
                result = null;
            }
            return(result);
        }
示例#5
0
        public object ESRI_GetFeatureClassFieldDefinition(ResultBuffer rb)
        {
            object result;

            try
            {
                TypedValue[] array = rb.AsArray();
                if (array.Count <TypedValue>() < 2)
                {
                    result = null;
                }
                else
                {
                    TypedValue typedValue = array[0];
                    if (typedValue.TypeCode != 5005)
                    {
                        result = null;
                    }
                    else
                    {
                        string name        = typedValue.Value.ToString();
                        string subtypeName = null;
                        if (array.Count <TypedValue>() == 3)
                        {
                            TypedValue typedValue2 = array[2];
                            if (typedValue2.TypeCode != 5005)
                            {
                                result = null;
                                return(result);
                            }
                            subtypeName = typedValue2.Value.ToString();
                        }
                        MSCFeatureClass featureClassOrService = this.GetFeatureClassOrService(name, subtypeName);
                        if (featureClassOrService == null)
                        {
                            result = null;
                        }
                        else
                        {
                            TypedValue typedValue3 = array[1];
                            if (typedValue3.TypeCode != 5005)
                            {
                                result = null;
                            }
                            else
                            {
                                string fieldName = typedValue3.Value.ToString();
                                if (featureClassOrService.Fields.Count == 0)
                                {
                                    result = null;
                                }
                                else
                                {
                                    CadField cadField = FeatureClassAPI.FindField(featureClassOrService.Fields, fieldName);
                                    if (cadField == null)
                                    {
                                        result = null;
                                    }
                                    else
                                    {
                                        List <TypedValue> list = new List <TypedValue>();
                                        list.Add(new TypedValue(5016, null));
                                        LspUtil.AppendDottedPair(ref list, 5005, "NAME", 5005, cadField.Name);
                                        LspUtil.AppendDottedPair(ref list, 5005, "TYPE", 5005, CadField.CodeString((int)cadField.FieldType));
                                        LspUtil.AppendDottedPair(ref list, 5005, "RO", 5003, cadField.ReadOnly);
                                        if (cadField.FieldType == CadField.CadFieldType.String)
                                        {
                                            LspUtil.AppendDottedPair(ref list, 5005, "LENGTH", 5003, cadField.Length);
                                        }
                                        LspUtil.AppendDottedPair(ref list, "VALUE", cadField.Value);
                                        list.Add(new TypedValue(5017, null));
                                        ResultBuffer resultBuffer = new ResultBuffer(list.ToArray());
                                        result = resultBuffer;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                result = null;
            }
            return(result);
        }