Exemple #1
0
        public void Should_be_able_to_parse_multiple_lines()
        {
            var parseText = new StringText(Text);

            var firstLine = _lineParser.Parse(parseText);

            Assert.IsTrue(firstLine.HasResult);

            Result <TextSpan, TextSpan> result = _parser.Parse(parseText, firstLine.Result);

            Assert.IsTrue(result.HasResult);
            Assert.That(parseText.ToString(result.Result), Is.EqualTo("1"));

            result = _parser.Parse(parseText, result.Next);

            Assert.IsTrue(result.HasResult);
            Assert.That(parseText.ToString(result.Result), Is.EqualTo("Sun"));

            result = _parser.Parse(parseText, result.Next);

            Assert.IsTrue(result.HasResult);
            Assert.That(parseText.ToString(result.Result), Is.EqualTo("Moon"));

            result = _parser.Parse(parseText, result.Next);

            Assert.IsTrue(result.HasResult);
            Assert.That(parseText.ToString(result.Result), Is.EqualTo("12.34"));
        }
Exemple #2
0
        public void ContextRangeFindingTest()
        {
            var text    = new StringText("0123456789");
            var finding = new RangeContextFinding(text, 3, 5, contextSize: 1);

            var marker1 = finding.Result.PlainText;

            Assert.AreEqual(3, finding.Result.Offset);
            Assert.AreEqual("34567", marker1);

            var content1 = finding.Context.PlainText;

            Assert.AreEqual("2345678", content1);

            var normalized = finding.Normalize();

            var marker2 = normalized.Result.PlainText;

            Assert.AreEqual(1, normalized.Result.Offset);
            Assert.AreEqual("34567", marker2);

            var content2 = normalized.Context.PlainText;

            Assert.AreEqual("2345678", content2);
        }
        private DynamicLayout GenGeneralPanel()
        {
            var layout = new DynamicLayout();

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);

            var id = new Label()
            {
                Width = 255
            };

            id.TextBinding.Bind(_vm, _ => _.Identifier);
            id.Bind(_ => _.ToolTip, _vm, _ => _.Identifier);
            layout.AddRow("ID:", id);
            layout.AddRow(null, new Label()
            {
                Visible = false
            });                                                   // add space

            var nameTB = new StringText();

            nameTB.TextBinding.Bind(_vm, _ => _.DisplayName);
            layout.AddRow("Name:", nameTB);

            var IsDetached = new CheckBox();

            IsDetached.CheckedBinding.Bind(_vm, _ => _.IsDetached.IsChecked);
            layout.AddRow("Is Site Context:", IsDetached);
            return(layout);
        }
Exemple #4
0
        public void Should_choose_the_greediest_one()
        {
            var subject = "Hello, World";

            var first = Parser.Factory.CreateText(x => x.String("Hello"));

            var stringText = new StringText(subject);

            Assert.IsTrue(first.Parse(stringText).HasResult, "First did not match");

            var second = Parser.Factory.CreateText(x =>
                                                   from h in x.String("Hello")
                                                   from y in x.Char(',')
                                                   from ws in x.Whitespace()
                                                   from w in x.String("World")
                                                   select h + y + ws + w);

            Assert.IsTrue(second.Parse(stringText).HasResult, "Second did not match");

            var parser = Parser.Factory.CreateText(x => x.Longest(first, second));

            var result = parser.Parse(stringText);

            Assert.IsTrue(result.HasResult, "Neither matched");

            Assert.AreEqual("Hello, World", stringText.ToString(result.Result), "Longest parser should have matched");
        }
Exemple #5
0
        public void Should_fault_on_empty_message()
        {
            const string message = @"";

            var text = new StringText(message);

            Assert.That(() => Parser.Parse(text, new TextSpan(0, text.Length)), Throws.TypeOf <MacheteParserException>());
        }
Exemple #6
0
        public void Should_parse_the_opening_segment()
        {
            const string message = @"MSH|^~\&|LIFTLAB||UBERMED||201701131234||ORU^R01|K113|P|";

            var text = new StringText(message);

            var result = Parser.Parse(text, new TextSpan(0, text.Length));
        }
 public ScriptEditorViewModel(string name, string content, IHighlightingDefinition highlighting)
 {
     Name = name;
     Content = content;
     CurrentText = new StringText(content);
     Highlighting = highlighting;
     References = new BindableCollection<string>();
     UsingStatements = new BindableCollection<string>();
 }
Exemple #8
0
        [Route("")]         //associated route string (exclude the leading /)
        public IActionResult Index()
        {
            StringText Sometext = new StringText()
            {
                Sometext = "This is some text of a string",
            };

            return(View("Index", Sometext));
        }
Exemple #9
0
        public object Visit_StringText(StringText stringText)
        {
            TreeViewItem item = new TreeViewItem();

            item.IsExpanded = true;

            item.Header = "\"" + stringText.Text.ToString() + "\"";
            return(item);
        }
 public ScriptEditorViewModel(string name, string content, IHighlightingDefinition highlighting)
 {
     Name            = name;
     Content         = content;
     CurrentText     = new StringText(content);
     Highlighting    = highlighting;
     References      = new BindableCollection <string>();
     UsingStatements = new BindableCollection <string>();
 }
Exemple #11
0
 static void ThreadProject()
 {
     _12ConGiap.DrawImage();
     VanKhanString.ReadVK();
     LunnarCalendar.ReadFileStar();
     StringText.GetQuote();
     StringText.DrawImage();
     StringText.GetHDSD();
 }
Exemple #12
0
 internal Line(StringText text, TextSpan body, int lineBreakLength, int lineNumber)
 {
     Contract.ThrowIfNull(text);
     Contract.ThrowIfFalse(lineBreakLength >= 0);
     Contract.Requires(lineNumber >= 0);
     this.text            = text;
     this.textSpan        = body;
     this.lineBreakLength = lineBreakLength;
     this.lineNumber      = lineNumber;
 }
Exemple #13
0
 public bool TryGetFile(string path, out SourceText text)
 {
     if (_includes.TryGetValue(path, out string include))
     {
         text = new StringText(include, path, false);
         return(true);
     }
     text = null;
     return(false);
 }
 internal Line(StringText text, TextSpan body, int lineBreakLength, int lineNumber)
 {
     Contract.ThrowIfNull(text);
     Contract.ThrowIfFalse(lineBreakLength >= 0);
     Contract.Requires(lineNumber >= 0);
     this.text = text;
     this.textSpan = body;
     this.lineBreakLength = lineBreakLength;
     this.lineNumber = lineNumber;
 }
        public void IncrementalParse()
        {
            var oldText = new StringText("class C { }");
            var newText = oldText.WithChanges(new TextChange(new TextSpan(9, 0), "void M() { } "));

            SyntaxTree tree = SyntaxTree.ParseText(oldText);

            var newTree = tree.WithChangedText(newText);

            Assert.AreEqual(newText.ToString(), newTree.ToString());
        }
Exemple #16
0
        public static SyntaxTree Parse(string text, string filename = "", CSharpParseOptions options = null)
        {
            if ((object)options == null)
            {
                options = TestOptions.Regular;
            }

            var stringText = StringText.From(text, Encoding.UTF8);

            return(SyntaxFactory.ParseSyntaxTree(stringText, options, filename));
        }
Exemple #17
0
        public static SyntaxTree ParseWithChecksum(string text, string filename = "", CSharpParseOptions options = null)
        {
            if ((object)options == null)
            {
                options = TestOptions.Regular;
            }

            var stringText = StringText.From(text, Hash.ComputeSha1(Encoding.UTF8.GetBytes(text)));

            return(SyntaxFactory.ParseSyntaxTree(stringText, filename, options));
        }
Exemple #18
0
        public bool TryGetFile(string path, out SourceText text)
        {
            if (File.Exists(path))
            {
                text = new StringText(File.ReadAllText(path), path);
                return(true);
            }

            text = null;
            return(false);
        }
Exemple #19
0
        public void IncrementalParse()
        {
            var oldText = new StringText("class C { }");
            var newText = oldText.WithChanges(new TextChange(new TextSpan(9, 0), "void M() { } "));

            SyntaxTree tree = SyntaxTree.ParseText(oldText);

            var newTree = tree.WithChangedText(newText);

            Assert.AreEqual(newText.ToString(), newTree.ToString());
        }
Exemple #20
0
        void GetWeather()
        {
            StringText sText = new StringText();

            sText.GetList();
            string cityID = sText.IsEqualCityName(ComboBoxCity.Text);
            string url    = string.Format(
                "http://api.openweathermap.org/data/2.5/weather?id={0}&units=metric&cnt=6&appid={1}"
                , cityID, API_KEY);

            using (WebClient web = new WebClient())
            {
                try
                {
                    var json   = web.DownloadString(url);
                    var result = JsonConvert.DeserializeObject <WeatherInfo.root>(json);
                    WeatherInfo.root output    = result;
                    string           urlicon   = string.Format("http://openweathermap.org/img/wn/{0}@2x.png", output.weather[0].icon);
                    byte[]           image     = web.DownloadData(urlicon);
                    MemoryStream     stream    = new MemoryStream(image);
                    Bitmap           newbitmap = new Bitmap(stream);
                    Bitmap           icon      = newbitmap;
                    PictureWeather.Image = newbitmap;
                    labelLog.Text        = string.Format("{0}\u00B0", Math.Round(output.coord.lon, 1));
                    labelLat.Text        = string.Format("{0}\u00B0", Math.Round(output.coord.lat, 1));
                    labelTemp.Text       = string.Format("{0}\u00B0" + "C", Math.Round(output.main.temp, 0));
                    if (Math.Round(output.main.temp_min, 0) == Math.Round(output.main.temp_max, 0))
                    {
                        labelTempMinMax.Text = string.Format("{0}\u00B0" + "C", Math.Round(output.main.temp_max, 0));
                    }
                    else
                    {
                        labelTempMinMax.Text = string.Format("{0}\u00B0" + "C/{1}\u00B0" + "C", Math.Round(output.main.temp_min, 0), Math.Round(output.main.temp_max, 0));
                    }
                    labelWeather.Text  = sText.IsEqualMainWeather(output.weather[0].main);
                    labelCloud.Text    = sText.IsEqualDescriptionWeather(output.weather[0].description);
                    labelHumidity.Text = string.Format("{0}%", output.main.humidity);
                    labelWind.Text     = string.Format("{0} km/h", output.wind.speed);
                    labelPressure.Text = string.Format("{0} hPa", output.main.pressure);
                    labelVisible.Text  = string.Format("{0} km", output.visibility / 1000);
                    labelDate.Text     = string.Format("NGÀY {0}/{1}/{2}"
                                                       , getDate(output.dt).Day, getDate(output.dt).Month, getDate(output.dt).Year);
                    labelHour.Text        = string.Format("Giờ {0}", getDate(output.dt).ToShortTimeString());
                    labelWeather.Location = new Point((PanelDisplayWT.Size.Width / 2) - (labelWeather.Size.Width / 2), 0);
                    labelTemp.Location    = new Point((PanelDisplayWT.Size.Width / 2) - (labelTemp.Size.Width / 2), 54);
                    labelHour.Text        = DateTime.Now.ToString("t");
                }
                catch (System.Net.WebException)
                {
                    PanelDisplayWT.Visible = false;
                    MessageBox.Show("Vui lòng kết nối mạng trước khi sử dụng tính năng  này.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Exemple #21
0
        private DynamicLayout GenGeneralPanel()
        {
            var layout = new DynamicLayout();

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);

            var id = new Label()
            {
                Width = 255
            };

            id.TextBinding.Bind(_vm, (_) => _.Identifier);
            id.Bind(_ => _.ToolTip, _vm, _ => _.Identifier);
            layout.AddRow("ID:", id);
            layout.AddRow(null, new Label()
            {
                Visible = false
            });                                                   // add space

            var nameTB = new StringText();

            nameTB.TextBinding.Bind(_vm, (_) => _.DisplayName);
            layout.AddRow("Name:", nameTB);



            var faceTypeText = new TextBox();

            faceTypeText.Bind(_ => _.Text, _vm, _ => _.FaceTypeText);
            var faceTypeDP = new EnumDropDown <HB.FaceType>()
            {
                Height = 24
            };

            faceTypeDP.SelectedValueBinding.Bind(_vm, (_) => _.FaceType);
            faceTypeDP.Visible      = false;
            faceTypeText.MouseDown += (s, e) => {
                faceTypeText.Visible = false;
                faceTypeDP.Visible   = true;
            };
            faceTypeDP.LostFocus += (s, e) => {
                faceTypeText.Visible = true;
                faceTypeDP.Visible   = false;
            };
            var typeDp = new DynamicLayout();

            typeDp.AddRow(faceTypeText);
            typeDp.AddRow(faceTypeDP);
            layout.AddRow("Face Type:", typeDp);

            return(layout);
        }
Exemple #22
0
        public static ParseResult <TSchema> Parse <TSchema>(this IParser <TSchema> parser, string text)
            where TSchema : Entity
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var stringText = new StringText(text);

            return(parser.Parse(stringText, new TextSpan(0, stringText.Length)));
        }
Exemple #23
0
 /// <summary>
 /// Create a new TextLineSpan from the given parameters
 /// </summary>
 /// <param name="text">StringText this Line is a part of</param>
 /// <param name="start">Start position of the TextLineSpan</param>
 /// <param name="length">Length of the span not including the line break</param>
 /// <param name="lineBreakLength">Length of the line break section of the line</param>
 /// <param name="lineNumber">Line number of this line.</param>
 internal Line(StringText text, int start, int length, int lineBreakLength, int lineNumber)
 {
     Contract.ThrowIfNull(text);
     Contract.ThrowIfFalse(start >= 0);
     Contract.ThrowIfFalse(length >= 0);
     Contract.ThrowIfFalse(lineBreakLength >= 0);
     Contract.Requires(lineNumber >= 0);
     this.text            = text;
     this.textSpan        = new TextSpan(start, length);
     this.lineBreakLength = lineBreakLength;
     this.lineNumber      = lineNumber;
 }
 /// <summary>
 /// Create a new TextLineSpan from the given parameters
 /// </summary>
 /// <param name="text">StringText this Line is a part of</param>
 /// <param name="start">Start position of the TextLineSpan</param>
 /// <param name="length">Length of the span not including the line break</param>
 /// <param name="lineBreakLength">Length of the line break section of the line</param>
 /// <param name="lineNumber">Line number of this line.</param>
 internal Line(StringText text, int start, int length, int lineBreakLength, int lineNumber)
 {
     Contract.ThrowIfNull(text);
     Contract.ThrowIfFalse(start >= 0);
     Contract.ThrowIfFalse(length >= 0);
     Contract.ThrowIfFalse(lineBreakLength >= 0);
     Contract.Requires(lineNumber >= 0);
     this.text = text;
     this.textSpan = new TextSpan(start, length);
     this.lineBreakLength = lineBreakLength;
     this.lineNumber = lineNumber;
 }
Exemple #25
0
        public void SmokeTest()
        {
            var text = new StringText("0123456789");

            var s1 = text.Substring(3, 5);

            Assert.AreEqual("34567", s1.PlainText);

            var s2 = s1.Substring(2, 3);

            Assert.AreEqual("567", s2.PlainText);
        }
Exemple #26
0
        public void Should_parse_the_opening_segment_and_return_the_first_entity()
        {
            const string message = @"MSH|^~\&|LIFTLAB||UBERMED||201701131234||ORU^R01|K113|P|";

            var text = new StringText(message);

            var result = Parser.Parse(text, new TextSpan(0, text.Length));

            MSHSegment msh = null;

            Assert.IsTrue(result.TryGetEntity(0, out msh));

            Assert.IsNotNull(msh);

            Assert.IsNotNull(msh.SendingApplication);
            Assert.IsTrue(msh.SendingApplication.IsPresent);
            Assert.IsTrue(msh.SendingApplication.HasValue);
            Assert.That(msh.SendingApplication.Value, Is.EqualTo("LIFTLAB"));

            Assert.IsNotNull(msh.ReceivingApplication);
            Assert.IsTrue(msh.ReceivingApplication.IsPresent);
            Assert.IsTrue(msh.ReceivingApplication.HasValue);
            Assert.That(msh.ReceivingApplication.Value, Is.EqualTo("UBERMED"));

            Assert.IsNotNull(msh.VersionId);
            Assert.IsFalse(msh.VersionId.IsPresent);
            Assert.IsFalse(msh.VersionId.HasValue);

            Assert.IsNotNull(msh.ContinuationPointer);
            Assert.IsFalse(msh.ContinuationPointer.IsPresent);

            Assert.IsNotNull(msh.Fields);
            Assert.IsTrue(msh.Fields.IsPresent);
            Assert.IsTrue(msh.Fields.HasValue);
            Assert.IsTrue(msh.Fields[0].HasValue);
            Assert.That(msh.Fields[0].Value, Is.EqualTo("LIFTLAB"));

            Assert.IsNotNull(msh.MessageType);
            Assert.IsTrue(msh.MessageType.IsPresent);
            Assert.IsTrue(msh.MessageType.HasValue);

            MSG messageType = msh.MessageType.Value;

            Assert.IsNotNull(messageType.MessageCode);
            Assert.IsTrue(messageType.MessageCode.IsPresent);
            Assert.IsTrue(messageType.MessageCode.HasValue);
            Assert.That(messageType.MessageCode.Value, Is.EqualTo("ORU"));
            Assert.IsNotNull(messageType.TriggerEvent);
            Assert.IsTrue(messageType.TriggerEvent.IsPresent);
            Assert.IsTrue(messageType.TriggerEvent.HasValue);
            Assert.That(messageType.TriggerEvent.Value, Is.EqualTo("R01"));
        }
Exemple #27
0
        public void Should_be_able_to_combine_text()
        {
            ParseText input = new StringText("abcdefg");

            var first  = input.GetSubText(new TextSpan(0, 3));
            var second = input.GetSubText(new TextSpan(4, 3));

            var composite = new CompositeText(new[] { first, second });

            var text = composite.ToString();

            Assert.That(text, Is.EqualTo("abcefg"));
        }
Exemple #28
0
        public void Should_parse_text_from_the_string()
        {
            var input = new StringText("Hello, World.");

            var parser = new SymbolParser(char.IsLetter, char.IsLetterOrDigit);

            var result = parser.Parse(input, new TextSpan(0, input.Length));

            Assert.IsTrue(result.HasValue);

            var text = input.GetSubText(result.Value);

            Assert.AreEqual("Hello", text.ToString());
        }
        private GroupBox GenRadiancePanel()
        {
            var gp = new GroupBox()
            {
                Text = "Radiance"
            };

            var layout = new DynamicLayout();

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);

            var c = new Button();

            c.Width = 250;
            c.Bind(_ => _.Enabled, _vm, v => v.Modifier.IsBtnEnabled);
            c.TextBinding.Bind(_vm, _ => _.Modifier.BtnName);
            c.Command = this._vm.ModifierCommand;
            var cByRoom = new CheckBox()
            {
                Text = ReservedText.ByGlobalSetting
            };

            cByRoom.CheckedBinding.Bind(_vm, _ => _.Modifier.IsCheckboxChecked);

            layout.AddRow("Modifier:", cByRoom);
            layout.AddRow(null, c);

            var mb = new Button();

            mb.Bind(_ => _.Enabled, _vm, v => v.ModifierBlk.IsBtnEnabled);
            mb.TextBinding.Bind(_vm, _ => _.ModifierBlk.BtnName);
            mb.Command = this._vm.ModifierBlkCommand;
            var mbByRoom = new CheckBox()
            {
                Text = ReservedText.ByGlobalSetting
            };

            mbByRoom.CheckedBinding.Bind(_vm, _ => _.ModifierBlk.IsCheckboxChecked);
            layout.AddRow("Modifier Blk:", mbByRoom);
            layout.AddRow(null, mb);

            var dynamicGroup = new StringText();

            dynamicGroup.TextBinding.Bind(_vm, _ => _.DynamicGroupIdentifier);
            layout.AddRow("Dynamic Group ID:", dynamicGroup);

            gp.Content = layout;
            return(gp);
        }
        public void AnalyzerOptionsArePassedToAllAnalyzers()
        {
            var             text    = new StringText(string.Empty, encodingOpt: null);
            AnalyzerOptions options = new AnalyzerOptions
                                      (
                new[] { new TestAdditionalText("myfilepath", text) }.ToImmutableArray <AdditionalText>()
                                      );

            var compilation = CreateCompilationWithMscorlib45(TestResource.AllInOneCSharpCode);
            var analyzer    = new OptionsDiagnosticAnalyzer <SyntaxKind>(options);

            compilation.GetAnalyzerDiagnostics(new[] { analyzer }, options);
            analyzer.VerifyAnalyzerOptions();
        }
Exemple #31
0
        public void Should_be_able_to_combine_slices()
        {
            ParseText input = new StringText("abcdefg");

            var first  = input.GetSubText(new TextSpan(0, 3));
            var second = input.GetSubText(new TextSpan(4, 3));

            TextSlice firstSlice  = new ParseTextSlice(first, new TextSpan(0, first.Length));
            TextSlice secondSlice = new ParseTextSlice(second, new TextSpan(0, second.Length));

            var composite = new CompositeTextSlice(firstSlice, secondSlice);

            var text = composite.Text.ToString();

            Assert.That(text, Is.EqualTo("abcefg"));
        }
Exemple #32
0
        public void ChecksumAlgorithms()
        {
            var source1   = "public class C1 { public C1() { } }";
            var source256 = "public class C256 { public C256() { } }";
            var tree1     = SyntaxFactory.ParseSyntaxTree(
                StringText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1),
                path: "sha1.cs"
                );
            var tree256 = SyntaxFactory.ParseSyntaxTree(
                StringText.From(source256, Encoding.UTF8, SourceHashAlgorithm.Sha256),
                path: "sha256.cs"
                );

            var compilation = CreateCompilation(new[] { tree1, tree256 });

            compilation.VerifyPdb(
                @"
<symbols>
  <files>
    <file id=""1"" name=""sha1.cs"" language=""C#"" checksumAlgorithm=""SHA1"" checksum=""8E-37-F3-94-ED-18-24-3F-35-EC-1B-70-25-29-42-1C-B0-84-9B-C8"" />
    <file id=""2"" name=""sha256.cs"" language=""C#"" checksumAlgorithm=""SHA256"" checksum=""83-31-5B-52-08-2D-68-54-14-88-0E-E3-3A-5E-B7-83-86-53-83-B4-5A-3F-36-9E-5F-1B-60-33-27-0A-8A-EC"" />
  </files>
  <methods>
    <method containingType=""C1"" name="".ctor"">
      <customDebugInfo>
        <using>
          <namespace usingCount=""0"" />
        </using>
      </customDebugInfo>
      <sequencePoints>
        <entry offset=""0x0"" startLine=""1"" startColumn=""19"" endLine=""1"" endColumn=""30"" document=""1"" />
        <entry offset=""0x6"" startLine=""1"" startColumn=""33"" endLine=""1"" endColumn=""34"" document=""1"" />
      </sequencePoints>
    </method>
    <method containingType=""C256"" name="".ctor"">
      <customDebugInfo>
        <forward declaringType=""C1"" methodName="".ctor"" />
      </customDebugInfo>
      <sequencePoints>
        <entry offset=""0x0"" startLine=""1"" startColumn=""21"" endLine=""1"" endColumn=""34"" document=""2"" />
        <entry offset=""0x6"" startLine=""1"" startColumn=""37"" endLine=""1"" endColumn=""38"" document=""2"" />
      </sequencePoints>
    </method>
  </methods>
</symbols>"
                );
        }
Exemple #33
0
        public void ChecksumAlgorithms()
        {
            var source1   = "public class C1 { public C1() { } }";
            var source256 = "public class C256 { public C256() { } }";
            var tree1     = SyntaxFactory.ParseSyntaxTree(StringText.From(source1, Encoding.UTF8, SourceHashAlgorithm.Sha1), path: "sha1.cs");
            var tree256   = SyntaxFactory.ParseSyntaxTree(StringText.From(source256, Encoding.UTF8, SourceHashAlgorithm.Sha256), path: "sha256.cs");

            var compilation = CreateCompilationWithMscorlib(new SyntaxTree[] { tree1, tree256 });

            string actual = GetPdbXml(compilation);

            string expected = @"
<symbols>
  <files>
    <file id=""1"" name=""sha1.cs"" language=""3f5162f8-07c6-11d3-9053-00c04fa302a1"" languageVendor=""994b45c4-e6e9-11d2-903f-00c04fa302a1"" documentType=""5a869d0b-6611-11d3-bd2a-0000f80849bd"" checkSumAlgorithmId=""ff1816ec-aa5e-4d10-87f7-6f4963833460"" checkSum=""8E, 37, F3, 94, ED, 18, 24, 3F, 35, EC, 1B, 70, 25, 29, 42, 1C, B0, 84, 9B, C8, "" />
    <file id=""2"" name=""sha256.cs"" language=""3f5162f8-07c6-11d3-9053-00c04fa302a1"" languageVendor=""994b45c4-e6e9-11d2-903f-00c04fa302a1"" documentType=""5a869d0b-6611-11d3-bd2a-0000f80849bd"" checkSumAlgorithmId=""8829d00f-11b8-4213-878b-770e8597ac16"" checkSum=""83, 31, 5B, 52,  8, 2D, 68, 54, 14, 88,  E, E3, 3A, 5E, B7, 83, 86, 53, 83, B4, 5A, 3F, 36, 9E, 5F, 1B, 60, 33, 27,  A, 8A, EC, "" />
  </files>
  <methods>
    <method containingType=""C1"" name="".ctor"" parameterNames="""">
      <customDebugInfo version=""4"" count=""1"">
        <using version=""4"" kind=""UsingInfo"" size=""12"" namespaceCount=""1"">
          <namespace usingCount=""0"" />
        </using>
      </customDebugInfo>
      <sequencepoints total=""2"">
        <entry il_offset=""0x0"" start_row=""1"" start_column=""19"" end_row=""1"" end_column=""30"" file_ref=""1"" />
        <entry il_offset=""0x6"" start_row=""1"" start_column=""33"" end_row=""1"" end_column=""34"" file_ref=""1"" />
      </sequencepoints>
      <locals />
    </method>
    <method containingType=""C256"" name="".ctor"" parameterNames="""">
      <customDebugInfo version=""4"" count=""1"">
        <forward version=""4"" kind=""ForwardInfo"" size=""12"" declaringType=""C1"" methodName="".ctor"" parameterNames="""" />
      </customDebugInfo>
      <sequencepoints total=""2"">
        <entry il_offset=""0x0"" start_row=""1"" start_column=""21"" end_row=""1"" end_column=""34"" file_ref=""2"" />
        <entry il_offset=""0x6"" start_row=""1"" start_column=""37"" end_row=""1"" end_column=""38"" file_ref=""2"" />
      </sequencepoints>
      <locals />
    </method>
  </methods>
</symbols>";

            AssertXmlEqual(expected, actual);
        }
Exemple #34
0
        private IExpression Factor()
        {
            Token token = currentToken;

            if (token.TokenType == TokenType.PLUS)
            {
                EatToken(TokenType.PLUS);
                return(new UnaryOp(token, Factor()));
            }
            else if (token.TokenType == TokenType.MINUS)
            {
                EatToken(TokenType.MINUS);
                return(new UnaryOp(token, Factor()));
            }
            else if (token.TokenType == TokenType.NUMBER)
            {
                EatToken(TokenType.NUMBER);
                return(new Num(token));
            }
            else if (token.TokenType == TokenType.IDENT)
            {
                IExpression node = Variable();
                return(node);
            }
            else if (token.TokenType == TokenType.LPARENT)
            {
                EatToken(TokenType.LPARENT);
                IExpression node = Expression();
                EatToken(TokenType.RPARENT);
                return(node);
            }
            else if (token.TokenType == TokenType.TEXT)
            {
                IExpression text = new StringText(currentToken);
                EatToken(TokenType.TEXT);
                return(text);
            }

            throw new Exception("Factor did not return result");
        }
Exemple #35
0
        static void Main(string[] args)
        {
            var workspace = Workspace.LoadSolution(
                @"C:\Lectures\NDC 2012 - June 2012\Roslyn... hmmm.... what\Demos\TestSolution\TestSolution.sln");

            var solution = workspace.CurrentSolution;

            var newSolution = solution;
            foreach (var project in solution.Projects)
            {
                foreach (var document in project.Documents)
                {
                    var updatedFile = new StringText(TopOfFileComment + document.GetSyntaxTree().Root.GetFullText());

                    newSolution = newSolution.UpdateDocument(document.Id, updatedFile);
                }
            }

            if (newSolution != solution)
            {
                workspace.ApplyChanges(solution, newSolution);
            }
        }
Exemple #36
0
        static void Main(string[] args)
        {
            var workspace = Workspace.LoadSolution(
                @"..\\..\\..\\03_Workspaces_Solution_Target\EmptyTryCatch.sln");

            var solution = workspace.CurrentSolution;

            var newSolution = solution;
            foreach (var project in solution.Projects)
            {
                foreach (var document in project.Documents)
                {
                   TryCatchRewriter rewriter = new TryCatchRewriter();
                   var updatedFile = new StringText(rewriter.Visit((SyntaxNode)document.GetSyntaxTree().GetRoot()).GetText().ToString());

                   newSolution = newSolution.UpdateDocument(document.Id, updatedFile);
                }
            }

            if (newSolution != solution)
            {
                workspace.ApplyChanges(solution, newSolution);
            }
        }
 private void OnDocumentChanged(object sender, DocumentChangeEventArgs e)
 {
     CurrentText = new StringText(Document.Text);
     OnTextChanged(new TextChangeEventArgs(OldText, CurrentText, new TextChangeRange[0]));
 }
 public override bool TryGetText(out IText text)
 {
     text = new StringText(string.Empty);
     return true;
 }
Exemple #39
0
		/// <summary>
		///     画像内の文字を検索
		/// </summary>
		/// <param name="bmp">画像</param>
		/// <param name="color">文字色</param>
		/// <returns>結果</returns>
		public static List<StringText> LetterSearch( Bitmap bmp, Color color ) {
			var colordata = new bool[bmp.Width, bmp.Height];

			var spacedata = "";
			for( var y = 0; y < FONT_HEIGHT; y++ ) {
				spacedata += "0";
			}

			//扱いやすいbool型に
			for( var x = 0; x < bmp.Width; x++ ) {
				for( var y = 0; y < bmp.Height; y++ ) {
					if( bmp.GetPixel( x, y ) == color ) {
						colordata[x, y] = true;
					} else {
						colordata[x, y] = false;
					}
				}
			}

			//各行の文字の一番上と一番下の行を求める
			var stringLineList = new List<StringLine>();
			{
				var upperSide = -1;
				for( var y = 0; y < bmp.Height; y++ ) {
					var flag = false;
					for( var x = 0; x < bmp.Width; x++ ) {
						if( colordata[x, y] ) {
							flag = true;
							break;
						}
					}
					if( upperSide == -1 && flag ) {
						upperSide = y;
					}
					if( upperSide != -1 && !flag ) {
						stringLineList.Add( new StringLine( upperSide, y-1 ) );
						upperSide = -1;
					}
					if( upperSide != -1 && y == bmp.Height-1 ) {
						stringLineList.Add(new StringLine(upperSide,y));
					}
				}
			}

			using( var font = new Font() ) {
				var result = new List<StringText>();
				foreach( var stringLine in stringLineList ) {
					var stringText = new StringText( 0, 0, "" );
					foreach( var padding in stringLine.padding ) {
						//文字と文字の間の位置を求める
						var spaceList = new List<int>();
						spaceList.Add(-1);
						for( var x = 0; x < bmp.Width; x++ ) {
							var flag = false;
							for( var y = stringLine.upperSide; y <= stringLine.lowerSide; y++ ) {
								if( colordata[x, y] ) {
									flag = true;
									break;
								}
							}
							if( !flag ) {
								spaceList.Add( x );
							}
						}

						//0と1で構成されたfontdataを生成する
						var fontdataList = new List<string>();
						for( var i = 0; i < spaceList.Count; i++ ) {
							var nextCol = i + 1 == spaceList.Count ? bmp.Width : spaceList[i + 1];

							fontdataList.Add( spacedata );

							if( spaceList[i] + 1 < nextCol ) {
								//次の行がスペースでない場合
								if( stringText.x == 0 ) {
									stringText.x = spaceList[i] + 1;
								}

								var fontdata = "";
								for( var x = spaceList[i] + 1; x < nextCol; x++ ) {
									for( var p = 0; p < padding.upper; p++ ) {
										fontdata += "0";
									}
									for( var y = stringLine.upperSide; y <= stringLine.lowerSide; y++ ) {
										fontdata += colordata[x, y] ? "1" : "0";
									}
									for( var p = 0; p < padding.lower; p++ ) {
										fontdata += "0";
									}
								}
								fontdataList.Add( fontdata );
							}
						}
						var tempStr = "";
						for( var i = 0; i < fontdataList.Count; i++ ) {
							if( fontdataList.Count - 4 > i ) {
								if( fontdataList[i] == spacedata &&
									fontdataList[i + 1] == spacedata &&
									fontdataList[i + 2] == spacedata &&
									fontdataList[i + 3] == spacedata
																) {
									tempStr += " ";
									i += 3;
									continue;
								}
							}
							var res = font.LikeSearch( fontdataList[i] );
							switch( res.Length ) {
								case 0:

									//該当0
									break;
								case 1:
									tempStr += res[0][0];
									break;
								default:

									//複数結果があった場合の処理
									tempStr += LongestMatch( res, fontdataList.ToArray(), ref i );
									break;
							}
						}

						tempStr = Regex.Replace( tempStr, "^ +| +$", "" );
						if( stringText.text.Length < tempStr.Length ) {
							stringText.text = tempStr;
							stringText.y = stringLine.upperSide - padding.upper;
						}
					}
					result.Add( stringText );
				}
				return result.ToList();
			}
		}
Exemple #40
0
 /*
  * Update one ducument in a solution to the specified string, and return the instance of
  * the modified ISolution.
  */
 public static IDocument UpdateDocumentToString(IDocument document, String s)
 {
     IText text = new StringText(s);
     CommonSyntaxNode node = ASTUtil.GetSyntaxTreeFromSource(s).GetRoot();
     return document.Project.Solution.UpdateDocument(document.Id, text).GetDocument(document.Id);
 }