예제 #1
0
        public void LogVarValue(Agent pAgent, string name, object value)
        {
#if !BEHAVIAC_RELEASE
            if (Config.IsLoggingOrSocketing)
            {
                string valueStr = StringUtils.ToString(value);
                string typeName = "";

                if (!Object.ReferenceEquals(value, null))
                {
                    typeName = Utils.GetNativeTypeName(value.GetType());
                }
                else
                {
                    typeName = "Agent";
                }

                string full_name = name;

                if (!Object.ReferenceEquals(pAgent, null))
                {
                    CMemberBase pMember = pAgent.FindMember(name);

                    if (pMember != null)
                    {
                        string classFullName = pMember.GetClassNameString().Replace(".", "::");
                        full_name = string.Format("{0}::{1}", classFullName, name);
                    }
                }

                LogManager.Instance.Log(pAgent, typeName, full_name, valueStr);
            }
#endif
        }
예제 #2
0
        public void Log(Agent pAgent)
        {
            string value    = StringUtils.ToString(this.m_value);
            string typeName = string.Empty;

            if (!object.ReferenceEquals(this.m_value, null))
            {
                typeName = Utils.GetNativeTypeName(this.m_value.GetType());
            }
            else
            {
                typeName = "Agent";
            }
            string varName = this.m_name;

            if (!object.ReferenceEquals(pAgent, null))
            {
                CMemberBase cMemberBase = pAgent.FindMember(this.m_name);
                if (cMemberBase != null)
                {
                    string text = cMemberBase.GetClassNameString().Replace(".", "::");
                    varName = string.Format("{0}::{1}", text, this.m_name);
                }
            }
            LogManager.Log(pAgent, typeName, varName, value);
        }
예제 #3
0
파일: Properties.cs 프로젝트: i17c/behaviac
        public void Log(Agent pAgent)
        {
            //BEHAVIAC_ASSERT(this.m_changed);

            string valueStr = StringUtils.ToString(this.m_value);
            string typeName = "";

            if (!Object.ReferenceEquals(this.m_value, null))
            {
                typeName = Utils.GetNativeTypeName(this.m_value.GetType());
            }
            else
            {
                typeName = "Agent";
            }

            string full_name = this.m_name;

            if (!Object.ReferenceEquals(pAgent, null))
            {
                CMemberBase pMember = pAgent.FindMember(this.m_name);
                if (pMember != null)
                {
                    string classFullName = pMember.GetClassNameString().Replace(".", "::");
                    full_name = string.Format("{0}::{1}", classFullName, this.m_name);
                }
            }

            LogManager.Log(pAgent, typeName, full_name, valueStr);
#if !BEHAVIAC_RELEASE
            this.m_changed = false;
#endif
        }
예제 #4
0
        public void Set(Agent pAgent, CMemberBase pMember, string variableName, object value, uint varId)
        {
            if (varId == 0u)
            {
                varId = Utils.MakeVariableId(variableName);
            }
            IVariable variable = null;

            if (!this.m_variables.TryGetValue(varId, out variable))
            {
                if (pMember == null)
                {
                    if (pAgent != null)
                    {
                        pMember = pAgent.FindMember(variableName);
                    }
                    else
                    {
                        pMember = Agent.FindMemberBase(variableName);
                    }
                }
                variable = new IVariable(pMember, variableName, varId);
                this.m_variables.Add(varId, variable);
            }
            variable.SetValue(value, pAgent);
        }
예제 #5
0
        public object Get(Agent pAgent, uint varId)
        {
            IVariable variable = null;

            if (this.m_variables.TryGetValue(varId, out variable))
            {
                Property property = variable.GetProperty();
                if (property != null)
                {
                    string refName = property.GetRefName();
                    if (!string.IsNullOrEmpty(refName))
                    {
                        return(this.Get(pAgent, property.GetRefNameId()));
                    }
                }
                return(variable.GetValue(pAgent));
            }
            CMemberBase cMemberBase = pAgent.FindMember(varId);

            if (cMemberBase != null)
            {
                return(cMemberBase.Get(pAgent));
            }
            return(null);
        }
예제 #6
0
        public void SetFromString(Agent pAgent, string variableName, string valueStr)
        {
            string      nameWithoutClassName = Utils.GetNameWithoutClassName(variableName);
            CMemberBase pMember  = pAgent.FindMember(nameWithoutClassName);
            uint        key      = Utils.MakeVariableId(nameWithoutClassName);
            IVariable   variable = null;

            if (this.m_variables.TryGetValue(key, out variable))
            {
                variable.SetFromString(pAgent, pMember, valueStr);
            }
        }
예제 #7
0
파일: Properties.cs 프로젝트: i17c/behaviac
        public void SetFromString(Agent pAgent, string variableName, string valueStr)
        {
            Debug.Check(!string.IsNullOrEmpty(variableName));

            //to skip class name
            string variableNameOnly = Utils.GetNameWithoutClassName(variableName);

            CMemberBase pMember = pAgent.FindMember(variableNameOnly);

            uint varId = Utils.MakeVariableId(variableNameOnly);

            if (this.m_variables.ContainsKey(varId))
            {
                IVariable pVar = this.m_variables[varId];

                pVar.SetFromString(pAgent, pMember, valueStr);
            }
        }
예제 #8
0
파일: Properties.cs 프로젝트: i17c/behaviac
        public object Get(Agent pAgent, uint varId)
        {
            if (!this.m_variables.ContainsKey(varId))
            {
                //possible static property
                CMemberBase pMember = pAgent.FindMember(varId);

                if (pMember != null)
                {
                    object pAddr = pMember.Get(pAgent);

                    return(pAddr);
                }

                Debug.Check(false, "a compatible property is not found");
            }
            else
            {
                //par
                IVariable pVar = this.m_variables[varId];

                {
                    Property refPropety = pVar.GetProperty();
                    if (refPropety != null)
                    {
                        string refName = refPropety.GetRefName();
                        if (!string.IsNullOrEmpty(refName))
                        {
                            return(this.Get(pAgent, refPropety.GetRefNameId()));
                        }
                    }

                    return(pVar.GetValue(pAgent));
                }
            }

            return(null);
        }
예제 #9
0
        public object Get(Agent pAgent, uint varId)
        {
            IVariable variable = null;

            if (!this.m_variables.TryGetValue(varId, out variable))
            {
                CMemberBase base2 = pAgent.FindMember(varId);
                if (base2 != null)
                {
                    return(base2.Get(pAgent));
                }
            }
            else
            {
                Property property = variable.GetProperty();
                if ((property != null) && !string.IsNullOrEmpty(property.GetRefName()))
                {
                    return(this.Get(pAgent, property.GetRefNameId()));
                }
                return(variable.GetValue(pAgent));
            }
            return(null);
        }
예제 #10
0
파일: Properties.cs 프로젝트: i17c/behaviac
        public void Set(Agent pAgent, CMemberBase pMember, string variableName, object value, uint varId)
        {
            Debug.Check(!string.IsNullOrEmpty(variableName));

            if (varId == 0)
            {
                varId = Utils.MakeVariableId(variableName);
            }

            IVariable pVar = null;

            if (!this.m_variables.ContainsKey(varId))
            {
                if (pMember == null)
                {
                    if (pAgent != null)
                    {
                        pMember = pAgent.FindMember(variableName);
                    }
                    else
                    {
                        pMember = Agent.FindMemberBase(variableName);
                    }
                }

                pVar = new IVariable(pMember, variableName, varId);
                behaviac.Debug.Check(pVar != null);
                m_variables[varId] = pVar;
            }
            else
            {
                pVar = this.m_variables[varId];
            }

            pVar.SetValue(value, pAgent);
        }