static bool Encoding_GetBytes__Char_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            System.Char[] arg0 = JSDataExchangeMgr.GetJSArg <System.Char[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new System.Char[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (System.Char)JSApi.getChar((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            var arrRet = ((System.Text.Encoding)vc.csObj).GetBytes(arg0);
            for (int i = 0; arrRet != null && i < arrRet.Length; i++)
            {
                JSApi.setByte((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
                JSApi.moveSaveID2Arr(i);
            }
            JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
        }

        return(true);
    }
 public DirectBinaryNumber(Char[] codeNumber)
 {
     if (IsCorrectBinaryCoding(codeNumber))
         _code = new String(codeNumber).PadLeft(_LENGTH_CODING, '0').ToCharArray();
     else
         throw new ArgumentException("Недопустимое значение двоичного числа!");
 }
Exemplo n.º 3
0
        static StackObject *Vector3Parse_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Char @separator = (char)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @content = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = global::StringUtils.Vector3Parse(@content, @separator);

            if (ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder != null)
            {
                ILRuntime.Runtime.Generated.CLRBindings.s_UnityEngine_Vector3_Binding_Binder.PushValue(ref result_of_this_method, __intp, __ret, __mStack);
                return(__ret + 1);
            }
            else
            {
                return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a set of NFA states from which there is a transition on input symbol
        /// inp from some state s in states.
        /// </summary>
        /// <param name="states"></param>
        /// <param name="inp"></param>
        /// <returns></returns>
        public Set <state> Move(Set <state> states, input inp)
        {
            Set <state> result = new Set <state>();

            // For each state in the set of states
            foreach (state state in states)
            {
                int i = 0;

                // For each transition from this state
                foreach (input input in transTable[state])
                {
                    // If the transition is on input inp, add it to the resulting set
                    if (input == inp)
                    {
                        state u = Array.IndexOf(transTable[state], input, i);
                        result.Add(u);
                    }

                    i = i + 1;
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Renames all the NFA's states. For each nfa state: number += shift.
        /// Functionally, this doesn't affect the NFA, it only makes it larger and renames
        /// its states.
        /// </summary>
        /// <param name="shift"></param>
        public void ShiftStates(int shift)
        {
            int newSize = size + shift;

            if (shift < 1)
            {
                return;
            }

            // Creates a new, empty transition table (of the new size).
            input[][] newTransTable = new input[newSize][];

            for (int i = 0; i < newSize; ++i)
            {
                newTransTable[i] = new input[newSize];
            }

            // Copies all the transitions to the new table, at their new locations.
            for (state i = 0; i < size; ++i)
            {
                for (state j = 0; j < size; ++j)
                {
                    newTransTable[i + shift][j + shift] = transTable[i][j];
                }
            }

            // Updates the NFA members.
            size       = newSize;
            initial   += shift;
            final     += shift;
            transTable = newTransTable;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prints out the NFA.
        /// </summary>
        public void Show()
        {
            Console.WriteLine("This NFA has {0} states: 0 - {1}", size, size - 1);
            Console.WriteLine("The initial state is {0}", initial);
            Console.WriteLine("The final state is {0}\n", final);

            for (state from = 0; from < size; ++from)
            {
                for (state to = 0; to < size; ++to)
                {
                    input @in = transTable[from][to];

                    if (@in != (char)Constants.None)
                    {
                        Console.Write("Transition from {0} to {1} on input ", from, to);

                        if (@in == (char)Constants.Epsilon)
                        {
                            Console.Write("Epsilon\n");
                        }
                        else
                        {
                            Console.Write("{0}\n", @in);
                        }
                    }
                }
            }
            Console.Write("\n\n");
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //Mostrar Hello World en la consola
            System.Console.WriteLine("Hello World :D");

            //Tomar los datos
            Console.ReadLine();

            //Variables
            var numero = 4;
            var saludo = "Hola";

            System.Console.WriteLine(numero);
            System.Console.WriteLine(saludo);
            System.Console.WriteLine(numero + 2);

            //Tipos de variables
            System.Int32   wholeNumber;
            System.Double  pi     = 3.1416;
            System.Boolean status = true;
            System.String  cadena = "hello";
            System.Char    letter = 'z';

            //Espera a que se oprima una tecla para salir
            Console.ReadKey();
        }
Exemplo n.º 8
0
        public static string PostModel(string url, string param, Encoding encoding,int timeout)
        {
            Encoding encode = encoding;
            byte[] arrB = encode.GetBytes(param);
            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
            if (timeout > 0) myReq.Timeout = timeout;
            myReq.Method = "POST";
            myReq.ContentType = "application/x-www-form-urlencoded";
            myReq.ContentLength = arrB.Length;
            Stream outStream = myReq.GetRequestStream();
            outStream.Write(arrB, 0, arrB.Length);
            outStream.Close();
            WebResponse myResp = null;
            try
            {
                myResp = myReq.GetResponse();
            }
            catch
            {

            }
            Stream ReceiveStream = myResp.GetResponseStream();
            StreamReader readStream = new StreamReader(ReceiveStream, encode);
            Char[] read = new Char[256];
            int count = readStream.Read(read, 0, 256);
            string str = null;
            while (count > 0)
            {
                str += new String(read, 0, count);
                count = readStream.Read(read, 0, 256);
            }
            readStream.Close();
            myResp.Close();
            return str;
        }
Exemplo n.º 9
0
 void Restart()
 {
     for (int i = 0; i < dataGridView1.RowCount; i++)
     {
         for (int j = 0; j < dataGridView1.ColumnCount; j++)
         {
             dataGridView1.Rows[i].Cells[j].Value = "";
             t[i][j] = ' ';
         }
     }
     dataGridView1.Enabled = true;
     Random r = new Random();
     if (r.Next(2) == 0)
     {
         gracz = 'O';
     }
     else
     {
         if (siX && !siO)
         {
             Ruch(t, 'X');
         }
         else
         {
             gracz = 'X';
         }
     }
     label1.Text = "Gracz";
     label2.Text = gracz.ToString();
     if (siX && siO)
         sIVsSI();
 }
Exemplo n.º 10
0
 internal static InputBoxResult Show(String prompt, String title, Char passwordChar)
 {
     LoadForm(title, prompt, string.Empty);
     frmInputDialog.AssignPasswordChar(passwordChar);
     frmInputDialog.ShowDialog();
     return OutputResponse;
 }
Exemplo n.º 11
0
Arquivo: Form1.cs Projeto: 3141592/vs
        private void button1_Click(object sender, EventArgs e)
        {
            string sURL;
            sURL = "http://microsoft.com";

            HttpWebRequest myHttpWebRequest;
            myHttpWebRequest = (HttpWebRequest)WebRequest.Create(sURL);
            myHttpWebRequest.UserAgent = "leviticus2195 Test Client";

            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream streamResponse = myHttpWebResponse.GetResponseStream();
            StreamReader streamRead = new StreamReader(streamResponse);
            Char[] readBuff = new Char[256];
            int count = streamRead.Read(readBuff, 0, 256);
            string content = "";
            while (count > 0)
            {
                String outputData = new String(readBuff, 0, count);
                content = content + outputData;
                count = streamRead.Read(readBuff, 0, 256);
            }
            // Release the response object resources.
            streamRead.Close();
            streamResponse.Close();
            myHttpWebResponse.Close();
            this.richTextBox1.AppendText(content);
        }
Exemplo n.º 12
0
		/// <summary>
		/// Creates a string from the specified character.
		/// </summary>
		/// <param name="c">
		/// The character to create the string from.
		/// </param>
		/// <param name="length">
		/// The number of instances of the specified character
		/// to construct the string from.
		/// </param>
		public static String Create(Char c, Int32 length) {
			StringBuilder sb = new StringBuilder(length);
			for (Int32 i = 0; i < length; i++) {
				sb.Append(c);
			}
			return sb.ToString();
		}
Exemplo n.º 13
0
 public int CharToInt(Char key)
 {
     switch (key)
     {
         case 'a':
             return 0;
         case 'b':
             return 1;
         case 'c':
             return 2;
         case 'd':
             return 3;
         case 'e':
             return 4;
         case 'f':
             return 5;
         case 'g':
             return 6;
         case 'h':
             return 7;
         case 'i':
             return 8;
         case 'j':
             return 9;
         case 'k':
             return 10;
         case 'l':
             return 11;
         case 'm':
             return 12;
         case 'n':
             return 13;
         case 'o':
             return 14;
         case 'p':
             return 15;
         case 'q':
             return 16;
         case 'r':
             return 17;
         case 's':
             return 18;
         case 't':
             return 19;
         case 'u':
             return 20;
         case 'v':
             return 21;
         case 'w':
             return 22;
         case 'x':
             return 23;
         case 'y':
             return 24;
         case 'z':
             return 25;
         default:
             return -1;
     }
 }
        public void Write (Char[]! buffer, int index, int count) {
            CodeContract.Requires(buffer != null);
            CodeContract.Requires(index >= 0);
            CodeContract.Requires(count >= 0);
            CodeContract.Requires((buffer.Length - index) >= count);

        }
Exemplo n.º 15
0
        private static byte ComponentValue(string aColorSpec, int aLen, int color, int dpc)
        {
            int component = 0;
            int index     = (color * dpc);

            if (2 < dpc)
            {
                dpc = 2;
            }
            while (--dpc >= 0)
            {
                PRUnichar ch = ((index < aLen) ? aColorSpec[index++] : '0');
                if (('0' <= ch) && (ch <= '9'))
                {
                    component = (component * 16) + (ch - '0');
                }
                else if ((('a' <= ch) && (ch <= 'f')) ||
                         (('A' <= ch) && (ch <= 'F')))
                {
                    // "ch&7" handles lower and uppercase hex alphabetics
                    component = (component * 16) + (ch & 7) + 9;
                }
                else   // not a hex digit, treat it like 0
                {
                    component = (component * 16);
                }
            }
            return((byte)component);
        }
Exemplo n.º 16
0
        private bool VerifyInvalidReadValue(int iBufferSize, int iIndex, int iCount, Type exceptionType)
        {
            bool bPassed = false;
            Char[] buffer = new Char[iBufferSize];

            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_NAME);
            DataReader.Read();
            if (!DataReader.CanReadValueChunk)
            {
                try
                {
                    DataReader.ReadValueChunk(buffer, 0, 5);
                    return bPassed;
                }
                catch (NotSupportedException)
                {
                    return true;
                }
            }
            try
            {
                DataReader.ReadValueChunk(buffer, iIndex, iCount);
            }
            catch (Exception e)
            {
                CError.WriteLine("Actual   exception:{0}", e.GetType().ToString());
                CError.WriteLine("Expected exception:{0}", exceptionType.ToString());
                bPassed = (e.GetType().ToString() == exceptionType.ToString());
            }

            return bPassed;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Ises the quantifier.
        /// </summary>
        /// <returns>
        /// The quantifier.
        /// </returns>
        /// <param name='_value'>
        /// If set to <c>true</c> _value.
        /// </param>
        public static bool isQuantifier(System.Char _value)
        {
            string pattern = @"[\+\.\*\?]";
            Regex  rgx     = new Regex(pattern);

            return(rgx.IsMatch(_value.ToString()));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Ises the char.
        /// </summary>
        /// <returns>
        /// The char.
        /// </returns>
        /// <param name='_value'>
        /// If set to <c>true</c> _value.
        /// </param>
        public static bool isChar(System.Char _value)
        {
            string pattern = @"[\n\r]";
            Regex  rgx     = new Regex(pattern);

            return(!rgx.IsMatch(_value.ToString()));
        }
Exemplo n.º 19
0
        public static bool isLiteral(System.Char _value)
        {
            string pattern = @"[\wa-zA-Z0-9:/]";
            Regex  rgx     = new Regex(pattern);

            return(rgx.IsMatch(_value.ToString()));
        }
Exemplo n.º 20
0
        static StackObject *Split2List_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Char @split = (char)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            Unity.Standard.ScriptsWarp.StringView instance_of_this_method = (Unity.Standard.ScriptsWarp.StringView) typeof(Unity.Standard.ScriptsWarp.StringView).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            var result_of_this_method = instance_of_this_method.Split2List(@split);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __intp.Free(ptr_of_this_method);
            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Finds the Global Address List associated with the MailStore
        /// </summary>
        /// <param name="folderPath">parameter for FindFolder</param>
        /// <returns>IMailFolder for the target of the event</returns>
        /// In this case the Folder element is a path in Outlook. Each component of the path separated by '\'.
        /// The first or default folder in the path, can be preceded by "\\" or nothing. If it's the only part of
        /// the path, then it MUST be one of the default OL folders (see the schema for the EventMonitor operation).
        public IMailFolder FindFolder(string folderPath)
        {
            IMailFolder folder;

            System.Char backslash = '\\';
            if (folderPath.StartsWith(@"\\"))
            {
                folderPath = folderPath.Remove(0, 2);
            }
            String[] folders = folderPath.Split(backslash);
            folder = GetDefaultFolder(folders[0]);

            if (folder != null)
            {
                for (int i = 1; i <= folders.Length - 1; i++)
                {
                    IEnumerable <IMailFolder> subFolders = folder.SubFolders;
                    folder = subFolders.FirstOrDefault(fld => fld.Name.Equals(folders[i], StringComparison.CurrentCultureIgnoreCase));
                    if (folder == null)
                    {
                        return(null);
                    }
                }
            }
            return(folder);
        }
Exemplo n.º 22
0
        public static List<DATFile> FindFiles(DAT dat, BinaryReader br)
        {
            List<DATFile> DatFiles = new List<DATFile>();

            uint FileIndex = 0;
            br.BaseStream.Seek(-(dat.TreeSize + 4), SeekOrigin.End);
            while (FileIndex < dat.FilesTotal)
            {
                DATFile file = new DATFile();
                file.br = br;
                file.FileNameSize = br.ReadInt32();
                char[] namebuf = new Char[file.FileNameSize];
                br.Read(namebuf, 0, (int)file.FileNameSize);
                file.Path = new String(namebuf, 0, namebuf.Length);
                file.FileName = Path.GetFileName(file.Path);
                file.Compression = br.ReadByte();
                file.UnpackedSize = br.ReadInt32();
                file.PackedSize = br.ReadInt32();
                if (file.Compression==0x00&&(file.UnpackedSize != file.PackedSize))
                        file.Compression = 1;
                file.Offset = br.ReadInt32();
                long oldoffset = br.BaseStream.Position;
                // Read whole file into a buffer
                br.BaseStream.Position = file.Offset;
                file.Buffer = new Byte[file.PackedSize];
                br.Read(file.Buffer, 0, file.PackedSize);
                br.BaseStream.Position = oldoffset;

                DatFiles.Add(file);
                FileIndex++;
            }
            return DatFiles;
        }
Exemplo n.º 23
0
 public DelimitedValuesFormatter(Char indentChar, String dateTimeFormatText, String logContext, String delimiter)
 {
     _default = new DefaultFormatter(indentChar, dateTimeFormatText);
     _delayedService = new DelayedFormatterService(dateTimeFormatText);
     this.LogContext = logContext;
     this.Delimiter = delimiter;
 }
Exemplo n.º 24
0
        private static uint convertToBoardPositionIntegerX(File file)
        {
            var firstFileCharCode = (Int32)firstFile;
            int intValue          = file - firstFileCharCode;

            return((uint)intValue);
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            int   num  = 0;
            Int32 num1 = 0;
            byte  num2 = 0;

            System.Byte num3 = 0;
            char        s    = '0';

            System.Char s1   = '0';
            long        num4 = 0;
            Int64       num5 = 0;
            object      o    = 0;
            string      str  = "0";

            Console.WriteLine(num.GetType().ToString());
            Console.WriteLine(num1.GetType().ToString());
            Console.WriteLine(num2.GetType().ToString());
            Console.WriteLine(num3.GetType().ToString());
            Console.WriteLine(s.GetType().ToString());
            Console.WriteLine(s1.GetType().ToString());
            Console.WriteLine(num4.GetType().ToString());
            Console.WriteLine(num5.GetType().ToString());
            Console.WriteLine(o.GetType().ToString());
            Console.WriteLine(str.GetType().ToString());

            Console.ReadKey();
        }
Exemplo n.º 26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            siX = false;
            siO = false;
            Random r = new Random();
            if (r.Next(2) == 0)
                gracz = 'O';
            else
                gracz = 'X';
            for (int i = 0; i < k; i++)
            {
                AddAColumn(i);
            }
            dataGridView1.RowHeadersDefaultCellStyle.Padding = new Padding(3);
            for (int i = 0; i < k; i++)
            {
                AddARow(i);
            }

            t = new Char[dataGridView1.RowCount][];
            for (int i = 0; i < t.Length; i++)
            {
                t[i] = new Char[dataGridView1.ColumnCount];
                for (int j = 0; j < t[i].Length; j++)
                {
                    t[i][j] = ' ';
                    dataGridView1.Rows[i].Cells[j].Value = t[i][j].ToString();
                }
            }
            label2.Text = gracz.ToString();
            dataGridView1.ClearSelection();
        }
Exemplo n.º 27
0
        // mathfrak
        private TLongChar GetFraktur(TChar c)
        {
            // Fraktur has exceptions:
            switch (c)
            {
            case 'C':
                return(0x212D); // C Fraktur

            case 'H':
                return(0x210C); // Hilbert space

            case 'I':
                return(0x2111); // Imaginary

            case 'R':
                return(0x211C); // Real

            case 'Z':
                return(0x2128); // Z Fraktur
            }
            if (IsUpperEn(c))
            {
                return(UnicodeMathCapitalFrakturStart + (TLongChar)(c - 'A'));
            }
            else if (IsLowerEn(c))
            {
                return(UnicodeMathLowerFrakturStart + (TLongChar)(c - 'a'));
            }
            return(GetDefaultStyle(c));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this Gdk key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        /// <remarks>
        /// This is taken from MonoDevelop's code.
        /// </remarks>
        public static string ToString(Key key)
        {
            // Pull out the unicode value for the key. If we have one, we use
            // that instead.
            var c = (char)Keyval.ToUnicode((uint)key);

            if (c != 0)
            {
                return(c == ' '
                                        ? "Space"
                                        : Char.ToUpper(c).ToString());
            }

            // Some keys do not convert directly because there are multiple
            // values for the enumeration. This is used to normalize the values.
            switch (key)
            {
            case Key.Next:
                return("Page_Down");

            case Key.L1:
                return("F11");

            case Key.L2:
                return("F12");
            }

            // Return the string representation of the key.
            return(key.ToString());
        }
Exemplo n.º 29
0
        private TLongChar GetItalicized(TChar c)
        {
            TLongChar r = c;

            if (c == 'h')
            {
                r = kMTUnicodePlanksConstant;
            }
            else if (IsUpperEn(c))
            {
                r = UnicodeMathCapitalItalicStart + (TLongChar)(c - 'A');
            }
            else if (IsLowerEn(c))
            {
                r = UnicodeMathLowerItalicStart + (TLongChar)(c - 'a');
            }
            else if (IsLowerGreek(c))
            {
                r = UnicodeGreekLowerItalicStart + (TLongChar)(c - UnicodeGreekLowerStart);
            }
            else if (IsUpperGreek(c))
            {
                r = UnicodeGreekCapitalItalicStart + (TLongChar)(c - UnicodeGreekUpperStart);
            }
            else if (IsGreekSymbol(c))
            {
                r = UnicodeGreekSymbolItalicStart + (TLongChar)GreekSymbolOrder(c);
            }
            return(r);
        }
Exemplo n.º 30
0
        private TLongChar GetBoldItalic(TChar c)
        {
            TLongChar r = c;

            if (IsLowerEn(c))
            {
                r = UnicodeMathLowerBoldItalicStart + (TLongChar)(c - 'a');
            }
            else if (IsUpperEn(c))
            {
                r = UnicodeMathCapitalBoldItalicStart + (TLongChar)(c - 'A');
            }
            else if (IsUpperGreek(c))
            {
                r = UnicodeGreekCapitalBoldItalicStart + (TLongChar)(c - UnicodeGreekUpperStart);
            }
            else if (IsLowerGreek(c))
            {
                r = UnicodeGreekLowerBoldItalicStart + (TLongChar)(c - UnicodeGreekLowerStart);
            }
            else if (IsGreekSymbol(c))
            {
                r = UnicodeGreekSymbolBoldItalicStart + (TLongChar)GreekSymbolOrder(c);
            }
            else if (IsNumber(c))
            {
                // no bold italic for numbers, so we just bold them.
                r = GetBold(c);
            }
            return(r);
        }
Exemplo n.º 31
0
 public static System.Boolean IsIdentifierStartCharTSS(
     /*OPCTrendLib.Scanner*/ object target,
     System.Char c)
 {
     //return (System.Boolean)Helper.CallMethod(target, "IsIdentifierStartChar", new object[] { c });
     return(false);
 }
Exemplo n.º 32
0
        /// <summary>取拼音第一个字段</summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static String GetFirst(Char ch)
        {
            var rs = Get(ch);
            if (!String.IsNullOrEmpty(rs)) rs = rs.Substring(0, 1);

            return rs;
        }
Exemplo n.º 33
0
        XmlToken DataText(Char c)
        {
            while (true)
            {
                switch (c)
                {
                    case Symbols.LessThan:
                    case Symbols.EndOfFile:
                        Back();
                        return NewCharacters();

                    case Symbols.Ampersand:
                        _stringBuffer.Append(CharacterReference(GetNext()));
                        c = GetNext();
                        break;

                    case Symbols.SquareBracketClose:
                        _stringBuffer.Append(c);
                        c = CheckCharacter(GetNext());
                        break;

                    default:
                        _stringBuffer.Append(c);
                        c = GetNext();
                        break;
                }
            }
        }
    static bool Encoding_GetByteCount__Char_Array__Int32__Int32(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 3)
        {
            System.Char[] arg0 = JSDataExchangeMgr.GetJSArg <System.Char[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new System.Char[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (System.Char)JSApi.getChar((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            System.Int32 arg1 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            System.Int32 arg2 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(((System.Text.Encoding)vc.csObj).GetByteCount(arg0, arg1, arg2)));
        }

        return(true);
    }
Exemplo n.º 35
0
        public SMSManager(Char receivingProjectCode, Char receivingProgramCode)
        {
            // check project code and program code availability.
            if (!arrayContains(usableCharset, receivingProjectCode))
                throw new ArgumentException("Project Code needs to be within accepted Charset");

            if (!arrayContains(usableCharset, receivingProgramCode))
                throw new ArgumentException("Program Code needs to be within accepted Charset");

            this.receivingProjectCode = receivingProjectCode;
            this.receivingProgramCode = receivingProgramCode;

            resendTimer = new System.Windows.Forms.Timer();

            /* Adds the event and the event handler for the method that will
            process the timer event to the timer. */
            resendTimer.Tick += new EventHandler(ResendFailedToSentMsgs);

            // Timer runs every 10 minutes.
            resendTimer.Interval = resendCheckInterval;
            resendTimer.Enabled = true;

            unfinishedSentMsgList = new Dictionary<String, SentMessage>();

            // create monitoring thread
            smsSendingMonitorThread = new Thread(new ThreadStart(smsSendingMonitor));
            smsSendingMonitorThread.Start();
        }
Exemplo n.º 36
0
 private static string POST(string Url, string Data)
 {
     WebRequest req = WebRequest.Create(Url);
     req.Method = "POST";
     req.Timeout = 100000;
     req.ContentType = "application/x-www-form-urlencoded";
     byte[] sentData = Encoding.GetEncoding(1251).GetBytes(Data);
     req.ContentLength = sentData.Length;
     Stream sendStream = req.GetRequestStream();
     sendStream.Write(sentData, 0, sentData.Length);
     sendStream.Close();
     WebResponse res = req.GetResponse();
     Stream ReceiveStream = res.GetResponseStream();
     StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8);
     //Кодировка указывается в зависимости от кодировки ответа сервера
     Char[] read = new Char[256];
     int count = sr.Read(read, 0, 256);
     string Out = String.Empty;
     while (count > 0)
     {
         String str = new String(read, 0, count);
         Out += str;
         count = sr.Read(read, 0, 256);
     }
     return Out;
 }
        private Environment GetEnvironment(string credential)
        {
            var separators = new Char [] { '$' };
            var environment = credential.Split(separators)[1];

            return Environment.ParseEnvironment(environment);
        }
Exemplo n.º 38
0
 internal static System.String Decode(System.String entity)
 {
     if (entity[entity.Length - 1] == ';')
     {
         // remove trailing semicolon
         entity = entity.Substring(0, (entity.Length - 1) - (0));
     }
     if (entity[1] == '#')
     {
         int start = 2;
         int radix = 10;
         if (entity[2] == 'X' || entity[2] == 'x')
         {
             start++;
             radix = 16;
         }
         System.Char c = (char)System.Convert.ToInt32(entity.Substring(start), radix);
         return(c.ToString());
     }
     else
     {
         System.String s = (System.String)decoder[entity];
         if (s != null)
         {
             return(s);
         }
         else
         {
             return("");
         }
     }
 }
Exemplo n.º 39
0
 private bool caseInsensitiveCharactersMatch(Char firstCharacter, Char secondCharacter)
 {
     var lowerCaseFirstCharacter = char.ToLowerInvariant(firstCharacter);
     var lowerCaseSecondCharacter = char.ToLowerInvariant(secondCharacter);
     var charactersMatch = lowerCaseFirstCharacter.CompareTo(lowerCaseSecondCharacter) == 0;
     return charactersMatch;
 }
Exemplo n.º 40
0
        /// <summary>
        /// Adds a plug mapping
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        public void AddPlug(Char from, Char to)
        {
            var workingFrom = from;
            if (char.IsLower(workingFrom))
            {
                workingFrom = Char.ToUpper(workingFrom);
            }

            var workingTo = to;
            if (char.IsLower(workingTo))
            {
                workingTo = Char.ToUpper(workingTo);
            }

            if (Plugs.ContainsKey(from))
            {
                var existingTo = this.Plugs[from];
                throw new PlugBoardException("Already mapped {0} <=> {1}".Format(from, existingTo));
            }
            if (Plugs.ContainsKey(to))
            {
                var existingFrom = this.Plugs[to];
                throw new PlugBoardException("Already mapped {0} <=> {1}".Format(existingFrom, to));
            }

            Plugs.Add(workingFrom, workingTo);
            Plugs.Add(workingTo, workingFrom);
        }
Exemplo n.º 41
0
 public static Char CreateCharacter(short type, int chrId)
 {
     XElement cls = XmlDatas.TypeToElement[type];
     if (cls == null) return null;
     var ret = new Char
     {
         ObjectType = type,
         CharacterId = chrId,
         Level = 1,
         Exp = 0,
         CurrentFame = 0,
         Backpack = 1,
         _Equipment = cls.Element("Equipment").Value,
         MaxHitPoints = int.Parse(cls.Element("MaxHitPoints").Value),
         HitPoints = int.Parse(cls.Element("MaxHitPoints").Value),
         MaxMagicPoints = int.Parse(cls.Element("MaxMagicPoints").Value),
         MagicPoints = int.Parse(cls.Element("MaxMagicPoints").Value),
         Attack = int.Parse(cls.Element("Attack").Value),
         Defense = int.Parse(cls.Element("Defense").Value),
         Speed = int.Parse(cls.Element("Speed").Value),
         Dexterity = int.Parse(cls.Element("Dexterity").Value),
         HpRegen = int.Parse(cls.Element("HpRegen").Value),
         MpRegen = int.Parse(cls.Element("MpRegen").Value),
         Tex1 = 0,
         Tex2 = 0,
         Dead = false,
         PCStats = "",
         FameStats = new FameStats(),
         Pet = -1
     };
     ret.Backpacks = new Dictionary<int, short[]> { { 1, ret.PackFromEquips() } };
     return ret;
 }
Exemplo n.º 42
0
		/// <summary>Converts the value from <c>Char[]</c> to an equivalent <c>Byte[]</c> value.</summary>
		public static Byte[] ToByteArray(Char[] p)
		{
			var bytes = new Byte[Buffer.ByteLength(p)];

			Buffer.BlockCopy(p, 0, bytes, 0, bytes.Length);
			return bytes;
		}
Exemplo n.º 43
0
        public MFTestResults Ctor_Test()
        {
            /// <summary>
            /// 1. Tests the constructors of the string type
            /// </summary>
            ///
            Log.Comment("Test of the standard constructor");
            bool testResult = true;
            char[] car = new Char[] { 'a', 'b', 'c', 'd' };

            Log.Comment("Char [], start, number");
            string str = new string(car, 1, 2);
            testResult &= (str == "bc");

            str = new string(car, 0, 4);
            testResult &= (str == "abcd");
            
            Log.Comment("Char []");
            str = new string(car);
            testResult &= (str == "abcd");

            Log.Comment("Char, number");
            str = new string('\n', 33);
            testResult &= (str.Length == 33);
            for (int i = 0; i < str.Length; i++)
                testResult &= (str[i] == '\n');

            Log.Comment("Char, string terminator known failure. ");
            char[] car2 = new char[] { (char)0, (char)65};
            string s = new string(car2);
            testResult &= (s == "\0A");
                
            Log.Comment("This was previously bug 20620");
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
Exemplo n.º 44
0
        private TLongChar GetBold(TChar c)
        {
            TLongChar r = c;

            if (IsUpperEn(c))
            {
                r = UnicodeMathCapitalBoldStart + (TLongChar)(c - 'A');
            }
            else if (IsLowerEn(c))
            {
                r = UnicodeMathLowerBoldStart + (TLongChar)(c - 'a');
            }
            else if (IsUpperGreek(c))
            {
                r = UnicodeGreekCapitalBoldStart + (TLongChar)(c - UnicodeGreekUpperStart);
            }
            else if (IsLowerGreek(c))
            {
                r = UnicodeGreekLowerBoldStart + (TLongChar)(c - UnicodeGreekLowerStart);
            }
            else if (IsNumber(c))
            {
                r = UnicodeNumberBoldStart + (TLongChar)(c - '0');
            }
            return(r);
        }
 public static IFolder GetIDirectoryManagerStub(Char[] illegalChars, Int32 maxPath)
 {
     IFolder dirManager = MockRepository.GenerateStub<IFolder>();
     dirManager.Stub(d => d.GetIllegalPathChars()).Return(illegalChars);
     dirManager.Stub(d => d.MaxPath()).Return(maxPath);
     return dirManager;
 }
Exemplo n.º 46
0
		/// <summary>
		/// Creates a parser that matches a single character
		/// </summary>
		/// <param name="matchCharacter">character to match</param>
		/// <returns></returns>
		public static CharParser Ch(Char matchCharacter)
		{
			return new CharParser(delegate(Char c)
			{
				return matchCharacter == c;
			});
		}
Exemplo n.º 47
0
		public static List<String> getSubString (String s, Char[] sep)
		{
			String[] words = s.Split (sep);
			//s.Substring(0,50)
			List<String> sl = new List<String> ();
			String tmps = "";

			for (int i = 0; i < words.Length; i++) {
				if (i == 0 && words.Length == 1) {
					sl.Add (words [i]);
				} else if (i < words.Length - 1) {
					if (tmps.Length == 0)
						tmps = words [i];
					else if (tmps.Length < 50)
						tmps += words [i];
					else {
						sl.Add (tmps);
						tmps = words [i];
					}
				} else {
					sl.Add (tmps + words [i]);
				}
			}
			return sl;
		}
        /// <summary>
        /// post方法传递json数据
        /// </summary>
        /// <param name="urlStr">目标url</param>
        /// <param name="urlStrFunc">对应方法</param>
        /// <param name="urlStrPara">json参数</param>
        /// <returns></returns>
        public static string Post_RSA_Json(string urlStr, string urlStrFunc, string urlStrPara)
        {
            Encoding encode = Encoding.UTF8;
            byte[] arrB = encode.GetBytes(urlStrPara);
            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(urlStr + urlStrFunc);
            myReq.Method = "POST";
            myReq.ContentType = "application/x-www-form-urlencoded";
            myReq.ContentLength = arrB.Length;
            Stream outStream = myReq.GetRequestStream();
            outStream.Write(arrB, 0, arrB.Length);
            outStream.Close();
            //接收HTTP做出的响应
            WebResponse myResp = myReq.GetResponse();

            Stream ReceiveStream = myResp.GetResponseStream();
            StreamReader readStream = new StreamReader(ReceiveStream, encode);
            Char[] read = new Char[256];
            int count = readStream.Read(read, 0, 256);
            string str = null;
            while (count > 0)
            {
                str += new String(read, 0, count);
                count = readStream.Read(read, 0, 256);
            }
            readStream.Close();
            myResp.Close();
            return str;
        }
Exemplo n.º 49
0
        /// <summary>
        /// The text declaration for external DTDs.
        /// </summary>
        /// <param name="c">The character.</param>
        /// <returns>The token.</returns>
        protected DtdToken TextDecl(Char c)
        {
            if (_external)
            {
                var token = new DtdDeclToken();

                if (c.IsSpaceCharacter())
                {
                    c = SkipSpaces(c);

                    if (_stream.ContinuesWith(AttributeNames.VERSION))
                    {
                        _stream.Advance(6);
                        return TextDeclVersion(_stream.Next, token);
                    }
                    else if (_stream.ContinuesWith(AttributeNames.ENCODING))
                    {
                        _stream.Advance(7);
                        return TextDeclEncoding(_stream.Next, token);
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
Exemplo n.º 50
0
        /// <summary>
        /// based on http://weblogs.asp.net/abdullaabdelhaq/archive/2009/06/27/displaying-arabic-number.aspx
        /// seems like a fairly expensive method to call so not sure if its suitable to use this everywhere
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string SubstituteArabicDigits(string input)
        {
            if (string.IsNullOrEmpty(input)) { return input; }

            Encoding utf8 = new UTF8Encoding();
            Decoder utf8Decoder = utf8.GetDecoder();
            StringBuilder result = new StringBuilder();

            Char[] translatedChars = new Char[1];
            Char[] inputChars = input.ToCharArray();
            Byte[] bytes = { 217, 160 };

            foreach (Char c in inputChars)
            {
                if (Char.IsDigit(c))
                {
                    // is this the key to it all? does adding 160 change to the unicode char for Arabic?
                    //So we can do the same with other languages using a different offset?
                    bytes[1] = Convert.ToByte(160 + Convert.ToInt32(char.GetNumericValue(c)));
                    utf8Decoder.GetChars(bytes, 0, 2, translatedChars, 0);
                    result.Append(translatedChars[0]);
                }
                else
                {
                    result.Append(c);
                }
            }

            return result.ToString();
        }
Exemplo n.º 51
0
        private static void DecodePixelData(ref Dictionary<Char, UInt32> upper, ref Dictionary<Char, UInt32> lower, ref Byte[] texturePixels, Char c, Int32 textureWidth)
        {
            Int32 charPstn = GetGlyphIndex(c);
            Int32 charTextureOffset = charPstn * FontWidth;
            Int32 halfway = FontWidth * FontHeight / 2;
            Boolean pixelIsLit;

            for (Int32 y = 0; y < FontHeight; y++)
            {
                Int32 textureRowPixelOffset = y * textureWidth;
                Int32 charRowPixelOffset = y * FontWidth;

                for (Int32 x = 0; x < FontWidth; x++)
                {
                    Int32 charPixelIndex =  x + charRowPixelOffset;

                    if(charPixelIndex < halfway)
                        pixelIsLit = ((upper[c] & (1 << charPixelIndex)) != 0);
                    else
                        pixelIsLit = ((lower[c] & (1 << (charPixelIndex - halfway))) != 0);

                    Int32 texturePixelIndex = textureRowPixelOffset + charTextureOffset + x;

                    texturePixels[texturePixelIndex] = pixelIsLit ? PixelLit : PixelDark;
                }
            }
        }
Exemplo n.º 52
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static AtomEntry CreateAtomEntry(int iCount)
        {
            AtomEntry entry = new AtomEntry();
            // some unicode chars
            Char[] chars = new Char[] {
            '\u0023', // #
            '\u0025', // %
            '\u03a0', // Pi
            '\u03a3',  // Sigma
            '\u03d1', // beta
            '&',
            };

            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3] + chars[4] + chars[5]; 
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);
    
            AtomCategory cat = new AtomCategory();
    
            cat.Label = "Default";
            cat.Term = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);
    
            entry.Content.Content = "this is the default text & entry";
            entry.Content.Type = "html"; 
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

    
            return entry;
        }
Exemplo n.º 53
0
 private int GreekSymbolOrder(TChar c)
 {
     // These greek symbols that always appear in unicode in this particular order
     // after the alphabet.
     // The symbols are epsilon, vartheta, varkappa, phi, varrho, and varpi.
     TChar[] greekSymbols = { '\x03F5', '\x03D1', '\x03F0', '\x03D5', '\x03F1', '\x03D6' };
     return(Array.IndexOf(greekSymbols, c));
 }
Exemplo n.º 54
0
        /////////////////////////////////////////////////////////////////
        //
        // NFA building functions
        //
        // Using Thompson Construction, build NFAs from basic inputs or
        // compositions of other NFAs.
        //

        /// <summary>
        /// Builds a basic, single input NFA
        /// </summary>
        /// <param name="in"></param>
        /// <returns></returns>
        public static NFA BuildNFABasic(input @in)
        {
            NFA basic = new NFA(2, 0, 1);

            basic.AddTrans(0, 1, @in);

            return(basic);
        }
Exemplo n.º 55
0
 public virtual void  TestValueOf()
 {
     for (int i = 0; i < 256; i++)
     {
         System.Char valueOf = CharacterCache.ValueOf((char)i);
         Assert.AreEqual((char)i, valueOf);
     }
 }
Exemplo n.º 56
0
 public void Write(System.Char data)
 {
     unsafe
     {
         System.Char *pPtr = &data;
         Write((IntPtr)pPtr, sizeof(System.Char));
     }
 }
Exemplo n.º 57
0
 public void TestChar()
 {
     System.Char arg    = 'a';
     System.Char result = m_test.TestEchoChar(arg);
     Assertion.AssertEquals(arg, result);
     arg    = '0';
     result = m_test.TestEchoChar(arg);
     Assertion.AssertEquals(arg, result);
 }
Exemplo n.º 58
0
        private TLongChar GetCaligraphic(TChar c)
        {
            // Caligraphic has lots of exceptions:
            switch (c)
            {
            case 'B':
                return(0x212C); // Script B (bernoulli)

            case 'E':
                return(0x2130); // Script E (emf)

            case 'F':
                return(0x2131); // Script F (fourier)

            case 'H':
                return(0x210B); // Script H (hamiltonian)

            case 'I':
                return(0x2110); // Script I

            case 'L':
                return(0x2112); // Script L (laplace)

            case 'M':
                return(0x2133); // Script M (M-matrix)

            case 'R':
                return(0x211B); // Script R (Riemann integral)

            case 'e':
                return(0x212F); // Script e (Natural exponent)

            case 'g':
                return(0x210A); // Script g (real number)

            case 'o':
                return(0x2134); // Script o (order)
            }
            TLongChar r;

            if (IsUpperEn(c))
            {
                r = UnicodeMathCapitalScriptStart + (TLongChar)(c - 'A');
            }
            else if (IsLowerEn(c))
            {
                // Latin modern math doesn't have lower case caligraphic characters
                r = GetDefaultStyle(c);
            }
            else
            {
                // doesn't exist for greek or numbers.
                r = GetDefaultStyle(c);
            }
            return(r);
        }
Exemplo n.º 59
0
 public static extern int multiSignedMessage_Init(
     String segurisignIP,
     int segurisignPort,
     StringBuilder data,
     int dataLen,
     System.Char dataType,     // 0 - Información a registrar; 1 - Ruta del archivo a registrar; 2 - Digestión del archivo (SHA1)
     String info,
     StringBuilder theID,
     StringBuilder theDigest,
     ref int theDigestLen,
     StringBuilder errorMsg);
Exemplo n.º 60
0
        public static System.Globalization.UnicodeCategory GetUnicodeCategoryTSSS(System.Char c)
        {
            string currentMethodName = Dottest.Framework.Stubs.CurrentTestMethod.Name;

            if (currentMethodName.Equals("TestIsIdentifierStartChar121") ||
                currentMethodName.Equals("TestIsIdentifierPartChar121"))
            {
                return(System.Globalization.UnicodeCategory.ConnectorPunctuation);
            }
            return(System.Globalization.UnicodeCategory.LetterNumber);
        }