Example #1
0
        public static string GetAttrValue(Snap.NX.NXObject nxObject, string title)
        {
            string result = string.Empty;

            if (nxObject.GetAttributeInfo().Where(u => u.Title == title).Count() > 0)
            {
                var attr = nxObject.GetAttributeInfo().FirstOrDefault(u => u.Title == title);
                switch (attr.Type)
                {
                case Snap.NX.NXObject.AttributeType.Integer:
                {
                    result = nxObject.GetIntegerAttribute(title).ToString();
                    break;
                }

                case Snap.NX.NXObject.AttributeType.Real:
                {
                    result = nxObject.GetRealAttribute(title).ToString();
                    break;
                }

                case Snap.NX.NXObject.AttributeType.String:
                {
                    result = nxObject.GetStringAttribute(title);
                    break;
                }
                }
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// 获取属性值
        /// </summary>
        public static string GetAttrValue(this Snap.NX.NXObject nxObject, string title)
        {
            string result = string.Empty;

            if (nxObject.IsHasAttr(title))
            {
                var attr = nxObject.GetAttributeInfo().FirstOrDefault(u => u.Title.ToUpper() == title.ToUpper());
                title = attr.Title;
                switch (attr.Type)
                {
                case Snap.NX.NXObject.AttributeType.Integer:
                {
                    result = nxObject.GetIntegerAttribute(title).ToString();
                    break;
                }

                case Snap.NX.NXObject.AttributeType.Real:
                {
                    result = nxObject.GetRealAttribute(title).ToString();
                    break;
                }

                case Snap.NX.NXObject.AttributeType.String:
                {
                    result = nxObject.GetStringAttribute(title);
                    break;
                }
                }
            }
            return(result);
        }
Example #3
0
        private static string GetStringAttribute(Snap.NX.NXObject obj, string title)
        {
            var list = obj.GetAttributeInfo().Where(u => u.Title == title && u.Type == Snap.NX.NXObject.AttributeType.String).ToList();

            if (list.Count > 0)
            {
                return(obj.GetStringAttribute(title));
            }
            return(string.Empty);
        }
Example #4
0
 /// <summary>
 /// 是否有该属性
 /// </summary>
 public static bool IsHasAttr(this Snap.NX.NXObject obj, string title)
 {
     return(obj.GetAttributeInfo().Where(m => m.Title.ToUpper() == title.ToUpper()).Count() > 0);
 }