示例#1
0
        public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable <ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
            mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
            mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

            myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
            InitClient();

            syncSources.View(lifetime, (lt1, source) =>
                             source.FilesToSync.View(lt1, (lt2, fileToSync) =>
            {
                SyncFromCloud(fileToSync.Value);

                var fileTrackingLifetime = new SequentialLifetimes(lt2);
                fileToSync.Change.Advise(lt2,
                                         args =>
                {
                    var path = args.Property.Value;
                    if (lifetime.IsTerminated || path.IsNullOrEmpty())
                    {
                        fileTrackingLifetime.TerminateCurrent();
                    }
                    else
                    {
                        fileTrackingLifetime.Next(lt =>
                                                  fileSystemTracker.AdviseFileChanges(lt, path,
                                                                                      delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
                    }
                });
            }));
        }
        public ProductSettingsTracker(Lifetime lifetime, ClientFactory clientFactory, IViewable<ISyncSource> syncSources, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse("ReSharperPlatform");
              InitClient();

              syncSources.View(lifetime, (lt1, source) =>
            source.FilesToSync.View(lt1, (lt2, fileToSync) =>
            {
              SyncFromCloud(fileToSync.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lt2);
              fileToSync.Change.Advise(lt2,
            args =>
            {
              var path = args.Property.Value;
              if (lifetime.IsTerminated || path.IsNullOrEmpty())
              {
                fileTrackingLifetime.TerminateCurrent();
              }
              else
              {
                fileTrackingLifetime.Next(lt =>
                    fileSystemTracker.AdviseFileChanges(lt, path,
                      delta => delta.Accept(new FileChangesVisitor(myClient, myRootFolder))));
              }
            });
            }));
        }
        public HighlightingTracker(Lifetime lifetime, ITextControlManager textControlManager,
                                   IDocumentMarkupManager markupManager, IViewable <IHighlightingChangeHandler> handlers)
        {
            textControlManager.TextControls.View(lifetime, (textControlLifetime, textControl) =>
            {
                var markupModel = markupManager.GetMarkupModel(textControl.Document);

                Action <DocumentMarkupModifiedEventArgs> onChanged = args =>
                {
                    Lifetimes.Using(l =>
                    {
                        handlers.View(l, (_, h) =>
                        {
                            h.OnHighlightingChanged(textControl.Document, args.Added, args.Removed, args.Modified);
                        });
                    });
                };

                markupModel.Changed += onChanged;
                textControlLifetime.AddAction(() => markupModel.Changed -= onChanged);
            });
        }