Esempio n. 1
0
        public static T GetOrAddDefinition <T>(this Polymorphic <T> polymorphic, Type type) where T : class, new()
        {
            T value = polymorphic.GetDefinition(type);

            if (value != null)
            {
                return(value);
            }

            value = new T();

            polymorphic.SetDefinition(type, value);

            return(value);
        }
Esempio n. 2
0
 public static void Register <T, S, P0, P1, P2, P3, R>(this Polymorphic <Func <T, P0, P1, P2, P3, R> > polymorphic, Func <S, P0, P1, P2, P3, R> func) where S : T
 {
     polymorphic.SetDefinition(typeof(S), (t, p0, p1, p2, p3) => func((S)t, p0, p1, p2, p3));
 }
Esempio n. 3
0
 public static void Register <T, S, R>(this Polymorphic <Func <T, R> > polymorphic, Func <S, R> func) where S : T
 {
     polymorphic.SetDefinition(typeof(S), t => func((S)t));
 }
Esempio n. 4
0
 public static void Register <T, S, P0, P1, P2, P3>(this Polymorphic <Action <T, P0, P1, P2, P3> > polymorphic, Action <S, P0, P1, P2, P3> action) where S : T
 {
     polymorphic.SetDefinition(typeof(S), (t, p0, p1, p2, p3) => action((S)t, p0, p1, p2, p3));
 }
Esempio n. 5
0
 public static void Register <T, S, P0>(this Polymorphic <Action <T, P0> > polymorphic, Action <S, P0> action) where S : T
 {
     polymorphic.SetDefinition(typeof(S), (t, p0) => action((S)t, p0));
 }
Esempio n. 6
0
 public static void Register <T, S>(this Polymorphic <Action <T> > polymorphic, Action <S> action) where S : T
 {
     polymorphic.SetDefinition(typeof(S), t => action((S)t));
 }