当前位置: 首页>>代码示例>>C#>>正文


C# WorkflowMarkupSerializationManager.AddSerializationProvider方法代码示例

本文整理汇总了C#中System.Workflow.ComponentModel.Serialization.WorkflowMarkupSerializationManager.AddSerializationProvider方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowMarkupSerializationManager.AddSerializationProvider方法的具体用法?C# WorkflowMarkupSerializationManager.AddSerializationProvider怎么用?C# WorkflowMarkupSerializationManager.AddSerializationProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Workflow.ComponentModel.Serialization.WorkflowMarkupSerializationManager的用法示例。


在下文中一共展示了WorkflowMarkupSerializationManager.AddSerializationProvider方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Close

        public override void Close()
        {
            if (this.serializedXmlString != null)
                return;

            DesignerSerializationManager serializationManager = new LocalDesignerSerializationManager(this, serviceProvider);
            using (serializationManager.CreateSession())
            {
                // serialize all objects 
                WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(serializationManager);
                StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);
                using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
                {
                    if (this.memberList.Count == 0)
                    {
                        WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
                        foreach (Activity activity in this.activities)
                            xomlSerializer.SerializeObject(xomlSerializationManager, activity, writer);
                    }
                    else
                    {
                        PropertySegmentSerializationProvider propertySegmentSerializationProvider = new PropertySegmentSerializationProvider();
                        xomlSerializationManager.AddSerializationProvider(propertySegmentSerializationProvider);

                        xomlSerializationManager.Context.Push(new StringWriter(CultureInfo.InvariantCulture));

                        IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                        if (referenceService != null)
                        {
                            for (int loop = 0; loop < this.memberList.Count; loop++)
                            {
                                object obj = referenceService.GetReference(this.parentObjectNameList[loop]);
                                PropertySegmentSerializer serializer = new PropertySegmentSerializer(null);
                                if (this.memberList[loop] is PropertyDescriptor)
                                {
                                    PropertyInfo propertyInfo = XomlComponentSerializationService.GetProperty(obj.GetType(), (this.memberList[loop] as PropertyDescriptor).Name, BindingFlags.Public | BindingFlags.Instance);
                                    if (propertyInfo != null)
                                        serializer.SerializeObject(xomlSerializationManager, new PropertySegment(this.serviceProvider, obj, propertyInfo), writer);
                                    else
                                        serializer.SerializeObject(xomlSerializationManager, new PropertySegment(this.serviceProvider, obj, this.memberList[loop] as PropertyDescriptor), writer);
                                }
                                else if (this.memberList[loop] is EventDescriptor)
                                {
                                    // Events.
                                    IEventBindingService eventBindingService = this.serviceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService;
                                    if (eventBindingService != null)
                                    {
                                        PropertySegment propertySegment = new PropertySegment(serviceProvider, obj, eventBindingService.GetEventProperty(this.memberList[loop] as EventDescriptor));
                                        serializer.SerializeObject(xomlSerializationManager, propertySegment, writer);
                                    }
                                }
                            }
                        }

                        xomlSerializationManager.Context.Pop();
                        xomlSerializationManager.RemoveSerializationProvider(propertySegmentSerializationProvider);
                    }
                }
                this.serializedXmlString = stringWriter.ToString();

                // store all the assembly names
                List<AssemblyName> assemblyList = new List<AssemblyName>();
                foreach (Activity activity in this.activities)
                {
                    Assembly a = activity.GetType().Assembly;
                    assemblyList.Add(a.GetName(true));
                }
                this.assemblies = assemblyList.ToArray();
                this.activities.Clear();
                this.activities = null;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:72,代码来源:ComponentSerializationService.cs

示例2: OnBeforeSerialize

        protected override void OnBeforeSerialize(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            base.OnBeforeSerialize(serializationManager, obj);

            serializationManager.AddSerializationProvider(serializer);
        }
开发者ID:ssickles,项目名称:archive,代码行数:6,代码来源:StackActivitySerializer.cs

示例3: Close

 public override void Close()
 {
     if (this.serializedXmlString == null)
     {
         DesignerSerializationManager manager = new LocalDesignerSerializationManager(this, this.serviceProvider);
         using (manager.CreateSession())
         {
             WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
             StringWriter w = new StringWriter(CultureInfo.InvariantCulture);
             using (XmlTextWriter writer2 = new XmlTextWriter(w))
             {
                 if (this.memberList.Count == 0)
                 {
                     WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
                     foreach (Activity activity in this.activities)
                     {
                         serializer.SerializeObject(serializationManager, activity, writer2);
                     }
                 }
                 else
                 {
                     PropertySegmentSerializationProvider provider = new PropertySegmentSerializationProvider();
                     serializationManager.AddSerializationProvider(provider);
                     serializationManager.Context.Push(new StringWriter(CultureInfo.InvariantCulture));
                     IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                     if (service != null)
                     {
                         for (int i = 0; i < this.memberList.Count; i++)
                         {
                             object reference = service.GetReference(this.parentObjectNameList[i]);
                             PropertySegmentSerializer serializer2 = new PropertySegmentSerializer(null);
                             if (this.memberList[i] is PropertyDescriptor)
                             {
                                 PropertyInfo property = XomlComponentSerializationService.GetProperty(reference.GetType(), (this.memberList[i] as PropertyDescriptor).Name, BindingFlags.Public | BindingFlags.Instance);
                                 if (property != null)
                                 {
                                     serializer2.SerializeObject(serializationManager, new PropertySegment(this.serviceProvider, reference, property), writer2);
                                 }
                                 else
                                 {
                                     serializer2.SerializeObject(serializationManager, new PropertySegment(this.serviceProvider, reference, this.memberList[i] as PropertyDescriptor), writer2);
                                 }
                             }
                             else if (this.memberList[i] is EventDescriptor)
                             {
                                 IEventBindingService service2 = this.serviceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService;
                                 if (service2 != null)
                                 {
                                     PropertySegment segment = new PropertySegment(this.serviceProvider, reference, service2.GetEventProperty(this.memberList[i] as EventDescriptor));
                                     serializer2.SerializeObject(serializationManager, segment, writer2);
                                 }
                             }
                         }
                     }
                     serializationManager.Context.Pop();
                     serializationManager.RemoveSerializationProvider(provider);
                 }
             }
             this.serializedXmlString = w.ToString();
             List<AssemblyName> list = new List<AssemblyName>();
             foreach (Activity activity2 in this.activities)
             {
                 Assembly assembly = activity2.GetType().Assembly;
                 list.Add(assembly.GetName(true));
             }
             this.assemblies = list.ToArray();
             this.activities.Clear();
             this.activities = null;
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:71,代码来源:WorkflowMarkupSerializationStore.cs

示例4: DeserializeTo

        internal void DeserializeTo(IServiceProvider serviceProvider, IContainer container)
        {
            DesignerSerializationManager serializationManager = new LocalDesignerSerializationManager(this, serviceProvider);

            using (serializationManager.CreateSession())
            {
                WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(serializationManager);
                PropertySegmentSerializationProvider propertySegmentSerializationProvider = new PropertySegmentSerializationProvider();
                xomlSerializationManager.AddSerializationProvider(propertySegmentSerializationProvider);

                StringReader stringReader = new StringReader(this.serializedXmlString);
                using (XmlTextReader reader = new XmlTextReader(stringReader))
                {
                    while (reader.NodeType != XmlNodeType.Element && reader.NodeType != XmlNodeType.ProcessingInstruction && reader.Read());

                    IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                    IComponentChangeService componentChangeService = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                    for (int loop = 0; loop < this.memberList.Count; loop++)
                    {
                        object obj = referenceService.GetReference(this.parentObjectNameList[loop]);
                        if (obj != null)
                        {
                            bool needChangeEvent = (componentChangeService != null) && (!(obj is IComponent) || (((IComponent)obj).Site == null));

                            PropertyDescriptor member = this.memberList[loop] as PropertyDescriptor;
                            if (needChangeEvent)
                                componentChangeService.OnComponentChanging(obj, member);

                            xomlSerializationManager.Context.Push(obj);
                            PropertySegmentSerializer serializer = new PropertySegmentSerializer(null);
                            PropertySegment propertySegment = serializer.DeserializeObject(xomlSerializationManager, reader) as PropertySegment;
                            System.Diagnostics.Debug.Assert(obj == xomlSerializationManager.Context.Current, "Serialization Store did not remove object which it pushed onto the stack.");
                            xomlSerializationManager.Context.Pop();

                            if (needChangeEvent)
                                componentChangeService.OnComponentChanged(obj, member, null, null);
                        }
                    }
                }

                xomlSerializationManager.RemoveSerializationProvider(propertySegmentSerializationProvider);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:43,代码来源:ComponentSerializationService.cs

示例5: DeserializeTo

 internal void DeserializeTo(IServiceProvider serviceProvider, IContainer container)
 {
     DesignerSerializationManager manager = new LocalDesignerSerializationManager(this, serviceProvider);
     using (manager.CreateSession())
     {
         WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
         PropertySegmentSerializationProvider provider = new PropertySegmentSerializationProvider();
         serializationManager.AddSerializationProvider(provider);
         StringReader input = new StringReader(this.serializedXmlString);
         using (XmlTextReader reader2 = new XmlTextReader(input))
         {
             while (((reader2.NodeType != XmlNodeType.Element) && (reader2.NodeType != XmlNodeType.ProcessingInstruction)) && reader2.Read())
             {
             }
             IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
             IComponentChangeService service2 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
             for (int i = 0; i < this.memberList.Count; i++)
             {
                 object reference = service.GetReference(this.parentObjectNameList[i]);
                 if (reference != null)
                 {
                     bool flag = (service2 != null) && (!(reference is IComponent) || (((IComponent) reference).Site == null));
                     PropertyDescriptor member = this.memberList[i] as PropertyDescriptor;
                     if (flag)
                     {
                         service2.OnComponentChanging(reference, member);
                     }
                     serializationManager.Context.Push(reference);
                     new PropertySegmentSerializer(null).DeserializeObject(serializationManager, reader2);
                     serializationManager.Context.Pop();
                     if (flag)
                     {
                         service2.OnComponentChanged(reference, member, null, null);
                     }
                 }
             }
         }
         serializationManager.RemoveSerializationProvider(provider);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:WorkflowMarkupSerializationStore.cs

示例6: SaveDesignerLayout

        protected void SaveDesignerLayout(XmlWriter layoutWriter, ActivityDesigner rootDesigner, out IList layoutSaveErrors)
        {
            if (layoutWriter == null)
                throw new ArgumentNullException("layoutWriter");

            if (rootDesigner == null)
                throw new ArgumentNullException("rootDesigner");

            ArrayList errors = new ArrayList();
            layoutSaveErrors = errors;

            if (rootDesigner.SupportsLayoutPersistence)
            {
                DesignerSerializationManager serializationManager = new DesignerSerializationManager(LoaderHost);
                using (serializationManager.CreateSession())
                {
                    WorkflowMarkupSerializationManager layoutSerializationManager = new WorkflowMarkupSerializationManager(serializationManager);
                    layoutSerializationManager.AddSerializationProvider(new ActivityDesignerLayoutSerializerProvider());

                    try
                    {
                        new WorkflowMarkupSerializer().Serialize(layoutSerializationManager, layoutWriter, rootDesigner);
                    }
                    catch (Exception e)
                    {
                        errors.Add(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_LayoutSerialization), e));
                    }
                    finally
                    {
                        if (serializationManager.Errors != null)
                            errors.AddRange(serializationManager.Errors);
                    }
                }
            }
            else
            {
                errors.Add(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_LayoutSerializationPersistenceSupport)));
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:39,代码来源:XomlDesignerLoader.cs

示例7: LoadDesignerLayout

        protected void LoadDesignerLayout(XmlReader layoutReader, out IList layoutLoadErrors)
        {
            if (layoutReader == null)
                throw new ArgumentNullException("layoutReader");

            ArrayList errors = new ArrayList();
            layoutLoadErrors = errors;

            ActivityDesigner rootDesigner = null;
            IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designerHost != null && designerHost.RootComponent != null)
                rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as ActivityDesigner;

            if (rootDesigner != null)
            {
                if (rootDesigner.SupportsLayoutPersistence)
                {
                    DesignerSerializationManager serializationManager = new DesignerSerializationManager(LoaderHost);
                    using (serializationManager.CreateSession())
                    {
                        WorkflowMarkupSerializationManager layoutSerializationManager = new WorkflowMarkupSerializationManager(serializationManager);
                        layoutSerializationManager.AddSerializationProvider(new ActivityDesignerLayoutSerializerProvider());

                        try
                        {
                            new WorkflowMarkupSerializer().Deserialize(layoutSerializationManager, layoutReader);
                        }
                        catch (Exception e)
                        {
                            errors.Add(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_LayoutDeserialization), e));
                        }
                        finally
                        {
                            if (serializationManager.Errors != null)
                                errors.AddRange(serializationManager.Errors);
                        }
                    }
                }
                else
                {
                    errors.Add(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_LayoutSerializationPersistenceSupport)));
                }
            }
            else
            {
                errors.Add(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_LayoutSerializationRootDesignerNotFound)));
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:48,代码来源:XomlDesignerLoader.cs

示例8: SaveDesignerLayout

 protected void SaveDesignerLayout(XmlWriter layoutWriter, ActivityDesigner rootDesigner, out IList layoutSaveErrors)
 {
     if (layoutWriter == null)
     {
         throw new ArgumentNullException("layoutWriter");
     }
     if (rootDesigner == null)
     {
         throw new ArgumentNullException("rootDesigner");
     }
     ArrayList list = new ArrayList();
     layoutSaveErrors = list;
     if (rootDesigner.SupportsLayoutPersistence)
     {
         DesignerSerializationManager manager = new DesignerSerializationManager(base.LoaderHost);
         using (manager.CreateSession())
         {
             WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
             serializationManager.AddSerializationProvider(new ActivityDesignerLayoutSerializerProvider());
             try
             {
                 new WorkflowMarkupSerializer().Serialize(serializationManager, layoutWriter, rootDesigner);
             }
             catch (Exception exception)
             {
                 list.Add(new WorkflowMarkupSerializationException(SR.GetString("Error_LayoutSerialization"), exception));
             }
             finally
             {
                 if (manager.Errors != null)
                 {
                     list.AddRange(manager.Errors);
                 }
             }
             return;
         }
     }
     list.Add(new WorkflowMarkupSerializationException(SR.GetString("Error_LayoutSerializationPersistenceSupport")));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:WorkflowDesignerLoader.cs

示例9: LoadDesignerLayout

 protected void LoadDesignerLayout(XmlReader layoutReader, out IList layoutLoadErrors)
 {
     if (layoutReader == null)
     {
         throw new ArgumentNullException("layoutReader");
     }
     ArrayList list = new ArrayList();
     layoutLoadErrors = list;
     ActivityDesigner designer = null;
     IDesignerHost service = base.GetService(typeof(IDesignerHost)) as IDesignerHost;
     if ((service != null) && (service.RootComponent != null))
     {
         designer = service.GetDesigner(service.RootComponent) as ActivityDesigner;
     }
     if (designer != null)
     {
         if (designer.SupportsLayoutPersistence)
         {
             DesignerSerializationManager manager = new DesignerSerializationManager(base.LoaderHost);
             using (manager.CreateSession())
             {
                 WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
                 serializationManager.AddSerializationProvider(new ActivityDesignerLayoutSerializerProvider());
                 try
                 {
                     new WorkflowMarkupSerializer().Deserialize(serializationManager, layoutReader);
                 }
                 catch (Exception exception)
                 {
                     list.Add(new WorkflowMarkupSerializationException(SR.GetString("Error_LayoutDeserialization"), exception));
                 }
                 finally
                 {
                     if (manager.Errors != null)
                     {
                         list.AddRange(manager.Errors);
                     }
                 }
                 return;
             }
         }
         list.Add(new WorkflowMarkupSerializationException(SR.GetString("Error_LayoutSerializationPersistenceSupport")));
     }
     else
     {
         list.Add(new WorkflowMarkupSerializationException(SR.GetString("Error_LayoutSerializationRootDesignerNotFound")));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:WorkflowDesignerLoader.cs


注:本文中的System.Workflow.ComponentModel.Serialization.WorkflowMarkupSerializationManager.AddSerializationProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。