public void VisitNode(JSEnumLiteral el) { // It's a literal so it could show up in the tree multiple times. if (el.CachedEnumType == null) { el.SetCachedType(GetCachedType(el.EnumType)); } VisitChildren(el); }
public JSExpression TranslateAttributeConstructorArgument( TypeSystem typeSystem, TypeReference context, CustomAttributeArgument ca ) { if (ca.Value == null) { return(JSLiteral.Null(ca.Type)); } else if (ca.Value is CustomAttributeArgument) { // :| return(TranslateAttributeConstructorArgument( typeSystem, context, (CustomAttributeArgument)ca.Value )); } else if (ca.Value is CustomAttributeArgument[]) { // Issue #141. WTF. var valueArray = (CustomAttributeArgument[])ca.Value; return(new JSArrayExpression(typeSystem.Object, (from value in valueArray select TranslateAttributeConstructorArgument( typeSystem, context, value )).ToArray() )); } else if (ca.Type.FullName == "System.Type") { return(new JSTypeOfExpression((TypeReference)ca.Value)); } else if (TypeUtil.IsEnum(ca.Type)) { var longValue = Convert.ToInt64(ca.Value); var result = JSEnumLiteral.TryCreate( _TypeInfoProvider.GetExisting(ca.Type), longValue ); if (result != null) { return(result); } else { return(JSLiteral.New(longValue)); } } else { try { return(JSLiteral.New(ca.Value as dynamic)); } catch (Exception) { throw new NotImplementedException(String.Format("Attribute arguments of type '{0}' are not implemented.", ca.Type.FullName)); } } }
public void VisitNode(JSEnumLiteral enm) { bool isFirst = true; if (enm.Names.Length == 1) { Output.Identifier(enm.EnumType, ReferenceContext); Output.Dot(); Output.Identifier(enm.Names[0]); } else { Output.Identifier(enm.EnumType, ReferenceContext); Output.Dot(); Output.Identifier("Flags"); Output.LPar(); Output.CommaSeparatedList( enm.Names, ReferenceContext, ListValueType.Primitive ); Output.RPar(); } }
public void VisitNode(JSEnumLiteral el) { el.SetCachedType(GetCachedType(el.EnumType)); VisitChildren(el); }