Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / RunTime / Hosting / DefaultWorkflowLoaderService.cs / 1305376 / DefaultWorkflowLoaderService.cs
#region Imports using System; using System.Diagnostics; using System.Collections; using System.Collections.Generic; using System.Xml; using System.Text; using System.IO; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.ComponentModel.Design; using System.Workflow.Runtime; #endregion namespace System.Workflow.Runtime.Hosting { public class DefaultWorkflowLoaderService : WorkflowLoaderService { protected internal override Activity CreateInstance(Type workflowType) { if (workflowType == null) throw new ArgumentNullException("workflowType"); if (!typeof(Activity).IsAssignableFrom(workflowType)) throw new ArgumentException(ExecutionStringManager.TypeMustImplementRootActivity); if (workflowType.GetConstructor(System.Type.EmptyTypes) == null) throw new ArgumentException(ExecutionStringManager.TypeMustHavePublicDefaultConstructor); return Activator.CreateInstance(workflowType) as Activity; } // This function will create a new root activity definition tree by deserializing the xoml and the rules file. protected internal override Activity CreateInstance(XmlReader workflowDefinitionReader, XmlReader rulesReader) { if (workflowDefinitionReader == null) throw new ArgumentNullException("workflowDefinitionReader"); Activity root = null; ValidationErrorCollection errors = new ValidationErrorCollection(); ServiceContainer serviceContainer = new ServiceContainer(); ITypeProvider typeProvider = this.Runtime.GetService(); if (typeProvider != null) serviceContainer.AddService(typeof(ITypeProvider), typeProvider); DesignerSerializationManager manager = new DesignerSerializationManager(serviceContainer); try { using (manager.CreateSession()) { WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(manager); root = new WorkflowMarkupSerializer().Deserialize(xomlSerializationManager, workflowDefinitionReader) as Activity; if (root != null && rulesReader != null) { object rules = new WorkflowMarkupSerializer().Deserialize(xomlSerializationManager, rulesReader); root.SetValue(ConditionTypeConverter.DeclarativeConditionDynamicProp, rules); } foreach (object error in manager.Errors) { if (error is WorkflowMarkupSerializationException) errors.Add(new ValidationError(((WorkflowMarkupSerializationException)error).Message, ErrorNumbers.Error_SerializationError)); else errors.Add(new ValidationError(error.ToString(), ErrorNumbers.Error_SerializationError)); } } } catch (Exception e) { errors.Add(new ValidationError(e.Message, ErrorNumbers.Error_SerializationError)); } if (errors.HasErrors) throw new WorkflowValidationFailedException(ExecutionStringManager.WorkflowValidationFailure, errors); return root; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebPartTransformerAttribute.cs
- SafeHandles.cs
- HtmlInputControl.cs
- _FixedSizeReader.cs
- InfoCardProofToken.cs
- XmlSerializerSection.cs
- Rule.cs
- SimpleRecyclingCache.cs
- SqlDuplicator.cs
- CollectionBase.cs
- XomlCompiler.cs
- FilteredDataSetHelper.cs
- BooleanKeyFrameCollection.cs
- ClientUriBehavior.cs
- EventData.cs
- ObjectParameter.cs
- DescendantOverDescendantQuery.cs
- WeakEventTable.cs
- SqlInfoMessageEvent.cs
- ImageButton.cs
- ComponentRenameEvent.cs
- SamlAudienceRestrictionCondition.cs
- AppSettings.cs
- LOSFormatter.cs
- AssemblyAttributesGoHere.cs
- InvokeGenerator.cs
- ExpandCollapseProviderWrapper.cs
- Matrix.cs
- XmlElement.cs
- CompletionBookmark.cs
- SessionSwitchEventArgs.cs
- SettingsProviderCollection.cs
- SqlClientMetaDataCollectionNames.cs
- Hyperlink.cs
- ActiveXContainer.cs
- RSAProtectedConfigurationProvider.cs
- DynamicControl.cs
- CodeLinePragma.cs
- X500Name.cs
- HttpDebugHandler.cs
- Label.cs
- SHA256.cs
- ChannelEndpointElementCollection.cs
- SharedUtils.cs
- HtmlTitle.cs
- PublisherIdentityPermission.cs
- KeyManager.cs
- ListenerUnsafeNativeMethods.cs
- smtpconnection.cs
- PrintPreviewDialog.cs
- DataView.cs
- KeyToListMap.cs
- RefreshPropertiesAttribute.cs
- StreamInfo.cs
- AnchoredBlock.cs
- MenuItemStyleCollectionEditor.cs
- Control.cs
- ClassicBorderDecorator.cs
- TransactionManagerProxy.cs
- TransformerInfo.cs
- AxHostDesigner.cs
- MediaCommands.cs
- MulticastIPAddressInformationCollection.cs
- MessageBox.cs
- ItemAutomationPeer.cs
- CapiHashAlgorithm.cs
- XmlnsCache.cs
- WsatServiceCertificate.cs
- IndependentlyAnimatedPropertyMetadata.cs
- EnumerableValidator.cs
- StateRuntime.cs
- RoleManagerModule.cs
- HtmlTitle.cs
- HeaderedItemsControl.cs
- Drawing.cs
- WebPartEditorOkVerb.cs
- EndpointDispatcher.cs
- ListItemCollection.cs
- JsonEncodingStreamWrapper.cs
- RepeatInfo.cs
- infer.cs
- AtomServiceDocumentSerializer.cs
- SmiContext.cs
- XmlTextReaderImplHelpers.cs
- DataGridRow.cs
- DrawingContext.cs
- AdapterUtil.cs
- WebBrowserDocumentCompletedEventHandler.cs
- JsonQueryStringConverter.cs
- ObjectViewFactory.cs
- CaseExpr.cs
- BinaryConverter.cs
- CollectionViewProxy.cs
- CacheHelper.cs
- ProtocolsConfigurationHandler.cs
- PassportAuthentication.cs
- XmlDeclaration.cs
- OleDbRowUpdatedEvent.cs
- FixedLineResult.cs
- VectorAnimationUsingKeyFrames.cs