internal static bool AddValue(ref ISet <AnalysisUnit> references, AnalysisUnit value) { AnalysisUnit prevNs; SetOfTwo <AnalysisUnit> prevSetOfTwo; if (references == null) { references = value; return(true); } else if ((prevNs = references as AnalysisUnit) != null) { if (references != value) { references = new SetOfTwo <AnalysisUnit>(prevNs, value); return(true); } } else if ((prevSetOfTwo = references as SetOfTwo <AnalysisUnit>) != null) { if (value != prevSetOfTwo.Value1 && value != prevSetOfTwo.Value2) { references = new HashSet <AnalysisUnit>(prevSetOfTwo); references.Add(value); return(true); } } else { return(references.Add(value)); } return(false); }
internal static bool Add(ref ISet <Namespace> set, Namespace ns) { Namespace one; if (set == null) { set = ns; return(true); } else if ((one = set as Namespace) != null) { if (!one.Contains(ns)) { set = new SetOfTwo <Namespace>(one, ns); return(true); } } else if (set is SetOfTwo <Namespace> ) { if (set.Contains(ns)) { return(false); } set = new HashSet <Namespace>(set); set.Add(ns); return(true); } else if (set.Add(ns)) { if (set.Count > MaxUniqueNamespaces) { if (((HashSet <Namespace>)set).Comparer == ObjectComparer) { set = new HashSet <Namespace>(set, UnionComparer); } } return(true); } return(false); }
internal static bool AddValue(ref ISet<AnalysisUnit> references, AnalysisUnit value) { AnalysisUnit prevNs; SetOfTwo<AnalysisUnit> prevSetOfTwo; if (references == null) { references = value; return true; } else if ((prevNs = references as AnalysisUnit) != null) { if (references != value) { references = new SetOfTwo<AnalysisUnit>(prevNs, value); return true; } } else if ((prevSetOfTwo = references as SetOfTwo<AnalysisUnit>) != null) { if (value != prevSetOfTwo.Value1 && value != prevSetOfTwo.Value2) { references = new HashSet<AnalysisUnit>(prevSetOfTwo); references.Add(value); return true; } } else { return references.Add(value); } return false; }