A condition that must be true after an object has been constructed and that is by default a part of the precondition and postcondition of every public method of the associated type.
상속: ContractElement, ITypeInvariant
예제 #1
0
 /// <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;
 }
예제 #2
0
 /// <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;
 }