示例#1
0
 public static unsafe void Ctor(string aThis, char *aChars,
                                [FieldAccess(Name = "System.String System.String.Empty")] ref string aStringEmpty,
                                [FieldAccess(Name = "System.Int32 System.String._stringLength")] ref int aStringLength,
                                [FieldAccess(Name = "System.Char System.String._firstChar")] char *aFirstChar)
 {
     mDebugger.SendInternal("String.Ctor(string, char*)");
     aStringEmpty = "";
     while (*aChars != '\0')
     {
         mDebugger.SendInternal(*aChars);
         aFirstChar[aStringLength] = *aChars;
         aStringLength++;
         aChars++;
     }
     mDebugger.SendInternal(aStringLength);
 }
示例#2
0
        public static unsafe void Ctor(
            string aThis,
            [ObjectPointerAccess] char *aChars,
            [FieldAccess(Name = "System.String System.String.Empty")] ref string aStringEmpty,
            [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength,
            [FieldAccess(Name = "System.Char System.String.m_firstChar")] char *aFirstChar)
        {
            mDebugger.SendInternal("String.Ctor(string, char*)");

            aStringEmpty = "";
            while (*aChars != '\0')
            {
                aChars++;
                aStringLength++;
            }
            for (int i = 0; i < aStringLength; i++)
            {
                aFirstChar[i] = aChars[i];
            }
        }
示例#3
0
        internal static string FormatHelper(IFormatProvider aFormatProvider, string aFormat, params object[] aArgs)
        {
            char[] xCharArray = aFormat.ToCharArray();
            string xFormattedString = string.Empty, xStaticString;
            bool   xFoundPlaceholder = false, xParamNumberDone = true;
            int    xStartParamNumber = -1, xEndParamNumber = -1, xLastPlaceHolder = 0;

            for (int i = 0; i < xCharArray.Length; i++)
            {
                if (xFoundPlaceholder)
                {
                    if (xCharArray[i] == '{')
                    {
                        throw new FormatException("The format string provided is invalid.");
                    }
                    if (xCharArray[i] == '}')
                    {
                        mDebugger.SendInternal("Found closing placeholder.");
                        if (xEndParamNumber < 0)
                        {
                            xEndParamNumber = i;
                        }
                        string xParamNumber = aFormat.Substring(xStartParamNumber, xEndParamNumber - xStartParamNumber);
                        mDebugger.SendInternal("Calling StringHelper.GetStringToNumber");
                        mDebugger.SendInternal(xParamNumber);
                        int xParamIndex = StringHelper.GetStringToNumber(xParamNumber);
                        mDebugger.SendInternal("Converted paramindex to a number.");
                        if ((xParamIndex < aArgs.Length) && (aArgs[xParamIndex] != null))
                        {
                            string xParamValue = aArgs[xParamIndex].ToString();
                            xFormattedString = string.Concat(xFormattedString, xParamValue);
                        }
                        xFoundPlaceholder = false;
                        xParamNumberDone  = true;
                        xStartParamNumber = -1;
                        xEndParamNumber   = -1;
                        xLastPlaceHolder  = i + 1;
                    }
                    else if (xCharArray[i] == ':')
                    {
                        xParamNumberDone = true;
                        xEndParamNumber  = i;
                        // TODO: Need to handle different formats. (X, N, etc)
                    }
                    else if ((char.IsDigit(xCharArray[i])) && (!xParamNumberDone))
                    {
                        mDebugger.SendInternal("Getting param number.");
                        if (xStartParamNumber < 0)
                        {
                            xStartParamNumber = i;
                        }
                    }
                }
                else if (xCharArray[i] == '{')
                {
                    mDebugger.SendInternal("Found opening placeholder");
                    xStaticString     = aFormat.Substring(xLastPlaceHolder, i - xLastPlaceHolder);
                    xFormattedString  = string.Concat(xFormattedString, xStaticString);
                    xFoundPlaceholder = true;
                    xParamNumberDone  = false;
                }
            }

            xStaticString    = aFormat.Substring(xLastPlaceHolder, aFormat.Length - xLastPlaceHolder);
            xFormattedString = string.Concat(xFormattedString, xStaticString);

            return(xFormattedString);
        }