Exemplo n.º 1
0
        public virtual string WriteEnumValue(TsEnumValue tsEnumValue)
        {
            if (tsEnumValue.EnumValue != null)
            {
                return(tsEnumValue.Name + " = " + tsEnumValue.EnumValue);
            }

            return(tsEnumValue.Name);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void AppendEnumValueDoc(ScriptBuilder sb, TsEnumValue value)
 {
 }
Exemplo n.º 4
0
 public void AppendEnumValueDoc(ScriptBuilder sb, TsEnumValue value)
 {
     AppendMemberDoc(sb, value.Field);
 }
Exemplo n.º 5
0
 private static string GenerateContent(TsEnumValue enumValue)
 {
     return($"{enumValue.Name} = {enumValue.Value}");
 }
 public void AppendEnumValueDoc(IndentedStringBuilder sb, TsEnumValue value)
 {
 }
Exemplo n.º 7
0
 protected string GetEnumValue(TsEnumValue e)
 {
     return(ValueMode == EnumValueMode.Number ? e.Value : "\"" + e.Name + "\"");
 }
Exemplo n.º 8
0
 /// <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));
 }
Exemplo n.º 9
0
 /// <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 + "\"");
 }