Пример #1
0
 /// <summary>
 /// Store ObjectInfo if not exists
 /// </summary>
 /// <param name="objectToStore">The ObjectStorage that should be stored</param>
 private void storeObjectInfo(RefScrObjectStorage objectToStore)
 {
     if (!Projector.ObjectInfo.knownOjectMethods.ContainsKey(objectToStore.originObjectName))
     {
         Projector.ObjectInfo.knownOjectMethods.Add(objectToStore.originObjectName, objectToStore);
     }
 }
Пример #2
0
        /// <summary>
        /// Updates the current collected Infomation in objStore about
        /// the current State.
        /// usefull after some changes happens
        /// </summary>
        /// <param name="execObject">the object that are executable</param>
        /// <param name="executeableObj"></param>
        /// <param name="objStore"></param>
        private void updatePropInfos(Object execObject, Type executeableObj, RefScrObjectStorage objStore)
        {
            PropertyInfo[] propInfo = executeableObj.GetProperties();

            foreach (PropertyInfo prop in propInfo)
            {
                if (prop.CanRead && prop.CanWrite)
                {
                    Object          val   = null;
                    ParameterInfo[] pInfo = prop.GetIndexParameters();
                    if (pInfo.Count() < 1 && executeableObj != null)
                    {
                        try
                        {
                            val = prop.GetValue(execObject, null);
                        }
                        catch (Exception e) { }
                    }

                    switch (prop.PropertyType.Name)
                    {
                    case "In32":
                        objStore.Integers.Add(prop.Name, val);
                        break;

                    case "String":
                        objStore.Strings.Add(prop.Name, val);
                        break;

                    case "Boolean":
                        objStore.Booleans.Add(prop.Name, val);
                        break;
                    }
                }
            }
        }
Пример #3
0
        public List <string> getObjectInfo(Object obj, Boolean getFullProp)
        {
            List <string> maskData = new List <string>();

            if (obj == null)
            {
                return(null);
            }

            // "& SETCOORDS ? ? ? ?" + Projector.ReflectionScript.MASK_DELIMITER + "METHOD" + Projector.ReflectionScript.MASK_DELIMITER + ". setCoords INT INT INT INT"

            Type executeableObj = obj.GetType();

            MethodInfo[] myMethodInfos = executeableObj.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            if (myMethodInfos.Count() < 1)
            {
                return(null);
            }

            RefScrObjectStorage objStore = new RefScrObjectStorage();

            if (getFullProp)
            {
                this.updatePropInfos(obj, executeableObj, objStore);
            }
            else
            {
                this.updatePropInfos(null, executeableObj, objStore);
            }

            string objStr = obj.ToString();

            string[] objParts  = objStr.Split(',');
            string[] nameParts = objParts[0].Split('.');
            string   objname   = nameParts[nameParts.Count() - 1];

            objStore.originObjectName = objname;



            foreach (MethodInfo mInfo in myMethodInfos)
            {
                // dirty way to get the name
                // TODO: find better soultion



                string maskStr   = "&" + objname + " " + mInfo.Name.ToUpper();
                string paramPart = ". " + mInfo.Name;
                objStore.methods.Add(mInfo);
                objStore.methodNames.Add(mInfo.Name);

                ParameterInfo[] parameters = mInfo.GetParameters();
                foreach (ParameterInfo parInfo in parameters)
                {
                    string partype = parInfo.ParameterType.Name;
                    maskStr   += " ?";
                    paramPart += " " + partype;
                }



                string keepMe = maskStr;
                maskStr += Projector.Script.ReflectionScript.MASK_DELIMITER + "METHOD" + Projector.Script.ReflectionScript.MASK_DELIMITER + paramPart;

                maskData.Add(maskStr);
                objStore.methodMask.Add(maskStr);

                string returnVar = mInfo.ReturnType.FullName;
                string retval    = this.getReturnValue(returnVar);
                if (retval != "")
                {
                    //maskStr = retval + " " + maskStr;
                    maskStr = "% = " + keepMe + Projector.Script.ReflectionScript.MASK_DELIMITER + "METHOD ASSIGN" + Projector.Script.ReflectionScript.MASK_DELIMITER + retval + " = " + paramPart;
                    maskData.Add(maskStr);
                    objStore.methodMask.Add(maskStr);
                }
            }
            this.storeObjectInfo(objStore);
            this.lastObjectInfo = objStore;
            return(maskData);
        }