Example #1
0
        public void ToString_(string expectedValue, string expectedType, string value)
        {
            var typedValue = new TypedValue(value);
            var str        = typedValue.ToString();

            Assert.Equal($"{expectedValue} : {expectedType}", str);
        }
Example #2
0
        public override string ToString()
        {
            if (_memberInfo is null)
            {
                return(base.ToString() !);
            }

            return($"{MemberInfo.Name} = {TypedValue.ToString(ArgumentType != typeof(object))}");
        }
        public override string ToString()
        {
            if (m_memberInfo == null)
            {
                return(base.ToString());
            }

            return(string.Format("{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))));
        }
Example #4
0
        [Test] public void DuplicateIsInvoked()
        {
            RuntimeMember method = GetMethod("duplicate", 1);

            method.Invoke(new object[] { "stuff" });

            method = GetMethod("duplicate", 0);
            TypedValue result = method.Invoke(new object[] {});

            Assert.AreEqual("stuff", result.ToString());
        }
        public void TestTypedValue()
        {
            var tv1 = new TypedValue("hello");
            var tv2 = new TypedValue("hello");
            var tv3 = new TypedValue("bye");

            Assert.Equal(typeof(string), tv1.TypeDescriptor);
            Assert.Equal("TypedValue: 'hello' of [System.String]", tv1.ToString());
            Assert.Equal(tv1, tv2);
            Assert.Equal(tv2, tv1);
            Assert.NotEqual(tv1, tv3);
            Assert.NotEqual(tv2, tv3);
            Assert.NotEqual(tv3, tv1);
            Assert.NotEqual(tv3, tv2);
            Assert.Equal(tv1.GetHashCode(), tv2.GetHashCode());
            Assert.NotEqual(tv1.GetHashCode(), tv3.GetHashCode());
            Assert.NotEqual(tv2.GetHashCode(), tv3.GetHashCode());
        }
 public override string ToString()
 {
     if (_attributeType == null)
     {
         return(base.ToString()); // Someone called ToString() on default(CustomAttributeNamedArgument)
     }
     try
     {
         bool typed;
         if (_lazyMemberInfo == null)
         {
             // If we haven't resolved the memberName into a MemberInfo yet, don't do so just for ToString()'s sake (it can trigger a MissingMetadataException.)
             // Just use the fully type-qualified format by fiat.
             typed = true;
         }
         else
         {
             Type argumentType = IsField ? ((FieldInfo)_lazyMemberInfo).FieldType : ((PropertyInfo)_lazyMemberInfo).PropertyType;
             typed = argumentType != typeof(object);
         }
         return(string.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberName, TypedValue.ToString(typed)));
     }
     catch (MissingMetadataException)
     {
         return(base.ToString()); // Failsafe. Code inside "try" should still strive to avoid trigging a MissingMetadataException as caught exceptions are annoying when debugging.
     }
 }
Example #7
0
 public override string ToString() => TypedValue.ToString(CultureInfo.InvariantCulture);
Example #8
0
 public override string ToString() => $"{{\"type\":\"{TypedValue.GetType().Name}\",\"intValue\":{Convert.ToInt32(TypedValue)},\"name\":\"{TypedValue.ToString()}\",\"displayName\":\"{TypedValue.GetDescription()}\"}}";
Example #9
0
 public string GetCreationCode() => $"new Enum('{TypedValue.GetType().Name}',{Convert.ToInt32(TypedValue)},'{TypedValue.ToString()}','{TypedValue.GetDescription()}')";
Example #10
0
 public override string ToString() => TypedValue.ToString();
Example #11
0
 public string GetCreationCode() => TypedValue.ToString();
Example #12
0
 public string GetCreationCode() => TypedValue.ToString(CultureInfo.InvariantCulture);
Example #13
0
 public override string ToString() =>
 TypedValue?.ToString() ?? "<null>";
 // Optionally override TypedValue
 public override void Deal()
 {
     Console.WriteLine(TypedValue.ToString("#0.000"));
 }