A database based on .net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

// Author: Simon Gockner
// Created: 2020-02-08
// Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
namespace GBase.Api.Communication
{
public enum ServerProtocol //TODO: Decide which protocols should be usable
{
Http,
Https,
Tcp
}
public static class ServerProtocolExtensions
{
public static string GetProtocolString(this ServerProtocol protocol)
{
switch (protocol)
{
case ServerProtocol.Http:
return "http://";
case ServerProtocol.Https:
return "https://";
case ServerProtocol.Tcp:
throw new NotImplementedException();
default:
throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Invalid Protocol");
}
}
public static ServerProtocol GetServerProtocolFromString(string @string)
{
if (@string.Equals("http://") || @string.Equals("http"))
return ServerProtocol.Http;
else if (@string.Equals("https://") || @string.Equals("https"))
return ServerProtocol.Https;
else
throw new ArgumentOutOfRangeException(nameof(@string), @string, "Invalid string.");
}
}
}