예제 #1
0
        public void Update(IUsageProvider provider)
        {
/*			if (providerTasks == null)
 *                              return;
 *                      providerUsages [provider] = new List<DocumentLocation> (provider.Usages);
 *                      OnTaskProviderUpdated (EventArgs.Empty);*/
        }
예제 #2
0
 public void Update(IUsageProvider provider)
 {
     if (providerTasks == null)
     {
         return;
     }
     providerUsages [provider] = new List <Usage> (provider.Usages);
     OnTaskProviderUpdated(EventArgs.Empty);
 }
예제 #3
0
        public async Task Update(int year, int day, IEnumerable <Type> solvers, IUsageProvider usageProvider)
        {
            if (!System.Environment.GetEnvironmentVariables().Contains("SESSION"))
            {
                throw new Exception("Specify SESSION environment variable");
            }

            var cookieContainer = new CookieContainer();

            using (var client = new HttpClient(
                       new HttpClientHandler {
                CookieContainer = cookieContainer,
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            })
                   ) {
                var baseAddress = new Uri("https://adventofcode.com/");
                client.BaseAddress = baseAddress;
                cookieContainer.Add(baseAddress, new Cookie("session", System.Environment.GetEnvironmentVariable("SESSION")));

                var calendar = await DownloadCalendar(client, year);

                var problem = await DownloadProblem(client, year, day);

                var dir = Dir(year, day);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                // var years = Assembly.GetEntryAssembly().GetTypes()
                //     .Where(t => t.GetTypeInfo().IsClass && typeof(ISolver).IsAssignableFrom(t))
                //     .Select(tsolver => SolverExtensions.Year(tsolver));
                var years = solvers.Select(tsolver => SolverExtensions.Year(tsolver));

                if (years.Any())
                {
                    UpdateProjectReadme(years.Min(), years.Max(), usageProvider);
                }
                UpdateReadmeForYear(calendar);
                UpdateSplashScreen(calendar);
                UpdateReadmeForDay(problem);
                UpdateInput(problem);
                UpdateRefout(problem);
                UpdateSolutionTemplate(problem);
            }
        }
예제 #4
0
        public string Generate(int firstYear, int lastYear, IUsageProvider usageProvider)
        {
            return($@"
               > # Advent of Code ({firstYear}-{lastYear})
               > My C# solutions to the advent of code problems. (My solutions are in the ""solutions"" branch. The master branch contains the scaffolding).
               > Check out http://adventofcode.com.

               > ## Dependencies

               > - This library is built for `.Net Standard 2.0`. It should work on Windows, Linux and OS X.
               > - `Newtonsoft.Json` for JSON parsing
               > - `HtmlAgilityPack` is used for problem download.

               > ## Setting the session variable
               > The application depends on an environment variable. To get your identifier, you need to
               > look at the request headers for your daily data, and take the session identifier from
               > the cookie in the Request Headers (for example https://adventofcode.com/2018/day/1/input)

               > Then you can set it:

               > ```
               > Powershell: $Env:SESSION = {'"'}...{'"'}
               > 
               > Command Prompt: set SESSION = ...
               > ```

               > ## Running

               > To run the project:

               > 1. Install .NET Core
               > 2. Clone the repo
               > 3. Get help with `dotnet run`
               > ```
               > {usageProvider.Usage()}
               > ```
               > ".StripMargin("> "));
        }
예제 #5
0
        void UpdateProjectReadme(int firstYear, int lastYear, IUsageProvider usageProvider)
        {
            var file = Path.Combine("README.md");

            WriteFile(file, new ProjectReadmeGenerator().Generate(firstYear, lastYear, usageProvider));
        }
예제 #6
0
			public void AddUsageProvider (IUsageProvider p)
			{
				p.UsagesUpdated += (sender, e) => strip.Update (p);
			}
예제 #7
0
		public void AddUsageTaskProvider (IUsageProvider provider)
		{
			usageProvider.Add (provider);
			mainsw.AddUsageProvider (provider); 
			if (secondsw != null)
				secondsw.AddUsageProvider (provider);
		}
예제 #8
0
			public void AddUsageProvider (IUsageProvider p)
			{
				if (!strip.Visible) {
					strip.VAdjustment = scrolledWindow.Vadjustment;
					scrolledWindow.ReplaceVScrollBar (strip);
				}
				p.UsagesUpdated += (sender, e) => strip.Update (p);
			}
예제 #9
0
		public void Update (IUsageProvider provider)
		{
			if (providerTasks == null)
				return;
			providerUsages [provider] = new List<Usage> (provider.Usages);
			OnTaskProviderUpdated (EventArgs.Empty);
		}
예제 #10
0
		public void Update (IUsageProvider provider)
		{
/*			if (providerTasks == null)
				return;
			providerUsages [provider] = new List<DocumentLocation> (provider.Usages);
			OnTaskProviderUpdated (EventArgs.Empty);*/
		}
예제 #11
0
 public ConsoleWriter(TextWriter writer, IUsageProvider usageProvider)
 {
     this.writer        = writer;
     this.usageProvider = usageProvider;
 }
예제 #12
0
 public ConsoleWriter(IUsageProvider usageProvider) : this(Console.Out, usageProvider)
 {
 }