本文整理汇总了C#中IRequest.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IRequest.GetType方法的具体用法?C# IRequest.GetType怎么用?C# IRequest.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequest
的用法示例。
在下文中一共展示了IRequest.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RestRequest
internal RestRequest(WebRequest newRequest, IRequest oldRequest)
{
//Probably really slow, but makes sure we get the same
foreach(var property in oldRequest.GetType().GetProperties())
{
//Make sure property exists in new request in case they are different
var propExists = newRequest.GetType().GetProperties().Contains(property);
if (propExists)
{
if (property.Name != "RequestUri")
{
property.SetValue(newRequest, property.GetValue(oldRequest));
}
}
}
_baseRequest = newRequest;
}
示例2: InvokeServiceAsync
/// <summary>Invokes the OWS service corresponding to the specified <paramref name="request" />.</summary>
/// <param name="arguments">The arguments to use for the service instantiation. Can be <c>null</c>.</param>
/// <param name="request">The request that is used for the service call.</param>
/// <returns>The result of the call.</returns>
public async Task<IXmlSerializable> InvokeServiceAsync(object[] arguments, IRequest request)
{
Debug.Assert(request!=null);
if (request==null)
throw new OwsException(OwsExceptionCode.MissingParameterValue) {
Locator=OgcService.RequestParameter
};
string operation=request.GetType().Name;
if (string.IsNullOrEmpty(request.Service))
throw new OwsException(OwsExceptionCode.MissingParameterValue) {
Locator=OgcService.ServiceParameter
};
if ((operation!="GetCapabilities") && string.IsNullOrEmpty(request.Version))
throw new OwsException(OwsExceptionCode.MissingParameterValue) {
Locator=OgcService.VersionParameter
};
return await InvokeServiceAsync(arguments, request, request.Service, request.Version, operation);
}
示例3: CreateRequestHandler
/// <summary>
/// Creates the request handler.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>The newly created request handler.</returns>
protected virtual IRequestHandler CreateRequestHandler(IRequest request)
{
var requestHandlerType = typeof(IRequestHandler<>).MakeGenericType(request.GetType());
var requestHandler = (IRequestHandler)this.CompositionContext.GetExport(requestHandlerType);
return requestHandler;
}
示例4: SubmitRequest
/// <summary>
/// Submit a request to the cvs repository.
/// </summary>
/// <param name="request"></param>
public void SubmitRequest(IRequest request) {
if (null != request && null != request.RequestString) {
if (null != this.RequestMessageEvent) {
this.RequestMessageEvent(this, new MessageEventArgs(request,
request.GetType().Name));
}
}
outputStream.SendString(request.RequestString);
if (request.DoesModifyConnection) {
request.ModifyConnection(this);
}
if (request.IsResponseExpected) {
HandleResponses();
}
}
示例5: GetResponses
public IObservable<IResponse> GetResponses(IRequest request)
{
Connect();
var getSlackChannels = request as GetSlackChannels;
if (getSlackChannels != null)
{
return Observable.Return(new GetSlackChannelsResponse
{
RequestId = request.RequestId,
RequesterId = request.RequesterId,
Channels = _channels.Values.Select(channel =>
new GetSlackChannelsResponse.Channel
{
Id = channel.ID,
Name = channel.Name,
IsPrivate = channel.IsPrivate,
IsMember = channel.IsMember
}).ToList()
});
}
var getSlackUsers = request as GetSlackUsers;
if (getSlackUsers != null)
{
return Observable.Return(new GetSlackUsersResponse
{
RequestId = request.RequestId,
RequesterId = request.RequesterId,
Users = _users.Values.Select(user =>
new GetSlackUsersResponse.User
{
Id = user.ID,
Name = user.Name
}).ToList()
});
}
throw new Exception($"Unknown Request Type '{request.GetType().FullName}'");
}
示例6: NotifyLightsDevice
/// <summary>
/// Notifies the USB device to switch the LEDs correctly, given the request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns><c>true</c> if the device was notified; otherwise, <c>false</c>.</returns>
public LightsDeviceResult NotifyLightsDevice(IRequest request)
{
if (this.usbProtocolType == UsbProtocolType.DasBlinkenlichten)
{
return this.lightsDeviceController.SendCommand(Parser.TranslateForDasBlinkenlichten(request));
}
if (this.usbProtocolType == UsbProtocolType.Blink1)
{
short featureReportByteLength = this.lightsDeviceController.GetFeatureReportByteLength();
byte[] bytes = null;
if (request.GetType() == typeof(BuildActiveRequest))
{
BuildActiveRequest buildActiveRequest = (BuildActiveRequest)request;
if (buildActiveRequest.IsBuildsActive)
{
bytes = Parser.TranslateForBlink1(buildActiveRequest, featureReportByteLength);
}
}
else if (request.GetType() == typeof(AttentionRequest))
{
bytes = Parser.TranslateForBlink1((AttentionRequest)request, featureReportByteLength);
}
else if (request.GetType() == typeof(StatusRequest))
{
StatusRequest statusRequest = (StatusRequest)request;
if (!statusRequest.Status)
{
bytes = Parser.TranslateForBlink1(statusRequest, featureReportByteLength);
}
}
// Hmm... This is a lie. We didn't send anything, but we didn't have to
// (or at least, should not have).
return bytes != null ? this.lightsDeviceController.SendCommand(bytes) : LightsDeviceResult.Ack;
}
throw new UnsupportedUsbProtocolTypeException(string.Format("Type {0} not supported", this.usbProtocolType));
}
示例7: TranslateForDasBlinkenlichten
/// <summary>
/// Translates the specified request to a USB byte command (DasBlinkenlichten protocol).
/// </summary>
/// <param name="request">The request.</param>
/// <returns>An array of byte arrays (commands).</returns>
public static byte[] TranslateForDasBlinkenlichten(IRequest request)
{
if (request.GetType() == typeof(BuildActiveRequest))
{
BuildActiveRequest buildActiveRequest = (BuildActiveRequest)request;
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>> {
buildActiveRequest.IsBuildsActive ? CreatePair(Field.YellowLed, LedState.On) : CreatePair(Field.YellowLed, LedState.Off)
};
return Encoding.ASCII.GetBytes(AssembleCommand(list, Packet.PacketAltTerminator));
}
if (request.GetType() == typeof(AttentionRequest) || request.GetType() == typeof(StatusRequest))
{
// We need to construct two commands, since the USB device only accepts one
// light command in a packet and the red and green lights works in a pair.
// But, nothing stops us from sending two packets in one go...
List<KeyValuePair<string, string>> listRed = new List<KeyValuePair<string, string>>();
List<KeyValuePair<string, string>> listGreen = new List<KeyValuePair<string, string>>();
List<KeyValuePair<string, string>> listYellow = new List<KeyValuePair<string, string>>();
if (request.GetType() == typeof(AttentionRequest) && ((AttentionRequest)request).IsAttentionRequired)
{
AttentionRequest attentionRequest = (AttentionRequest)request;
listRed.Add(attentionRequest.IsPriority ? CreatePair(Field.RedLed, LedState.Sos) : CreatePair(Field.RedLed, LedState.On));
listGreen.Add(CreatePair(Field.GreenLed, LedState.Off));
}
else if (request.GetType() == typeof(AttentionRequest) && !((AttentionRequest)request).IsAttentionRequired)
{
listRed.Add(CreatePair(Field.RedLed, LedState.Off));
listGreen.Add(CreatePair(Field.GreenLed, LedState.On));
}
else if (request.GetType() == typeof(StatusRequest) && !((StatusRequest)request).Status)
{
listRed.Add(CreatePair(Field.RedLed, LedState.On));
listGreen.Add(CreatePair(Field.GreenLed, LedState.On));
listYellow.Add(CreatePair(Field.YellowLed, LedState.On));
}
else if (request.GetType() == typeof(StatusRequest) && ((StatusRequest)request).Status)
{
throw new InvalidTranslationRequestException("Cannot translate a server up request; only a down request");
}
StringBuilder commandBuilder = new StringBuilder();
commandBuilder.Append(AssembleCommand(listRed, Packet.PacketAltTerminator));
commandBuilder.Append(AssembleCommand(listGreen, Packet.PacketAltTerminator));
if (listYellow.Count > 0)
{
commandBuilder.Append(AssembleCommand(listYellow, Packet.PacketAltTerminator));
}
return Encoding.ASCII.GetBytes(commandBuilder.ToString());
}
throw new InvalidTranslationRequestException(string.Format("The request type is not one that can be translated: {0}", request.GetType()));
}
示例8: Encode
/// <summary>
/// Encodes the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>The encoded request</returns>
public static string Encode(IRequest request)
{
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
string requestTypeString = ((int)request.Type).ToString(CultureInfo.InvariantCulture);
list.Add(CreatePair(Field.RequestTypeId, requestTypeString));
if (request.GetType() == typeof(RegistrationRequest))
{
RegistrationRequest registrationRequest = (RegistrationRequest)request;
list.Add(CreatePair(Field.Hostname, registrationRequest.Hostname));
list.Add(CreatePair(Field.Username, registrationRequest.Username));
}
else if (request.GetType() == typeof(BuildActiveRequest))
{
BuildActiveRequest buildActiveRequest = (BuildActiveRequest)request;
list.Add(CreatePair(Field.BuildsActive, Convert.ToInt16(buildActiveRequest.IsBuildsActive).ToString(CultureInfo.InvariantCulture)));
}
else if (request.GetType() == typeof(AttentionRequest))
{
AttentionRequest attentionRequest = (AttentionRequest)request;
list.Add(CreatePair(Field.AttentionRequired, Convert.ToInt16(attentionRequest.IsAttentionRequired).ToString(CultureInfo.InvariantCulture)));
list.Add(CreatePair(Field.AttentionPriority, Convert.ToInt16(attentionRequest.IsPriority).ToString(CultureInfo.InvariantCulture)));
}
else if (request.GetType() == typeof(StatusRequest))
{
StatusRequest statusRequest = (StatusRequest)request;
list.Add(CreatePair(Field.ServerStatus, Convert.ToInt16(statusRequest.Status).ToString(CultureInfo.InvariantCulture)));
}
return AssembleCommand(list);
}