Example #1
0
        static void Main(string[] args)
        {
            if (Sanitize(args, out var requestedFolder))
            {
                return;
            }

            var bus               = new InMemoryPubSub();
            var fileHandlers      = new ConcurrentDictionary <string, List <Type> >();
            var assemblyValidator = new AssemblyValidator(bus);
            var dllLoader         = new NewFileTypeSubscriber(fileHandlers);

            var fileManager = new Manager(fileHandlers);

            bus.Subscribe(assemblyValidator);
            bus.Subscribe(dllLoader);
            bus.Subscribe(fileManager);
            var fileSystemWatcher = new FileWatcherManager(requestedFolder, bus);
            var startables        = new List <IStartableService> {
                fileSystemWatcher
            };

            startables.ForEach(x => x.Start());

            Task.Run(function: () =>
            {
                Console.WriteLine("Listening for Dlls or files to parse...");
                while (true)
                {
                }
            }).Wait();
        }
        public void Should_remove_if_invalidated()
        {
            var anotherPubsub = new InMemoryPubSub();
            var anotherSut    = new InvalidatingMemoryCache(new MemoryCache(new MyOptions <MemoryCacheOptions>(new MemoryCacheOptions())), anotherPubsub);

            anotherSut.Set("a-key", 123);

            Assert.Equal(123, anotherSut.Get <int>("a-key"));

            anotherPubsub.Publish("CacheInvalidations", "a-key", true);

            Assert.Equal(0, anotherSut.Get <int>("a-key"));
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine(FizzBuzz.SomeFizzBuzz());
            Console.WriteLine(FizzBuzz.MoreFizzBuzz(1, 30, new FizzBuzzSubstitution[]{
                new FizzBuzzSubstitution{ Modulus = 4, Substitution = "Hello"},
                new FizzBuzzSubstitution{ Modulus = 7, Substitution = "World"},
                new FizzBuzzSubstitution{ Modulus = 8, Substitution = "!"}
            }));

            var searchResults = MethodSearch.FromDirectory();

            var pubsub = new InMemoryPubSub();

            var switchboard = new MethodSwitchboard(pubsub.Publish);
            foreach(var entry in searchResults.GetMethodDescriptions())
            {
                switchboard.Load(entry.Key, entry.Value.GetMethodInfo());
            }

            Console.WriteLine(switchboard.CallMethodAsync("FizzBuzz", new string[] { "1", "100", "3", "\"FIZZ\"", "5", "\"BUZZ\"" }).Result.SuccessData);

            Console.ReadLine();
        }