Пример #1
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            output.Write(RandomId.ToBytes());
            output.Write(TTL.ToBytes());
            //output.Write(RandomBytes.ToBytes());
            output.Write(Message.ToBytes());
            Media.ToStream(output);

            ChatId.NullableToStream(output);
            InputFile.NullableToStream(output);
            FromId.NullableToStream(output);
            Out.NullableToStream(output);
            Unread.NullableToStream(output);
            Date.NullableToStream(output);
            DeleteDate.NullableToStream(output);
            Qts.NullableToStream(output);

            var status = new TLInt((int)Status);

            output.Write(status.ToBytes());

            InSeqNo.NullableToStream(output);
            OutSeqNo.NullableToStream(output);
            CustomFlags.NullableToStream(output);
        }
Пример #2
0
 private Request(Guid id, Login login, Password password, TTL ttl)
 {
     this.login    = login;
     this.password = password;
     this.ttl      = ttl;
     this.id       = id;
 }
Пример #3
0
        public override void ToStream(Stream output)
        {
            output.Write(TLUtils.SignatureToBytes(Signature));
            output.Write(Flags.ToBytes());
            output.Write(RandomId.ToBytes());
            output.Write(TTL.ToBytes());
            output.Write(Message.ToBytes());
            ToStream(output, Media, Flags, (int)MessageFlags.Media);
            ToStream(output, Entities, Flags, (int)MessageFlags.Entities);
            ToStream(output, ViaBotName, Flags, (int)MessageFlags.ViaBotId);
            ToStream(output, ReplyToRandomMsgId, Flags, (int)MessageFlags.ReplyToMsgId);

            ChatId.NullableToStream(output);
            InputFile.NullableToStream(output);
            FromId.NullableToStream(output);
            Out.NullableToStream(output);
            Unread.NullableToStream(output);
            Date.NullableToStream(output);
            DeleteDate.NullableToStream(output);
            Qts.NullableToStream(output);

            var status = new TLInt((int)Status);

            output.Write(status.ToBytes());

            InSeqNo.NullableToStream(output);
            OutSeqNo.NullableToStream(output);
            CustomFlags.NullableToStream(output);

            if (IsSet(CustomFlags, (int)MessageCustomFlags.BotInlineResult))
            {
                _inlineBotResult.ToStream(output);
            }
        }
Пример #4
0
        // Public Methods

        public override String ToString()
        {
            return(String.Format("{0} {1} {2} {3} {4}",
                                 Name,
                                 TTL.ToString(),
                                 RecordClass.ToString(),
                                 RecordType.ToString(),
                                 RecordData));
        }
Пример #5
0
 public string ToString(int namePadding)
 {
     return(String.Join(" ", new string[] {
         NAME.PadLeft(namePadding),
         TTL.ToString(),
         CLASS.ToString(),
         TypeString
     }));
 }
Пример #6
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                RandomId.ToBytes(),
                TTL.ToBytes(),
                Message.ToBytes(),
                Media.ToBytes()));
 }
Пример #7
0
        public void Must_not_allow_negative_values()
        {
            var a = Record.Exception(() => new TTL(-1));

            a.Should().BeOfType <ArgumentOutOfRangeException>();

            var b = Record.Exception(() => { TTL a = -1; });

            b.Should().BeOfType <ArgumentOutOfRangeException>();
        }
Пример #8
0
        public void Must_be_Comparable()
        {
            var a = new TTL(1200);
            var b = new TTL(2400);
            var c = new TTL(3600);

            b.CompareTo(a).Should().Be(1);
            b.CompareTo(b).Should().Be(0);
            b.CompareTo(c).Should().Be(-1);
        }
Пример #9
0
        public override byte[] ToBytes()
        {
            System.Diagnostics.Debug.WriteLine("  <<TLDecryptedMessage17.ToBytes random_id={0} ttl={1} message={2} media=[{3}]", RandomId, TTL, Message, Media);

            return(TLUtils.Combine(
                       TLUtils.SignatureToBytes(Signature),
                       RandomId.ToBytes(),
                       TTL.ToBytes(),
                       Message.ToBytes(),
                       Media.ToBytes()));
        }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        _emitter              = GetComponent <ParticleSystem>();
        _ttl                  = GetComponent <TTL>();
        DiminishStartPercent /= 100.0f;
        var duration = (_ttl.end - _ttl.start) * (1 - DiminishStartPercent);

        _startTime     = (_ttl.end - _ttl.start) - duration;
        _diminishSize  = _emitter.startSize / (duration / DiminishFrequencyInSeconds);
        _diminishSpeed = _emitter.startSpeed / (duration / DiminishFrequencyInSeconds) + DiminishSpeed;
    }
Пример #11
0
 public bool Equals(RRBase rrbase)
 {
     if (object.ReferenceEquals(null, rrbase))
     {
         return(false);
     }
     return
         (NAME.Equals(rrbase.NAME) &&
          TypeValue.Equals(rrbase.TypeValue) &&
          CLASS.Equals(rrbase.CLASS) &&
          TTL.Equals(rrbase.TTL));
 }
Пример #12
0
        public void SetString_ConvertToTtl_Ttl()
        {
            // Arrange
            RssTtl    rssTtl = new RssTtl();
            const int TTL    = 10;

            // Action
            rssTtl.TTL = TTL;

            // Assert
            Assert.AreEqual(TTL.ToString(), rssTtl.TTLString);
        }
Пример #13
0
        public void SetTtl_ConvertToString_String()
        {
            // Arrange
            RssTtl    rssTtl = new RssTtl();
            const int TTL    = 10;

            // Action
            rssTtl.TTLString = TTL.ToString();

            // Assert
            Assert.Equal(TTL, rssTtl.TTL);
        }
Пример #14
0
        public void Must_be_Equatable()
        {
            var a = new TTL(1200);
            var b = new TTL(1200);
            var c = new TTL(3600);

            a.Equals(a).Should().BeTrue();
            a.Equals(b).Should().BeTrue();
            b.Equals(a).Should().BeTrue();
            a.Equals(c).Should().BeFalse();
            c.Equals(a).Should().BeFalse();
        }
Пример #15
0
        public override byte[] ToBytes()
        {
            System.Diagnostics.Debug.WriteLine("  <<TLDecryptedMessage45.ToBytes random_id={0} ttl={1} message={2} media=[{3}]", RandomId, TTL, Message, Media);

            return(TLUtils.Combine(
                       TLUtils.SignatureToBytes(Signature),
                       Flags.ToBytes(),
                       RandomId.ToBytes(),
                       TTL.ToBytes(),
                       Message.ToBytes(),
                       ToBytes(Media, Flags, (int)MessageFlags.Media),
                       ToBytes(Entities, Flags, (int)MessageFlags.Entities),
                       ToBytes(ViaBotName, Flags, (int)MessageFlags.ViaBotId),
                       ToBytes(ReplyToRandomMsgId, Flags, (int)MessageFlags.ReplyToMsgId)));
        }
Пример #16
0
#pragma warning disable S1541 // Methods and properties should not be too complex
        public override int GetHashCode()
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            unchecked
            {
                var hashCode = base.GetHashCode();
                hashCode = (hashCode * 397) ^ (Result != null ? Result.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ SourceId.GetHashCode();
                hashCode = (hashCode * 397) ^ (Key != null ? Key.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Response != null ? Response.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (TTL != null ? TTL.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Connection != null ? Connection.GetHashCode() : 0);
                return(hashCode);
            }
        }
Пример #17
0
        public void Must_implement_comparison_operators()
        {
            var a = new TTL(1200);
            var b = new TTL(1200);

            (a == b).Should().BeTrue();
            (b == a).Should().BeTrue();

            (a != b).Should().BeFalse();
            (b != a).Should().BeFalse();

            (a >= b).Should().BeTrue();
            (b >= a).Should().BeTrue();

            (a <= b).Should().BeTrue();
            (b <= a).Should().BeTrue();

            (a > b).Should().BeFalse();
            (b > a).Should().BeFalse();

            (a < b).Should().BeFalse();
            (b < a).Should().BeFalse();

            b = new TTL(2400);

            (a == b).Should().BeFalse();
            (b == a).Should().BeFalse();

            (a != b).Should().BeTrue();
            (b != a).Should().BeTrue();

            (a >= b).Should().BeFalse();
            (b >= a).Should().BeTrue();

            (a <= b).Should().BeTrue();
            (b <= a).Should().BeFalse();

            (a > b).Should().BeFalse();
            (b > a).Should().BeTrue();

            (a < b).Should().BeTrue();
            (b < a).Should().BeFalse();
        }
Пример #18
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            var go = new GameObject("Grenade Out!");
            go.transform.position = transform.position + transform.right * 0.5f + transform.up * 0.5f;

            var visible = Instantiate <GameObject>(ProjectilePrefab, go.transform);
            foreach (var collider in new List <Collider>(visible.GetComponentsInChildren <Collider>()))
            {
                Destroy(collider);
            }

            // initial toss motion
            Vector3 tossVelocity = transform.forward * RelativeMotion.z + transform.up * RelativeMotion.y;
            // maybe add in user motion
            if (GetTosserMotion != null)
            {
                tossVelocity += GetTosserMotion();
            }
            // parabolic motion
            Ballistic3D.Attach(go, tossVelocity, GravityForThisWeapon);

            // this gets called when the RaycastSensor notices you hit something
            System.Action <Vector3> OnHit = (pos) => {
                Instantiate <GameObject>(ExplosionPrefab, pos, Quaternion.identity);

                damager.ApplyDamage(pos, DamageConfig);

                Destroy(go);
            };
            RaycastSensor.Attach(go, OnHit);

            // death sentence
            TTL.Attach(go, 10.0f);

            // make it tumble
            var spinner = go.AddComponent <SpinMeAllAxes>();
            spinner.RateOfSpin = Random.onUnitSphere * Random.Range(1000, 2000);
        }
    }
Пример #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TTL != 0)
            {
                hash ^= TTL.GetHashCode();
            }
            if (Epoch != 0UL)
            {
                hash ^= Epoch.GetHashCode();
            }
            if (Version != 0)
            {
                hash ^= Version.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ID != 0L)
            {
                hash ^= ID.GetHashCode();
            }
            if (TTL != 0L)
            {
                hash ^= TTL.GetHashCode();
            }
            if (RemainingTTL != 0L)
            {
                hash ^= RemainingTTL.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #21
0
        /// <summary>
        /// Converts the channel to a string
        /// </summary>
        /// <returns>The channel as a string</returns>
        public override string ToString()
        {
            StringBuilder ChannelString = new StringBuilder();

            ChannelString.Append("<channel>");
            ChannelString.Append("<title>").Append(Title).Append("</title>\r\n");
            ChannelString.Append("<link>").Append(Link).Append("</link>\r\n");
            ChannelString.Append("<atom:link xmlns:atom=\"http://www.w3.org/2005/Atom\" rel=\"self\" href=\"").Append(Link).Append("\" type=\"application/rss+xml\" />");

            ChannelString.Append("<description><![CDATA[").Append(Description).Append("]]></description>\r\n");
            ChannelString.Append("<language>").Append(Language).Append("</language>\r\n");
            ChannelString.Append("<copyright>").Append(Copyright).Append("</copyright>\r\n");
            ChannelString.Append("<webMaster>").Append(WebMaster).Append("</webMaster>\r\n");
            ChannelString.Append("<pubDate>").Append(PubDate.ToString("Ddd, dd MMM yyyy HH':'mm':'ss", CultureInfo.InvariantCulture)).Append("</pubDate>\r\n");
            ChannelString.Append("<itunes:explicit>").Append((Explicit ? "yes" : "no")).Append("</itunes:explicit>");
            ChannelString.Append("<itunes:subtitle>").Append(Title).Append("</itunes:subtitle>");
            ChannelString.Append("<itunes:summary><![CDATA[").Append(Description).Append("]]></itunes:summary>");

            foreach (string Category in Categories)
            {
                ChannelString.Append("<category>").Append(Category).Append("</category>\r\n");
                ChannelString.Append("<itunes:category text=\"").Append(Category).Append("\" />\r\n");
            }
            ChannelString.Append("<docs>").Append(Docs).Append("</docs>\r\n");
            ChannelString.Append("<ttl>").Append(TTL.ToString(CultureInfo.InvariantCulture)).Append("</ttl>\r\n");
            if (!string.IsNullOrEmpty(ImageUrl))
            {
                ChannelString.Append("<image><url>").Append(ImageUrl).Append("</url>\r\n<title>").Append(Title).Append("</title>\r\n<link>").Append(Link).Append("</link>\r\n</image>\r\n");
            }
            foreach (Item CurrentItem in Items)
            {
                ChannelString.Append(CurrentItem.ToString());
            }
            ChannelString.Append("</channel>\r\n");
            return(ChannelString.ToString());
        }
Пример #22
0
 public override IEnumerable <StateVariable> GetState()
 {
     return(new[] {
         new StateVariable
         {
             Name = "Key",
             Value = Key,
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = "TTL",
             Value = TTL.ToString(),
             Type = StateVariable.StateType.Input
         },
         new StateVariable
         {
             Name = "Result",
             Value = Result,
             Type = StateVariable.StateType.Output
         }
         ,
         new StateVariable
         {
             Name = "Response",
             Value = Response,
             Type = StateVariable.StateType.Output
         },
         new StateVariable
         {
             Name = "SourceId",
             Value = SourceId.ToString(),
             Type = StateVariable.StateType.Input
         }
     });
 }
Пример #23
0
        protected override Dictionary <string, string> ExtQueryParameters()
        {
            var ret = new Dictionary <string, string>()
            {
                ["RecordId"] = RecordId,
                ["RR"]       = RR,
                ["Type"]     = Type,
                ["Value"]    = Value,
            };

            if (TTL > 0)
            {
                ret["TTL"] = TTL.ToString();
            }
            //if (Priority > 0 && Priority < 500)
            //{
            //    ret["Priority"] = Priority.ToString();
            //}
            if (!string.IsNullOrWhiteSpace(Line))
            {
                ret["Line"] = Line;
            }
            return(ret);
        }
Пример #24
0
        static void Init()
        {
            Console.Clear();
            cmdText.printLogo();
            cmdText.PrintCommand("1", "SWITCH TTL TO 64 (MOBILE VALUE)");
            cmdText.PrintCommand("2", "SWITCH TTL TO 128(PC DEFAULT TTL)");
            cmdText.PrintCommand("3", "EXIT");
            //На заметку: параметр true не позволяет печатать текст во время регистрации нажатий
            ConsoleKeyInfo answer = Console.ReadKey(true);

            while (answer.KeyChar != 49 && answer.KeyChar != 50 && answer.KeyChar != 51)
            {
                answer = Console.ReadKey(true);
            }

            //1
            if (answer.KeyChar == 49)
            {
                TTL.SetMobileTTL();
                cmdText.Done();
                RebootRequirement();
            }
            //2
            else if (answer.KeyChar == 50)
            {
                TTL.SetToDefault();
                cmdText.Done();
                RebootRequirement();
            }
            //3
            else if (answer.KeyChar == 51)
            {
                Environment.Exit(0);
            }
            ;
        }
Пример #25
0
        public void Update(GameTime gameTime)
        {
            EmissionPoint = EmitterLocation;
            TTL.Update(gameTime.ElapsedGameTime);
            if (!Started)
            {
                Started = true;
                OnStart(this);
            }
            if (!TTL.IsComplete && Particles.Count < Max)
            {
                Emit(gameTime);
            }

            foreach (var m in Modifiers.Where(p => !p.IsPattern))
            {
                m.Update(gameTime, this);
            }

            for (var particle = 0; particle < Particles.Count; particle++)
            {
                Particles[particle].Update(gameTime);
                if (!Particles[particle].TTL.IsComplete)
                {
                    continue;
                }
                Particles.RemoveAt(particle);
                particle--;
            }
            if (Ended || !TTL.IsComplete)
            {
                return;
            }
            Ended = true;
            OnEnd(this);
        }
Пример #26
0
        public void Must_allow_zero()
        {
            Int32 i = new TTL(0);

            i.Should().Be(0);
        }
Пример #27
0
        public void Must_be_constructable_from_Int32()
        {
            var a = new TTL(3600);

            a.Should().Be(3600);
        }
Пример #28
0
        public void Must_be_assignable_to_Int32()
        {
            Int32 i = new TTL(1200);

            i.Should().Be(1200);
        }
Пример #29
0
        public void Must_be_assignable_from_Int32()
        {
            TTL a = 1200;

            a.Should().Be(1200);
        }
Пример #30
0
        public void Must_be_assignable_to_String()
        {
            String s = new TTL(1200);

            s.Should().Be("1200");
        }