public virtual string WriteEnumValue(TsEnumValue tsEnumValue) { if (tsEnumValue.EnumValue != null) { return(tsEnumValue.Name + " = " + tsEnumValue.EnumValue); } return(tsEnumValue.Name); }
public void WhenCreateFromFieldInfo_NameAndValueIsSetToValuesProvidedByConfigurationProvider() { var enumType = typeof(EnumWithoutAttribute); var enumTypeInfo = enumType.GetTypeInfo(); var enumValueFieldInfo = enumTypeInfo.GetField("EnumValue1"); _configurationProviderMock .Setup(o => o.GetEnumValueConfiguration(It.Is <FieldInfo>(f => f == enumValueFieldInfo))) .Returns(new TsEnumValueConfiguration() { Name = "EnumValue1", Value = "1" }); var enumValue = TsEnumValue.CreateFrom(enumValueFieldInfo, _configurationProviderMock.Object); Assert.Equal("EnumValue1", enumValue.Name); Assert.Equal("1", enumValue.Value); }
public void AppendEnumValueDoc(ScriptBuilder sb, TsEnumValue value) { }
public void AppendEnumValueDoc(ScriptBuilder sb, TsEnumValue value) { AppendMemberDoc(sb, value.Field); }
private static string GenerateContent(TsEnumValue enumValue) { return($"{enumValue.Name} = {enumValue.Value}"); }
public void AppendEnumValueDoc(IndentedStringBuilder sb, TsEnumValue value) { }
protected string GetEnumValue(TsEnumValue e) { return(ValueMode == EnumValueMode.Number ? e.Value : "\"" + e.Name + "\""); }
/// <summary> /// Obtains the string value for the given enum field (<paramref name="enumValue"/>). /// The value obtained takes into account the <see cref="ValueMode"/> specified as the parameter in the constructor. /// </summary> /// <param name="enumGroup">The definitions for the type containing the enum field.</param> /// <param name="enumValue">The field/option of the enum that the values needs to be obtained from.</param> protected virtual string GetEnumValue(EnumGroup enumGroup, TsEnumValue enumValue) { return(GapEnumGenerator.GetEnumValue(ValueMode, enumValue)); }
/// <summary> /// Obtains the string value for the given enum field (<paramref name="enumValue"/>). /// The value obtained depends on the <paramref name="mode"/> specified. /// </summary> /// <param name="mode">The mode used to generate the enum value, it can be the enum field value or the enum field name.</param> /// <param name="enumValue">The field/option of the enum that the values needs to be obtained from.</param> protected static string GetEnumValue(EnumValueMode mode, TsEnumValue enumValue) { return(mode == EnumValueMode.Number ? enumValue.Value : "\"" + enumValue.Name + "\""); }