/// <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> /// <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(); }