コード例 #1
0
        public void StrippedHtmlIsSameAsInput()
        {
            var input  = SampleFile.Load("csharp-sample.txt");
            var tokens = new CSharpLexer()
                         .GetTokens(input)
                         .ToArray();

            var subject = new HtmlFormatter(new HtmlFormatterOptions()
            {
                NoWrap = true
            });

            var htmlOut = new StringWriter();

            subject.Format(tokens, htmlOut);

            File.WriteAllText("output.html", htmlOut.ToString());

            var txtOut = new StringWriter();

            new NullFormatter().Format(tokens, txtOut);

            var strippedHtml = Regex.Replace(htmlOut.ToString(),
                                             @"<.*?>", "")
                               .Trim();
            var escapedText = HtmlFormatter.EscapeHtml(txtOut.ToString()).Trim();

            Check.That(strippedHtml).IsEqualTo(escapedText);
        }
コード例 #2
0
        public CSharpExampleFileTests(ITestOutputHelper output)
        {
            _output = output;
            var subject = new CSharpLexer();

            _results = subject.GetTokens(SampleFile.Load("csharp-sample.txt"))
                       .ToArray();
        }
コード例 #3
0
        public void should_work_with_sample_data(SampleFile sampleFile)
        {
            var builder = new NearestRankBuilder(new [] { 80, 90, 99, 99.9, 99.99, 99.999 });

            foreach (var line in File.ReadAllLines(sampleFile.Filename))
            {
                var value = double.Parse(line, CultureInfo.InvariantCulture);
                builder.AddValue(value);
            }

            builder.GetPercentiles().Select(p => (int)p.Value).ShouldBeEquivalentTo(sampleFile.ExpectedValues);
        }
コード例 #4
0
        public void NoCharactersAreLost()
        {
            var expected = SampleFile.Load("csharp-sample.txt");

            var writer = new StringWriter();

            new NullFormatter().Format(_results, writer);

            var s = writer.ToString().Replace("\n", "\r\n");

            Check.That(s).IsEqualTo(expected);
        }
コード例 #5
0
        private void importData(FileInfo file)
        {
            StreamReader sr = new StreamReader(file.OpenRead());

            string line = "";

            sr.ReadLine();
            while ((line = sr.ReadLine()) != null)
            {
                lines.Add(line);
            }
            SampleFile newSampleFile = new SampleFile(lines);

            session.CurrentSampleFile = newSampleFile;
        }
コード例 #6
0
ファイル: Initialize.cs プロジェクト: lacostej/uplift
        static Initialize()
        {
            Debug.Log("Upfile loading...");
            if (!Upfile.CheckForUpfile())
            {
                Debug.Log("No Upfile was found at the root of your project, Uplift created a sample one for you to start working on");
                SampleFile.CreateSampleUpfile();
            }

            if (!IsInitialized())
            {
                UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.ONLY_LOCKFILE, refresh: true);
                MarkAsInitialized();
            }
        }
コード例 #7
0
ファイル: Initialize.cs プロジェクト: sjb8100/uplift
        static Initialize()
        {
            Debug.Log("Using Uplift version " + About.Version);
            if (!Upfile.CheckForUpfile())
            {
                Debug.Log("No Upfile was found at the root of your project, Uplift created a sample one for you to start working on");
                SampleFile.CreateSampleUpfile();
            }

            if (LockFileTracker.HasChanged())
            {
                UpliftManager.ResetInstances();
                UpliftManager.Instance().InstallDependencies(strategy: UpliftManager.InstallStrategy.ONLY_LOCKFILE);
                LockFileTracker.SaveState();
            }

            Updater.CheckForUpdate();
        }
コード例 #8
0
        private void xSampleFileButton_Click(object sender, RoutedEventArgs e)
        {
            switch (sampleFile)
            {
            case SampleFile.Normal:
                sampleFile = SampleFile.Confuse;
                sampleList = sampleConfuseList;
                break;

            case SampleFile.Confuse:
                sampleFile = SampleFile.Normal;
                sampleList = sampleNormalList;
                break;
            }
            xSampleFileButton.Content = sampleFile;
            sampleListIndex           = sampleList.Count - 1;
            // sampleListIndex = 1;
            NextSentence();
        }
コード例 #9
0
        public void TestLineNumbers()
        {
            var options = new HtmlFormatterOptions()
            {
                LineNumbers = LineNumberStyle.Table
            };
            var input  = SampleFile.Load("csharp-sample.txt");
            var tokens = new CSharpLexer()
                         .GetTokens(input);

            var subject = new HtmlFormatter(options);
            var output  = new StringWriter();

            subject.Format(tokens, output);

            var html = output.ToString();

            Check.That(Regex.IsMatch(html, @"<pre>\s+1\s+2\s+3"))
            .IsTrue();
        }
コード例 #10
0
        public static object PostFile(object json, HttpPostedFile file)
        {
            var stream = file.InputStream;
            var bytes  = new byte[stream.Length];

            stream.Read(bytes, 0, bytes.Length);
            using (var context = new SampleContext())
            {
                var newFile = new SampleFile()
                {
                    Name    = file.FileName,
                    Type    = file.ContentType,
                    Size    = file.InputStream.Length,
                    Content = bytes
                };
                context.Files.Add(newFile);
                context.SaveChanges();
                return(newFile.Id);
            }
        }
コード例 #11
0
        public void TestLineAnchors()
        {
            var options = new HtmlFormatterOptions()
            {
                LineAnchors       = "foo",
                AnchorLineNumbers = true
            };
            var input  = SampleFile.Load("csharp-sample.txt");
            var tokens = new CSharpLexer()
                         .GetTokens(input);

            var subject = new HtmlFormatter(options);
            var output  = new StringWriter();

            subject.Format(tokens, output);

            var html = output.ToString();

            Check.That(Regex.IsMatch(html, "<a name=\"foo-1\">"))
            .IsTrue();
        }
コード例 #12
0
        public void Full()
        {
            var options = new HtmlFormatterOptions()
            {
                Full  = true,
                Title = "My Source Code"
            };
            var input  = SampleFile.Load("csharp-sample.txt");
            var tokens = new CSharpLexer()
                         .GetTokens(input);

            var subject = new HtmlFormatter(options);
            var output  = new StringWriter();

            subject.Format(tokens, output);

            var html = output.ToString();

            File.WriteAllText("output.html", html);

            Check.That(html).Contains("<html>", "<head>", "<title>My Source Code</title>");
        }
コード例 #13
0
        public void should_work_with_sample_data(SampleFile sampleFile)
        {
            var desiredPercentiles = new[] { 80, 90, 99, 99.9, 99.99, 99.999 };
            var builders           = new List <Tuple <string, IPercentileBuilder> >
            {
                new Tuple <string, IPercentileBuilder>("Nearest rank", new NearestRankBuilder(desiredPercentiles)),
                new Tuple <string, IPercentileBuilder>("P² single value (fast)", new CombinedPsquareSinglePercentileAlgorithmBuilder(desiredPercentiles, Precision.LessPreciseAndFaster)),
                new Tuple <string, IPercentileBuilder>("P² single value (normal)", new CombinedPsquareSinglePercentileAlgorithmBuilder(desiredPercentiles)),
                new Tuple <string, IPercentileBuilder>("Hdr histogram)", new HdrHistogramBuilder(int.MaxValue /* Assuming we don't know the data */, 2, desiredPercentiles))
            };
            var nearestRank = builders[0].Item2;

            foreach (var line in File.ReadAllLines(sampleFile.Filename))
            {
                var value = double.Parse(line, CultureInfo.InvariantCulture);
                foreach (var builder in builders)
                {
                    builder.Item2.AddValue(value);
                }
            }

            Console.WriteLine("Percentile;" + string.Join(";", builders.Select(x => x.Item1)));
            foreach (var desiredPercentile in desiredPercentiles)
            {
                Console.WriteLine(desiredPercentile + ";" + string.Join(";", builders.Select(x => (int)x.Item2.GetPercentiles().Single(p => p.Rank == desiredPercentile).Value)));
            }
            Console.Write("MSE to Nearest rank");
            foreach (var builder in builders)
            {
                var squaredErrors = nearestRank.GetPercentiles().Zip(builder.Item2.GetPercentiles(), (a, b) => Math.Pow(a.Value - b.Value, 2)).ToList();
                Console.Write(";" + squaredErrors.Average());
            }

            Console.WriteLine("\r\n\r\nData size in bytes: " + sizeof(double) * File.ReadAllLines(sampleFile.Filename).Count());
            Console.WriteLine("Hdr estimated size: " + ((HdrHistogramBuilder)builders.Last().Item2).GetEstimatedSize());
            Console.WriteLine("P² (fast) estimated size: 200");
            Console.WriteLine("P² (normal) estimated size: 270");
            Console.WriteLine("Hdr estimated size: " + (new HdrHistogramBuilder(Int32.MaxValue, 0, new[] { 90d, 95d, 99d }).GetEstimatedSize()));
        }
コード例 #14
0
ファイル: SettingsWindow.cs プロジェクト: sjb8100/uplift
        protected void OnGUI()
        {
#if UNITY_5_1_OR_NEWER
            titleContent.text = "Edit settings";
#endif
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            string settingsLocation = UpliftSettings.GetDefaultLocation();

            FileSystemUtil.EnsureParentExists(settingsLocation);

            if (!File.Exists(settingsLocation))
            {
                EditorGUILayout.HelpBox("It seems that you do not have a settings.xml file under HOME/.uplift.", MessageType.Warning);
                if (GUILayout.Button("Create a sample settings file"))
                {
                    SampleFile.CreateSampleSettingsFile();
                }
            }
            else
            {
                if (settingsText == null)
                {
                    settingsText = System.IO.File.ReadAllText(settingsLocation);
                }

                settingsText = EditorGUILayout.TextArea(settingsText);

                if (GUILayout.Button("Save settings file"))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.InnerXml = settingsText;
                    doc.Save(settingsLocation);
                    Repaint();
                }
            }

            EditorGUILayout.EndScrollView();
        }
コード例 #15
0
        public override string ToString()
        {
            //if (ParentProjects != null)
            //{
            //    return ParentProjects.Aggregate("", (current, project) => current + project.ToString());
            //}
            //if (ParentAppResult != null)
            //{
            //    return ParentAppResult.ToString();
            //}
            //if (Sample != null)
            //{
            //    return Sample.ToString();
            //}

            if (SampleFile != null)
            {
                return(SampleFile.ToString());
            }

            //if (Application != null)
            //{
            //    return Application.ToString();
            //}

            if (AppResult != null)
            {
                return(AppResult.ToString());
            }

            if (AppResultFile != null)
            {
                return(AppResultFile.ToString());
            }

            return(base.ToString());
        }
コード例 #16
0
        public async Task <IActionResult> Post([FromForm] SampleFile file, CancellationToken ct)
        {
            var x = file;

            return(Ok("file upload works!"));
        }
コード例 #17
0
 public void IndexOutOfRange_8(string fixture)
 {
     var content = SampleFile.Load(fixture);
     var lexer = new CSharpLexer();
     Check.ThatCode(() => lexer.GetTokens(content)).DoesNotThrow();
 }
コード例 #18
0
 public void Test1()
 {
     _ = SampleFile.Parse("/Users/Therzok/Desktop/sample_startup.txt");
 }
コード例 #19
0
            public void AddContainerItem(string name)
            {
                SampleFile file = new SampleFile(name, this);

                _childItems.Add(file);
            }
コード例 #20
0
 public ProjectWithImportSample(SampleFile projectFile, SampleFile importedPropsFile)
 {
     ProjectFile       = projectFile;
     ImportedPropsFile = importedPropsFile;
 }
コード例 #21
0
 public void RemoveSampleFile(SampleFile sampleFile)
 {
     _sampleFileList.Remove(sampleFile);
 }
コード例 #22
0
 private void xSampleFileButton_Click(object sender, RoutedEventArgs e)
 {
     switch (sampleFile)
     {
         case SampleFile.Normal:
             sampleFile = SampleFile.Confuse;
             sampleList = sampleConfuseList;
             break;
         case SampleFile.Confuse:
             sampleFile = SampleFile.Normal;
             sampleList = sampleNormalList;
             break;
     }
     xSampleFileButton.Content = sampleFile;
     sampleListIndex = sampleList.Count - 1;
    // sampleListIndex = 1;
     NextSentence();
 }
コード例 #23
0
 public FSharpSampleSolution(SampleFile solutionFile, SampleFile fSharpProjectFile, SampleFile cSharpProjectFile)
 {
     SolutionFile      = solutionFile;
     FSharpProjectFile = fSharpProjectFile;
     CSharpProjectFile = cSharpProjectFile;
 }
コード例 #24
0
 public void AddSampleFile(SampleFile sampleFile)
 {
     _sampleFileList.Add(sampleFile);
 }