示例#1
0
        private ObjectTypes?ObjectTypeOf(IXenObject o)
        {
            PropertyAccessor pa  = PropertyAccessors.Get(PropertyNames.type);
            Object           obj = pa(o);

            return((ObjectTypes?)obj);
        }
示例#2
0
        public override GridItemBase GetGridItem(IXenObject o)
        {
            if (o is Folder)
            {
                return(NewStringItem(String.Empty));  // CA-28300.5
            }
            GridItemBase item;

            if (CheckVMTools(o, out item))
            {
                return(item);
            }

            if (PropertyAccessors.Get(property)(o) == null)
            {
                return(NewStringItem(new PropertyWrapper(textProperty, o)));
            }

            return(NewBarItem(
                       new PropertyWrapper(textProperty, o),
                       new ImageDelegate(delegate()
            {
                int?i = (int?)PropertyAccessors.Get(rankProperty)(o);
                if (i == null)
                {
                    return null;
                }

                return HelpersGUI.GetProgressImage(i.Value);
            })));
        }
示例#3
0
        public PropertyGrouping(XmlNode node)
            : base(node)
        {
            this.property         = (PropertyNames)Enum.Parse(typeof(PropertyNames), Helpers.GetXmlAttribute(node, "property"));
            this.propertyAccessor = PropertyAccessors.Get(property);

            this.i18n   = PropertyAccessors.PropertyNames_i18n[property];
            this.i18ns  = Invert((Dictionary <String, T>)PropertyAccessors.Geti18nFor(property));
            this.images = (ImageDelegate <T>)PropertyAccessors.GetImagesFor(property);
        }
示例#4
0
        public PropertyGrouping(PropertyNames property, Grouping subgrouping)
            : base(subgrouping)
        {
            this.property         = property;
            this.propertyAccessor = PropertyAccessors.Get(property);

            this.i18n   = PropertyAccessors.PropertyNames_i18n[property];
            this.i18ns  = Invert((Dictionary <String, T>)PropertyAccessors.Geti18nFor(property));
            this.images = (ImageDelegate <T>)PropertyAccessors.GetImagesFor(property);
        }
示例#5
0
        private PropertyAccessor CalcProperty()
        {
            if (column.StartsWith(CustomFieldsManager.CUSTOM_FIELD))
            {
                string fieldName = column.Substring(CustomFieldsManager.CUSTOM_FIELD.Length);
                CustomFieldDefinition customFieldDefinition = CustomFieldsManager.GetCustomFieldDefinition(fieldName);
                if (customFieldDefinition == null)  // a custom field that existed at the time the search was created but no longer exists
                {
                    return(o => null);
                }

                if (customFieldDefinition.Type == CustomFieldDefinition.Types.Date)
                {
                    return(delegate(IXenObject o)
                    {
                        object val = CustomFieldsManager.GetCustomFieldValue(o, customFieldDefinition);
                        return (DateTime?)(val is DateTime ? val : null);
                    });
                }
                else
                {
                    return(delegate(IXenObject o)
                    {
                        object val = CustomFieldsManager.GetCustomFieldValue(o, customFieldDefinition);
                        return val == null ? null : val.ToString();
                    });
                }
            }

            ColumnNames c;

            try
            {
                c = (ColumnNames)Enum.Parse(typeof(ColumnNames), column);
            }
            catch (ArgumentException)
            {
                return(null);
            }
            PropertyNames propertyName = PropertyAccessors.GetSortPropertyName(c);

            return(PropertyAccessors.Get(propertyName));
        }
示例#6
0
        private static Type GetType(XmlNode node)
        {
            Type type;

            if (subclasses.ContainsKey(node.Name))
            {
                type = subclasses[node.Name];
            }
            else
            {
                type = Type.GetType(node.Name, true);
            }

            if (!type.IsGenericType)
            {
                return(type);
            }

            Type genericType = PropertyAccessors.GetType(GetPropertyNames(node));

            return(type.MakeGenericType(genericType));
        }
示例#7
0
 protected PropertyQuery(XmlNode node, bool nullProtect)
 {
     this.property         = (PropertyNames)Enum.Parse(typeof(PropertyNames), Helpers.GetXmlAttribute(node, "property"));
     this.propertyAccessor = PropertyAccessors.Get(property);
     this.nullProtect      = nullProtect;
 }
示例#8
0
 protected PropertyQuery(PropertyNames property, bool nullProtect)
 {
     this.property         = property;
     this.propertyAccessor = PropertyAccessors.Get(property);
     this.nullProtect      = nullProtect;
 }
示例#9
0
文件: Common.cs 项目: ywscr/xenadmin
 public PropertyWrapper(PropertyNames property, IXenObject o)
 {
     this.property = PropertyAccessors.Get(property);
     this.o        = o;
 }