Пример #1
0
 public Sandbox(SandboxDescriptor desc, List <ComponentDescriptor> comps)
 {
     Descriptor = desc;
     if (comps != null)
     {
         this.comps = comps.ToDictionary(x => x.ID, y => y);
     }
 }
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    Console.WriteLine("Would you like to register .sandbox files for this .exe? (y/n)");

                    if (Console.ReadLine().ToLower() == "y")
                    {
                        FileAssociations.EnsureAssociationsSet(new FileAssociation()
                        {
                            ExecutableFilePath  = Assembly.GetExecutingAssembly().Location,
                            Extension           = ".sandbox",
                            FileTypeDescription = "WSB Wrapper",
                            ProgId = "LR_Sandbox"
                        });
                        Console.WriteLine("Done");
                        Console.ReadLine();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    SandboxDescriptor sandbox = JsonConvert.DeserializeObject <SandboxDescriptor>(File.ReadAllText(args[0]));

                    List <ComponentDescriptor> comps = ComponentDescriptor.GetDescriptors();


                    Sandbox box = new Sandbox(sandbox, comps);

                    box.Prepare();

                    box.Run();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:" + ex.Message);
                Console.WriteLine("Stacktrace:" + ex.StackTrace);
                Console.ReadLine();
            }
        }