Example #1
0
        protected TypedFormatter(PropertyInfo property)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            if (property.DeclaringType == null)
            {
                throw new InvalidOperationException();
            }

            var parameter = Expression.Parameter(typeof(object));
            var get       = Expression.Property(Expression.Convert(parameter, property.DeclaringType), property);

            Getter = Expression.Lambda <Func <object, T> >(get, parameter).Compile();
            Name   = InfluxName.Escape(property.Name);
        }
        public void JustReturnsBytes()
        {
            var actual = InfluxName.Escape("Foo");

            Assert.Equal(Encoding.UTF8.GetBytes("Foo"), actual);
        }