示例#1
0
        public static List <String> GetProperties <T> (T inputType, EnumHelper.QueryType input)
        {
            String        itemQuery    = String.Empty;
            List <String> propertyList = new List <string>();

            try
            {
                PropertyDescriptorCollection properties =
                    TypeDescriptor.GetProperties(typeof(T));

                foreach (PropertyDescriptor prop in properties)
                {
                    // wmiitems.Add(prop.DisplayName);

                    if (input == EnumHelper.QueryType.Database)
                    {
                        propertyList.Add(prop.DisplayName);
                    }

                    else if (input == EnumHelper.QueryType.WMI)
                    {
                        propertyList.Add(prop.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(propertyList);
        }
示例#2
0
        public static String GetQuery <T> (T inputType, EnumHelper.QueryType input, String precedString = "")
        {
            String        itemQuery  = String.Empty;
            List <String> tempString = new List <string>();

            try
            {
                PropertyDescriptorCollection properties =
                    TypeDescriptor.GetProperties(typeof(T));

                foreach (PropertyDescriptor prop in properties)
                {
                    // wmiitems.Add(prop.DisplayName);

                    if (input == EnumHelper.QueryType.Database)
                    {
                        tempString.Add(precedString + prop.DisplayName);
                    }

                    else if (input == EnumHelper.QueryType.WMI)
                    {
                        tempString.Add(precedString + prop.Name);
                    }
                }

                foreach (var item in  typeof(T).GetFields())
                {
                    if (input == EnumHelper.QueryType.Database)
                    {
                        tempString.Add(precedString + item.Name);
                    }
                }

                if (String.IsNullOrEmpty(precedString))
                {
                    itemQuery = String.Join(",", tempString.ToArray());
                }

                else
                {
                    itemQuery = String.Join(",", tempString.ToArray());
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(itemQuery);
        }
示例#3
0
        public static List <String> GetFields <T> (T inputType, EnumHelper.QueryType input)
        {
            String        itemQuery    = String.Empty;
            List <String> propertyList = new List <string>();

            try
            {
                foreach (var prop in typeof(T).GetFields())
                {
                    // wmiitems.Add(prop.DisplayName);

                    if (input == EnumHelper.QueryType.Database)
                    {
                        propertyList.Add(prop.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(propertyList);
        }