private static void CollateResults(string testName, Runs runs) { lock (Results) { Results[testName] = runs; } DisplayResults(); }
protected static Runs Append(Runs head, Runs action) { if (head == null) { return(action); } head.next = Append(head.next, action); return(head); }
private void CompleteExistingRun(string messages, byte[] artifact) { RunAttempt last = Runs.LastOrDefault(); if (last != null) { last.Complete(messages, artifact); } }
private void RemoveOptimizer(IOptimizer optimizer) { DeregisterOptimizerEvents(optimizer); Runs.RemoveRange(optimizer.Runs); if (ExecutionState == ExecutionState.Prepared && !optimizers.Any(opt => opt.ExecutionState == ExecutionState.Prepared)) { OnStopped(); } }
private void AddOptimizer(IOptimizer optimizer) { RegisterOptimizerEvents(optimizer); Runs.AddRange(optimizer.Runs); optimizer.Prepare(); if (ExecutionState == ExecutionState.Stopped && optimizer.ExecutionState == ExecutionState.Prepared) { OnPrepared(); } }
private XElement ToXml() { XElement x = new XElement("ScenarioRuns"); if (models != null && models.Count > 0) { var Elfile = new XElement("ModelFiles"); foreach (var v in models) { Elfile.Add(new XElement("FileName", v.DisplayName)); } x.Add(Elfile); } x.Add(new XElement("OutputDirectory", OutputDirectory)); x.Add(new XElement("Prefix", Prefix)); if (mikeSheFileName != null) { x.Add(new XElement("MikeSheFileName", MikeSheFileName)); } if (postProcessBat != null) { x.Add(new XElement("PostProcessBatFile", PostProcessBat)); } if (slf != null) { x.Add(new XElement("SimlabFileName", slf.FileName)); } if (Runs != null) { StringBuilder s = new StringBuilder(); foreach (var r in Runs.Where(var => var.RunThis)) { s.Append(", " + r.Number); } x.Add(new XElement("ScenariosToRun", s.ToString())); } var file = new XElement("FilesToCopy"); foreach (var v in this.FileNamesToCopy) { file.Add(new XElement("FileName", v)); } x.Add(file); return(x); }
private void Algorithm_Stopped(object sender, EventArgs e) { var cloner = new Cloner(); var algRun = cloner.Clone(Algorithm.Runs.Last()); var clonedSnapshots = cloner.Clone(snapshots); algRun.Results.Add("TimeLimitRunSnapshots", clonedSnapshots); Runs.Add(algRun); Algorithm.Runs.Clear(); OnStopped(); }
/// <summary> /// 解析留言內容 /// </summary> /// <param name="liveChatTextMessageRenderer"></param> /// <param name="txtMsgRd">json data.</param> private void ParseTextMessage(LiveChatTextMessageRenderer liveChatTextMessageRenderer, dynamic txtMsgRd) { liveChatTextMessageRenderer.authorExternalChannelId = Convert.ToString(JsonHelper.TryGetValueByXPath(txtMsgRd, "authorExternalChannelId", "")); liveChatTextMessageRenderer.authorName.simpleText = Convert.ToString(JsonHelper.TryGetValueByXPath(txtMsgRd, "authorName.simpleText", "")); liveChatTextMessageRenderer.authorPhoto.thumbnails = ParseAuthorPhotoThumb(JsonHelper.TryGetValueByXPath(txtMsgRd, "authorPhoto.thumbnails", null)); liveChatTextMessageRenderer.contextMenuAccessibility.accessibilityData.label = Convert.ToString(JsonHelper.TryGetValueByXPath(txtMsgRd, "contextMenuAccessibility.accessibilityData.label", "")); liveChatTextMessageRenderer.id = Convert.ToString(JsonHelper.TryGetValueByXPath(txtMsgRd, "id", "")); liveChatTextMessageRenderer.timestampUsec = Convert.ToInt64(JsonHelper.TryGetValueByXPath(txtMsgRd, "timestampUsec", 0)); //留言包含自訂表情符號或空格時runs陣列會分割成多元素 dynamic runs = JsonHelper.TryGetValueByXPath(txtMsgRd, "message.runs"); if (runs != null) { for (int i = 0; i < runs.Count; i++) { dynamic run = runs[i]; Runs r = new Runs(); //解析一般文字元素 string text = ParseText(run); if (text != "") { r.text = text; liveChatTextMessageRenderer.message.runs.Add(r); } //解析Emoji元素 Emoji emj = ParseEmoji(run); if (emj != null) { r.emoji = emj; liveChatTextMessageRenderer.message.runs.Add(r); } } } else { liveChatTextMessageRenderer.message.simpleText = ""; } var authorBadges = JsonHelper.TryGetValueByXPath(txtMsgRd, "authorBadges", null); if (authorBadges != null) { //留言者可能擁有多個徽章 (EX:管理員、會員) for (int i = 0; i < authorBadges.Count; i++) { AuthorBadge badge = new AuthorBadge(); badge.tooltip = Convert.ToString(JsonHelper.TryGetValueByXPath(authorBadges[i], "liveChatAuthorBadgeRenderer.tooltip")); liveChatTextMessageRenderer.authorBadges.Add(badge); } } }
public void Run() { Runs.Add(RunNumber); Runner(this); if (Failed) { HandleFailure(); return; } RunNumber++; }
private void runComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { Runs r = e.AddedItems[0] as Runs; selectedRun = r; exampleLabel.Content = r.FamilyType; qtyLabel.Content = r.ElementIds.Count.ToString(); } catch { } }
private Runs NextRun() { lock (this) { Runs run = _pendingRuns; if (run != null) { _pendingRuns = run.next; } return(run); } }
private string FormatMessageText(Message msg) { string ret = ""; for (int i = 0; i < msg.runs.Count; i++) { Runs r = msg.runs[i]; ret += r.text; ret += FormatEmojiImage(r.emoji); } return(ret); }
/// <summary> /// Adds a run to this trial for every project's subject /// for which a run does not already exist for this trial. /// </summary> public virtual void PopulateWithRuns() { foreach (Subject subject in Researcher.Current.ActiveProject.Subjects) { if (!Runs.Any((run) => run.Subject.Code == subject.Code)) { AddRun(new Run() { Subject = subject }); } } }
public async Task ReturnsLeaderboards() { // Arrange var products = new Products(fixture.Products.Select(p => p.Name).ToList()); var modes = new Modes(fixture.Modes.Select(m => m.Name).ToList()); var runs = new Runs(fixture.Runs.Select(r => r.Name).ToList()); var characters = new Characters(fixture.Characters.Select(c => c.Name).ToList()); // Act var result = await controller.GetLeaderboards(products, modes, runs, characters); // Assert Assert.IsAssignableFrom <OkNegotiatedContentResult <LeaderboardsEnvelope> >(result); }
public void RemoveAt(int index) { int run, offset; RunAndOffset(index, out run, out offset); if (Runs[run].Length != 0) { Runs[run] = new Run((byte)(Runs[run].Length - 1), Runs[run].Value); } else { Runs.RemoveAt(run); } }
protected internal virtual void Disconnect(Cons cons) { lock (this) { if (IsDispatching()) { _pendingRuns = Append(_pendingRuns, new DisconnectImpl(this, cons)); } else { _listeners = Cons.Remove(_listeners, cons); ConnectionRemoved(); } } }
public void Add(T value) { var last = Runs.Count - 1; // See if we can add it to the last run if (Runs.Count > 0 && Runs[last].Length != byte.MaxValue && Runs[last].Value.Equals(value)) { Runs[last] = new Run((byte)(Runs[last].Length + 1), Runs[last].Value); } else { // Else add new 1 element run Runs.Add(new Run(0, value)); } }
protected internal virtual void RemoveConnection(GoListener listener) { lock (this) { if (IsDispatching()) { _pendingRuns = Append(_pendingRuns, new RemoveConnectionImpl(this, listener)); } else { _listeners = Cons.RemoveAll(_listeners, listener); ConnectionRemoved(); } } }
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { //we do a CONSIDERABLE amount of trolling. contentPack.artifactDefs.Add(Artifacts.DumpContent()); //args.ReportProgress(1f); contentPack.bodyPrefabs.Add(Bodies.DumpContent()); //args.ReportProgress(1f); contentPack.buffDefs.Add(Buffs.DumpContent()); //args.ReportProgress(1f); contentPack.effectDefs.Add(Effects.DumpContent()); //args.ReportProgress(1f); contentPack.eliteDefs.Add(Elites.DumpContent()); //args.ReportProgress(1f); contentPack.gameEndingDefs.Add(GameEndings.DumpContent()); //args.ReportProgress(1f); contentPack.entityStateConfigurations.Add(Loadouts.DumpConfigs()); //args.ReportProgress(1f); contentPack.entityStateTypes.Add(Loadouts.DumpEntityStates()); //args.ReportProgress(1f); contentPack.skillFamilies.Add(Loadouts.DumpContentSkillFamilies()); //args.ReportProgress(1f); contentPack.skillDefs.Add(Loadouts.DumpContentSkillDefs()); //args.ReportProgress(1f); contentPack.survivorDefs.Add(Loadouts.DumpSurvivorDefs()); //args.ReportProgress(1f); contentPack.masterPrefabs.Add(Masters.DumpContent()); //args.ReportProgress(1f); contentPack.musicTrackDefs.Add(MusicTracks.DumpContent()); //args.ReportProgress(1f); contentPack.networkedObjectPrefabs.Add(NetworkPrefabs.DumpContent()); //args.ReportProgress(1f); contentPack.networkSoundEventDefs.Add(NetworkSoundEvents.DumpContent()); //args.ReportProgress(1f); contentPack.itemDefs.Add(Pickups.DumpContentItems()); //args.ReportProgress(1f); contentPack.equipmentDefs.Add(Pickups.DumpContentEquipment()); //args.ReportProgress(1f); contentPack.projectilePrefabs.Add(Projectiles.DumpContent()); //args.ReportProgress(1f); contentPack.gameModePrefabs.Add(Runs.DumpContent()); //args.ReportProgress(1f); contentPack.sceneDefs.Add(Scenes.DumpContent()); //args.ReportProgress(1f); contentPack.surfaceDefs.Add(SurfaceDefinitions.DumpContent()); args.ReportProgress(1f); yield break; }
protected internal virtual Cons AddCons(Cons cons) { lock (this) { if (IsDispatching()) { _pendingRuns = Append(_pendingRuns, new AddConsImpl(this, cons)); } else { _listeners = Cons.Insert(_listeners, cons); ConnectionAdded(); } return(cons); } }
/// <summary> /// 将蓝图转换成一个要显示的 ListViewItem /// </summary> /// <returns></returns> public ListViewItem ListViewItem() { ListViewItem lvi = new ListViewItem(); // 蓝图名称 if (BluePrints == null) { lvi.Text = invTypes.GetInvTypes(BluePrintID).Name; } else { lvi.Text = BluePrints.invTypes.Name; } lvi.SubItems.Add(ID.ToString()); lvi.SubItems.Add(ItemID.ToString()); lvi.SubItems.Add(BluePrintID.ToString()); lvi.SubItems.Add(MaterialEfficiency.ToString()); lvi.SubItems.Add(TimeEfficiency.ToString()); lvi.SubItems.Add(Quantity.ToString()); lvi.SubItems.Add(Runs.ToString()); // 如果是角色拥有则显示角色名称, 否则直接显示"军团" if (CharacterOwned) { if (Characters == null) { lvi.SubItems.Add(Characters.GetCharacters(Owner).CharacterName); } else { lvi.SubItems.Add(Characters.CharacterName); } } else { lvi.SubItems.Add("军团"); } lvi.SubItems.Add(LocationID.ToString()); lvi.SubItems.Add(LocationFlag.ToString()); lvi.SubItems.Add(UpdateTime.ToString()); lvi.SubItems.Add(Cost.ToString()); return(lvi); }
private void ShrinkActions() { Verifying = true; Shrinking = false; Reporting = false; BreakRun = false; Failed = false; var failingSpec = FailingSpec; var exception = Exception; var max = Runs.Max(); var current = 0; while (current <= max) { Failed = false; TempMemory = new TempMemory(); FailingSpec = failingSpec; Exception = exception; foreach (var run in Runs.ToList()) { RunNumber = run; if (run != current) { Runner(this); } if (BreakRun) { break; } } if (Failed && !BreakRun) { Runs.Remove(current); } current++; } Failed = true; FailingSpec = failingSpec; Exception = exception; }
public IDictionary <string, object> AsDict() { var logURLs = new Dictionary <string, string> (); if (LogURL != null) { string defaultURL; logURLs.TryGetValue("*", out defaultURL); if (defaultURL == null) { logURLs ["*"] = LogURL; } else if (defaultURL != LogURL) { foreach (var run in Runs) { logURLs [run.Benchmark.Name] = LogURL; } } } var dict = new Dictionary <string, object> (); dict ["MainProduct"] = Commit.AsDict(); dict ["SecondaryProducts"] = SecondaryCommits.Select(c => c.AsDict()).ToList(); dict ["Machine"] = Machine.AsDict(); dict ["Config"] = Config.AsDict(); dict ["TimedOutBenchmarks"] = new List <string> (TimedOutBenchmarks); dict ["CrashedBenchmarks"] = new List <string> (CrashedBenchmarks); dict ["StartedAt"] = StartDateTime.ToString(DATETIME_FORMAT); dict ["FinishedAt"] = FinishDateTime.ToString(DATETIME_FORMAT); dict ["BuildURL"] = BuildURL; dict ["LogURLs"] = logURLs; dict ["Runs"] = Runs.Select(r => r.AsDict()).ToList(); if (PullRequestBaselineRunSetId != null) { var prDict = new Dictionary <string, object> (); prDict ["BaselineRunSetID"] = PullRequestBaselineRunSetId.Value; prDict ["URL"] = PullRequestURL; dict ["PullRequest"] = prDict; } return(dict); }
private void ShrinkInputs() { Verifying = false; Shrinking = true; Reporting = false; Failed = false; TempMemory = new TempMemory(); var failingSpec = FailingSpec; var exception = Exception; foreach (var run in Runs.ToList()) { RunNumber = run; Runner(this); } Failed = true; FailingSpec = failingSpec; Exception = exception; }
/// <summary> /// Returns true if PipelineImpllinks instances are equal /// </summary> /// <param name="other">Instance of PipelineImpllinks to be compared</param> /// <returns>Boolean</returns> public bool Equals(PipelineImpllinks other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Runs == other.Runs || Runs != null && Runs.Equals(other.Runs) ) && ( Self == other.Self || Self != null && Self.Equals(other.Self) ) && ( Queue == other.Queue || Queue != null && Queue.Equals(other.Queue) ) && ( Actions == other.Actions || Actions != null && Actions.Equals(other.Actions) ) && ( Class == other.Class || Class != null && Class.Equals(other.Class) )); }
///<summary> /// Returns whether the 'other' CardCombo looks the same as this one, meaning that it has the same runs and sets. /// ONLY CHECKING the suit and rank, not whether the cards are actually identical Objects. ///</summary> public bool LooksEqual(CardCombo other) { if (other.PackCount != PackCount) { return(false); } if (other.CardCount != CardCount) { return(false); } if (other.Sets.Count != Sets.Count || other.Runs.Count != Runs.Count) { return(false); } var orderedSets1 = Sets.OrderBy(set => set.Value); var orderedSets2 = other.Sets.OrderBy(set => set.Value); for (int i = 0; i < orderedSets1.Count(); i++) { if (!orderedSets1.ElementAt(i).LooksEqual(orderedSets2.ElementAt(i))) { return(false); } } var orderedRuns1 = Runs.OrderBy(run => run.Value); var orderedRuns2 = other.Runs.OrderBy(run => run.Value); for (int i = 0; i < orderedRuns1.Count(); i++) { if (!orderedRuns1.ElementAt(i).LooksEqual(orderedRuns2.ElementAt(i))) { return(false); } } return(true); }
public void Insert(int index, T value) { int run, offset; RunAndOffset(index, out run, out offset); if (Runs[run].Length != byte.MaxValue && Runs[run].Value.Equals(value)) { Runs[run] = new Run((byte)(Runs[run].Length + 1), Runs[run].Value); } else if (offset == 0 && run > 0 && Runs[run - 1].Length != byte.MaxValue && Runs[run - 1].Value.Equals(value)) { Runs[run - 1] = new Run((byte)(Runs[run - 1].Length + 1), Runs[run - 1].Value); } else if (offset == Runs[run].Length && run < Runs.Count - 1 && Runs[run + 1].Length != byte.MaxValue && Runs[run + 1].Value.Equals(value)) { Runs[run + 1] = new Run((byte)(Runs[run + 1].Length + 1), Runs[run + 1].Value); } else { var before = offset; var after = (Runs[run].Length + 1) - offset; var val = Runs[run].Value; Runs[run] = new Run(0, value); if (before != 0) { Runs.Insert(run, new Run((byte)(before - 1), val)); } if (after != 0) { Runs.Insert(run + 1, new Run((byte)(after - 1), val)); } } }
void drawBallLine(Runs ballRun) { // increase run count RunsCount[ballRun.GetValue() - 1]++; float length = ballRun.GetLength() / 10; int zone = ballRun.GetZone(); GameObject shotline = Instantiate(ShotImg) as GameObject; shotline.transform.SetParent(Wheel.transform); shotline.transform.localPosition = Vector3.zero; ballRun.SetLine(shotline); //random angle for the give zone float angle = 45 * zone; angle = Random.Range((angle - 45) + 5, angle - 5); //random angle for the give zone shotline.transform.localEulerAngles = new Vector3(0, 0, angle); shotline.GetComponent <Image>().fillAmount = length; shotline.GetComponent <Image>().color = ShotColors[ballRun.GetValue() - 1]; }
/// <summary> /// Create a new Runs object. /// </summary> /// <param name="ID">Initial value of Id.</param> public static Runs CreateRuns(int ID) { Runs runs = new Runs(); runs.Id = ID; return runs; }
/// <summary> /// There are no comments for Runs in the schema. /// </summary> public void AddToRuns(Runs runs) { base.AddObject("Runs", runs); }
private TextRun _GetTextRun(int textSourceCharacterIndex) { _charIndex = textSourceCharacterIndex; _debugFn?.Invoke($"GetTextRun(textSourceCharacterIndex = {textSourceCharacterIndex})", 5); if (textSourceCharacterIndex == 0) { #if DEBUG _debugFn?.Invoke($"Clearing runs because at beginning of text source", 4); #endif Runs.Clear(); SyntaxInfos = GetSyntaxInfos().GetEnumerator(); if (!SyntaxInfos.MoveNext()) { var endOfParagraph = new CustomTextEndOfParagraph(2) { Index = textSourceCharacterIndex }; Runs.Add(endOfParagraph); return(endOfParagraph); } } else { #if DEBUGRUNS foreach (var textRun in Runs) { _debugFn?.Invoke(" " + textRun.ToString(), 4); } #endif Runs = RunsBefore(textSourceCharacterIndex, Runs).ToList(); } var si = SyntaxInfos.Current; if (si == null) { var endOfParagraph = new CustomTextEndOfParagraph(2) { Index = textSourceCharacterIndex }; Runs.Add(endOfParagraph); return(endOfParagraph); } // ReSharper disable once PossibleNullReferenceException while (textSourceCharacterIndex > si.Span1.Start || /*|| si.Span1.End < textSourceCharacterIndex*/ si.Text.Length == 0) { if (!SyntaxInfos.MoveNext()) { if (textSourceCharacterIndex < Length) { var len = Length - textSourceCharacterIndex; var buf = new char[len]; Text.CopyTo(textSourceCharacterIndex, buf, 0, len); if (len == 2 && buf[0] == '\r' && buf[1] == '\n') { var eol = new CustomTextEndOfLine(2) { Index = textSourceCharacterIndex }; Runs.Add(eol); return(eol); } var t = string.Join("", buf); var customTextCharacters = new CustomTextCharacters(t, MakeProperties(SyntaxKind.None, t)) { Index = textSourceCharacterIndex }; Runs.Add(customTextCharacters); return(customTextCharacters); } var endOfParagraph = new CustomTextEndOfParagraph(2) { Index = textSourceCharacterIndex }; Runs.Add(endOfParagraph); return(endOfParagraph); } si = SyntaxInfos.Current; } if (textSourceCharacterIndex < si.Span1.Start) { var len = si.Span1.Start - textSourceCharacterIndex; var buf = new char[len]; Text.CopyTo(textSourceCharacterIndex, buf, 0, len); if (len == 2 && buf[0] == '\r' && buf[1] == '\n') { var eol = new CustomTextEndOfLine(2) { Index = textSourceCharacterIndex }; Runs.Add(eol); return(eol); } var t = string.Join("", buf); var nl = t.IndexOf("\r\n", StringComparison.Ordinal); if (nl != -1) { t = t.Substring(0, nl); if (t == "") { var eol = new CustomTextEndOfLine(2) { Index = textSourceCharacterIndex }; Runs.Add(eol); return(eol); } var ctc = new CustomTextCharacters(t, MakeProperties(SyntaxKind.None, t)) { Index = textSourceCharacterIndex }; Runs.Add(ctc); return(ctc); } var customTextCharacters = new CustomTextCharacters(t, MakeProperties(SyntaxKind.None, t)) { Index = textSourceCharacterIndex }; Runs.Add(customTextCharacters); return(customTextCharacters); } // while (textSourceCharacterIndex > si.Span1.Start) // { // if (!SyntaxInfos.MoveNext()) // { // } // } if (textSourceCharacterIndex != si.Span1.Start) { throw new InvalidOperationException("Character index does not match span start"); } if (si.SyntaxTrivia.HasValue) { var syntaxKind = CSharpExtensions.Kind(si.SyntaxTrivia.Value); if (syntaxKind == SyntaxKind.EndOfLineTrivia || syntaxKind == SyntaxKind.XmlTextLiteralNewLineToken) { var customTextEndOfLine = new CustomTextEndOfLine(2) { Index = textSourceCharacterIndex }; Runs.Add(customTextEndOfLine); return(customTextEndOfLine); } var p = PropsFor(si.SyntaxTrivia.Value, si.Text); var syntaxTriviaTextCharacters = new SyntaxTriviaTextCharacters(si.Text, p, si.Span1, si.SyntaxTrivia.Value, si.Node, si.Token, si.TriviaPosition, si.StructuredTrivia) { Index = si.Span1.Start }; Runs.Add(syntaxTriviaTextCharacters); return(syntaxTriviaTextCharacters); } if (si.SyntaxToken.HasValue) { if (CSharpExtensions.Kind(si.SyntaxToken.Value) == SyntaxKind.XmlTextLiteralNewLineToken) { var customTextEndOfLine = new CustomTextEndOfLine(2) { Index = textSourceCharacterIndex }; Runs.Add(customTextEndOfLine); return(customTextEndOfLine); } var syntaxTokenTextCharacters = new SyntaxTokenTextCharacters(si.Text, si.Text.Length, PropsFor(si.SyntaxToken.Value, si.Text), si.SyntaxToken.Value, si.SyntaxToken.Value.Parent) { Index = si.Span1.Start }; Runs.Add(syntaxTokenTextCharacters); return(syntaxTokenTextCharacters); } var textEndOfParagraph = new CustomTextEndOfParagraph(2) { Index = textSourceCharacterIndex }; Runs.Add(textEndOfParagraph); return(textEndOfParagraph); #if false Debug.WriteLine($"index: {textSourceCharacterIndex}"); TextSpan?TakeToken() { var includeDocumentationComments = true; var includeDirectives = true; var includeSkipped = true; var includeZeroWidth = true; token = token.HasValue ? token.Value.GetNextToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments) : Node?.GetFirstToken(includeZeroWidth, includeSkipped, includeDirectives, includeDocumentationComments); if (token.HasValue) { if (!_starts.Any() && token.Value.SpanStart != 0) { } var tuple = new StartInfo(token.Value.Span, token.Value); _starts.Add(tuple); DumpStarts(); return(token.Value.Span); } return(null); } TextSpan?span = null; if (textSourceCharacterIndex == 0) { if (Length == 0) { return(new TextEndOfParagraph(2)); } _curStart = 0; if (_starts.Any()) { var startInfo = _starts.First(); token = startInfo.Token; trivia = startInfo.SyntaxTrivia; span = startInfo.TextSpan; if (token.HasValue) { CheckToken(token); } } // _starts.Clear(); DumpStarts(); } else { var startInfo = _starts[_curStart]; token = startInfo.Token; trivia = startInfo.SyntaxTrivia; span = startInfo.TextSpan; if (token.HasValue) { CheckToken(token); } } try { var childInPos = Node.ChildThatContainsPosition(textSourceCharacterIndex); if (childInPos.IsNode) { var n = childInPos.AsNode(); if (textSourceCharacterIndex < n.SpanStart) { foreach (var syntaxTrivia in n.GetLeadingTrivia()) { if (textSourceCharacterIndex >= syntaxTrivia.SpanStart && textSourceCharacterIndex < syntaxTrivia.Span.End) { Debug.WriteLine("In trivia " + syntaxTrivia); if (textSourceCharacterIndex > syntaxTrivia.SpanStart) { Debug.WriteLine("In middle of trivia"); } var characterString = syntaxTrivia.ToFullString(); return(new SyntaxTriviaTextCharacters(characterString, PropsFor(syntaxTrivia, characterString), syntaxTrivia.FullSpan, syntaxTrivia, null, null, TriviaPosition.Leading)); } } } } } catch (Exception ex) { } var token1 = token; // Debug.WriteLine("Index = " + textSourceCharacterIndex); // if (!token1.HasValue) // { // span = TakeToken(); // if (!this.token.HasValue) return new TextEndOfParagraph(2); // token1 = this.token; // } // var token = token1.Value; if (!span.HasValue) { throw new InvalidOperationException(); } var k = span.Value; if (textSourceCharacterIndex < k.Start) { var len = k.Start - textSourceCharacterIndex; var buf = new char[len]; Text.CopyTo(textSourceCharacterIndex, buf, 0, len); if (len == 2 && buf[0] == '\r' && buf[1] == '\n') { return(new CustomTextEndOfLine(2)); } var t = string.Join("", buf); return(new CustomTextCharacters(t, MakeProperties(SyntaxKind.None, t))); } else if (textSourceCharacterIndex >= k.End && k.Length != 0) { TakeToken(); return(GetTextRun(textSourceCharacterIndex)); } else { if (trivia.HasValue) { var syntaxTrivia1 = trivia.Value; var q = syntaxTrivia1.Token.LeadingTrivia .SkipWhile(syntaxTrivia => syntaxTrivia != syntaxTrivia1) .Skip(1); if (q.Any()) { _curStart++; var startInfo = new StartInfo(q.First()); if (_starts.Count <= _curStart) { _starts.Add(startInfo); } else { _starts[_curStart] = startInfo; } } else { var t2 = syntaxTrivia1.Token.GetNextToken(true, true, true, true); if (t2.HasLeadingTrivia) { var st = new StartInfo(t2.LeadingTrivia.First()); _curStart++; if (_starts.Count <= _curStart) { _starts.Add(st); } else { _starts[_curStart] = st; } } else if (CSharpExtensions.Kind(t2) != SyntaxKind.None) { var st = new StartInfo(t2.Span, t2); _curStart++; if (_starts.Count <= _curStart) { _starts.Add(st); } else { _starts[_curStart] = st; } } } var t = syntaxTrivia1.ToFullString(); return(new SyntaxTriviaTextCharacters(t, PropsFor(trivia.Value, t), span.Value, syntaxTrivia1, null, null, TriviaPosition.Leading)); } if (token.HasValue && (CSharpExtensions.Kind(token.Value) == SyntaxKind.None || CSharpExtensions.Kind(token.Value) == SyntaxKind.EndOfFileToken)) { return(new TextEndOfParagraph(2)); } var token0 = token.Value; if (CSharpExtensions.Kind(token0) == SyntaxKind.EndOfLineTrivia) { return(new CustomTextEndOfLine(2)); } var len = k.Length; if (len == 0) { TakeToken(); return(GetTextRun(textSourceCharacterIndex)); } TakeToken(); if (token0.Text.Length != len) { } return(new CustomTextCharacters(token0.Text, MakeProperties(token, token0.Text))); } #endif }
private void optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs <IRun> e) { lock (runsLocker) Runs.RemoveRange(e.Items); }