Example #1
0
        static void Main(string[] args)
        {
            string filename = @"config.plist";

            if (args.Length > 0)
            {
                filename = args[0];
            }
            if (args.Length > 1)
            {
                isMaskValue = false;
            }

            if (!File.Exists(filename))
            {
                Console.WriteLine("File not Found . {0}", filename);
                Environment.Exit(0);
            }

            Data.PList plist = new Data.PList();
            plist.Load(filename);

            Console.WriteLine("plist file = {0}", filename);
            PrintPList(plist);
        }
Example #2
0
        static public void PrintPList(Data.PList plist, int level = 0)
        {
            if (plist.Count == 0)
            {
                PrintIndent(level);
                Console.WriteLine("{0}", "{ }");
                return;
            }

            PrintIndent(level);
            Console.WriteLine("{0}", "{");
            ++level;

            foreach (KeyValuePair <string, dynamic> kvp in plist)
            {
                if (kvp.Value is Data.PList)
                {
                    PrintIndent(level);
                    Console.WriteLine("{0}", kvp.Key);
                    PrintPList(kvp.Value, level);
                    continue;
                }

                if (kvp.Value is List <dynamic> )
                {
                    PrintIndent(level);
                    Console.WriteLine("{0}", kvp.Key);
                    if (kvp.Value.Count == 0)
                    {
                        PrintIndent(level);
                        Console.WriteLine("{0}", "[ ]");
                        continue;
                    }

                    PrintIndent(level);
                    Console.WriteLine("{0}", "[");
                    foreach (dynamic item in kvp.Value)
                    {
                        if (item is Data.PList)
                        {
                            PrintPList(item, level + 1);
                            continue;
                        }

                        PrintIndent(level + 1);
                        Console.WriteLine("{0}", item);
                    }
                    PrintIndent(level);
                    Console.WriteLine("{0}", "]");
                    continue;
                }

                string value = "";
                if (kvp.Value is string)
                {
                    value = '"' + kvp.Value + '"';
                }
                else
                if (kvp.Value is bool)
                {
                    value = kvp.Value ? "true" : "false";
                }
                else
                if (kvp.Value is byte[])
                {
                    foreach (byte b in kvp.Value)
                    {
                        value += string.Format("{0:X2}", b);
                    }
                    value += " (";
                    value += Convert.ToBase64String(kvp.Value);
                    value += ")";
                }
                else
                {
                    PrintIndent(level);
                    Console.WriteLine("{0} = {1}", kvp.Key, kvp.Value);
                    continue;
                }

                if (isMaskValue)
                {
                    if (maskKeyList.Contains(kvp.Key))
                    {
                        value = "/** masked **/";
                    }
                }

                PrintIndent(level);
                Console.WriteLine("{0} = {1}", kvp.Key, value);
            }

            --level;
            PrintIndent(level);
            Console.WriteLine("{0}", "}");
        }