コード例 #1
0
ファイル: MdBinaryReaderGen.cs プロジェクト: tijoytom/corert
        } // Read

        public static unsafe uint Read(this NativeReader reader, uint offset, out CharCollection values)
        {
            values = new CharCollection(reader, offset);
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            offset = checked(offset + count * sizeof(Char));
            return offset;
        } // Read
コード例 #2
0
ファイル: MdBinaryReaderGen.cs プロジェクト: wffy/corert
        } // Read

        public static unsafe uint Read(this NativeReader reader, uint offset, out CharCollection values)
        {
            values = new CharCollection(reader, offset);
            uint count;

            offset = reader.DecodeUnsigned(offset, out count);
            offset = checked (offset + count * sizeof(Char));
            return(offset);
        } // Read
コード例 #3
0
        /// <summary>
        /// 生成随机字符串
        /// </summary>
        /// <returns></returns>
        public string GetRandomString(Int32 textLength)
        {
            string[] randomArray  = CharCollection.Split(','); //将字符串生成数组
            int      arrayLength  = randomArray.Length;
            string   randomString = "";

            for (int i = 0; i < textLength; i++)
            {
                randomString += randomArray[random.Next(0, arrayLength)];
            }

            return(randomString); //长度是textLength +1
        }
コード例 #4
0
        public static char[] ToArray(this CharCollection collection)
        {
            int count = collection.Count;

            char[] result = new char[count];
            int    i      = 0;

            foreach (char element in collection)
            {
                result[i++] = element;
            }
            Debug.Assert(i == count);
            return(result);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: snegdaholoda/cSharp
        static void Main(string[] args)
        {
            ByteCollection list1 = new ByteCollection();

            for (int i = 0; i < 9; i++)
            {
                //             list1.Add(i);                  //   This isn't compiled

                list1.Add((byte)i);
            }
            foreach (byte i in list1)
            {
                Console.WriteLine(" {0} ", i);
            }
            Console.WriteLine();



            CharCollection list2 = new CharCollection();

            //         list2.Add(5);                 //   This isn't compiled

            list2.Add('a');
            list2.Add('b');
            list2.Add('c');
            list2.Add('d');
            list2.Add('e');
            list2.Add('f');

            foreach (char i in list2)
            {
                Console.WriteLine(" {0} ", i);
            }

            Console.ReadKey();
        }
コード例 #6
0
        internal static CharCollection GetDefaultCharReplacements()
        {
            var dictionary = new Dictionary<char, string>()
                        {
                            {' ',"-"},
                            {'\"',""},
                            {'\'',""},
                            {'%',""},
                            {'.',""},
                            {';',""},
                            {'/',""},
                            {'\\',""},
                            {':',""},
                            {'#',""},
                            {'+',"plus"},
                            {'*',"star"},
                            {'&',""},
                            {'?',""},
                            {'æ',"ae"},
                            {'ø',"oe"},
                            {'å',"aa"},
                            {'ä',"ae"},
                            {'ö',"oe"},
                            {'ü',"ue"},
                            {'ß',"ss"},
                            {'Ä',"ae"},
                            {'Ö',"oe"},
                            {'|',"-"},
                            {'<',""},
                            {'>',""}
                        };

            //const string chars = @" ,"",',%,.,;,/,\,:,#,+,*,&,?,æ,ø,å,ä,ö,ü,ß,Ä,Ö,|,<,>";

            var collection = new CharCollection();
            foreach (var c in dictionary)
            {
                collection.Add(new CharElement
                {
                    Char = c.Key.ToString(CultureInfo.InvariantCulture),
                    Replacement = c.Value.ToString(CultureInfo.InvariantCulture)
                });
            }

            return collection;
        }