Ejemplo n.º 1
0
        public static List <BcdObject> ParseCollection(string data)
        {
            List <BcdObject> collection = new List <BcdObject>();
            BcdObject        obj        = new BcdObject();
            BcdProperty      previous   = new BcdProperty("---");

            try
            {
                foreach (string line in data.Split('\n'))
                {
                    if (line.Length > 1)
                    {
                        BcdProperty bps = new BcdProperty(line);
                        if (bps.IsNewObject)
                        {
                            if (!IsEmpty(obj))
                            {
                                collection.Add(obj);
                            }
                            obj          = new BcdObject();
                            obj.TypeName = bps.Title;
                        }
                        else
                        if (bps.EnumType == BcdItemTypeEnum.PropertyString)
                        {
                            if (bps.Key.Length > 0 && bps.Value.Length > 0)
                            {
                                obj.Properties[bps.Key] = bps.Value;
                                if (bps.IsCollection)
                                {
                                    obj.Properties[bps.Key] = new List <Guid>();
                                    ((List <Guid>)obj.Properties[bps.Key]).Add(new Guid(bps.Value));
                                    previous = bps;
                                }
                            }
                        }
                        else
                        if (bps.IsGuid && previous.IsCollection)
                        {
                            ((List <Guid>)obj.Properties[previous.Key]).Add(bps.GuidValue);
                        }
                    }
                }
                collection.Add(obj);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}\n{ex.StackTrace}\n{ex.InnerException}");
            }
            return(collection);
        }
Ejemplo n.º 2
0
        [STAThread] // required for Windows Forms
        public static void Main(string[] args)
        {
            try
            {
                string bcdInfo = Lib.GetPseudoCmdOutput("bcdedit /enum /v");
                var    objs    = BcdObject.ParseCollection(bcdInfo);

                Console.WriteLine($"{objs.Count} objects parsed");
                foreach (var obj in objs)
                {
                    Console.WriteLine(obj);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}\n{ex.StackTrace}");
            }
        }
Ejemplo n.º 3
0
 public static bool IsEmpty(BcdObject obj)
 {
     return(obj.Properties.Count == 0);
 }