internal void CreateXamlObjectReaders(object deserializedObject, XamlSchemaContext schemaContext, out XamlReader newWorkflowReader, out XamlObjectReaderWithSequence deserializedObjectSequenceBuilder) { deserializedObjectSequenceBuilder = new XamlObjectReaderWithSequence(deserializedObject, schemaContext); if (this.FrameworkName.Is45OrHigher()) { newWorkflowReader = ViewStateXamlHelper.ConvertAttachedPropertiesToViewState(deserializedObjectSequenceBuilder, this.IdManager); } else { newWorkflowReader = ViewStateXamlHelper.RemoveIdRefs(deserializedObjectSequenceBuilder); } }
private object DeserializeString(string text, DeserializationMode mode, out IList <XamlLoadErrorInfo> loadErrors, out Dictionary <object, SourceLocation> sourceLocations) { object result = null; loadErrors = null; Dictionary <object, SourceLocation> collectingSourceLocations = new Dictionary <object, SourceLocation>(ObjectReferenceEqualityComparer <object> .Default); SourceLocationFoundCallback sourceLocationFoundCallback = new SourceLocationFoundCallback((obj, sourceLocation) => { // If an object appear more than once in the XAML stream (e.g. System.Type, which is cached by reflection) // we count the first occurrence. if (!collectingSourceLocations.ContainsKey(obj)) { collectingSourceLocations.Add(obj, sourceLocation); } this.OnSourceLocationFound(obj, sourceLocation); }); this.XamlSchemaContext.ContainsConversionRequiredType = false; Dictionary <string, SourceLocation> viewStateDataSourceLocationMapping = null; using (XamlDebuggerXmlReader debuggerReader = new XamlDebuggerXmlReader(new StringReader(text), this.XamlSchemaContext)) { using (System.Xaml.XamlReader activityBuilderReader = ActivityXamlServices.CreateBuilderReader(debuggerReader)) { using (System.Xaml.XamlReader activityTemplateFactoryBuilderReader = new ActivityTemplateFactoryBuilderReader(activityBuilderReader, this.XamlSchemaContext)) { debuggerReader.SourceLocationFound += delegate(object sender, SourceLocationFoundEventArgs args) { sourceLocationFoundCallback(args.Target, args.SourceLocation); }; this.OnBeforeDeserialize(); debuggerReader.CollectNonActivitySourceLocation = this.FrameworkName.Is45OrHigher(); using (System.Xaml.XamlReader reader = ViewStateXamlHelper.ConvertViewStateToAttachedProperties(activityTemplateFactoryBuilderReader, this.IdManager, out viewStateDataSourceLocationMapping)) { switch (mode) { #if ERROR_TOLERANT_SUPPORT case DeserializationMode.ErrorTolerant: { ErrorTolerantObjectWriter tolerantWriter = new ErrorTolerantObjectWriter(reader.SchemaContext); tolerantWriter.LocalAssemblyName = this.LocalAssemblyName; XamlServices.Transform(reader, tolerantWriter); loadErrors = this.CheckFileFormatError(tolerantWriter.LoadErrors); result = tolerantWriter.Result; ErrorActivity.SetHasErrorActivities(result, true); } break; #endif case DeserializationMode.Default: { result = this.TransformAndGetPropertySourceLocation(reader, new SourceTextScanner(text), sourceLocationFoundCallback); loadErrors = this.CheckFileFormatError(loadErrors); } break; } } } } } sourceLocations = collectingSourceLocations; this.OnAfterDeserialize(viewStateDataSourceLocationMapping); return(result); }