コード例 #1
0
 /// <inheritdoc/>
 public void LoadExtension(string rootDirectory, string manifestJson, IExtensionHandler handler)
 {
     if (Cef.CurrentlyOnThread(CefThreadIds.TID_UI))
     {
         requestContext.LoadExtension(rootDirectory, manifestJson, handler);
     }
     else
     {
         Cef.UIThreadTaskFactory.StartNew(() =>
         {
             requestContext.LoadExtension(rootDirectory, manifestJson, handler);
         });
     }
 }
コード例 #2
0
        /// <summary>
        /// Registers a handler to call when reading non-native XLIFF elements and attributes to store extension data.
        /// </summary>
        /// <param name="ns">The namespace of items handled by the handler.</param>
        /// <param name="handler">The handler to add.</param>
        public void RegisterExtensionHandler(string ns, IExtensionHandler handler)
        {
            ArgValidator.Create(ns, "ns").IsNotNullOrWhitespace();
            ArgValidator.Create(handler, "handler").IsNotNull();

            if (this.handlers.Value.ContainsKey(ns))
            {
                string message;

                message = string.Format(Properties.Resources.XliffReader_ExtensionAlreadyRegistered_Format, ns);
                throw new ExtensionAlreadyRegisteredException(message);
            }

            this.handlers.Value.Add(ns, handler);
        }
コード例 #3
0
        public void LoadExtension(string rootDirectory, string manifestJson, IExtensionHandler handler)
        {
            return;

            //    bool manifest = false;

            /// CefRefPtr
            //         < CefDictionaryValue > manifest;
            //
            //      object value = null;
            //          manifest = value->GetDictionary();

            //        Exception gcnew = null;
            // throw gcnew int errorCode = 0;
            // object errorMessage = null;
            // Exception("Unable to parse JSON ErrorCode:" + Convert::ToString((int)errorCode) + "; ErrorMessage:" + StringUtils::ToClr(errorMessage));


            throw new NotImplementedException();
        }
コード例 #4
0
        /// <summary>
        /// Load extension(s) from the given directory. This methods obtains all the sub directories of <paramref name="rootDirectory"/>
        /// and calls <see cref="IRequestContext.LoadExtension(string, string, IExtensionHandler)"/> if manifest.json
        /// is found in the sub folder. To load crx file(s) you must unzip them first.
        /// For further details see <seealso cref="IRequestContext.LoadExtension(string, string, IExtensionHandler)"/>
        /// </summary>
        /// <param name="requestContext">request context</param>
        /// <param name="rootDirectory">absolute path to the directory that contains the extension(s) to be loaded.</param>
        /// <param name="handler">handle events related to browser extensions</param>
        public static void LoadExtensionsFromDirectory(this IRequestContext requestContext, string rootDirectory, IExtensionHandler handler)
        {
            var fullPath = Path.GetFullPath(rootDirectory);

            foreach (var dir in Directory.GetDirectories(fullPath))
            {
                //Check the directory has a manifest.json, if so call load
                if (File.Exists(Path.Combine(dir, "manifest.json")))
                {
                    requestContext.LoadExtension(dir, null, handler);
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Load an extension from the given directory. To load a crx file you must unzip it first.
 /// For further details see <seealso cref="IRequestContext.LoadExtension(string, string, IExtensionHandler)"/>
 /// </summary>
 /// <param name="requestContext">request context</param>
 /// <param name="rootDirectory">absolute path to the directory that contains the extension to be loaded.</param>
 /// <param name="handler">handle events related to browser extensions</param>
 public static void LoadExtensionFromDirectory(this IRequestContext requestContext, string rootDirectory, IExtensionHandler handler)
 {
     requestContext.LoadExtension(Path.GetFullPath(rootDirectory), null, handler);
 }
コード例 #6
0
 /// <inheritdoc/>
 public void LoadExtension(string rootDirectory, string manifestJson, IExtensionHandler handler)
 {
     requestContext.LoadExtension(rootDirectory, manifestJson, handler);
 }
コード例 #7
0
        /// <summary>
        /// Registers a handler to call when reading non-native XLIFF elements and attributes to store extension data.
        /// </summary>
        /// <param name="ns">The namespace of items handled by the handler.</param>
        /// <param name="handler">The handler to add.</param>
        public void RegisterExtensionHandler(string ns, IExtensionHandler handler)
        {
            ArgValidator.Create(ns, "ns").IsNotNullOrWhitespace();
            ArgValidator.Create(handler, "handler").IsNotNull();

            if (this.handlers.Value.ContainsKey(ns))
            {
                string message;

                message = string.Format(Properties.Resources.XliffReader_ExtensionAlreadyRegistered_Format, ns);
                throw new ExtensionAlreadyRegisteredException(message);
            }

            this.handlers.Value.Add(ns, handler);
        }