public static void Unregister()
        {
            lock (registerSync)
            {
                if (!registered)
                {
                    throw new InvalidOperationException("Protocol not yet registered.");
                }

                if (permanent)
                {
                    PluggableProtocolRegistrationServices.UnregisterPermanentProtocolHandler(
                        MethodBase.GetCurrentMethod().DeclaringType,
                        Schema);
                }
                else
                {
                    PluggableProtocolRegistrationServices.UnregisterTemporaryProtocolHandler(
                        MethodBase.GetCurrentMethod().DeclaringType,
                        Schema);
                }

                registered = false;
                permanent  = false;
            }
        }
        public static void RegisterPermanent()
        {
            lock (registerSync)
            {
                if (registered)
                {
                    throw new InvalidOperationException("Protocol already registered.");
                }

                PluggableProtocolRegistrationServices.RegisterPermanentProtocolHandler(
                    MethodBase.GetCurrentMethod().DeclaringType,
                    Schema);

                registered = true;
                permanent  = true;
            }
        }