Beispiel #1
0
 public override bool CanActionBeLinked(TaskID act)
 {
     if (act.Action != null)
     {
         ClassPointer cpr = this.RootPointer.GetExternalExecuterClass(act.Action);
         if (cpr != null)
         {
             return(false);
         }
         DataTypePointer dtp = act.Action.ActionMethod.Owner as DataTypePointer;
         if (dtp != null)
         {
             return(false);
         }
         SetterPointer sp = act.Action.ActionMethod as SetterPointer;
         if (sp != null)
         {
             CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
             if (cpp != null)
             {
                 return(cpp.MemberId == this.PropertyId);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
 public object GetParameterType(uint id)
 {
     if (id == ActionAssignInstance.IntanceTypeId)
     {
         return(new DataTypePointer(new TypePointer(typeof(Type))));
     }
     if (id == ActionAssignInstance.IntanceValueId)
     {
         if (_var != null)
         {
             bool            bOK = false;
             DataTypePointer dp  = _valType.ConstantValue.Value as DataTypePointer;
             if (dp != null)
             {
                 bOK = _var.ClassType.IsAssignableFrom(dp);
             }
             if (!bOK)
             {
                 _valType.SetValue(_var.ClassType);
                 dp = _var.ClassType;
             }
             return(dp);
         }
     }
     return(null);
 }
Beispiel #3
0
        public override bool CanActionBeLinked(TaskID act)
        {
            if (act.Action == null)
            {
                act.LoadActionInstance(this.RootPointer);
            }
            ActionAttachEvent aae = act.Action as ActionAttachEvent;

            if (aae != null)
            {
                return(aae.ExecuterMemberId == ActionExecuterId);
            }
            if (act.Action != null && act.Action.ActionMethod != null)
            {
                ClassPointer cpr = this.RootPointer.GetExternalExecuterClass(act.Action);
                if (cpr != null)
                {
                    return(false);
                }
                DataTypePointer dtp = act.Action.ActionMethod.Owner as DataTypePointer;
                if (dtp != null)
                {
                    return(false);
                }
                CustomMethodPointer cp = act.Action.ActionMethod as CustomMethodPointer;
                if (cp != null)
                {
                    if (cp.ClassId != act.ClassId)
                    {
                        if (act.Action.ExecuterMemberId == ActionExecuterId)
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    SetterPointer sp = act.Action.ActionMethod as SetterPointer;
                    if (sp != null)
                    {
                        CustomPropertyPointer cpp = sp.SetProperty as CustomPropertyPointer;
                        if (cpp == null || cpp.ClassId != act.ClassId)
                        {
                            if (act.Action.ExecuterMemberId == ActionExecuterId)
                            {
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        if (act.Action.ExecuterMemberId == ActionExecuterId)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
 public Type GetResolvedDataType()
 {
     if (ClassType != null && BaseClassType != null)
     {
         if (BaseClassType.IsGenericParameter)
         {
             if (_type.ConcreteType == null)
             {
                 MethodClass mc = this.Owner as MethodClass;
                 if (mc != null)
                 {
                     DataTypePointer dp = mc.GetConcreteType(BaseClassType);
                     if (dp != null)
                     {
                         _type.SetConcreteType(dp);
                     }
                 }
             }
             if (_type.ConcreteType != null)
             {
                 return(_type.ConcreteType.BaseClassType);
             }
         }
     }
     return(BaseClassType);
 }
Beispiel #5
0
        public DataTypePointer GetConcreteType(Type typeParameter)
        {
            if (ClassType != null)
            {
                DataTypePointer dp = _type.GetConcreteType(typeParameter);
                if (dp != null)
                {
                    return(dp);
                }
            }
            IGenericTypePointer igp = null;
            IObjectPointer      op  = Owner;

            while (op != null)
            {
                igp = op as IGenericTypePointer;
                if (igp != null)
                {
                    break;
                }
                op = op.Owner;
            }
            if (igp != null)
            {
                return(igp.GetConcreteType(typeParameter));
            }
            return(null);
        }
        public static void CheckDeclareField(bool isStatic, string fieldName, DataTypePointer fieldType, CodeTypeDeclaration typeDeclaration, string defaultValue)
        {
            CodeMemberField cmf;

            foreach (CodeTypeMember ctm in typeDeclaration.Members)
            {
                cmf = ctm as CodeMemberField;
                if (cmf != null)
                {
                    if (string.CompareOrdinal(cmf.Name, fieldName) == 0)
                    {
                        return;
                    }
                }
            }
            cmf = new CodeMemberField(fieldType.TypeString, fieldName);
            if (!string.IsNullOrEmpty(defaultValue))
            {
                bool   b;
                object val = VPLUtil.ConvertObject(defaultValue, fieldType.BaseClassType, out b);
                if (b)
                {
                    cmf.InitExpression = ObjectCreationCodeGen.ObjectCreationCode(val);
                }
            }
            if (isStatic)
            {
                cmf.Attributes |= MemberAttributes.Static;
            }
            typeDeclaration.Members.Add(cmf);
        }
Beispiel #7
0
 public LocalVariable(DataTypePointer type, string name, UInt32 classId, UInt32 memberId)
 {
     _type     = type;
     _name     = name;
     _classId  = classId;
     _memberId = memberId;
 }
Beispiel #8
0
        public override bool CanActionBeLinked(TaskID act)
        {
            HandlerMethodID hid = act as HandlerMethodID;

            if (hid != null)
            {
                return(hid.ActionId == this.MethodId);
            }
            if (act.Action != null)
            {
                DataTypePointer dtp = act.Action.ActionMethod.Owner as DataTypePointer;
                if (dtp != null)
                {
                    return(false);
                }
                ClassPointer cpr = this.RootPointer.GetExternalExecuterClass(act.Action);
                if (cpr != null)
                {
                    return(false);
                }
                CustomMethodPointer cmp = act.Action.ActionMethod as CustomMethodPointer;
                if (cmp != null)
                {
                    if (cmp.MemberId == MethodId)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 public void SetValueDataType(DataTypePointer type)
 {
     if (ScopeMethod != null)
     {
         ScopeMethod.ReturnValue.SetDataType(type);
     }
 }
Beispiel #10
0
        static public void ValidateParameterValues(ParameterValueCollection parameters, IList <IParameter> ps, IActionMethodPointer owner)
        {
            List <ParameterValue> pvs = new List <ParameterValue>();

            for (int i = 0; i < ps.Count; i++)
            {
                bool bFound = false;
                foreach (ParameterValue pv in parameters)
                {
                    if (string.Compare(ps[i].Name, pv.Name, StringComparison.Ordinal) == 0)
                    {
                        bFound = true;
                        DataTypePointer dp = ps[i] as DataTypePointer;
                        if (dp != null)
                        {
                            pv.SetDataType(dp);
                        }
                        else
                        {
                            pv.SetDataType(ps[i].ParameterLibType);
                        }
                        pvs.Add(pv);
                        break;
                    }
                }
                if (!bFound)
                {
                    ParameterValue p = owner.CreateDefaultParameterValue(i);
                    pvs.Add(p);
                }
            }
            parameters.Clear();
            parameters.AddRange(pvs);
        }
        public object GetParameterType(uint id)
        {
            if (id == ActionAssignComponent.IntanceTypeId)
            {
                return(new DataTypePointer(new TypePointer(typeof(Type))));
            }
            if (id == ActionAssignComponent.IntanceValueId)
            {
                bool            bOK = false;
                DataTypePointer vType;
                if (_var.VariableLibType == null)
                {
                    vType = new DataTypePointer(_var.VariableCustomType);
                }
                else
                {
                    vType = new DataTypePointer(new TypePointer(_var.VariableLibType));
                }
                DataTypePointer dp = _valType.ConstantValue.Value as DataTypePointer;
                if (dp != null)
                {
                    bOK = vType.IsAssignableFrom(dp);
                }
                if (!bOK)
                {
                    _valType.SetValue(_var.ClassType);
                    dp = vType;
                }
                return(dp);
            }

            return(null);
        }
        private void adjustParamType()
        {
            if (_var != null)
            {
                bool bOK = false;
                _valType.SetDataType(new DataTypePointer(new TypePointer(typeof(Type))));
                _valType.SetConstructorTypeScope(_var.ObjectType);
                DataTypePointer vType;
                if (_var.VariableLibType == null)
                {
                    vType = new DataTypePointer(_var.VariableCustomType);
                }
                else
                {
                    vType = new DataTypePointer(new TypePointer(_var.VariableLibType));
                }
                DataTypePointer dp = _valType.ConstantValue.Value as DataTypePointer;
                if (dp != null)
                {
                    bOK = vType.IsAssignableFrom(dp);
                }
                if (!bOK)
                {
                    _valType.SetValue(vType);
                    dp = vType;
                }

                if (!vType.IsAssignableFrom(_val.DataType))
                {
                    _val.SetDataType(dp);
                }
            }
        }
Beispiel #13
0
 public CodeTypeReference GetCodeTypeReference()
 {
     if (BaseClassType == null)
     {
         return(new CodeTypeReference(typeof(object)));
     }
     if (BaseClassType.IsGenericType)
     {
         return(ClassType.GetCodeTypeReference());
     }
     else if (BaseClassType.IsGenericParameter)
     {
         if (_type.ConcreteType == null)
         {
             MethodClass mc = this.Owner as MethodClass;
             if (mc != null)
             {
                 DataTypePointer dp = mc.GetConcreteType(BaseClassType);
                 if (dp != null)
                 {
                     _type.SetConcreteType(dp);
                 }
             }
         }
         if (_type.ConcreteType != null)
         {
             return(_type.ConcreteType.GetCodeTypeReference());
         }
     }
     return(new CodeTypeReference(this.TypeString));
 }
 public SeverStatePointer(string dataName, DataTypePointer dataType, ClassPointer root, EnumWebRunAt runAt)
 {
     _runAt    = runAt;
     _dataName = dataName;
     _dataType = dataType;
     _root     = root;
 }
Beispiel #15
0
 public ComponentIconLocal(ILimnorDesigner designer, LocalVariable pointer, MethodClass method)
     : base(designer, pointer, method)
 {
     _type = pointer.ClassType;
     _name = pointer.Name;
     SetIconImage(Resources._var.ToBitmap());
 }
Beispiel #16
0
 public void SetParameterValue(string name, object value)
 {
     if (string.Compare(name, ActionAssignInstance.Instance_Value, StringComparison.Ordinal) == 0)
     {
         InstanceValue.SetValue(value);
         if (_valueChanged != null)
         {
             _valueChanged(this, EventArgs.Empty);
         }
     }
     if (_var != null)
     {
         if (string.Compare(name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0)
         {
             bool            typeChanged = false;
             DataTypePointer dp          = value as DataTypePointer;
             if (dp != null)
             {
                 if (_var.ClassType.IsAssignableFrom(dp))
                 {
                     InstanceType.SetValue(dp);
                     typeChanged = true;
                 }
             }
             if (typeChanged)
             {
                 if (_valueChanged != null)
                 {
                     _valueChanged(this, EventArgs.Empty);
                 }
             }
         }
     }
 }
Beispiel #17
0
        protected virtual void OnRead(IXmlCodeReader reader, XmlNode dataNode)
        {
            Type t = XmlUtil.GetLibTypeAttribute(dataNode);

            if (t != null)
            {
                if (t.Equals(typeof(ParameterClass)))
                {
                    _type = (DataTypePointer)Activator.CreateInstance(t, Method);
                }
                else
                {
                    _type = (DataTypePointer)Activator.CreateInstance(t);
                }
                reader.ReadObjectFromXmlNode(dataNode, _type, t, this);
                CreateLocalVariable();
                if (_type.IsPrimitive)
                {
                    LocalVariable v = this.LocalPointer;
                    if (v != null)
                    {
                        XmlNode nd = dataNode.SelectSingleNode("Value");
                        if (nd != null)
                        {
                            object val = reader.ReadValue(nd, null, _type.ObjectType);
                            if (val != null)
                            {
                                v.ObjectInstance = val;
                            }
                        }
                    }
                }
            }
        }
 public static void SetReturnType(CodeMemberMethod method, DataTypePointer type)
 {
     if (!method.UserData.Contains(RETURNTYPE))
     {
         method.UserData.Add(RETURNTYPE, type);
     }
 }
 public static void ActionSetInputName(IAction a, string name, DataTypePointer type)
 {
     if (a != null)
     {
         if (a.ActionCondition != null)
         {
             a.ActionCondition.SetActionInputName(name, type.BaseClassType);
         }
         List <ParameterValue> pvs = a.ParameterValues;
         if (pvs != null && pvs.Count > 0)
         {
             foreach (ParameterValue p in pvs)
             {
                 if (p.ValueType == EnumValueType.MathExpression)
                 {
                     MathNodeRoot mr = p.MathExpression as MathNodeRoot;
                     if (mr != null)
                     {
                         mr.SetActionInputName(name, type.BaseClassType);
                     }
                 }
                 else if (p.ValueType == EnumValueType.Property)
                 {
                     ActionInput ai = p.Property as ActionInput;
                     if (ai != null)
                     {
                         ai.SetActionInputName(name, type);
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// set the input variable name to all input variables
 /// </summary>
 /// <param name="name"></param>
 public override void SetInputName(string name, DataTypePointer type)
 {
     if (_logicExpression != null)
     {
         _logicExpression.SetActionInputName(name, type.BaseClassType);
     }
     base.SetInputName(name, type);
 }
Beispiel #21
0
 /// <summary>
 /// set the input variable name to all input variables
 /// </summary>
 /// <param name="name"></param>
 public override void SetInputName(string name, DataTypePointer type)
 {
     if (_list != null && _list.Count > 0)
     {
         _list[0].InputName = name;
         _list[0].InputType = type;
         _list[0].SetInputName(name, type);
     }
 }
Beispiel #22
0
 protected override IList <PropertyDescriptor> OnGetProperties(Attribute[] attrs)
 {
     if (_type != null)
     {
         if (_type.IsGenericType)
         {
             if (_type.TypeParameters != null && _type.TypeParameters.Length > 0)
             {
                 Type[] tcs = _type.BaseClassType.GetGenericArguments();
                 if (tcs != null && tcs.Length == _type.TypeParameters.Length)
                 {
                     List <PropertyDescriptor> lst = new List <PropertyDescriptor>();
                     for (int i = 0; i < tcs.Length; i++)
                     {
                         lst.Add(new PropertyDescriptorForDisplay(this.GetType(), tcs[i].Name, _type.TypeParameters[i].DataTypeName, new Attribute[] { new ParenthesizePropertyNameAttribute(true) }));
                     }
                     return(lst);
                 }
             }
         }
         else if (_type.IsGenericParameter)
         {
             if (_type.ConcreteType == null && this.ClassPointer != null)
             {
                 MethodClass mc = this.ClassPointer.Owner as MethodClass;
                 if (mc != null)
                 {
                     DataTypePointer dp = mc.GetConcreteType(_type.BaseClassType);
                     if (dp != null)
                     {
                         _type.SetConcreteType(dp);
                     }
                 }
             }
             if (_type.ConcreteType != null)
             {
                 List <PropertyDescriptor> lst = new List <PropertyDescriptor>();
                 lst.Add(new PropertyDescriptorForDisplay(this.GetType(), _type.Name, _type.ConcreteType.DataTypeName, new Attribute[] { new ParenthesizePropertyNameAttribute(true) }));
                 return(lst);
             }
         }
         else if (_type.IsPrimitive)
         {
             LocalVariable v = ClassPointer as LocalVariable;
             if (v != null)
             {
                 List <PropertyDescriptor>       lst = new List <PropertyDescriptor>();
                 PropertyDescriptorVariableValue p   = new PropertyDescriptorVariableValue("Value", attrs, "", v, this.GetType());
                 p.ValueChanged += p_ValueChanged;
                 lst.Add(p);
                 return(lst);
             }
         }
     }
     return(null);
 }
Beispiel #23
0
 public virtual void OnPostSerialize(ObjectIDmap objMap, XmlNode objectNode, bool saved, object serializer)
 {
     if (BaseClassType != null)
     {
         if (BaseClassType.IsGenericParameter || BaseClassType.IsGenericType)
         {
             XmlObjectReader xr = serializer as XmlObjectReader;
             if (xr != null)
             {
                 if (xr.ObjectStack.Count > 0)
                 {
                     DataTypePointer dp = null;
                     IEnumerator     ie = xr.ObjectStack.GetEnumerator();
                     while (ie.MoveNext())
                     {
                         if (ie.Current != this)
                         {
                             ActionClass act = ie.Current as ActionClass;
                             if (act != null)
                             {
                                 dp = act.GetConcreteType(this.BaseClassType);
                                 if (dp != null)
                                 {
                                     break;
                                 }
                             }
                             else
                             {
                                 MethodClass mc = ie.Current as MethodClass;
                                 if (mc != null)
                                 {
                                     dp = mc.GetConcreteType(this.BaseClassType);
                                     if (dp != null)
                                     {
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                     if (dp != null)
                     {
                         if (BaseClassType.IsGenericParameter)
                         {
                             _type.SetConcreteType(dp);
                         }
                         else
                         {
                             _type.TypeParameters = dp.TypeParameters;
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #24
0
 /// <summary>
 /// set the input variable name to all input variables
 /// </summary>
 /// <param name="name"></param>
 public override void SetInputName(string name, DataTypePointer type)
 {
     if (_actionList != null)
     {
         for (int k = 0; k < _actionList.Count; k++)
         {
             AB_SingleAction.ActionSetInputName(_actionList[k].Action, name, type);
         }
     }
 }
 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);
     }
 }
Beispiel #26
0
        public override bool IsForThePointer(IObjectPointer pointer)
        {
            DataTypePointer cp = pointer as DataTypePointer;

            if (cp != null && cp.BaseClassType != null)
            {
                return(cp.BaseClassType.Equals(this.ClassType));
            }
            return(false);
        }
        public DataTypePointer[] GetConcreteTypes()
        {
            DataTypePointer p = ValueType;

            if (p != null)
            {
                return(p.TypeParameters);
            }
            return(null);
        }
        public IList <DataTypePointer> GetGenericTypes()
        {
            DataTypePointer p = ValueType;

            if (p != null)
            {
                return(p.GetGenericTypes());
            }
            return(null);
        }
        public CodeTypeReference GetCodeTypeReference()
        {
            DataTypePointer p = ValueType;

            if (p != null)
            {
                return(p.GetCodeTypeReference());
            }
            return(null);
        }
        public DataTypePointer GetConcreteType(Type typeParameter)
        {
            DataTypePointer p = ValueType;

            if (p != null)
            {
                return(p.GetConcreteType(typeParameter));
            }
            return(null);
        }