/// <summary> /// 使用要复制的泛型形参的界限集集合初始化 <see cref="TypeBounds"/> 类的新实例。 /// </summary> /// <param name="typeBounds">泛型形参的界限集集合。</param> public TypeBounds(TypeBounds typeBounds) { Contract.Requires(typeBounds != null); var len = typeBounds.boundSets.Length; boundSets = new BoundSet[len]; boundSetDict = new Dictionary <Type, BoundSet>(len); for (var i = 0; i < typeBounds.boundSets.Length; i++) { boundSets[i] = new BoundSet(typeBounds.boundSets[i]); boundSetDict.Add(boundSets[i].GenericArgument, boundSets[i]); } }
/// <summary> /// 使用指定的泛型形参初始化 <see cref="TypeBounds"/> 类的新实例。 /// </summary> /// <param name="genericArguments">泛型形参列表。</param> public TypeBounds(params Type[] genericArguments) { Contract.Requires(genericArguments != null); var len = genericArguments.Length; boundSets = new BoundSet[len]; boundSetDict = new Dictionary <Type, BoundSet>(len); for (var i = 0; i < genericArguments.Length; i++) { boundSets[i] = new BoundSet(genericArguments[i]); boundSetDict.Add(genericArguments[i], boundSets[i]); } }
/// <summary> /// 使用指定的界限集初始化 <see cref="BoundSet"/> 类的新实例。 /// </summary> /// <param name="bound">界限集。</param> public BoundSet(BoundSet bound) { Contract.Requires(bound != null); genericArgument = bound.genericArgument; ReferenceType = bound.ReferenceType; if (bound.exactBound == null) { lowerBounds.UnionWith(bound.lowerBounds); upperBounds.UnionWith(bound.upperBounds); } else { exactBound = bound.exactBound; } }
/// <summary> /// 返回当前类型的复制。 /// </summary> /// <returns>当前类型的复制。</returns> public BoundSet Clone() { BoundSet newSet = new BoundSet(); if (this.exactBound == null) { newSet.lowerBounds.UnionWith(this.lowerBounds); newSet.upperBounds.UnionWith(this.upperBounds); } else { newSet.exactBound = this.exactBound; } newSet.ReferenceType = this.ReferenceType; return(newSet); }
/// <summary> /// 使用指定的界限集初始化 <see cref="BoundSet"/> 类的新实例。 /// </summary> /// <param name="bound">界限集。</param> public BoundSet(BoundSet bound) { Contract.Requires(bound != null); this.genericArgument = bound.genericArgument; this.ReferenceType = bound.ReferenceType; if (bound.exactBound == null) { this.lowerBounds.UnionWith(bound.lowerBounds); this.upperBounds.UnionWith(bound.upperBounds); } else { this.exactBound = bound.exactBound; } }
/// <summary> /// 返回当前类型的复制。 /// </summary> /// <returns>当前类型的复制。</returns> public BoundSet Clone() { BoundSet newSet = new BoundSet(); if (this.exactBound == null) { newSet.lowerBounds.UnionWith(this.lowerBounds); newSet.upperBounds.UnionWith(this.upperBounds); } else { newSet.exactBound = this.exactBound; } newSet.ReferenceType = this.ReferenceType; return newSet; }