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);
        }
Exemple #2
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);
        }
        internal static string GenerateUniqueIdentifier(IServiceProvider serviceProvider, string baseIdentifier, string[] existingNames)
        {
            CodeDomProvider provider = null;

            if (serviceProvider != null)
            {
                provider = serviceProvider.GetService(typeof(CodeDomProvider)) as CodeDomProvider;
                if (provider == null)
                {
                    IdentifierCreationService service = serviceProvider.GetService(typeof(IIdentifierCreationService)) as IdentifierCreationService;
                    if (service != null)
                    {
                        provider = service.Provider;
                    }
                }
            }
            if (provider != null)
            {
                baseIdentifier = provider.CreateValidIdentifier(baseIdentifier);
            }
            baseIdentifier = baseIdentifier.Replace('.', '_');
            baseIdentifier = baseIdentifier.Replace('/', '_');
            baseIdentifier = baseIdentifier.Replace('(', '_');
            baseIdentifier = baseIdentifier.Replace(')', '_');
            baseIdentifier = baseIdentifier.Replace(" ", "");
            ArrayList list = new ArrayList(existingNames);
            int       num  = 1;
            string    str  = string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[] { baseIdentifier, num });

            list.Sort();
            while (list.BinarySearch(str.ToLowerInvariant(), StringComparer.OrdinalIgnoreCase) >= 0)
            {
                str = string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[] { baseIdentifier, num });
                num++;
            }
            return(str);
        }
        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;
 }