Exemple #1
0
 public string GetTypeName(EnumType tst)
 {
     return tst.ClrType.Name;
 }
Exemple #2
0
 private string GetPropertyComment(EnumType p)
 {
     return null;
 }
Exemple #3
0
 private static string NormalizeName(EnumType t)
 {
     return t.Module + "." + t.ClrType.Name;
 }
        private void Render(IndentedStringBuilder sb, EnumType type)
        {
            sb.AppendLine("export enum {0} {{", type.ClrType.Name);
              sb.IncreaseIndentation();

              var values = Enum.GetValues(type.ClrType);
              var names = Enum.GetNames(type.ClrType);

              int i = 0;

              foreach (var val in values)
              {
            var name = names[i];
            i++;

            sb.AppendLine("{0} = {1},", name, Convert.ChangeType(val, typeof(int)));
              }

              sb.DecreaseIndentation();
              sb.AppendLine("}}");
              sb.AppendLine("");
        }
Exemple #5
0
        private TypeScriptType ProcessTypeScriptType(Type t, EnumType tst)
        {
            TypeScriptType processedType;

              if (!_processedTypes.TryGetValue(tst.ClrType, out processedType))
              {
            processedType = tst;

            _processedTypes.Add(tst.ClrType, processedType);

            tst.Module = _options.ModuleNameGenerator(t);
              }

              return processedType;
        }
Exemple #6
0
        private TypeScriptType GetTypeScriptType(Type type)
        {
            TypeScriptType tst;

              if (TypeHelper.Is(type, typeof(string)))
              {
            tst = new StringType();
              }
              else if (TypeHelper.Is(type, typeof(bool)))
              {
            tst = new BooleanType();
              }
              else if (TypeHelper.Is(type, typeof(int),
                                        typeof(decimal),
                                        typeof(double),
                                        typeof(long),
                                        typeof(float),
                                        typeof(short),
                                        typeof(byte),
                                        typeof(uint),
                                        typeof(ushort),
                                        typeof(ulong),
                                        typeof(sbyte)
                                        ))
              {
            tst = new NumberType();
              }
              else if (TypeHelper.Is(type, typeof(DateTime)))
              {
            tst = new DateTimeType();
              }
              else if (TypeHelper.Is(type, typeof(TimeSpan)))
              {
            tst = new TimeSpanType();
              }
              else if (type.IsGenericParameter)
              {
            tst = new GenericTypeParameter();
              }
              else if (TypeHelper.IsDictionary(type))
              {
            tst = new DictionaryType();
              }
              else if (TypeHelper.IsEnumerable(type))
              {
            tst = new ArrayType();
              }
              else if (TypeHelper.IsEnum(type))
              {
            tst = new EnumType();
              }
              else
              {
            var processType = _options.TypeFilter(type);

            if (processType)
            {
              if (type.IsInterface)
              {
            tst = new InterfaceType(type);
              }
              else
              {
            tst = new CustomType(type);
              }
            }
            else
            {
              tst = new AnyType();
            }
              }

              if (TypeHelper.IsNullableValueType(type))
              {
            ((ValueType)tst).IsNullable = true;
            type = Nullable.GetUnderlyingType(type);
              }

              tst.ClrType = type;

              return tst;
        }
Exemple #7
0
 public string GetModuleName(EnumType type)
 {
     return type.Module + ".";
 }