Beispiel #1
0
 public void setProperty(string field, System.Object value)
 {
     if (!list.ContainsKey(field))
     {
         list.Add(field, value.ToString());
     }
     else
     {
         list[field] = value.ToString();
     }
 }
 public static void SetVariableValue(VariableHandler handler, System.Object value, StringValue key)
 {
     if (value is string)
     {
         handler.Set(key.GetValue(), (string)value);
     }
     else if (value is bool)
     {
         handler.Set(key.GetValue(), (bool)value);
     }
     else if (value is int)
     {
         handler.Set(key.GetValue(), (int)value);
     }
     else if (value is float)
     {
         handler.Set(key.GetValue(), (float)value);
     }
     else if (value is Vector3)
     {
         handler.Set(key.GetValue(), (Vector3)value);
     }
     else if (value != null)
     {
         handler.Set(key.GetValue(), value.ToString());
     }
 }
Beispiel #3
0
        public static System.Boolean IsNumeric(this System.Object Expression)
        {
            if (Expression == null || Expression is DateTime)
            {
                return(false);
            }

            if (Expression is Int16 || Expression is Int32 || Expression is Int64 || Expression is Decimal || Expression is Single || Expression is Double || Expression is Boolean)
            {
                return(true);
            }

            try
            {
                if (Expression is string)
                {
                    Double.Parse(Expression as string);
                }
                else
                {
                    Double.Parse(Expression.ToString());
                }
                return(true);
            }
            catch { } // just dismiss errors but return false
            return(false);
        }
        /// Display an error message to the user, related to an action taken
        /// by the specified controller.
        public static void Error(InputManager.ControllerName controller,
                                 string msg,
                                 System.Object detail = null)
        {
            // If our singleton instances haven't been assigned, defer the error.
            if (m_Instance == null || ControllerConsoleScript.m_Instance == null)
            {
                DeferError(controller, msg, detail);
            }
            else
            {
                Debug.LogErrorFormat("User-visible error: {0}\nDetail: {1}", msg, detail);

                // In the future, maybe use color or something instead of prepending ERROR
                string card    = string.Format("ERROR: {0}", msg);
                float  cardPop = 1.0f + InfoCardAnimation.s_NumCards * 0.2f;
                m_Instance.CreateInfoCardAtController(controller, card, cardPop, false);

                ControllerConsoleScript.m_Instance.AddNewLine(msg, true);
                if (detail != null)
                {
                    string detailStr = detail.ToString();
                    if (detailStr.Length > CONTROLLER_DETAIL_MAX_LENGTH)
                    {
                        detailStr = detailStr.Substring(0, CONTROLLER_DETAIL_MAX_LENGTH - 3) + " ...";
                    }
                    ControllerConsoleScript.m_Instance.AddNewLine(detailStr, false);
                }
            }
        }
Beispiel #5
0
 private static string FormatObject(System.Object o) //Takes any variable, checks its type and returns a string that will format it correctly in JSON
 {
     if (o != null)
     {
         System.Text.StringBuilder sb = new System.Text.StringBuilder("");
         if (o.GetType() == typeof(string))
         {
             sb.Append("\"").Append(o).Append("\"");
             return(sb.ToString());
         }
         else if (o.GetType() == typeof(int) || o.GetType() == typeof(float) || o.GetType() == typeof(double))
         {
             return(o.ToString());
         }
         else if (o.GetType() == typeof(bool))
         {
             sb.Append("\"").Append(o.ToString()).Append("\"");
             return(sb.ToString());
         }
         else if (o.GetType() == typeof(Vector2))
         {
             Vector2 v = (Vector2)o;
             sb.Append("[").Append(v.x).Append(",").Append(v.y).Append("]");
             return(sb.ToString());
         }
         else if (o.GetType() == typeof(Vector3))
         {
             Vector3 v = (Vector3)o;
             sb.Append("[").Append(v.x).Append(",").Append(v.y).Append(",").Append(v.z).Append("]");
             return(sb.ToString());
         }
         else if (o.GetType() == typeof(Vector4))
         {
             Vector4 v = (Vector4)o;
             sb.Append("[").Append(v.x).Append(",").Append(v.y).Append(",").Append(v.z).Append(",").Append(v.w).Append("]");
             return(sb.ToString());
         }
         else if (o.GetType() == typeof(Quaternion))
         {
             Quaternion v = (Quaternion)o;
             sb.Append("[").Append(v.x).Append(",").Append(v.y).Append(",").Append(v.z).Append(",").Append(v.w).Append("]");
             return(sb.ToString());
         }
     }
     Debug.LogWarning("Formatting Object unsuccessful. Returning empty.");
     return("");
 }
Beispiel #6
0
 public static System.String GetLocalizedMessage(System.String key, System.Globalization.CultureInfo locale)
 {
     System.Object message = GetResourceBundleObject(key, locale);
     if (message == null)
     {
         return("Message with key:" + key + " and locale: " + locale + " not found.");
     }
     return(message.ToString());
 }
Beispiel #7
0
 public override bool Contains(System.Object o)
 {
     if (o is char[])
     {
         char[] text = (char[])o;
         return(Contains(text, 0, text.Length));
     }
     return(Contains(o.ToString()));
 }
Beispiel #8
0
        static string GetName(System.Object o)
        {
            if (o is GameObject go)
            {
                return(go.name);
            }

            return(o.ToString());
        }
Beispiel #9
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Private Member Functions

        //---------------------------------------------------------------------------

        /// <summary>
        /// Log at the specified level, message and showTrace.
        /// </summary>
        /// <param name='level'>
        /// Log Level.
        /// </param>
        /// <param name='message'>
        /// Log info object, usually a string.
        /// </param>
        /// <param name='showTrace'>
        /// Show trace.
        /// </param>
        private void Log(LogLevel level, System.Object message, bool showTrace = false)
        {
            if (!_isLogEnabled)
            {
                return;
            }

            string now = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss:fff");

            string logToPrint = "[" + now + "] [" + level.ToString() + "] ";

            if (showTrace)
            {
                StackTrace trace  = new StackTrace();
                StackFrame frame  = null;
                MethodBase method = null;

                frame  = trace.GetFrame(2);
                method = frame.GetMethod();

                string callingMethod = method.ReflectedType.Name + "::" + method.Name;
                logToPrint += callingMethod + ": ";
            }

            logToPrint += message.ToString();

            if (level <= _currentLevel)
            {
                /**
                 * Use unity api for writing information to
                 * unity editor console.
                 */
                switch (level)
                {
                case LogLevel.FINE:
                case LogLevel.DEBUG:
                case LogLevel.INFO:
                {
                    UnityEngine.Debug.Log(logToPrint);
                    break;
                }

                case LogLevel.WARN:
                {
                    UnityEngine.Debug.LogWarning(logToPrint);
                    break;
                }

                case LogLevel.ERROR:
                {
                    UnityEngine.Debug.LogError(logToPrint);
                    break;
                }
                }
            }
        }
        public static void Log(System.Object str)
        {
#if UNITY_EDITOR
            Debug.Log(str.ToString());
#endif

#if UNITY_ANDROID
            //Debug.Log(str.ToString());
#endif
        }
Beispiel #11
0
        protected override object OnDrawValue()
        {
            System.Object vValue = pi_.GetValue(obj_, null);
            if (lastValue_.ToString() != vValue.ToString())
            {
                editingContent_ = vValue.ToString();
                lastValue_      = vValue;
            }
            editingContent_ = GUILayout.TextField(editingContent_);
            if (mi_ != null)
            {
                System.Object[] args = new System.Object[] { editingContent_, vValue };
                if ((bool)mi_.Invoke(null, args))
                {
                    vValue     = args[1];
                    lastValue_ = vValue;
                }
            }
            return(vValue);

            /*
             * string nowStr = vValue.ToString();
             *          if( Time.time - lastEditTime_ <= 2.0f ){
             *              nowStr = editingContent_;
             *              editingContent_ = GUILayout.TextField( nowStr );
             *              if ( editingContent_ != nowStr ) {
             *                  lastEditTime_ = Time.time;
             *              }
             *              if ( mi_ != null ) {
             *                  System.Object[] args = new System.Object[] { editingContent_, vValue };
             *                  if ( (bool)mi_.Invoke( null, args ) ) {
             *                      vValue = args[ 1 ];
             *                  }
             *              }
             *          }
             *          else{
             *              editingContent_ = GUILayout.TextField( nowStr );
             *              if( editingContent_ != nowStr ){
             *                  lastEditTime_ = Time.time;
             *              }
             *          }
             *          return vValue;*/
        }
Beispiel #12
0
/* -------------------------------------------------------------------- */

    // Known in ILASM as [RTS]CP_rts::withMesg
    public static System.String withMesg(System.Object o)
    {
        //    System.String c = o.getClass().getName();
        //    c = c.substring(c.lastIndexOf('.') + 1);
        //    c = "WITH else-trap: type = " + c;
        //  NEEDS TO USE LIGHTNING REFLECTION SERVICES HERE
        string c = "WITH else-trap: type = " + o.ToString();

        return(c);
    }
Beispiel #13
0
 public PGCValue(System.Object vObj, PropertyInfo vPi)
     : base(vObj, vPi)
 {
     mi_ = vPi.PropertyType.GetMethod("TryParse", new System.Type[] { typeof(string), vPi.PropertyType.MakeByRefType() });
     if (mi_ == null)
     {
         Debug.Log("can't find TryParse");
     }
     lastValue_      = pi_.GetValue(obj_, null);
     editingContent_ = lastValue_.ToString();
 }
Beispiel #14
0
        static void AppendInfo(StringBuilder builder, string label, System.Object number)
        {
            // Add comma
            if (builder.Length > 0)
            {
                builder.Append(", ");
            }

            // Add build number
            builder.Append(label);
            builder.Append(number.ToString());
        }
Beispiel #15
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.OpenCVObject))
            {
                LogError("owner is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.OpenCVObject, System.Object>(owner);


            storeResult.Value = wrapped_owner.ToString();
        }
        void DoProcess()
        {
            if (!(owner.Value is DlibFaceLandmarkDetectorPlayMakerActions.DlibObject))
            {
                LogError("owner is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_owner = DlibFaceLandmarkDetectorPlayMakerActionsUtils.GetWrappedObject <DlibFaceLandmarkDetectorPlayMakerActions.DlibObject, System.Object> (owner);


            storeResult.Value = wrapped_owner.ToString();
        }
Beispiel #17
0
        private void InternalAppend(System.Type itemType, System.Object item)
        {
            if (itemType.IsPrimitive ||
                itemType.IsEnum ||
                itemType == typeof(string))
            {
                Append(item.ToString());
                return;
            }

            if (itemType.IsSubclassOf(typeof(UnityEngine.Object)))
            {
                var unityObject = item as UnityEngine.Object;
                Append((unityObject != null) ? unityObject.name : "");
                return;
            }

            if (itemType.IsArray)
            {
                var array = item as System.Array;
                if (array == null || itemType.GetArrayRank() > 1)
                {
                    Append("0");
                }
                else
                {
                    var objectList = new List <System.Object>();
                    foreach (var subItem in array)
                    {
                        if (subItem != null)
                        {
                            objectList.Add(subItem);
                        }
                    }
                    Append(objectList.Count.ToString());
                    foreach (var subItem in objectList)
                    {
                        InternalAppend(itemType.GetElementType(), subItem);
                    }
                }
                return;
            }

            var bindingFlags = BindingFlags.Instance | BindingFlags.Public;
            var members      = itemType.GetFields(bindingFlags);

            foreach (var member in members)
            {
                InternalAppend(member.FieldType, member.GetValue(item));
            }
        }
        //
        // START-StepCostFunction
        public double c(System.Object fromCurrentState, Action action, System.Object toNextState)
        {
            System.String fromLoc = fromCurrentState.ToString();
            System.String toLoc   = toNextState.ToString();

            System.Double distance = map.getDistance(fromLoc, toLoc);

            if (distance == null || distance <= 0)
            {
                return(constantCost);
            }

            return(distance);
        }
Beispiel #19
0
 protected override object OnDrawValue()
 {
     GUI.SetNextControlName(pi_.Name);
     System.Object vValue = pi_.GetValue(obj_, null);
     if (GUILayout.Button(vValue.ToString()))
     {
         for (int i = 0; i < enumValues_.Count; i++)
         {
             if (enumValues_[i].ToString() == vValue.ToString())
             {
                 if (i + 1 >= enumValues_.Count)
                 {
                     vValue = enumValues_[0];
                 }
                 else
                 {
                     vValue = enumValues_[i + 1];
                 }
                 break;
             }
         }
     }
     return(vValue);
 }
Beispiel #20
0
            public HashSet <Action> actions(System.Object state)
            {
                HashSet <Action> actions = new LinkedHashSet <Action>();

                System.String location = state.ToString();

                List <System.String> linkedLocations = map.getLocationsLinkedTo(location);

                foreach (System.String linkLoc in linkedLocations)
                {
                    actions.Add(new MoveToAction(linkLoc));
                }

                return(actions);
            }
Beispiel #21
0
            public HashSet <Action> actions(System.Object state)
            {
                HashSet <Action> actions = new HashSet <Action>();

                System.String location = state.ToString();

                List <System.String> linkedLocations = reverseMode ? map.getPossiblePrevLocations(location)
                                        : map.getPossibleNextLocations(location);

                foreach (System.String linkLoc in linkedLocations)
                {
                    actions.Add(new MoveToAction(linkLoc));
                }
                return(actions);
            }
Beispiel #22
0
        public static string TrimSpecial(System.Object obj)
        {
            if (obj == null)
            {
                return(null);
            }

            if (obj == System.DBNull.Value)
            {
                return(null);
            }

            string str = obj.ToString();

            return(str.Trim(new char[] { '\r', '\n', ' ', '\t' }));
        } // End Function TrimSpecial
Beispiel #23
0
        /** Claim this path.
         * A claim on a path will ensure that it is not recycled.
         * If you are using a path, you will want to claim it when you first get it and then release it when you will not
         * use it anymore. When there are no claims on the path, it will be recycled and put in a pool.
         *
         * \see Release
         * \see Recycle
         */
        public void Claim(System.Object o)
        {
            if (o == null)
            {
                throw new System.ArgumentNullException("o");
            }

            if (claimed.Contains(o))
            {
                throw new System.ArgumentException("You have already claimed the path with that object (" + o.ToString() + "). Are you claiming the path with the same object twice?");
            }

            claimed.Add(o);
#if ASTAR_POOL_DEBUG
            claimInfo.Add(o.ToString() + "\n\nClaimed from:\n" + System.Environment.StackTrace);
#endif
        }
Beispiel #24
0
        public virtual bool Add(System.Object o)
        {
            if (o is char[])
            {
                return(Add((char[])o));
            }

            if (o is System.Collections.Hashtable)
            {
                foreach (string word in ((System.Collections.Hashtable)o).Keys)
                {
                    Add(word);
                }
                return(true);
            }

            return(Add(o.ToString()));
        }
Beispiel #25
0
                          public override System.String ToString()
                          {
                              System.Text.StringBuilder b = new System.Text.StringBuilder("[");
                              bool first = true;

                              for (Iterator i = this.iterator(); i.hasNext();)
                              {
                                  if (!first)
                                  {
                                      b.Append(", ");
                                  }
                                  first = false;
                                  System.Object o = i.next();
                                  b.Append((o == null) ? "null" : o.ToString());
                              }
                              b.Append("]");
                              return(b.ToString());
                          }
Beispiel #26
0
/* ------------------------------------------------------------ */
//  PROCEDURE ObjToStr(obj: mscorlib_System.Object; OUT str: ARRAY OF CHAR);
//  (** Decode an .NET object into an array of CHAR *)
//  BEGIN END ObjToStr;
//
    // Known in ILASM as [RTS]RTS::ObjToStr
    public static void ObjToStr(System.Object obj, char[] str)
    {
        System.String lls;
        if (obj.GetType().IsEnum)
        {
#if BETA1
            lls = obj.ToString();
#else //BETA2
            lls = System.Convert.ToString(System.Convert.ToInt64(obj));
#endif
        }
        else
        {
            if (obj.GetType().Equals(typDouble))
            {
#if BETA1
                lls = System.Convert.ToDouble(obj).ToString();
#else //BETA2
                lls = System.Convert.ToDouble(obj).ToString("R");
#endif
            }
            else if (obj.GetType().Equals(typSingle))
            {
#if BETA1
                lls = System.Convert.ToSingle(obj).ToString();
#else //BETA2
                lls = System.Convert.ToSingle(obj).ToString("R");
#endif
            }
            else
            {
                lls = System.Convert.ToString(obj);
            }
        }

        int len = lls.Length;
        if (len >= str.Length)
        {
            len = str.Length - 1;
        }
        lls.CopyTo(0, str, 0, len);
        str[len] = '\0';
    }
Beispiel #27
0
        /** Claim this path (pooling).
         * A claim on a path will ensure that it is not pooled.
         * If you are using a path, you will want to claim it when you first get it and then release it when you will not
         * use it anymore. When there are no claims on the path, it will be reset and put in a pool.
         *
         * This is essentially just reference counting.
         *
         * The object passed to this method is merely used as a way to more easily detect when pooling is not done correctly.
         * It can be any object, when used from a movement script you can just pass "this". This class will throw an exception
         * if you try to call Claim on the same path twice with the same object (which is usually not what you want) or
         * if you try to call Release with an object that has not been used in a Claim call for that path.
         * The object passed to the Claim method needs to be the same as the one you pass to this method.
         *
         * \see Release
         * \see Pool
         * \see \ref pooling
         * \see https://en.wikipedia.org/wiki/Reference_counting
         */
        public void Claim(System.Object o)
        {
            if (System.Object.ReferenceEquals(o, null))
            {
                throw new System.ArgumentNullException("o");
            }

            for (int i = 0; i < claimed.Count; i++)
            {
                // Need to use ReferenceEquals because it might be called from another thread
                if (System.Object.ReferenceEquals(claimed[i], o))
                {
                    throw new System.ArgumentException("You have already claimed the path with that object (" + o + "). Are you claiming the path with the same object twice?");
                }
            }

            claimed.Add(o);
#if ASTAR_POOL_DEBUG
            claimInfo.Add(o.ToString() + "\n\nClaimed from:\n" + System.Environment.StackTrace);
#endif
        }
Beispiel #28
0
        static void AppendBuildNumber(StringBuilder builder, System.Object checkValue)
        {
            // Add comma
            if (builder.Length > 0)
            {
                builder.Append(", ");
            }

            // Add platform
#if UNITY_IOS
            builder.Append("iOS ");
#elif UNITY_WINRT
            builder.Append("Windows ");
#elif UNITY_AMAZON
            builder.Append("Amazon ");
#elif UNITY_ANDROID
            builder.Append("Android ");
#endif

            // Add build number
            builder.Append(BuildLabel);
            builder.Append(checkValue.ToString());
        }
        /** 文字列。取得。
         */
        public static bool GetTryCellString(System.Object a_cell, out string a_result_value)
        {
            try{
                if (a_cell != null)
                {
                    string t_value_string = a_cell.ToString();
                    if (t_value_string != null)
                    {
                        a_result_value = t_value_string;
                        return(true);
                    }
                }
                else
                {
                    //データのないセル。
                }
            }catch (System.Exception t_exception) {
                Tool.DebugReThrow(t_exception);
            }

            //失敗。
            a_result_value = null;
            return(false);
        }
                          public override System.String ToString()
                          {
                              System.Text.StringBuilder b = new System.Text.StringBuilder("{");
                              bool first = true;

                              for (Iterator it = keySet().iterator(); it.hasNext();)
                              {
                                  System.Object k = it.next();
                                  System.Object v = get(k);
                                  if (first)
                                  {
                                      first = false;
                                  }
                                  else
                                  {
                                      b.Append(", ");
                                  }
                                  b.Append(k == null ? "null" : k.ToString());
                                  b.Append("=");
                                  b.Append(v == null ? "null" : v.ToString());
                              }
                              b.Append("}");
                              return(b.ToString());
                          }
 public void Start()
 {
     var obj = new System.Object();
     obj.ToString();
 }