/// <summary> /// True if this node has siblings with the same charge state, and /// if those siblings must be in-synch, then only if they are not. /// For small molecules, true only if all transitions are precursor transitions /// </summary> private bool HasSiblingsToSynch(bool mustBeInSynch) { var siblingNodes = Parent.Nodes; if (siblingNodes.Count > 1) { // For small molecules, we can only synch precursor transitions, // and only if both transition groups are defined by formula, or both by mz if (!IsSynchable()) { return(false); } var tranGroupThis = DocNode.TransitionGroup; foreach (TransitionGroupTreeNode nodeTree in siblingNodes) { var tranGroup = nodeTree.DocNode.TransitionGroup; if (!ReferenceEquals(tranGroupThis, tranGroup) && tranGroupThis.PrecursorCharge == tranGroup.PrecursorCharge && !(mustBeInSynch && DocNode.EquivalentChildren(nodeTree.DocNode))) { if (!tranGroupThis.IsCustomIon) { return(true); } else if (tranGroup.IsCustomIon && nodeTree.IsSynchable() && string.IsNullOrEmpty(tranGroupThis.CustomIon.Formula) == string.IsNullOrEmpty(tranGroup.CustomIon.Formula)) { return(true); } } } } return(false); }
public static TestClass FromDoc(TestClass existing, DocNode doc) { if (doc.Type != DocNodeType.List) { throw new System.ArgumentException("Not a list! " + doc.Type); } if (doc[0].StringValue == "Derived") { TestClassDerived derivedExisting; if (existing is TestClassDerived) { derivedExisting = (TestClassDerived)existing; } else { derivedExisting = new TestClassDerived(); } derivedExisting.derivedKey = Convert.ToInt32(doc[1].StringValue, System.Globalization.CultureInfo.InvariantCulture); return(derivedExisting); } else { if (!(existing is TestClass)) { existing = new TestClass(); } existing.baseKey = Convert.ToInt32(doc[1].StringValue, System.Globalization.CultureInfo.InvariantCulture); return(existing); } }
private void SelectedDocument(object sender, TreeViewEventArgs e) { switchingDoc = true; CurrentNode = e.Node as DocNode; (e.Node as DocNode).Doc.Load(); DocNode.DisplayNames(); }
public override IEnumerable <DocNode> GetChoices(bool useFilter) { SrmSettings settings = DocSettings; List <DocNode> listPeptides = new List <DocNode>(); foreach (var nodePep in DocNode.GetPeptideNodes(settings, useFilter)) { var nodePepMaterialized = nodePep.ChangeSettings(settings, SrmSettingsDiff.ALL); if (!useFilter || settings.TransitionSettings.Libraries.MinIonCount == 0 || nodePepMaterialized.Children.Count != 0) { listPeptides.Add(nodePepMaterialized); } } PeptideRankId rankId = DocSettings.PeptideSettings.Libraries.RankId; if (rankId != null && !DocNode.IsPeptideList) { listPeptides = PeptideGroup.RankPeptides(listPeptides, settings, useFilter).ToList(); } MergeChosen(listPeptides, useFilter, node => ((PeptideDocNode)node).Key); return(listPeptides); }
public void MergedDict() { CreateFile("globals.yaml", "Beetles: 12\nBirdName: Shabazz\nVersion: 1.2"); CreateFile("items.yaml", "Treehouse: true"); CreateFile("rooms.yaml", "Version: 1.3\nrooms:\n - Overthorax\n - Chirpinghouse\n - Antennagate\n - Subchitin"); Configs.Preload(); DocNode MixedDict = null; // load all files from the DictDir into one dict Configs.LoadFilesAsMergedDict("*", d => { MixedDict = d; return(true); }); Assert.IsNotNull(MixedDict); Assert.AreEqual(5, MixedDict.Count); Assert.AreEqual(12, MixedDict["Beetles"].As <int>()); Assert.AreEqual(1.3f, MixedDict["Version"].As <float>()); Assert.True(MixedDict["Treehouse"].As <bool>()); // Overwrite file contents CreateFile("items.yaml", "Chitin: 1000"); // force a reload Configs.Update(1.0f); Assert.AreEqual(5, MixedDict.Count); Assert.False(MixedDict.ContainsKey("Treehouse")); Assert.AreEqual(1000, MixedDict["Chitin"].As <int>()); }
public static void TestTagModelIsPlayingUpdater_IsPlaying() { PlayerModel model = new PlayerModel(); TagModelList tml = DocNode.Create <TagModelList>(); tml.SetFiles(TestTagModel.testFileNames); PlayerModelIsPlayingUpdater updater = new PlayerModelIsPlayingUpdater(); updater.Model = model; updater.Items = tml.Items; for (int i = 0; i < tml.Items.Count; ++i) { model.CurrentModel.Value = tml[i]; for (int j = 0; j < tml.Items.Count; ++j) { UnitTest.Test(tml[j].IsPlaying.Value == (i == j)); } } model.CurrentModel.Value = null; }
// let's take over the parsing of Location, because we want to be able to // have a short form for the common case of specifying only the position public static Location FromDoc(Location existing, DocNode doc) { if (existing == null) { // want to modify an existing Location if possible, but if it's // null we need to instantiate it existing = new Location(default, default);
public static TagModel CreateClone(TagModel other) { TagModel tagModel = DocNode.Create <TagModel>(); tagModel.Init(other.FileNameFull, other.ToTag(), other.Bitrate.Value); return(tagModel); }
public static PropertyName GetNodeName(SrmDocument doc, DocNode docNode) { DocNode nextNode = null; if (docNode is TransitionDocNode) { nextNode = doc.MoleculeTransitionGroups.FirstOrDefault(group => group.Transitions.Any(t => ReferenceEquals(t.Id, docNode.Id))); } else if (docNode is TransitionGroupDocNode) { nextNode = doc.Molecules.FirstOrDefault(group => group.TransitionGroups.Any(t => ReferenceEquals(t.Id, docNode.Id))); } else if (docNode is PeptideDocNode) { nextNode = doc.MoleculeGroups.FirstOrDefault(group => group.Molecules.Any(m => ReferenceEquals(m.Id, docNode.Id))); } // TODO: add other interface to these doc nodes? var auditLogObj = docNode as IAuditLogObject; if (auditLogObj == null) { return(null); } var text = auditLogObj.AuditLogText; return(nextNode == null ? PropertyName.ROOT.SubProperty(text) : GetNodeName(doc, nextNode).SubProperty(text)); }
public override IEnumerable <DocNode> GetChoices(bool useFilter) { var mods = DocNode.ExplicitMods; var listChildrenNew = new List <DocNode>(); foreach (TransitionGroup group in DocNode.GetTransitionGroups(DocSettings, mods, useFilter)) { // The maximum allowable precursor charge may be larger than it makes sense to show. var charges = group.IsProteomic ? DocSettings.TransitionSettings.Filter.PeptidePrecursorCharges : DocSettings.TransitionSettings.Filter.SmallMoleculePrecursorAdducts; if (Math.Abs(group.PrecursorAdduct.AdductCharge) <= TransitionGroup.MAX_PRECURSOR_CHARGE_PICK || charges.Contains(group.PrecursorAdduct)) { var nodeChoice = CreateChoice(group, mods); if (!useFilter || DocSettings.TransitionSettings.Libraries.HasMinIonCount(nodeChoice)) { listChildrenNew.Add(nodeChoice); } } } var nodePep = (PeptideDocNode)DocNode.ChangeChildren(listChildrenNew); nodePep.ChangeSettings(DocSettings, SrmSettingsDiff.PROPS); listChildrenNew = new List <DocNode>(nodePep.Children); MergeChosen(listChildrenNew, useFilter); return(listChildrenNew); }
public void RequestPlaying(string filename) { TagModel model = DocNode.Create <TagModel>(); model.FileNameFull = filename; try { int tagSize = TagUtils.TagSizeV2(new FileInfo(filename)); using (Stream stream = VirtualDrive.OpenInStream(filename)) { stream.Seek(tagSize, SeekOrigin.Begin); model.Bitrate.Value = ID3MediaFileHeader.MP3Header.ReadBitrate( stream, VirtualDrive.FileLength(filename)); } } catch (Exception) { } FileInfo fileInfo = new FileInfo(filename); FileTreeModel.ExpandAndSelect(fileInfo.DirectoryName, true); RequestPlaying(model); }
public static IdentityPath ToIdentityPath(IList <int> idPath, SrmDocument document) { IdentityPath identityPath = ROOT; DocNode next = document; foreach (int globalIndex in idPath) { DocNodeParent parent = next as DocNodeParent; if (null == parent) { return(null); } next = null; foreach (var child in parent.Children) { if (child.Id.GlobalIndex == globalIndex) { next = child; break; } } if (null == next) { return(null); } identityPath = new IdentityPath(identityPath, next.Id); } return(identityPath); }
protected DocNode DeleteChildren(DocNode parent, IdentityPath identityPath, HashSet <IdentityPath> pathsToDelete) { var docNodeParent = parent as DocNodeParent; if (docNodeParent == null) { return(parent); } if (docNodeParent.Children.Count == 0) { return(parent); } var newChildren = new List <DocNode>(); foreach (var child in docNodeParent.Children) { var childPath = new IdentityPath(identityPath, child.Id); if (pathsToDelete.Contains(childPath)) { continue; } var newChild = DeleteChildren(child, childPath, pathsToDelete); if (newChild != null) { newChildren.Add(newChild); } } if (newChildren.Count == 0) { return(null); } return(docNodeParent.ChangeChildren(newChildren)); }
private void OnFileRequest(object sender, AccessObserver.AccessObserverEventArgs args) { Action action = null; switch (args.Request) { case AccessObserver.AccessRequest.LockExclusive: action = delegate { if (Model.CurrentModel.Value.FileNameFull == args.ObservedId) { PausePosition = (long)Player.Position.TotalMilliseconds; Controller.Stop(); System.Threading.Thread.Sleep(100); VirtualDrive.ObserverFreeShared.Register(Model.CurrentModel.Value.FileNameFull, OnFileRequest); } }; break; case AccessObserver.AccessRequest.FreeShared: action = delegate { VirtualDrive.ObserverFreeShared.Unregister(args.ObservedId); if (Model.CurrentModel.Value.FileNameFull == args.ObservedId) { if (String.IsNullOrEmpty(args.NewObservedId)) { Model.CurrentModel.Value = null; } else { try { TagModel model = DocNode.Create <TagModel>(); model.Load(args.NewObservedId); Model.CurrentModel.Value = model; Controller.Play(); Player.Position = new TimeSpan(0, 0, 0, 0, (int)PausePosition); } catch (Exception e) { Logger.WriteLine(Tokens.Exception, e); } } } }; break; } if (!Object.ReferenceEquals(action, null)) { Player.Dispatcher.Invoke(action); } }
protected GraphData(SrmDocument document, DocNode docNode, DisplayTypeChrom displayType, GraphValues.ReplicateGroupOp replicateGroupOp, PaneKey paneKey) { _document = document; _docNode = docNode; _displayType = displayType; ReplicateGroupOp = replicateGroupOp; _paneKey = paneKey; }
private void fileWrite(StreamWriter file, DocNode node, string tabs = "") { file.WriteLine(tabs + "{" + node.Doc.Title + "|" + node.Doc.Text.Replace(System.Environment.NewLine, "%").TrimEnd("%".ToCharArray()) + "}"); foreach (DocNode child in node.Nodes) { fileWrite(file, child, tabs + "\t"); } }
/// <summary> /// Sets all members on a struct from the given dictionary DocNode /// </summary> /// <param name="obj"></param> /// <param name="doc">The doc to read fields from. Must be a dictionary.</param> /// <param name="options"></param> /// <typeparam name="T"></typeparam> public void SetFieldsOnStruct <T>(ref T obj, DocNode doc, ReificationOptions?options = null) where T : struct { var type = typeof(T); object setRef = obj; SetFieldsOnObject(type, ref setRef, doc, options); obj = (T)setRef; }
public void DeepMerge_DifferentDocTypes_ThrowsException() { var emptyDoc = new ComposedDocNode(DocNodeType.List); var otherEmptyDoc = new ComposedDocNode(DocNodeType.Dictionary); Assert.That(() => DocNode.DeepMerge(emptyDoc, otherEmptyDoc), Throws.TypeOf <ArgumentException>()); }
public static void TestBasic() { Playlist playlist = DocNode.Create <Playlist>(); playlist.Player = new PlayerModel(); UnitTest.Test(Object.ReferenceEquals(playlist.IsPlayingUpdater.Model, playlist.Player)); UnitTest.Test(Object.ReferenceEquals(playlist.IsPlayingUpdater.Items, playlist.Items)); }
public override string ToString() { if (DocNode.Peptide.IsCustomMolecule) { return(DocNode.CustomMolecule.ToString()); } return(DocNode.GetCrosslinkedSequence()); }
protected Brush GetBrushForNode(SrmSettings settings, DocNode docNode, Color color) { var transitionDocNode = docNode as TransitionDocNode; if (transitionDocNode == null || transitionDocNode.IsQuantitative(settings)) { return(new SolidBrush(color)); } return(new HatchBrush(HatchStyle.Percent50, color, SystemColors.Window)); }
public void DeepMerge_DictsWithDifferentKeys_KeysCombined() { var doc = CreateDictNode(Pair("A", "1"), Pair("B", "2")); var otherDoc = CreateDictNode(Pair("X", "9"), Pair("Y", "10")); var merged = DocNode.DeepMerge(doc, otherDoc); var ideal = CreateDictNode(Pair("A", "1"), Pair("B", "2"), Pair("X", "9"), Pair("Y", "10")); Assert.AreEqual(ideal, merged); }
public static PeptideTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { Debug.Assert(nodeDoc is PeptideDocNode); var nodeTree = new PeptideTreeNode(tree, (PeptideDocNode)nodeDoc); if (tree.ExpandPeptides) { nodeTree.Expand(); } return(nodeTree); }
private TransitionGroupDocNode CreateChoice(Identity childId, ExplicitMods mods) { TransitionGroup tranGroup = (TransitionGroup)childId; TransitionDocNode[] transitions = DocNode.GetMatchingTransitions( tranGroup, DocSettings, mods); var nodeGroup = new TransitionGroupDocNode(tranGroup, transitions); return(nodeGroup.ChangeSettings(DocSettings, DocNode, mods, SrmSettingsDiff.ALL)); }
private IEnumerable <string> GetGalleryPageUris() { var pageNodes = DocNode.SelectNodes(GALLERY_PAGE_LINKS).Skip(1); string page_1 = pageNodes.First().SelectSingleNode("a").Attributes["href"].Value; int totalPageCount = int.Parse(pageNodes.Skip(pageNodes.Count() - 2).First().SelectSingleNode("a").InnerHtml); Logger.SafeWriteLine($"Found {totalPageCount} pages in total for gallery '{GalleryName}'"); var page_others = Enumerable.Range(1, totalPageCount - 1).Select(x => $"{page_1}?p={x}"); return(new string[] { page_1 }.Concat(page_others).ToArray()); }
//public string PROTEIN_TITLE = "Protein"; //public const string PEPTIDE_LIST_TITLE = "Peptide List"; public static PeptideGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { var nodeTree = new PeptideGroupTreeNode(tree, (PeptideGroupDocNode)nodeDoc); if (tree.ExpandProteins) { nodeTree.Expand(); } return(nodeTree); }
public void DeepMerge_Lists_ListsMerged() { var doc = CreateListNode("foo", "bar"); var otherDoc = CreateListNode("wiggle", "waggle"); var merged = DocNode.DeepMerge(doc, otherDoc); var ideal = CreateListNode("foo", "bar", "wiggle", "waggle"); Assert.AreEqual(ideal, merged); }
internal static object FromTimeSpan(object existing, DocNode doc) { bool isSuccess = TimeSpan.TryParse(doc.StringValue, out var newSpan); if (!isSuccess) { throw new ParseException("expected parseable timespan string " + doc.StringValue, null); } return(newSpan); }
public void DeepMerge_DictsWithIdenticallyKeyedLists_ListsCombined() { var doc = CreateDictNode(Pair("A", CreateListNode("foo", "bar"))); var otherDoc = CreateDictNode(Pair("A", CreateListNode("wiggle", "waggle"))); var merged = DocNode.DeepMerge(doc, otherDoc); var ideal = CreateDictNode(Pair("A", CreateListNode("foo", "bar", "wiggle", "waggle"))); Assert.AreEqual(ideal, merged); }
public void DeepMerge_DictsWithSameKeys_OtherKeysPreferred() { var doc = CreateDictNode(Pair("A", "1"), Pair("B", "2")); var otherDoc = CreateDictNode(Pair("A", "9"), Pair("Y", "10")); var merged = DocNode.DeepMerge(doc, otherDoc); var ideal = CreateDictNode(Pair("A", "9"), Pair("B", "2"), Pair("Y", "10")); Assert.AreEqual(ideal, merged); }
//public string PROTEIN_TITLE = "Protein"; //public const string PEPTIDE_LIST_TITLE = "Peptide List"; public static PeptideGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { var nodeTree = new PeptideGroupTreeNode(tree, (PeptideGroupDocNode)nodeDoc); if (tree.ExpandProteins) nodeTree.Expand(); return nodeTree; }
public static Distribution FromDoc(Distribution existing, DocNode doc) { // a single number means we want just a fixed value instead of a random distribution if (doc.Type == DocNodeType.Scalar) { var fixedValue = System.Convert.ToSingle(doc.StringValue); if (existing != null && existing is Range) { ((Range)existing).Start = fixedValue; ((Range)existing).End = fixedValue; return existing; } else { return new Range(fixedValue, fixedValue); } } var first = doc[0].StringValue; var resultType = typeof(Range); int startingIndex = 1; if (first == "vary") { resultType = typeof(Vary); } else if (first == "gaussian") { resultType = typeof(Gaussian); } else if (first == "binomial") { resultType = typeof(Binomial); } else if (first == "exponential") { resultType = typeof(Exponential); } else if (first == "range") { resultType = typeof(Range); } else { // we haven't found a tag we know about, so assume that the first value is a number and it's a Range startingIndex = 0; } // all these distributions take two floats as arguments, so let's parse those out first float firstNum = System.Convert.ToSingle(doc[startingIndex].StringValue); float secondNum = System.Convert.ToSingle(doc[startingIndex + 1].StringValue); // set the numbers appropriate to the class if (resultType == typeof(Range)) { if (existing != null && existing is Range) { ((Range)existing).Start = firstNum; ((Range)existing).End = secondNum; } else { existing = new Range(firstNum, secondNum); } } else if (resultType == typeof(Vary)) { if (existing != null && existing is Vary) { ((Vary)existing).Mean = firstNum; ((Vary)existing).Proportion = secondNum; } else { existing = new Vary(firstNum, secondNum); } } else if (resultType == typeof(Gaussian)) { if (existing != null && existing is Gaussian) { ((Gaussian)existing).Mean = firstNum; ((Gaussian)existing).StdDev = secondNum; } else { existing = new Gaussian(firstNum, secondNum); } } else if (resultType == typeof(Binomial)) { if (existing != null && existing is Binomial) { ((Binomial)existing).FlipProb = firstNum; ((Binomial)existing).Max = secondNum; } else { existing = new Binomial(firstNum, secondNum); } } else if (resultType == typeof(Exponential)) { if (existing != null && existing is Exponential) { ((Exponential)existing).InvLambda = firstNum; ((Exponential)existing).Minimum = secondNum; } else { existing = new Exponential(firstNum, secondNum); } } return existing; }
public override Image GetPickPeakImage(DocNode child) { return TransitionTreeNode.GetPeakImage((TransitionDocNode)child, PepNode, SequenceTree); }
private static bool ContainsChoice(IList<DocNode> choices, DocNode choice) { return choices.IndexOf(c => ReferenceEquals(c, choice)) != -1; }
public static PeptideTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { Debug.Assert(nodeDoc is PeptideDocNode); var nodeTree = new PeptideTreeNode(tree, (PeptideDocNode)nodeDoc); if (tree.ExpandPeptides) nodeTree.Expand(); return nodeTree; }
public override Image GetPickTypeImage(DocNode child) { return PeptideTreeNode.GetTypeImage((PeptideDocNode) child, SequenceTree); }
public AreaGraphData(SrmDocument document, DocNode docNode, DisplayTypeChrom displayType, GraphValues.ReplicateGroupOp replicateGroupOp, int ratioIndex, AreaNormalizeToData normalize, AreaExpectedValue expectedVisible, PaneKey paneKey) : base(document, docNode, displayType, replicateGroupOp, paneKey) { _docNode = docNode; _ratioIndex = ratioIndex; _normalize = normalize; _expectedVisible = expectedVisible; }
protected override int GetPickInsertIndex(DocNode node, IList<DocNode> choices, int iFirst, int iLast) { var nodePep = (PeptideDocNode) node; for (int i = iFirst; i < iLast; i++) { var nodeNext = (PeptideDocNode) choices[i]; // If the next node is later in order than the node to insert, then // insert before it. if (nodePep.Peptide.Begin.HasValue && nodeNext.Peptide.Begin.HasValue && nodePep.Peptide.Begin.Value < nodeNext.Peptide.Begin.Value) { return i; } // If the next node is the same peptide and has explicit modifications, // insert before it. if (Equals(nodePep.Peptide, nodeNext.Peptide) && nodeNext.HasExplicitMods) { return i; } } // Use the last possible insertion point. return iLast; }
public PeptideGraphInfo GetPeptideGraphInfo(DocNode docNode) { return SequenceTree.GetPeptideGraphInfo(docNode); }
public override string GetPickLabel(DocNode child) { return TransitionGroupTreeNode.DisplayText((TransitionGroupDocNode)child, SequenceTree.GetDisplaySettings((PeptideDocNode) Model)); }
public PickListChoice(DocNode choice, string label, bool chosen) { Choice = choice; Label = label; Chosen = chosen; }
public override ITipProvider GetPickTip(DocNode child) { return new PickTransitionGroupTip(DocNode, (TransitionGroupDocNode) child, DocSettings); }
private void pickListMulti_MouseMove(object sender, MouseEventArgs e) { Point pt = e.Location; if (!_moveThreshold.Moved(pt)) return; _moveThreshold.Location = null; ITipProvider tipProvider = null; int i = GetIndexAtPoint(pt); // Make sure it is in the text portion of the item if (i != -1 && !GetItemTextRectangle(i).Contains(pt)) i = -1; if (i == -1) { _lastTipNode = null; _lastTipProvider = null; } else { var nodeDoc = GetVisibleChoice(i).Choice; if (!ReferenceEquals(nodeDoc, _lastTipNode)) { _lastTipNode = nodeDoc; _lastTipProvider = _picker.GetPickTip(nodeDoc); } tipProvider = _lastTipProvider; } if (tipProvider == null || !tipProvider.HasTip) _nodeTip.HideTip(); else _nodeTip.SetTipProvider(tipProvider, GetItemTextRectangle(i), pt); }
public override string GetPickLabel(DocNode child) { return TransitionTreeNode.DisplayText((TransitionDocNode) child, SequenceTree.GetDisplaySettings(PepNode)); }
public override ITipProvider GetPickTip(DocNode child) { return new PickTransitionTip((TransitionDocNode) child); }
public static TransitionGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { Debug.Assert(nodeDoc is TransitionGroupDocNode); var nodeTree = new TransitionGroupTreeNode(tree, (TransitionGroupDocNode) nodeDoc); if (tree.ExpandPrecursors) nodeTree.Expand(); return nodeTree; }
public override Image GetPickTypeImage(DocNode child) { return TransitionGroupTreeNode.GetTypeImage((TransitionGroupDocNode) child, SequenceTree); }
public static TransitionTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc) { Debug.Assert(nodeDoc is TransitionDocNode); return new TransitionTreeNode(tree, (TransitionDocNode)nodeDoc); }
public override ITipProvider GetPickTip(DocNode child) { return new PickPeptideTip((PeptideDocNode) child, DocSettings); }
public override bool DrawPickLabel(DocNode child, Graphics g, Rectangle bounds, ModFontHolder fonts, Color foreColor, Color backColor) { PeptideTreeNode.DrawPeptideText((PeptideDocNode) child, DocSettings, null, g, bounds, fonts, foreColor, backColor); return true; }
private IEnumerable<Bookmark> FindAll(IdentityPath identityPath, DocNode docNode) { var results = new List<Bookmark>(); var transitionGroupDocNode = docNode as TransitionGroupDocNode; if (transitionGroupDocNode == null) { var docNodeParent = docNode as DocNodeParent; if (docNodeParent == null) { return results; } foreach (var child in docNodeParent.Children) { results.AddRange(FindAll(new IdentityPath(identityPath, child.Id), child)); } return results; } if (!transitionGroupDocNode.HasResults) { return results; } for (int iReplicate = 0; iReplicate < transitionGroupDocNode.Results.Count; iReplicate++) { var replicate = transitionGroupDocNode.Results[iReplicate]; if (replicate == null) { continue; } var fileDatas = new Dictionary<FinderChromFileKey, FinderChromFileData>(); foreach (var transitionGroupChromInfo in replicate) { FinderChromFileData chromFileData; var chromFileKey = new FinderChromFileKey(transitionGroupChromInfo); if (!fileDatas.TryGetValue(chromFileKey, out chromFileData)) { chromFileData = new FinderChromFileData { TransitionGroupChromInfo = transitionGroupChromInfo, MatchingTransitionBookmarks = new List<Bookmark>(), AllTransitionsMatch = true, }; fileDatas.Add(chromFileKey, chromFileData); } } foreach (var transitionDocNode in transitionGroupDocNode.Transitions) { if (!transitionDocNode.HasResults || iReplicate >= transitionDocNode.Results.Count) { continue; } var transitionResults = transitionDocNode.Results[iReplicate]; if (transitionResults == null) { continue; } var transitionId = new IdentityPath(identityPath, transitionDocNode.Id); foreach (var chromInfo in transitionResults) { FinderChromFileData chromFileData; bool match = MatchTransition(chromInfo) != null; var transitionBookmark = new Bookmark(transitionId, chromInfo.FileId, chromInfo.OptimizationStep); var chromFileKey = new FinderChromFileKey(chromInfo); if (!fileDatas.TryGetValue(chromFileKey, out chromFileData)) { if (match) { results.Add(transitionBookmark); } } else { if (match) { chromFileData.MatchingTransitionBookmarks.Add(transitionBookmark); } else { chromFileData.AllTransitionsMatch = false; } } } } foreach (var fileDataEntry in fileDatas) { if (fileDataEntry.Value.AllTransitionsMatch && fileDataEntry.Value.MatchingTransitionBookmarks.Count > 0) { var transitionGroupMatch = MatchTransitionGroup(fileDataEntry.Value.TransitionGroupChromInfo); if (transitionGroupMatch != null) { results.Add(new Bookmark(identityPath, fileDataEntry.Value.TransitionGroupChromInfo.FileId, fileDataEntry.Value.TransitionGroupChromInfo.OptimizationStep)); continue; } } results.AddRange(fileDataEntry.Value.MatchingTransitionBookmarks); } } return results; }
public static Range FromDoc(Range existing, DocNode doc) { Assert.True(doc.Type == DocNodeType.List, "Range config expected list, got ", doc.Type); Assert.True(doc.Count == 2, "Range config expected 2 items, got ", doc.Count); float min = System.Convert.ToSingle(doc[0].StringValue); float max = System.Convert.ToSingle(doc[1].StringValue); if (existing == null) { return new Range(min, max); } else { existing.Start = min; existing.End = max; return existing; } }