Esempio n. 1
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);
            AdapterActivity activity = this.Activity as AdapterActivity;

            if (activity != null && activity.Type != null && activity.MethodName != null)
            {
                MethodInfo mi = activity.Type.GetMethod(activity.MethodName);
                if (mi != null)
                {
                    //get the parameters and add them as properties
                    ParameterInfo[] pis = mi.GetParameters();
                    if (pis != null)
                    {
                        foreach (ParameterInfo pi in pis)
                        {
                            //add a new parameter
                            properties[pi.Name] = new ParameterBindingPropertyDescriptor <AdapterActivity>(pi.Name, pi.ParameterType, new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), new BrowsableAttribute(true), new CategoryAttribute("Parameters"), new DescriptionAttribute(pi.ParameterType.FullName), new EditorAttribute(typeof(BindUITypeEditor), typeof(UITypeEditor)) });
                        }
                        if ((mi.ReturnType != typeof(void)))
                        {
                            properties["(ReturnValue)"] = new ParameterBindingPropertyDescriptor <AdapterActivity>("(ReturnValue)", mi.ReturnType, new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), new BrowsableAttribute(true), new CategoryAttribute("Parameters"), new DescriptionAttribute(mi.ReturnType.FullName), new EditorAttribute(typeof(BindUITypeEditor), typeof(UITypeEditor)) });
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 internal void GetParameterPropertyDescriptors(IDictionary properties)
 {
     if (this.Site != null)
     {
         ITypeProvider provider = (ITypeProvider)this.Site.GetService(typeof(ITypeProvider));
         if (provider == null)
         {
             throw new InvalidOperationException("Missing ITypeProvider Service");
         }
         if ((this.ConnectorActivityName != null) && !string.IsNullOrEmpty(this.ConnectorActivityName.Trim()))
         {
             Activity activity = Helpers.GetRootActivity(this).GetActivityByName(this.ConnectorActivityName, false) as Activity;
             if (activity != null)
             {
                 Type   type       = activity.GetType().InvokeMember("Type", BindingFlags.ExactBinding | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance, null, activity, new object[0]) as Type;
                 string methodname = activity.GetType().InvokeMember("MethodName", BindingFlags.ExactBinding | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance, null, activity, new object[0]) as string;
                 if (type != null && !string.IsNullOrEmpty(methodname))
                 {
                     MethodInfo mi = type.GetMethod(methodname);
                     if (mi != null && mi.ReturnType != typeof(void))
                     {
                         Trace.WriteLine(string.Format("GetParameterPropertyDescriptors - ReturnType={0}", mi.ReturnType));
                         PropertyDescriptor descriptor = new ParameterBindingPropertyDescriptor <ReturnActivity>("(ReturnValue)", mi.ReturnType, new Attribute[] { DesignOnlyAttribute.Yes, new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden), new BrowsableAttribute(true), new CategoryAttribute("Parameters"), new DescriptionAttribute(mi.ReturnType.FullName), new EditorAttribute(typeof(BindUITypeEditor), typeof(UITypeEditor)) });
                         if (descriptor != null)
                         {
                             properties[descriptor.Name] = descriptor;
                         }
                     }
                 }
             }
         }
     }
 }