Пример #1
0
 private TightDecoder()
 {
     Streams = new Inflator[4];
     for (var i = 0; i < 4; i++)
     {
         Streams[i] = new Inflator();
     }
 }
Пример #2
0
        public void EmptyNotificationsThrowsError()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "C:/test" },
            };
            Inflator inflator = new Inflator();

            Assert.Throws <ArgumentException>(() => _ = inflator.CreateFromComponent(headers, false, this.serviceProvider));
        }
Пример #3
0
        public void ActivateFromThrows()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "test" }
            };

            Slack.Inflator inflator = new Inflator();
            Assert.Throws <NotImplementedException>(() => { inflator.CreateFromComponent(headers, false); });
        }
Пример #4
0
        public void EmptyTargetThrowsError()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Notifications", "Changed" },
            };
            Inflator inflator = new Inflator();

            Assert.Throws <ArgumentException>(() => _ = inflator.CreateFromComponent(headers, false));
        }
Пример #5
0
        public void ActivateAtomicThrows()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "test" },
                { "MessageSource", "Body" }
            };

            Slack.Inflator inflator = new Inflator();
            Assert.Throws <NotImplementedException>(() => { inflator.CreateAtomicComponent(headers); });
        }
Пример #6
0
        public void ActivateToWorks()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "test" },
                { "MessageSource", "Body" }
            };

            Slack.Inflator inflator = new Inflator();
            Assert.NotNull(inflator.CreateToComponent(headers));
        }
Пример #7
0
        public void CanGetTo()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "test/target" },
                { "Action", "Move" },
                { "Overwrite", "true" }
            };

            Inflator inflator = new Inflator();

            Assert.NotNull(inflator.CreateToComponent(headers, this.serviceProvider));
        }
Пример #8
0
        public void CanGetFrom()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>()
            {
                { "Target", "test/" },
                { "Notifications", "Created" },
                { "Filter", "*.tdd" },
                { "SubDirectories", "true" }
            };
            Inflator inflator = new Inflator();

            Assert.NotNull(inflator.CreateFromComponent(headers, false, this.serviceProvider));
        }
Пример #9
0
        public IServiceCollection GetServiceDescriptors()
        {
            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.AddTransient <ILogger <Kyameru.Route> >(sp =>
            {
                return(this.logger.Object);
            });

            Inflator inflator = new Inflator();

            inflator.RegisterFrom(serviceDescriptors);
            inflator.RegisterTo(serviceDescriptors);

            return(serviceDescriptors);
        }
Пример #10
0
        private IServiceCollection GetServiceDescriptors(bool tryFrom = false)
        {
            IServiceCollection serviceDescriptors = new ServiceCollection();

            serviceDescriptors.AddTransient <ILogger <Kyameru.Route> >(sp =>
            {
                return(this.logger.Object);
            });

            Inflator inflator = new Inflator();

            inflator.RegisterTo(serviceDescriptors);
            if (tryFrom)
            {
                inflator.RegisterFrom(serviceDescriptors);
            }

            return(serviceDescriptors);
        }
Пример #11
0
        public static int Main(string[] args)
        {
            try
            {
                ProcessArgs(args);

                // Force-allow TLS 1.2 for HTTPS URLs, because GitHub requires it.
                // This is on by default in .NET 4.6, but not in 4.5.
                ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

                // If we see the --version flag, then display our build info
                // and exit.
                if (Options.Version)
                {
                    Console.WriteLine(Meta.GetVersion(VersionFormat.Full));
                    return(ExitOk);
                }

                if (!string.IsNullOrEmpty(Options.ValidateCkan))
                {
                    var ckan = new Metadata(JObject.Parse(File.ReadAllText(Options.ValidateCkan)));
                    var inf  = new Inflator(
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    inf.ValidateCkan(ckan);
                    Console.WriteLine(QueueHandler.serializeCkan(
                                          new PropertySortTransformer().Transform(ckan, null).First()
                                          ));
                    return(ExitOk);
                }

                if (!string.IsNullOrEmpty(Options.Queues))
                {
                    var queues = Options.Queues.Split(new char[] { ',' }, 2);
                    var qh     = new QueueHandler(
                        queues[0],
                        queues[1],
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    qh.Process();
                    return(ExitOk);
                }

                if (Options.File != null)
                {
                    Log.InfoFormat("Transforming {0}", Options.File);

                    var netkan = ReadNetkan();
                    Log.Info("Finished reading input");

                    var inf = new Inflator(
                        Options.CacheDir,
                        Options.OverwriteCache,
                        Options.GitHubToken,
                        Options.PreRelease
                        );
                    var ckans = inf.Inflate(Options.File, netkan, ParseReleases(Options.Releases));
                    foreach (Metadata ckan in ckans)
                    {
                        WriteCkan(ckan);
                    }
                }
                else
                {
                    Log.Fatal(
                        "Usage: netkan [--verbose|--debug] [--debugger] [--prerelease] [--outputdir=...] <filename>"
                        );
                    return(ExitBadOpt);
                }
            }
            catch (Exception e)
            {
                e = e.GetBaseException() ?? e;

                Log.Fatal(e.Message);

                if (Options == null || Options.Debug)
                {
                    Log.Fatal(e.StackTrace);
                }

                return(ExitError);
            }

            return(ExitOk);
        }
Пример #12
0
        public void AtomicThrows()
        {
            Inflator inflator = new Inflator();

            Assert.Throws <NotImplementedException>(() => inflator.CreateAtomicComponent(null));
        }