Esempio n. 1
0
        public DomainLogicRoot(IProductWebpageDownloader productWebpageDownloader, IDb database)
        {
            var productPageParser = new ProductPageParser();

            GetHandler = new RequestHandler(productWebpageDownloader, productPageParser, database);
        }
Esempio n. 2
0
 public ValuesController(IGetHandler getHandler)
 {
     _getHandler = getHandler;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebDavDispatcherClass1"/> class.
        /// </summary>
        /// <param name="class1Handlers">The WebDAV class 1 handlers</param>
        /// <param name="context">The WebDAV context</param>
        /// <param name="deadPropertyFactory">The factory to create dead properties</param>
        /// <param name="mimeTypeDetector">The mime type detector for the getmimetype property</param>
        /// <param name="options">The options for the WebDAV class 1 implementation</param>
        public WebDavDispatcherClass1(
            IEnumerable <IClass1Handler> class1Handlers,
            IWebDavContext context,
            IDeadPropertyFactory deadPropertyFactory,
            IMimeTypeDetector mimeTypeDetector,
            IOptions <WebDavDispatcherClass1Options> options)
        {
            _deadPropertyFactory = deadPropertyFactory;
            _mimeTypeDetector    = mimeTypeDetector;
            var httpMethods = new HashSet <string>();

            foreach (var class1Handler in class1Handlers)
            {
                var handlerFound = false;

                if (class1Handler is IOptionsHandler optionsHandler)
                {
                    _optionsHandler = optionsHandler;
                    handlerFound    = true;
                }

                if (class1Handler is IPropFindHandler propFindHandler)
                {
                    _propFindHandler = propFindHandler;
                    handlerFound     = true;
                }

                if (class1Handler is IGetHandler getHandler)
                {
                    _getHandler  = getHandler;
                    handlerFound = true;
                }

                if (class1Handler is IHeadHandler headHandler)
                {
                    _headHandler = headHandler;
                    handlerFound = true;
                }

                if (class1Handler is IPropPatchHandler propPatchHandler)
                {
                    _propPatchHandler = propPatchHandler;
                    handlerFound      = true;
                }

                if (class1Handler is IPutHandler putHandler)
                {
                    _putHandler  = putHandler;
                    handlerFound = true;
                }

                if (class1Handler is IMkColHandler mkColHandler)
                {
                    _mkColHandler = mkColHandler;
                    handlerFound  = true;
                }

                if (class1Handler is IDeleteHandler deleteHandler)
                {
                    _deleteHandler = deleteHandler;
                    handlerFound   = true;
                }

                if (class1Handler is ICopyHandler copyHandler)
                {
                    _copyHandler = copyHandler;
                    handlerFound = true;
                }

                if (class1Handler is IMoveHandler moveHandler)
                {
                    _moveHandler = moveHandler;
                    handlerFound = true;
                }

                if (!handlerFound)
                {
                    throw new NotSupportedException();
                }

                foreach (var httpMethod in class1Handler.HttpMethods)
                {
                    httpMethods.Add(httpMethod);
                }
            }

            HttpMethods   = httpMethods.ToList();
            WebDavContext = context;

            OptionsResponseHeaders = new Dictionary <string, IEnumerable <string> >()
            {
                ["Allow"] = HttpMethods,
            };

            DefaultResponseHeaders = new Dictionary <string, IEnumerable <string> >()
            {
                ["DAV"] = new[] { "1" },
            };

            _defaultCreationMap = new Lazy <IReadOnlyDictionary <XName, CreateDeadPropertyDelegate> >(() => CreateDeadPropertiesMap(options?.Value ?? new WebDavDispatcherClass1Options()));
        }