Example #1
0
        public void Different_names_generate_different_hashes()
        {
            var a = new Stream("abc");
            var b = new Stream("xyz");

            Assert.NotEqual(a, b);
        }
Example #2
0
 public StreamListItem(Stream audioStream)
 {
     // Set Stream
     stream = audioStream;
     // Create components
     InitializeComponent();
 }
        public async void When_provisioning_along_with_custom_properties()
        {
            var properties = new Dictionary<string, EntityProperty>
            {
                {"Created", new EntityProperty(DateTimeOffset.Now)},
                {"Active",  new EntityProperty(true)}
            };

            var stream = await Stream.ProvisionAsync(partition, StreamProperties.From(properties));
            var entity = partition.RetrieveStreamEntity();

            var expectedStream = new Stream
            (
                partition,
                entity.ETag, 0, 
                StreamProperties.From(properties)
            );

            stream.ShouldEqual(expectedStream.ToExpectedObject());

            var expectedEntity = new
            {
                RowKey = Api.StreamRowKey,
                Properties = StreamProperties.From(properties),
                Version = 0
            };

            entity.ShouldMatch(expectedEntity.ToExpectedObject());
        }
Example #4
0
		short prev; // 1音前のデータを一時的に保存しておく。

		#endregion
		#region 初期化

		/// <summary>
		/// 初期化。
		/// </summary>
		/// <param name="stream">内部ストリーム</param>
		/// <param name="rate">変換レート</param>
		public RateTransposer(Stream stream, double rate)
		{
			this.stream = stream;
			this.rate = rate;
			this.inputBuffer = null;
			this.prev = 0;
		}
Example #5
0
 public Output Reify(
     Cell<IMaybe<Size>> size,
     Stream<MouseEvent> sMouse, Stream<KeyEvent> sKey,
     Cell<long> focus, Supply idSupply)
 {
     return this.reify(size, sMouse, sKey, focus, idSupply);
 }
Example #6
0
        public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.WriteLine("Shadow.UShadow.Cloud.Worker entry point called", "Information");

            // Connect to Twitter.
            //
            Stream.ProcessTweetDelegate produceTweetDelegate = new Stream.ProcessTweetDelegate(processTweet);

            // Creating the stream and specifying the delegate
            Stream myStream = new Stream(produceTweetDelegate);

            Token token = new Token()
            {
                AccessToken = "14910567-1AnQzrOuwPFsPd9HrcXrCPBmW7Cwf7doxXqd5vdgi",
                AccessTokenSecret = "hHzkPdejgaJkt9VKxW7JGDC0AnJ5GzvlRjhNaHzYzW4",
                ConsumerKey = "WFYdWcCCTZk4ASituGqhqQ",
                ConsumerSecret = "DfOmNZOrhN31vuEDpm10lxkSSB1MfjVA4Y9oPzSK0gc"
            };

            myStream.StreamUrl = "https://userstream.twitter.com/1.1/user.json?with=user&track=!Shadow";

            // Starting the stream by specifying credentials thanks to the Token
            myStream.StartStream(token);

            while (true)
            {
                Thread.Sleep(10000);
                Trace.WriteLine("Working", "Information");
            }
        }
Example #7
0
 public static byte ReadByte(Stream s)
 {
     int v = s.ReadByte();
     if (v == -1)
         throw new Exception("IOException: EOF");
     return (byte)v;
 }
Example #8
0
        public void Same_name_generates_equal_streams()
        {
            var a = new Stream("123");
            var b = new Stream("123");

            Assert.Equal(a, b);
        }
Example #9
0
 public static int InternalReadByte(Stream s)
 {
     int v = s.ReadByte();
     if (v == -1)
         throw new Exception("IOException: EOF");
     return v;
 }
Example #10
0
        public void Names_must_be_case_insensitive()
        {
            var a = new Stream("foobar");
            var b = new Stream("FooBAR");

            Assert.Equal(a, b);
        }
        internal void NavigateToStream(Stream streamObject, StreamDeskDatabase db)
        {
            if (streamObject.StreamEmbed == "url_browser") {
                webBrowser1.ScrollBarsEnabled = true;
                toolStrip1.Visible = true;
            } else {
                webBrowser1.ScrollBarsEnabled = false;
                toolStrip1.Visible = false;
            }

            viewToolStripMenuItem.Visible = true;
            ActiveStreamObject = streamObject;
            ActiveDatabase = db;

            if (streamObject.ChatEmbed != "none" || streamObject.ChatEmbed != null)
                chatToolStripMenuItem.Visible = true;
            else
                chatToolStripMenuItem.Visible = false;

            Text = streamObject.Name + " > " + streamObject.ProviderObject.Name;

            if (streamObject.StreamEmbed == "url_browser" || streamObject.StreamEmbed == "url_custom")
                webBrowser1.Navigate(streamObject.GetStreamEmbedData("URL"));
            else {
                ClientSize = new Size(streamObject.Size.Width, streamObject.Size.Height);
                webBrowser1.DocumentText = db.GetStream(streamObject);
            }
        }
 public void OnStreamCreated(PublisherKit publisher, Stream stream)
 {
     mStreams.Add(stream);
     if (mSubscriber == null) {
         SubscribeToStream(stream);
     }
 }
Example #13
0
        public Conference(string json_str)
        {
            dynamic json = JObject.Parse(json_str);
            var conference = json["conference"];
            cid = (int)conference["cid"];
            string desc = (string)conference["desc"];
            this.desc = Encoding.GetEncoding("gbk").GetString(Convert.FromBase64String(desc));
            mode = (string)conference["mode"];
            uptime = (double)conference["uptime"];

            Streams = new List<Stream>();
            foreach (var stream in conference["streams"]) {
                Stream s = new Stream();
                s.streamid = stream["streamid"];
                string d = stream["desc"];
                if (d == "audio(iLBC)")
                    s.desc = d;
                else {
                    byte[] raw = Convert.FromBase64String(d);
                    s.desc = Encoding.GetEncoding("gbk").GetString(raw);
                }
                s.stat = new Stream.Stat();
                s.stat.bytes_recv = stream["stat"]["bytes_recv"];
                s.stat.bytes_sent = stream["stat"]["bytes_sent"];
                s.stat.jitter = stream["stat"]["jitter"];
                s.stat.packet_lost_recv = stream["stat"]["packet_lost_recv"];
                s.stat.packet_lost_sent = stream["stat"]["packet_lost_sent"];
                s.stat.packet_recv = stream["stat"]["packet_recv"];
                s.stat.packet_sent = stream["stat"]["packet_sent"];

                Streams.Add(s);
            }

            // TODO:
            Sources = new List<Source>();

            Sinks = new List<Sink>();
            foreach (var sink in conference["sinks"]) {
                Sink s = new Sink();
                s.sinkid = sink["sinkid"];
                string d = sink["desc"];
                if (d == "audio(iLBC)")
                    s.desc = d;
                else {
                    byte[] raw = Convert.FromBase64String(d);
                    s.desc = Encoding.GetEncoding("gbk").GetString(raw);
                }
                d = sink["who"];
                byte[] who_raw = Convert.FromBase64String(d);
                s.who = Encoding.GetEncoding("gbk").GetString(who_raw);
                s.stat = new Sink.Stat();
                s.stat.jitter = sink["stat"]["jitter"];
                s.stat.packets_lost = sink["stat"]["packets_lost"];
                s.stat.packets = sink["stat"]["packets"];
                s.stat.sent = sink["stat"]["sent"];

                Sinks.Add(s);
            }
        }
Example #14
0
 protected override void doSerialize(Stream stream)
 {
     centerOfMass.serialize(stream);
     stream.write(mass);
     torque.serialize(stream);
     momentumOfInertia.serialize(stream);
     angularMomentum.serialize(stream);
 }
Example #15
0
 protected override void doDeserialize(Stream stream)
 {
     centerOfMass.deserialize(stream);
     mass = stream.readDouble();
     torque.deserialize(stream);
     momentumOfInertia.deserialize(stream);
     angularMomentum.deserialize(stream);
 }
		/// <summary>
		/// 序列化对象到流
		/// </summary>
		/// <param name="objectToSerialize">要序列化的对象</param>
		/// <param name="stream">保存对象信息的流</param>
		public static void SerializeToStream(this object objectToSerialize, Stream stream)
		{
			if (objectToSerialize == null || stream == null)
				return;

			BinaryFormatter xso = new BinaryFormatter();
			xso.Serialize(stream, objectToSerialize);
		}
 public StreamInformation(Stream stream)
 {
     InitializeComponent();
     textBox1.Text = stream.Name;
     textBox2.Text = stream.Tags;
     linkLabel1.Text = stream.Web;
     textBox3.Text = stream.Description;
 }
Example #18
0
 public static Timetable From(Stream stream)
 {
     Timetable t = new Timetable();
     t.SubjectList.Add(stream.Type.Subject);
     t.TypeList.Add(stream.Type);
     t.StreamList.Add(stream);
     t.ClassList.AddRange(stream.Classes);
     return t;
 }
Example #19
0
        public static Serializable tryCreate(Stream stream)
        {
            var tag = stream.tryReadTag(true);

            if(tag == null)
                return null;

            return _create(stream, tag.Value);
        }
Example #20
0
 public Output(
     Cell<DrawableDelegate> drawable,
     Cell<Size> desiredSize,
     Stream<long> sChangeFocus)
 {
     this.Drawable = drawable;
     this.DesiredSize = desiredSize;
     this.SChangeFocus = sChangeFocus;
 }
Example #21
0
		/// <summary>
		/// 初期化。
		/// </summary>
		/// <param name="stream">内部ストリーム</param>
		/// <param name="rate">変換レート</param>
		/// <param name="overlapSize">オーバーラップ部分の長さ</param>
		public TimeStretcher(Stream stream, double rate, int overlapSize, int margin)
		{
			this.stream = stream;
			this.rate = rate;
			this.inputBuffer = null;
			this.readSize = 0;
			this.overlapBuffer = new short[overlapSize];
			this.margin = margin;
		}
		public TextWriterTraceListener (Stream stream, string name)
			: base (name ?? "")
			{
			if (stream == null)
				throw new ArgumentNullException ("stream");
			if (stream.GetType () == typeof (Stream))
				writer = new StreamWriter (stream);
			else
				mwriter = new MStreamWriter (stream);
			}
Example #23
0
        public void Same_hashes_generate_equal_streams()
        {
            var hash1 = Enumerable.Range(0, 20).Select(i => (byte)i).ToArray();
            var hash2 = Enumerable.Range(0, 20).Select(i => (byte)i).ToArray();

            var a = new Stream(hash1);
            var b = new Stream(hash2);

            Assert.Equal(a, b);
        }
Example #24
0
        public AggregateCommand(Stream stream, object command, TimeSpan timeout)
        {
            Argument.RequiresNotNull(stream, nameof(stream));
            Argument.RequiresNotNull(command, nameof(command));

            this.CommandID = Guid.NewGuid();
            this.Stream = stream;
            this.Command = command;
            this.Timeout = Timeout.In(timeout);
        }
Example #25
0
 static void Run(int k, Stream<int> xs)
 {
     while (k-- > 0)
     {
         Debug.Assert(15 + 11 - k - 1 == xs.Value);
         Console.WriteLine(xs.Value);
         Runtime.Tick();
         xs = xs.Next.Force();
     }
 }
Example #26
0
        public virtual void deserializeState(Stream stream)
        {
            if (stream.readTag(true) != this.tag)
                throw new SerializationException("Tried to deserialize state from node with wrong tag");

            doDeserializeState(stream);

            if(stream.readTag(false) != tag)
                throw new SerializationException("Wrong closing tag");
        }
Example #27
0
        public ReadStreamRequest(Stream stream, int initialSequence, int count)
        {
            Argument.Requires(stream != null);
            Argument.Requires(initialSequence >= 1, nameof(initialSequence));
            Argument.Requires(count >= 0 || count == EventCount.Unlimited, nameof(count));

            this.Stream = stream;
            this.InitialSequence = initialSequence;
            this.Count = count;
        }
Example #28
0
        public PersistenceRequest(Stream stream, int expectedStreamSequence, IReadOnlyList<UnpersistedEvent> events)
            : this(events)
        {
            Argument.RequiresNotNull(stream, nameof(stream));
            Argument.Requires(expectedStreamSequence >= 0 || expectedStreamSequence == ExpectedSequence.Any, nameof(expectedStreamSequence));
            Argument.Requires(events.All(e => e.Stream.Equals(stream)), nameof(events), $"All events must belong to the stream '{stream}'");

            this.Stream = stream;
            this.ExpectedStreamSequence = expectedStreamSequence;
            this.Events = events;
        }
Example #29
0
 public static void Convert(String htmlFilename, String mhtFilename)
 {
     var objMessage = new Message();
     objMessage.CreateMHTMLBody(htmlFilename);
     var strm = new Stream {Type = StreamTypeEnum.adTypeText, Charset = "US-ASCII"};
     strm.Open();
     IDataSource dsk = objMessage.DataSource;
     dsk.SaveToObject(strm, "_Stream");
     strm.SaveToFile(mhtFilename, SaveOptionsEnum.adSaveCreateOverWrite);
     strm.Close();
 }
Example #30
0
 public STM32DMA(Machine machine)
 {
     streamFinished = new bool[NumberOfStreams];
     streams = new Stream[NumberOfStreams];
     for(var i = 0; i < streams.Length; i++)
     {
         streams[i] = new Stream(this, i);
     }
     this.machine = machine;
     engine = new DmaEngine(machine);
     Reset();
 }