Пример #1
0
        void GetResponders()
        {
            _responders = new Dictionary<string, Responder>();

            var asm = typeof (App).Assembly;

            var queryType = typeof (Query);
            var resourceType = typeof (Resource);

            foreach (var t in asm.GetTypes ()) {
                if (queryType.IsAssignableFrom (t) && !t.IsAbstract) {

                    var query = (Query)Activator.CreateInstance (t);
                    var r = new QueryResponder (query, _repository, _options);

                    _responders [query.Path] = r;

                    Console.WriteLine ("{0} -> {1}", query.Path, r);
                }
                else if (resourceType.IsAssignableFrom (t) && !t.IsAbstract) {

                    var resource = (Resource)Activator.CreateInstance (t);
                    var r = new ResourceResponder (resource, _repository, _options);

                    _responders [resource.Path] = r;

                    Console.WriteLine ("{0} -> {1}", resource.Path, r);
                }
            }
        }