Пример #1
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IContingencyConstraintLimit contingencyConstraintLimitItem = item.As <IContingencyConstraintLimit>();

                if (((contingencyConstraintLimitItem != null) &&
                     this._parent.ContingencyConstraintLimits.Remove(contingencyConstraintLimitItem)))
                {
                    return(true);
                }
                if ((this._parent.DefaultConstraintLimit == item))
                {
                    this._parent.DefaultConstraintLimit = null;
                    return(true);
                }
                if ((this._parent.BaseCaseConstraintLimit == item))
                {
                    this._parent.BaseCaseConstraintLimit = null;
                    return(true);
                }
                IConstraintTerm constraintTermItem = item.As <IConstraintTerm>();

                if (((constraintTermItem != null) &&
                     this._parent.ConstraintTerms.Remove(constraintTermItem)))
                {
                    return(true);
                }
                if ((this._parent.RTO == item))
                {
                    this._parent.RTO = null;
                    return(true);
                }
                return(false);
            }
Пример #2
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IContingencyConstraintLimit contingencyConstraintLimitsCasted = item.As <IContingencyConstraintLimit>();

                if ((contingencyConstraintLimitsCasted != null))
                {
                    this._parent.ContingencyConstraintLimits.Add(contingencyConstraintLimitsCasted);
                }
                if ((this._parent.DefaultConstraintLimit == null))
                {
                    IDefaultConstraintLimit defaultConstraintLimitCasted = item.As <IDefaultConstraintLimit>();
                    if ((defaultConstraintLimitCasted != null))
                    {
                        this._parent.DefaultConstraintLimit = defaultConstraintLimitCasted;
                        return;
                    }
                }
                if ((this._parent.BaseCaseConstraintLimit == null))
                {
                    IBaseCaseConstraintLimit baseCaseConstraintLimitCasted = item.As <IBaseCaseConstraintLimit>();
                    if ((baseCaseConstraintLimitCasted != null))
                    {
                        this._parent.BaseCaseConstraintLimit = baseCaseConstraintLimitCasted;
                        return;
                    }
                }
                IConstraintTerm constraintTermsCasted = item.As <IConstraintTerm>();

                if ((constraintTermsCasted != null))
                {
                    this._parent.ConstraintTerms.Add(constraintTermsCasted);
                }
                if ((this._parent.RTO == null))
                {
                    IRTO rTOCasted = item.As <IRTO>();
                    if ((rTOCasted != null))
                    {
                        this._parent.RTO = rTOCasted;
                        return;
                    }
                }
            }