public override object FromStringValue(List <Nodes.Node.ErrorCheck> result, DefaultObject node, object parentObject, Type type, string str) { if (type != typeof(RightValueDef)) { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); } if (str.Length == 0 || str.Length == 2 && str == "\"\"") { return(null); } if (!str.StartsWith("const")) { int pos = str.IndexOf('('); if (pos < 0) { VariableDef var = DesignerPropertyEnum.parsePropertyVar(result, node, str); return(new RightValueDef(var)); } else { Nodes.Behavior behavior = node.Behavior as Nodes.Behavior; AgentType agentType = (behavior != null) ? behavior.AgentType : null; string valueClass = VariableDef.kSelfMethod; MethodDef method = DesignerMethodEnum.parseMethodString(result, node, agentType, this.MethodType, str); if (method == null) { string className = Plugin.GetClassName(str); method = DesignerMethodEnum.parseMethodString(result, node, Plugin.GetInstanceAgentType(className, behavior, null), this.MethodType, str); valueClass = className + VariableDef.kMethod; } string instanceName = Plugin.GetInstanceName(str); if (!string.IsNullOrEmpty(instanceName)) { valueClass = instanceName + VariableDef.kMethod; } return(new RightValueDef(method, valueClass)); } } else { VariableDef var = this.parseConstVar(result, node, parentObject, str); if (var != null) { return(new RightValueDef(var)); } } return(null); }
public override object FromStringValue(NodeTag.DefaultObject node, object parentObject, Type type, string str) { if (type != typeof(RightValueDef)) { throw new Exception(Resources.ExceptionDesignerAttributeInvalidType); } if (str.Length == 0 || str.Length == 2 && str == "\"\"") { return(null); } if (!str.StartsWith("const")) { int pos = str.IndexOf('('); if (pos < 0) { VariableDef var = this.parsePropertyVar(node, str); return(new RightValueDef(var)); } else { //Ship::Getter(100,50,50) Behaviac.Design.Nodes.Behavior behavior = node.Behavior as Behaviac.Design.Nodes.Behavior; string valueClass = VariableDef.kSelfMethod; MethodDef method = DesignerMethodEnum.parseMethodString(node, behavior.AgentType, this.MethodType, str); if (method == null) { string className = Plugin.GetClassName(str); method = DesignerMethodEnum.parseMethodString(node, Plugin.GetInstanceAgentType(className), this.MethodType, str); valueClass = className + VariableDef.kMethod; } //Debug.Check(method != null); string instanceName = Plugin.GetInstanceName(str); if (!string.IsNullOrEmpty(instanceName)) { valueClass = instanceName + VariableDef.kMethod; } return(new RightValueDef(method, valueClass)); } } else { VariableDef var = this.parseConstVar(node, parentObject, str); if (var != null) { return(new RightValueDef(var)); } } return(null); }