Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / Workflow / Runtime / WorkflowDefinitionContext.cs / 1305376 / WorkflowDefinitionContext.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Workflow.Runtime { using System.ComponentModel.Design; using System.Reflection; using System.Runtime; using System.ServiceModel; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Compiler; abstract class WorkflowDefinitionContext { WorkflowRuntime workflowRuntime; public abstract string ConfigurationName { get; } public abstract string WorkflowName { get; } internal protected WorkflowRuntime WorkflowRuntime { get { Fx.Assert(this.workflowRuntime != null, "Attempt to call WorkflowRuntime before Register"); return this.workflowRuntime; } } public abstract WorkflowInstance CreateWorkflow(); public abstract WorkflowInstance CreateWorkflow(Guid instanceId); public abstract Activity GetWorkflowDefinition(); internal void Register(WorkflowRuntime workflowRuntime, bool validate) { if (workflowRuntime == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("workflowRuntime"); } this.workflowRuntime = workflowRuntime; OnRegister(); if (!this.workflowRuntime.IsStarted) { this.workflowRuntime.StartRuntime(); } if (validate) { ValidateDefinition(); } } protected static TypeProvider CreateTypeProvider(Activity rootActivity) { TypeProvider typeProvider = new TypeProvider(null); Type companionType = rootActivity.GetType(); typeProvider.SetLocalAssembly(companionType.Assembly); typeProvider.AddAssembly(companionType.Assembly); foreach (AssemblyName assemblyName in companionType.Assembly.GetReferencedAssemblies()) { Assembly referencedAssembly = null; try { referencedAssembly = Assembly.Load(assemblyName); if (referencedAssembly != null) { typeProvider.AddAssembly(referencedAssembly); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } } if (referencedAssembly == null && assemblyName.CodeBase != null) { typeProvider.AddAssemblyReference(assemblyName.CodeBase); } } return typeProvider; } protected abstract void OnRegister(); protected abstract void OnValidate(ValidationErrorCollection errors); void ValidateDefinition() { ValidationErrorCollection errors = new ValidationErrorCollection(); Activity rootActivity = GetWorkflowDefinition(); ITypeProvider typeProvider = CreateTypeProvider(rootActivity); ServiceContainer serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(ITypeProvider), typeProvider); ValidationManager validationManager = new ValidationManager(serviceContainer); foreach (Validator validator in validationManager.GetValidators(rootActivity.GetType())) { foreach (ValidationError error in validator.Validate(validationManager, rootActivity)) { if (!error.UserData.Contains(typeof(Activity))) { error.UserData[typeof(Activity)] = rootActivity; } errors.Add(error); } } OnValidate(errors); if (errors.HasErrors) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WorkflowValidationFailedException(SR2.WorkflowValidationFailed, errors)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EncoderParameter.cs
- RegexCompilationInfo.cs
- HttpPostedFile.cs
- odbcmetadatafactory.cs
- QueryResponse.cs
- EncryptionUtility.cs
- WinFormsSecurity.cs
- EventLogPropertySelector.cs
- StorageTypeMapping.cs
- PixelFormats.cs
- MetadataArtifactLoader.cs
- WindowPatternIdentifiers.cs
- SiteMapNodeItem.cs
- safex509handles.cs
- DataContractSet.cs
- AutoResizedEvent.cs
- SslStreamSecurityElement.cs
- Span.cs
- MatrixTransform3D.cs
- TrackingServices.cs
- BaseDataList.cs
- CalendarBlackoutDatesCollection.cs
- TemplateBuilder.cs
- Binding.cs
- Error.cs
- VSDExceptions.cs
- IgnoreDataMemberAttribute.cs
- Exceptions.cs
- TagMapInfo.cs
- XmlSerializerImportOptions.cs
- PageEventArgs.cs
- PersonalizableTypeEntry.cs
- FirewallWrapper.cs
- Attributes.cs
- MatrixAnimationBase.cs
- ExpressionDumper.cs
- Light.cs
- WebPartConnectVerb.cs
- DesignTable.cs
- ReferenceEqualityComparer.cs
- GroupItemAutomationPeer.cs
- MessageSecurityOverHttp.cs
- BasePattern.cs
- SwitchCase.cs
- OleDbErrorCollection.cs
- CodeEntryPointMethod.cs
- WindowsListViewItemStartMenu.cs
- XPathBuilder.cs
- Vector3DIndependentAnimationStorage.cs
- CuspData.cs
- RoleBoolean.cs
- AllMembershipCondition.cs
- QilXmlReader.cs
- BindingList.cs
- SymbolTable.cs
- PKCS1MaskGenerationMethod.cs
- _TLSstream.cs
- SerialErrors.cs
- CodeTypeOfExpression.cs
- XsltInput.cs
- DelegatedStream.cs
- DiscoveryUtility.cs
- ToolboxItemLoader.cs
- DataSourceView.cs
- SerializationException.cs
- ManipulationInertiaStartingEventArgs.cs
- UnsafeNativeMethodsTablet.cs
- OdbcDataReader.cs
- CodeAttributeDeclaration.cs
- DataGridAddNewRow.cs
- XmlDeclaration.cs
- RemoveStoryboard.cs
- IsolatedStorageFile.cs
- NewArrayExpression.cs
- CryptoKeySecurity.cs
- EmptyReadOnlyDictionaryInternal.cs
- BooleanFacetDescriptionElement.cs
- AssertFilter.cs
- XmlWrappingWriter.cs
- Path.cs
- RegexStringValidator.cs
- DockAndAnchorLayout.cs
- CompressionTransform.cs
- Config.cs
- ProfileService.cs
- DefaultMergeHelper.cs
- ServiceAuthorizationBehavior.cs
- XMLSchema.cs
- CustomAttribute.cs
- SymbolEqualComparer.cs
- VirtualizedContainerService.cs
- CLSCompliantAttribute.cs
- SqlDataReader.cs
- StorageComplexPropertyMapping.cs
- PenLineJoinValidation.cs
- DetailsViewPagerRow.cs
- XmlSchemaInfo.cs
- HMACSHA512.cs
- WindowsToolbarAsMenu.cs
- AQNBuilder.cs