Пример #1
0
 /// <summary>Gets the resolver.</summary>
 /// <remarks>Gets the resolver.</remarks>
 /// <TBD></TBD>
 /// <param name="type">the type</param>
 /// <returns>the resolver</returns>
 public virtual CodeResolver GetResolver <T>(Type type) where T : Code
 {
     if (this.resolvers.ContainsKey(type))
     {
         return(this.resolvers.SafeGet(type));
     }
     else
     {
         if (EnumPattern.IsEnum(type)) // or EnumPattern
         {
             // not sure that this is the ideal behaviour here; do we want to return a resolver for something not registered?
             // (though this *is* what happens when this.instance is not null)
             return(new EnumBasedCodeResolver((Type)type));
         }
         else
         {
             if (this.instance == null)
             {
                 throw new InvalidOperationException("No code resolver established for " + type.FullName + ".");
             }
             else
             {
                 return(this.instance);
             }
         }
     }
 }