1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.Workflow.Activities
{
using System.ServiceModel;
using System.Reflection;
using System.Collections.Generic;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;
class ReceiveActivityValidator : CompositeActivityValidator
{
public override ValidationErrorCollection Validate(
ValidationManager manager,
object obj)
{
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
ReceiveActivity receiveActivity = obj as ReceiveActivity;
if (receiveActivity == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("obj",
SR2.GetString(SR2.Error_ArgumentTypeInvalid, "obj", typeof(ReceiveActivity)));
}
ITypeProvider typeProvider = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
if (typeProvider == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
SR2.GetString(SR2.General_MissingService, typeof(ITypeProvider).Name)));
}
if (receiveActivity.ServiceOperationInfo == null)
{
validationErrors.Add(
new ValidationError(
SR2.GetString(SR2.Error_Validation_OperationInfoNotSpecified, receiveActivity.Name),
WorkflowServicesErrorNumbers.Error_OperationInfoNotSpecified,
false,
"ServiceOperationInfo"));
}
else
{
// validate operation info
//
ValidationErrorCollection operationInfoValidationErrors =
ValidationHelper.ValidateOperationInfo(
receiveActivity,
receiveActivity.ServiceOperationInfo,
manager);
validationErrors.AddRange(operationInfoValidationErrors);
// do not validate parameter binding if the operation info is not valid
// we might generate noise and false positives.
//
if (operationInfoValidationErrors.Count == 0)
{
validationErrors.AddRange(
ValidationHelper.ValidateParameterBindings(receiveActivity, receiveActivity.ServiceOperationInfo,
receiveActivity.ParameterBindings, manager));
}
// validate the context token
//
validationErrors.AddRange(
ValidationHelper.ValidateContextToken(receiveActivity, receiveActivity.ContextToken, manager));
}
// Check if the validation for all service operations being implemented
// has been done previously.
// If it has been done once then ServiceOperationsImplementedValidationMarker
// will be on the context stack.
//
if (validationErrors.Count == 0 &&
manager.Context[typeof(ServiceOperationsImplementedValidationMarker)] == null)
{
Activity rootActivity = receiveActivity;
while (rootActivity.Parent != null)
{
rootActivity = rootActivity.Parent;
}
validationErrors.AddRange(
ValidationHelper.ValidateAllServiceOperationsImplemented(
manager,
rootActivity));
}
return validationErrors;
}
}
}
|