Exemple #1
0
 public ContextProxy(ITypeDescriptorContext context, Type filterType, List <Project> additionalProjects, bool useProjectItemWrapper)
 {
     this.context               = context;
     this.filterProvider        = (ITypeFilterProvider)Activator.CreateInstance(filterType);
     this.additionalProjects    = additionalProjects;
     this.useProjectItemWrapper = useProjectItemWrapper;
 }
Exemple #2
0
            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
            {
                object convertedValue = value;

                string        stringValue  = value as string;
                ITypeProvider typeProvider = context.GetService(typeof(ITypeProvider)) as ITypeProvider;

                if (context != null && typeProvider != null && !String.IsNullOrEmpty(stringValue))
                {
                    Type type = typeProvider.GetType(stringValue, false);
                    if (type != null)
                    {
                        ITypeFilterProvider typeFilterProvider = context.Instance as ITypeFilterProvider;
                        if (typeFilterProvider != null)
                        {
                            typeFilterProvider.CanFilterType(type, true);
                        }

                        convertedValue = type;
                    }
                }
                else if (stringValue != null && stringValue.Length == 0)
                {
                    convertedValue = null;
                }

                return(convertedValue);
            }
        public override void SetValue(object component, object value)
        {
            string str = value as string;

            if ((str != null) && (str.Length > 0))
            {
                ITypeProvider service = (ITypeProvider)base.ServiceProvider.GetService(typeof(ITypeProvider));
                if (service == null)
                {
                    throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
                }
                Type type = service.GetType(value as string);
                if (type == null)
                {
                    throw new Exception(SR.GetString("Error_TypeNotResolved", new object[] { value }));
                }
                TypeFilterProviderAttribute attribute = this.Attributes[typeof(TypeFilterProviderAttribute)] as TypeFilterProviderAttribute;
                if (attribute != null)
                {
                    ITypeFilterProvider provider2 = null;
                    Type type2 = Type.GetType(attribute.TypeFilterProviderTypeName);
                    if (type2 != null)
                    {
                        provider2 = Activator.CreateInstance(type2, new object[] { base.ServiceProvider }) as ITypeFilterProvider;
                    }
                    if (provider2 != null)
                    {
                        provider2.CanFilterType(type, true);
                    }
                }
                value = type.AssemblyQualifiedName;
            }
            base.RealPropertyDescriptor.SetValue(component, value);
        }
Exemple #4
0
            public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
            {
                object        obj2    = value;
                string        str     = value as string;
                ITypeProvider service = context.GetService(typeof(ITypeProvider)) as ITypeProvider;

                if (((context != null) && (service != null)) && !string.IsNullOrEmpty(str))
                {
                    Type type = service.GetType(str, false);
                    if (type == null)
                    {
                        return(obj2);
                    }
                    ITypeFilterProvider instance = context.Instance as ITypeFilterProvider;
                    if (instance != null)
                    {
                        instance.CanFilterType(type, true);
                    }
                    return(type);
                }
                if ((str != null) && (str.Length == 0))
                {
                    obj2 = null;
                }
                return(obj2);
            }
 public TypeBrowserDialog(IServiceProvider serviceProvider, ITypeFilterProvider filterProvider, string selectedTypeName)
 {
     this.genericParameters = new GenericParameters();
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     this.InitializeDialog(serviceProvider, filterProvider, selectedTypeName);
 }
Exemple #6
0
        protected override bool AcceptType(Type type)
        {
            ITypeFilterProvider filter = Filter;

            if (filter != null)
            {
                return(filter.CanFilterType(type, false));
            }

            return(base.AcceptType(type));
        }
Exemple #7
0
        internal void RefreshTargetWorkflowType()
        {
            if (Activity == null)
            {
                return;
            }

            ITypeFilterProvider typeFilterProvider = Activity as ITypeFilterProvider;
            Type workflowType = Activity.GetType().InvokeMember("TargetWorkflow", BindingFlags.GetProperty | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.ExactBinding, null, Activity, new object[] { }, CultureInfo.InvariantCulture) as Type;

            if (workflowType != null && typeFilterProvider.CanFilterType(workflowType, false))
            {
                ITypeProvider typeProvider = (ITypeProvider)GetService(typeof(ITypeProvider));
                if (typeProvider != null)
                {
                    Type updatedWorkflowType = null;
                    if (workflowType.Assembly == null && typeProvider.LocalAssembly != null)
                    {
                        updatedWorkflowType = typeProvider.LocalAssembly.GetType(workflowType.FullName);
                    }
                    else
                    {
                        updatedWorkflowType = typeProvider.GetType(workflowType.FullName);
                    }

                    if (updatedWorkflowType != null)
                    {
                        workflowType = updatedWorkflowType;
                    }
                }
            }
            else
            {
                workflowType = null;
            }

            if (this.targetWorkflowType != workflowType)
            {
                this.targetWorkflowType = workflowType;
                RefreshHostedActivity();

                if (this.targetWorkflowType is DesignTimeType)
                {
                    HelpText = DR.GetString(DR.BuildTargetWorkflow);
                }
                else
                {
                    HelpText = DR.GetString(DR.SpecifyTargetWorkflow);
                }
            }

            TypeDescriptor.Refresh(Activity);
        }
 public TypeBrowserDialog(IServiceProvider serviceProvider, ITypeFilterProvider filterProvider, string selectedTypeName, System.Workflow.ComponentModel.Compiler.TypeProvider typeProvider)
 {
     this.genericParameters = new GenericParameters();
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     this.localTypeProvider = typeProvider;
     this.serviceProvider = serviceProvider;
     Helpers.AddTypeProviderAssembliesFromRegistry(this.localTypeProvider, serviceProvider);
     this.InitializeDialog(serviceProvider, filterProvider, selectedTypeName);
     this.buttonBrowse.Visible = true;
     this.buttonBrowse.Enabled = true;
     this.buttonBrowse.BringToFront();
 }
        public TypeBrowserDialog(IServiceProvider serviceProvider, ITypeFilterProvider filterProvider, string selectedTypeName, TypeProvider typeProvider)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            this.localTypeProvider = typeProvider;
            this.serviceProvider = serviceProvider;
            // Load assemblies specified in the registry
            Helpers.AddTypeProviderAssembliesFromRegistry(this.localTypeProvider, serviceProvider);

            InitializeDialog(serviceProvider, filterProvider, selectedTypeName);

            this.buttonBrowse.Visible = true;
            this.buttonBrowse.Enabled = true;
            this.buttonBrowse.BringToFront();
        }
 public override void SetValue(object component, object value)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     if (value != null)
     {
         Type type = value as Type;
         ITypeFilterProvider provider = System.Workflow.Activities.Common.PropertyDescriptorUtils.GetComponent(new System.Workflow.Activities.Common.TypeDescriptorContext(base.ServiceProvider, base.RealPropertyDescriptor, component)) as ITypeFilterProvider;
         if (provider != null)
         {
             provider.CanFilterType(type, true);
         }
     }
     base.SetValue(component, value);
 }
Exemple #11
0
 internal void RefreshTargetWorkflowType()
 {
     if (base.Activity != null)
     {
         ITypeFilterProvider activity = base.Activity as ITypeFilterProvider;
         Type type = base.Activity.GetType().InvokeMember("TargetWorkflow", BindingFlags.ExactBinding | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, base.Activity, new object[0], CultureInfo.InvariantCulture) as Type;
         if ((type != null) && activity.CanFilterType(type, false))
         {
             ITypeProvider service = (ITypeProvider)base.GetService(typeof(ITypeProvider));
             if (service != null)
             {
                 Type type2 = null;
                 if ((type.Assembly == null) && (service.LocalAssembly != null))
                 {
                     type2 = service.LocalAssembly.GetType(type.FullName);
                 }
                 else
                 {
                     type2 = service.GetType(type.FullName);
                 }
                 if (type2 != null)
                 {
                     type = type2;
                 }
             }
         }
         else
         {
             type = null;
         }
         if (this.targetWorkflowType != type)
         {
             this.targetWorkflowType = type;
             base.RefreshHostedActivity();
             if (this.targetWorkflowType is DesignTimeType)
             {
                 this.HelpText = DR.GetString("BuildTargetWorkflow", new object[0]);
             }
             else
             {
                 this.HelpText = DR.GetString("SpecifyTargetWorkflow", new object[0]);
             }
         }
         TypeDescriptor.Refresh(base.Activity);
     }
 }
Exemple #12
0
        public override void SetValue(object component, object value)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            if (value != null)
            {
                Type type = value as Type;
                ITypeFilterProvider filterProvider = PropertyDescriptorUtils.GetComponent(new TypeDescriptorContext(ServiceProvider, RealPropertyDescriptor, component)) as ITypeFilterProvider;
                if (filterProvider != null)
                {
                    filterProvider.CanFilterType(type, true); //this will throw an exception if the type is not correctly filterable
                }
            }

            base.SetValue(component, value);
        }
        public override void SetValue(object component, object value)
        {
            string typeName = value as String;

            if (typeName != null && typeName.Length > 0)
            {
                ITypeProvider typeProvider = (ITypeProvider)this.ServiceProvider.GetService(typeof(ITypeProvider));
                if (typeProvider == null)
                {
                    throw new Exception(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));
                }

                Type type = typeProvider.GetType(value as string);
                if (type == null)
                {
                    throw new Exception(SR.GetString(SR.Error_TypeNotResolved, value));
                }

                TypeFilterProviderAttribute filterProviderAttribute = this.Attributes[typeof(TypeFilterProviderAttribute)] as TypeFilterProviderAttribute;
                if (filterProviderAttribute != null)
                {
                    ITypeFilterProvider typeFilterProvider = null;
                    Type typeFilterProviderType            = Type.GetType(filterProviderAttribute.TypeFilterProviderTypeName);
                    if (typeFilterProviderType != null)
                    {
                        typeFilterProvider = Activator.CreateInstance(typeFilterProviderType, new object[] { this.ServiceProvider }) as ITypeFilterProvider;
                    }
                    if (typeFilterProvider != null)
                    {
                        typeFilterProvider.CanFilterType(type, true);
                    }
                }
                // we always store assembly qualified name of the type
                value = type.AssemblyQualifiedName;
            }

            RealPropertyDescriptor.SetValue(component, value);
        }
Exemple #14
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object value)
        {
            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            object obj2 = value;

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (this.editorService != null)
            {
                ITypeFilterProvider         filterProvider = null;
                TypeFilterProviderAttribute attribute      = null;
                if ((typeDescriptorContext.PropertyDescriptor != null) && (typeDescriptorContext.PropertyDescriptor.Attributes != null))
                {
                    attribute = typeDescriptorContext.PropertyDescriptor.Attributes[typeof(TypeFilterProviderAttribute)] as TypeFilterProviderAttribute;
                }
                if (attribute != null)
                {
                    if (!(serviceProvider.GetService(typeof(ITypeProvider)) is ITypeProvider))
                    {
                        throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
                    }
                    System.Type type = System.Type.GetType(attribute.TypeFilterProviderTypeName);
                    if (type != null)
                    {
                        filterProvider = Activator.CreateInstance(type, new object[] { serviceProvider }) as ITypeFilterProvider;
                    }
                }
                if (filterProvider == null)
                {
                    filterProvider = ((typeDescriptorContext.Instance is object[]) ? ((ITypeFilterProvider)((object[])typeDescriptorContext.Instance)[0]) : ((ITypeFilterProvider)typeDescriptorContext.Instance)) as ITypeFilterProvider;
                }
                if (filterProvider == null)
                {
                    filterProvider = value as ITypeFilterProvider;
                }
                if (filterProvider == null)
                {
                    IReferenceService service = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                    if (service != null)
                    {
                        IComponent component = service.GetComponent(typeDescriptorContext.Instance);
                        if (component is ITypeFilterProvider)
                        {
                            filterProvider = component as ITypeFilterProvider;
                        }
                    }
                }
                if (filterProvider == null)
                {
                    filterProvider = typeDescriptorContext.PropertyDescriptor as ITypeFilterProvider;
                }
                string selectedTypeName = value as string;
                if (((value != null) && (typeDescriptorContext.PropertyDescriptor.PropertyType != typeof(string))) && ((typeDescriptorContext.PropertyDescriptor.Converter != null) && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertTo(typeof(string))))
                {
                    selectedTypeName = typeDescriptorContext.PropertyDescriptor.Converter.ConvertTo(typeDescriptorContext, CultureInfo.CurrentCulture, value, typeof(string)) as string;
                }
                using (TypeBrowserDialog dialog = new TypeBrowserDialog(serviceProvider, filterProvider, selectedTypeName))
                {
                    if (DialogResult.OK != this.editorService.ShowDialog(dialog))
                    {
                        return(obj2);
                    }
                    if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(System.Type))
                    {
                        return(dialog.SelectedType);
                    }
                    if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(string))
                    {
                        return(dialog.SelectedType.FullName);
                    }
                    if ((typeDescriptorContext.PropertyDescriptor.Converter != null) && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertFrom(typeDescriptorContext, typeof(string)))
                    {
                        obj2 = typeDescriptorContext.PropertyDescriptor.Converter.ConvertFrom(typeDescriptorContext, CultureInfo.CurrentCulture, dialog.SelectedType.FullName);
                    }
                }
            }
            return(obj2);
        }
Exemple #15
0
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object value)
        {
            if (typeDescriptorContext == null)
            {
                throw new ArgumentNullException("typeDescriptorContext");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            object returnVal = value;

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (editorService != null)
            {
                ITypeFilterProvider         typeFilterProvider = null;
                TypeFilterProviderAttribute typeFilterProvAttr = null;

                if (typeDescriptorContext.PropertyDescriptor != null && typeDescriptorContext.PropertyDescriptor.Attributes != null)
                {
                    typeFilterProvAttr = typeDescriptorContext.PropertyDescriptor.Attributes[typeof(TypeFilterProviderAttribute)] as TypeFilterProviderAttribute;
                }

                if (typeFilterProvAttr != null)
                {
                    ITypeProvider typeProvider = serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
                    if (typeProvider == null)
                    {
                        throw new Exception(SR.GetString(SR.General_MissingService, typeof(ITypeProvider).FullName));
                    }

                    Type typeFilterProviderType = Type.GetType(typeFilterProvAttr.TypeFilterProviderTypeName);
                    //typeProvider.GetType(typeFilterProvAttr.TypeFilterProviderTypeName);
                    if (typeFilterProviderType != null)
                    {
                        typeFilterProvider = Activator.CreateInstance(typeFilterProviderType, new object[] { serviceProvider }) as ITypeFilterProvider;
                    }
                }

                if (typeFilterProvider == null)
                {
                    typeFilterProvider = ((typeDescriptorContext.Instance is object[]) ? ((object[])typeDescriptorContext.Instance)[0] : typeDescriptorContext.Instance) as ITypeFilterProvider;
                }

                if (typeFilterProvider == null)
                {
                    typeFilterProvider = value as ITypeFilterProvider;
                }

                if (typeFilterProvider == null)
                {
                    IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
                    if (rs != null)
                    {
                        IComponent baseComponent = rs.GetComponent(typeDescriptorContext.Instance);
                        if (baseComponent is ITypeFilterProvider)
                        {
                            typeFilterProvider = baseComponent as ITypeFilterProvider;
                        }
                    }
                }

                if (typeFilterProvider == null)
                {
                    typeFilterProvider = typeDescriptorContext.PropertyDescriptor as ITypeFilterProvider;
                }

                string oldTypeName = value as string;
                if (value != null && typeDescriptorContext.PropertyDescriptor.PropertyType != typeof(string) && typeDescriptorContext.PropertyDescriptor.Converter != null && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertTo(typeof(string)))
                {
                    oldTypeName = typeDescriptorContext.PropertyDescriptor.Converter.ConvertTo(typeDescriptorContext, CultureInfo.CurrentCulture, value, typeof(string)) as string;
                }

                using (TypeBrowserDialog dlg = new TypeBrowserDialog(serviceProvider, typeFilterProvider as ITypeFilterProvider, oldTypeName))
                {
                    if (DialogResult.OK == editorService.ShowDialog(dlg))
                    {
                        if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(Type))
                        {
                            returnVal = dlg.SelectedType;
                        }
                        else if (typeDescriptorContext.PropertyDescriptor.PropertyType == typeof(string))
                        {
                            returnVal = dlg.SelectedType.FullName;
                        }
                        else if (typeDescriptorContext.PropertyDescriptor.Converter != null && typeDescriptorContext.PropertyDescriptor.Converter.CanConvertFrom(typeDescriptorContext, typeof(string)))
                        {
                            returnVal = typeDescriptorContext.PropertyDescriptor.Converter.ConvertFrom(typeDescriptorContext, CultureInfo.CurrentCulture, dlg.SelectedType.FullName);
                        }
                    }
                }
            }
            return(returnVal);
        }
			public ContextProxy(ITypeDescriptorContext context, Type filterType)
			{
				this.context = context;
				this.filterProvider = (ITypeFilterProvider)Activator.CreateInstance(filterType);
			}
        internal void InitializeDialog(IServiceProvider serviceProvider, ITypeFilterProvider filterProvider, string selectedTypeName)
        {
            this.serviceProvider = serviceProvider;
            this.sortListViewAscending = true;
            this.refreshTreeView = false;
            this.refreshTypeTextBox = false;
            this.selectedTypeName = selectedTypeName;
            this.typeFilterProvider = filterProvider;

            IDesignerHost designerHost = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
            WorkflowDesignerLoader loader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
            if (designerHost == null || designerHost.RootComponent == null || loader == null || loader.InDebugMode)
                throw new Exception(DR.GetString(DR.Error_WorkflowNotLoaded));

            InitializeComponent();
            CustomInitializeComponent();

            this.genericParametersPropertyGrid.Site = new DummySite(this.serviceProvider);
        }
        public TypeBrowserDialog(IServiceProvider serviceProvider, ITypeFilterProvider filterProvider, string selectedTypeName)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            InitializeDialog(serviceProvider, filterProvider, selectedTypeName);
        }
		public TypeFilterPropertyDescriptor(PropertyDescriptor descriptor, ITypeFilterProvider filterProvider)
			: base(descriptor)
		{
			this.descriptor = descriptor;
			this.filterProvider = filterProvider;
		}
Exemple #20
0
 public TypeFilterPropertyDescriptor(PropertyDescriptor descriptor, ITypeFilterProvider filterProvider)
     : base(descriptor)
 {
     this.descriptor     = descriptor;
     this.filterProvider = filterProvider;
 }
 public ContextProxy(ITypeDescriptorContext context, Type filterType)
 {
     this.context        = context;
     this.filterProvider = (ITypeFilterProvider)Activator.CreateInstance(filterType);
 }