• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: InitFirmata

    private void InitFirmata()
    {
      //USB\VID_2A03&PID_0043&REV_0001
      //create a serial connection
      //var devices = await UsbSerial.listAvailableDevicesAsync();
      //var devList = devices.ToList();

      serial = new UsbSerial("VID_2A03", "PID_0043");

      //construct the firmata client
      firmata = new UwpFirmata();
      firmata.FirmataConnectionReady += Firmata_FirmataConnectionReady;
      firmata.StringMessageReceived += Firmata_StringMessageReceived;

      //last, construct the RemoteWiring layer by passing in our Firmata layer.
      arduino = new RemoteDevice(firmata);
      arduino.DeviceReady += Arduino_DeviceReady;

      //if you create the firmata client yourself, don't forget to begin it!
      firmata.begin(serial);

      //you must always call 'begin' on your IStream object to connect.
      //these parameters do not matter for bluetooth, as they depend on the device. However, these are the best params to use for USB, so they are illustrated here
      serial.begin(57600, SerialConfig.SERIAL_8N1);

    }
开发者ID:BretStateham,项目名称:GrokingFirmata,代码行数:26,代码来源:MainPage.xaml.cs


示例2: RegisterStream

        public bool RegisterStream(IStream stream)
        {
            if (StreamsByUniqueId.ContainsKey(stream.UniqueId))
            {
                Logger.FATAL("Stream with unique ID {0} already registered",stream.UniqueId);
                return false;
            }
            StreamsByUniqueId[stream.UniqueId] = stream;
            var protocol = stream.GetProtocol();
            if (protocol != null)
            {
                if (!StreamsByProtocolId.ContainsKey(protocol.Id))
                    StreamsByProtocolId[protocol.Id] = new Dictionary<uint, IStream>();
                StreamsByProtocolId[protocol.Id][stream.UniqueId] = stream;

            }
            if (!StreamsByType.ContainsKey(stream.Type))
            {
                StreamsByType[stream.Type] = new Dictionary<uint, IStream>();
            }
            StreamsByType[stream.Type][stream.UniqueId] = stream;
            if (!StreamsByName.ContainsKey(stream.Name))
            {
                StreamsByName[stream.Name] = new Dictionary<uint, IStream>();
            }
            StreamsByName[stream.Name][stream.UniqueId] = stream;
            Application.SignalStreamRegistered(stream);
            return true;
        }
开发者ID:langhuihui,项目名称:csharprtmp,代码行数:29,代码来源:StreamsManager.cs


示例3: Write

        private static void Write(IStream stream)
        {
            try
            {
                int i = 1;
                StrKey k1 = k1 = new StrKey("k1");
                while (true)
                {
                    stream.Append(k1, new ByteValue(StreamFactory.GetBytes("k1-value" + i)));
                    i++;

                    Console.WriteLine("Written "+i+" values");
                   if (i %10==0)
                        stream.Seal(false);


                    if (isWriting)
                        System.Threading.Thread.Sleep(1000);
                    else
                        break;
                }
            }
            catch(Exception e)
            {
                Console.WriteLine("Exception in write: "+e);
            }

        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:28,代码来源:Program.cs


示例4: GetDecorateAscii7Stream

 public static IStream GetDecorateAscii7Stream(IStream stream)
 {
     return new Ascii7Stream
                {
                    Stream = stream
                };
 }
开发者ID:AbstactFactory,项目名称:DesignPatterns,代码行数:7,代码来源:StreamFactoryMethodClass.cs


示例5: WriteReflexive

        /// <summary>
        ///     Writes data to a reflexive, reallocating the original.
        /// </summary>
        /// <param name="entries">The entries to write.</param>
        /// <param name="oldCount">The old count.</param>
        /// <param name="oldAddress">The old address.</param>
        /// <param name="newCount">The number of entries to write.</param>
        /// <param name="layout">The layout of the data to write.</param>
        /// <param name="metaArea">The meta area of the cache file.</param>
        /// <param name="allocator">The cache file's meta allocator.</param>
        /// <param name="stream">The stream to manipulate.</param>
        /// <returns>The address of the new reflexive, or 0 if the entry list is empty and the reflexive was freed.</returns>
        public static uint WriteReflexive(IEnumerable<StructureValueCollection> entries, int oldCount, uint oldAddress,
			int newCount, StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
        {
            if (newCount == 0)
            {
                // Free the old reflexive and return
                if (oldCount > 0 && oldAddress != 0)
                    allocator.Free(oldAddress, oldCount*layout.Size);
                return 0;
            }

            uint newAddress = oldAddress;
            if (newCount != oldCount)
            {
                // Reallocate the reflexive
                int oldSize = oldCount*layout.Size;
                int newSize = newCount*layout.Size;
                if (oldCount > 0 && oldAddress != 0)
                    newAddress = allocator.Reallocate(oldAddress, oldSize, newSize, stream);
                else
                    newAddress = allocator.Allocate(newSize, stream);
            }

            // Write the new values
            WriteReflexive(entries.Take(newCount), newAddress, layout, metaArea, stream);
            return newAddress;
        }
开发者ID:ChadSki,项目名称:Assembly,代码行数:39,代码来源:ReflexiveWriter.cs


示例6: LoadStreams

        public void LoadStreams(IStream leftStream, FileType leftFileType, byte[] leftData, IStream rightStream, FileType rightFileType, byte[] rightData)
        {
            _leftDetails.SelectDetails(leftStream, leftFileType);
            _rightDetails.SelectDetails(rightStream, rightFileType);

            _summary.Text = Labels.BinaryFileSummary;
        }
开发者ID:netide,项目名称:netide,代码行数:7,代码来源:SummaryViewer.cs


示例7: FromStream

        //static public ImagePlus FromFile(
        //    string filename,
        //    bool useEmbeddedColorManagement 
        //)
        //{
        //}

        static public ImagePlus FromStream(
            IStream stream,
            bool useEmbeddedColorManagement
        )
        {
            return new ImagePlus(stream, useEmbeddedColorManagement);
        }
开发者ID:intille,项目名称:mitessoftware,代码行数:14,代码来源:Image.cs


示例8: ImagePlus

 public ImagePlus(
     IStream stream,
     bool useEmbeddedColorManagement
 )
 {
     NativeMethods.GdipLoadImageFromStream(stream, out nativeImage);
 }
开发者ID:intille,项目名称:mitessoftware,代码行数:7,代码来源:Image.cs


示例9: Copy

		/// <summary>
		///     Copies data between two locations in the same stream.
		///     The source and destination areas may overlap.
		/// </summary>
		/// <param name="stream">The stream to copy data in.</param>
		/// <param name="originalPos">The position of the block of data to copy.</param>
		/// <param name="targetPos">The position to copy the block to.</param>
		/// <param name="size">The number of bytes to copy.</param>
		public static void Copy(IStream stream, long originalPos, long targetPos, long size)
		{
			if (size == 0)
				return;
			if (size < 0)
				throw new ArgumentException("The size of the data to copy must be >= 0");

			const int BufferSize = 0x1000;
			var buffer = new byte[BufferSize];
			long remaining = size;
			while (remaining > 0)
			{
				var read = (int) Math.Min(BufferSize, remaining);

				if (targetPos > originalPos)
					stream.SeekTo(originalPos + remaining - read);
				else
					stream.SeekTo(originalPos + size - remaining);

				stream.ReadBlock(buffer, 0, read);

				if (targetPos > originalPos)
					stream.SeekTo(targetPos + remaining - read);
				else
					stream.SeekTo(targetPos + size - remaining);

				stream.WriteBlock(buffer, 0, read);
				remaining -= read;
			}
		}
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:38,代码来源:StreamUtil.cs


示例10: PatchSegments

        /// <summary>
        ///     Patches the file segments in a stream.
        /// </summary>
        /// <param name="changes">The changes to make to the segments and their data.</param>
        /// <param name="stream">The stream to write changes to.</param>
        public static void PatchSegments(IEnumerable<SegmentChange> changes, IStream stream)
        {
            // Sort changes by their offsets
            var changesByOffset = new SortedList<uint, SegmentChange>();
            foreach (SegmentChange change in changes)
                changesByOffset[change.OldOffset] = change;

            // Now adjust each segment
            foreach (SegmentChange change in changesByOffset.Values)
            {
                // Resize it if necessary
                if (change.NewSize != change.OldSize)
                {
                    if (change.ResizeAtEnd)
                        stream.SeekTo(change.NewOffset + change.OldSize);
                    else
                        stream.SeekTo(change.NewOffset);

                    StreamUtil.Insert(stream, change.NewSize - change.OldSize, 0);
                }

                // Patch its data
                DataPatcher.PatchData(change.DataChanges, change.NewOffset, stream);
            }
        }
开发者ID:t3hm00kz,项目名称:Assembly,代码行数:30,代码来源:SegmentPatcher.cs


示例11: Allocate

        /// <summary>
        ///     Allocates a free block of memory in the cache file's meta area.
        /// </summary>
        /// <param name="size">The size of the memory block to allocate.</param>
        /// <param name="align">The power of two to align the block to.</param>
        /// <param name="stream">The stream to write cache file changes to.</param>
        /// <returns></returns>
        public uint Allocate(int size, uint align, IStream stream)
        {
            // Find the smallest block that fits, or if nothing is found, expand the meta area
            FreeArea block = FindSmallestBlock(size, align);
            if (block == null)
                block = Expand(size, stream);

            if (block.Size == size)
            {
                // Perfect fit - just remove the block and we're done
                RemoveArea(block);
                return block.Address;
            }

            // Align the address
            uint oldAddress = block.Address;
            uint alignedAddress = (oldAddress + align - 1) & ~(align - 1);

            // Adjust the block's start address to free the data we're using
            ChangeStartAddress(block, (uint) (alignedAddress + size));

            // Add a block at the beginning if we had to align
            if (alignedAddress > oldAddress)
                Free(oldAddress, (int) (alignedAddress - oldAddress));

            return alignedAddress;
        }
开发者ID:ChadSki,项目名称:Assembly,代码行数:34,代码来源:MetaAllocator.cs


示例12: Write

 public void Write(IStream stream, object somethingToWrite, int level)
 {
     objectCounter.Add(somethingToWrite);
     stream.Write(string.Format("#{0} : {1}.", objectCounter.Count, somethingToWrite.GetType().Name));
     stream.WriteLine();
     foreach (var propertyInfo in somethingToWrite.GetType().GetProperties(DomainGenerator.FlattenHierarchyBindingFlag))
     {
         level.Times(() => stream.Write("    "));
         stream.Write(string.Format("{0} = ", propertyInfo.Name));
         if (primitivesWriter.IsMatch(propertyInfo.PropertyType))
         {
             primitivesWriter.Write(stream, propertyInfo.PropertyType, propertyInfo.GetValue(somethingToWrite, null));
             stream.WriteLine();
             continue;
         }
         //try
         //{
         //    var value = propertyInfo.GetValue(somethingToWrite, null);
         //    if (objectCounter.Contains(value))
         //    {
         //        stream.Write(string.Format("#{0} : {1}.", objectCounter.IndexOf(value) + 1, propertyInfo.PropertyType.Name));
         //        stream.WriteLine();
         //        continue;
         //    }
         //    Write(stream, value, ++level);
         //}
         //catch (Exception)
         //{
         //    stream.Write(string.Format("#dunno : {0}.", propertyInfo.PropertyType.Name));
         //    stream.WriteLine();
         //    continue;
         //}
     }
 }
开发者ID:Bunk,项目名称:QuickGenerate,代码行数:34,代码来源:ObjectWriter.cs


示例13: ComStream

 /// <summary>
 /// Wraps a native IStream interface into a CLR Stream subclass.
 /// </summary>
 /// <param name="stream">
 /// The stream that this object wraps.
 /// </param>
 /// <remarks>
 /// Note that the parameter is passed by ref.  On successful creation it is
 /// zeroed out to the caller.  This object becomes responsible for the lifetime
 /// management of the wrapped IStream.
 /// </remarks>
 public ComStream(ref IStream stream)
 {
     Verify.IsNotNull(stream, "stream");
     _source = stream;
     // Zero out caller's reference to this.  The object now owns the memory.
     stream = null;
 }
开发者ID:Alkalinee,项目名称:GamerJail,代码行数:18,代码来源:StreamHelper.cs


示例14: Read

        private static void Read(IStream stream)
        {
            try
            {
                StrKey k1 = k1 = new StrKey("k1");
                while (true)
                {
                    IEnumerable<IDataItem> dataitems= stream.GetAll(k1);

                    DateTime now = DateTime.Now;
                    int count =0;
                    foreach (IDataItem item in dataitems)
                    {
                        item.GetVal();
                        count++;
                    }
                    
                    Console.WriteLine("[" + now + "]" + "GetAll "+count+" values received.");

                    if (isReading)
                        System.Threading.Thread.Sleep(ReadFrequencySeconds * 1000);
                    else
                        break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in read: " + e);
            }

        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:31,代码来源:Program.cs


示例15: MarshalInterface

        public void MarshalInterface(IStream pstm, ref Guid riid, IntPtr pv, uint dwDestContext, IntPtr pvDestContext, uint MSHLFLAGS)
        {
            uint written;
            byte[] data = ComUtils.CreateStandardMarshal(_binding);

            pstm.Write(data, (uint)data.Length, out written);
        }
开发者ID:Ridter,项目名称:Trebuchet,代码行数:7,代码来源:ComInterfaces.cs


示例16:

 void IStream.CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
 {
     var bytes = new byte[cb];
     Marshal.WriteInt64(pcbRead, this.stream.Read(bytes, 0, (int)cb));
     Marshal.WriteInt64(pcbWritten, cb);
     this.stream.Write(bytes, 0, (int)cb);
 }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.Imaging,代码行数:7,代码来源:StreamAdapter.cs


示例17: create

 /// <summary>
 /// Create a sequence from a stream.
 /// </summary>
 /// <param name="stream">The stream to sequence.</param>
 /// <returns>The persistent sequence.</returns>
 /// <remarks>Requires looking at the first element of the stream.  
 /// This is so that we know if the stream has any elements.  
 /// This is so because the sequence must have at least element or be null.</remarks>
 public static StreamSeq create(IStream stream)
 {
     object x = stream.next();
     return (RT.isEOS(x))
         ? null
         : new StreamSeq(x, stream);
 }
开发者ID:arohner,项目名称:clojure-contrib,代码行数:15,代码来源:StreamSeq.cs


示例18: Return

        public void Return(IStream stream)
        {
            var fileSystemStream = stream as PooledFileSystemStream;
            if (fileSystemStream == null)
                throw new ArgumentException("The stream parameter does not contain a stream handled by this provider");

            fileSystemStream.Stream.Dispose();
        }
开发者ID:jaygumji,项目名称:EnigmaDb,代码行数:8,代码来源:FileSystemStreamProvider.cs


示例19: UnsafeIndexingFilterStream

        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
        /// <summary>
        /// Build a System.IO.Stream implementation around an IStream component.
        /// </summary>
        /// <remarks>
        /// The client code is entirely responsible for the lifespan of the stream,
        /// and there is no way it can tip us off for when to release it. Therefore,
        /// its reference count is not incremented. The risk of the client 
        /// releasing the IStream component before we're done with it is no worse than
        /// that of the client passing a pointer to garbage in the first place, and we
        /// cannot protect against that either. After all, the client is unmanaged and
        /// has endless possibilities of trashing the machine if she wishes to.
        /// </remarks>
        internal UnsafeIndexingFilterStream(IStream oleStream)
        {
            if (oleStream == null)
                throw new ArgumentNullException("oleStream");

            _oleStream = oleStream;
            _disposed = false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:unsafeIndexingFilterStream.cs


示例20: Delete

        public void Delete(IStream feedStream)
        {
            List<IStream> feedStreams = new List<IStream>();
            if (activityFeedStore.TryGetValue(feedStream.FeedId, out feedStreams) == false)
                activityFeedStore.TryAdd(feedStream.FeedId, feedStreams);

            feedStreams.Remove(feedStream);
        }
开发者ID:djimmytrovy,项目名称:ActivityStreams,代码行数:8,代码来源:InMemoryFeedStreamStore.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IStringReader类代码示例发布时间:2022-05-24
下一篇:
C# IStrategy类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap