/// <summary>Initializes a new instance of the <see cref="T4FileDataCache"/> class.</summary> /// <param name="lifetime">The lifetime of this class.</param> /// <param name="psiFiles">The PSI manager.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4FileDataCache(Lifetime lifetime, [NotNull] PsiFiles psiFiles, [NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; FileDataChanged = new Signal <Pair <IPsiSourceFile, T4FileDataDiff> >(lifetime, "T4FileDataCache.FileDataChanged"); lifetime.Bracket( () => psiFiles.PsiFileCreated += OnPsiFileChanged, () => psiFiles.PsiFileCreated -= OnPsiFileChanged ); lifetime.Bracket( () => psiFiles.AfterPsiChanged += OnPsiChanged, () => psiFiles.AfterPsiChanged -= OnPsiChanged ); lifetime.OnTermination(_fileDataBySourceFile); }
protected override void Init(Lifetime lifetime) { Protocol.InitTrace?.Log($"{this} :: binding"); var parentProtocol = base.Proto; var parentWire = parentProtocol.Wire; parentProtocol.Serializers.RegisterToplevelOnce(GetType(), Register); //todo ExtScheduler myExtWire.RealWire = parentWire; lifetime.Bracket( () => { myExtProtocol = new Protocol(parentProtocol.Name, parentProtocol.Serializers, parentProtocol.Identities, parentProtocol.Scheduler, myExtWire, lifetime, SerializationContext, parentProtocol.Contexts); }, () => { myExtProtocol = null; } ); parentWire.Advise(lifetime, this); lifetime.OnTermination(() => { SendState(parentWire, ExtState.Disconnected); }); //protocol must be set first to allow bindable bind to it base.Init(lifetime); SendState(parentWire, ExtState.Ready); Protocol.InitTrace?.Log($"{this} :: bound"); }
public void Bind(Lifetime lf, IRdDynamic parent, string name) { if (myParent != null) { Assertion.Fail($"Trying to bound already bound {this} to {parent.Location}"); } //todo uncomment when fix InterningTest //Assertion.Require(RdId != RdId.Nil, "Must be identified first"); lf.Bracket(() => { myParent = parent; Location = parent.Location.Sub(name); }, () => { Location = Location.Sub("<<unbound>>", "::"); myParent = null; RdId = RdId.Nil; } ); myDirectMap.Clear(); myInverseMap.Clear(); Proto.Wire.Advise(lf, this); }
protected override void Init(Lifetime lifetime) { TraceMe(Protocol.InitializationLogger, "binding"); var parentProtocol = base.Proto; var parentWire = parentProtocol.Wire; parentProtocol.Serializers.RegisterToplevelOnce(GetType(), Register); //todo ExtScheduler myExtWire.RealWire = parentWire; lifetime.Bracket( () => { myExtProtocol = new Protocol(parentProtocol.Name, parentProtocol.Serializers, parentProtocol.Identities, parentProtocol.Scheduler, myExtWire, lifetime, SerializationContext, parentProtocol.ClientIdSet); }, () => { myExtProtocol = null; } ); parentWire.Advise(lifetime, this); SendState(parentWire, ExtState.Ready); lifetime.OnTermination(() => { SendState(parentWire, ExtState.Disconnected); }); //protocol must be set first to allow bindable bind to it base.Init(lifetime); TraceMe <Func <string> >(Protocol.InitializationLogger, "created and bound :: {0}", this.PrintToString); }
public void Bind(Lifetime lf, IRdDynamic parent, string name) { if (Parent != null) { Assertion.Fail($"Trying to bound already bound {this} to {parent.Location}"); } //todo uncomment when fix InterningTest //Assertion.Require(RdId != RdId.Nil, "Must be identified first"); lf.Bracket(() => { Parent = parent; Location = parent.Location.Sub(name); myBindLifetime = lf; IsBoundProperty.SetValue(true); }, () => { IsBoundProperty.SetValue(false); myBindLifetime = Lifetime.Terminated; Location = Location.Sub("<<unbound>>", "::"); Parent = null; RdId = RdId.Nil; } ); Proto.Scheduler.AssertThread(this); using (Signal.PriorityAdviseCookie.Create()) Init(lf); }
public static void CreateOutputExtensionChangeListener( [NotNull] this IDocument thіs, Lifetime lifetime, [NotNull] T4OutputExtensionChangeListener listener ) => lifetime.Bracket( () => thіs.PutData(T4_OUTPUT_EXTENSION_CHANGE_LISTENER_KEY, listener), () => thіs.PutData(T4_OUTPUT_EXTENSION_CHANGE_LISTENER_KEY, null) );
public T4DeclaredAssembliesManager( Lifetime lifetime, [NotNull] IPsiFiles psiFiles ) { FileDataChanged = new Signal <Pair <IPsiSourceFile, T4DeclaredAssembliesDiff> >( lifetime, "T4DeclaredAssembliesCache.FileDataChanged" ); lifetime.Bracket( () => psiFiles.PsiFileCreated += OnPsiFileChanged, () => psiFiles.PsiFileCreated -= OnPsiFileChanged ); lifetime.Bracket( () => psiFiles.AfterPsiChanged += OnPsiChanged, () => psiFiles.AfterPsiChanged -= OnPsiChanged ); }
public CofraFacade( Lifetime lifetime, IThreading threading, ISolution solution) { myLifetime = lifetime; myThreading = threading; mySolution = solution; myDaemonImpl = mySolution.GetComponent <DaemonImpl>(); mySuspendedAcitons = new Queue <Action <CofraClient> >(); ResultsAvailable = false; lifetime.Bracket(StartSession, Terminate); }
public NodeUnderCaretDetector(Lifetime lifetime, ISolution solution, DocumentManager documentManager, ITextControlManager textControlManager, IShellLocks shellLocks) { Solution = solution; _lifetime = lifetime; _documentManager = documentManager; _textControlManager = textControlManager; _shellLocks = shellLocks; NodeUnderCaret = new Property <ITreeNode>("NodeUnderCaretDetector.NodeUnderCaret"); NodeReferencedElements = new Property <IEnumerable <IDeclaredElement> >("NodeUnderCaretDetector.NodeReferencedElements"); EventHandler caretMoved = (sender, args) => { _shellLocks.QueueReadLock("NodeUnderCaretDetector.CaretMoved", Refresh); }; lifetime.Bracket ( () => _textControlManager.Legacy.CaretMoved += caretMoved, () => _textControlManager.Legacy.CaretMoved -= caretMoved ); }
protected void AttachEvents(PopupWindowManager popupWindowManager) { lifetime.OnTermination(DetachEvents); var context = Context; if (context != null) { lifetime.Bracket(() => Layouter = context.CreateLayouter(lifetime), () => Layouter = null); Layouter?.Layout.Change.Advise_HasNew(lifetime, OnLayouterResultChanged); context.AnyOtherAction += OnContextOwnerAnyActionPerformed; context.Scroll += OnContextOwnerScroll; context.SelectionChanged += OnContextOwnerSelectionChanged; context.Deactivated += OnContextOwnerDeactivated; context.EscapePressed += OnContextOwnerEscapePressed; } AttachWindowEvents(); popupWindowManager?.PopupWindows.Add(lifetime, this); }
internal static Socket CreateServerSocket(Lifetime lifetime, [CanBeNull] IPEndPoint endPoint) { Protocol.InitLogger.Verbose("Creating server socket on endpoint: {0}", endPoint); return(lifetime.Bracket(() => { var serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); SetSocketOptions(serverSocket); endPoint = endPoint ?? new IPEndPoint(IPAddress.Loopback, 0); serverSocket.Bind(endPoint); serverSocket.Listen(1); Protocol.InitLogger.Verbose("Server socket created, listening started on endpoint: {0}", endPoint); return serverSocket; }, socket => { ourStaticLog.Verbose("closing server socket"); CloseSocket(socket); } )); }
public static void AddLifetimed <T>(this ICollection <T> me, Lifetime lifetime, T item) { lifetime.Bracket(() => me.Add(item), () => me.Remove(item)); }
public void SetActive(Lifetime lifetime) { lifetime.Bracket(() => { ourActive++; }, () => { ourActive--; }); }