internal Settings(ISyncSettings self) { this.SynchronousSettings = self; this.Values = new Values(this.SynchronousSettings); this.Environments = new Environments(this.SynchronousSettings); this.Users = new Users(this.SynchronousSettings); }
/// <summary> /// Ctor /// </summary> /// <param name="syncContext"></param> /// <param name="syncSettings"></param> /// <param name="entitiesToSync"></param> public RemoteSyncService(IContext syncContext, ISyncSettings syncSettings, IEnumerable <ISyncEntity <DataTable> > entitiesToSync = null, bool initClient = true) : base(syncContext, syncSettings, entitiesToSync) { if (initClient) { Init(); } }
public GenericSyncServiceTwoWayTests() { _localProvider = Substitute.For <ISynchronisationProvider <SyncClass, int> >(); _remoteProvider = Substitute.For <ISynchronisationProvider <SyncClass, int> >(); _settings = Substitute.For <ISyncSettings>(); _settings.LastSync = DateTime.Today; _syncService = new GenericSynchronisationService <SyncClass, int>(c => c.Id, _localProvider, _remoteProvider, _settings, SyncDirection.TwoWay); }
public GenericSyncServiceTwoWayTests() { _localProvider = Substitute.For<ISynchronisationProvider<SyncClass, int>>(); _remoteProvider = Substitute.For<ISynchronisationProvider<SyncClass, int>>(); _settings = Substitute.For<ISyncSettings>(); _settings.LastSync = DateTime.Today; _syncService = new GenericSynchronisationService<SyncClass, int>(c => c.Id, _localProvider, _remoteProvider, _settings, SyncDirection.TwoWay); }
/// <summary> /// Retrieves the value from the server. If the value doesn't exist, or you don't have access to it, returns null. /// /// This (and its async sister in CityHall.Settings) should be the most often-used function of the library. /// The first call will instantiate CityHall.Synchronous.SyncSettings.Connection, using config file settings. /// </summary> /// <param name="path">The path of the value. Starting or trailing '/' may be omitted.</param> /// <param name="environment">If it is null or empty, it will use ISyncSettings.DefaultEnvironmnet</param> /// <param name="over">The override to get. If this is unspecified, then the override that matches /// the logged in user is retrieved. Otherwise, the default value is returned.</param> public static string Get(string path, string environment = null, string over = null) { if ((SyncSettings.Connection == null) || !SyncSettings.Connection.LoggedIn) { lock (SyncSettings.syncObject) { SyncSettings.Connection = SyncSettings.New(); } } return SyncSettings.Connection.Values.Get(path, environment, over); }
/// <summary> /// Initializes a new instance of the <see cref="GenericSynchronisationService<TType, TKey>"/> class. /// </summary> /// <param name="keySelector">The key selector.</param> /// <param name="localProvider">The local provider.</param> /// <param name="remoteProvider">The remote provider.</param> /// <param name="settings">The settings.</param> /// <param name="syncDirection">The sync direction.</param> public GenericSynchronisationService( Func <TType, TKey> keySelector, ISynchronisationProvider <TType, TKey> localProvider, ISynchronisationProvider <TType, TKey> remoteProvider, ISyncSettings settings, SyncDirection syncDirection) { _keySelector = keySelector; _localProvider = localProvider; _remoteProvider = remoteProvider; _settings = settings; _syncDirection = syncDirection; }
/// <summary> /// Выполняет проверку настроек синхронизации /// </summary> /// <param name="settings"></param> protected virtual void ValidateSettings(ISyncSettings settings) { if (settings == null) { throw new Exception("Необходимо задать настройки синхронизации (SyncSettings)"); } if (settings.DataSerializer == null) { throw new Exception("Необходимо задать настройки сериализации (DataSerializer)"); } if (settings.Logger == null) { throw new Exception("Необходимо задать настройки логирования (Logger)"); } }
/// <summary> /// Initialization /// </summary> /// <param name="syncContext">Synchronization context</param> /// <param name="syncSettings">Synchronization settings</param> /// <param name="syncEntities">Entities to sync</param> /// <returns></returns> public void Init(IContext syncContext, ISyncSettings syncSettings, IEnumerable <ISyncEntity <DataTable> > syncEntities) { try { ValidateSettings(syncSettings); SyncContext = syncContext; SyncSettings = syncSettings; SetEntitiesToSync(syncEntities); } catch (Exception ex) { if (syncSettings != null && syncSettings.Logger != null) { syncSettings.Logger.Error(ex); } Out(ex.ToString()); throw; } }
/// <summary> /// Возвращает true, если настройки синхронизации заданы правильно, /// false - в случае не корректных настроек /// </summary> /// <param name="settings"></param> /// <param name="generateException"></param> /// <returns></returns> public bool IsValidSettings(ISyncSettings settings, bool generateException = false) { try { ValidateSettings(settings); } catch (Exception exception) { if (settings.Logger != null) { settings.Logger.Error(exception); } Out(exception.ToString()); if (generateException) { throw; } return(false); } return(true); }
/// <summary> /// Ctor /// </summary> /// <param name="syncContext"></param> /// <param name="syncSettings"></param> /// <param name="entitiesToSync"></param> public SimpleSyncService(IContext syncContext, ISyncSettings syncSettings, IEnumerable <ISyncEntity <DataTable> > entitiesToSync = null) : base(syncContext, syncSettings, entitiesToSync) { Init(); }
/// <summary> /// Base ctor /// </summary> /// <param name="syncContext"></param> /// <param name="syncSettings"></param> /// <param name="syncEntities"></param> protected BaseSyncService(IContext syncContext, ISyncSettings syncSettings, IEnumerable <ISyncEntity <DataTable> > syncEntities) { Init(syncContext, syncSettings, syncEntities); }
public Users(ISyncSettings self) { this.self = self; }
public Environments(ISyncSettings self) { this.self = self; }