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


C# IStream类代码示例

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


IStream类属于命名空间,在下文中一共展示了IStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Arduino_Disconnect

 private void Arduino_Disconnect()
 {
     arduinoConnected = false;
     arduinoConnection.end();
     arduinoConnection = null;
     arduino = null;
 }
开发者ID:turkycat,项目名称:band-controlled-car,代码行数:7,代码来源:MainPage.xaml.cs

示例15: SetUp

 public void SetUp()
 {
     streamId = Guid.NewGuid().ToString();
     store = TestEventStore.Create();
     store.Populate(streamId);
     stream =  NEventStoreStream.ByAggregate(store, streamId);
 }
开发者ID:gitter-badger,项目名称:Alluvial,代码行数:7,代码来源:ProjectionTests.cs


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