本文整理汇总了C#中System.Workflow.ComponentModel.Compiler.ValidationError类的典型用法代码示例。如果您正苦于以下问题:C# ValidationError类的具体用法?C# ValidationError怎么用?C# ValidationError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationError类属于System.Workflow.ComponentModel.Compiler命名空间,在下文中一共展示了ValidationError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillCorrelationAliasAttrs
private static void FillCorrelationAliasAttrs(MemberInfo memberInfo, Hashtable correlationAliasAttrs, ValidationErrorCollection validationErrors)
{
foreach (object obj2 in memberInfo.GetCustomAttributes(typeof(CorrelationAliasAttribute), false))
{
CorrelationAliasAttribute attributeFromObject = Helpers.GetAttributeFromObject<CorrelationAliasAttribute>(obj2);
if (string.IsNullOrEmpty(attributeFromObject.Name) || (attributeFromObject.Name.Trim().Length == 0))
{
ValidationError item = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Name", memberInfo.Name }), 0x150);
item.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
validationErrors.Add(item);
}
else if (string.IsNullOrEmpty(attributeFromObject.Path) || (attributeFromObject.Path.Trim().Length == 0))
{
ValidationError error2 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_CorrelationAttributeInvalid", new object[] { typeof(CorrelationAliasAttribute).Name, "Path", memberInfo.Name }), 0x150);
error2.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
validationErrors.Add(error2);
}
else if (correlationAliasAttrs.Contains(attributeFromObject.Name))
{
ValidationError error3 = new ValidationError(SR.GetString(CultureInfo.CurrentCulture, "Error_DuplicateCorrelationAttribute", new object[] { typeof(CorrelationAliasAttribute).Name, attributeFromObject.Name, memberInfo.Name }), 0x151);
error3.UserData.Add(typeof(CorrelationAliasAttribute), memberInfo.Name);
validationErrors.Add(error3);
}
else
{
correlationAliasAttrs.Add(attributeFromObject.Name, attributeFromObject);
}
}
}
示例2: Validate
internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
{
RuleExpressionInfo info;
bool flag;
CodeDirectionExpression expression2 = (CodeDirectionExpression) expression;
if (isWritten)
{
ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodeDirectionExpression).ToString() }), 0x17a);
item.UserData["ErrorObject"] = expression2;
validation.Errors.Add(item);
return null;
}
if (expression2.Expression == null)
{
ValidationError error2 = new ValidationError(Messages.NullDirectionTarget, 0x53d);
error2.UserData["ErrorObject"] = expression2;
validation.Errors.Add(error2);
return null;
}
if (expression2.Expression is CodeTypeReferenceExpression)
{
ValidationError error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CodeExpressionNotHandled, new object[] { expression2.Expression.GetType().FullName }), 0x548);
error.UserData["ErrorObject"] = expression2.Expression;
validation.AddError(error);
return null;
}
if (expression2.Direction == FieldDirection.Ref)
{
flag = true;
if (RuleExpressionWalker.Validate(validation, expression2.Expression, false) == null)
{
return null;
}
info = RuleExpressionWalker.Validate(validation, expression2.Expression, true);
}
else if (expression2.Direction == FieldDirection.Out)
{
flag = true;
info = RuleExpressionWalker.Validate(validation, expression2.Expression, true);
}
else
{
flag = false;
info = RuleExpressionWalker.Validate(validation, expression2.Expression, false);
}
if (info == null)
{
return null;
}
Type expressionType = info.ExpressionType;
if (expressionType == null)
{
return null;
}
if (((expressionType != typeof(NullLiteral)) && flag) && !expressionType.IsByRef)
{
expressionType = expressionType.MakeByRefType();
}
return new RuleExpressionInfo(expressionType);
}
示例3: Validate
internal override bool Validate(RuleValidation validation)
{
bool flag = false;
RuleExpressionInfo info = null;
if (this.assignStatement.Left == null)
{
ValidationError item = new ValidationError(Messages.NullAssignLeft, 0x541);
item.UserData["ErrorObject"] = this.assignStatement;
validation.Errors.Add(item);
}
else
{
info = validation.ExpressionInfo(this.assignStatement.Left);
if (info == null)
{
info = RuleExpressionWalker.Validate(validation, this.assignStatement.Left, true);
}
}
RuleExpressionInfo info2 = null;
if (this.assignStatement.Right == null)
{
ValidationError error2 = new ValidationError(Messages.NullAssignRight, 0x543);
error2.UserData["ErrorObject"] = this.assignStatement;
validation.Errors.Add(error2);
}
else
{
info2 = RuleExpressionWalker.Validate(validation, this.assignStatement.Right, false);
}
if ((info == null) || (info2 == null))
{
return flag;
}
Type expressionType = info2.ExpressionType;
Type lhsType = info.ExpressionType;
if (lhsType == typeof(NullLiteral))
{
ValidationError error3 = new ValidationError(Messages.NullAssignLeft, 0x542);
error3.UserData["ErrorObject"] = this.assignStatement;
validation.Errors.Add(error3);
return false;
}
if (lhsType != expressionType)
{
ValidationError error = null;
if (!RuleValidation.TypesAreAssignable(expressionType, lhsType, this.assignStatement.Right, out error))
{
if (error == null)
{
error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.AssignNotAllowed, new object[] { RuleDecompiler.DecompileType(expressionType), RuleDecompiler.DecompileType(lhsType) }), 0x545);
}
error.UserData["ErrorObject"] = this.assignStatement;
validation.Errors.Add(error);
return flag;
}
}
return true;
}
示例4: ValidateInvokeAttribute
private bool ValidateInvokeAttribute(RuleValidation validation, MemberInfo member, Type contextType, Stack<MemberInfo> methodStack)
{
ValidationError error;
if (string.IsNullOrEmpty(this.methodInvoked))
{
error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.AttributeMethodNotFound, new object[] { member.Name, base.GetType().Name, Messages.NullValue }), 0x56b, true);
error.UserData["ErrorObject"] = this;
validation.AddError(error);
return false;
}
bool flag = true;
MemberInfo[] infoArray = contextType.GetMember(this.methodInvoked, MemberTypes.Property | MemberTypes.Method, BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
if ((infoArray == null) || (infoArray.Length == 0))
{
error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.AttributeMethodNotFound, new object[] { member.Name, base.GetType().Name, this.methodInvoked }), 0x56b, true);
error.UserData["ErrorObject"] = this;
validation.AddError(error);
return false;
}
for (int i = 0; i < infoArray.Length; i++)
{
MemberInfo item = infoArray[i];
if (!methodStack.Contains(item))
{
methodStack.Push(item);
object[] customAttributes = item.GetCustomAttributes(typeof(RuleAttribute), true);
if ((customAttributes != null) && (customAttributes.Length != 0))
{
foreach (RuleAttribute attribute in customAttributes)
{
RuleReadWriteAttribute attribute2 = attribute as RuleReadWriteAttribute;
if (attribute2 != null)
{
if (attribute2.Target == RuleAttributeTarget.Parameter)
{
error = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.InvokeAttrRefersToParameterAttribute, new object[] { item.Name }), 0x1a5, true);
error.UserData["ErrorObject"] = this;
validation.AddError(error);
flag = false;
}
else
{
attribute2.Validate(validation, item, contextType, null);
}
}
else
{
((RuleInvokeAttribute) attribute).ValidateInvokeAttribute(validation, item, contextType, methodStack);
}
}
}
methodStack.Pop();
}
}
return flag;
}
示例5: Validate
internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
{
if (isWritten)
{
ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodeThisReferenceExpression).ToString() }), 0x17a);
item.UserData["ErrorObject"] = expression;
validation.Errors.Add(item);
return null;
}
return new RuleExpressionInfo(validation.ThisType);
}
示例6: Validate
internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
{
if (isWritten)
{
ValidationError item = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodePrimitiveExpression).ToString() }), 0x17a);
item.UserData["ErrorObject"] = expression;
validation.Errors.Add(item);
return null;
}
CodePrimitiveExpression expression2 = (CodePrimitiveExpression) expression;
return new RuleExpressionInfo((expression2.Value != null) ? expression2.Value.GetType() : typeof(NullLiteral));
}
示例7: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
ValidationErrorCollection errors = base.Validate(manager, obj);
MethodBind bind = obj as MethodBind;
if (bind == null)
{
throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(MethodBind).FullName }), "obj");
}
PropertyValidationContext validationContext = manager.Context[typeof(PropertyValidationContext)] as PropertyValidationContext;
if (validationContext == null)
{
throw new InvalidOperationException(SR.GetString("Error_ContextStackItemMissing", new object[] { typeof(BindValidationContext).Name }));
}
Activity activity = manager.Context[typeof(Activity)] as Activity;
if (activity == null)
{
throw new InvalidOperationException(SR.GetString("Error_ContextStackItemMissing", new object[] { typeof(Activity).Name }));
}
ValidationError item = null;
if (string.IsNullOrEmpty(bind.Name))
{
item = new ValidationError(SR.GetString("Error_PropertyNotSet", new object[] { "Name" }), 0x116) {
PropertyName = base.GetFullPropertyName(manager) + ".Name"
};
}
else
{
BindValidationContext context2 = manager.Context[typeof(BindValidationContext)] as BindValidationContext;
if (context2 == null)
{
Type baseType = BindHelpers.GetBaseType(manager, validationContext);
if (baseType != null)
{
AccessTypes accessType = BindHelpers.GetAccessType(manager, validationContext);
context2 = new BindValidationContext(baseType, accessType);
}
}
if (context2 != null)
{
Type targetType = context2.TargetType;
if (item == null)
{
errors.AddRange(this.ValidateMethod(manager, activity, bind, new BindValidationContext(targetType, context2.Access)));
}
}
}
if (item != null)
{
errors.Add(item);
}
return errors;
}
示例8: Validate
internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
{
if (isWritten)
{
string message = string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, typeof(CodeThisReferenceExpression).ToString());
ValidationError error = new ValidationError(message, ErrorNumbers.Error_InvalidAssignTarget);
error.UserData[RuleUserDataKeys.ErrorObject] = expression;
validation.Errors.Add(error);
return null;
}
return new RuleExpressionInfo(validation.ThisType);
}
示例9: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
FieldBind bind = obj as FieldBind;
if (bind == null)
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(FieldBind).FullName), "obj");
PropertyValidationContext validationContext = manager.Context[typeof(PropertyValidationContext)] as PropertyValidationContext;
if (validationContext == null)
throw new InvalidOperationException(SR.GetString(SR.Error_ContextStackItemMissing, typeof(BindValidationContext).Name));
Activity activity = manager.Context[typeof(Activity)] as Activity;
if (activity == null)
throw new InvalidOperationException(SR.GetString(SR.Error_ContextStackItemMissing, typeof(Activity).Name));
ValidationError error = null;
if (string.IsNullOrEmpty(bind.Name))
{
error = new ValidationError(SR.GetString(SR.Error_PropertyNotSet, "Name"), ErrorNumbers.Error_PropertyNotSet);
error.PropertyName = GetFullPropertyName(manager) + ".Name";
}
else
{
BindValidationContext validationBindContext = manager.Context[typeof(BindValidationContext)] as BindValidationContext;
if (validationBindContext == null)
{
Type baseType = BindHelpers.GetBaseType(manager, validationContext);
if (baseType != null)
{
AccessTypes accessType = BindHelpers.GetAccessType(manager, validationContext);
validationBindContext = new BindValidationContext(baseType, accessType);
}
//else
//{
// error = new ValidationError(SR.GetString(SR.Error_BindBaseTypeNotSpecified, validationContext.PropertyName), ErrorNumbers.Error_BindBaseTypeNotSpecified);
// error.PropertyName = GetFullPropertyName(manager) + ".Name";
//}
}
if (validationBindContext != null)
{
Type targetType = validationBindContext.TargetType;
if (error == null)
validationErrors.AddRange(this.ValidateField(manager, activity, bind, new BindValidationContext(targetType, validationBindContext.Access)));
}
}
if (error != null)
validationErrors.Add(error);
return validationErrors;
}
示例10: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
if (manager == null)
throw new ArgumentNullException("manager");
Activity activity = obj as Activity;
if (activity == null)
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj");
if (manager.Context == null)
throw new ArgumentException("manager", SR.GetString(SR.Error_MissingContextProperty));
manager.Context.Push(activity);
ValidationErrorCollection errors = new ValidationErrorCollection();
errors.AddRange(base.Validate(manager, obj));
if (activity.Parent == null)
{
errors.AddRange(ValidationHelpers.ValidateUniqueIdentifiers(activity));
if (activity.Enabled == false)
{
ValidationError error = new ValidationError(SR.GetString(SR.Error_RootIsNotEnabled), ErrorNumbers.Error_RootIsNotEnabled);
error.PropertyName = "Enabled";
errors.Add(error);
}
}
// validate ID property, only if it is not root activity
Activity rootActivity = Helpers.GetRootActivity(activity);
if (activity != rootActivity)
{
ValidationError identifierError = ValidationHelpers.ValidateNameProperty("Name", manager, activity.Name);
if (identifierError != null)
errors.Add(identifierError);
}
try
{
errors.AddRange(ValidateProperties(manager, obj));
}
finally
{
System.Diagnostics.Debug.Assert(manager.Context.Current == activity, "Unwinding contextStack: the item that is about to be popped is not the one we pushed.");
manager.Context.Pop();
}
return errors;
}
示例11: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
ValidationErrorCollection errors = base.Validate(manager, obj);
MsmqSendActivity act = (MsmqSendActivity)obj;
if ( !act.IsBindingSet(MsmqSendActivity.QueueProperty) )
{
if ( act.GetValue(MsmqSendActivity.QueueProperty) == null )
{
errors.Add(ValidationError.GetNotSetValidationError("Queue"));
}
}
if ( !act.IsBindingSet(MsmqSendActivity.MessageToSendProperty) )
{
if ( act.GetValue(MsmqSendActivity.MessageToSendProperty) == null )
{
errors.Add(ValidationError.GetNotSetValidationError("MessageToSend"));
}
}
// if the queue is transactional, one of our parents
// must be a TransactionScope
if ( act.IsTransactionalQueue )
{
bool isInTransaction = false;
Activity parent = act.Parent;
while ( parent != null )
{
if ( parent is TransactionScopeActivity )
{
isInTransaction = true;
break;
}
parent = parent.Parent;
}
if ( !isInTransaction )
{
ValidationError error =
new ValidationError(Resources.Send_MustBeInTransaction, 9001);
errors.Add(error);
}
}
return errors;
}
示例12: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
if (manager == null)
{
throw new ArgumentNullException("manager");
}
Activity context = obj as Activity;
if (context == null)
{
throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(Activity).FullName }), "obj");
}
if (manager.Context == null)
{
throw new ArgumentException("manager", SR.GetString("Error_MissingContextProperty"));
}
manager.Context.Push(context);
ValidationErrorCollection errors = new ValidationErrorCollection();
errors.AddRange(base.Validate(manager, obj));
if (context.Parent == null)
{
errors.AddRange(ValidationHelpers.ValidateUniqueIdentifiers(context));
if (!context.Enabled)
{
ValidationError item = new ValidationError(SR.GetString("Error_RootIsNotEnabled"), 0x628) {
PropertyName = "Enabled"
};
errors.Add(item);
}
}
Activity rootActivity = Helpers.GetRootActivity(context);
if (context != rootActivity)
{
ValidationError error2 = ValidationHelpers.ValidateNameProperty("Name", manager, context.Name);
if (error2 != null)
{
errors.Add(error2);
}
}
try
{
errors.AddRange(this.ValidateProperties(manager, obj));
}
finally
{
manager.Context.Pop();
}
return errors;
}
示例13: Validate
internal override RuleExpressionInfo Validate(CodeExpression expression, RuleValidation validation, bool isWritten)
{
CodeTypeReferenceExpression expression2 = (CodeTypeReferenceExpression) expression;
if (expression2.Type == null)
{
ValidationError item = new ValidationError(Messages.NullTypeType, 0x53d);
item.UserData["ErrorObject"] = expression2;
validation.Errors.Add(item);
return null;
}
if (isWritten)
{
ValidationError error2 = new ValidationError(string.Format(CultureInfo.CurrentCulture, Messages.CannotWriteToExpression, new object[] { typeof(CodeTypeReferenceExpression).ToString() }), 0x17a);
error2.UserData["ErrorObject"] = expression2;
validation.Errors.Add(error2);
return null;
}
return new RuleExpressionInfo(validation.ResolveType(expression2.Type));
}
示例14: Validate
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
{
ValidationErrorCollection errors = base.Validate(manager, obj);
FaultHandlerActivity activity = obj as FaultHandlerActivity;
if (activity == null)
{
throw new ArgumentException(SR.GetString("Error_UnexpectedArgumentType", new object[] { typeof(FaultHandlerActivity).FullName }), "obj");
}
if (!(activity.Parent is FaultHandlersActivity))
{
errors.Add(new ValidationError(SR.GetString("Error_FaultHandlerActivityParentNotFaultHandlersActivity"), 0x519));
}
if (!(manager.GetService(typeof(ITypeProvider)) is ITypeProvider))
{
throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
}
ValidationError item = null;
if (activity.FaultType == null)
{
item = new ValidationError(SR.GetString("Error_TypePropertyInvalid", new object[] { "FaultType" }), 0x116) {
PropertyName = "FaultType"
};
errors.Add(item);
}
else if (!TypeProvider.IsAssignable(typeof(Exception), activity.FaultType))
{
item = new ValidationError(SR.GetString("Error_TypeTypeMismatch", new object[] { "FaultType", typeof(Exception).FullName }), 0x51a) {
PropertyName = "FaultType"
};
errors.Add(item);
}
if (activity.EnabledActivities.Count == 0)
{
errors.Add(new ValidationError(SR.GetString("Warning_EmptyBehaviourActivity", new object[] { typeof(FaultHandlerActivity).FullName, activity.QualifiedName }), 0x1a3, true));
}
if (activity.AlternateFlowActivities.Count > 0)
{
errors.Add(new ValidationError(SR.GetString("Error_ModelingConstructsCanNotContainModelingConstructs"), 0x61f));
}
return errors;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:FaultHandlerActivityValidator.cs
示例15: ValidateIdentifier
internal static ValidationError ValidateIdentifier(string propName, IServiceProvider context, string identifier)
{
if (context == null)
throw new ArgumentNullException("context");
ValidationError error = null;
if (identifier == null || identifier.Length == 0)
error = new ValidationError(SR.GetString(SR.Error_PropertyNotSet, propName), ErrorNumbers.Error_PropertyNotSet);
else
{
try
{
ValidationHelpers.ValidateIdentifier(context, identifier);
}
catch (Exception e)
{
error = new ValidationError(SR.GetString(SR.Error_InvalidIdentifier, propName, e.Message), ErrorNumbers.Error_InvalidIdentifier);
}
}
if (error != null)
error.PropertyName = propName;
return error;
}