本文整理汇总了C#中TransportType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TransportType.ToString方法的具体用法?C# TransportType.ToString怎么用?C# TransportType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransportType
的用法示例。
在下文中一共展示了TransportType.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransportSource
public ITransportInterface TransportSource(TransportType type)
{
switch (type)
{
case TransportType.Metro:
return new MetroSource();
case TransportType.Train:
return new TrainSource();
default:
throw new NotSupportedException("TransportType: " + type.ToString());
}
}
示例2: GetTransport
public Transport GetTransport(TransportType type)
{
// A BoatPlane is worth 500k, otherwise it is worth 100k
var transportValue = type == TransportType.BoatPlane ? 500000 : 100000;
const int carSize = 6;
var transportString = type.ToString();
var normalGraphic = _content.Load<Texture2D>(String.Concat("Images/Transport/", transportString));
var glowGraphic = _content.Load<Texture2D>(String.Concat("Images/Transport/", transportString, "_glow"));
var newTransport = new Transport(type, transportString, carSize, normalGraphic, glowGraphic, transportValue);
return newTransport;
}
示例3: CreateFromConnectionString
/// <summary>
/// Create DeviceClient from the specified connection string using the specified transport type
/// (WinRT) Only Http transport is allowed
/// </summary>
/// <param name="connectionString">Connection string for the IoT hub (including DeviceId)</param>
/// <param name="transportType">Specifies whether Amqp or Http transport is used</param>
/// <returns>DeviceClient</returns>
public static DeviceClient CreateFromConnectionString(string connectionString, TransportType transportType)
{
if (connectionString == null)
{
throw new ArgumentNullException("connectionString");
}
var iotHubConnectionString = IotHubConnectionString.Parse(connectionString);
if (transportType == TransportType.Http1)
{
return new DeviceClient(new HttpDeviceClient(iotHubConnectionString));
}
else
{
throw new NotImplementedException();
}
throw new InvalidOperationException("Unsupported Transport Type " + transportType.ToString());
}
示例4: OscServer
/// <summary>
/// Creates a new instance of OscServer.
/// </summary>
/// <param name="transportType">The underlying transport protocol.</param>
/// <param name="ipAddress">The local IP address to bind to.</param>
/// <param name="port">The UDP port to bind to.</param>
/// <param name="multicastAddress">The multicast IP address to join.</param>
/// <param name="transmissionType">The transmission type for the server to use.</param>
/// <param name="consumeParsingExceptions">Specifies the behavior of handling parsing exceptions.</param>
/// <remarks>If ipAddress is specified, Unicast; otherwise, if multicastAddress is specified, Multicast.</remarks>
public OscServer(TransportType transportType, IPAddress ipAddress, int port, IPAddress multicastAddress, TransmissionType transmissionType, bool consumeParsingExceptions)
{
Assert.IsTrue(transportType == TransportType.Udp || transportType == TransportType.Tcp);
if ((transportType == TransportType.Tcp) && (transmissionType != TransmissionType.Unicast))
{
throw new InvalidOperationException("TCP must be used with TransmissionType.Unicast.");
}
mTransportType = transportType;
mIPAddress = ipAddress;
mPort = port;
mIPEndPoint = new IPEndPoint(ipAddress, port);
mTransmissionType = transmissionType;
if (mTransmissionType == TransmissionType.Multicast)
{
Assert.ParamIsNotNull(multicastAddress);
mMulticastAddress = multicastAddress;
}
mRegisteredMethods = new List<string>();
mFilterRegisteredMethods = true;
mConsumeParsingExceptions = consumeParsingExceptions;
switch (mTransportType)
{
case TransportType.Udp:
mUdpServer = new UdpServer(mIPAddress, mPort, mMulticastAddress, mTransmissionType);
mUdpServer.DataReceived += new UdpDataReceivedHandler(mUdpServer_DataReceived);
break;
case TransportType.Tcp:
mTcpServer = new TcpServer(mIPAddress, mPort, true, false, OscPacket.LittleEndianByteOrder);
mTcpServer.DataReceived += new TcpDataReceivedHandler(mTcpServer_DataReceived);
break;
default:
throw new InvalidOperationException("Invalid transport type: " + mTransportType.ToString());
}
}
示例5: CreateTransport
public IVoIPTransport CreateTransport(TransportType transportType)
{
return _container.Get<IVoIPTransport>(transportType.ToString());
}