Ejemplo n.º 1
0
            private async Task <TRoot> RestoreRootAsync(CancellationToken cancellationToken)
            {
                using (await this.Gate.DisposableWaitAsync(cancellationToken).ConfigureAwait(false))
                {
                    TRoot root;
                    if (!this.rootSource.TryGetValue(out root))
                    {
                        root = containingTree.CloneNodeAsRoot(await this.RecoverFromStorageIfPossibleAsync(cancellationToken).ConfigureAwait(false));
                        Contract.ThrowIfFalse(root.SyntaxTree == containingTree);

                        // now keep it around until we get evicted again
                        this.rootSource = new ConstantValueSource <TRoot>(root);
                    }

                    return(root);
                }
            }
Ejemplo n.º 2
0
 public RecoverableSyntaxRoot(
     AbstractSyntaxTreeFactoryService service,
     TRoot root,
     IRecoverableSyntaxTree <TRoot> containingTree)
     : base(new ConstantValueSource <TRoot>(containingTree.CloneNodeAsRoot(root)))
 {
     _service        = service;
     _containingTree = containingTree;
 }
Ejemplo n.º 3
0
 private TRoot RecoverRoot(Stream stream, CancellationToken cancellationToken)
 {
     return(_containingTree.CloneNodeAsRoot((TRoot)_service.DeserializeNodeFrom(stream, cancellationToken)));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Called by the constructor the parent tree.
 /// </summary>
 /// <remarks>
 /// This is to address the catch-22 dependency -- a tree needs it's recoverable root
 /// and vice versa. The dangerous bit is when we call TickleCache because it's the
 /// first place when this tree gets handed out to another system. We need to make sure
 /// both this object and the parent tree are fully constructed by that point.</remarks>
 public void SetContainingTree(IRecoverableSyntaxTree <TRoot> containingTree)
 {
     this.containingTree = containingTree;
     this.rootSource     = new ConstantValueSource <TRoot>(containingTree.CloneNodeAsRoot(this.rootSource.GetValue()));
     this.OnRootAccessed(this.rootSource.GetValue());
 }