Beispiel #1
0
        public ProductSettingsTracker(Lifetime lifetime, IProductNameAndVersion product, 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(product.ProductName);
            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, IProductNameAndVersion product, ClientFactory clientFactory, GlobalPerProductStorage globalPerProductStorage, IFileSystemTracker fileSystemTracker, JetBoxSettingsStorage jetBoxSettings)
        {
            myClientFactory = clientFactory;
              mySettingsStore = jetBoxSettings.SettingsStore.BindToContextLive(lifetime, ContextRange.ApplicationWide);
              mySettingsStore.Changed.Advise(lifetime, _ => InitClient());

              myRootFolder = FileSystemPath.Parse(product.ProductName);
              InitClient();

              var productSettingsPath = globalPerProductStorage.XmlFileStorage.Path;

              SyncFromCloud(productSettingsPath.Value);

              var fileTrackingLifetime = new SequentialLifetimes(lifetime);
              productSettingsPath.Change.Advise(lifetime,
            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, IProductNameAndVersion product, 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(product.ProductName);
              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 ExtensionsSyncSource(Lifetime lifetime, ExtensionLocations extensionLocations, IProductNameAndVersion product, AnyProductSettingsLocation anyProductSettingsLocation)
 {
     FilesToSync = new CollectionEvents<IProperty<FileSystemPath>>(lifetime, "ExtensionsSyncSource")
       {
     new Property<FileSystemPath>(lifetime, "ExtensionsSyncSource::ExtensionsSettings1", extensionLocations.UserExtensionSettingsFilePath),
     new Property<FileSystemPath>(lifetime, "ExtensionsSyncSource::ExtensionsSettings2", extensionLocations.UserExtensionSettingsFilePath.ChangeExtension(".xml")),
     new Property<FileSystemPath>(lifetime, "ExtensionsSyncSource::NuGetPackages.config",
       extensionLocations.GetBaseLocation(Environment.SpecialFolder.ApplicationData, anyProductSettingsLocation, product).Combine("packages.config"))
       };
 }
Beispiel #5
0
 public ExtensionsSyncSource(Lifetime lifetime, ExtensionLocations extensionLocations, IProductNameAndVersion product, AnyProductSettingsLocation anyProductSettingsLocation)
 {
     FilesToSync = new CollectionEvents <IProperty <FileSystemPath> >(lifetime, "ExtensionsSyncSource")
     {
         new Property <FileSystemPath>(lifetime, "ExtensionsSyncSource::ExtensionsSettings1", extensionLocations.UserExtensionSettingsFilePath),
         new Property <FileSystemPath>(lifetime, "ExtensionsSyncSource::ExtensionsSettings2", extensionLocations.UserExtensionSettingsFilePath.ChangeExtension(".xml")),
         new Property <FileSystemPath>(lifetime, "ExtensionsSyncSource::NuGetPackages.config",
                                       extensionLocations.GetBaseLocation(Environment.SpecialFolder.ApplicationData, anyProductSettingsLocation, product).Combine("packages.config"))
     };
 }