Example #1
0
        static void VA(WMISubject sub)
        {
            Strobarried s = new Strobarried(new WMIProvider(sub));
            var         v = Strobarried.Validate(s);

            if (v != Strobarried.Evaluation.True)
            {
                Environment.Exit(-1);
            }
        }
Example #2
0
        internal virtual void SetSubject(WMISubject subject)
        {
            var q = new ManagementObjectSearcher($"select * from {subject}")
                    .Get()
                    .Cast <ManagementObject>()
                    ?.FirstOrDefault();

            if (q == null)
            {
                throw new NotSupportedException(subject.ToString());
            }
            this.wmi = q
                       .Properties
                       .Cast <PropertyData>()
                       .Where(x => x.Value != null)
                       .Aggregate(new Dictionary <string, string>(), (x, item) =>
            {
                x.Add(item.Name, (item.Value is IEnumerable & !(item.Value is string))
                      ? $"{string.Join(", ", (item.Value as IEnumerable).Cast<object>())}"
                      : item.Value.ToString());
                return(x);
            });
        }
Example #3
0
 public WMIProvider(WMISubject subject)
 {
     this.SetSubject(this.Subject = subject);
 }