예제 #1
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.ConnectivityNodeContainer == null))
                {
                    IConnectivityNodeContainer connectivityNodeContainerCasted = item.As <IConnectivityNodeContainer>();
                    if ((connectivityNodeContainerCasted != null))
                    {
                        this._parent.ConnectivityNodeContainer = connectivityNodeContainerCasted;
                        return;
                    }
                }
                if ((this._parent.TopologicalNode == null))
                {
                    ITopologicalNode topologicalNodeCasted = item.As <ITopologicalNode>();
                    if ((topologicalNodeCasted != null))
                    {
                        this._parent.TopologicalNode = topologicalNodeCasted;
                        return;
                    }
                }
                if ((this._parent.BusNameMarker == null))
                {
                    IBusNameMarker busNameMarkerCasted = item.As <IBusNameMarker>();
                    if ((busNameMarkerCasted != null))
                    {
                        this._parent.BusNameMarker = busNameMarkerCasted;
                        return;
                    }
                }
                ILossPenaltyFactor lossPenaltyFactorsCasted = item.As <ILossPenaltyFactor>();

                if ((lossPenaltyFactorsCasted != null))
                {
                    this._parent.LossPenaltyFactors.Add(lossPenaltyFactorsCasted);
                }
                INodeConstraintTerm nodeConstraintTermsCasted = item.As <INodeConstraintTerm>();

                if ((nodeConstraintTermsCasted != null))
                {
                    this._parent.NodeConstraintTerms.Add(nodeConstraintTermsCasted);
                }
                ITerminal terminalsCasted = item.As <ITerminal>();

                if ((terminalsCasted != null))
                {
                    this._parent.Terminals.Add(terminalsCasted);
                }
                if ((this._parent.Pnode == null))
                {
                    IPnode pnodeCasted = item.As <IPnode>();
                    if ((pnodeCasted != null))
                    {
                        this._parent.Pnode = pnodeCasted;
                        return;
                    }
                }
            }
예제 #2
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)
            {
                if ((this._parent.ConnectivityNodeContainer == item))
                {
                    this._parent.ConnectivityNodeContainer = null;
                    return(true);
                }
                if ((this._parent.TopologicalNode == item))
                {
                    this._parent.TopologicalNode = null;
                    return(true);
                }
                if ((this._parent.BusNameMarker == item))
                {
                    this._parent.BusNameMarker = null;
                    return(true);
                }
                ILossPenaltyFactor lossPenaltyFactorItem = item.As <ILossPenaltyFactor>();

                if (((lossPenaltyFactorItem != null) &&
                     this._parent.LossPenaltyFactors.Remove(lossPenaltyFactorItem)))
                {
                    return(true);
                }
                INodeConstraintTerm nodeConstraintTermItem = item.As <INodeConstraintTerm>();

                if (((nodeConstraintTermItem != null) &&
                     this._parent.NodeConstraintTerms.Remove(nodeConstraintTermItem)))
                {
                    return(true);
                }
                ITerminal terminalItem = item.As <ITerminal>();

                if (((terminalItem != null) &&
                     this._parent.Terminals.Remove(terminalItem)))
                {
                    return(true);
                }
                if ((this._parent.Pnode == item))
                {
                    this._parent.Pnode = null;
                    return(true);
                }
                return(false);
            }