Пример #1
0
 public static object PMLObjectToSystemObject(PMLParameter eventParam)
 {
     if (eventParam.IsEnum) return PMLEnumToSystemEnum("Enum." + eventParam.EnumName, eventParam.GetValue());
     else return PMLObjectToSystemObject(eventParam.Type.ToString(), eventParam.GetValue());
 }
Пример #2
0
 public void SetParameter(string paramName, Type type, object value)
 {
     Parameters[paramName] = new PMLParameter(type, value);
     RebuildArrays();
 }
Пример #3
0
 public PML(string name, MethodBase method, object[] values = null)
 {
     this.name = name;
     ParameterInfo[] paramInfo = method.GetParameters();
     int numParameters = paramInfo.Length;
     if (values!=null && numParameters != values.Length)
     {
         Environment.Instance.DebugIf("error", string.Format("PML: Wrong number of arguments for method '{0}' specified (got {1}, espected {2})", method.Name, values.Length, numParameters));
         return;
     }
     for (int i = 0; i < numParameters; i++)
     {
         object paramValue = null;
         if (values != null) paramValue = values[i];
         PMLParameter p;
         if (paramValue is String) p = new PMLParameter(paramInfo[i].ParameterType, (string)paramValue);
         else p = new PMLParameter(paramInfo[i].ParameterType, paramValue);
         this.Parameters[paramInfo[i].Name] = p;
     }
     RebuildArrays();
 }
Пример #4
0
        public PML(string name, string[] parameterNames, string[] parameterTypes, string[] parameterValues = null)
        {
            this.name = name;
            this.parameterNames = parameterNames;
            this.parameterTypes = parameterTypes;
            
            if (parameterValues!=null) this.parameterValues = parameterValues;
            else this.parameterValues = new string[this.parameterNames.Length];

            for (int i = 0; i < parameterNames.Length; i++)
            {
                PMLParameter p;
                if (parameterValues != null) p = new PMLParameter(DataTypes.PMLTypeToSystemType(parameterTypes[i]), DataTypes.PMLObjectToSystemObject(parameterTypes[i], parameterValues[i]));
                else
                {
                    p = PMLParameter.FromStringType(parameterTypes[i]);
                    this.parameterValues[i] = "";
                }
                this.Parameters[parameterNames[i]] = p;
            }
        }
Пример #5
0
 public PML(string name, string parameterName, PMLParameter parameterValue): this(name)
 {
     Parameters.Add(parameterName, parameterValue);
     RebuildArrays();
 }
Пример #6
0
        public static PMLParameter FromStringType(string stringType) 
        {
            if (stringType.StartsWith("Enum."))
            {
                string enumName = stringType.Substring(stringType.IndexOf('.') + 1);
                enumName = enumName.Substring(enumName.IndexOf('.') + 1);

                if (PML.EnumInfo.ContainsKey(enumName))
                {
                    PMLParameter p = new PMLParameter();
                    p.MakeEnum(stringType);
                    return p;
                }
                else return new PMLParameter(typeof(string), null);
            }
            if (Enum.IsDefined(typeof(PMLParameterType), stringType)) return new PMLParameter(DataTypes.PMLTypeToSystemType((PMLParameterType)Enum.Parse(typeof(PMLParameterType), stringType)), null);
            return new PMLParameter();
        }