コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: RdExtBase.cs プロジェクト: vorotynsky/rd
        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");
        }
コード例 #3
0
ファイル: InternRoot.cs プロジェクト: yvvan/rd
        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);
        }
コード例 #4
0
ファイル: RdExtBase.cs プロジェクト: LongJohnCoder/rd
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 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)
     );
コード例 #7
0
 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
         );
 }
コード例 #8
0
ファイル: CofraFacade.cs プロジェクト: zeta1999/CoFRA
        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);
        }
コード例 #9
0
        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
            );
        }
コード例 #10
0
        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);
        }
コード例 #11
0
            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);
                }
                                        ));
            }
コード例 #12
0
 public static void AddLifetimed <T>(this ICollection <T> me, Lifetime lifetime, T item)
 {
     lifetime.Bracket(() => me.Add(item), () => me.Remove(item));
 }
コード例 #13
0
 public void SetActive(Lifetime lifetime)
 {
     lifetime.Bracket(() => { ourActive++; }, () => { ourActive--; });
 }