Esempio n. 1
0
        internal PropertyInfo[] GetProperties(IServiceProvider serviceProvider)
        {
            ArrayList properties = new ArrayList(GetType().GetProperties());

            if (this.property != null)
            {
                properties.Add(new PropertySegmentPropertyInfo(this, this.property));
            }
            else if (this.propertyDescriptor != null)
            {
                properties.Add(new PropertySegmentPropertyInfo(this, this.propertyDescriptor));
            }
            else if (this.obj != null)
            {
                PropertyDescriptorCollection props = null;
                TypeConverter converter            = TypeDescriptor.GetConverter(this.obj);
                if (converter != null && converter.GetPropertiesSupported())
                {
                    DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(this.serviceProvider, GetComponent(this.obj, serviceProvider), null);
                    props = converter.GetProperties(dummyContext, this.obj, new Attribute[] { });
                }
                else
                {
                    props = TypeDescriptor.GetProperties(this.obj);
                }

                foreach (PropertyDescriptor propDesc in props)
                {
                    PropertyInfo propInfo = XomlComponentSerializationService.GetProperty(this.obj.GetType(), propDesc.Name, BindingFlags.Public | BindingFlags.Instance);
                    if (propInfo != null)
                    {
                        if (Helpers.GetSerializationVisibility(propInfo) == DesignerSerializationVisibility.Hidden)
                        {
                            continue;
                        }

                        properties.Add(new PropertySegmentPropertyInfo(this, propInfo));
                    }
                    else
                    {
                        properties.Add(new PropertySegmentPropertyInfo(this, propDesc));
                        if (propDesc.Converter != null)
                        {
                            DummyTypeDescriptorContext dummyContext = new DummyTypeDescriptorContext(this.serviceProvider, GetComponent(this.obj, serviceProvider), propDesc);
                            if (propDesc.Converter.GetPropertiesSupported(dummyContext))
                            {
                                foreach (PropertyDescriptor childDesc in propDesc.Converter.GetProperties(dummyContext, this.obj, new Attribute[] { }))
                                {
                                    properties.Add(new PropertySegmentPropertyInfo(this, childDesc));
                                }
                            }
                        }
                    }
                }
            }

            return(properties.ToArray(typeof(PropertyInfo)) as PropertyInfo[]);
        }
Esempio n. 2
0
        internal PropertyInfo[] GetProperties(IServiceProvider serviceProvider)
        {
            ArrayList list = new ArrayList(base.GetType().GetProperties());

            if (this.property != null)
            {
                list.Add(new PropertySegmentPropertyInfo(this, this.property));
            }
            else if (this.propertyDescriptor != null)
            {
                list.Add(new PropertySegmentPropertyInfo(this, this.propertyDescriptor));
            }
            else if (this.obj != null)
            {
                PropertyDescriptorCollection properties = null;
                TypeConverter converter = TypeDescriptor.GetConverter(this.obj);
                if ((converter != null) && converter.GetPropertiesSupported())
                {
                    DummyTypeDescriptorContext context = new DummyTypeDescriptorContext(this.serviceProvider, this.GetComponent(this.obj, serviceProvider), null);
                    properties = converter.GetProperties(context, this.obj, new Attribute[0]);
                }
                else
                {
                    properties = TypeDescriptor.GetProperties(this.obj);
                }
                foreach (System.ComponentModel.PropertyDescriptor descriptor in properties)
                {
                    PropertyInfo memberInfo = XomlComponentSerializationService.GetProperty(this.obj.GetType(), descriptor.Name, BindingFlags.Public | BindingFlags.Instance);
                    if (memberInfo != null)
                    {
                        if (Helpers.GetSerializationVisibility(memberInfo) != DesignerSerializationVisibility.Hidden)
                        {
                            list.Add(new PropertySegmentPropertyInfo(this, memberInfo));
                        }
                    }
                    else
                    {
                        list.Add(new PropertySegmentPropertyInfo(this, descriptor));
                        if (descriptor.Converter != null)
                        {
                            DummyTypeDescriptorContext context2 = new DummyTypeDescriptorContext(this.serviceProvider, this.GetComponent(this.obj, serviceProvider), descriptor);
                            if (descriptor.Converter.GetPropertiesSupported(context2))
                            {
                                foreach (System.ComponentModel.PropertyDescriptor descriptor2 in descriptor.Converter.GetProperties(context2, this.obj, new Attribute[0]))
                                {
                                    list.Add(new PropertySegmentPropertyInfo(this, descriptor2));
                                }
                            }
                        }
                    }
                }
            }
            return(list.ToArray(typeof(PropertyInfo)) as PropertyInfo[]);
        }
Esempio n. 3
0
        private object OnCreateService(IServiceContainer container, Type serviceType)
        {
            object createdService = null;

            if (serviceType == typeof(ComponentSerializationService))
            {
                createdService = new XomlComponentSerializationService(LoaderHost);
            }
            else if (serviceType == typeof(IReferenceService))
            {
                createdService = new ReferenceService(LoaderHost);
            }
            else if (serviceType == typeof(IIdentifierCreationService))
            {
                createdService = new IdentifierCreationService(container, this);
            }
            else if (serviceType == typeof(IWorkflowCompilerOptionsService))
            {
                createdService = new WorkflowCompilerOptionsService();
            }
            else if (serviceType == typeof(IDesignerVerbProviderService))
            {
                createdService = new DesignerVerbProviderService();
            }

            if (createdService != null)
            {
                if (this.createdServices == null)
                {
                    this.createdServices = new Hashtable();
                }
                object existingService = this.createdServices[serviceType];
                this.createdServices[serviceType] = createdService;
                if (existingService != null)
                {
                    OnDisposeService(serviceType, existingService);
                }
            }

            return(createdService);
        }
Esempio n. 4
0
        private object OnCreateService(IServiceContainer container, Type serviceType)
        {
            object obj2 = null;

            if (serviceType == typeof(ComponentSerializationService))
            {
                obj2 = new XomlComponentSerializationService(base.LoaderHost);
            }
            else if (serviceType == typeof(IReferenceService))
            {
                obj2 = new System.Workflow.ComponentModel.Design.ReferenceService(base.LoaderHost);
            }
            else if (serviceType == typeof(IIdentifierCreationService))
            {
                obj2 = new IdentifierCreationService(container, this);
            }
            else if (serviceType == typeof(IWorkflowCompilerOptionsService))
            {
                obj2 = new WorkflowCompilerOptionsService();
            }
            else if (serviceType == typeof(IDesignerVerbProviderService))
            {
                obj2 = new DesignerVerbProviderService();
            }
            if (obj2 != null)
            {
                if (this.createdServices == null)
                {
                    this.createdServices = new Hashtable();
                }
                object service = this.createdServices[serviceType];
                this.createdServices[serviceType] = obj2;
                if (service != null)
                {
                    this.OnDisposeService(serviceType, service);
                }
            }
            return(obj2);
        }
Esempio n. 5
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;
            }
        }
        private object OnCreateService(IServiceContainer container, Type serviceType)
        {
            object createdService = null;

            if (serviceType == typeof(ComponentSerializationService))
                createdService = new XomlComponentSerializationService(LoaderHost);
            else if (serviceType == typeof(IReferenceService))
                createdService = new ReferenceService(LoaderHost);
            else if (serviceType == typeof(IIdentifierCreationService))
                createdService = new IdentifierCreationService(container, this);
            else if (serviceType == typeof(IWorkflowCompilerOptionsService))
                createdService = new WorkflowCompilerOptionsService();
            else if (serviceType == typeof(IDesignerVerbProviderService))
                createdService = new DesignerVerbProviderService();

            if (createdService != null)
            {
                if (this.createdServices == null)
                    this.createdServices = new Hashtable();
                object existingService = this.createdServices[serviceType];
                this.createdServices[serviceType] = createdService;
                if (existingService != null)
                {
                    OnDisposeService(serviceType, existingService);
                }
            }

            return createdService;
        }
 private object OnCreateService(IServiceContainer container, Type serviceType)
 {
     object obj2 = null;
     if (serviceType == typeof(ComponentSerializationService))
     {
         obj2 = new XomlComponentSerializationService(base.LoaderHost);
     }
     else if (serviceType == typeof(IReferenceService))
     {
         obj2 = new System.Workflow.ComponentModel.Design.ReferenceService(base.LoaderHost);
     }
     else if (serviceType == typeof(IIdentifierCreationService))
     {
         obj2 = new IdentifierCreationService(container, this);
     }
     else if (serviceType == typeof(IWorkflowCompilerOptionsService))
     {
         obj2 = new WorkflowCompilerOptionsService();
     }
     else if (serviceType == typeof(IDesignerVerbProviderService))
     {
         obj2 = new DesignerVerbProviderService();
     }
     if (obj2 != null)
     {
         if (this.createdServices == null)
         {
             this.createdServices = new Hashtable();
         }
         object service = this.createdServices[serviceType];
         this.createdServices[serviceType] = obj2;
         if (service != null)
         {
             this.OnDisposeService(serviceType, service);
         }
     }
     return obj2;
 }
 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;
         }
     }
 }