/// <summary> /// Initializes a new instance of the <see cref="HubViewModel"/> class. /// </summary> /// <param name="iocCommonLogging"> /// The ioc common logging. /// </param> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> public HubViewModel(ISharedLogging iocCommonLogging, IMessenger iocEventAggregator, IErrorNotifications iocErrorNotifications) : base(iocCommonLogging) { _iocErrorNotifications = iocErrorNotifications; BaseTitle = "Hub"; BaseTitleIcon = Constants.IconHub; App.Current.Services.GetService <IMessenger>().Register <DataLoadCompleteEvent>(this, (r, m) => { if (!m.Value) { return; } HandledDataLoadedEvent(); }); App.Current.Services.GetService <IMessenger>().Register <DataLoadStartEvent>(this, async(r, m) => { if (!m.Value) { return; } _iocErrorNotifications.DataLogShow(); }); }
/// <summary> /// Initializes a new instance of the <see cref="PlatformSpecific"/> class. /// </summary> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> public PlatformSpecific(IMessenger iocEventAggregator, IErrorNotifications iocErrorNotification) { // iocEventAggregator.GetEvent<DataLoadCompleteEvent>().Subscribe(UpdateTile, ThreadOption.UIThread); _IMessenger = iocEventAggregator; _IErrorNotifications = iocErrorNotification; }
/// <summary> /// Initializes a new instance of the <see cref="StoreXML"/> class. /// </summary> /// <param name="iocCommonLogging"> /// Common Logging. /// </param> /// <param name="iocCommonNotifications"> /// Common Notifications /// </param> public StoreXML(ISharedLogging iocCommonLogging, IErrorNotifications iocCommonNotifications) { _iocCommonLogging = iocCommonLogging; _iocCommonNotifications = iocCommonNotifications; ns = Constants.GrampsXMLNameSpace; }
/// <summary> /// Initializes a new instance of the <see cref="DataRepositoryManager"/> class. /// </summary> /// <param name="iocCommonLogging"> /// The ioc common logging. /// </param> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> /// <param name="iocExternalStorage"> /// The ioc external storage. /// </param> /// <param name="iocGrampsStorePostLoad"> /// The ioc gramps store post load. /// </param> /// <param name="iocGrampsStoreSerial"> /// The ioc gramps store serial. /// </param> /// <param name="iocStoreFile"> /// The ioc store file. /// </param> public DataRepositoryManager(ISharedLogging iocCommonLogging, IErrorNotifications iocCommonNotifications, IMessenger iocEventAggregator, IStoreXML iocExternalStorage, IStorePostLoad iocGrampsStorePostLoad, IGrampsStoreSerial iocGrampsStoreSerial, IStoreFile iocStoreFile) { _CL = iocCommonLogging ?? throw new ArgumentNullException(nameof(iocCommonLogging)); _ExternalStorage = iocExternalStorage ?? throw new ArgumentNullException(nameof(iocExternalStorage)); _PostLoad = iocGrampsStorePostLoad; _StoreSerial = iocGrampsStoreSerial; _StoreFile = iocStoreFile; _EventAggregator = iocEventAggregator; _commonNotifications = iocCommonNotifications; // Event Handlers Contract.Assert(_EventAggregator != null); App.Current.Services.GetService <IMessenger>().Register <DataLoadStartEvent>(this, (r, m) => { if (!m.Value) { return; } StartDataLoad(); }); App.Current.Services.GetService <IMessenger>().Register <DataSaveSerialEvent>(this, (r, m) => { if (!m.Value) { return; } SerializeRepositoriesAsync(true); }); App.Current.Services.GetService <IMessenger>().Register <DataLoadCompleteEvent>(this, (r, m) => { if (!m.Value) { return; } DataLoadedSetTrue(); }); }
/// <summary> /// Initializes a new instance of the <see cref="StorePostLoad"/> class. /// </summary> /// <param name="iocCommonLogging"> /// The ioc common logging. /// </param> /// <param name="iocEventAggregator"> /// The ioc event aggregator. /// </param> public StorePostLoad(ISharedLogging iocCommonLogging, IErrorNotifications iocCommonNotifications, IMessenger iocEventAggregator) { _EventAggregator = iocEventAggregator; _CommonLogging = iocCommonLogging; _commonNotifications = iocCommonNotifications; _iocPlatformSpecific = DependencyService.Get <IPlatformSpecific>(); App.Current.Services.GetService <IMessenger>().Register <DataLoadXMLEvent>(this, (r, m) => { if (m.Value == null) { return; } LoadXMLUIItems(true); }); }
public static void setupMocks() { /* * Mock Common Logging */ ISharedLogging iocCommonLogging = new SharedLogging(); /* * Mock Common Notifications */ Mock <IErrorNotifications> mockCommonNotifications = new Mock <IErrorNotifications>(); mockCommonNotifications .Setup(x => x.DataLogEntryAdd(It.IsAny <string>())); iocCommonNotifications = mockCommonNotifications.Object; /* * Mock Image Loading */ Mock <IFFImageLoading> mocFFImageLoading = new Mock <IFFImageLoading>(); IFFImageLoading iocFFImageLoading = mocFFImageLoading.Object; /* * Mock Xamarin Essentials */ Mock <IXamarinEssentials> mocXamarinEssentials = new Mock <IXamarinEssentials>(); mocXamarinEssentials .Setup(x => x.FileSystemCacheDirectory) .Returns(Path.GetTempPath()); IXamarinEssentials iocXamarinEssentials = mocXamarinEssentials.Object; /* * Mock Event Aggregator */ Mock <DataLoadXMLEvent> mockedEventDataLoadXMLEvent = new Mock <DataLoadXMLEvent>(); // TODO fix this //mocEventAggregator // .Setup(x => x.Register<DataLoadXMLEvent>()) // .Returns(mockedEventDataLoadXMLEvent.Object); //Mock<DataLoadStartEvent> mockedEventDataLoadStartEvent = new Mock<DataLoadStartEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataLoadStartEvent>()) // .Returns(mockedEventDataLoadStartEvent.Object); //Mock<DataSaveSerialEvent> mockedEventDataSaveSerialEvent = new Mock<DataSaveSerialEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataSaveSerialEvent>()) // .Returns(mockedEventDataSaveSerialEvent.Object); //Mock<DataLoadCompleteEvent> mockedEventDataLoadCompleteEvent = new Mock<DataLoadCompleteEvent>(); //mocEventAggregator // .Setup(x => x.GetEvent<DataLoadCompleteEvent>()) // .Returns(mockedEventDataLoadCompleteEvent.Object); IMessenger iocEventAggregator = mocEventAggregator.Object; /* * Mock Platform specific */ iocPlatformSpecific = mocPlatformSpecific.Object; /* * Configure DataStore */ DataStore.Instance.ES = iocXamarinEssentials; DataStore.Instance.FFIL = iocFFImageLoading; /* * Other setup */ iocExternalStorage = new StoreXML(iocCommonLogging, iocCommonNotifications); iocGrampsStorePostLoad = new StorePostLoad(iocCommonLogging, iocCommonNotifications, iocEventAggregator); iocGrampsStoreSerial = new GrampsStoreSerial(iocCommonLogging); iocStoreFile = new StoreFile(); newManager = new DataRepositoryManager(iocCommonLogging, iocCommonNotifications, iocEventAggregator, iocExternalStorage, iocGrampsStorePostLoad, iocGrampsStoreSerial, iocStoreFile); }