/// <summary> /// Visits the specified type invariant. /// </summary> /// <param name="typeInvariant">The type invariant.</param> protected virtual ITypeInvariant DeepCopy(TypeInvariant typeInvariant) { typeInvariant.Condition = this.Substitute(typeInvariant.Condition); if (typeInvariant.Description != null) typeInvariant.Description = this.Substitute(typeInvariant.Description); return typeInvariant; }
/// <summary> /// Get the mutable copy of a type invariant. /// </summary> /// <param name="typeInvariant"></param> /// <returns></returns> public virtual TypeInvariant GetMutableCopy(ITypeInvariant typeInvariant) { object cachedValue; if (this.cache.TryGetValue(typeInvariant, out cachedValue)) return (TypeInvariant)cachedValue; var result = new TypeInvariant(typeInvariant); // Probably not necessary, no two thrown exceptions are shared. this.cache.Add(typeInvariant, result); this.cache.Add(result, result); return result; }