public void ToString_(string expectedValue, string expectedType, string value) { var typedValue = new TypedValue(value); var str = typedValue.ToString(); Assert.Equal($"{expectedValue} : {expectedType}", str); }
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)))); }
[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. } }
public override string ToString() => TypedValue.ToString(CultureInfo.InvariantCulture);
public override string ToString() => $"{{\"type\":\"{TypedValue.GetType().Name}\",\"intValue\":{Convert.ToInt32(TypedValue)},\"name\":\"{TypedValue.ToString()}\",\"displayName\":\"{TypedValue.GetDescription()}\"}}";
public string GetCreationCode() => $"new Enum('{TypedValue.GetType().Name}',{Convert.ToInt32(TypedValue)},'{TypedValue.ToString()}','{TypedValue.GetDescription()}')";
public override string ToString() => TypedValue.ToString();
public string GetCreationCode() => TypedValue.ToString();
public string GetCreationCode() => TypedValue.ToString(CultureInfo.InvariantCulture);
public override string ToString() => TypedValue?.ToString() ?? "<null>";
// Optionally override TypedValue public override void Deal() { Console.WriteLine(TypedValue.ToString("#0.000")); }