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


C# UnmanagedMemoryStream.Dispose方法代码示例

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


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

示例1: received_data

        /// <summary>
        /// A portion of the file contents have been received. This method will
        /// be called multiple times until the download is complete. Return
        /// |true| to continue receiving data and |false| to cancel.
        /// </summary>
        private int received_data(cef_download_handler_t* self, void* data, int data_size)
        {
            ThrowIfObjectDisposed();

            var m_stream = new UnmanagedMemoryStream((byte*)data, data_size, data_size, FileAccess.Read);

            var handled = this.ReceivedData(m_stream);

            m_stream.Dispose();

            return handled ? 1 : 0;
        }
开发者ID:yasoonOfficial,项目名称:cefglue,代码行数:17,代码来源:CefDownloadHandler.Impl.cs

示例2: process_data

        /// <summary>
        /// Set |substitute_data| to the replacement for the data in |data| if
        /// data should be modified.
        /// </summary>
        private void process_data(cef_content_filter_t* self, /*const*/ void* data, int data_size, cef_stream_reader_t** substitute_data)
        {
            ThrowIfObjectDisposed();

            var m_stream = new UnmanagedMemoryStream((byte*)data, data_size, data_size, FileAccess.Read);
            CefStreamReader m_substitute_data;

            this.ProcessData(m_stream, out m_substitute_data);

            if (m_substitute_data != null)
            {
                *substitute_data = m_substitute_data.GetNativePointerAndAddRef();
            }

            m_stream.Dispose();
        }
开发者ID:yasoonOfficial,项目名称:cefglue,代码行数:20,代码来源:CefContentFilter.Impl.cs

示例3: InitDna


//.........这里部分代码省略.........
            if (!codes.Equals("SDNANAME"))
            {
                throw new InvalidDataException();
            }
            int dataLen = reader.ReadInt32();
            _names = new Dna.NameInfo[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List<byte> name = new List<byte>();
                byte ch = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }

                _names[i] = new Dna.NameInfo(ASCIIEncoding.ASCII.GetString(name.ToArray()));
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TYPE
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TYPE"))
            {
                throw new InvalidDataException();
            }
            dataLen = reader.ReadInt32();
            _types = new Dna.TypeDecl[dataLen];
            for (int i = 0; i < dataLen; i++)
            {
                List<byte> name = new List<byte>();
                byte ch = reader.ReadByte();
                while (ch != 0)
                {
                    name.Add(ch);
                    ch = reader.ReadByte();
                }
                string type = ASCIIEncoding.ASCII.GetString(name.ToArray());
                _types[i] = new Dna.TypeDecl(type);
            }
            stream.Position = (stream.Position + 3) & ~3;

            // TLEN
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("TLEN"))
            {
                throw new InvalidDataException();
            }
            for (int i = 0; i < _types.Length; i++)
            {
                _types[i].Length = reader.ReadInt16();
            }
            stream.Position = (stream.Position + 3) & ~3;

            // STRC
            code = reader.ReadBytes(4);
            codes = ASCIIEncoding.ASCII.GetString(code);
            if (!codes.Equals("STRC"))
            {
                throw new InvalidDataException();
            }
            dataLen = reader.ReadInt32();
            _structs = new Dna.StructDecl[dataLen];
            long shtPtr = stream.Position;
            for (int i = 0; i < dataLen; i++)
            {
                Dna.StructDecl structDecl = new Dna.StructDecl();
                _structs[i] = structDecl;
                if (!BitConverter.IsLittleEndian)
                {
                    throw new NotImplementedException();
                }
                else
                {
                    short typeNr = reader.ReadInt16();
                    structDecl.Type = _types[typeNr];
                    structDecl.Type.Struct = structDecl;
                    int numElements = reader.ReadInt16();
                    structDecl.Elements = new Dna.ElementDecl[numElements];
                    for (int j = 0; j < numElements; j++)
                    {
                        typeNr = reader.ReadInt16();
                        short nameNr = reader.ReadInt16();
                        structDecl.Elements[j] = new Dna.ElementDecl(_types[typeNr], _names[nameNr]);
                    }
                }
            }

            reader.Dispose();
            stream.Dispose();

            // build reverse lookups
            _structReverse = new Dictionary<string, Dna.StructDecl>(_structs.Length);
            foreach (Dna.StructDecl s in _structs)
            {
                _structReverse.Add(s.Type.Name, s);
            }
        }
开发者ID:RainsSoft,项目名称:BulletSharpPInvoke,代码行数:101,代码来源:Serializer.cs

示例4: Open

        public override void Open(string filePath)
        {
            _content = File.ReadAllText(filePath);

            int i = _content.IndexOf("%!");

            if (i > 0)
            {
                _content = _content.Substring(i, _content.Length - i - 1);
            }

            i = _content.IndexOf("%%EOF");

            if (i > -1)
            {
                _content = _content.Substring(0, i + 5);
            }

            if (this.Viewer.EPSClip)
            {
                unsafe
                {
                    fixed (char* p = _content)
                    {
                        UnmanagedMemoryStream ums = new UnmanagedMemoryStream((byte*)p, _content.Length);
                        DSCTokenizer tokenizer = new DSCTokenizer(ums, true, BitConverter.IsLittleEndian);

                        DSCToken token = null;

                        while ((token = tokenizer.GetNextDSCKeywordToken()) != null)
                        {
                            if (token.Text == "%%BoundingBox:")
                            {
                                try
                                {
                                    DSCToken v1 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
                                    DSCToken v2 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
                                    DSCToken v3 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
                                    DSCToken v4 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);

                                    this.BoundingBox = new GhostscriptRectangle(
                                            float.Parse(v1.Text, System.Globalization.CultureInfo.InvariantCulture),
                                            float.Parse(v2.Text, System.Globalization.CultureInfo.InvariantCulture),
                                            float.Parse(v3.Text, System.Globalization.CultureInfo.InvariantCulture),
                                            float.Parse(v4.Text, System.Globalization.CultureInfo.InvariantCulture));
                                }
                                catch { }

                                break;
                            }
                        }

                        tokenizer.Dispose(); tokenizer = null;
                        ums.Close(); ums.Dispose(); ums = null;
                    }
                }
            }

            this.FirstPageNumber = 1;
            this.LastPageNumber = 1;
        }
开发者ID:illgamer,项目名称:Ghostscript.NET,代码行数:61,代码来源:GhostscriptViewerEpsFormatHandler.cs

示例5: getImage

        //returns bitmap image converted from the PANGU stream
        public Bitmap getImage(float x, float y, float z, float yaw, float pitch, float roll , float fov)
        {
            try
            {
                unsafe
                {
                    pan_protocol_set_aspect_ratio(sock, 1);     //sets aspect ratio
                    pan_protocol_set_boulder_view(sock, 1, 0);  //view boulders
                    pan_protocol_set_field_of_view(sock, fov);  //set field of view

                    ulong t = 1024;
                    char* img;
                    img = pan_protocol_get_viewpoint_by_angle(sock, x, y, z, yaw, pitch, roll, &t); //gets the image
                    UnmanagedMemoryStream readStream = new UnmanagedMemoryStream((byte*)img, (long)t);

                    Bitmap bitmap = fetchImage(readStream);
                    readStream.Close();
                    readStream.Dispose();
                    return bitmap;
                }
            }
            catch
            {
                return null; //Error at PANGU end.
            }
        }
开发者ID:Stewart-Taylor,项目名称:DynamicPathPlanner,代码行数:27,代码来源:PANGU_Connector.cs


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