Beispiel #1
0
 //Полчучаем значение атрибута
 public static string GetAttributeValue(this IgObject gobj, string attrname)
 {
     if (gobj == null)
     {
         throw new ArgumentNullException($" Объект {gobj.Tagname} не существует или NULL");
     }
     if (string.IsNullOrWhiteSpace(attrname))
     {
         throw new Exception($"Имя атрибута {nameof(attrname)} не может быть пустым");
     }
     if (gobj.IsExistAttribute(attrname))
     {
         var attrs = gobj.GetAttributesAny();
         return(attrs[attrname]?.value?.GetString());
     }
     else
     {
         return(null);
     }
 }
Beispiel #2
0
        //Получить тип
        // если вернулось MxNoData - значит атрибута не существует
        // TODO: проверить нужен ли check out
        public static MxDataType GetAttributeMxDataType(this IgObject gobj, string attrname)
        {
            if (gobj == null)
            {
                throw new ArgumentNullException($" Объект {gobj.Tagname} не существует или NULL");
            }
            if (string.IsNullOrWhiteSpace(attrname))
            {
                throw new Exception($"Имя атрибута {nameof(attrname)} не может быть пустым");
            }
            MxDataType type = MxDataType.MxNoData;

            gobj.CheckOutWithCheckStatus();
            if (gobj.IsExistAttribute(attrname))
            {
                type = gobj.ConfigurableAttributes[attrname].DataType;
                gobj.SaveAndCheckIn($"Получение типа атрибута {attrname} для объекта {gobj}.");
            }
            else
            {
                throw new AttributeNullReferenceException();
            }
            return(type);
        }