本文整理汇总了C#中RequestType.ParseParameters方法的典型用法代码示例。如果您正苦于以下问题:C# RequestType.ParseParameters方法的具体用法?C# RequestType.ParseParameters怎么用?C# RequestType.ParseParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestType
的用法示例。
在下文中一共展示了RequestType.ParseParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishRequestDelta
/// <summary>
/// Publishes the request delta.
/// </summary>
/// <param name="request">The request type.</param>
/// <param name="comparedRequest">if set to <c>true</c>, lookups associated with the [//ComparedRequest/Delta/...] parameter.</param>
private void PublishRequestDelta(RequestType request, bool comparedRequest)
{
Logger.Instance.WriteMethodEntry(EventIdentifier.ResolveLookupsPublishRequestDelta, "Request Operation: '{0}'. ComparedRequest: '{1}'.", request.Operation, comparedRequest);
try
{
// Action will be determined based on the request type
// Put requests support additional modes (Insert, Remove)
switch (request.Operation)
{
case OperationType.Put:
{
// Pull the update request parameters from the request and loop through them
ReadOnlyCollection<UpdateRequestParameter> requestParameters = request.ParseParameters<UpdateRequestParameter>();
foreach (UpdateRequestParameter parameter in requestParameters)
{
string propertyKey = string.Empty;
UniqueIdentifier target = comparedRequest ? request.Target : this.Request.CurrentRequest.Target;
// for some reason target comes as null for compared requests
if (parameter.Target == target || target == null)
{
// Build the property key based on the mode for the update
// This property key will be used to identify matching keys in the read and expression dictionaries
switch (parameter.Mode)
{
case UpdateMode.Modify:
propertyKey = string.Format(CultureInfo.InvariantCulture, "Delta/{0}", parameter.PropertyName);
break;
case UpdateMode.Insert:
propertyKey = string.Format(CultureInfo.InvariantCulture, "Delta/{0}/Added", parameter.PropertyName);
break;
case UpdateMode.Remove:
propertyKey = string.Format(CultureInfo.InvariantCulture, "Delta/{0}/Removed", parameter.PropertyName);
break;
}
}
Logger.Instance.WriteVerbose(EventIdentifier.ResolveLookupsPublishRequestDelta, "Request Operation: '{0}'. ComparedRequest: '{1}'. Request Target: '{2}'. RequestParameter Target: '{3}'. Parameter: '{4}'.", request.Operation, comparedRequest, target, parameter.Target, parameter.PropertyName);
// If this is a compared request, append the "ComparedRequest/" prefix to the delta property key
// Publish the delta property to the resource and expression dictionaries
if (comparedRequest)
{
propertyKey = string.Format(CultureInfo.InvariantCulture, "ComparedRequest/{0}", propertyKey);
}
this.Publish(propertyKey, parameter.Value);
}
}
break;
case OperationType.Create:
{
// Pull the create request parameters from the request and loop through them
ReadOnlyCollection<CreateRequestParameter> requestParameters = request.ParseParameters<CreateRequestParameter>();
foreach (CreateRequestParameter parameter in requestParameters)
{
string propertyKey = string.Empty;
UniqueIdentifier target = comparedRequest ? request.Target : this.Request.CurrentRequest.Target;
// This be always null in AuthZ for a create request.
if (parameter.Target == target || target == null)
{
// Build the property key which will be used to identify matching keys
// in the read and expression dictionaries
propertyKey = string.Format(CultureInfo.InvariantCulture, "Delta/{0}", parameter.PropertyName);
}
Logger.Instance.WriteVerbose(EventIdentifier.ResolveLookupsPublishRequestDelta, "Request Operation: '{0}'. ComparedRequest: '{1}'. Request Target: '{2}'. RequestParameter Target: '{3}'. Parameter: '{4}'.", request.Operation, comparedRequest, target, parameter.Target, parameter.PropertyName);
// If this is a compared request, append the "ComparedRequest/" prefix to the delta property key
// Publish the delta property to the resource and expression dictionaries
if (comparedRequest)
{
propertyKey = string.Format(CultureInfo.InvariantCulture, "ComparedRequest/{0}", propertyKey);
}
this.Publish(propertyKey, parameter.Value);
}
}
break;
}
}
finally
{
Logger.Instance.WriteMethodExit(EventIdentifier.ResolveLookupsPublishRequestDelta, "Request Operation: '{0}'. ComparedRequest: '{1}'.", request.Operation, comparedRequest);
}
}