コード例 #1
0
        private static MockHistoryObject BuildObject(
            HistoryId id,
            IEnumerable <Tuple <byte, IStoreTimelineValues> > members,
            params object[] constructorArguments)
        {
            IVariableTimeline <int>    someValue    = null;
            IListTimelineStorage <int> lotsOfValues = null;

            foreach (var pair in members)
            {
                if (pair.Item1 == MockHistoryObject.SomeValueIndex)
                {
                    someValue = pair.Item2 as IVariableTimeline <int>;
                    continue;
                }

                if (pair.Item1 == MockHistoryObject.LotsOfValuesIndex)
                {
                    lotsOfValues = pair.Item2 as IListTimelineStorage <int>;
                    continue;
                }
            }

            return(new MockHistoryObject(id, someValue, lotsOfValues));
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositionLayer"/> class.
        /// </summary>
        /// <param name="id">The ID used by the timeline to uniquely identify the current object.</param>
        /// <param name="definitions">The collection containing all the known group definitions.</param>
        /// <param name="groups">The collection containing the known groups for the current dataset.</param>
        /// <param name="groupConnections">The graph that describes the connections between the groups.</param>
        /// <param name="parts">The collection that contains all the parts for the currently selected groups.</param>
        /// <param name="partConnections">The graph that determines how the different parts are connected.</param>
        /// <param name="instances">The object that stores the instances of the parts.</param>
        private CompositionLayer(
            HistoryId id,
            IDictionaryTimelineStorage <GroupRegistrationId, GroupDefinition> definitions,
            IDictionaryTimelineStorage <GroupCompositionId, GroupRegistrationId> groups,
            IBidirectionalGraphHistory <GroupCompositionId, GroupCompositionGraphEdge> groupConnections,
            IDictionaryTimelineStorage <PartCompositionId, PartCompositionInfo> parts,
            IBidirectionalGraphHistory <PartCompositionId, PartImportExportEdge <PartCompositionId> > partConnections,
            IVariableTimeline <IStoreInstances> instances)
        {
            {
                Debug.Assert(id != null, "The ID object should not be a null reference.");
                Debug.Assert(definitions != null, "The definition collectino should not be a null reference.");
                Debug.Assert(groups != null, "The groups collection should not be a null reference.");
                Debug.Assert(groupConnections != null, "The group connection graph should not be a null reference.");
                Debug.Assert(parts != null, "The parts collection should not be a null reference.");
                Debug.Assert(partConnections != null, "The part connection graph should not be a null reference.");
                Debug.Assert(instances != null, "The instance collection should not be a null reference.");
            }

            m_HistoryId        = id;
            m_Definitions      = definitions;
            m_Groups           = groups;
            m_GroupConnections = groupConnections;
            m_Parts            = parts;
            m_PartConnections  = partConnections;
            m_Instances        = instances;
        }
コード例 #3
0
ファイル: DatasetProxy.cs プロジェクト: rafysanchez/Apollo
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetProxy"/> class.
        /// </summary>
        /// <param name="constructorArgs">The object that holds all the constructor arguments that do not belong to the timeline.</param>
        /// <param name="proxyBuilder">The function that is used to create the proxy for the data inside the 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="historyId">The ID for use in the history system.</param>
        /// <param name="name">The data structure that stores the history information for the name of the dataset.</param>
        /// <param name="summary">The data structure that stores the history information for the summary of the dataset.</param>
        /// <param name="distributionLocation">
        /// The data structure that stores the history information indicating if the dataset is activated at any point.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="constructorArgs"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="proxyBuilder"/> 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="historyId"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="name"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="summary"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="distributionLocation"/> is <see langword="null" />.
        /// </exception>
        private DatasetProxy(
            DatasetConstructionParameters constructorArgs,
            Func <DatasetOnlineInformation, DatasetStorageProxy> proxyBuilder,
            ICollectNotifications notifications,
            SystemDiagnostics diagnostics,
            HistoryId historyId,
            IVariableTimeline <string> name,
            IVariableTimeline <string> summary,
            IVariableTimeline <NetworkIdentifier> distributionLocation)
        {
            {
                Lokad.Enforce.Argument(() => constructorArgs);
                Lokad.Enforce.Argument(() => proxyBuilder);
                Lokad.Enforce.Argument(() => notifications);
                Lokad.Enforce.Argument(() => diagnostics);
                Lokad.Enforce.Argument(() => historyId);
                Lokad.Enforce.Argument(() => name);
                Lokad.Enforce.Argument(() => summary);
                Lokad.Enforce.Argument(() => distributionLocation);
            }

            m_ConstructorArgs      = constructorArgs;
            m_ProxyBuilder         = proxyBuilder;
            m_Notifications        = notifications;
            m_Diagnostics          = diagnostics;
            m_HistoryId            = historyId;
            m_Name                 = name;
            m_Summary              = summary;
            m_DistributionLocation = distributionLocation;

            m_Name.OnExternalValueUpdate    += HandleOnNameUpdate;
            m_Summary.OnExternalValueUpdate += HandleOnSummaryUpdate;
            m_DistributionLocation.OnExternalValueUpdate += HandleOnIsActivatedUpdate;
        }
コード例 #4
0
        /// <summary>
        /// Creates a new instance of the <see cref="ProjectHistoryStorage"/> class with the given
        /// history information.
        /// </summary>
        /// <param name="id">The history ID for the project storage.</param>
        /// <param name="members">The collection that holds all the members for the current object.</param>
        /// <param name="constructorArguments">The optional constructor arguments.</param>
        /// <returns>A new instance of the <see cref="ProjectHistoryStorage"/> class.</returns>
        /// <exception cref="UnknownMemberException">
        /// Thrown if the <paramref name="members"/> collection contains data for an unknown member field.
        /// </exception>
        internal static ProjectHistoryStorage CreateInstance(
            HistoryId id,
            IEnumerable <Tuple <byte, IStoreTimelineValues> > members,
            params object[] constructorArguments)
        {
            {
                Debug.Assert(members.Count() == 2, "There should only be two members.");
            }

            IVariableTimeline <string> name    = null;
            IVariableTimeline <string> summary = null;

            foreach (var member in members)
            {
                if (member.Item1 == NameIndex)
                {
                    name = member.Item2 as IVariableTimeline <string>;
                    continue;
                }

                if (member.Item1 == SummaryIndex)
                {
                    summary = member.Item2 as IVariableTimeline <string>;
                    continue;
                }

                throw new UnknownMemberException();
            }

            return(new ProjectHistoryStorage(id, name, summary));
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectHistoryStorage"/> class.
        /// </summary>
        /// <param name="id">The ID used by the timeline to uniquely identify the current object.</param>
        /// <param name="name">The timeline storage that stores the name of the project.</param>
        /// <param name="summary">The timeline storage that stores the summary of the project.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="id"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="name"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="summary"/> is <see langword="null" />.
        /// </exception>
        private ProjectHistoryStorage(
            HistoryId id,
            IVariableTimeline<string> name,
            IVariableTimeline<string> summary)
        {
            {
                Lokad.Enforce.Argument(() => id);
                Lokad.Enforce.Argument(() => name);
                Lokad.Enforce.Argument(() => summary);
            }

            m_HistoryId = id;
            m_Name = name;
            m_Summary = summary;
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectHistoryStorage"/> class.
        /// </summary>
        /// <param name="id">The ID used by the timeline to uniquely identify the current object.</param>
        /// <param name="name">The timeline storage that stores the name of the project.</param>
        /// <param name="summary">The timeline storage that stores the summary of the project.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="id"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="name"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="summary"/> is <see langword="null" />.
        /// </exception>
        private ProjectHistoryStorage(
            HistoryId id,
            IVariableTimeline <string> name,
            IVariableTimeline <string> summary)
        {
            {
                Lokad.Enforce.Argument(() => id);
                Lokad.Enforce.Argument(() => name);
                Lokad.Enforce.Argument(() => summary);
            }

            m_HistoryId = id;
            m_Name      = name;
            m_Summary   = summary;
        }
コード例 #7
0
ファイル: DatasetProxy.cs プロジェクト: rafysanchez/Apollo
        /// <summary>
        /// Creates a new instance of the <see cref="DatasetProxy"/> class with the given data that was stored in the history system.
        /// </summary>
        /// <param name="historyId">The ID of the current object as used by the timeline.</param>
        /// <param name="members">The collection of member fields that are stored in the timeline.</param>
        /// <param name="constructorArguments">The arguments needed to create the proxy.</param>
        /// <returns>A new instance of the <see cref="DatasetProxy"/> class.</returns>
        /// <exception cref="UnknownMemberException">
        ///     Thrown if <paramref name="members"/> contains member data for an unknown member.
        /// </exception>
        internal static DatasetProxy CreateInstance(
            HistoryId historyId,
            IEnumerable <Tuple <byte, IStoreTimelineValues> > members,
            params object[] constructorArguments)
        {
            {
                Debug.Assert(members.Count() == 3, "There should only be three members.");
                Debug.Assert(constructorArguments.Length == 4, "There should be four constructor arguments.");
            }

            IVariableTimeline <string>            name    = null;
            IVariableTimeline <string>            summary = null;
            IVariableTimeline <NetworkIdentifier> distributionLocation = null;

            foreach (var member in members)
            {
                if (member.Item1 == NameIndex)
                {
                    name = member.Item2 as IVariableTimeline <string>;
                    continue;
                }

                if (member.Item1 == SummaryIndex)
                {
                    summary = member.Item2 as IVariableTimeline <string>;
                    continue;
                }

                if (member.Item1 == DistributionLocationIndex)
                {
                    distributionLocation = member.Item2 as IVariableTimeline <NetworkIdentifier>;
                    continue;
                }

                throw new UnknownMemberException();
            }

            return(new DatasetProxy(
                       constructorArguments[0] as DatasetConstructionParameters,
                       constructorArguments[1] as Func <DatasetOnlineInformation, DatasetStorageProxy>,
                       constructorArguments[2] as ICollectNotifications,
                       constructorArguments[3] as SystemDiagnostics,
                       historyId,
                       name,
                       summary,
                       distributionLocation));
        }
コード例 #8
0
 public MockHistoryObject(HistoryId id, IVariableTimeline <int> valueStorage, IListTimelineStorage <int> collectionStorage)
 {
     m_Id           = id;
     m_SomeValue    = valueStorage;
     m_LotsOfValues = collectionStorage;
 }
コード例 #9
0
        /// <summary>
        /// Creates a new instance of the <see cref="CompositionLayer"/> class with the given
        /// history information.
        /// </summary>
        /// <param name="id">The history ID for the dataset storage.</param>
        /// <param name="members">The collection that holds all the members for the current object.</param>
        /// <param name="constructorArguments">The optional constructor arguments.</param>
        /// <returns>A new instance of the <see cref="CompositionLayer"/> class.</returns>
        internal static CompositionLayer CreateInstance(
            HistoryId id,
            IEnumerable <Tuple <byte, IStoreTimelineValues> > members,
            params object[] constructorArguments)
        {
            {
                Debug.Assert(members.Count() == 6, "There should be 6 members.");
            }

            IDictionaryTimelineStorage <GroupRegistrationId, GroupDefinition>          definitions = null;
            IDictionaryTimelineStorage <GroupCompositionId, GroupRegistrationId>       groups      = null;
            IBidirectionalGraphHistory <GroupCompositionId, GroupCompositionGraphEdge> graph       = null;
            IDictionaryTimelineStorage <PartCompositionId, PartCompositionInfo>        parts       = null;
            IBidirectionalGraphHistory <PartCompositionId, PartImportExportEdge <PartCompositionId> > partConnections = null;
            IVariableTimeline <IStoreInstances> instances = null;

            foreach (var member in members)
            {
                if (member.Item1 == GroupDefinitionIndex)
                {
                    definitions = member.Item2 as IDictionaryTimelineStorage <GroupRegistrationId, GroupDefinition>;
                    continue;
                }

                if (member.Item1 == GroupCompositionIndex)
                {
                    groups = member.Item2 as IDictionaryTimelineStorage <GroupCompositionId, GroupRegistrationId>;
                    continue;
                }

                if (member.Item1 == GroupConnectionIndex)
                {
                    graph = member.Item2 as IBidirectionalGraphHistory <GroupCompositionId, GroupCompositionGraphEdge>;
                    continue;
                }

                if (member.Item1 == PartCompositionIndex)
                {
                    parts = member.Item2 as IDictionaryTimelineStorage <PartCompositionId, PartCompositionInfo>;
                    continue;
                }

                if (member.Item1 == PartConnectionIndex)
                {
                    partConnections = member.Item2 as IBidirectionalGraphHistory <PartCompositionId, PartImportExportEdge <PartCompositionId> >;
                    continue;
                }

                if (member.Item1 == PartInstanceIndex)
                {
                    instances = member.Item2 as IVariableTimeline <IStoreInstances>;
                    continue;
                }

                throw new UnknownMemberException();
            }

            return(new CompositionLayer(
                       id,
                       definitions,
                       groups,
                       graph,
                       parts,
                       partConnections,
                       instances));
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositionLayer"/> class.
        /// </summary>
        /// <param name="id">The ID used by the timeline to uniquely identify the current object.</param>
        /// <param name="definitions">The collection containing all the known group definitions.</param>
        /// <param name="groups">The collection containing the known groups for the current dataset.</param>
        /// <param name="groupConnections">The graph that describes the connections between the groups.</param>
        /// <param name="parts">The collection that contains all the parts for the currently selected groups.</param>
        /// <param name="partConnections">The graph that determines how the different parts are connected.</param>
        /// <param name="instances">The object that stores the instances of the parts.</param>
        private CompositionLayer(
            HistoryId id,
            IDictionaryTimelineStorage<GroupRegistrationId, GroupDefinition> definitions,
            IDictionaryTimelineStorage<GroupCompositionId, GroupRegistrationId> groups,
            IBidirectionalGraphHistory<GroupCompositionId, GroupCompositionGraphEdge> groupConnections,
            IDictionaryTimelineStorage<PartCompositionId, PartCompositionInfo> parts,
            IBidirectionalGraphHistory<PartCompositionId, PartImportExportEdge<PartCompositionId>> partConnections,
            IVariableTimeline<IStoreInstances> instances)
        {
            {
                Debug.Assert(id != null, "The ID object should not be a null reference.");
                Debug.Assert(definitions != null, "The definition collectino should not be a null reference.");
                Debug.Assert(groups != null, "The groups collection should not be a null reference.");
                Debug.Assert(groupConnections != null, "The group connection graph should not be a null reference.");
                Debug.Assert(parts != null, "The parts collection should not be a null reference.");
                Debug.Assert(partConnections != null, "The part connection graph should not be a null reference.");
                Debug.Assert(instances != null, "The instance collection should not be a null reference.");
            }

            m_HistoryId = id;
            m_Definitions = definitions;
            m_Groups = groups;
            m_GroupConnections = groupConnections;
            m_Parts = parts;
            m_PartConnections = partConnections;
            m_Instances = instances;
        }