You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,63 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
#region Class ActivityValidator
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class ActivityValidator : DependencyObjectValidator
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
|
||||
#region BindValidationContext
|
||||
|
||||
[Flags]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public enum AccessTypes
|
||||
{
|
||||
Read = 0x01,
|
||||
Write = 0x02,
|
||||
ReadWrite = Read | Write
|
||||
}
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class BindValidationContext
|
||||
{
|
||||
private Type targetType = null;
|
||||
private AccessTypes access = AccessTypes.Read;
|
||||
|
||||
public BindValidationContext(Type targetType)
|
||||
: this(targetType, AccessTypes.Read)
|
||||
{
|
||||
}
|
||||
|
||||
public BindValidationContext(Type targetType, AccessTypes access)
|
||||
{
|
||||
if (targetType == null)
|
||||
throw new ArgumentNullException("targetType");
|
||||
this.targetType = targetType;
|
||||
this.access = access;
|
||||
}
|
||||
|
||||
public Type TargetType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.targetType;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessTypes Access
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.access;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
#region Class CompositeActivityValidator
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class CompositeActivityValidator : ActivityValidator
|
||||
{
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
CompositeActivity compositeActivity = obj as CompositeActivity;
|
||||
if (compositeActivity == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(CompositeActivity).FullName), "obj");
|
||||
if (Helpers.IsActivityLocked(compositeActivity))
|
||||
return new ValidationErrorCollection();
|
||||
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
|
||||
// check if more than one cancellation handler or compensation or fault handlers are specified
|
||||
int cancelHandlerCount = 0;
|
||||
int exceptionHandlersCount = 0;
|
||||
int compensationHandlerCount = 0;
|
||||
foreach (Activity activity in ((ISupportAlternateFlow)compositeActivity).AlternateFlowActivities)
|
||||
{
|
||||
cancelHandlerCount += (activity is CancellationHandlerActivity) ? 1 : 0;
|
||||
exceptionHandlersCount += (activity is FaultHandlersActivity) ? 1 : 0;
|
||||
compensationHandlerCount += (activity is CompensationHandlerActivity) ? 1 : 0;
|
||||
}
|
||||
// check cancellation handlers
|
||||
if (cancelHandlerCount > 1)
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_MoreThanOneCancelHandler, compositeActivity.GetType().Name), ErrorNumbers.Error_ScopeMoreThanOneEventHandlersDecl));
|
||||
|
||||
// check exception handlers
|
||||
if (exceptionHandlersCount > 1)
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_MoreThanOneFaultHandlersActivityDecl, compositeActivity.GetType().Name), ErrorNumbers.Error_ScopeMoreThanOneFaultHandlersActivityDecl));
|
||||
|
||||
// check compensation handlers
|
||||
if (compensationHandlerCount > 1)
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_MoreThanOneCompensationDecl, compositeActivity.GetType().Name), ErrorNumbers.Error_ScopeMoreThanOneCompensationDecl));
|
||||
|
||||
|
||||
if (manager.ValidateChildActivities)
|
||||
{
|
||||
foreach (Activity childActivity in Helpers.GetAllEnabledActivities(compositeActivity))
|
||||
validationErrors.AddRange(ValidationHelpers.ValidateActivity(manager, childActivity));
|
||||
}
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
|
||||
{
|
||||
if (activity == null)
|
||||
throw new ArgumentNullException("activity");
|
||||
if (action == null)
|
||||
throw new ArgumentNullException("action");
|
||||
|
||||
if (activity.ExecutionStatus != ActivityExecutionStatus.Initialized &&
|
||||
activity.ExecutionStatus != ActivityExecutionStatus.Executing &&
|
||||
activity.ExecutionStatus != ActivityExecutionStatus.Closed)
|
||||
{
|
||||
return new ValidationError(SR.GetString(SR.Error_DynamicActivity, activity.QualifiedName, Enum.GetName(typeof(ActivityExecutionStatus), activity.ExecutionStatus)), ErrorNumbers.Error_DynamicActivity);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class ConditionValidator : DependencyObjectValidator
|
||||
{
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
|
||||
ActivityCondition conditionDeclaration = obj as ActivityCondition;
|
||||
if (conditionDeclaration == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(ActivityCondition).FullName), "obj");
|
||||
|
||||
validationErrors.AddRange(ValidateProperties(manager, obj));
|
||||
|
||||
return validationErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class DependencyObjectValidator : Validator
|
||||
{
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj");
|
||||
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
DependencyObject dependencyObject = obj as DependencyObject;
|
||||
if (dependencyObject == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(DependencyObject).FullName), "obj");
|
||||
|
||||
ArrayList allProperties = new ArrayList();
|
||||
|
||||
// Validate all the settable dependency properties
|
||||
// attached property can not be found through the call to DependencyProperty.FromType()
|
||||
foreach (DependencyProperty prop in DependencyProperty.FromType(dependencyObject.GetType()))
|
||||
{
|
||||
// This property is attached to some other object. We should not validate it here
|
||||
// because the context is wrong.
|
||||
if (!prop.IsAttached)
|
||||
allProperties.Add(prop);
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
foreach (DependencyProperty prop in dependencyObject.MetaDependencyProperties)
|
||||
{
|
||||
if (prop.IsAttached)
|
||||
{
|
||||
if (obj.GetType().GetProperty(prop.Name, BindingFlags.Public | BindingFlags.Instance) == null)
|
||||
allProperties.Add(prop);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DependencyProperty prop in allProperties)
|
||||
{
|
||||
object[] validationVisibilityAtrributes = prop.DefaultMetadata.GetAttributes(typeof(ValidationOptionAttribute));
|
||||
ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
|
||||
if (validationVisibility != ValidationOption.None)
|
||||
validationErrors.AddRange(ValidateDependencyProperty(dependencyObject, prop, manager));
|
||||
}
|
||||
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
private ValidationErrorCollection ValidateDependencyProperty(DependencyObject dependencyObject, DependencyProperty dependencyProperty, ValidationManager manager)
|
||||
{
|
||||
ValidationErrorCollection errors = new ValidationErrorCollection();
|
||||
|
||||
Attribute[] validationVisibilityAtrributes = dependencyProperty.DefaultMetadata.GetAttributes(typeof(ValidationOptionAttribute));
|
||||
ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
|
||||
|
||||
Activity activity = manager.Context[typeof(Activity)] as Activity;
|
||||
if (activity == null)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_ContextStackItemMissing, typeof(Activity).FullName));
|
||||
|
||||
PropertyValidationContext propertyValidationContext = new PropertyValidationContext(activity, dependencyProperty);
|
||||
manager.Context.Push(propertyValidationContext);
|
||||
|
||||
try
|
||||
{
|
||||
if (dependencyProperty.DefaultMetadata.DefaultValue != null)
|
||||
{
|
||||
if (!dependencyProperty.PropertyType.IsValueType &&
|
||||
dependencyProperty.PropertyType != typeof(string))
|
||||
{
|
||||
errors.Add(new ValidationError(SR.GetString(SR.Error_PropertyDefaultIsReference, dependencyProperty.Name), ErrorNumbers.Error_PropertyDefaultIsReference));
|
||||
}
|
||||
else if (!dependencyProperty.PropertyType.IsAssignableFrom(dependencyProperty.DefaultMetadata.DefaultValue.GetType()))
|
||||
{
|
||||
errors.Add(new ValidationError(SR.GetString(SR.Error_PropertyDefaultTypeMismatch, dependencyProperty.Name, dependencyProperty.PropertyType.FullName, dependencyProperty.DefaultMetadata.DefaultValue.GetType().FullName), ErrorNumbers.Error_PropertyDefaultTypeMismatch));
|
||||
}
|
||||
}
|
||||
|
||||
// If an event is of type Bind, GetBinding will return the Bind object.
|
||||
object propValue = null;
|
||||
if (dependencyObject.IsBindingSet(dependencyProperty))
|
||||
propValue = dependencyObject.GetBinding(dependencyProperty);
|
||||
else if (!dependencyProperty.IsEvent)
|
||||
propValue = dependencyObject.GetValue(dependencyProperty);
|
||||
|
||||
if (propValue == null || propValue == dependencyProperty.DefaultMetadata.DefaultValue)
|
||||
{
|
||||
if (dependencyProperty.IsEvent)
|
||||
{
|
||||
// Is this added through "+=" in InitializeComponent? If so, the value should be in the instance properties hashtable
|
||||
// If none of these, its value is stored in UserData at design time.
|
||||
propValue = dependencyObject.GetHandler(dependencyProperty);
|
||||
if (propValue == null)
|
||||
propValue = WorkflowMarkupSerializationHelpers.GetEventHandlerName(dependencyObject, dependencyProperty.Name);
|
||||
|
||||
if (propValue is string && !string.IsNullOrEmpty((string)propValue))
|
||||
errors.AddRange(ValidateEvent(activity, dependencyProperty, propValue, manager));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Maybe this is an instance property.
|
||||
propValue = dependencyObject.GetValue(dependencyProperty);
|
||||
}
|
||||
}
|
||||
|
||||
// Be careful before changing this. This is the (P || C) validation validation
|
||||
// i.e. validate properties being set only if Parent is set or
|
||||
// a child exists.
|
||||
bool checkNotSet = (activity.Parent != null) || ((activity is CompositeActivity) && (((CompositeActivity)activity).EnabledActivities.Count != 0));
|
||||
|
||||
if (validationVisibility == ValidationOption.Required &&
|
||||
(propValue == null || (propValue is string && string.IsNullOrEmpty((string)propValue))) &&
|
||||
(dependencyProperty.DefaultMetadata.IsMetaProperty) &&
|
||||
checkNotSet)
|
||||
{
|
||||
errors.Add(ValidationError.GetNotSetValidationError(GetFullPropertyName(manager)));
|
||||
}
|
||||
else if (propValue != null)
|
||||
{
|
||||
if (propValue is IList)
|
||||
{
|
||||
PropertyValidationContext childContext = new PropertyValidationContext(propValue, null, String.Empty);
|
||||
manager.Context.Push(childContext);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (object child in (IList)propValue)
|
||||
errors.AddRange(ValidationHelpers.ValidateObject(manager, child));
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(manager.Context.Current == childContext, "Unwinding contextStack: the item that is about to be popped is not the one we pushed.");
|
||||
manager.Context.Pop();
|
||||
}
|
||||
}
|
||||
else if (dependencyProperty.ValidatorType != null)
|
||||
{
|
||||
Validator validator = null;
|
||||
try
|
||||
{
|
||||
validator = Activator.CreateInstance(dependencyProperty.ValidatorType) as Validator;
|
||||
if (validator == null)
|
||||
errors.Add(new ValidationError(SR.GetString(SR.Error_CreateValidator, dependencyProperty.ValidatorType.FullName), ErrorNumbers.Error_CreateValidator));
|
||||
else
|
||||
errors.AddRange(validator.Validate(manager, propValue));
|
||||
}
|
||||
catch
|
||||
{
|
||||
errors.Add(new ValidationError(SR.GetString(SR.Error_CreateValidator, dependencyProperty.ValidatorType.FullName), ErrorNumbers.Error_CreateValidator));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errors.AddRange(ValidationHelpers.ValidateObject(manager, propValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(manager.Context.Current == propertyValidationContext, "Unwinding contextStack: the item that is about to be popped is not the one we pushed.");
|
||||
manager.Context.Pop();
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
|
||||
{
|
||||
ValidationErrorCollection validationErrors = new ValidationErrorCollection();
|
||||
|
||||
if (propValue is string && !string.IsNullOrEmpty((string)propValue))
|
||||
{
|
||||
bool handlerExists = false;
|
||||
Type objType = null;
|
||||
Activity rootActivity = Helpers.GetRootActivity(activity);
|
||||
Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
|
||||
string typeName = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
|
||||
if (rootActivity == enclosingActivity && !string.IsNullOrEmpty(typeName))
|
||||
{
|
||||
ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
|
||||
if (typeProvider == null)
|
||||
throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));
|
||||
|
||||
objType = typeProvider.GetType(typeName);
|
||||
}
|
||||
else
|
||||
objType = enclosingActivity.GetType();
|
||||
|
||||
if (objType != null)
|
||||
{
|
||||
MethodInfo invokeMethod = dependencyProperty.PropertyType.GetMethod("Invoke");
|
||||
if (invokeMethod != null)
|
||||
{
|
||||
// resolve the method
|
||||
List<Type> paramTypes = new List<Type>();
|
||||
foreach (ParameterInfo paramInfo in invokeMethod.GetParameters())
|
||||
paramTypes.Add(paramInfo.ParameterType);
|
||||
|
||||
MethodInfo methodInfo = Helpers.GetMethodExactMatch(objType, propValue as string, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy, null, paramTypes.ToArray(), null);
|
||||
if (methodInfo != null && TypeProvider.IsAssignable(invokeMethod.ReturnType, methodInfo.ReturnType))
|
||||
handlerExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handlerExists)
|
||||
{
|
||||
ValidationError error = new ValidationError(SR.GetString(SR.Error_CantResolveEventHandler, dependencyProperty.Name, propValue as string), ErrorNumbers.Error_CantResolveEventHandler);
|
||||
error.PropertyName = GetFullPropertyName(manager);
|
||||
validationErrors.Add(error);
|
||||
}
|
||||
}
|
||||
|
||||
return validationErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
#region PropertyValidationContext
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class PropertyValidationContext
|
||||
{
|
||||
private string propertyName = string.Empty;
|
||||
private object propertyOwner = null;
|
||||
private object propertyInfo = null;
|
||||
|
||||
public PropertyValidationContext(object propertyOwner, PropertyInfo propertyInfo, string propertyName)
|
||||
{
|
||||
if (propertyName == null)
|
||||
throw new ArgumentNullException("propertyName");
|
||||
if (propertyOwner == null)
|
||||
throw new ArgumentNullException("propertyOwner");
|
||||
|
||||
this.propertyOwner = propertyOwner;
|
||||
this.propertyName = propertyName;
|
||||
this.propertyInfo = propertyInfo;
|
||||
}
|
||||
|
||||
public PropertyValidationContext(object propertyOwner, DependencyProperty dependencyProperty)
|
||||
{
|
||||
if (propertyOwner == null)
|
||||
throw new ArgumentNullException("propertyOwner");
|
||||
|
||||
this.propertyOwner = propertyOwner;
|
||||
this.propertyInfo = dependencyProperty;
|
||||
}
|
||||
|
||||
public string PropertyName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.propertyInfo is DependencyProperty)
|
||||
return ((DependencyProperty)this.propertyInfo).Name;
|
||||
else
|
||||
return this.propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
public object PropertyOwner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.propertyOwner;
|
||||
}
|
||||
}
|
||||
|
||||
public object Property
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.propertyInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#region Class SynchronizationValidator
|
||||
internal sealed class SynchronizationValidator : Validator
|
||||
{
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
|
||||
Activity activity = obj as Activity;
|
||||
if (activity == null)
|
||||
return validationErrors;
|
||||
|
||||
ICollection<string> synchronizationHandles = activity.GetValue(Activity.SynchronizationHandlesProperty) as ICollection<string>;
|
||||
if (synchronizationHandles != null)
|
||||
{
|
||||
foreach (string handle in synchronizationHandles)
|
||||
{
|
||||
ValidationError error = ValidationHelpers.ValidateIdentifier("SynchronizationHandles", manager, handle);
|
||||
if (error != null)
|
||||
validationErrors.Add(error);
|
||||
}
|
||||
}
|
||||
return validationErrors;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
internal sealed class TransactionContextValidator : Validator
|
||||
{
|
||||
#region Validate Method
|
||||
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
|
||||
Activity activity = obj as Activity;
|
||||
if (activity == null)
|
||||
throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj");
|
||||
|
||||
WorkflowTransactionOptions atomicTransaction = TransactedContextFilter.GetTransactionOptions(activity);
|
||||
if (atomicTransaction != null)
|
||||
{
|
||||
// Atomic scopes can't have exception handlers.
|
||||
CompositeActivity exceptionHandlers = FaultAndCancellationHandlingFilter.GetFaultHandlers(activity);
|
||||
if (exceptionHandlers != null)
|
||||
{
|
||||
ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithFaultHandlersActivityDecl, activity.Name), ErrorNumbers.Error_AtomicScopeWithFaultHandlersActivityDecl);
|
||||
validationErrors.Add(error);
|
||||
}
|
||||
|
||||
// Atomic scopes can't have cancel handlers.
|
||||
Activity cancellationHandler = FaultAndCancellationHandlingFilter.GetCancellationHandler(activity);
|
||||
if (cancellationHandler != null)
|
||||
{
|
||||
ValidationError error = new ValidationError(SR.GetString(SR.Error_AtomicScopeWithCancellationHandlerActivity, activity.Name), ErrorNumbers.Error_AtomicScopeWithCancellationHandlerActivity);
|
||||
validationErrors.Add(error);
|
||||
}
|
||||
|
||||
// check that this transaction scope is not nested inside another transaction scope
|
||||
Activity parent = activity.Parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent.SupportsTransaction)
|
||||
{
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT));
|
||||
break;
|
||||
}
|
||||
parent = parent.Parent;
|
||||
}
|
||||
|
||||
// check that an activity with PersistOnClose/SupportsTransaction/ICompensatableActivity attribute is not nested inside the transaction scope
|
||||
Queue<Activity> nestedEnabledActivities = new Queue<Activity>(Helpers.GetAllEnabledActivities((CompositeActivity)activity));
|
||||
while (nestedEnabledActivities.Count > 0)
|
||||
{
|
||||
Activity nestedEnabledActivity = nestedEnabledActivities.Dequeue();
|
||||
if (nestedEnabledActivity.PersistOnClose)
|
||||
{
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_LRTScopeNestedInNonLRT), ErrorNumbers.Error_LRTScopeNestedInNonLRT));
|
||||
break;
|
||||
}
|
||||
if (nestedEnabledActivity is ICompensatableActivity)
|
||||
{
|
||||
validationErrors.Add(new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, nestedEnabledActivity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity));
|
||||
break;
|
||||
}
|
||||
|
||||
if (nestedEnabledActivity is CompositeActivity)
|
||||
{
|
||||
foreach (Activity nestedEnabledActivity2 in Helpers.GetAllEnabledActivities((CompositeActivity)nestedEnabledActivity))
|
||||
nestedEnabledActivities.Enqueue(nestedEnabledActivity2);
|
||||
}
|
||||
}
|
||||
|
||||
// check timeout property
|
||||
if (atomicTransaction.TimeoutDuration.Ticks < 0)
|
||||
{
|
||||
ValidationError timeoutError = new ValidationError(SR.GetString(SR.Error_NegativeValue, new object[] { atomicTransaction.TimeoutDuration.ToString(), "TimeoutDuration" }), ErrorNumbers.Error_NegativeValue);
|
||||
timeoutError.PropertyName = "TimeoutDuration";
|
||||
validationErrors.Add(timeoutError);
|
||||
}
|
||||
}
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
public override ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
|
||||
{
|
||||
if (activity == null)
|
||||
throw new ArgumentNullException("activity");
|
||||
|
||||
if (action == null)
|
||||
throw new ArgumentNullException("action");
|
||||
|
||||
AddedActivityAction addedAction = action as AddedActivityAction;
|
||||
|
||||
if (addedAction != null)
|
||||
{
|
||||
//Check existence of nested PersistOnClose/ICompensatable/SupportsTransaction nested anywhere
|
||||
//in the added activity branch
|
||||
System.Collections.Generic.Queue<Activity> childrenQueue = new System.Collections.Generic.Queue<Activity>();
|
||||
childrenQueue.Enqueue(addedAction.AddedActivity);
|
||||
|
||||
while (childrenQueue.Count != 0)
|
||||
{
|
||||
Activity childActivity = childrenQueue.Dequeue();
|
||||
|
||||
if (childActivity.SupportsTransaction)
|
||||
return new ValidationError(SR.GetString(SR.Error_AtomicScopeNestedInNonLRT), ErrorNumbers.Error_AtomicScopeNestedInNonLRT);
|
||||
|
||||
if (childActivity.PersistOnClose)
|
||||
return new ValidationError(SR.GetString(SR.Error_NestedPersistOnClose, activity.QualifiedName), ErrorNumbers.Error_NestedPersistOnClose);
|
||||
|
||||
if (childActivity is ICompensatableActivity)
|
||||
return new ValidationError(SR.GetString(SR.Error_NestedCompensatableActivity, activity.QualifiedName), ErrorNumbers.Error_NestedCompensatableActivity);
|
||||
|
||||
CompositeActivity compositeActivity = childActivity as CompositeActivity;
|
||||
|
||||
if (compositeActivity != null)
|
||||
{
|
||||
foreach (Activity grandChild in compositeActivity.EnabledActivities)
|
||||
{
|
||||
childrenQueue.Enqueue(grandChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.ValidateActivityChange(activity, action);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
#region Class ValidationError
|
||||
|
||||
[Serializable()]
|
||||
public sealed class ValidationError
|
||||
{
|
||||
private string errorText = string.Empty;
|
||||
private int errorNumber = 0;
|
||||
private Hashtable userData = null;
|
||||
private bool isWarning = false;
|
||||
string propertyName = null;
|
||||
|
||||
public ValidationError(string errorText, int errorNumber)
|
||||
: this(errorText, errorNumber, false, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ValidationError(string errorText, int errorNumber, bool isWarning)
|
||||
: this(errorText, errorNumber, isWarning, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ValidationError(string errorText, int errorNumber, bool isWarning, string propertyName)
|
||||
{
|
||||
this.errorText = errorText;
|
||||
this.errorNumber = errorNumber;
|
||||
this.isWarning = isWarning;
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
public string PropertyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.propertyName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.propertyName = value;
|
||||
}
|
||||
}
|
||||
public string ErrorText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errorText;
|
||||
}
|
||||
}
|
||||
public bool IsWarning
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isWarning;
|
||||
}
|
||||
}
|
||||
public int ErrorNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errorNumber;
|
||||
}
|
||||
}
|
||||
public IDictionary UserData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.userData == null)
|
||||
this.userData = new Hashtable();
|
||||
return this.userData;
|
||||
}
|
||||
}
|
||||
|
||||
public static ValidationError GetNotSetValidationError(string propertyName)
|
||||
{
|
||||
ValidationError error = new ValidationError(SR.GetString(SR.Error_PropertyNotSet, propertyName), ErrorNumbers.Error_PropertyNotSet);
|
||||
error.PropertyName = propertyName;
|
||||
return error;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format(CultureInfo.InvariantCulture, "{0} {1}: {2}", this.isWarning ? "warning" : "error", this.errorNumber, this.errorText);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#region ValidationErrorCollection
|
||||
|
||||
[Serializable()]
|
||||
public sealed class ValidationErrorCollection : Collection<ValidationError>
|
||||
{
|
||||
public ValidationErrorCollection()
|
||||
{
|
||||
}
|
||||
|
||||
public ValidationErrorCollection(ValidationErrorCollection value)
|
||||
{
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
public ValidationErrorCollection(IEnumerable<ValidationError> value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, ValidationError item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
|
||||
base.InsertItem(index, item);
|
||||
}
|
||||
|
||||
protected override void SetItem(int index, ValidationError item)
|
||||
{
|
||||
if (item == null)
|
||||
throw new ArgumentNullException("item");
|
||||
|
||||
base.SetItem(index, item);
|
||||
}
|
||||
|
||||
public void AddRange(IEnumerable<ValidationError> value)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
foreach (ValidationError error in value)
|
||||
this.Add(error);
|
||||
}
|
||||
|
||||
public bool HasErrors
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
foreach (ValidationError e in this)
|
||||
{
|
||||
if (e != null && !e.IsWarning)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasWarnings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Count > 0)
|
||||
{
|
||||
foreach (ValidationError e in this)
|
||||
{
|
||||
if (e != null && e.IsWarning)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationError[] ToArray()
|
||||
{
|
||||
ValidationError[] errorsArray = new ValidationError[this.Count];
|
||||
this.CopyTo(errorsArray, 0);
|
||||
return errorsArray;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
|
||||
#endregion
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ValidationManager : IServiceProvider
|
||||
{
|
||||
#region Data members
|
||||
|
||||
private Hashtable hashOfValidators = new Hashtable();
|
||||
private IServiceProvider serviceProvider = null;
|
||||
private ContextStack context = null;
|
||||
private bool validateChildActivities = true;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ValidationManager(IServiceProvider serviceProvider)
|
||||
:
|
||||
this(serviceProvider, true)
|
||||
{
|
||||
}
|
||||
|
||||
public ValidationManager(IServiceProvider serviceProvider, bool validateChildActivities)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
this.validateChildActivities = validateChildActivities;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public members
|
||||
|
||||
public ContextStack Context
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context == null)
|
||||
this.context = new ContextStack();
|
||||
|
||||
return this.context;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateChildActivities
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.validateChildActivities;
|
||||
}
|
||||
}
|
||||
|
||||
public Validator[] GetValidators(Type type)
|
||||
{
|
||||
if (this.hashOfValidators.Contains(type))
|
||||
return ((List<Validator>)this.hashOfValidators[type]).ToArray();
|
||||
|
||||
List<Validator> validators = new List<Validator>();
|
||||
foreach (Validator validator in ComponentDispenser.CreateComponents(type, typeof(ActivityValidatorAttribute)))
|
||||
validators.Add(validator);
|
||||
|
||||
this.hashOfValidators[type] = validators;
|
||||
return validators.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IServiceProvider Members
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return this.serviceProvider.GetService(serviceType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public enum ValidationOption
|
||||
{
|
||||
None,
|
||||
Optional,
|
||||
Required
|
||||
}
|
||||
|
||||
[AttributeUsageAttribute(AttributeTargets.Property | AttributeTargets.Event, AllowMultiple = false, Inherited = true)]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ValidationOptionAttribute : Attribute
|
||||
{
|
||||
private ValidationOption validationOption;
|
||||
|
||||
public ValidationOptionAttribute(ValidationOption validationOption)
|
||||
{
|
||||
this.validationOption = validationOption;
|
||||
}
|
||||
|
||||
public ValidationOption ValidationOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.validationOption;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#region Class Validator
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class Validator
|
||||
{
|
||||
public virtual ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj");
|
||||
|
||||
return new ValidationErrorCollection();
|
||||
}
|
||||
|
||||
public virtual ValidationError ValidateActivityChange(Activity activity, ActivityChangeAction action)
|
||||
{
|
||||
if (activity == null)
|
||||
throw new ArgumentNullException("activity");
|
||||
if (action == null)
|
||||
throw new ArgumentNullException("action");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException("obj");
|
||||
|
||||
ValidationErrorCollection errors = new ValidationErrorCollection();
|
||||
|
||||
Activity activity = manager.Context[typeof(Activity)] as Activity;
|
||||
|
||||
// Validate all members that support validations.
|
||||
Walker walker = new Walker(true);
|
||||
walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
|
||||
{
|
||||
//If we find dynamic property of the same name then we do not invoke the validator associated with the property
|
||||
//Attached dependency properties will not be found by FromName().
|
||||
|
||||
// args.CurrentProperty can be null if the property is of type IList. The walker would go into each item in the
|
||||
// list, but we don't need to validate these items.
|
||||
if (args.CurrentProperty != null)
|
||||
{
|
||||
DependencyProperty dependencyProperty = DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType);
|
||||
if (dependencyProperty == null)
|
||||
{
|
||||
object[] validationVisibilityAtrributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
|
||||
ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
|
||||
if (validationVisibility != ValidationOption.None)
|
||||
{
|
||||
errors.AddRange(ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
|
||||
// don't probe into subproperties as validate object inside the ValidateProperties call does it for us
|
||||
args.Action = WalkerAction.Skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
walker.WalkProperties(activity, obj);
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
protected string GetFullPropertyName(ValidationManager manager)
|
||||
{
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException("manager");
|
||||
|
||||
string fullName = string.Empty;
|
||||
|
||||
// iterate the properties in the stack starting with the last one
|
||||
int iterator = 0;
|
||||
while (manager.Context[iterator] != null)
|
||||
{
|
||||
if (manager.Context[iterator] is PropertyValidationContext)
|
||||
{
|
||||
PropertyValidationContext propertyValidationContext = manager.Context[iterator] as PropertyValidationContext;
|
||||
if (propertyValidationContext.PropertyName == string.Empty)
|
||||
fullName = string.Empty; // property chain broke... dicard properties after break
|
||||
else if (fullName == string.Empty)
|
||||
fullName = propertyValidationContext.PropertyName;
|
||||
else
|
||||
fullName = propertyValidationContext.PropertyName + "." + fullName;
|
||||
}
|
||||
iterator++;
|
||||
}
|
||||
|
||||
return fullName;
|
||||
}
|
||||
|
||||
internal protected ValidationErrorCollection ValidateProperty(PropertyInfo propertyInfo, object propertyOwner, object propertyValue, ValidationManager manager)
|
||||
{
|
||||
ValidationErrorCollection errors = new ValidationErrorCollection();
|
||||
|
||||
object[] validationVisibilityAtrributes = propertyInfo.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
|
||||
ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
|
||||
PropertyValidationContext propertyValidationContext = new PropertyValidationContext(propertyOwner, propertyInfo, propertyInfo.Name);
|
||||
manager.Context.Push(propertyValidationContext);
|
||||
|
||||
try
|
||||
{
|
||||
if (propertyValue != null)
|
||||
{
|
||||
errors.AddRange(ValidationHelpers.ValidateObject(manager, propertyValue));
|
||||
if (propertyValue is IList)
|
||||
{
|
||||
PropertyValidationContext childContext = new PropertyValidationContext(propertyValue, null, "");
|
||||
manager.Context.Push(childContext);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (object child in (IList)propertyValue)
|
||||
errors.AddRange(ValidationHelpers.ValidateObject(manager, child));
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(manager.Context.Current == childContext, "Unwinding contextStack: the item that is about to be popped is not the one we pushed.");
|
||||
manager.Context.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(manager.Context.Current == propertyValidationContext, "Unwinding contextStack: the item that is about to be popped is not the one we pushed.");
|
||||
manager.Context.Pop();
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
|
||||
#region Class ValidatorAttribute
|
||||
[AttributeUsageAttribute(AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class ActivityValidatorAttribute : Attribute
|
||||
{
|
||||
private string validatorTypeName = null;
|
||||
|
||||
public ActivityValidatorAttribute(Type validatorType)
|
||||
{
|
||||
if (validatorType != null)
|
||||
this.validatorTypeName = validatorType.AssemblyQualifiedName;
|
||||
}
|
||||
|
||||
public ActivityValidatorAttribute(string validatorTypeName)
|
||||
{
|
||||
this.validatorTypeName = validatorTypeName;
|
||||
}
|
||||
|
||||
public string ValidatorTypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.validatorTypeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Permissions;
|
||||
|
||||
[Serializable()]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public sealed class WorkflowValidationFailedException : Exception
|
||||
{
|
||||
private ValidationErrorCollection errors = null;
|
||||
|
||||
private WorkflowValidationFailedException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
if (info == null)
|
||||
throw new ArgumentNullException("info");
|
||||
|
||||
this.errors = (ValidationErrorCollection)info.GetValue("errors", typeof(ValidationErrorCollection));
|
||||
|
||||
if (this.errors == null)
|
||||
throw new SerializationException(SR.GetString(SR.Error_SerializationInsufficientState));
|
||||
}
|
||||
|
||||
public WorkflowValidationFailedException()
|
||||
: base(SR.GetString(SR.Error_WorkflowLoadValidationFailed))
|
||||
{
|
||||
}
|
||||
|
||||
public WorkflowValidationFailedException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public WorkflowValidationFailedException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public WorkflowValidationFailedException(string message, ValidationErrorCollection errors)
|
||||
: base(message)
|
||||
{
|
||||
if (errors == null)
|
||||
throw new ArgumentNullException("errors");
|
||||
|
||||
this.errors = XomlCompilerHelper.MorphIntoFriendlyValidationErrors(errors);
|
||||
}
|
||||
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
if (info == null)
|
||||
throw new ArgumentNullException("info");
|
||||
|
||||
base.GetObjectData(info, context);
|
||||
|
||||
//ValidationErrorCollection is serializable
|
||||
info.AddValue("errors", this.errors, typeof(ValidationErrorCollection));
|
||||
}
|
||||
|
||||
public ValidationErrorCollection Errors
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user