summaryrefslogtreecommitdiff
path: root/src/core/extensions/Dynamic.cs
blob: df349456f351cf7222cb1d4e8a6d7196afaa6047 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;

namespace core.extensions
{
    public static class Dynamic
    {
        public static void call_as<DynamicType>(this object target, Action<DynamicType> command) where DynamicType : class
        {
            target.downcast_to<DynamicType>().run(command);
        }

        public static void run<T>(this T target, Action<T> command)
        {
            if (null == target) return;
            command(target);
        }
    }
}