123456789101112131415161718192021222324252627282930 |
- using Invercargill.DataStructures;
- namespace Invercargill {
- private static Dictionary<Type, Type> promotion_registry = null;
- public static void register_promotion(Type generic, Type promotion) {
- if(promotion_registry == null) {
- promotion_registry = new Dictionary<Type, Type>();
- }
- promotion_registry[generic] = promotion;
- }
- public static void resolve_promotion<T>(ref Type type) {
- if(promotion_registry == null) {
- return;
- }
- Type promotion;
- if(promotion_registry.try_get(typeof(T), out promotion)) {
- type = promotion;
- }
- }
- public interface Promotion<T> {
- public abstract Enumerable<T> wrap(Enumerable<T> enumerable) throws PromotionError;
- public abstract bool can_wrap(Type element_type);
- }
- }
|