private void ThrowIfInvalidBufferType(BufferType expectedBufferType)
 {
     if (this.bufferType != expectedBufferType)
     {
         throw new InvalidOperationException($"Invalid attempt to read data of type '{expectedBufferType}' when data is of type '{this.bufferType}'.");
     }
 }
 /// <summary>
 /// Constructor of IndexBufferObject class
 /// </summary>
 /// <param name="device">Graphics device</param>
 /// <param name="type">Type of buffer to use</param>
 /// <param name="elementSize">Size of one element stored in the buffer</param>
 /// <param name="indexCount">Initial size of the buffer</param>
 internal IndexBufferObject(GraphicsDevice device, BufferType type, IndexElementSize elementSize, int indexCount)
 {
     _device = device;
     _bufferType = type;
     _elementSize = elementSize;
     CreateBuffer(indexCount);
 }
Beispiel #3
0
 public GraphicsBufferBase(GraphicsObject graphicsObject, string name, string attributeName, BufferType bufferType)
     : base(name)
 {
     GraphicsObject  = graphicsObject;
     AttributeName   = attributeName;
     this.bufferType = bufferType;
 }
        public static void OnDocumentOpened(IVsTextLines lines, BufferType type)
        {
            switch (type)
            {
            case BufferType.CSHARP_OR_C_OR_CPP:
                lock (cssBuffers) {
                    if (!cssBuffers.Contains(lines))
                    {
                        cssBuffers.Add(lines);
                    }
                }
                break;

            case BufferType.VISUAL_BASIC:
                lock (vbBuffers) {
                    if (!vbBuffers.Contains(lines))
                    {
                        vbBuffers.Add(lines);
                    }
                }
                break;
            }

            if (AtlassianPanel.Instance.Jira != null && AtlassianPanel.Instance.Jira.CurrentlySelectedServerOrDefault != null)
            {
                addMarkersToDocument(lines);
            }
        }
Beispiel #5
0
 public void SetBufferEmpty()
 {
     BufferType = BufferType.SECBUFFER_EMPTY;
     Buffer     = null;
     Offset     = 0;
     Size       = 0;
 }
Beispiel #6
0
        // Size in bytes, and the usages
        private protected Buffer(uint size, BufferType type, Vk.BufferUsages usages)
        {
            Device = SpectrumApp.Instance.GraphicsDevice;
            Size   = size;
            Type   = type;

            // Create the buffer
            var bci = new Vk.BufferCreateInfo(
                size,
                Vk.BufferUsages.TransferDst | Vk.BufferUsages.TransferSrc | usages,
                flags: Vk.BufferCreateFlags.None,
                sharingMode: Vk.SharingMode.Exclusive
                );

            VkBuffer = Device.VkDevice.CreateBuffer(bci);

            // Create the backing memory
            var memReq = VkBuffer.GetMemoryRequirements();
            var memIdx = Device.FindMemoryTypeIndex(memReq.MemoryTypeBits, Vk.MemoryProperties.DeviceLocal);

            if (memIdx == -1)
            {
                throw new InvalidOperationException("Cannot find a memory type that supports buffers (this means bad or out-of-date hardware)");
            }
            var mai = new Vk.MemoryAllocateInfo(memReq.Size, memIdx);

            VkMemory = Device.VkDevice.AllocateMemory(mai);
            VkBuffer.BindMemory(VkMemory);
        }
Beispiel #7
0
 public void SetBuffer(BufferType type, byte[] bytes, int offset, int size)
 {
     BufferType = type;
     Buffer     = bytes;
     Offset     = offset;
     Size       = size;
 }
Beispiel #8
0
 public void SetBuffer(BufferType type, byte[] bytes)
 {
     BufferType = type;
     Buffer     = bytes;
     Offset     = 0;
     Size       = bytes.Length;
 }
Beispiel #9
0
 public void SetBufferEmpty()
 {
     this.BufferType = BufferType.SECBUFFER_VERSION;
     this.Buffer     = null;
     this.Offset     = 0;
     this.Size       = 0;
 }
 /// <summary>
 /// Constructor of IndexBufferObject class
 /// </summary>
 /// <param name="device">Graphics device</param>
 /// <param name="type">Type of buffer to use</param>
 /// <param name="buffer">Underlying index buffer</param>
 internal IndexBufferObject(GraphicsDevice device, BufferType type, IndexBuffer buffer)
 {
     _device = device;
     _bufferType = type;
     _elementSize = buffer.IndexElementSize;
     CreateWrapper(buffer);
 }
 public SecurityBuffer(byte[] data, int offset, int size, BufferType tokentype)
 {
     this.offset = ((data == null) || (offset < 0)) ? 0 : Math.Min(offset, data.Length);
     this.size = ((data == null) || (size < 0)) ? 0 : Math.Min(size, data.Length - this.offset);
     this.type = tokentype;
     this.token = (size == 0) ? null : data;
 }
 public SecurityBuffer(byte[] data, int offset, int size, BufferType tokentype)
 {
     this.offset = offset;
     this.size = (data == null) ? 0 : size;
     this.type = tokentype;
     this.token = data;
 }
Beispiel #13
0
        internal SecurityStatus Decrypt(byte[] payload, ref int offset, ref int count)
        {
            if ((offset < 0) || (offset > ((payload == null) ? 0 : payload.Length)))
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            if ((count < 0) || (count > ((payload == null) ? 0 : (payload.Length - offset))))
            {
                throw new ArgumentOutOfRangeException("count");
            }
            SecurityBuffer[] input = new SecurityBuffer[] { new SecurityBuffer(payload, offset, count, BufferType.Data), new SecurityBuffer(null, BufferType.Empty), new SecurityBuffer(null, BufferType.Empty), new SecurityBuffer(null, BufferType.Empty) };
            int num = SSPIWrapper.DecryptMessage(GlobalSSPI.SSPISecureChannel, this.m_SecurityContext, input, 0);

            count = 0;
            BufferType data = BufferType.Data;

            if (num != 0)
            {
                data = BufferType.Extra;
            }
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i].type == data)
                {
                    count = input[i].size;
                    break;
                }
            }
            if ((data == BufferType.Data) && (count > 0))
            {
                offset += this.m_HeaderSize;
            }
            return((SecurityStatus)num);
        }
Beispiel #14
0
 public IndexBufferPool()
 {
     version    = BufferType.Index;
     numBuffers = 0;
     size       = 0;
     buffers    = new Dictionary <ulong, IndexBuffer>();
 }
Beispiel #15
0
 public MappedBuffer(Scene scene, Int32 geometryID, BufferType bufferType)
     : base(RTC.MapBuffer(scene.NativePtr, geometryID, bufferType))
 {
     this.scene      = scene;
     this.geometryID = geometryID;
     this.bufferType = bufferType;
 }
Beispiel #16
0
        private void AllocateBuffers(int number, BufferType type)
        {
            Logger.Log(null, "BufferManager - Allocating {0} buffers of type {1}", number, type);
            switch (type)
            {
            case BufferType.LargeMessageBuffer:
                while (number-- > 0)
                {
                    _largeMessageBuffers.Enqueue(new byte[LargeMessageBufferSize]);
                }
                break;

            case BufferType.MediumMessageBuffer:
                while (number-- > 0)
                {
                    _mediumMessageBuffers.Enqueue(new byte[MediumMessageBufferSize]);
                }
                break;

            case BufferType.SmallMessageBuffer:
                while (number-- > 0)
                {
                    _smallMessageBuffers.Enqueue(new byte[SmallMessageBufferSize]);
                }
                break;

            default:
                throw new ArgumentException("Unsupported BufferType detected");
            }
        }
Beispiel #17
0
 public WebGLBuffer(WebGLContext context, int id, BufferType type, BufferUsage usage)
 {
     this.context = context;
     this.Id      = id;
     this.Type    = type;
     this.Usage   = usage;
 }
Beispiel #18
0
 public void SetBuffer(BufferType type, byte[] bytes, int offset, int size)
 {
     this.BufferType = type;
     this.Buffer     = bytes;
     this.Offset     = offset;
     this.Size       = size;
 }
Beispiel #19
0
        public void CopyHtml(string text, BufferType buffer_type)
        {
            text = HelperFunctions.TrimTrailingSpace(text);

            string formattedText =
                (buffer_type == BufferType.Logic)   ? _colorizer.LogicToHtml(text) :
                (buffer_type == BufferType.Message) ? _colorizer.MessageToHtml(text) :
                (buffer_type == BufferType.Report)  ? _colorizer.HtmlReportToHtml(text) :
                _pffColorizer.Colorize(new PffColorizerHtml(), text);

            // html to clipboard code from: http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx
            string htmlCopyText = "Format:HTML Format Version:1.0\nStartHTML:<<<<<<<1\nEndHTML:<<<<<<<2\nStartFragment:<<<<<<<3\nEndFragment:<<<<<<<4\n";
            int    startHTML    = htmlCopyText.Length;

            int beginChunkPos = formattedText.IndexOf("<div");
            int endChunkPos   = formattedText.IndexOf("</div>") + 6; // 6 is length if </div>

            htmlCopyText += formattedText.Substring(0, beginChunkPos) + "<!--StartFragment-->";
            int startFragment = htmlCopyText.Length;

            htmlCopyText += formattedText.Substring(beginChunkPos, endChunkPos - beginChunkPos);
            int endFragment = htmlCopyText.Length;

            htmlCopyText += "<!--EndFragment-->" + formattedText.Substring(endChunkPos);
            int endHTML = htmlCopyText.Length;

            htmlCopyText = htmlCopyText.Replace("<<<<<<<1", String.Format("{0,8}", startHTML));
            htmlCopyText = htmlCopyText.Replace("<<<<<<<2", String.Format("{0,8}", endHTML));
            htmlCopyText = htmlCopyText.Replace("<<<<<<<3", String.Format("{0,8}", startFragment));
            htmlCopyText = htmlCopyText.Replace("<<<<<<<4", String.Format("{0,8}", endFragment));

            Clipboard.Clear();
            Clipboard.SetText(htmlCopyText, TextDataFormat.Html);
        }
 /// <summary>
 /// Undef a buffer in this configuration
 /// </summary>
 /// <param name="bType">
 /// A <see cref="BufferType"/> indicating the buffer to undefine.
 /// </param>
 private void UndefineBuffer(BufferType bType)
 {
     // Undefine buffer
     mSurfaceBuffers           &= ~bType;
     mRequiredSurfaceBuffers   &= ~bType;
     mDegradableSurfaceBuffers &= ~bType;
 }
Beispiel #21
0
 public void Revive()
 {
     if (DataManager.Instance.character == 5)
     {
         goldParticle.SetActive(true);
     }
     dir = 1;
     DataManager.Instance.isExited = true;
     isPowered = false;
     buffer    = BufferType.None;
     shakeDist = 0f;
     shakeDir  = 1;
     life      = 1;
     lifeSet.Revive();
     isImmune           = false;
     isStomping         = false;
     chargeSoundPlayed  = false;
     powerSoundPlayed   = false;
     scaleLock          = false;
     transform.position = originalPos;
     deathParticle.SetActive(false);
     deathParticle1.gameObject.SetActive(true);
     deathParticle2.gameObject.SetActive(true);
     StartCoroutine(ReviveCor());
 }
        public override async Task GenerateWrite(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration typeGen,
            Accessor writerAccessor,
            Accessor itemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationMaskAccessor,
            Accessor converterAccessor)
        {
            BufferType zero = typeGen as BufferType;

            using (var args = new ArgsWrapper(fg,
                                              $"{this.NamespacePrefix}{GetTranslatorInstance(typeGen, getter: true)}.Write"))
            {
                args.Add($"writer: {writerAccessor}");
                if (zero.Static)
                {
                    args.Add($"item: {objGen.CommonClassName(LoquiInterfaceType.IGetter, MaskType.Normal)}.{typeGen.Name}");
                }
                else
                {
                    args.Add($"item: {itemAccessor}");
                }
            }
        }
Beispiel #23
0
        private void AllocateBuffers(int number, BufferType type)
        {
            Logger.Log(null, "BufferManager - Allocating {0} buffers of type {1}", number, type);
            if (type == BufferType.LargeMessageBuffer)
            {
                while (number-- > 0)
                {
                    this.largeMessageBuffers.Enqueue(new byte[LargeMessageBufferSize]);
                }
            }

            else if (type == BufferType.MediumMessageBuffer)
            {
                while (number-- > 0)
                {
                    this.mediumMessageBuffers.Enqueue(new byte[MediumMessageBufferSize]);
                }
            }

            else if (type == BufferType.SmallMessageBuffer)
            {
                while (number-- > 0)
                {
                    this.smallMessageBuffers.Enqueue(new byte[SmallMessageBufferSize]);
                }
            }

            else
            {
                throw new ArgumentException("Unsupported BufferType detected");
            }
        }
        public override void GenerateCopyInRet(
            FileGeneration fg,
            ObjectGeneration objGen,
            TypeGeneration targetGen,
            TypeGeneration typeGen,
            Accessor readerAccessor,
            AsyncMode asyncMode,
            Accessor retAccessor,
            Accessor outItemAccessor,
            Accessor errorMaskAccessor,
            Accessor translationAccessor,
            Accessor converterAccessor,
            bool inline)
        {
            if (inline)
            {
                throw new NotImplementedException();
            }
            if (asyncMode == AsyncMode.Direct)
            {
                throw new NotImplementedException();
            }
            BufferType buf = typeGen as BufferType;

            fg.AppendLine($"{readerAccessor}.Position += {buf.Length};");
        }
 public SecurityBuffer(byte[] data, int offset, int size, BufferType tokentype)
 {
     this.offset = ((data == null) || (offset < 0)) ? 0 : Math.Min(offset, data.Length);
     this.size   = ((data == null) || (size < 0)) ? 0 : Math.Min(size, data.Length - this.offset);
     this.type   = tokentype;
     this.token  = (size == 0) ? null : data;
 }
        private int DecryptNtlm(byte[] payload, int offset, int count, out int newOffset, uint expectedSeqNumber)
        {
            int num;

            if (count < 0x10)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            SecurityBuffer[] input = new SecurityBuffer[] { new SecurityBuffer(payload, offset, 0x10, BufferType.Token), new SecurityBuffer(payload, offset + 0x10, count - 0x10, BufferType.Data) };
            BufferType       data  = BufferType.Data;

            if (this.IsConfidentialityFlag)
            {
                num = SSPIWrapper.DecryptMessage(GlobalSSPI.SSPIAuth, this.m_SecurityContext, input, expectedSeqNumber);
            }
            else
            {
                data         |= BufferType.ReadOnlyFlag;
                input[1].type = data;
                num           = SSPIWrapper.VerifySignature(GlobalSSPI.SSPIAuth, this.m_SecurityContext, input, expectedSeqNumber);
            }
            if (num != 0)
            {
                throw new Win32Exception(num);
            }
            if (input[1].type != data)
            {
                throw new InternalException();
            }
            newOffset = input[1].offset;
            return(input[1].size);
        }
Beispiel #27
0
 public SecurityBufferClass(byte[] data, BufferType tokentype)
 {
     this.offset = 0;
     this.size   = ((data == null) ? 0 : data.Length);
     this.type   = (int)tokentype;
     this.token  = data;
 }
Beispiel #28
0
 void Awake()
 {
     //state = State.Idle;
     dir               = 1;
     isPowered         = false;
     animator          = GetComponent <Animator>();
     collider          = GetComponent <BoxCollider2D>();
     jumpSpeed         = landPosX * 2 / jumpDuration;
     powerJumpSpeed    = landPosX * 2 / powerJumpDuration;
     buffer            = BufferType.None;
     shakeDist         = 0f;
     shakeDir          = 1;
     originalY         = transform.position.y;
     life              = 3;
     isImmune          = false;
     isStomping        = false;
     chargeSoundPlayed = false;
     powerSoundPlayed  = false;
     GameManager.Instance.targetScrollSpeed = 900;
     if (DataManager.Instance.character > 3)
     {
         SetTimes(1.2f);
     }
     StartCoroutine(IncreaseSpeed());
     scaleLock = false;
     GameManager.Instance.StartGame();
     characterChange.ChangeImage(DataManager.Instance.character);
     ChangeParticleColor(deathParticle1, dieColors1[DataManager.Instance.character - 1]);
     ChangeParticleColor(deathParticle2, dieColors2[DataManager.Instance.character - 1]);
     ChangeParticleColor(hitParticle, dieColors1[DataManager.Instance.character - 1]);
     ChangeParticleColor(sweat.GetComponent <ParticleSystem>(), dieColors2[DataManager.Instance.character - 1]);
     GameManager.Instance.player   = this;
     GameManager.Instance.adset    = adset;
     DataManager.Instance.isExited = false;
 }
Beispiel #29
0
 public SecurityBufferClass(int size, BufferType tokentype)
 {
     this.offset = 0;
     this.size   = size;
     this.type   = (int)tokentype;
     this.token  = ((size == 0) ? null : new byte[size]);
 }
Beispiel #30
0
 public VertexBufferPool()
 {
     version    = BufferType.Vertex;
     numBuffers = 0;
     size       = 0;
     buffers    = new Dictionary <ulong, VertexBuffer>();
 }
Beispiel #31
0
        /// <summary>
        /// Creates a new <see cref="Buffer{T}"/> instance with the specified parameters
        /// </summary>
        /// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance</param>
        /// <param name="size">The number of items to store in the current buffer</param>
        /// <param name="sizeInBytes">The size in bytes for the current buffer</param>
        /// <param name="bufferType">The buffer type for the current buffer</param>
        internal Buffer(GraphicsDevice device, int size, int sizeInBytes, BufferType bufferType) : base(device)
        {
            Size                     = size;
            SizeInBytes              = sizeInBytes; // Not necessarily a multiple of the element size, as there could be padding
            ElementSizeInBytes       = Unsafe.SizeOf <T>();
            BufferType               = bufferType;
            PaddedElementSizeInBytes = sizeInBytes / size;

            // Determine the right heap type and flags
            (HeapType heapType, ResourceFlags flags, ResourceStates states) = bufferType switch
            {
                BufferType.Constant => (HeapType.Upload, ResourceFlags.None, ResourceStates.GenericRead),
                BufferType.ReadOnly => (HeapType.Default, ResourceFlags.None, ResourceStates.Common),
                BufferType.ReadWrite => (HeapType.Default, ResourceFlags.AllowUnorderedAccess, ResourceStates.Common),
                BufferType.ReadBack => (HeapType.Readback, ResourceFlags.None, ResourceStates.CopyDestination),
                BufferType.Transfer => (HeapType.Upload, ResourceFlags.None, ResourceStates.GenericRead),
                _ => throw new ArgumentException($"Invalid buffer type {bufferType}", nameof(bufferType))
            };

            // Create the native resource
            ResourceDescription description = ResourceDescription.Buffer(sizeInBytes, flags);

            NativeResource = GraphicsDevice.NativeDevice.CreateCommittedResource(new HeapProperties(heapType), HeapFlags.None, description, states);

            // Create the resource handles, if needed
            (NativeCpuDescriptorHandle, NativeGpuDescriptorHandle) = bufferType switch
            {
                BufferType.Constant => CreateConstantBufferView(),
                BufferType.ReadOnly => CreateShaderResourceView(),
                BufferType.ReadWrite => CreateUnorderedAccessView(),
                _ => default
            };
        }
Beispiel #32
0
        public bool IsDBNull(int i, ColumnData[] columns)
        {
            if (dataBuffer == null)
            {
                dataBuffer = new MemoryHandle(2048);
            }

            ColumnData column = columns[i];
            BufferType type   = column.bufferType;

            IntPtr length;

            CLI.ReturnCode rc = (CLI.ReturnCode)CLI.SQLGetData(
                hstmt,
                (ushort)(i + 1),
                (short)type.sqlCType,
                dataBuffer.Handle,
                (IntPtr)0,
                out length);
            if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO)
            {
                Diagnostics.HandleResult(rc, this, outerCommand.Connection);
            }

            // rewind so that another IsDBNull() won't get SQL_NO_DATA
            RewindData(columns);

            return(length == (IntPtr)(int)CLI.LengthCode.SQL_NULL_DATA);
        }
Beispiel #33
0
 /// <summary>
 /// Create test instance from user input.
 /// </summary>
 /// <param name="testType"></param>
 /// <param name="bufferType"></param>
 /// <param name="capacity"></param>
 /// <returns></returns>
 static IStreamTest CreateTest(TestType testType, BufferType bufferType, int capacity)
 {
     if (TestType.VesselLocation == testType)
     {
         StreamTest <VesselLocation> streamTest = new StreamTest <VesselLocation>(CreateBuffer <VesselLocation>(bufferType, capacity));
         foreach (string name in System.Configuration.ConfigurationManager.AppSettings.Get("Vessels.Names").Split(','))
         {
             streamTest.Register(new VesselLocationGenerator(name));
         }
         return(streamTest);
     }
     else if (TestType.Transaction == testType)
     {
         StreamTest <Transaction> streamTest = new StreamTest <Transaction>(CreateBuffer <Transaction>(bufferType, capacity));
         foreach (string name in System.Configuration.ConfigurationManager.AppSettings.Get("Transaction.Names").Split(','))
         {
             streamTest.Register(new TransactionGenerator(name));
         }
         return(streamTest);
     }
     else if (TestType.Message == testType)
     {
         StreamTest <string> streamTest = new StreamTest <string>(CreateBuffer <string>(bufferType, capacity));
         foreach (string name in System.Configuration.ConfigurationManager.AppSettings.Get("Message.Names").Split(','))
         {
             streamTest.Register(new MessageGenerator(name));
         }
         return(streamTest);
     }
     throw new ArgumentException(String.Format("Invalid test type: \"{0}\"", testType));
 }
Beispiel #34
0
 public SecurityBuffer(byte[] data, int offset, int size, BufferType tokentype)
 {
     this.offset = offset;
     this.size   = (data == null ? 0 : size);
     this.type   = tokentype;
     this.token  = data;
 }
 /// <summary>
 /// Constructor of VertexBufferObject class
 /// </summary>
 /// <param name="device">Graphics device</param>
 /// <param name="type">Type of buffer to use</param>
 /// <param name="buffer">Underlying vertex buffer</param>
 internal VertexBufferObject(GraphicsDevice device, BufferType type, VertexBuffer buffer)
 {
     _device = device;
     _bufferType = type;
     _vertexDeclaration = buffer.VertexDeclaration;
     CreateWrapper(buffer);
 }
Beispiel #36
0
		internal DataType (
			string typeName,
			VirtDbType vdbType,
			System.Data.DbType dbType,
			CLI.SqlType sqlType,
			BufferType bufferType)
			: this (typeName, vdbType, dbType, sqlType, bufferType, false)
		{
		}
        /// <summary>
        /// Constructor of VertexBufferObject class
        /// </summary>
        /// <param name="device">Graphics device</param>
        /// <param name="type">Type of buffer to use</param>
        /// <param name="vertexType">Type of vertex used in the buffer</param>
        /// <param name="vertexCount">Initial size of the buffer</param>
        internal VertexBufferObject(GraphicsDevice device, BufferType type, Type vertexType, int vertexCount)
        {
            if(device == null) throw new ArgumentNullException("device");
            if(vertexType == null) throw new ArgumentNullException("vertexType");

            IVertexType vertex = Activator.CreateInstance(vertexType) as IVertexType;
            if(vertex == null) throw new ArgumentException("Invalid vertex type");

            _device = device;
            _bufferType = type;
            _vertexDeclaration = vertex.VertexDeclaration;
            CreateBuffer(vertexCount);
        }
Beispiel #38
0
		internal DataType (
			string typeName,
			VirtDbType vdbType,
			System.Data.DbType dbType,
			CLI.SqlType sqlType,
			BufferType bufferType,
			bool isLong)
		{
			this.typeName = typeName;
			this.vdbType = vdbType;
			this.dbType = dbType;
			this.sqlType = sqlType;
			this.bufferType = bufferType;
			this.isLong = isLong;
		}
        /// <summary>
        ///     Allocates an existing buffer from the pool
        /// </summary>
        /// <param name="buffer">The byte[]you want the buffer to be assigned to</param>
        /// <param name="type">The type of buffer that is needed</param>
        private void GetBuffer(ref byte[] buffer, BufferType type)
        {
            // We check to see if the buffer already there is the empty buffer. If it isn't, then we have
            // a buffer leak somewhere and the buffers aren't being freed properly.
            if (buffer != EmptyBuffer)
                throw new TorrentException("The old Buffer should have been recovered before getting a new buffer");

            // If we're getting a small buffer and there are none in the pool, just return a new one.
            // Otherwise return one from the pool.
            switch (type)
            {
                case BufferType.SmallMessageBuffer:
                    lock (_smallMessageBuffers)
                    {
                        if (_smallMessageBuffers.Count == 0)
                            AllocateBuffers(5, BufferType.SmallMessageBuffer);
                        buffer = _smallMessageBuffers.Dequeue();
                    }
                    break;
                case BufferType.MediumMessageBuffer:
                    lock (_mediumMessageBuffers)
                    {
                        if (_mediumMessageBuffers.Count == 0)
                            AllocateBuffers(5, BufferType.MediumMessageBuffer);
                        buffer = _mediumMessageBuffers.Dequeue();
                    }
                    break;
                case BufferType.LargeMessageBuffer:
                    lock (_largeMessageBuffers)
                    {
                        if (_largeMessageBuffers.Count == 0)
                            AllocateBuffers(5, BufferType.LargeMessageBuffer);
                        buffer = _largeMessageBuffers.Dequeue();
                    }
                    break;
                default:
                    throw new TorrentException("You cannot directly request a massive buffer");
            }
        }
Beispiel #40
0
 /// <summary>
 /// Creates a new IndexBufferObject
 /// </summary>
 /// <param name="bufferType">Type of buffer to create</param>
 /// <param name="elementSize">Size of index stored in the buffer</param>
 /// <param name="indexCount">Number of indices in the buffer</param>
 /// <returns>Returns an IndexBufferObject</returns>
 public IndexBufferObject CreateIndexBuffer(BufferType bufferType, IndexElementSize elementSize, int indexCount)
 {
     return new IndexBufferObject(_deviceManager.GraphicsDevice, bufferType, elementSize, indexCount);
 }
 private void AllocateBuffers(int number, BufferType type)
 {
     Debug.WriteLine("BufferManager - Allocating {0} buffers of type {1}", number, type);
     switch (type)
     {
         case BufferType.LargeMessageBuffer:
             while (number-- > 0)
                 _largeMessageBuffers.Enqueue(new byte[LargeMessageBufferSize]);
             break;
         case BufferType.MediumMessageBuffer:
             while (number-- > 0)
                 _mediumMessageBuffers.Enqueue(new byte[MediumMessageBufferSize]);
             break;
         case BufferType.SmallMessageBuffer:
             while (number-- > 0)
                 _smallMessageBuffers.Enqueue(new byte[SmallMessageBufferSize]);
             break;
         default:
             throw new ArgumentException("Unsupported BufferType detected");
     }
 }
Beispiel #42
0
        private void AllocateBuffers(int number, BufferType type)
        {
            Logger.Log(null, "BufferManager - Allocating {0} buffers of type {1}", number, type);
            if (type == BufferType.LargeMessageBuffer)
                while (number-- > 0)
                    this.largeMessageBuffers.Enqueue(new ArraySegment<byte>(new byte[LargeMessageBufferSize], 0, LargeMessageBufferSize));

            else if (type == BufferType.MediumMessageBuffer)
                while (number-- > 0)
                    this.mediumMessageBuffers.Enqueue(new ArraySegment<byte>(new byte[MediumMessageBufferSize], 0, MediumMessageBufferSize));

            else if (type == BufferType.SmallMessageBuffer)
                while (number-- > 0)
                        this.smallMessageBuffers.Enqueue(new ArraySegment<byte>(new byte[SmallMessageBufferSize], 0, SmallMessageBufferSize));

            else
                throw new ArgumentException("Unsupported BufferType detected");
        }
        internal static void WebSocketSendWithoutBody(WebSocketBase webSocket,
            BufferType bufferType)
        {
            Debug.Assert(webSocket != null,
                "'webSocket' MUST NOT be NULL or INVALID.");
            Debug.Assert(webSocket.SessionHandle != null && !webSocket.SessionHandle.IsInvalid,
                "'webSocket.SessionHandle' MUST NOT be NULL or INVALID.");

            ThrowIfSessionHandleClosed(webSocket);

            int errorCode;
            try
            {
                errorCode = Interop.WebSocket.WebSocketSendWithoutBody_Raw(webSocket.SessionHandle, bufferType, IntPtr.Zero, IntPtr.Zero);
            }
            catch (ObjectDisposedException innerException)
            {
                throw ConvertObjectDisposedException(webSocket, innerException);
            }

            ThrowOnError(errorCode);
        }
 public SecurityBuffer(ChannelBinding binding)
 {
     this.size = (binding == null) ? 0 : binding.Size;
     this.type = BufferType.ChannelBindings;
     this.unmanagedToken = binding;
 }
 public SecurityBuffer(int size, BufferType tokentype)
 {
     this.size = size;
     this.type = tokentype;
     this.token = (size == 0) ? null : new byte[size];
 }
 public PackageSpec(BufferType Types, double Quality)
 {
     RequiredBuffers = Types;
     this.Quality = Quality;
 }
 public PackageSpec(BufferType Types, Size VideoSize, double Quality)
 {
     RequiredBuffers = Types;
     this.VideoSize = VideoSize;
     this.Quality = Quality;
 }
 internal MemoryBytes(IntPtr data, int size, BufferType bufferType) {
     _size = size;
     _arrayData = null;
     _intptrData = data;
     _fileHandle = IntPtr.Zero;
     _bufferType = bufferType;
 }
 public PackageSpec(BufferType Types, Size VideoSize)
 {
     RequiredBuffers = Types;
     this.VideoSize = VideoSize;
 }
 internal MemoryBytes(byte[] data, int size, bool useTransmitFile, long fileSize) {
     _size = size;
     _arrayData = data;
     _intptrData = IntPtr.Zero;
     _fileHandle = IntPtr.Zero;
     if (useTransmitFile) {
         _bufferType = BufferType.TransmitFile;
     }
     _fileSize = fileSize;
 }
    private BufferType  _bufferType; // 0 managed, 1 native pool, 2 IIS allocated request memory, 3 TransmitFile

    internal MemoryBytes(string fileName, long offset, long fileSize) {
        _bufferType = BufferType.TransmitFile;
        _intptrData = IntPtr.Zero;
        _fileHandle = IntPtr.Zero;
        _fileSize = fileSize;
        _fileName = fileName;
        _offset = offset;
        // _cachedResponseBodyLength will be wrong if we don't set _size now.
        _size = IntPtr.Size;
    }
Beispiel #52
0
        /// <summary>
        /// Allocates an existing buffer from the pool
        /// </summary>
        /// <param name="buffer">The byte[]you want the buffer to be assigned to</param>
        /// <param name="type">The type of buffer that is needed</param>
        private void GetBuffer(ref ArraySegment<byte> buffer, BufferType type)
        {
            // We check to see if the buffer already there is the empty buffer. If it isn't, then we have
            // a buffer leak somewhere and the buffers aren't being freed properly.
            if (buffer != EmptyBuffer)
                throw new TorrentException("The old Buffer should have been recovered before getting a new buffer");

            // If we're getting a small buffer and there are none in the pool, just return a new one.
            // Otherwise return one from the pool.
            if (type == BufferType.SmallMessageBuffer)
                lock (this.smallMessageBuffers)
                {
                    if (this.smallMessageBuffers.Count == 0)
                        this.AllocateBuffers(5, BufferType.SmallMessageBuffer);
                    buffer = this.smallMessageBuffers.Dequeue();
                }

            else if (type == BufferType.MediumMessageBuffer)
                lock (this.mediumMessageBuffers)
                {
                    if (this.mediumMessageBuffers.Count == 0)
                        this.AllocateBuffers(5, BufferType.MediumMessageBuffer);
                    buffer = this.mediumMessageBuffers.Dequeue();
                }

            // If we're getting a large buffer and there are none in the pool, just return a new one.
            // Otherwise return one from the pool.
            else if (type == BufferType.LargeMessageBuffer)
                lock (this.largeMessageBuffers)
                {
                    if (this.largeMessageBuffers.Count == 0)
                        this.AllocateBuffers(5, BufferType.LargeMessageBuffer);
                    buffer = this.largeMessageBuffers.Dequeue();
                }

            else
                throw new TorrentException("You cannot directly request a massive buffer");
        }
Beispiel #53
0
        public SecurityBuffer(byte[] data, int offset, int size, BufferType tokentype) {
            GlobalLog.Assert(offset >= 0 && offset <= (data == null ? 0 : data.Length), "SecurityBuffer::.ctor", "'offset' out of range.  [" + offset + "]");
            GlobalLog.Assert(size >= 0 && size <= (data == null ? 0 : data.Length - offset), "SecurityBuffer::.ctor", "'size' out of range.  [" + size + "]");
			
            this.offset = data == null || offset < 0 ? 0 : Math.Min(offset, data.Length);
            this.size   = data == null || size < 0 ? 0 : Math.Min(size, data.Length - this.offset);
            this.type   = tokentype;
            this.token  = size == 0 ? null : data;
        }
Beispiel #54
0
		internal NumericDataType (
			string typeName,
			VirtDbType vdbType,
			System.Data.DbType dbType,
			CLI.SqlType sqlType,
			BufferType bufferType)
			: base (typeName, vdbType, dbType, sqlType, bufferType)
		{
		}
Beispiel #55
0
        public SecurityBuffer(int size, BufferType tokentype) {
            GlobalLog.Assert(size >= 0, "SecurityBuffer::.ctor", "'size' out of range.  [" + size.ToString(NumberFormatInfo.InvariantInfo) + "]");

            this.size   = size;
            this.type   = tokentype;
            this.token  = size == 0 ? null : new byte[size];
        }
Beispiel #56
0
 public override void setText(CharSequence text, BufferType type)
 {
     base.setText(Iconify.compute(Context, text, this), type);
 }
 public SecurityBuffer(byte[] data, BufferType tokentype)
 {
     this.size = (data == null) ? 0 : data.Length;
     this.type = tokentype;
     this.token = (this.size == 0) ? null : data;
 }
        internal static void WebSocketGetAction(WebSocketBase webSocket,
            ActionQueue actionQueue,
            Interop.WebSocket.Buffer[] dataBuffers,
            ref uint dataBufferCount,
            out Action action,
            out BufferType bufferType,
            out IntPtr actionContext)
        {
            Debug.Assert(webSocket != null,
                "'webSocket' MUST NOT be NULL or INVALID.");
            Debug.Assert(webSocket.SessionHandle != null && !webSocket.SessionHandle.IsInvalid,
                "'webSocket.SessionHandle' MUST NOT be NULL or INVALID.");
            Debug.Assert(dataBufferCount >= 0, "'dataBufferCount' MUST NOT be negative.");
            Debug.Assert((dataBuffers == null && dataBufferCount == 0) ||
                (dataBuffers != null && dataBufferCount == dataBuffers.Length),
                "'dataBufferCount' MUST MATCH 'dataBuffers.Length'.");

            action = Action.NoAction;
            bufferType = BufferType.None;
            actionContext = IntPtr.Zero;

            IntPtr dummy;
            ThrowIfSessionHandleClosed(webSocket);

            int errorCode;
            try
            {
                errorCode = Interop.WebSocket.WebSocketGetAction(webSocket.SessionHandle,
                    actionQueue,
                    dataBuffers,
                    ref dataBufferCount,
                    out action,
                    out bufferType,
                    out dummy,
                    out actionContext);
            }
            catch (ObjectDisposedException innerException)
            {
                throw ConvertObjectDisposedException(webSocket, innerException);
            }
            ThrowOnError(errorCode);

            webSocket.ValidateNativeBuffers(action, bufferType, dataBuffers, dataBufferCount);

            Debug.Assert(dataBufferCount >= 0);
            Debug.Assert((dataBufferCount == 0 && dataBuffers == null) ||
                (dataBufferCount <= dataBuffers.Length));
        }
 public override void SetText(ICharSequence text, BufferType type)
 {
     base.SetText(this.Compute(Context, text), type);
 }
Beispiel #60
0
 public static extern void SourceQueueBuffer(Source source, Buffer buffer, IntPtr pcm, int bufferSize, BufferType streamType);