Ejemplo n.º 1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ConditionMap"/> class.
            /// </summary>
            /// <param name="information">The information describing the condition.</param>
            /// <param name="condition">The condition.</param>
            public ConditionMap(ScheduleConditionInformation information, IScheduleCondition condition)
            {
                {
                    Debug.Assert(information != null, "The condition information should not be a null reference.");
                    Debug.Assert(condition != null, "The condition should not be a null reference.");
                }

                m_Info      = information;
                m_Condition = condition;
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the <see cref="IScheduleCondition"/> object with the dependencies for that condition.
        /// </summary>
        /// <param name="condition">The condition that should be stored.</param>
        /// <param name="name">The name of the condition that is being described by this information object.</param>
        /// <param name="description">The description of the condition that is being described by this information object.</param>
        /// <returns>An object identifying and describing the condition.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="condition"/> is <see langword="null" />.
        /// </exception>
        public ScheduleConditionInformation Add(
            IScheduleCondition condition,
            string name,
            string description)
        {
            {
                Lokad.Enforce.Argument(() => condition);
            }

            var id   = new ScheduleElementId();
            var info = new ScheduleConditionInformation(id, name, description);

            m_Conditions.Add(id, new ConditionMap(info, condition));

            return(info);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Replaces the condition current stored against the given ID with a new one.
        /// </summary>
        /// <param name="conditionToReplace">The ID of the condition that should be replaced.</param>
        /// <param name="newCondition">The new condition.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="conditionToReplace"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="newCondition"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="UnknownScheduleConditionException">
        ///     Thrown if <paramref name="conditionToReplace"/> is not linked to a known condition.
        /// </exception>
        public void Update(
            ScheduleElementId conditionToReplace,
            IScheduleCondition newCondition)
        {
            {
                Lokad.Enforce.Argument(() => conditionToReplace);
                Lokad.Enforce.Argument(() => newCondition);
                Lokad.Enforce.With <UnknownScheduleConditionException>(
                    m_Conditions.ContainsKey(conditionToReplace),
                    Resources.Exceptions_Messages_UnknownScheduleCondition);
            }

            var oldInfo = m_Conditions[conditionToReplace].Information;
            var info    = new ScheduleConditionInformation(
                conditionToReplace,
                oldInfo.Name,
                oldInfo.Description);

            m_Conditions[conditionToReplace] = new ConditionMap(info, newCondition);
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="ConditionMap"/> class.
            /// </summary>
            /// <param name="information">The information describing the condition.</param>
            /// <param name="condition">The condition.</param>
            public ConditionMap(ScheduleConditionInformation information, IScheduleCondition condition)
            {
                {
                    Debug.Assert(information != null, "The condition information should not be a null reference.");
                    Debug.Assert(condition != null, "The condition should not be a null reference.");
                }

                m_Info = information;
                m_Condition = condition;
            }
        /// <summary>
        /// Replaces the condition current stored against the given ID with a new one.
        /// </summary>
        /// <param name="conditionToReplace">The ID of the condition that should be replaced.</param>
        /// <param name="newCondition">The new condition.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="conditionToReplace"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="newCondition"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="UnknownScheduleConditionException">
        ///     Thrown if <paramref name="conditionToReplace"/> is not linked to a known condition.
        /// </exception>
        public void Update(
            ScheduleElementId conditionToReplace,
            IScheduleCondition newCondition)
        {
            {
                Lokad.Enforce.Argument(() => conditionToReplace);
                Lokad.Enforce.Argument(() => newCondition);
                Lokad.Enforce.With<UnknownScheduleConditionException>(
                    m_Conditions.ContainsKey(conditionToReplace),
                    Resources.Exceptions_Messages_UnknownScheduleCondition);
            }

            var oldInfo = m_Conditions[conditionToReplace].Information;
            var info = new ScheduleConditionInformation(
                conditionToReplace,
                oldInfo.Name,
                oldInfo.Description);
            m_Conditions[conditionToReplace] = new ConditionMap(info, newCondition);
        }
        /// <summary>
        /// Adds the <see cref="IScheduleCondition"/> object with the dependencies for that condition.
        /// </summary>
        /// <param name="condition">The condition that should be stored.</param>
        /// <param name="name">The name of the condition that is being described by this information object.</param>
        /// <param name="description">The description of the condition that is being described by this information object.</param>
        /// <returns>An object identifying and describing the condition.</returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="condition"/> is <see langword="null" />.
        /// </exception>
        public ScheduleConditionInformation Add(
            IScheduleCondition condition,
            string name,
            string description)
        {
            {
                Lokad.Enforce.Argument(() => condition);
            }

            var id = new ScheduleElementId();
            var info = new ScheduleConditionInformation(id, name, description);
            m_Conditions.Add(id, new ConditionMap(info, condition));

            return info;
        }