本文整理汇总了C#中IParameterCollection.ContainsParameter方法的典型用法代码示例。如果您正苦于以下问题:C# IParameterCollection.ContainsParameter方法的具体用法?C# IParameterCollection.ContainsParameter怎么用?C# IParameterCollection.ContainsParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IParameterCollection
的用法示例。
在下文中一共展示了IParameterCollection.ContainsParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessBefore
// TODO: Break in to Supporting Objects, User, Object, and Field Level Security Processing
public void ProcessBefore(IParameterCollection inputs, IList<CustomAttributeNamedArgument> customAttributeNamedArguments)
{
if (_validationContext.EnableValidation)
{
var parameters = customAttributeNamedArguments.FirstOrDefault(x => x.MemberName == "Parameters").TypedValue.Value as string;
if (parameters == null)
{
parameters = string.Empty;
}
var parameterList = parameters.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
var validationMessages = new List<string>();
var isValid = true;
if (parameterList.Length == 0 && inputs.Count > 0)
{
var flaggedInput = inputs[0];
if (flaggedInput != null)
{
var response = Validate(flaggedInput);
isValid = response.IsValid;
validationMessages.AddRange(response.ValidationErrors);
}
}
else
{
foreach (var parameter in parameterList)
{
if (!String.IsNullOrWhiteSpace(parameter) && inputs.ContainsParameter(parameter))
{
var flaggedInput = inputs[parameter];
if (flaggedInput != null)
{
var response = Validate(flaggedInput);
isValid = isValid && response.IsValid;
validationMessages.AddRange(response.ValidationErrors);
}
}
else
{
throw new ConfigurationErrorsException(string.Format("Incorrect Parameter Specified {0}, Parameter Does Not Exist!", parameter));
}
}
}
if (!isValid)
{
var validationMessageStringBuilder = new StringBuilder();
foreach (var validationMessage in validationMessages)
{
validationMessageStringBuilder.Append(validationMessage);
validationMessageStringBuilder.Append(" ");
}
throw new ValidationException(validationMessageStringBuilder.ToString());
}
}
}
示例2: ProcessBefore
// TODO: Break in to Supporting Objects, User, Object, and Field Level Security Processing
public void ProcessBefore(IParameterCollection inputs, IList<CustomAttributeNamedArgument> customAttributeNamedArguments)
{
var action = customAttributeNamedArguments.FirstOrDefault(x => x.MemberName == "Action").TypedValue.Value as string;
if (action == null)
{
throw new ConfigurationErrorsException("No Security Action Specified for Method!");
}
if (_securityContext.EnableUserLevelSecurity)
{
var response = _securityAuthorizationProvider.CheckUserAuthorization(action);
if (!response.IsAuthorized)
{
throw new SecurityException(response.AuthorizationMessage);
}
}
if (_securityContext.EnableObjectLevelSecurity)
{
if (action != "Read")
{
var parameters = customAttributeNamedArguments.FirstOrDefault(x => x.MemberName == "Parameters").TypedValue.Value as string;
if (parameters == null)
{
parameters = string.Empty;
}
var parameterList = parameters.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
foreach (var parameter in parameterList)
{
if (!String.IsNullOrWhiteSpace(parameter) && inputs.ContainsParameter(parameter))
{
var flaggedInput = inputs[parameter];
if (flaggedInput != null && (action == "Update" || action == "Create"))
{
if (_securityContext.EnableFieldLevelSecurity)
{
// NOTE: This implementation Makes a Hard Assumption on Mongo
// TODO: Decouple from Mongo
var flaggedInputType = flaggedInput.GetType();
var originalInput = _objectFactory.Create(flaggedInputType);
if (action == "Update")
{
var flaggedEntity = flaggedInput as IEntity<string>;
if (flaggedEntity != null)
{
originalInput = _genericRepository.GetById(flaggedInput.GetType(), flaggedEntity.Id);
}
else
{
throw new SecurityException("Cannot Determine Access!");
}
}
var response = _securityAuthorizationProvider.CheckObjectAuthorization(flaggedInput, originalInput, action);
if (!response.IsAuthorized)
{
throw new SecurityException(response.AuthorizationMessage);
}
var flaggedInputPropertyInfoList = flaggedInput.GetType().GetProperties();
var responsePropertyInfoList = response.SecuredObject.GetType().GetProperties();
for (var i = 0; i < flaggedInputPropertyInfoList.Length; i++)
{
flaggedInputPropertyInfoList[i].SetValue(flaggedInput, responsePropertyInfoList[i].GetValue(response.SecuredObject));
}
}
else
{
var response = _securityAuthorizationProvider.CheckObjectAuthorization(flaggedInput, null, action);
if (!response.IsAuthorized)
{
throw new SecurityException(response.AuthorizationMessage);
}
}
}
if (action == "Delete")
{
var response = _securityAuthorizationProvider.CheckObjectAuthorization(flaggedInput, null, action);
if (!response.IsAuthorized)
{
throw new SecurityException(response.AuthorizationMessage);
}
}
}
else
{
throw new ConfigurationErrorsException(string.Format("Incorrect Parameter Specified {0}, Parameter Does Not Exist!", parameter));
}
}
}
}
}