コード例 #1
0
 internal PropertySegmentPropertyInfo(PropertySegment propertySegment, PropertyInfo realPropInfo)
 {
     this.realPropInfo = realPropInfo;
     this.propertySegment = propertySegment;
 }
コード例 #2
0
 internal PropertySegmentPropertyInfo(PropertySegment propertySegment, PropertyDescriptor realPropDesc)
 {
     this.realPropDesc = realPropDesc;
     this.propertySegment = propertySegment;
 }
 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;
         }
     }
 }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            string propertyName = Name;

            DependencyProperty dependencyProperty = null;
            PropertySegment    propertySegment    = obj as PropertySegment;
            Activity           activity           = (propertySegment != null) ? propertySegment.Object as Activity : obj as Activity;

            if (activity != null)
            {
                Type propertyType = DeclaringType;
                if (!String.IsNullOrEmpty(propertyName) && propertyType != null)
                {
                    dependencyProperty = DependencyProperty.FromName(propertyName, propertyType);
                }
            }

            PropertyDescriptor propertyDescriptor = null;
            object             destnObject        = null;

            if (propertySegment != null)
            {
                PropertyDescriptorCollection props = null;
                TypeConverter converter            = TypeDescriptor.GetConverter(propertySegment.Object);
                if (converter != null && converter.GetPropertiesSupported())
                {
                    DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(propertySegment.ServiceProvider, propertySegment.Object, this.realPropDesc);
                    props = converter.GetProperties(dummyContext, propertySegment.Object, new Attribute[] { });
                }
                else
                {
                    props = TypeDescriptor.GetProperties(propertySegment.Object);
                }

                foreach (PropertyDescriptor propDesc in props)
                {
                    if (propDesc.Name == propertyName)
                    {
                        propertyDescriptor = propDesc;
                    }
                    else if (propDesc.Converter != null)
                    {
                        DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(propertySegment.ServiceProvider, propertySegment.Object, propDesc);
                        if (propDesc.GetValue(propertySegment.Object) != null && propDesc.Converter.GetPropertiesSupported(dummyContext))
                        {
                            foreach (PropertyDescriptor childDesc in propDesc.Converter.GetProperties(dummyContext, propDesc.GetValue(propertySegment.Object), new Attribute[] { }))
                            {
                                if (childDesc.Name == propertyName)
                                {
                                    propertyDescriptor = childDesc;
                                }
                            }
                        }
                    }
                }

                destnObject = propertySegment.Object;
            }
            else
            {
                propertyDescriptor = TypeDescriptor.GetProperties(obj)[propertyName];
                destnObject        = obj;
            }

            if (propertyDescriptor != null && destnObject != null)
            {
                propertyDescriptor.SetValue(destnObject, value);
            }
        }
コード例 #6
0
 internal PropertySegmentPropertyInfo(PropertySegment propertySegment, PropertyDescriptor realPropDesc)
 {
     this.realPropDesc    = realPropDesc;
     this.propertySegment = propertySegment;
 }
コード例 #7
0
 internal PropertySegmentPropertyInfo(PropertySegment propertySegment, PropertyInfo realPropInfo)
 {
     this.realPropInfo    = realPropInfo;
     this.propertySegment = propertySegment;
 }
コード例 #8
0
        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;
            }
        }
 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;
         }
     }
 }