当前位置: 首页>>代码示例>>C#>>正文


C# Reader类代码示例

本文整理汇总了C#中Reader的典型用法代码示例。如果您正苦于以下问题:C# Reader类的具体用法?C# Reader怎么用?C# Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Reader类属于命名空间,在下文中一共展示了Reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestVector

                public void TestVector()
                {
                    Reader rdr = new Reader();
                    NLVector vec = (NLVector)rdr.ReadFirstForm("[]");
                    Assert.IsNotNull(vec);
                    Assert.AreEqual(0, vec.Contents.Length);

                    vec = (NLVector) rdr.ReadFirstForm("[1]");
                    Assert.IsNotNull(vec);
                    Assert.AreEqual(1, vec.Contents.Length);
                    long ival = (long)vec.Contents[0];
                    Assert.AreEqual(1, ival);

                    vec = (NLVector)rdr.ReadFirstForm("[ 1, 2]");
                    Assert.IsNotNull(vec);
                    Assert.AreEqual(2, vec.Contents.Length);

                    ival = (long)vec.Contents[0];
                    Assert.AreEqual(1, ival);

                    ival = (long)vec.Contents[1];
                    Assert.AreEqual(2, ival);

                    vec = (NLVector)rdr.ReadFirstForm(" [ [, 42 ] \"a\" ]");
                    Assert.IsNotNull(vec);
                    Assert.AreEqual(2, vec.Contents.Length);

                    NLVector vval = (NLVector)vec.Contents[0];
                    Assert.AreEqual(42, (long)vval.Contents[0]);

                    string sval = (string)vec.Contents[1];
                    Assert.AreEqual("a", sval);
                }
开发者ID:foogoof,项目名称:nihilisp,代码行数:33,代码来源:TestReader.cs

示例2: TestReadsLines

 public void TestReadsLines()
 {
     Reader reader = new Reader(new StringReader("Line 0\n   Line 1\nLine 2   \n\n\n   Line 3   \n	Line 4		"));
     int lineNumber = 0;
     foreach (Line line in reader)
         Assert.AreEqual($"Line {lineNumber++}", line.Content);
 }
开发者ID:duhaly,项目名称:FormGenerator,代码行数:7,代码来源:ReaderTests.cs

示例3: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator)
            {
                MessageBox.Show("You must deploy this sample to a device, instead of the emulator so that you can get a video stream including a barcode/QR code");
                this.IsEnabled = false;
                base.NavigationService.GoBack();
            }
            else
            {
                string type = "";
                if (NavigationContext.QueryString.TryGetValue("type", out type) && type == "qrcode")
                {
                    _reader = new QRCodeReader();
                }
                else
                {
                    _reader = new EAN13Reader();
                }

                _photoCamera = new PhotoCamera();
                _photoCamera.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(cam_Initialized);
                _videoBrush.SetSource(_photoCamera);
                BarCodeRectInitial();
                base.OnNavigatedTo(e);
            }
        }
开发者ID:gzb1985,项目名称:WP7BarcodeScannerExample,代码行数:27,代码来源:BarCode.xaml.cs

示例4: assertHTMLStripsTo

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public static void assertHTMLStripsTo(java.io.Reader input, String gold, java.util.Set<String> escapedTags) throws Exception
 public static void assertHTMLStripsTo(Reader input, string gold, ISet<string> escapedTags)
 {
     HTMLStripCharFilter reader;
     if (null == escapedTags)
     {
       reader = new HTMLStripCharFilter(input);
     }
     else
     {
       reader = new HTMLStripCharFilter(input, escapedTags);
     }
     int ch = 0;
     StringBuilder builder = new StringBuilder();
     try
     {
       while ((ch = reader.read()) != -1)
       {
     builder.Append((char)ch);
       }
     }
     catch (Exception e)
     {
       if (gold.Equals(builder.ToString()))
       {
     throw e;
       }
       throw new Exception("('" + builder.ToString() + "' is not equal to '" + gold + "').  " + e.Message, e);
     }
     assertEquals("'" + builder.ToString() + "' is not equal to '" + gold + "'", gold, builder.ToString());
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:32,代码来源:HTMLStripCharFilterTest.cs

示例5: TestBrokenSearchTreePointer

 public void TestBrokenSearchTreePointer()
 {
     using (var reader = new Reader(Path.Combine(TestDataRoot, "MaxMind-DB-test-broken-pointers-24.mmdb")))
     {
         reader.Find("1.1.1.32");
     }
 }
开发者ID:Wolfium,项目名称:MaxMind-DB-Reader-dotnet,代码行数:7,代码来源:ReaderTest.cs

示例6: Parse

		public override void Parse(byte[] buffer)
		{
			Reader reader = new Reader(new MemoryStream(buffer));

			reader.ReadByte(); // Id
			MessageId = reader.ReadInt32();

			int count = reader.ReadInt32();
			Arguments = new KeyValuePair<type, object>[count];
			for (int i = 0; i < count; i++)
			{
				var key = (type)reader.ReadInt32();
				object value = null;
				switch (key)
				{
					case type.Text:
						value = reader.ReadString(Encoding.Unicode);
						break;
					case type.Number:
						value = reader.ReadInt32();
						break;
					case type.NpcName:
						value = reader.ReadInt32();
						break;
					case type.ItemName:
						value = reader.ReadInt32();
						break;
					case type.SkillName:
						value = reader.ReadInt32();
						reader.ReadInt32(); //there are 4 more bytes after this... the skill level by chance?
						break;
				}
				Arguments[i] = new KeyValuePair<type, object>(key, value);
			}
		}
开发者ID:EligiusSantori,项目名称:L2Apf.NET,代码行数:35,代码来源:SystemMessage.cs

示例7: CreateSeparateServices

 static OrderController CreateSeparateServices()
 {
     var reader = new Reader<Order>();
     var saver = new Saver<Order>();
     var deleter = new Deleter<Order>();
     return new OrderController(reader, saver, deleter);
 }
开发者ID:aleksandrzak-rafal,项目名称:AdaptiveCode,代码行数:7,代码来源:Program.cs

示例8: TestParallelFor

        public void TestParallelFor(FileAccessMode mode)
        {
            var count = 0;
            var ipsAndResults = new Dictionary<IPAddress, string>();
            var rand = new Random();
            using (var reader = new Reader(Path.Combine("..", "..", "TestData", "GeoLite2-City.mmdb"), mode))
            {
                while (count < 10000)
                {
                    var ip = new IPAddress(rand.Next(int.MaxValue));
                    var resp = reader.Find(ip);
                    if (resp != null && !ipsAndResults.ContainsKey(ip))
                    {
                        ipsAndResults.Add(ip, resp.ToString());
                        count++;
                    }
                }

                var ips = ipsAndResults.Keys.ToArray();
                Parallel.For(0, ips.Length, i =>
                {
                    var ipAddress = ips[i];
                    var result = reader.Find(ipAddress);
                    var resultString = result.ToString();
                    var expectedString = ipsAndResults[ipAddress];
                    if (resultString != expectedString)
                        throw new Exception($"Non-matching result. Expected {expectedString}, found {resultString}");
                });
            }
        }
开发者ID:RalphSim,项目名称:MaxMind-DB-Reader-dotnet,代码行数:30,代码来源:ThreadingTest.cs

示例9: read_atom

 public static MalVal read_atom(Reader rdr)
 {
     string token = rdr.next();
     string pattern = @"(^-?[0-9]+$)|(^-?[0-9][0-9.]*$)|(^nil$)|(^true$)|(^false$)|^("".*"")$|:(.*)|(^[^""]*$)";
     Regex regex = new Regex(pattern);
     Match match = regex.Match(token);
     //Console.WriteLine("token: ^" + token + "$");
     if (!match.Success) {
         throw new ParseError("unrecognized token '" + token + "'");
     }
     if (match.Groups[1].Value != String.Empty) {
         return new Mal.types.MalInt(int.Parse(match.Groups[1].Value));
     } else if (match.Groups[3].Value != String.Empty) {
         return Mal.types.Nil;
     } else if (match.Groups[4].Value != String.Empty) {
         return Mal.types.True;
     } else if (match.Groups[5].Value != String.Empty) {
         return Mal.types.False;
     } else if (match.Groups[6].Value != String.Empty) {
         string str = match.Groups[6].Value;
         str = str.Substring(1, str.Length-2)
             .Replace("\\\"", "\"")
             .Replace("\\n", "\n");
         return new Mal.types.MalString(str);
     } else if (match.Groups[7].Value != String.Empty) {
         return new Mal.types.MalString("\u029e" + match.Groups[7].Value);
     } else if (match.Groups[8].Value != String.Empty) {
         return new Mal.types.MalSymbol(match.Groups[8].Value);
     } else {
         throw new ParseError("unrecognized '" + match.Groups[0] + "'");
     }
 }
开发者ID:nboyd,项目名称:mal,代码行数:32,代码来源:reader.cs

示例10: Read2

 public static SimplyInt Read2(Reader reader)
 {
     SimplyInt result = new SimplyInt();
     result.Field1 = -reader.Read<int>();
     result.Field2 = reader.Read<uint>();
     return result;
 }
开发者ID:ExM,项目名称:OncRpc,代码行数:7,代码来源:SimplyInt.cs

示例11: cmdImport_Click

    protected void cmdImport_Click(object sender, EventArgs e)
    {
        var connection = new SQLServerConnect();
        //for live db
        //connection.SetupConnectionString("Server=MyPetsFW.db.3554730.hostedresource.com;USER ID=MyPetsFW;Password=DevryWeb460;Database=MyPetsFW;Trusted_Connection=False;");

        //for my local db
        //connection.SetupConnectionString("JON/Chris", "", @"Jon\SQLEXPRESS", "MyPetsFW");

        connection.SetupConnectionString("TestUser", "testuser", @"Jon\SQLEXPRESS", "MyPetsFW");

        var reader = new Reader
        {
            VendorID = 1,
            LogFile = @"C:\WEB460\DataImport\Output\Import09.log",
            DebugLevel = 3
        };

        const string fileName = @"C:\WEB460\DataImport\20090310-Products.txt";

        //string output = !reader.DoImport(fileName, connection) ?
        //            "There was an problem with the import." :
        //            "Import Successful.";
        //Console.WriteLine(output);

        lblError.Text = !reader.DoImport(fileName, connection) ? "There was an problem with the import" : "Import Successful";
    }
开发者ID:jasonhuber,项目名称:devryweb460store,代码行数:27,代码来源:Import.aspx.cs

示例12: ReceiveEventArgs

 public ReceiveEventArgs(Socket socket, ArrayList sockets)
 {
     this.socket = socket;
     this.clients = sockets;
     this.reader = new Reader(this.socket);
     this.writer = new Writer(this.socket);
 }
开发者ID:qq5013,项目名称:XJ_WCS,代码行数:7,代码来源:ReceiveEventArgs.cs

示例13: Parse

		public override void Parse(byte[] buffer)
		{
			Reader reader = new Reader(new MemoryStream(buffer));

			reader.ReadByte(); // Id
			int Count = reader.ReadByte();
			reader.ReadByte(); // ?

			List = new List<Model.GameServer>(Count);
			for (int i = 0; i < Count; i++)
				List.Add(new Model.GameServer()
				{
					Id = reader.ReadByte(),
					Address = string.Format("{0}.{1}.{2}.{3}", // ToDo: replace to native
						reader.ReadByte().ToString(),
						reader.ReadByte().ToString(),
						reader.ReadByte().ToString(),
						reader.ReadByte().ToString()),
					Port = reader.ReadInt32(),
					Age = reader.ReadByte(),
					PvP = reader.ReadByte() != 0,
					Online = reader.ReadInt16(),
					Maximum = reader.ReadInt16(),
					State = reader.ReadByte() != 0,
					Poop = string.Format("{0}-{1}-{2}-{3}-{4}", // ToDo: What is?
						reader.ReadByte().ToString("X2"),
						reader.ReadByte().ToString("X2"),
						reader.ReadByte().ToString("X2"),
						reader.ReadByte().ToString("X2"),
						reader.ReadByte().ToString("X2"))
				});
		}
开发者ID:EligiusSantori,项目名称:L2Apf.NET,代码行数:32,代码来源:GameServerList.cs

示例14: GeoIP

 static GeoIP()
 {
     using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ProxySearch.Engine.Resources.GeoLite2-Country.mmdb"))
     {
         Reader = new Reader(stream);
     }
 }
开发者ID:rburda82,项目名称:proxysearcher,代码行数:7,代码来源:GeoIP.cs

示例15: Parse

		public override void Parse(byte[] buffer)
		{
			Reader reader = new Reader(new MemoryStream(buffer));

			reader.ReadByte(); // Id
			Reason = (ReasonType)reader.ReadByte();
		}
开发者ID:EligiusSantori,项目名称:L2Apf.NET,代码行数:7,代码来源:LoginFail.cs


注:本文中的Reader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。