Example #1
0
        private static Property create(bool bParVar, bool bConst, string typeName, string variableName, string instanceName, string valueStr)
        {
            bool flag = !string.IsNullOrEmpty(variableName);

            if (flag && !bParVar)
            {
                Property property = Agent.CreateProperty(typeName, variableName, valueStr);
                if (flag && property != null && !bConst)
                {
                    property.SetVariableName(variableName);
                    property.SetInstanceNameString(instanceName);
                }
                return(property);
            }
            bool     flag2     = Property.IsAgentPtr(typeName, valueStr);
            Property property2 = new Property(null, bConst);
            object   defaultValue;

            if (!flag2)
            {
                bool flag3 = false;
                if (typeName.StartsWith("vector<"))
                {
                    flag3 = true;
                }
                Type typeFromName;
                if (flag3)
                {
                    int    num       = typeName.IndexOf('<');
                    int    num2      = typeName.IndexOf('>');
                    int    num3      = num2 - num - 1;
                    string typeName2 = typeName.Substring(num + 1, num3);
                    typeFromName = Property.GetTypeFromName(typeName2);
                }
                else
                {
                    typeFromName = Property.GetTypeFromName(typeName);
                }
                defaultValue = StringUtils.FromString(typeFromName, valueStr, flag3);
            }
            else
            {
                defaultValue = null;
            }
            property2.SetDefaultValue(defaultValue);
            if (flag && property2 != null && !bConst)
            {
                property2.SetVariableName(variableName);
            }
            return(property2);
        }
Example #2
0
        private static Property create(bool bParVar, bool bConst, string typeName, string variableName, string instanceName, string valueStr)
        {
            bool flag = !string.IsNullOrEmpty(variableName);

            if (flag && !bParVar)
            {
                Property property = Agent.CreateProperty(typeName, variableName, valueStr);
                if ((flag && (property != null)) && !bConst)
                {
                    property.SetVariableName(variableName);
                    property.SetInstanceNameString(instanceName);
                }
                return(property);
            }
            bool     flag2     = IsAgentPtr(typeName, valueStr);
            Property property2 = new Property(null, bConst);
            object   v         = null;

            if (!flag2)
            {
                bool bStrIsArrayType = false;
                if (typeName.StartsWith("vector<"))
                {
                    bStrIsArrayType = true;
                }
                System.Type typeFromName = null;
                if (bStrIsArrayType)
                {
                    int index  = typeName.IndexOf('<');
                    int length = (typeName.IndexOf('>') - index) - 1;
                    typeFromName = GetTypeFromName(typeName.Substring(index + 1, length));
                }
                else
                {
                    typeFromName = GetTypeFromName(typeName);
                }
                v = StringUtils.FromString(typeFromName, valueStr, bStrIsArrayType);
            }
            else
            {
                v = null;
            }
            property2.SetDefaultValue(v);
            if ((flag && (property2 != null)) && !bConst)
            {
                property2.SetVariableName(variableName);
            }
            return(property2);
        }
Example #3
0
        private static Property create(bool bParVar, bool bConst, string typeName, string variableName, string instanceName, string valueStr)
        {
            bool bValidName = !string.IsNullOrEmpty(variableName);

            if (bValidName)
            {
                if (!bParVar)
                {
                    Property p = Agent.CreateProperty(typeName, variableName, valueStr);

                    if (bValidName && p != null && !bConst)
                    {
                        p.SetVariableName(variableName);
                        p.SetInstanceNameString(instanceName);
                    }

                    return(p);
                }
            }

            var bAgentPtr = IsAgentPtr(typeName, valueStr);

            Property pProperty = new Property(null, bConst);
            object   v         = null;

            if (!bAgentPtr)
            {
                bool bArrayType = false;
                //array type
                if (typeName.StartsWith("vector<"))
                {
                    bArrayType = true;
                }

                Type type = null;
                if (bArrayType)
                {
                    int bracket0 = typeName.IndexOf('<');
                    int bracket1 = typeName.IndexOf('>');
                    int len      = bracket1 - bracket0 - 1;

                    string elementType = typeName.Substring(bracket0 + 1, len);

                    type = GetTypeFromName(elementType);
                }
                else
                {
                    type = GetTypeFromName(typeName);
                }

                v = StringUtils.FromString(type, valueStr, bArrayType);
            }
            else
            {
                v = null;
            }

            pProperty.SetDefaultValue(v);

            if (bValidName && pProperty != null && !bConst)
            {
                pProperty.SetVariableName(variableName);
            }

            return(pProperty);
        }