Пример #1
0
    public static void Register()
    {
        var binder = new NumericValueBinder();

        foreach (var type in NumericValueParser.Types)
        {
            // Register for both type and nullable type
            ModelBinders.Binders.Add(type, binder);
            ModelBinders.Binders.Add(typeof(Nullable <>).MakeGenericType(type), binder);
        }
    }
Пример #2
0
    public static void Register()
    {
        var binder = new NumericValueBinder();

        Type[] types =
        {
            typeof(decimal), typeof(double), typeof(float),
            typeof(int),     typeof(long),   typeof(short),
            typeof(uint),    typeof(ulong),  typeof(ushort),
        };
        foreach (var type in types)
        {
            // Register for both type and nullable type
            ModelBinders.Binders.Add(type, binder);
            ModelBinders.Binders.Add(typeof(Nullable <>).MakeGenericType(type), binder);
        }
    }