/// <summary> /// Initializes a new instance of the <see cref="NotificationModel"/> class. /// </summary> /// <param name="context">The context that is used to execute actions on the UI thread.</param> /// <param name="notificationCollector">The object that collects notifications from all over the system.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="context"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="notificationCollector"/> is <see langword="null" />. /// </exception> public NotificationModel(IContextAware context, ICollectNotifications notificationCollector) : base(context) { { Lokad.Enforce.Argument(() => notificationCollector); } m_Notifications = notificationCollector; m_Notifications.OnNotification += (s, e) => Notification = e.Notification; }
/// <summary> /// Initializes a new instance of the <see cref="Project"/> class. /// </summary> /// <param name="timeline">The timeline for the current project.</param> /// <param name="distributor"> /// The function which returns a <see cref="DistributionPlan"/> for a given /// <see cref="DatasetActivationRequest"/>. /// </param> /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param> /// <param name="notifications">The object that stores the notifications for the user interface.</param> /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param> /// <param name="persistenceInfo"> /// The object that describes how the project was persisted. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="timeline"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="distributor"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="dataStorageProxyBuilder"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="notifications"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="diagnostics"/> is <see langword="null" />. /// </exception> public Project( ITimeline timeline, Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor, Func<DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder, ICollectNotifications notifications, SystemDiagnostics diagnostics, IPersistenceInformation persistenceInfo) { { Lokad.Enforce.Argument(() => timeline); Lokad.Enforce.Argument(() => distributor); Lokad.Enforce.Argument(() => dataStorageProxyBuilder); Lokad.Enforce.Argument(() => notifications); Lokad.Enforce.Argument(() => diagnostics); } m_Timeline = timeline; m_Timeline.ForgetAllHistory(); m_Timeline.OnRolledBack += OnTimelineRolledBack; m_Timeline.OnRolledForward += OnTimelineRolledForward; m_ProjectInformation = m_Timeline.AddToTimeline(ProjectHistoryStorage.CreateInstance); m_Datasets = m_Timeline.AddToTimeline(DatasetHistoryStorage.CreateInstance); m_DatasetDistributor = distributor; m_DataStorageProxyBuilder = dataStorageProxyBuilder; m_Notifications = notifications; m_Diagnostics = diagnostics; if (persistenceInfo != null) { RestoreFromStore(persistenceInfo); } // Create a root dataset if there isn't one if (m_RootDataset == null) { var dataset = CreateDataset( null, new DatasetCreationInformation { CreatedOnRequestOf = DatasetCreator.System, LoadFrom = new NullPersistenceInformation(), CanBeDeleted = false, CanBeCopied = false, CanBecomeParent = true, CanBeAdopted = false, IsRoot = true, }); m_RootDataset = dataset.Id; dataset.Name = Resources.Projects_Dataset_RootDatasetName; dataset.Summary = Resources.Projects_Dataset_RootDatasetSummary; } m_Timeline.SetCurrentAsDefault(); }
/// <summary> /// Initializes a new instance of the <see cref="Project"/> class. /// </summary> /// <param name="timeline">The timeline for the current project.</param> /// <param name="distributor"> /// The function which returns a <see cref="DistributionPlan"/> for a given /// <see cref="DatasetActivationRequest"/>. /// </param> /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param> /// <param name="notifications">The object that stores the notifications for the user interface.</param> /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="distributor"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="dataStorageProxyBuilder"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="notifications"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="diagnostics"/> is <see langword="null" />. /// </exception> public Project( ITimeline timeline, Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor, Func<DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder, ICollectNotifications notifications, SystemDiagnostics diagnostics) : this(timeline, distributor, dataStorageProxyBuilder, notifications, diagnostics, null) { }
/// <summary> /// Provides the object that will store the notifications for use by the user interface. /// </summary> /// <param name="notifications">The object that stores the notifications for the user interface.</param> /// <returns> /// The current builder instance with the notification object stored. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="notifications"/> is <see langword="null" />. /// </exception> public IBuildProjects WithNotifications(ICollectNotifications notifications) { { Lokad.Enforce.Argument(() => notifications); } m_Notifications = notifications; return this; }
/// <summary> /// Initializes a new instance of the <see cref="ProjectService"/> class. /// </summary> /// <param name="timelineBuilder">The function that returns a new <see cref="ITimeline"/> object each time it is called.</param> /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param> /// <param name="datasetDistributor">The object that handles the distribution of datasets.</param> /// <param name="notifications">The object that stores the notifications for the user interface.</param> /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param> /// <param name="projectBuilder">The object that builds new projects.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="timelineBuilder"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="dataStorageProxyBuilder"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="datasetDistributor"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="notifications"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown when <paramref name="diagnostics"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="projectBuilder"/> is <see langword="null"/>. /// </exception> public ProjectService( Func<ITimeline> timelineBuilder, Func<DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder, IHelpDistributingDatasets datasetDistributor, ICollectNotifications notifications, SystemDiagnostics diagnostics, IBuildProjects projectBuilder) : base(diagnostics) { { Lokad.Enforce.Argument(() => timelineBuilder); Lokad.Enforce.Argument(() => dataStorageProxyBuilder); Lokad.Enforce.Argument(() => datasetDistributor); Lokad.Enforce.Argument(() => notifications); Lokad.Enforce.Argument(() => diagnostics); Lokad.Enforce.Argument(() => projectBuilder); } // No locks are necessary because we're in the constructor, no other // methods have been called or can be called. m_TimelineBuilder = timelineBuilder; m_DataStorageProxyBuilder = dataStorageProxyBuilder; m_DatasetDistributor = datasetDistributor; m_Notifications = notifications; m_Diagnostics = diagnostics; m_Builder = projectBuilder; }