Пример #1
0
 public static EnumWebActionType GetWebActionType(EnumWebRunAt methodRunAt, EnumWebValueSources parametersSources)
 {
     if (methodRunAt == EnumWebRunAt.Client)
     {
         if (parametersSources == EnumWebValueSources.HasBothValues || parametersSources == EnumWebValueSources.HasServerValues)
         {
             return(EnumWebActionType.Download);
         }
         return(EnumWebActionType.Client);
     }
     else if (methodRunAt == EnumWebRunAt.Server)
     {
         if (parametersSources == EnumWebValueSources.HasBothValues || parametersSources == EnumWebValueSources.HasClientValues)
         {
             return(EnumWebActionType.Upload);
         }
         return(EnumWebActionType.Server);
     }
     else
     {
         if (parametersSources == EnumWebValueSources.HasClientValues)
         {
             return(EnumWebActionType.Client);
         }
         else if (parametersSources == EnumWebValueSources.HasServerValues)
         {
             return(EnumWebActionType.Server);
         }
     }
     return(EnumWebActionType.Unknown);
 }
 public SeverStatePointer(string dataName, DataTypePointer dataType, ClassPointer root, EnumWebRunAt runAt)
 {
     _runAt    = runAt;
     _dataName = dataName;
     _dataType = dataType;
     _root     = root;
 }
 public void LoadAttributeParameterTypes(IWindowsFormsEditorService service, EnumWebRunAt runAt, Type initSelection)
 {
     _svc = service;
     treeView1.LoadAttributeParameterTypes(runAt, initSelection);
     treeView1.AfterSelect += new TreeViewEventHandler(treeView1_AfterSelect);
     treeView1.Click       += new EventHandler(treeView1_Click);
     treeView1.KeyPress    += new KeyPressEventHandler(treeView1_KeyPress);
 }
 public SeverStatePointer(ISourceValuePointer sv, ClassPointer root, EnumWebRunAt runAt)
     : this(sv.DataPassingCodeName, new DataTypePointer(typeof(string)), root, runAt)
 {
     _value = sv;
     _prop  = sv as IProperty;
     if (_prop != null)
     {
         _dataType = new DataTypePointer(_prop.ObjectType);
     }
 }
Пример #5
0
 public EnumWebActionType CheckWebActionType()
 {
     if (_dataTransfers != null)
     {
         EnumWebRunAt        methodRunAt = EnumWebRunAt.Unknown;
         EnumWebValueSources sources     = EnumWebValueSources.Unknown;
         foreach (KeyValuePair <IProperty, ParameterValue> kv in _dataTransfers)
         {
             if (kv.Value != null && kv.Key != null)
             {
                 if (methodRunAt == EnumWebRunAt.Unknown)
                 {
                     if (kv.Key.RunAt == EnumWebRunAt.Client)
                     {
                         methodRunAt = EnumWebRunAt.Client;
                     }
                     else if (kv.Key.RunAt == EnumWebRunAt.Server)
                     {
                         methodRunAt = EnumWebRunAt.Server;
                     }
                 }
                 IList <ISourceValuePointer> list = kv.Value.GetValueSources();
                 if (list != null && list.Count > 0)
                 {
                     sources = WebBuilderUtil.GetActionTypeFromSources(list, sources);
                 }
             }
         }
         if (methodRunAt == EnumWebRunAt.Unknown)
         {
             if (DesignUtil.IsWebClientObject(this.Owner))
             {
                 methodRunAt = EnumWebRunAt.Client;
             }
             else
             {
                 methodRunAt = EnumWebRunAt.Server;
             }
         }
         return(WebBuilderUtil.GetWebActionType(methodRunAt, sources));
     }
     return(EnumWebActionType.Unknown);
 }
        public void CheckWebActionType()
        {
            loadEventAction();
            _webActType = EnumWebActionType.Unknown;
            EnumWebValueSources sources = EnumWebValueSources.Unknown;

            if (_condition != null)
            {
                IList <ISourceValuePointer> conditionSource = _condition.MathExp.GetValueSources();
                if (conditionSource != null)
                {
                    sources = WebBuilderUtil.GetActionTypeFromSources(conditionSource);
                }
            }
            EnumWebRunAt sr = ScopeRunAt;

            if (sr == EnumWebRunAt.Client)
            {
                if (sources == EnumWebValueSources.HasBothValues || sources == EnumWebValueSources.HasServerValues)
                {
                    _webActType = EnumWebActionType.Download;
                }
                else
                {
                    _webActType = EnumWebActionType.Client;
                }
            }
            else if (sr == EnumWebRunAt.Server)
            {
                if (sources == EnumWebValueSources.HasBothValues || sources == EnumWebValueSources.HasClientValues)
                {
                    _webActType = EnumWebActionType.Upload;
                }
                else
                {
                    _webActType = EnumWebActionType.Server;
                }
            }
        }
        public static TypeSelector GetAttributeParameterDialogue(IWindowsFormsEditorService service, EnumWebRunAt runAt, Type initSelection)
        {
            TypeSelector dlg = new TypeSelector();

            dlg.LoadAttributeParameterTypes(service, runAt, initSelection);
            return(dlg);
        }
Пример #8
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);
 }
 public void SetRunAt(EnumWebRunAt runAt)
 {
     _runAt = runAt;
 }