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


C# BufferedStream.Close方法代码示例

本文整理汇总了C#中BufferedStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# BufferedStream.Close方法的具体用法?C# BufferedStream.Close怎么用?C# BufferedStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BufferedStream的用法示例。


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

示例1: writeFile

    /**
       	 * Writes a file from the contents of a String
       	 * @param filename The name of the file.
       	 * @return The String to write to the file.
       	 */
    public static void writeFile(string filename, string contents)
    {
        FileStream fs = null;
        BufferedStream bs = null;
        StreamWriter sw = null;

        try
        {
            fs = new FileStream(filename, FileMode.Open);

            // Here BufferedInputStream is added for fast writing.
            bs = new BufferedStream(fs);
            sw = new StreamWriter(bs);
            sw.Write(contents);

            // dispose all the resources after using them.
            fs.Close();
            bs.Close();
            sw.Close();
        }

        catch (FileNotFoundException e)
        {
            System.Console.WriteLine(e.ToString());
        }

        catch (IOException e)
        {
            System.Console.WriteLine(e.ToString());
        }
    }
开发者ID:sylvainhalle,项目名称:BeepBeepCSharp,代码行数:36,代码来源:SimpleFileWriter.cs

示例2: Example_19

    public Example_19()
    {
        try {

            FileStream fos = new FileStream("Example_19.pdf", FileMode.Create);
            BufferedStream bos = new BufferedStream(fos);

            PDF pdf = new PDF( bos );

            FileStream fis = new FileStream( "Example_03.pdf", FileMode.Open );

            // FileInputStream fis = new FileInputStream( "PDF32000_2008.pdf" );

            BufferedStream bis = new BufferedStream( fis );
            List< PDFobj > objects = pdf.read(bis);
            for ( int j = 0; j < objects.Count; j++ ) {
                PDFobj obj = ( PDFobj ) objects[j];
                for ( int i = 0; i < obj.dict.Count; i++ ) {
                    Console.WriteLine(obj.dict[i]);
                }
                Console.WriteLine();
            }
            bis.Close();

            pdf.Flush();
            bos.Close();
        }
        catch ( Exception e ) {
            Console.WriteLine(e.StackTrace);
        }
    }
开发者ID:pauljs,项目名称:Justin-Paul-s-Projects,代码行数:31,代码来源:Example_19.cs

示例3: Example_04

    public Example_04()
    {
        String fileName = "data/happy-new-year.txt";

        FileStream fos = new FileStream("Example_04.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Font f1 = new Font(
                pdf,
                "AdobeMingStd-Light",       // Chinese (Traditional) font
                CodePage.UNICODE);
        Font f2 = new Font(
                pdf,
                "AdobeSongStd-Light",       // Chinese (Simplified) font
                CodePage.UNICODE);
        Font f3 = new Font(
                pdf,
                "KozMinProVI-Regular",      // Japanese font
                CodePage.UNICODE);
        Font f4 = new Font(
                pdf,
                "AdobeMyungjoStd-Medium",   // Korean font
                CodePage.UNICODE);

        Page page = new Page(pdf, Letter.PORTRAIT);

        f1.SetSize(14);
        f2.SetSize(14);
        f3.SetSize(14);
        f4.SetSize(14);

        double x_pos = 100.0;
        double y_pos = 20.0;
        StreamReader reader = new StreamReader(
                new FileStream(fileName, FileMode.Open));
        TextLine text = new TextLine(f1);
        String line = null;
        while ((line = reader.ReadLine()) != null) {
            if (line.IndexOf("Simplified") != -1) {
                text.SetFont(f2);
            } else if (line.IndexOf("Japanese") != -1) {
                text.SetFont(f3);
            } else if (line.IndexOf("Korean") != -1) {
                text.SetFont(f4);
            }
            text.SetText(line);
            text.SetPosition(x_pos, y_pos += 24);
            text.DrawOn(page);
        }
        reader.Close();

        pdf.Flush();
        bos.Close();
    }
开发者ID:pauljs,项目名称:Justin-Paul-s-Projects,代码行数:57,代码来源:Example_04.cs

示例4: Example_01

    public Example_01()
    {
        FileStream fos = new FileStream("Example_01.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Box flag = new Box();
        flag.SetPosition(100.0, 100.0);
        flag.SetSize(190.0, 100.0);
        flag.SetColor(RGB.WHITE);
        flag.DrawOn(page);

        double sw = 7.69;   // stripe width
        Line stripe = new Line(0.0, sw/2, 190.0, sw/2);
        stripe.SetWidth(sw);
        stripe.SetColor(RGB.OLD_GLORY_RED);
        for (int row = 0; row < 7; row++) {
            stripe.PlaceIn(flag, 0.0, row * 2 * sw);
            stripe.DrawOn(page);
        }

        Box union = new Box();
        union.SetSize(76.0, 53.85);
        union.SetColor(RGB.OLD_GLORY_BLUE);
        union.SetFillShape(true);
        union.PlaceIn(flag, 0.0, 0.0);
        union.DrawOn(page);

        double h_si = 12.6; // horizontal star interval
        double v_si = 10.8; // vertical star interval
        Point star = new Point(h_si/2, v_si/2);
        star.SetShape(Point.STAR);
        star.SetRadius(3.0);
        star.SetColor(RGB.WHITE);
        star.SetFillShape(true);

        for (int row = 0; row < 6; row++) {
            for (int col = 0; col < 5; col++) {
                star.PlaceIn(union, row * h_si, col * v_si);
                star.DrawOn(page);
            }
        }
        star.SetPosition(h_si, v_si);
        for (int row = 0; row < 5; row++) {
            for (int col = 0; col < 4; col++) {
                star.PlaceIn(union, row * h_si, col * v_si);
                star.DrawOn(page);
            }
        }

        pdf.Flush();
        bos.Close();
    }
开发者ID:pauljs,项目名称:Justin-Paul-s-Projects,代码行数:57,代码来源:Example_01.cs

示例5: Main

    static void Main(string[] args)
    {
        // Check that an argument was specified when the
        // program was invoked.
        //if (args.Length == 0)
        //{
        //    Console.WriteLine("Error: The name of the host computer" +
        //        " must be specified when the program is invoked.");
        //    return;
        //}

          //  string remoteName = args[0];

        // Create the underlying socket and connect to the server.
        Console.WriteLine("OS {0} {1} processors count {2}\n", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "x64" : "x32", Environment.ProcessorCount);
        Socket clientSocket = new Socket(AddressFamily.InterNetwork,
            SocketType.Stream, ProtocolType.Tcp);

        clientSocket.Connect(new IPEndPoint(
            IPAddress.Parse("127.0.0.1"), 1800));

        Console.WriteLine("Client is connected.\n");

        // Create a NetworkStream that owns clientSocket and
        // then create a BufferedStream on top of the NetworkStream.
        // Both streams are disposed when execution exits the
        // using statement.
        using (Stream
            netStream = new NetworkStream(clientSocket, true),
            bufStream =
                  new BufferedStream(netStream, streamBufferSize))
        {
            // Check whether the underlying stream supports seeking.
            Console.WriteLine("NetworkStream {0} seeking.\n",
                bufStream.CanSeek ? "supports" : "does not support");

            // Send and receive data.
            if (bufStream.CanWrite)
            {
                SendData(netStream, bufStream);
            }
            if (bufStream.CanRead)
            {
                ReceiveData(netStream, bufStream);
            }

            // When bufStream is closed, netStream is in turn
            // closed, which in turn shuts down the connection
            // and closes clientSocket.
            Console.WriteLine("\nShutting down the connection.");
            bufStream.Close();
        }
        Console.ReadKey();
    }
开发者ID:bednarskyi,项目名称:BufferedStream,代码行数:54,代码来源:Program.cs

示例6: GetChunkData

    /// <summary>
    /// Gets the chunk data.
    /// </summary>
    /// <returns>The chunk data.</returns>
    /// <param name="x">The x coordinate.</param>
    /// <param name="z">The z coordinate.</param>
    /// <param name="width">Width.</param>
    /// <param name="height">Height.</param>
    /// <param name="depth">Depth.</param>
    public CubicTerrainData GetChunkData(int x, int y, int z, int width, int height, int depth)
    {
        BufferedStream chunkDataStream = new BufferedStream (File.Open (this.chunkDataFile, FileMode.Open));
        CubicTerrainData terrainData = new CubicTerrainData (width, height, depth);

        // Get chunk starting position
        chunkDataStream.Position = this.chunkLookupTable [new ListIndex<int>(x,y,z)];

        terrainData.DeserializeChunk (chunkDataStream);
        chunkDataStream.Close ();

        return terrainData;
    }
开发者ID:robotpie,项目名称:cubicworld,代码行数:22,代码来源:CubicTerrainFile.cs

示例7: Main

    static void Main(string[] args)
    {
        Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            MD5 md5 = MD5.Create();
            HashSet<byte[]> hashSet = new HashSet<byte[]>();
            string linha;

            string arquivoOriginal = "big-file.txt";
            string arquivoSemDuplicacao = "arquivoSemDuplicacao.txt";
            int tamanhoBuffer = 10 * 1024 * 1014;

            FileStream fsw = new FileStream(arquivoSemDuplicacao, FileMode.CreateNew);
            BufferedStream bsw = new BufferedStream(fsw, tamanhoBuffer);
            StreamWriter sw = new StreamWriter(bsw);

            using (FileStream fs = new FileStream(arquivoOriginal, FileMode.Open))
            {
                using (BufferedStream bs = new BufferedStream(fs, tamanhoBuffer))
                {
                    using (StreamReader sr = new StreamReader(bs))
                    {
                        while ((linha = sr.ReadLine()) != null)
                        {
                            byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(linha));

                            if (!hashSet.Contains(hash))
                            {
                                sw.WriteLine(linha);
                                hashSet.Add(hash);
                            }
                        }
                    }
                }
            }
            sw.Close();
            bsw.Close();
            fsw.Close();

            stopWatch.Stop();

            TimeSpan ts = stopWatch.Elapsed;
            string duracao = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds);
            Console.WriteLine("Duração: " + duracao);
    }
开发者ID:jonasabreu,项目名称:code-challenges,代码行数:46,代码来源:andre.cs

示例8: Example_08

    public Example_08()
    {
        FileStream fos = new FileStream("Example_08.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        // Before you enable this flag please read README.ZLIB.TXT
        // in the 'optional' directory.

        Font f1 = new Font(pdf, "Helvetica-Bold");
        f1.SetSize(7.0);
        Font f2 = new Font(pdf, "Helvetica");
        f2.SetSize(7.0);
        Font f3 = new Font(pdf, "Helvetica-BoldOblique");
        f3.SetSize(7.0);

        Page page = new Page(pdf, Letter.PORTRAIT);

        Table table = new Table(f1, f2);
        List<List<Cell>> tableData = GetData(
                "data/world-communications.txt", "|", Table.DATA_HAS_2_HEADER_ROWS, f1, f2);
        table.SetData(tableData, Table.DATA_HAS_2_HEADER_ROWS);

        table.SetLineWidth(0.2);
        table.SetPosition(70.0, 30.0);
        table.SetTextColorInRow(6, RGB.BLUE);
        table.SetTextColorInRow(39, RGB.RED);
        table.SetTextFontInRow(26, f3, 7);
        table.RemoveLineBetweenRows(0, 1);
        table.AutoAdjustColumnWidths();
        table.SetColumnWidth(0, 120);
        table.RightAlignNumbers();
        int numOfPages = table.GetNumberOfPages(page);
        while (true) {
            table.DrawOn(page);
            // TO DO: Draw "Page 1 of N" here
            if (!table.HasMoreData()) break;
            page = new Page(pdf, Letter.PORTRAIT);
        }

        pdf.Flush();
        bos.Close();
    }
开发者ID:pauljs,项目名称:Justin-Paul-s-Projects,代码行数:45,代码来源:Example_08.cs

示例9: readFile

    /**
     * Reads a file and outputs its content to a String.
     * @param filename The name of the file.
     * @return The String containing the file.
     */
    public static string readFile(string filename)
    {
        FileStream fs = null;
        BufferedStream bs = null;
        StreamReader sr = null;
        string content = "";

        try
        {
            fs = new FileStream(filename, FileMode.OpenOrCreate);

            // Here BufferedInputStream is added for fast reading.
            bs = new BufferedStream(fs);
            sr = new StreamReader(bs);

            string line = "";

            // sr.available() returns 0 if the file does not have more lines.
            while ((line = sr.ReadLine()) != null)
            {
                // this statement reads the line from the file and print it to
                // the console.
                content = content + line + "\n";
            }

            // dispose all the resources after using them.
            fs.Close();
            bs.Close();
            sr.Close();
        }

        catch (FileNotFoundException e)
        {
            System.Console.WriteLine(e.ToString());
        }

        catch (IOException e)
        {
            System.Console.WriteLine(e.ToString());
        }

        return content;
    }
开发者ID:sylvainhalle,项目名称:BeepBeepCSharp,代码行数:48,代码来源:SimpleFileReader.cs

示例10: Example_05

    public Example_05()
    {
        FileStream fos = new FileStream("Example_05.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

        // Before you enable this flag please read README.ZLIB.TXT
        // in the 'optional' directory.

        // If PDF/A is not required use Helvetica, TimesRoman or Courier
        Font f1 = new Font(pdf, "Helvetica");

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextLine text = new TextLine(f1);
        text.SetPosition(300.0, 300.0);
        for (int i = 0; i < 360; i += 15) {
            text.SetTextDirection(i);
            text.SetUnderline(true);
            // text.SetStrikeLine(true);
            text.SetText("             Hello, World -- " + i + " degrees.");
            text.DrawOn(page);
        }

        text = new TextLine(f1, "WAVE AWAY");
        text.SetPosition(70.0, 50.0);
        text.DrawOn(page);

        f1.SetKernPairs(true);
        text.SetPosition(70.0, 70.0);
        text.DrawOn(page);

        f1.SetKernPairs(false);
        text.SetPosition(70.0, 90.0);
        text.DrawOn(page);

        f1.SetSize(8);
        text = new TextLine(f1, "-- font.SetKernPairs(false);");
        text.SetPosition(150.0, 50.0);
        text.DrawOn(page);
        text.SetPosition(150.0, 90.0);
        text.DrawOn(page);
        text = new TextLine(f1, "-- font.SetKernPairs(true);");
        text.SetPosition(150.0, 70.0);
        text.DrawOn(page);

        Point point = new Point(300.0, 300.0);
        point.SetShape(Point.CIRCLE);
        point.SetFillShape(true);
        point.SetColor(RGB.BLUE);
        point.SetRadius(37.0);
        point.DrawOn(page);
        point.SetRadius(25.0);
        point.SetColor(RGB.WHITE);
        point.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
开发者ID:pauljs,项目名称:Justin-Paul-s-Projects,代码行数:61,代码来源:Example_05.cs

示例11: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		try
		{
			FileStream fs2;
			MemoryStream ms2;
			BufferedStream bs2;
			String filName = s_strTFAbbrev + "TestFile.tmp";
			Int32 ii = 0;
			Byte[] bytArr;
			Int32 i32;
			bytArr = new Byte[] {
				Byte.MinValue
				,Byte.MaxValue
				,100
				,Byte.MaxValue-100
			};
			if(File.Exists(filName))
				File.Delete(filName);
			strLoc = "Loc_8yfv7";
			fs2 = new FileStream(filName, FileMode.Create);
			bs2 = new BufferedStream(fs2);
			for(ii = 0 ; ii < bytArr.Length ; ii++)
				bs2.WriteByte(bytArr[ii]);		   
			bs2.Flush();
			bs2.Close();
			strLoc = "Loc_987hg";
			fs2 = new FileStream(filName, FileMode.Open);
			bs2 = new BufferedStream(fs2);
			for(ii = 0 ; ii < bytArr.Length ;ii++) {
				iCountTestcases++;
				if((i32 = bs2.ReadByte()) != bytArr[ii]) {
					iCountErrors++;
					printerr( "Error_298hg_"+ii+"! Expected=="+bytArr[ii]+" , got=="+i32);
				}
			}
			i32 = bs2.ReadByte();
			if(i32 != -1) {
				iCountErrors++;
				printerr( "Error_2389! -1 return expected, i32=="+i32);
			} 
			fs2.Close();
			strLoc = "Loc_398yc";
			ms2 = new MemoryStream();
			bs2 = new BufferedStream(ms2);
			for(ii = 0 ; ii < bytArr.Length ; ii++)
				bs2.WriteByte(bytArr[ii]);
			bs2.Flush();
			bs2.Position = 0;
			bs2.Flush();
			for(ii = 0 ; ii < bytArr.Length ; ii++) {
				iCountTestcases++;
				if((i32 = bs2.ReadByte()) != bytArr[ii]) {
					iCountErrors++;
					printerr( "Error_38yv8_"+ii+"! Expected=="+bytArr[ii]+", got=="+i32);
				}
			}
			i32 = bs2.ReadByte();
			if(i32 != -1) {
				iCountErrors++;
				printerr( "Error_238v8! -1 return expected, i32=="+i32);
			}
			bs2.Position = 0;
			for(ii = 0 ; ii < bytArr.Length; ii++)
				bs2.WriteByte(bytArr[ii]);
			if(File.Exists(filName))
				File.Delete(filName);
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:87,代码来源:co5744readbyte.cs

示例12: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     try
     {
         BufferedStream bs2;
         MemoryStream memstr2;
         FileStream fs2;
         if(File.Exists("Co5606Test.tmp"))
             File.Delete("Co5606Test.tmp");
         strLoc = "Loc_02u9c";
         memstr2 = new MemoryStream();
         bs2 = new BufferedStream(memstr2);
         bs2.Close();
         iCountTestcases++;
         if(bs2.CanRead) 
         {
             iCountErrors++;
             printerr( "Error_1099c! CanRead returned true for closed stream");
         } 
         strLoc = "Loc_20987";
         memstr2 = new MemoryStream();
         bs2 = new BufferedStream(memstr2);
         memstr2.Close();
         iCountTestcases++;
         if(bs2.CanRead) 
         {
             iCountErrors++;
             printerr( "Error_898c8! True when underlying stream is closed");
         }
         strLoc = "Loc_029uc";
         fs2 = new FileStream("Co5606Test.tmp", FileMode.Create, FileAccess.Write);
         bs2 = new BufferedStream(fs2);
         iCountTestcases++;
         if(bs2.CanRead) 
         {
             iCountErrors++;
             printerr( "Error_0uyt4! True when stream is write only");
         }
         bs2.Close();
         strLoc = "Loc_091uc";
         fs2 = new FileStream("Co5606Test.tmp", FileMode.Open, FileAccess.ReadWrite);
         bs2 = new BufferedStream(fs2);
         iCountTestcases++;
         if(!bs2.CanRead) 
         {
             iCountErrors++;
             printerr("Error_298xj! False when stream is ReadWrite");
         } 
         fs2.Close();
         strLoc = "Loc_09u9v";
         fs2 = new FileStream("Co5606Test.tmp", FileMode.Open, FileAccess.Read);
         bs2 = new BufferedStream(fs2);
         iCountTestcases++;
         if(!bs2.CanRead) 
         {
             iCountErrors++;
             printerr( "Error_f8u89! False when stream is Read");
         }
         fs2.Close();
         iCountTestcases++;
         m_PortSetEvent.Reset();
         Thread tcpListenerThread = new Thread(new ThreadStart(Co5606get_CanRead.StartListeningTcp));
         tcpListenerThread.Start();
         Console.WriteLine("Listening");
         Thread.Sleep( 1000 );
         m_PortSetEvent.WaitOne();
         Teleport("127.0.0.1");
         Thread.Sleep( 1000 );
         if(File.Exists("Co5606Test.tmp"))
             File.Delete("Co5606Test.tmp");
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
         return true;
     }
     else
     {
         Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:91,代码来源:co5606get_canread.cs

示例13: readProperty

	private static string readProperty(string filename)
	{
		// Opens the file
		string formula = "";
		//File queryFile = File.OpenText(filename);
		
		try
		{
			//FileStream fs = new FileStream(queryFile, FileAccess.ReadWrite);
			FileStream fs = new FileStream(filename, FileMode.Open);
			BufferedStream bs = new BufferedStream(fs);
			BinaryReader br = new BinaryReader(bs);
			
			while (br.Read() != 0)
			{
				formula += br.ReadString();
			}
			
			fs.Close();
			bs.Close();
			br.Close();
		}
		
		catch (FileNotFoundException e)
		{
			return null;
		}
		
		catch (IOException e)
		{
			System.Console.Error.WriteLine(e.ToString());
			
			return null;
		}
		
		return formula;
	}
开发者ID:sylvainhalle,项目名称:BeepBeepCSharp,代码行数:37,代码来源:BeepBeepValidator.cs

示例14: Page_Load


//.........这里部分代码省略.........
                    }
                    if (string.Compare(name, "signType") == 0)
                    {
                        signType = value;
                    }
                    if (string.Compare(name, "orderNo") == 0)
                    {
                        orderNo = value;
                    }
                    if (string.Compare(name, "orderAmount") == 0)
                    {
                        orderAmount = value;
                    }
                    if (string.Compare(name, "orderDatetime") == 0)
                    {
                        orderDatetime = value;
                    }
                    if (string.Compare(name, "refundAmount") == 0)
                    {
                        refundAmount = value;
                    }
                    if (string.Compare(name, "refundDatetime") == 0)
                    {
                        refundDatetime = value;
                    }
                    if (string.Compare(name, "refundResult") == 0)
                    {
                        refundResult = value;
                    }
                    if (string.Compare(name, "errorCode") == 0)
                    {
                        errorCode = value;
                    }
                    if (string.Compare(name, "returnDatetime") == 0)
                    {
                        returnDatetime = value;
                    }
                    if (string.Compare(name, "signMsg") == 0)
                    {
                        signMsg = value;
                    }

                }
            }
            #endregion

            StringBuilder bufSignSrcVerify = new StringBuilder();

            appendSignPara(bufSignSrcVerify, "merchantId", merchantId);
            appendSignPara(bufSignSrcVerify, "version", version);
            appendSignPara(bufSignSrcVerify, "signType", signType);
            appendSignPara(bufSignSrcVerify, "orderNo", orderNo);
            appendSignPara(bufSignSrcVerify, "orderAmount", orderAmount);
            appendSignPara(bufSignSrcVerify, "orderDatetime", orderDatetime);
            appendSignPara(bufSignSrcVerify, "refundAmount", refundAmount);
            appendSignPara(bufSignSrcVerify, "refundDatetime", refundDatetime);
            appendSignPara(bufSignSrcVerify, "refundResult", refundResult);
            appendSignPara(bufSignSrcVerify, "errorCode", errorCode);
            appendSignPara(bufSignSrcVerify, "returnDatetime", returnDatetime);
            appendLastSignPara(bufSignSrcVerify, "key", key);

            //联机退款申请结果返回报文,组织的签名原串
            refundSignSrcMsgResp = bufSignSrcVerify.ToString();

            //联机退款申请验签都是用md5验签
            //对签名原串进行MD5摘要
            String refundSignMsgResp = FormsAuthentication.HashPasswordForStoringInConfigFile(refundSignSrcMsgResp, "MD5");
            Console.WriteLine("**********+" + refundSignMsgResp);
            //signMsg是服务端返回的签名串,refundSignMsgResp是本地组成的签名串
            if (signMsg != null && refundSignMsgResp != null && signMsg.Equals(refundSignMsgResp))
            {
                verifyResult = true;
            }
            else {
                verifyResult = false;
            }
           // verifyResult = verify(srcMsg, signMsg, @"D:\cert\TLCert-test.cer", true); //证书路径请参考verify方法的注释设置

        }
        catch (Exception exc)
        {
            //异常捕获处理
        }
        finally
        {
            //4、关闭连接
            if (tRequestStream != null)
            {
                try { tRequestStream.Close(); }
                catch (Exception) { }
            }
            if (tWebResponse != null)
            {
                try { tWebResponse.Close(); }
                catch (Exception) { }
            }
        }

        return;
    }
开发者ID:test-lin,项目名称:Utility-class,代码行数:101,代码来源:orderRefund.aspx.cs

示例15: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue = String.Empty;
     try
     {
         BufferedStream bs2;
         MemoryStream memstr2;
         if(File.Exists("Co5604Test.tmp"))
             File.Delete("Co5604Test.tmp");
         strLoc = "Loc_857vi";
         memstr2 = new MemoryStream();
         bs2 = new BufferedStream(memstr2);
         bs2.Write(new Byte[]{65, 66}, 0, 2);
         bs2.Close();
         iCountTestcases++;
         try 
         {
             bs2.Flush();
             iCountErrors++;
             printerr("Error_2yc94! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_298uv! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_9t85y! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_09uf4";
         iCountTestcases++;
         try 
         {
             bs2.Write(new Byte[]{1,2,3}, 0, 3);
             iCountErrors++;
             printerr( "Error_129vc! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_27b99! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "ERror_0901v! Incorrect exception thrown, exc=="+exc.ToString());
         } 
         strLoc = "Loc_2099x";
         iCountTestcases++;
         try 
         {
             bs2.Read(new Byte[3], 0, 3);
             iCountErrors++;
             printerr( "Error_209cx! Expectede exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_t7587! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_20g8j! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_01990";
         iCountTestcases++;
         try 
         {
             bs2.Seek(54, SeekOrigin.Current);
             iCountErrors++;
             printerr( "Error_0190j! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo("Info_g6798! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_2998y! Incorrect exception thrown, exc=="+exc.ToString());
         }
         strLoc = "Loc_0939s";
         iCountTestcases++;
         try 
         {
             bs2.SetLength(100);
             iCountErrors++;
             printerr( "Error_209gb! Expected exception not thrown");
         } 
         catch (ObjectDisposedException iexc) 
         {
             printinfo( "Info_989gh! Caught expected exception, exc=="+iexc.Message);
         } 
         catch (Exception exc) 
         {
             iCountErrors++;
             printerr( "Error_0190x! Incorrect exception thrown, exc=="+exc.Message);
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5604close.cs


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