Exemple #1
0
        internal static Result FromObject(
            object value,
            bool forceCopy,
            bool supportedOnly,
            bool toString
            )
        {
            if (value == null)
            {
                return(null);
            }

            Result result = value as Result;

            if (result != null)
            {
                //
                // NOTE: Otherwise, use the existing reference.
                //
                if (forceCopy)
                {
                    result = new Result(result); /* COPY */
                }
            }
            else if (!supportedOnly || IsSupported(value.GetType()))
            {
                result = new Result(value); /* WRAP */
            }
            else if (toString)
            {
                result = StringOps.GetResultFromObject(value); /* String */
            }

            return(result);
        }