Exemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Shorthand.Length != 0)
            {
                hash ^= Shorthand.GetHashCode();
            }
            if (DefaultValue.Length != 0)
            {
                hash ^= DefaultValue.GetHashCode();
            }
            if (Usage.Length != 0)
            {
                hash ^= Usage.GetHashCode();
            }
            if (Required != false)
            {
                hash ^= Required.GetHashCode();
            }
            if (IncludeNested != false)
            {
                hash ^= IncludeNested.GetHashCode();
            }
            return(hash);
        }
 private static void AssertResult(Regex result, Shorthand expectedShorthand)
 {
     Assert.That(result.Children.Count, Is.EqualTo(1));
     Assert.That(result.Children[0], Is.InstanceOf<CharacterClassShorthand>());
     var characterClassShorthand = (CharacterClassShorthand) result.Children[0];
     Assert.That(characterClassShorthand.Shorthand, Is.EqualTo(expectedShorthand));
 }
        private static void AssertResult(Regex result, Shorthand expectedShorthand)
        {
            Assert.That(result.Children.Count, Is.EqualTo(1));
            Assert.That(result.Children[0], Is.InstanceOf <CharacterClassShorthand>());
            var characterClassShorthand = (CharacterClassShorthand)result.Children[0];

            Assert.That(characterClassShorthand.Shorthand, Is.EqualTo(expectedShorthand));
        }
Exemplo n.º 4
0
        public async Task <string> Post([FromBody] Shorthand data)
        {
            data.DateAdded = DateTime.Now;
            data.URL       = Guid.NewGuid()
                             .ToString("n")
                             .Substring(0, 5);

            var aMonthAgo = DateTime.Now.AddMonths(-1);
            var toRemove  = await this.context.Shorthands
                            .Where(x => x.DateAdded < aMonthAgo)
                            .ToListAsync();

            this.context.RemoveRange(toRemove);
            this.context.Add <Shorthand>(data);
            await this.context.SaveChangesAsync();

            return(data.URL);
        }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() * 71
            + Shorthand.GetHashCode() * 73);
 }