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);
        }
Exemple #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);
        }
Exemple #3
0
        public void SetFromString(Agent pAgent, CMemberBase pMember, string valueString)
        {
            if (pMember == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(valueString))
            {
                object value = StringUtils.FromString(pMember.MemberType, valueString, false);

                if (!(Details.Equal(this.m_value, value)))
                {
                    this.m_value = value;
#if !BEHAVIAC_RELEASE
                    this.m_changed = true;
#endif
                    if (!Object.ReferenceEquals(pAgent, null))
                    {
                        //const CMemberBase* pMember = pAgent.FindMember(variableName);

                        if (pMember != null)
                        {
                            pMember.Set(pAgent, value);
                        }
                    }
                }
            }
        }
Exemple #4
0
        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
        }
Exemple #5
0
 public Property(CMemberBase pMemberBase, bool bIsConst)
 {
     m_memberBase         = pMemberBase;
     m_variableId         = 0;
     m_bValidDefaultValue = false;
     m_bIsConst           = bIsConst;
 }
        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);
        }
Exemple #7
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
        }
Exemple #8
0
 public IVariable(CMemberBase pMember, Property property_)
 {
     this.m_property     = property_;
     this.m_pMember      = pMember;
     this.m_instantiated = 1;
     this.m_name         = this.m_property.GetVariableName();
     this.m_id           = this.m_property.GetVariableId();
 }
Exemple #9
0
 public IVariable(CMemberBase pMember, string variableName, uint id)
 {
     this.m_id           = id;
     this.m_name         = variableName;
     this.m_property     = null;
     this.m_pMember      = pMember;
     this.m_instantiated = 1;
 }
Exemple #10
0
 public void SetStaticVariable <VariableType>(CMemberBase pMember, string variableName, VariableType value, string staticClassName, uint variableId)
 {
     if (!this.m_static_variables.ContainsKey(staticClassName))
     {
         this.m_static_variables[staticClassName] = new Variables();
     }
     this.m_static_variables[staticClassName].Set(null, pMember, variableName, value, variableId);
 }
Exemple #11
0
        public static Property Create(string value, CMemberBase pMemberBase, bool bConst)
        {
            Property property = new Property(pMemberBase, bConst);

            if (string.IsNullOrEmpty(value) || property.SetDefaultValue(value))
            {
            }
            return(property);
        }
        public object run(Agent parent, Agent parHolder)
        {
            if (this.m_params != null)
            {
                for (int i = 0; i < this.m_params.Length; i++)
                {
                    Property paramProperty = this.m_params[i].paramProperty;
                    if (paramProperty != null)
                    {
                        this.m_param_values[i] = paramProperty.GetValue(parent, parHolder);
                    }
                    if (this.m_params[i].paramStructMembers != null)
                    {
                        Type type = this.m_param_values[i].GetType();
                        Agent.CTagObjectDescriptor descriptorByName = Agent.GetDescriptorByName(type.get_FullName());
                        foreach (KeyValuePair <string, Property> current in this.m_params[i].paramStructMembers)
                        {
                            CMemberBase member = descriptorByName.GetMember(current.get_Key());
                            if (member != null)
                            {
                                object value = current.get_Value().GetValue(parent, parHolder);
                                member.Set(this.m_param_values[i], value);
                            }
                        }
                    }
                }
            }
            object result = this.method_.Invoke(parent, this.m_param_values);

            if (this.m_params != null)
            {
                for (int j = 0; j < this.m_params.Length; j++)
                {
                    Property paramProperty2 = this.m_params[j].paramProperty;
                    if (paramProperty2 != null)
                    {
                        object v = this.m_param_values[j];
                        paramProperty2.SetValue(parHolder, v);
                    }
                    if (this.m_params[j].paramStructMembers != null)
                    {
                        Type type2 = this.m_param_values[j].GetType();
                        Agent.CTagObjectDescriptor descriptorByName2 = Agent.GetDescriptorByName(type2.get_FullName());
                        foreach (KeyValuePair <string, Property> current2 in this.m_params[j].paramStructMembers)
                        {
                            CMemberBase member2 = descriptorByName2.GetMember(current2.get_Key());
                            if (member2 != null)
                            {
                                object v2 = member2.Get(this.m_param_values[j]);
                                current2.get_Value().SetValue(parHolder, v2);
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #13
0
 public IVariable(IVariable copy)
 {
     this.m_id           = copy.m_id;
     this.m_name         = copy.m_name;
     this.m_property     = copy.m_property;
     this.m_pMember      = copy.m_pMember;
     this.m_instantiated = copy.m_instantiated;
     this.m_value        = copy.m_value;
 }
Exemple #14
0
 public static Property Create(string typeName, string variableName, string value, bool bStatic, bool bConst)
 {
     if (!bConst)
     {
         string instanceName = null;
         bool   flag         = Utils.IsParVar(variableName);
         string text;
         if (flag)
         {
             text = string.Format("{0}::{1}", typeName, variableName);
         }
         else
         {
             text = Property.ParseInstanceNameProperty(variableName, ref instanceName);
         }
         bool flag2 = false;
         if (!string.IsNullOrEmpty(text))
         {
             flag2 = Property.ms_properties.ContainsKey(text);
         }
         if (!flag2)
         {
             Property property = Property.create(flag, bConst, typeName, text, instanceName, value);
             if (!string.IsNullOrEmpty(text))
             {
                 Property.ms_properties.set_Item(text, property);
             }
             return(property.clone());
         }
         Property property2 = Property.ms_properties.get_Item(text);
         Property property3 = property2.clone();
         if (!string.IsNullOrEmpty(value) && !Property.IsAgentPtr(typeName, value))
         {
             property3.SetDefaultValue(value);
         }
         return(property3);
     }
     else
     {
         CMemberBase cMemberBase   = null;
         bool        flag3         = !string.IsNullOrEmpty(variableName);
         string      instanceName2 = null;
         string      text2         = variableName;
         if (flag3)
         {
             text2       = Property.ParseInstanceNameProperty(variableName, ref instanceName2);
             cMemberBase = Agent.FindMemberBase(text2);
         }
         if (cMemberBase != null)
         {
             return(cMemberBase.CreateProperty(value, true));
         }
         bool bParVar = flag3 && Utils.IsParVar(variableName);
         return(Property.create(bParVar, bConst, typeName, text2, instanceName2, value));
     }
 }
Exemple #15
0
        public static Property CreateProperty(string typeName, string propertyName, string defaultValue)
        {
            CMemberBase base2 = FindMemberBase(propertyName);

            if (base2 != null)
            {
                return(base2.CreateProperty(defaultValue, false));
            }
            return(null);
        }
Exemple #16
0
        public void SetStaticVariable <VariableType>(CMemberBase pMember, string variableName, VariableType value, string staticClassName, uint variableId)
        {
            if (!this.m_static_variables.ContainsKey(staticClassName))
            {
                this.m_static_variables.set_Item(staticClassName, new Variables());
            }
            Variables variables = this.m_static_variables.get_Item(staticClassName);

            variables.Set(null, pMember, variableName, value, variableId);
        }
        public static Property CreateProperty(string typeName, string propertyName, string defaultValue)
        {
            CMemberBase cMemberBase = Agent.FindMemberBase(propertyName);

            if (cMemberBase != null)
            {
                return(cMemberBase.CreateProperty(defaultValue, false));
            }
            return(null);
        }
Exemple #18
0
        public object run(Agent parent, Agent parHolder)
        {
            if (this.m_params != null)
            {
                for (int i = 0; i < this.m_params.Length; i++)
                {
                    Property paramProperty = this.m_params[i].paramProperty;
                    if (paramProperty != null)
                    {
                        this.m_param_values[i] = paramProperty.GetValue(parent, parHolder);
                    }
                    if (this.m_params[i].paramStructMembers != null)
                    {
                        Agent.CTagObjectDescriptor descriptorByName = Agent.GetDescriptorByName(this.m_param_values[i].GetType().FullName);
                        foreach (KeyValuePair <string, Property> pair in this.m_params[i].paramStructMembers)
                        {
                            CMemberBase member = descriptorByName.GetMember(pair.Key);
                            if (member != null)
                            {
                                object v = pair.Value.GetValue(parent, parHolder);
                                member.Set(this.m_param_values[i], v);
                            }
                        }
                    }
                }
            }
            object obj3 = this.method_.Invoke(parent, this.m_param_values);

            if (this.m_params != null)
            {
                for (int j = 0; j < this.m_params.Length; j++)
                {
                    Property property2 = this.m_params[j].paramProperty;
                    if (property2 != null)
                    {
                        object obj4 = this.m_param_values[j];
                        property2.SetValue(parHolder, obj4);
                    }
                    if (this.m_params[j].paramStructMembers != null)
                    {
                        Agent.CTagObjectDescriptor descriptor2 = Agent.GetDescriptorByName(this.m_param_values[j].GetType().FullName);
                        foreach (KeyValuePair <string, Property> pair2 in this.m_params[j].paramStructMembers)
                        {
                            CMemberBase base3 = descriptor2.GetMember(pair2.Key);
                            if (base3 != null)
                            {
                                object obj5 = base3.Get(this.m_param_values[j]);
                                pair2.Value.SetValue(parHolder, obj5);
                            }
                        }
                    }
                }
            }
            return(obj3);
        }
Exemple #19
0
        public static Property Create(string typeName, string variableName, string value, bool bStatic, bool bConst)
        {
            if (!bConst)
            {
                string str  = null;
                string str2 = null;
                bool   flag = Utils.IsParVar(variableName);
                if (flag)
                {
                    str2 = string.Format("{0}::{1}", typeName, variableName);
                }
                else
                {
                    str2 = ParseInstanceNameProperty(variableName, ref str);
                }
                bool flag2 = false;
                if (!string.IsNullOrEmpty(str2))
                {
                    flag2 = ms_properties.ContainsKey(str2);
                }
                if (!flag2)
                {
                    Property property = create(flag, bConst, typeName, str2, str, value);
                    if (!string.IsNullOrEmpty(str2))
                    {
                        ms_properties[str2] = property;
                    }
                    return(property.clone());
                }
                Property property4 = ms_properties[str2].clone();
                if (!string.IsNullOrEmpty(value) && !IsAgentPtr(typeName, value))
                {
                    property4.SetDefaultValue(value);
                }
                return(property4);
            }
            CMemberBase base2        = null;
            bool        flag4        = !string.IsNullOrEmpty(variableName);
            string      instanceName = null;
            string      propertyName = variableName;

            if (flag4)
            {
                propertyName = ParseInstanceNameProperty(variableName, ref instanceName);
                base2        = Agent.FindMemberBase(propertyName);
            }
            if (base2 != null)
            {
                return(base2.CreateProperty(value, true));
            }
            bool bParVar = flag4 && Utils.IsParVar(variableName);

            return(create(bParVar, bConst, typeName, propertyName, instanceName, value));
        }
Exemple #20
0
        public IVariable(CMemberBase pMember, string variableName, uint id)
        {
            m_id           = id;
            m_name         = variableName;
            m_property     = null;
            m_pMember      = pMember;
            m_instantiated = 1;
#if !BEHAVIAC_RELEASE
            m_changed = true;
#endif
        }
        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);
            }
        }
 public CMemberBase FindMember(uint propertyId)
 {
     Agent.CTagObjectDescriptor descriptor = this.GetDescriptor();
     for (int i = 0; i < descriptor.ms_members.Count; i++)
     {
         CMemberBase cMemberBase = descriptor.ms_members[i];
         if (cMemberBase.GetId().GetId() == propertyId)
         {
             return(cMemberBase);
         }
     }
     return(null);
 }
Exemple #23
0
 public void SetVariableRegistry(CMemberBase pMember, string variableName, object value, string staticClassName, uint variableId)
 {
     if (!string.IsNullOrEmpty(variableName))
     {
         if (!string.IsNullOrEmpty(staticClassName))
         {
             Context.GetContext(this.GetContextId()).SetStaticVariable <object>(pMember, variableName, value, staticClassName, variableId);
         }
         else
         {
             this.Variables.Set(this, pMember, variableName, value, variableId);
         }
     }
 }
Exemple #24
0
        public IVariable(CMemberBase pMember, Property property_)
        {
            m_property     = property_;
            m_pMember      = pMember;
            m_instantiated = 1;

            Debug.Check(this.m_property != null);

            this.m_name = this.m_property.GetVariableName();
            this.m_id   = this.m_property.GetVariableId();
#if !BEHAVIAC_RELEASE
            m_changed = true;
#endif
        }
Exemple #25
0
        /**
         * if staticClassName is no null, it is for static variable
         */
        public void SetStaticVariable <VariableType>(CMemberBase pMember, string variableName, VariableType value, string staticClassName, uint variableId)
        {
            Debug.Check(!string.IsNullOrEmpty(variableName));
            Debug.Check(!string.IsNullOrEmpty(staticClassName));

            if (!m_static_variables.ContainsKey(staticClassName))
            {
                m_static_variables[staticClassName] = new Variables();
            }

            Variables variables = m_static_variables[staticClassName];

            variables.Set(null, pMember, variableName, value, variableId);
        }
Exemple #26
0
 protected Property(Property copy)
 {
     this.m_varaibleName     = copy.m_varaibleName;
     this.m_varaibleFullName = copy.m_varaibleFullName;
     this.m_variableId       = copy.m_variableId;
     this.m_refParName       = copy.m_refParName;
     this.m_refParNameId     = copy.m_refParNameId;
     this.m_memberBase       = copy.m_memberBase;
     this.m_pt                 = copy.m_pt;
     this.m_instanceName       = copy.m_instanceName;
     this.m_bValidDefaultValue = copy.m_bValidDefaultValue;
     this.m_defaultValue       = copy.m_defaultValue;
     this.m_bIsConst           = copy.m_bIsConst;
 }
Exemple #27
0
        /**
         * if staticClassName is no null, it is for static variable
         */
        /// <summary>
        /// if the caller's third parameter's type is object
        /// </summary>
        /// <param name="pMember"></param>
        /// <param name="variableName"></param>
        /// <param name="value"></param>
        /// <param name="staticClassName"></param>
        /// <param name="variableId"></param>
        public void SetStaticVariableObject(CMemberBase pMember, string variableName, object value, string staticClassName, uint variableId)
        {
            Debug.Check(!string.IsNullOrEmpty(variableName));
            Debug.Check(!string.IsNullOrEmpty(staticClassName));

            if (!m_static_variables.ContainsKey(staticClassName))
            {
                m_static_variables[staticClassName] = new Variables();
            }

            Variables variables = m_static_variables[staticClassName];

            //TODO: ture and false add by notice by below
            variables.SetObject(true, null, false, pMember, variableName, value, variableId);
        }
Exemple #28
0
        public CMemberBase FindMember(uint propertyId)
        {
            CTagObjectDescriptor descriptor = this.GetDescriptor();
            CMemberBase          base2      = null;

            for (int i = 0; i < descriptor.ms_members.Count; i++)
            {
                base2 = descriptor.ms_members[i];
                if (base2.GetId().GetId() == propertyId)
                {
                    return(base2);
                }
            }
            return(null);
        }
Exemple #29
0
 public void SetFromString(Agent pAgent, CMemberBase pMember, string valueString)
 {
     if (!string.IsNullOrEmpty(valueString) && pMember != null)
     {
         object obj = StringUtils.FromString(pMember.MemberType, valueString, false);
         if (!Details.Equal(this.m_value, obj))
         {
             this.m_value = obj;
             if (!object.ReferenceEquals(pAgent, null) && pMember != null)
             {
                 pMember.Set(pAgent, obj);
             }
         }
     }
 }
Exemple #30
0
 public Property(CMemberBase pMemberBase, bool bIsConst)
 {
     this.m_memberBase         = pMemberBase;
     this.m_variableId         = 0u;
     this.m_bValidDefaultValue = false;
     this.m_bIsConst           = bIsConst;
     if (this.m_memberBase != null)
     {
         this.m_pt = this.m_memberBase.GetParentType();
     }
     else
     {
         this.m_pt = ParentType.PT_PAR;
     }
 }