コード例 #1
0
 public FilterableOperators()
 {
     Strings = new StringOperators();
     Numbers = new NumberOperators();
     Dates = new DateOperators();
     Enums = new EnumOperators();
 }
コード例 #2
0
        public FilterBaseModel()
        {
            var defaultStringOperators = StringOperators.First();

            var defaultDateOperators = NumericOprators.First();

            var defaultNumericOperators = NumericOprators.First(item => item.Equals("=="));

            TraceKey = TraceKey ?? new FilterElements {
                Operator = defaultStringOperators
            };

            //SystemTime = SystemTime ?? new FilterElements { Operator = defaultDateOperators, Operand = System.DateTime.Now.ToString("G") };
            StartDate = StartDate ?? new FilterElements {
                Operator = defaultDateOperators, Operand = System.DateTime.Now.AddMinutes(-5).ToString("G")
            };

            EndDate = EndDate ?? new FilterElements {
                Operator = NumericOprators.First(item => item.Equals("<")), Operand = System.DateTime.Now.AddDays(1).ToString("G")
            };

            Message = Message ?? new FilterElements {
                Operator = defaultStringOperators
            };

            Level = Level ?? new FilterElements {
                Operator = defaultNumericOperators
            };

            Writer = Writer ?? new FilterElements {
                Operator = defaultStringOperators
            };

            Data = new List <KeyValuePair <string, FilterElements> >();
        }
コード例 #3
0
        public void DecodeHex()
        {
            StringOperators.DecodeHex(null).Should().BeNull();
            StringOperators.DecodeHex("").Should().Be("");
            StringOperators.DecodeHex("45776f7574").Should().Be("Ewout");
            StringOperators.DecodeHex("e7bc96e7a081e696b9e5bc8f").Should().Be("编码方式");

            StringOperators.FpDecode("45776f7574", "hex").Should().Be("Ewout");
        }
コード例 #4
0
        public void UnknownEncoding()
        {
            Action act = () => StringOperators.FpEncode("Ewout", "reverse_polish");

            act.Should().Throw <ArgumentException>().Which.Message.StartsWith("Unknown encoding 'reverse_polish'.");

            act = () => StringOperators.FpDecode("Ewout", "reverse_polish");
            act.Should().Throw <ArgumentException>().Which.Message.StartsWith("Unknown encoding 'reverse_polish'.");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            while (!exit)
            {
                MainMenu();

                string choiceString = Console.ReadLine();
                int    intChoice;
                string txtFile;

                //Verifies the user input to make sure that they are inputing a number integer option.3
                while (!int.TryParse(choiceString, out intChoice))
                {
                    Console.Clear();
                    MainMenu();
                    Console.WriteLine("Please enter a valid number.");
                    choiceString = Console.ReadLine();
                }

                switch (intChoice)
                {
                case 1:
                    //Retrieves the text file input from the ReadFile method and puts it in the txtFile string.
                    txtFile = ReadFile();

                    if (txtFile != null)
                    {
                        Console.Clear();
                        Console.WriteLine(txtFile);
                        Console.WriteLine("The text file has {0} words.", StringOperators.WordCount(txtFile));
                        Console.WriteLine("The text file has {0} vowels", StringOperators.CharCount(txtFile, true));
                        Console.WriteLine("The text file has a string value of {0}", StringOperators.CharCount(txtFile, false));
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                    }
                    break;

                case 2:
                    //Creates an empty text file in user designated path and validates the path
                    CreateFile();
                    break;

                case 3:
                    //Exits the program
                    Console.Clear();
                    exit = true;
                    break;

                default:
                    //By default, will return to the beginingof the loop, most likely due to incorrect option being selected.
                    Console.Clear();
                    Console.WriteLine("Please enter a valid choice of 1, 2, or 3.");
                    Console.ReadKey();
                    break;
                }
            }
        }
コード例 #6
0
        public void UnknownEscape()
        {
            Action act = () => StringOperators.FpEscape("Ewout", "reverse_polish");

            act.Should().Throw <ArgumentException>().Which.Message.StartsWith("Unknown escaping method 'reverse_polish'.");

            act = () => StringOperators.FpUnescape("Ewout", "reverse_polish");
            act.Should().Throw <ArgumentException>().Which.Message.StartsWith("Unknown escaping method 'reverse_polish'.");
        }
コード例 #7
0
        public int Execute(string[] commandLineArguments)
        {
            options.Parse(commandLineArguments);

            if (StringOperators.IsNullOrWhiteSpace(signatureFilePath))
            {
                throw new OptionException("No signature file was specified", "new-file");
            }
            if (StringOperators.IsNullOrWhiteSpace(newFilePath))
            {
                throw new OptionException("No new file was specified", "new-file");
            }

            newFilePath       = Path.GetFullPath(newFilePath);
            signatureFilePath = Path.GetFullPath(signatureFilePath);

            var delta = new DeltaBuilder();

            foreach (var config in configuration)
            {
                config(delta);
            }

            if (!File.Exists(signatureFilePath))
            {
                throw new FileNotFoundException("File not found: " + signatureFilePath, signatureFilePath);
            }

            if (!File.Exists(newFilePath))
            {
                throw new FileNotFoundException("File not found: " + newFilePath, newFilePath);
            }

            if (StringOperators.IsNullOrWhiteSpace(deltaFilePath))
            {
                deltaFilePath = newFilePath + ".octodelta";
            }
            else
            {
                deltaFilePath = Path.GetFullPath(deltaFilePath);
                var directory = Path.GetDirectoryName(deltaFilePath);
                if (directory != null && !Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
            }

            using (var newFileStream = new FileStream(newFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var signatureStream = new FileStream(signatureFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var deltaStream = new FileStream(deltaFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                    {
                        delta.BuildDelta(newFileStream, new SignatureReader(signatureStream, delta.ProgressReporter), new AggregateCopyOperationsDecorator(new BinaryDeltaWriter(deltaStream)));
                    }

            return(0);
        }
コード例 #8
0
        public void DecodeBase64()
        {
            StringOperators.DecodeBase64(null).Should().BeNull();
            StringOperators.DecodeBase64("").Should().Be("");
            StringOperators.DecodeBase64("RXdvdXQ=").Should().Be("Ewout");
            StringOperators.DecodeBase64("RXdvdXQ+").Should().Be("Ewout>");
            StringOperators.DecodeBase64("57yW56CB5pa55byP").Should().Be("编码方式");

            StringOperators.FpDecode("RXdvdXQ=", "base64").Should().Be("Ewout");
        }
コード例 #9
0
 public PivotFieldMenuMessages()
 {
     Info = Messages.PivotFieldMenu_Info;
     FilterFields = Messages.PivotFieldMenu_FilterFields;
     Filter = Messages.PivotFieldMenu_Filter;
     Include = Messages.PivotFieldMenu_Include;
     Title = Messages.PivotFieldMenu_Title;
     Clear = Messages.PivotFieldMenu_Clear;
     Ok = Messages.PivotFieldMenu_Ok;
     Cancel = Messages.PivotFieldMenu_Cancel;
     Operators = new StringOperators();
 }
コード例 #10
0
        public void EncodeBase64Url()
        {
            StringOperators.EncodeUrlBase64(null).Should().BeNull();
            StringOperators.EncodeUrlBase64("").Should().Be("");
            //            StringOperators.EncodeUrlBase64("Ewout").Should().Be("RXdvdXQ");
            StringOperators.EncodeUrlBase64("Ewout").Should().Be("RXdvdXQ=");
            StringOperators.EncodeUrlBase64("Ewout>").Should().Be("RXdvdXQ-");
            StringOperators.EncodeUrlBase64("编码方式").Should().Be("57yW56CB5pa55byP");

            StringOperators.FpEncode("Ewout", "urlbase64").Should().Be("RXdvdXQ=");
            //StringOperators.FpEncode("Ewout", "urlbase64").Should().Be("RXdvdXQ");
        }
コード例 #11
0
        void PrintCommandHelp(string executable, ICommand command, ICommandMetadata commandMetadata, string commandName)
        {
            //Console.ResetColor();
            Console.Write("Usage: ");
            //Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(executable + " " + commandName + (!StringOperators.IsNullOrWhiteSpace(commandMetadata.Usage) ? " " + commandMetadata.Usage : "") + " [<options>]");
            // Console.ResetColor();
            Console.WriteLine();
            command.GetHelp(Console.Out);

            Console.WriteLine();
        }
コード例 #12
0
        public int Execute(string[] commandLineArguments)
        {
            options.Parse(commandLineArguments);

            if (StringOperators.IsNullOrWhiteSpace(basisFilePath))
            {
                throw new OptionException("No basis file was specified", "basis-file");
            }
            if (StringOperators.IsNullOrWhiteSpace(deltaFilePath))
            {
                throw new OptionException("No delta file was specified", "delta-file");
            }
            if (StringOperators.IsNullOrWhiteSpace(newFilePath))
            {
                throw new OptionException("No new file was specified", "new-file");
            }

            basisFilePath = Path.GetFullPath(basisFilePath);
            deltaFilePath = Path.GetFullPath(deltaFilePath);
            newFilePath   = Path.GetFullPath(newFilePath);

            if (!File.Exists(basisFilePath))
            {
                throw new FileNotFoundException("File not found: " + basisFilePath, basisFilePath);
            }
            if (!File.Exists(deltaFilePath))
            {
                throw new FileNotFoundException("File not found: " + deltaFilePath, deltaFilePath);
            }

            var directory = Path.GetDirectoryName(newFilePath);

            if (directory != null && !Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var delta = new DeltaApplier
            {
                SkipHashCheck = skipHashCheck
            };

            using (var basisStream = new FileStream(basisFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var deltaStream = new FileStream(deltaFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var newFileStream = new FileStream(newFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
                    {
                        delta.Apply(basisStream, new BinaryDeltaReader(deltaStream, progressReporter), newFileStream);
                    }

            return(0);
        }
コード例 #13
0
        public int Execute(string[] commandLineArguments)
        {
            options.Parse(commandLineArguments);

            if (StringOperators.IsNullOrWhiteSpace(basisFilePath))
            {
                throw new OptionException("No basis file was specified", "basis-file");
            }

            basisFilePath = Path.GetFullPath(basisFilePath);

            var signatureBuilder = new SignatureBuilder();

            foreach (var config in configuration)
            {
                config(signatureBuilder);
            }

            if (!File.Exists(basisFilePath))
            {
                throw new FileNotFoundException("File not found: " + basisFilePath, basisFilePath);
            }

            if (StringOperators.IsNullOrWhiteSpace(signatureFilePath))
            {
                signatureFilePath = basisFilePath + ".octosig";
            }
            else
            {
                signatureFilePath = Path.GetFullPath(signatureFilePath);
                var sigDirectory = Path.GetDirectoryName(signatureFilePath);
                if (sigDirectory != null && !Directory.Exists(sigDirectory))
                {
                    Directory.CreateDirectory(sigDirectory);
                }
            }

            using (var basisStream = new FileStream(basisFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var signatureStream = new FileStream(signatureFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    signatureBuilder.Build(basisStream, new SignatureWriter(signatureStream));
                }

            return(0);
        }
コード例 #14
0
        public int Execute(string[] commandLineArguments)
        {
            options.Parse(commandLineArguments);

            if (StringOperators.IsNullOrWhiteSpace(deltaFilePath))
            {
                throw new OptionException("No delta file was specified", "delta-file");
            }

            deltaFilePath = Path.GetFullPath(deltaFilePath);

            if (!File.Exists(deltaFilePath))
            {
                throw new FileNotFoundException("File not found: " + deltaFilePath, deltaFilePath);
            }

            using (var deltaStream = new FileStream(deltaFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var reader = new BinaryDeltaReader(deltaStream, new NullProgressReporter());

                reader.Apply(data =>
                {
                    if (data.Length > 20)
                    {
                        Console.WriteLine("Data: ({0} bytes): {1}...", data.Length,
                                          BitConverter.ToString(data.Take(20).ToArray()));
                    }
                    else
                    {
                        Console.WriteLine("Data: ({0} bytes): {1}", data.Length, BitConverter.ToString(data.ToArray()));
                    }
                },
                             (start, offset) => Console.WriteLine("Copy: {0:X} to {1:X}", start, offset));
            }

            return(0);
        }
コード例 #15
0
 public StringOperatorsBuilder(StringOperators operators)
 {
     this.strings = operators;
 }
コード例 #16
0
        public void EscapeJson()
        {
            StringOperators.EscapeJson("hi\t\"there\"! \\/").Should().Be("hi\\t\\\"there\\\"! \\\\/");

            StringOperators.FpEscape("hi\nthere", "json").Should().Be("hi\\nthere");
        }
コード例 #17
0
ファイル: StringOperatorsBuilder.cs プロジェクト: Zedfa/Core
 public StringOperatorsBuilder(StringOperators operators)
 {
     this.strings = operators;
 }
コード例 #18
0
        public void UnescapeHtml()
        {
            StringOperators.UnescapeHtml("&quot;Me &lt; Me &amp; Jou, Jou &gt; Me.&quot;, said he.").Should().Be("\"Me < Me & Jou, Jou > Me.\", said he.");

            StringOperators.FpUnescape("1 &lt; 5", "html").Should().Be("1 < 5");
        }