public static AgreedExtensionParameter ResolveParameter(string parameter)
        {
            if (!ValidateParameter(parameter))
            {
                return(null);
            }

            var keyValuePair       = parameter.TrimStart().TrimEnd().Split('=');
            var inputParameterName = keyValuePair[0].TrimStart().TrimEnd();
            ExtensionParameter matchedParameter = null;

            foreach (var @param in AllAvailableParameters)
            {
                if (string.Compare(inputParameterName, @param.Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    matchedParameter = @param;
                    break;
                }
            }

            switch (matchedParameter.Name)
            {
            case ServerNoContextTakeOverParameterName:
            case ClientNoContextTakeOverParameterName:
            {
                return(new AgreedSingleParameter(matchedParameter.Name));
            }

            case ServerMaxWindowBitsParameterName:
            case ClientMaxWindowBitsParameterName:
            {
                if (keyValuePair.Length == 1)
                {
                    return(new AgreedValuableParameter <byte>(matchedParameter.Name, ((AbsentableValueParameter <byte>)matchedParameter).DefaultValue));
                }

                var inputParameterValue = keyValuePair[1].TrimStart().TrimEnd();
                return(new AgreedValuableParameter <byte>(matchedParameter.Name, byte.Parse(inputParameterValue)));
            }

            default:
                throw new NotSupportedException("Invalid parameter type.");
            }
        }
        public static bool ValidateParameter(string parameter)
        {
            if (string.IsNullOrWhiteSpace(parameter))
            {
                return(false);
            }

            var keyValuePair       = parameter.TrimStart().TrimEnd().Split('=');
            var inputParameterName = keyValuePair[0].TrimStart().TrimEnd();
            ExtensionParameter matchedParameter = null;

            foreach (var @param in AllAvailableParameters)
            {
                if (string.Compare(inputParameterName, @param.Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    matchedParameter = @param;
                    break;
                }
            }

            if (matchedParameter == null)
            {
                return(false);
            }

            switch (matchedParameter.ParameterType)
            {
            case ExtensionParameterType.Single:
            {
                if (keyValuePair.Length == 1)
                {
                    return(true);
                }
            }
            break;

            case ExtensionParameterType.Valuable:
            {
                if (keyValuePair.Length != 2)
                {
                    return(false);
                }

                var inputParameterValue = keyValuePair[1].TrimStart().TrimEnd();
                if (((ValuableParameter <byte>)matchedParameter).ValueValidator.Invoke(inputParameterValue))
                {
                    return(true);
                }
            }
            break;

            case ExtensionParameterType.Single | ExtensionParameterType.Valuable:
            {
                if (keyValuePair.Length == 1)
                {
                    return(true);
                }

                if (keyValuePair.Length > 2)
                {
                    return(false);
                }

                var inputParameterValue = keyValuePair[1].TrimStart().TrimEnd();
                if (((AbsentableValueParameter <byte>)matchedParameter).ValueValidator.Invoke(inputParameterValue))
                {
                    return(true);
                }
            }
            break;

            default:
                throw new NotSupportedException("Invalid parameter type.");
            }

            return(false);
        }