コード例 #1
0
        public bool Equals(TermCollection terms)
        {
            if (terms == null)
            {
                return(false);
            }

            return(this.subject.Equals(terms.subject));
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj.GetType() != typeof(TermCollection))
            {
                return(false);
            }

            TermCollection terms = obj as TermCollection;

            return(this.Equals(terms));
        }
コード例 #3
0
        public bool Add(ITerm <Value> Term, Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap,
                        Dictionary <string, HashSet <long> > ResolvedSchedule, bool CheckForPerRisk = true)
        {
            Subject NodeIdentity = Term.GetSubject();

            bool IsAddSuccessful = true;

            if (NodeIdentity == null)
            {
                NodeIdentity = EMPTYSUBJECTCONSTRAINT;
            }

            TermCollection TermCollection = (IdentityMap.ContainsKey(NodeIdentity) ?
                                             IdentityMap[NodeIdentity].GetContent() : new TermCollection(NodeIdentity));

            // Switching off the following check intentionally, in order to allow redundant terms
            //if (TermCollection.Contains(Term))
            //    throw new ArgumentException("A term node with the same identity (i.e. subject) already contains this term in its collection!");

            IsAddSuccessful = TermCollection.Add(Term);

            if (IsAddSuccessful && !IdentityMap.ContainsKey(NodeIdentity))
            {
                TermNode _TermNode = new TermNode(TermCollection);

                IsAddSuccessful &= base.Add(_TermNode);

                if (IsAddSuccessful)
                {
                    IdentityMap.Add(NodeIdentity, _TermNode);
                    // A newly added term node (i.e. with no parent or child links) is both a root and a leaf, trivially.
                    IsAddSuccessful &= RootNodes.Add(_TermNode);
                    ExecutionState.RegisterModificationInGraphTopology();
                }
            }

            return(IsAddSuccessful);
        }