summaryrefslogtreecommitdiff
path: root/code/common/AbstractHandler.cs
blob: 75752911d09640c59ab1b7a17b30b703e16c2bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;

namespace common
{
    public abstract class AbstractHandler<T> : Handler<T>, Handler
    {
        bool can_handle(Type type)
        {
            this.log().debug("{0} can handle {1} = {2}", this, type, typeof (T).Equals(type));
            return typeof (T).Equals(type);
        }

        public void handle(object item)
        {
            if (can_handle(item.GetType()))
            {
                this.log().debug("handling... {0}", item);
                handle((T) item);
            }
        }

        public abstract void handle(T item);
    }
}