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


C# MemoryStream.ToString方法代码示例

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


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

示例1: EncryptString

        public static String EncryptString(String in_string)
        {
            String return_value;

            using (TripleDESCryptoServiceProvider tdsAlg = new TripleDESCryptoServiceProvider())
            {
                tdsAlg.GenerateKey();
                tdsAlg.GenerateIV();

                // Create a decrytor to perform the stream transform.
                ICryptoTransform encryptor = tdsAlg.CreateEncryptor(tdsAlg.Key, tdsAlg.IV);

                // Create the streams used for encryption.
                using (MemoryStream msEncrypt = new MemoryStream())
                {
                    using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                    {
                        using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                        {

                            //Write all data to the stream.
                            swEncrypt.Write(in_string);
                        }
                        return_value = msEncrypt.ToString();
                    }
                }
            }
            return return_value;
        }
开发者ID:expertlight,项目名称:CalandrePresentation,代码行数:29,代码来源:Crypto.cs

示例2: Image2Stream

        public Image2Stream()
        {
            // Stream -> IplImage
            using (FileStream stream = new FileStream(Const.ImageLenna, FileMode.Open))
            using (IplImage img = IplImage.FromStream(stream, LoadMode.Color))
            {
                CvWindow.ShowImages(img);

                // IplImage -> Stream
                using (MemoryStream ms = new MemoryStream())
                {
                    img.ToStream(ms, ".tiff");
                    ms.ToString();
                }
            }

            // Stream -> CvMat
            using (FileStream stream = new FileStream(Const.ImageLenna, FileMode.Open))
            using (CvMat mat = CvMat.FromStream(stream, LoadMode.Color))
            {
                mat.ToString();

                // CvMat -> Stream
                using (MemoryStream ms = new MemoryStream())
                {
                    mat.ToStream(ms, ".bmp");
                    ms.ToString();
                }
            }
        }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:30,代码来源:Image2Stream.cs

示例3: ImageToByte

 public byte ImageToByte(BitmapImage imageSource)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         imageSource.StreamSource.CopyTo(ms); //todo doesnt work so
         return Convert.ToByte(ms.ToString());
     }
 }
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:8,代码来源:Helper.cs

示例4: SendMsgPB

        public int SendMsgPB(int nMsgID, int nSockIndex, NFMsg.MsgBase xData)
        {
            MemoryStream body = new MemoryStream();
            Serializer.Serialize<NFMsg.MsgBase>(body, xData);

            SendMsg(nMsgID, nSockIndex, body.ToString());

            return 0;
        }
开发者ID:ketoo,项目名称:NFrame,代码行数:9,代码来源:NFNetModule.cs

示例5: Convert

        public string Convert(DataTable dataTable)
        {
            _dataTable = dataTable;

            using (var memoryStream = new MemoryStream())
            {
                _writer = new StreamWriter(memoryStream);
                WriteColumnNames();
                WriteRows();
                _writer.Close();

                return memoryStream.ToString();
            }
        }
开发者ID:AlexJCarstensen,项目名称:ProgrammingWithMosh,代码行数:14,代码来源:DataTableToCsvConvertor.cs

示例6: RunScript

 public static string RunScript(CMSDataContext db, string script)
 {
     var engine = Python.CreateEngine();
     var ms = new MemoryStream();
     var sw = new StreamWriter(ms);
     engine.Runtime.IO.SetOutput(ms, sw);
     engine.Runtime.IO.SetErrorOutput(ms, sw);
     var sc = engine.CreateScriptSourceFromString(script);
     var code = sc.Compile();
     var scope = engine.CreateScope();
     var pe = new PythonEvents(db);
     scope.SetVariable("model", pe);
     code.Execute(scope);
     return ms.ToString();
 }
开发者ID:hkouns,项目名称:bvcms,代码行数:15,代码来源:PythonEvents.cs

示例7: SerializeToString

        /// <summary>Serializes an <c>XMPMeta</c>-object as RDF into a string.</summary>
        /// <remarks>
        /// <em>Note:</em> Encoding is forced to UTF-16 when serializing to a
        /// string to ensure the correctness of &quot;exact packet size&quot;.
        /// </remarks>
        /// <param name="xmp">a metadata implementation object</param>
        /// <param name="options">Options to control the serialization (see <see cref="SerializeOptions"/>).</param>
        /// <returns>Returns a string containing the serialized RDF.</returns>
        /// <exception cref="XmpException">on serialization errors.</exception>
        public static string SerializeToString(XmpMeta xmp, SerializeOptions options)
        {
            // forces the encoding to be UTF-16 to get the correct string length
            options = options ?? new SerializeOptions();
            options.EncodeUtf16Be = true;

            var output = new MemoryStream(2048);
            Serialize(xmp, output, options);
            try
            {
                return options.GetEncoding().GetString(output.GetBuffer(), 0, (int)output.Length);
            }
            catch
            {
                // Should not happen as UTF-8/16LE/BE are all available
                return output.ToString();
            }
        }
开发者ID:ashbook,项目名称:xmp-core-dotnet,代码行数:27,代码来源:XMPSerializerHelper.cs

示例8: SignRequest

		private string SignRequest (System.Net.HttpWebRequest request, byte[] body)
		{
			Uri u = request.RequestUri;

			string pathAndQuery = request.RequestUri.PathAndQuery;
			byte[] pathAndQueryBytes = Config.Encoding.GetBytes(pathAndQuery);
			using (MemoryStream buffer = new MemoryStream())
			{
				buffer.Write(pathAndQueryBytes, 0, pathAndQueryBytes.Length);
				buffer.WriteByte((byte)'\n');
				if (body.Length > 0)
				{
					buffer.Write(body, 0, body.Length);
				}
				string digestBase64 = GetSHA1Key(mac.SecretKey, buffer.ToString());
				return mac.AccessKey + ":" + digestBase64;
			}
		}
开发者ID:Gemini2015,项目名称:QiniuSDK,代码行数:18,代码来源:QiniuAuthClient.cs

示例9: ToString

        /**
         * Returns the string representation of this record.
         */
        public override String ToString()
        {
            String nl = Environment.NewLine;

            String extraData;
            using (MemoryStream b = new MemoryStream())
            {
                try
                {
                    HexDump.Dump(this.remainingData, 0, b, 0);
                    extraData = b.ToString();
                }
                catch (Exception)
                {
                    extraData = "error\n";
                }
                return GetType().Name + ":" + nl +
                        "  RecordId: 0x" + HexDump.ToHex(RECORD_ID) + nl +
                        "  Options: 0x" + HexDump.ToHex(Options) + nl;
                //"  Extra Data:" + nl +
                //extraData;
            }
        }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:26,代码来源:EscherClientDataRecord.cs

示例10: DebugStoreIM

        private void DebugStoreIM(GridInstantMessage im)
        {
            MemoryStream buffer = new MemoryStream();
            Type type = typeof(GridInstantMessage);

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = Encoding.UTF8;

            using (XmlWriter writer = XmlWriter.Create(buffer, settings))
            {
                XmlSerializer serializer = new XmlSerializer(type);
                serializer.Serialize(writer, im);
                writer.Flush();
            }

            string debug = buffer.ToString();
            m_DummyOffline = buffer;
        }
开发者ID:digitalmystic,项目名称:halcyon,代码行数:18,代码来源:OfflineMessageModule.cs

示例11: GetSettings

 /// <summary>
 /// Gets the client settings as an XML string.
 /// </summary>
 /// <param name="includeMediaData">If True, Media settings are included, if any settings exist.</param>
 /// <returns>Returns client settings, as XML string.</returns>
 public string GetSettings(bool includeMediaData)
 {
     string originalMediaSettings = null, originalMediaType = null;
     if (!includeMediaData)
     {
         originalMediaSettings = this.m_MediaSettings;
         originalMediaType = this.m_MediaType;
         this.m_MediaType = this.m_MediaSettings = null;
     }
     try
     {
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent = true;
         settings.Encoding = System.Text.Encoding.UTF8;
         settings.CloseOutput = true;
         settings.CheckCharacters = false;
         string data;
         using (MemoryStream memoryStream = new MemoryStream())
         {
             using (StreamReader reader = new StreamReader(memoryStream))
             {
                 DataContractSerializer x = new DataContractSerializer(this.GetType());
                 x.WriteObject(memoryStream, this);
                 memoryStream.Position = 0;
                 data = memoryStream.ToString();
                 data = UTF8Encoding.UTF8.GetString(memoryStream.ToArray());
             }
         }
         return data;
     }
     finally
     {
         if (!includeMediaData)
         {
             this.m_MediaType = originalMediaType;
             this.m_MediaSettings = originalMediaSettings;
         }
     }
 }
开发者ID:giapdangle,项目名称:Gurux.Communication,代码行数:44,代码来源:GXClient.cs

示例12: TestIndexAndMerge

        public virtual void TestIndexAndMerge()
        {
            MemoryStream sw = new MemoryStream();
            StreamWriter @out = new StreamWriter(sw);

            Directory directory = NewFSDirectory(IndexDir, null);

            MockDirectoryWrapper wrapper = directory as MockDirectoryWrapper;
            if (wrapper != null)
            {
                // We create unreferenced files (we don't even write
                // a segments file):
                wrapper.AssertNoUnrefencedFilesOnClose = false;
            }

            IndexWriter writer = new IndexWriter(directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetOpenMode(OpenMode_e.CREATE).SetMaxBufferedDocs(-1).SetMergePolicy(NewLogMergePolicy(10)));

            SegmentCommitInfo si1 = IndexDoc(writer, "test.txt");
            PrintSegment(@out, si1);

            SegmentCommitInfo si2 = IndexDoc(writer, "test2.txt");
            PrintSegment(@out, si2);
            writer.Dispose();

            SegmentCommitInfo siMerge = Merge(directory, si1, si2, "_merge", false);
            PrintSegment(@out, siMerge);

            SegmentCommitInfo siMerge2 = Merge(directory, si1, si2, "_merge2", false);
            PrintSegment(@out, siMerge2);

            SegmentCommitInfo siMerge3 = Merge(directory, siMerge, siMerge2, "_merge3", false);
            PrintSegment(@out, siMerge3);

            directory.Dispose();
            @out.Dispose();
            sw.Dispose();

            string multiFileOutput = sw.ToString();
            //System.out.println(multiFileOutput);

            sw = new MemoryStream();
            @out = new StreamWriter(sw);

            directory = NewFSDirectory(IndexDir, null);

            wrapper = directory as MockDirectoryWrapper;
            if (wrapper != null)
            {
                // We create unreferenced files (we don't even write
                // a segments file):
                wrapper.AssertNoUnrefencedFilesOnClose = false;
            }

            writer = new IndexWriter(directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetOpenMode(OpenMode_e.CREATE).SetMaxBufferedDocs(-1).SetMergePolicy(NewLogMergePolicy(10)));

            si1 = IndexDoc(writer, "test.txt");
            PrintSegment(@out, si1);

            si2 = IndexDoc(writer, "test2.txt");
            PrintSegment(@out, si2);
            writer.Dispose();

            siMerge = Merge(directory, si1, si2, "_merge", true);
            PrintSegment(@out, siMerge);

            siMerge2 = Merge(directory, si1, si2, "_merge2", true);
            PrintSegment(@out, siMerge2);

            siMerge3 = Merge(directory, siMerge, siMerge2, "_merge3", true);
            PrintSegment(@out, siMerge3);

            directory.Dispose();
            @out.Dispose();
            sw.Dispose();
            string singleFileOutput = sw.ToString();

            Assert.AreEqual(multiFileOutput, singleFileOutput);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:78,代码来源:TestDoc.cs

示例13: ToString

 /// <summary>
 /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
 /// </returns>
 public override String ToString()
 {
     String dataStr;
     using (MemoryStream b = new MemoryStream())
     {
         try
         {
             HexDump.Dump(this._complexData, 0, b, 0);
             dataStr = b.ToString();
         }
         catch (Exception e)
         {
             dataStr = e.ToString();
         }
     }
     return "propNum: " + PropertyNumber
             + ", propName: " + EscherProperties.GetPropertyName(PropertyNumber)
             + ", complex: " + IsComplex
             + ", blipId: " + IsBlipId
             + ", data: " + Environment.NewLine + dataStr;
 }
开发者ID:89sos98,项目名称:npoi,代码行数:27,代码来源:EscherComplexProperty.cs

示例14: ToString

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override String ToString()
        {
            String nl = Environment.NewLine;

            String extraData;
            using (MemoryStream b = new MemoryStream())
            {
                try
                {
                    HexDump.Dump(this.field_pictureData, 0, b, 0);
                    extraData = b.ToString();
                }
                catch (Exception e)
                {
                    extraData = e.ToString();
                }
                return GetType().Name + ":" + nl +
                        "  RecordId: 0x" + HexDump.ToHex(RecordId) + nl +
                        "  Version: 0x" + HexDump.ToHex(Version) + '\n' +
                        "  Instance: 0x" + HexDump.ToHex(Instance) + '\n' +
                        "  UID: 0x" + HexDump.ToHex(field_1_UID) + nl +
                        (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.ToHex(field_2_UID) + nl)) +
                        "  Uncompressed Size: " + HexDump.ToHex(field_2_cb) + nl +
                        "  Bounds: " + Bounds + nl +
                        "  Size in EMU: " + SizeEMU + nl +
                        "  Compressed Size: " + HexDump.ToHex(field_5_cbSave) + nl +
                        "  Compression: " + HexDump.ToHex(field_6_fCompression) + nl +
                        "  Filter: " + HexDump.ToHex(field_7_fFilter) + nl +
                        "  Extra Data:" + nl + extraData +
                        (remainingData == null ? null : ("\n" +
                        " Remaining Data: " + HexDump.ToHex(remainingData, 32)));
            }
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:39,代码来源:EscherMetafileBlip.cs

示例15: ToString

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override String ToString()
        {
            String nl = Environment.NewLine;

            String extraData;
            using (MemoryStream b = new MemoryStream())
            {
                try
                {
                    HexDump.Dump(this._remainingData, 0, b, 0);
                    extraData = b.ToString();
                }
                catch (Exception e)
                {
                    extraData = e.ToString();
                }
                return GetType().Name + ":" + nl +
                        "  RecordId: 0x" + HexDump.ToHex(RECORD_ID) + nl +
                        "  Options: 0x" + HexDump.ToHex(Options) + nl +
                        "  BlipTypeWin32: " + field_1_blipTypeWin32 + nl +
                        "  BlipTypeMacOS: " + field_2_blipTypeMacOS + nl +
                        "  SUID: " + HexDump.ToHex(field_3_uid) + nl +
                        "  Tag: " + field_4_tag + nl +
                        "  Size: " + field_5_size + nl +
                        "  Ref: " + field_6_ref + nl +
                        "  Offset: " + field_7_offset + nl +
                        "  Usage: " + field_8_usage + nl +
                        "  Name: " + field_9_name + nl +
                        "  Unused2: " + field_10_unused2 + nl +
                        "  Unused3: " + field_11_unused3 + nl +
                        "  blipRecord: " + (field_12_blipRecord == null ? "null" : field_12_blipRecord.ToString()) + nl;
                //"  Extra Data:" + nl + extraData;
            }
        }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:40,代码来源:EscherBSERecord.cs


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