コード例 #1
0
 private static void ValidateValueIsCorrectType <T>(object value, string referenceId)
 {
     try
     {
         // No need to worry about unboxing here since T will always be a reference type at this point.
         T _ = (T)value;
     }
     catch (InvalidCastException)
     {
         ThrowHelper.ThrowInvalidOperationException_MetadataReferenceOfTypeCannotBeAssignedToType(
             referenceId, value.GetType(), typeof(T));
         throw;
     }
 }