protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            if (serializationManager == null)
            {
                throw new ArgumentNullException("serializationManager");
            }
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            XmlWriter writer = serializationManager.WorkflowMarkupStack[typeof(XmlWriter)] as XmlWriter;

            PropertyInfo[]           properties = base.GetProperties(serializationManager, obj);
            FreeformActivityDesigner designer   = obj as FreeformActivityDesigner;

            if (designer == null)
            {
                return(properties);
            }
            List <PropertyInfo> list = new List <PropertyInfo>();

            foreach (PropertyInfo info in properties)
            {
                if (((writer == null) || !info.Name.Equals("AutoSizeMargin", StringComparison.Ordinal)) || (designer.AutoSizeMargin != FreeformActivityDesigner.DefaultAutoSizeMargin))
                {
                    list.Add(info);
                }
            }
            list.Add(typeof(FreeformActivityDesigner).GetProperty("DesignerConnectors", BindingFlags.NonPublic | BindingFlags.Instance));
            return(list.ToArray());
        }
Exemplo n.º 2
0
        public void Save(string themeFilePath)
        {
            if ((themeFilePath == null) || (themeFilePath.Length == 0))
            {
                throw new ArgumentException(DR.GetString("ThemePathNotValid", new object[0]), "themeFilePath");
            }
            DesignerSerializationManager manager = new DesignerSerializationManager();

            using (manager.CreateSession())
            {
                WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
                XmlWriter writer = null;
                ThemeSerializationProvider provider = new ThemeSerializationProvider();
                try
                {
                    string directoryName = Path.GetDirectoryName(themeFilePath);
                    if ((directoryName.Length > 0) && !Directory.Exists(directoryName))
                    {
                        Directory.CreateDirectory(directoryName);
                    }
                    writer = Helpers.CreateXmlWriter(themeFilePath);
                    serializationManager.AddSerializationProvider(provider);
                    new WorkflowMarkupSerializer().Serialize(serializationManager, writer, this);
                }
                finally
                {
                    serializationManager.RemoveSerializationProvider(provider);
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
                this.filePath = themeFilePath;
            }
        }
Exemplo n.º 3
0
 protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
 {
     return(new List <PropertyInfo>(base.GetProperties(serializationManager, obj))
     {
         typeof(CompositeActivityDesigner).GetProperty("Designers", 0x24)
     }.ToArray());
 }
        protected override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            List <PropertyInfo> list     = new List <PropertyInfo>();
            StateDesigner       designer = obj as StateDesigner;

            if (designer != null)
            {
                foreach (PropertyInfo info in base.GetProperties(serializationManager, obj))
                {
                    if (info.Name.Equals("Location", StringComparison.Ordinal) || info.Name.Equals("Size", StringComparison.Ordinal))
                    {
                        list.Add(new System.Workflow.Activities.ExtendedPropertyInfo(info, new System.Workflow.Activities.GetValueHandler(designer.OnGetPropertyValue)));
                    }
                    else
                    {
                        list.Add(info);
                    }
                }
            }
            else
            {
                list.AddRange(base.GetProperties(serializationManager, obj));
            }
            return(list.ToArray());
        }
 protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type)
 {
     if (typeof(DesignerTheme).IsAssignableFrom(type))
     {
         return(Activator.CreateInstance(type, new object[] { serializationManager.Context[typeof(WorkflowTheme)] }));
     }
     return(base.CreateInstance(serializationManager, type));
 }
Exemplo n.º 6
0
        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)));
            }
        }
        // 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 <ITypeProvider>();

            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);
        }
        protected override void OnAfterDeserialize(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            base.OnAfterDeserialize(serializationManager, obj);
            Connector connector = obj as Connector;

            if (connector != null)
            {
                connector.SetConnectorModified(true);
            }
        }
Exemplo n.º 9
0
        protected internal override string SerializeToString(WorkflowMarkupSerializationManager serializationManager, object value)
        {
            TypeConverter converter = TypeDescriptor.GetConverter(value);

            if ((converter != null) && converter.CanConvertTo(typeof(string)))
            {
                return(converter.ConvertTo(value, typeof(string)) as string);
            }
            return(base.SerializeToString(serializationManager, value));
        }
Exemplo n.º 10
0
        protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            List <PropertyInfo> list = new List <PropertyInfo>();

            if (obj is Size)
            {
                list.Add(typeof(Size).GetProperty("Width"));
                list.Add(typeof(Size).GetProperty("Height"));
            }
            return(list.ToArray());
        }
Exemplo n.º 11
0
        protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            List <PropertyInfo> properties = new List <PropertyInfo>();

            if (obj is Point)
            {
                properties.Add(typeof(Point).GetProperty("X"));
                properties.Add(typeof(Point).GetProperty("Y"));
            }
            return(properties.ToArray());
        }
        protected override void OnAfterDeserialize(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            base.OnAfterDeserialize(serializationManager, obj);

            //The following code is needed in order to making sure that we set the modification flag correctly after deserialization
            Connector connector = obj as Connector;

            if (connector != null)
            {
                connector.SetConnectorModified(true);
            }
        }
        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)
                {
                    DtdProcessing = DtdProcessing.Prohibit
                })
                {
                    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);
            }
        }
        protected override object CreateInstance(WorkflowMarkupSerializationManager serializationManager, Type type)
        {
            if (serializationManager == null)
            {
                throw new ArgumentNullException("serializationManager");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            Connector                connector = null;
            IReferenceService        service   = serializationManager.GetService(typeof(IReferenceService)) as IReferenceService;
            FreeformActivityDesigner designer  = serializationManager.Context[typeof(FreeformActivityDesigner)] as FreeformActivityDesigner;

            if ((designer != null) && (service != null))
            {
                ConnectionPoint source = null;
                ConnectionPoint target = null;
                try
                {
                    Dictionary <string, string> connectorConstructionArguments = this.GetConnectorConstructionArguments(serializationManager, type);
                    if ((connectorConstructionArguments.ContainsKey("SourceActivity") && connectorConstructionArguments.ContainsKey("SourceConnectionIndex")) && connectorConstructionArguments.ContainsKey("SourceConnectionEdge"))
                    {
                        ActivityDesigner associatedDesigner = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["SourceActivity"]) as Activity);
                        DesignerEdges    designerEdge       = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["SourceConnectionEdge"]);
                        int connectionIndex = Convert.ToInt32(connectorConstructionArguments["SourceConnectionIndex"], CultureInfo.InvariantCulture);
                        if (((associatedDesigner != null) && (designerEdge != DesignerEdges.None)) && (connectionIndex >= 0))
                        {
                            source = new ConnectionPoint(associatedDesigner, designerEdge, connectionIndex);
                        }
                    }
                    if ((connectorConstructionArguments.ContainsKey("TargetActivity") && connectorConstructionArguments.ContainsKey("TargetConnectionIndex")) && connectorConstructionArguments.ContainsKey("TargetConnectionEdge"))
                    {
                        ActivityDesigner designer3 = ActivityDesigner.GetDesigner(service.GetReference(connectorConstructionArguments["TargetActivity"]) as Activity);
                        DesignerEdges    edges2    = (DesignerEdges)Enum.Parse(typeof(DesignerEdges), connectorConstructionArguments["TargetConnectionEdge"]);
                        int num2 = Convert.ToInt32(connectorConstructionArguments["TargetConnectionIndex"], CultureInfo.InvariantCulture);
                        if (((designer3 != null) && (edges2 != DesignerEdges.None)) && (num2 >= 0))
                        {
                            target = new ConnectionPoint(designer3, edges2, num2);
                        }
                    }
                }
                catch
                {
                }
                if ((source != null) && (target != null))
                {
                    connector = designer.AddConnector(source, target);
                }
            }
            return(connector);
        }
Exemplo n.º 15
0
        protected override void OnBeforeSerialize(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            base.OnBeforeSerialize(serializationManager, obj);
            ActivityDesigner designer = obj as ActivityDesigner;
            XmlWriter        writer   = serializationManager.WorkflowMarkupStack[typeof(XmlWriter)] as XmlWriter;

            if (((designer.Activity != null) && (designer.Activity.Parent == null)) && (writer != null))
            {
                string           prefix           = string.Empty;
                XmlQualifiedName xmlQualifiedName = serializationManager.GetXmlQualifiedName(typeof(Point), out prefix);
                writer.WriteAttributeString("xmlns", prefix, null, xmlQualifiedName.Namespace);
            }
        }
Exemplo n.º 16
0
        protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            List <PropertyInfo> list = new List <PropertyInfo>(base.GetProperties(serializationManager, obj));

            foreach (PropertyInfo info in obj.GetType().GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance))
            {
                if (((Helpers.GetSerializationVisibility(info) != DesignerSerializationVisibility.Hidden) && (info.GetSetMethod() == null)) && (info.GetSetMethod(true) != null))
                {
                    list.Add(info);
                }
            }
            return(list.ToArray());
        }
Exemplo n.º 17
0
        protected internal override Activity CreateInstance(XmlReader workflowDefinitionReader, XmlReader rulesReader)
        {
            if (workflowDefinitionReader == null)
            {
                throw new ArgumentNullException("workflowDefinitionReader");
            }
            Activity activity = null;
            ValidationErrorCollection errors    = new ValidationErrorCollection();
            ServiceContainer          container = new ServiceContainer();
            ITypeProvider             service   = base.Runtime.GetService <ITypeProvider>();

            if (service != null)
            {
                container.AddService(typeof(ITypeProvider), service);
            }
            DesignerSerializationManager manager = new DesignerSerializationManager(container);

            try
            {
                using (manager.CreateSession())
                {
                    WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
                    activity = new WorkflowMarkupSerializer().Deserialize(serializationManager, workflowDefinitionReader) as Activity;
                    if ((activity != null) && (rulesReader != null))
                    {
                        object obj2 = new WorkflowMarkupSerializer().Deserialize(serializationManager, rulesReader);
                        activity.SetValue(ConditionTypeConverter.DeclarativeConditionDynamicProp, obj2);
                    }
                    foreach (object obj3 in manager.Errors)
                    {
                        if (obj3 is WorkflowMarkupSerializationException)
                        {
                            errors.Add(new ValidationError(((WorkflowMarkupSerializationException)obj3).Message, 0x15b));
                        }
                        else
                        {
                            errors.Add(new ValidationError(obj3.ToString(), 0x15b));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                errors.Add(new ValidationError(exception.Message, 0x15b));
            }
            if (errors.HasErrors)
            {
                throw new WorkflowValidationFailedException(ExecutionStringManager.WorkflowValidationFailure, errors);
            }
            return(activity);
        }
Exemplo n.º 18
0
        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")));
            }
        }
        protected override void OnBeforeSerialize(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            base.OnBeforeSerialize(serializationManager, obj);

            //For root activity we will go through all the nested activities and put the namespaces at the top level
            ActivityDesigner activityDesigner = obj as ActivityDesigner;
            XmlWriter        writer           = serializationManager.WorkflowMarkupStack[typeof(XmlWriter)] as XmlWriter;

            if (activityDesigner.Activity != null && activityDesigner.Activity.Parent == null && writer != null)
            {
                string           prefix           = String.Empty;
                XmlQualifiedName xmlQualifiedName = serializationManager.GetXmlQualifiedName(typeof(Point), out prefix);
                writer.WriteAttributeString("xmlns", prefix, null, xmlQualifiedName.Namespace);
            }
        }
Exemplo n.º 20
0
        protected internal override string SerializeToString(WorkflowMarkupSerializationManager serializationManager, object value)
        {
            string convertedValue = String.Empty;

            TypeConverter converter = TypeDescriptor.GetConverter(value);

            if (converter != null && converter.CanConvertTo(typeof(string)))
            {
                convertedValue = converter.ConvertTo(value, typeof(string)) as string;
            }
            else
            {
                convertedValue = base.SerializeToString(serializationManager, value);
            }
            return(convertedValue);
        }
Exemplo n.º 21
0
        protected internal override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            List <PropertyInfo> properties = new List <PropertyInfo>(base.GetProperties(serializationManager, obj));

            //Collect the internal properties, we do this so that activity change action apis don't need to expose unnecessary setters
            foreach (PropertyInfo property in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy))
            {
                DesignerSerializationVisibility visibility = Helpers.GetSerializationVisibility(property);
                if (visibility != DesignerSerializationVisibility.Hidden && property.GetSetMethod() == null && property.GetSetMethod(true) != null)
                {
                    properties.Add(property);
                }
            }

            return(properties.ToArray());
        }
Exemplo n.º 22
0
        private static ArrayList CloneWorkflowChangeActions(ArrayList workflowChanges, Activity rootActivity)
        {
            if (workflowChanges == null)
            {
                throw new ArgumentNullException("workflowChanges");
            }

            if (rootActivity == null)
            {
                throw new ArgumentNullException("rootActivity");
            }

            string           dynamicUpdateHistory = null;
            TypeProvider     typeProvider         = CreateTypeProvider(rootActivity);
            ServiceContainer serviceContainer     = new ServiceContainer();

            serviceContainer.AddService(typeof(ITypeProvider), typeProvider);
            DesignerSerializationManager manager        = new DesignerSerializationManager(serviceContainer);
            WorkflowMarkupSerializer     xomlSerializer = new WorkflowMarkupSerializer();

            ArrayList clonedWorkflowChanges = null;

            // serialize dynamic updates
            using (manager.CreateSession())
            {
                using (StringWriter sw = new StringWriter(CultureInfo.InvariantCulture))
                {
                    using (XmlWriter xmlWriter = Helpers.CreateXmlWriter(sw))
                    {
                        WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(manager);
                        xomlSerializer.Serialize(xomlSerializationManager, xmlWriter, workflowChanges);
                        dynamicUpdateHistory = sw.ToString();
                    }
                }

                // deserialize those
                using (StringReader sr = new StringReader(dynamicUpdateHistory))
                {
                    using (XmlReader xmlReader = XmlReader.Create(sr))
                    {
                        WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(manager);
                        clonedWorkflowChanges = xomlSerializer.Deserialize(xomlSerializationManager, xmlReader) as ArrayList;
                    }
                }
            }
            return(clonedWorkflowChanges);
        }
 protected internal override object DeserializeFromString(WorkflowMarkupSerializationManager serializationManager, Type propertyType, string value)
 {
     if (propertyType.IsAssignableFrom(typeof(Color)))
     {
         string str = value;
         if (!string.IsNullOrEmpty(str))
         {
             if (str.StartsWith("0X", StringComparison.OrdinalIgnoreCase))
             {
                 long num = Convert.ToInt64(value, 0x10) & ((long)0xffffffffL);
                 return(Color.FromArgb((byte)(num >> 0x18), (byte)(num >> 0x10), (byte)(num >> 8), (byte)num));
             }
             return(base.DeserializeFromString(serializationManager, propertyType, value));
         }
     }
     return(null);
 }
Exemplo n.º 24
0
        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)));
            }
        }
Exemplo n.º 25
0
        protected internal override object DeserializeFromString(WorkflowMarkupSerializationManager serializationManager, Type propertyType, string value)
        {
            object empty = Point.Empty;
            string str   = value;

            if (string.IsNullOrEmpty(str))
            {
                return(empty);
            }
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Point));

            if (((converter != null) && converter.CanConvertFrom(typeof(string))) && !base.IsValidCompactAttributeFormat(str))
            {
                return(converter.ConvertFrom(value));
            }
            return(base.SerializeToString(serializationManager, value));
        }
Exemplo n.º 26
0
        protected override IList GetChildren(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            Queue queue = obj as Queue;

            if (queue == null)
            {
                throw new Exception(string.Format("The type of obj is not {0}", typeof(Queue).FullName));
            }

            ArrayList arrayList = new ArrayList(queue.ToArray());

            return(arrayList);
        }
        internal IList Deserialize(IServiceProvider serviceProvider)
        {
            DesignerSerializationManager serializationManager = new LocalDesignerSerializationManager(this, serviceProvider);

            using (serializationManager.CreateSession())
            {
                ArrayList objects = new ArrayList();
                WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(serializationManager);
                XmlTextReader reader = new XmlTextReader(this.serializedXmlString, XmlNodeType.Element, null)
                {
                    DtdProcessing = DtdProcessing.Prohibit
                };
                reader.MoveToElement();
                do
                {
                    if (!reader.Read())
                    {
                        return(objects);
                    }

                    xomlSerializationManager.FoundDefTag += delegate(object sender, WorkflowMarkupElementEventArgs eventArgs)
                    {
                        if (eventArgs.XmlReader.LookupNamespace(eventArgs.XmlReader.Prefix) == StandardXomlKeys.Definitions_XmlNs &&
                            xomlSerializationManager.Context.Current is Activity
                            )
                        {
                            WorkflowMarkupSerializationHelpers.ProcessDefTag(xomlSerializationManager, eventArgs.XmlReader, xomlSerializationManager.Context.Current as Activity, true, string.Empty);
                        }
                    };

                    WorkflowMarkupSerializer xomlSerializer = new WorkflowMarkupSerializer();
                    object activityDecl = xomlSerializer.DeserializeObject(xomlSerializationManager, reader);
                    if (activityDecl == null)
                    {
                        throw new InvalidOperationException(DR.GetString(DR.InvalidOperationDeserializationReturnedNonActivity));
                    }
                    if (activityDecl is Activity)
                    {
                        (activityDecl as Activity).UserData.Remove(UserDataKeys.CustomActivity);
                    }
                    objects.Add(activityDecl);
                } while (true);
            }
        }
        internal IList Deserialize(IServiceProvider serviceProvider)
        {
            IList list2;
            DesignerSerializationManager manager = new LocalDesignerSerializationManager(this, serviceProvider);

            using (manager.CreateSession())
            {
                EventHandler <WorkflowMarkupElementEventArgs> handler = null;
                ArrayList list = new ArrayList();
                WorkflowMarkupSerializationManager xomlSerializationManager = new WorkflowMarkupSerializationManager(manager);
                XmlTextReader reader = new XmlTextReader(this.serializedXmlString, XmlNodeType.Element, null);
                reader.MoveToElement();
Label_0042:
                if (!reader.Read())
                {
                    list2 = list;
                }
                else
                {
                    if (handler == null)
                    {
                        handler = delegate(object sender, WorkflowMarkupElementEventArgs eventArgs) {
                            if ((eventArgs.XmlReader.LookupNamespace(eventArgs.XmlReader.Prefix) == "http://schemas.microsoft.com/winfx/2006/xaml") && (xomlSerializationManager.Context.Current is Activity))
                            {
                                WorkflowMarkupSerializationHelpers.ProcessDefTag(xomlSerializationManager, eventArgs.XmlReader, xomlSerializationManager.Context.Current as Activity, true, string.Empty);
                            }
                        };
                    }
                    xomlSerializationManager.FoundDefTag += handler;
                    object obj2 = new WorkflowMarkupSerializer().DeserializeObject(xomlSerializationManager, reader);
                    if (obj2 == null)
                    {
                        throw new InvalidOperationException(DR.GetString("InvalidOperationDeserializationReturnedNonActivity", new object[0]));
                    }
                    if (obj2 is Activity)
                    {
                        (obj2 as Activity).UserData.Remove(UserDataKeys.CustomActivity);
                    }
                    list.Add(obj2);
                    goto Label_0042;
                }
            }
            return(list2);
        }
        protected override PropertyInfo[] GetProperties(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            if (serializationManager == null)
            {
                throw new ArgumentNullException("serializationManager");
            }
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            List <PropertyInfo> properties = new List <PropertyInfo>(base.GetProperties(serializationManager, obj));

            properties.Add(typeof(StateDesignerConnector).GetProperty("SetStateName", BindingFlags.Instance | BindingFlags.NonPublic));
            properties.Add(typeof(StateDesignerConnector).GetProperty("SourceStateName", BindingFlags.Instance | BindingFlags.NonPublic));
            properties.Add(typeof(StateDesignerConnector).GetProperty("TargetStateName", BindingFlags.Instance | BindingFlags.NonPublic));
            properties.Add(typeof(StateDesignerConnector).GetProperty("EventHandlerName", BindingFlags.Instance | BindingFlags.NonPublic));
            return(properties.ToArray());
        }
Exemplo n.º 30
0
        protected override IList GetChildren(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            Stack stack = obj as Stack;

            if (stack == null)
            {
                throw new Exception(string.Format("The type of obj is not {0}", typeof(Stack).FullName));
            }

            ArrayList arrayList = new ArrayList(stack.ToArray());

            arrayList.Reverse();
            return(arrayList);
        }