Esempio n. 1
0
        public MainForm(IFileReader fileReader,
                        IFileTabPageFactory fileTabPageFactory,
                        IOptionsHandler optionsHandler)
        {
            InitializeComponent();

            if (components == null)
            {
                components = new System.ComponentModel.Container();
            }

            this.fileReader         = fileReader;
            this.fileTabPageFactory = fileTabPageFactory;
            this.optionsHandler     = optionsHandler;
            options = optionsHandler.Options;
            wrapLongLinesMenuItem.Checked = !options.WrapLongLines;

            var menuItems = new ToolStripItem[]
            {
                copyPathMenuItem,
                toolStripSeparator3,
                closeMenuItem,
                closeAllButThisMenuItem,
                closeAllMenuItem
            };

            contextMenuStrip = new ContextMenuStrip(components)
            {
                Name = $"contextMenuStrip",
                Size = new Size(197, 98)
            };
            contextMenuStrip.Items.AddRange(menuItems);
        }
Esempio n. 2
0
        internal OptionsDialog(Type optionsType, IOptionsHandler handler)
        {
            string root = handler.ConfigPath;

            dialog           = null;
            modImage         = null;
            this.handler     = handler ?? throw new ArgumentNullException("handler");
            this.optionsType = optionsType ?? throw new ArgumentNullException("optionsType");
            optionCategories = OptionsEntry.BuildOptions(optionsType);
            options          = null;
            // Determine config location
            infoAttr = POptions.GetModInfoAttribute(optionsType);
            typeAttr = POptions.GetConfigFileAttribute(optionsType);
            path     = (root == null) ? null : Path.Combine(root, typeAttr?.ConfigFileName ??
                                                            POptions.CONFIG_FILE_NAME);
        }
Esempio n. 3
0
 public OptionsController(IOptionsHandler impl)
 {
     _impl = impl;
 }
        /// <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()));
        }