Ejemplo n.º 1
0
        protected static VariableDef setProperty(List <Nodes.Node.ErrorCheck> result, DefaultObject node, AgentType agentType, string propertyName, string arrayIndexStr, string valueType)
        {
            if (agentType != null)
            {
                IList <PropertyDef> properties = agentType.GetProperties();
                foreach (PropertyDef p in properties)
                {
                    if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                        || p.Name.EndsWith(propertyName)
#endif
                        )
                    {
                        PropertyDef prop = p.Clone();
                        prop.Owner = valueType;

                        VariableDef v = new VariableDef(prop, valueType);

                        if (v != null && !string.IsNullOrEmpty(arrayIndexStr))
                        {
                            v.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                            v.ArrayIndexElement.IsArrayIndex = true;
                            DesignerMethodEnum.parseParam(result, node, null, v.ArrayIndexElement, arrayIndexStr);
                        }

                        return(v);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        private static VariableDef createVariable(List <Nodes.Node.ErrorCheck> result, DefaultObject node, AgentType agentType, string instacneName, string propertyName)
        {
            List <string> tokens = DesignerPropertyEnum.SplitTokens(propertyName);

            Debug.Check(tokens.Count > 0);
            string arrayIndexStr = null;

            if (tokens.Count > 1)
            {
                propertyName  = tokens[0] + "[]";
                arrayIndexStr = tokens[1];
            }

            Nodes.Behavior behavior = node.Behavior as Nodes.Behavior;
            agentType = Plugin.GetInstanceAgentType(instacneName, behavior, agentType);

            if (agentType != null)
            {
                IList <PropertyDef> properties = agentType.GetProperties();

                foreach (PropertyDef p in properties)
                {
                    if (p.Name == propertyName
#if BEHAVIAC_NAMESPACE_FIX
                        || p.Name.EndsWith(propertyName)
#endif
                        )
                    {
                        VariableDef v = new VariableDef(p, instacneName);

                        if (v != null && !string.IsNullOrEmpty(arrayIndexStr))
                        {
                            v.ArrayIndexElement = new MethodDef.Param("ArrayIndex", typeof(int), "int", "ArrayIndex", "ArrayIndex");
                            v.ArrayIndexElement.IsArrayIndex = true;
                            DesignerMethodEnum.parseParam(result, node, null, v.ArrayIndexElement, arrayIndexStr);
                        }

                        return(v);
                    }
                }
            }

            return(null);
        }