예제 #1
0
 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
 {
     if (context != null && context.Instance != null)
     {
         MethodDiagramViewer mdv = context.Instance as MethodDiagramViewer;
         if (mdv != null)
         {
             WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod;
             if (wcehm != null)
             {
                 if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0)
                 {
                     return(UITypeEditorEditStyle.None);
                 }
             }
         }
         DataTypePointer dp = context.Instance as DataTypePointer;
         if (dp != null)
         {
             if (dp.ReadOnly)
             {
                 return(UITypeEditorEditStyle.None);
             }
             ParameterClass pc = dp as ParameterClass;
             if (pc != null)
             {
                 ConstructorClass cc = pc.Method as ConstructorClass;
                 if (cc != null)
                 {
                     ClassPointer cp = cc.Owner as ClassPointer;
                     if (cp != null)
                     {
                         if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType))
                         {
                             return(UITypeEditorEditStyle.DropDown);
                         }
                     }
                 }
             }
         }
     }
     return(UITypeEditorEditStyle.Modal);
 }
        public IList <ISourceValuePointer> GetServerVariables(ClassPointer root)
        {
            Dictionary <UInt32, IAction> actions = root.GetActions();
            SourceValuePointerList       svs     = new SourceValuePointerList();

            foreach (TaskID tid in Sect0)             //check client action return values
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        List <IAction> acts = hmid.HandlerMethod.GetActions();
                        foreach (IAction act in acts)
                        {
                            if (act.ReturnReceiver != null)
                            {
                                ISourceValuePointer sv = act.ReturnReceiver as ISourceValuePointer;
                                if (sv != null && sv.IsWebServerValue() && !sv.IsWebClientValue())
                                {
                                    svs.AddUnique(sv);
                                }
                            }
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null)
                    {
                        if (a.ReturnReceiver != null)
                        {
                            ISourceValuePointer sv = a.ReturnReceiver as ISourceValuePointer;
                            if (sv != null && sv.IsWebServerValue() && !sv.IsWebClientValue())
                            {
                                svs.AddUnique(sv);
                            }
                        }
                    }
                }
            }
            foreach (TaskID tid in Sect1)             //check server action parameters
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        hmid.HandlerMethod.CollectSourceValues(tid.TaskId);
                        //
                        svs.AddUnique(hmid.HandlerMethod.DownloadProperties);
                        //
                        List <MethodClass> ml = new List <MethodClass>();
                        hmid.HandlerMethod.GetCustomMethods(ml);
                        foreach (MethodClass m in ml)
                        {
                            m.CollectSourceValues(tid.TaskId);
                            svs.AddUnique(m.DownloadProperties);
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null && a.ActionMethod != null && a.ActionMethod.Owner != null)
                    {
                        IFormSubmitter fs = a.ActionMethod.Owner.ObjectInstance as IFormSubmitter;
                        if (fs != null && fs.IsSubmissionMethod(a.ActionMethod.MethodName))
                        {
                            continue;
                        }
                        svs.AddUnique(a.GetServerProperties(tid.TaskId));
                        ISourceValuePointer p = a.ReturnReceiver as ISourceValuePointer;
                        if (p != null)
                        {
                            if (p.IsWebServerValue())
                            {
                                svs.AddUnique(p);
                            }
                        }
                    }
                }
            }
            //collect download (server) variables from client actions
            foreach (TaskID tid in Sect2)
            {
                HandlerMethodID hmid = tid as HandlerMethodID;
                if (hmid != null)
                {
                    WebClientEventHandlerMethod wceh = hmid.HandlerMethod as WebClientEventHandlerMethod;
                    if (wceh != null)
                    {
                        hmid.HandlerMethod.SetActions(actions);
                        hmid.HandlerMethod.CollectSourceValues(tid.TaskId);
                        //
                        svs.AddUnique(hmid.HandlerMethod.DownloadProperties);
                        //
                        List <MethodClass> ml = new List <MethodClass>();
                        hmid.HandlerMethod.GetCustomMethods(ml);
                        foreach (MethodClass m in ml)
                        {
                            m.CollectSourceValues(tid.TaskId);
                            svs.AddUnique(m.DownloadProperties);
                        }
                    }
                }
                else
                {
                    IAction a = tid.GetPublicAction(root);
                    if (a != null)
                    {
                        svs.AddUnique(a.GetServerProperties(tid.TaskId));
                    }
                }
            }
            return(svs);
        }
예제 #3
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             DataTypePointer  typeScope = null;
             ITypeScopeHolder th        = context.Instance as ITypeScopeHolder;
             if (th != null)
             {
                 typeScope = th.GetTypeScope(context.PropertyDescriptor.Name);
             }
             if (typeScope == null)
             {
                 foreach (Attribute a in context.PropertyDescriptor.Attributes)
                 {
                     TypeScopeAttribute ts = a as TypeScopeAttribute;
                     if (ts != null && ts.Scope != null)
                     {
                         if (ts.Scope.IsGenericParameter)
                         {
                             Type[] ctps = ts.Scope.GetGenericParameterConstraints();
                             if (ctps != null && ctps.Length > 0)
                             {
                                 typeScope = new DataTypePointer(new TypePointer(ctps[0]));
                                 break;
                             }
                         }
                         else
                         {
                             typeScope = new DataTypePointer(new TypePointer(ts.Scope));
                             break;
                         }
                     }
                 }
             }
             MethodClass        scopeMethod = null;
             IScopeMethodHolder mh          = context.Instance as IScopeMethodHolder;
             if (mh != null)
             {
                 scopeMethod = mh.GetScopeMethod();
             }
             IWithProject mc = context.Instance as IWithProject;
             if (mc == null)
             {
                 ComponentInterfaceWrapper ciw = context.Instance as ComponentInterfaceWrapper;
                 if (ciw != null)
                 {
                     mc = ciw.Value as IWithProject;
                 }
             }
             if (mc == null)
             {
                 MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("{0} does not implement IWithProject", context.Instance.GetType()));
             }
             else
             {
                 if (mc.Project == null)
                 {
                     MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                 }
                 else
                 {
                     MethodDiagramViewer mdv = mc as MethodDiagramViewer;
                     if (mdv != null)
                     {
                         WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod;
                         if (wcehm != null)
                         {
                             if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0)
                             {
                                 return(value);
                             }
                         }
                     }
                     bool            isMethodReturn = false;
                     IObjectPointer  op             = value as IObjectPointer;
                     DataTypePointer val            = new DataTypePointer();
                     if (op != null)
                     {
                         val.SetDataType(op);
                     }
                     for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++)
                     {
                         MethodReturnAttribute mra = context.PropertyDescriptor.Attributes[i] as MethodReturnAttribute;
                         if (mra != null)
                         {
                             isMethodReturn = true;
                             break;
                         }
                     }
                     //
                     bool                   bUseDropDown = false;
                     EnumWebRunAt           runAt        = EnumWebRunAt.Inherit;
                     PropertyClassWebClient pcwc         = context.Instance as PropertyClassWebClient;
                     if (pcwc != null)
                     {
                         bUseDropDown = true;
                         runAt        = EnumWebRunAt.Client;
                     }
                     else
                     {
                         PropertyClassWebServer pcws = context.Instance as PropertyClassWebServer;
                         if (pcws != null)
                         {
                             bUseDropDown = true;
                             runAt        = EnumWebRunAt.Server;
                         }
                     }
                     if (!bUseDropDown)
                     {
                         ParameterClass pc = context.Instance as ParameterClass;
                         if (pc != null)
                         {
                             ConstructorClass cc = pc.Method as ConstructorClass;
                             if (cc != null)
                             {
                                 ClassPointer cp = cc.Owner as ClassPointer;
                                 if (cp != null)
                                 {
                                     if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType))
                                     {
                                         //use drop down
                                         bUseDropDown = true;
                                     }
                                 }
                             }
                         }
                     }
                     //
                     if (bUseDropDown)
                     {
                         TypeSelector drp = TypeSelector.GetAttributeParameterDialogue(service, runAt, val.BaseClassType);
                         service.DropDownControl(drp);
                         if (drp.SelectedType != null)
                         {
                             val.SetDataType(drp.SelectedType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ConstObjectPointer.VALUE_Type, drp.SelectedType);
                                         }
                                     }
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 value = val;
                             }
                         }
                     }
                     else
                     {
                         Type        typeAttr = null;
                         MethodClass mc0      = scopeMethod;
                         if (mc0 == null)
                         {
                             mc0 = mc as MethodClass;
                         }
                         if (mc0 == null)
                         {
                             MethodDiagramViewer mcv = mc as MethodDiagramViewer;
                             if (mcv != null)
                             {
                                 mc0 = mcv.Method;
                             }
                         }
                         if (mc0 != null)
                         {
                             if (mc.Project.ProjectType == EnumProjectType.WebAppPhp)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Server)
                                 {
                                     typeAttr = typeof(PhpTypeAttribute);
                                 }
                                 else
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                             else if (mc.Project.ProjectType == EnumProjectType.WebAppAspx)
                             {
                                 if (mc0.WebUsage == EnumMethodWebUsage.Client)
                                 {
                                     typeAttr = typeof(JsTypeAttribute);
                                 }
                             }
                         }
                         FrmObjectExplorer dlg = DesignUtil.GetDataTypeSelectionDialogue(mc.Project, scopeMethod, val, isMethodReturn, typeScope, typeAttr);
                         if (service.ShowDialog(dlg) == DialogResult.OK)
                         {
                             val.SetDataType(dlg.SelectedDataType);
                             bool bIsForLocalType = false;
                             if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
                             {
                                 PropertiesWrapper pw = context.Instance as PropertiesWrapper;
                                 if (pw != null)
                                 {
                                     AB_SingleAction sa = pw.Owner as AB_SingleAction;
                                     if (sa != null)
                                     {
                                         ActionAssignInstance aa = sa.ActionData as ActionAssignInstance;
                                         if (aa != null)
                                         {
                                             bIsForLocalType = true;
                                             aa.SetParameterValue(ActionAssignInstance.Instance_Type, dlg.SelectedDataType);
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 ComponentIconLocal cil = context.Instance as ComponentIconLocal;
                                 bIsForLocalType = (cil != null);
                                 if (bIsForLocalType)
                                 {
                                     cil.LocalPointer.ClassType = dlg.SelectedDataType;
                                 }
                             }
                             if (bIsForLocalType)
                             {
                             }
                             else
                             {
                                 ExceptionHandlerList.PropertyDescriptorExceptionHandler pdeh = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler;
                                 if (pdeh != null)
                                 {
                                     pdeh.Handler.ExceptionType = val;
                                 }
                                 else
                                 {
                                     value = val;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }