public JavascriptConversionContext(
     [NotNull] Expression node,
     [NotNull] ExpressionVisitor visitor,
     [NotNull] JavascriptWriter result,
     [NotNull] JavascriptCompilationOptions options)
 {
     if (node == null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     if (visitor == null)
     {
         throw new ArgumentNullException(nameof(visitor));
     }
     if (result == null)
     {
         throw new ArgumentNullException(nameof(result));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     this.result  = result;
     this.Visitor = visitor;
     this.Options = options;
     this.node    = node;
 }
        private bool WriteSingleEnumItem(
            JavascriptConversionContext context,
            JavascriptWriter writer,
            long numValue,
            object enumValue,
            bool inStringAlready)
        {
            if ((this.opts & EnumOptions.UseStrings) != 0)
            {
                if (inStringAlready)
                {
                    if ((this.opts & EnumOptions.UseNumbers) != 0)
                    {
                        writer.WriteLiteralStringContent(numValue.ToString());
                    }
                    else
                    {
                        var str = enumValue.ToString();
                        if (numValue == 0 && str == "0")
                        {
                            writer.WriteLiteralStringContent("");
                        }
                        else
                        {
                            writer.WriteLiteralStringContent(str);
                        }
                    }
                    return(true);
                }

                using (writer.Operation(JavascriptOperationTypes.Literal))
                {
                    if ((this.opts & EnumOptions.UseNumbers) != 0)
                    {
                        writer.WriteLiteral(numValue.ToString());
                    }
                    else
                    {
                        var str = enumValue.ToString();
                        if (numValue == 0 && str == "0")
                        {
                            writer.WriteLiteral("");
                        }
                        else
                        {
                            writer.WriteLiteral(str);
                        }
                    }
                    return(true);
                }
            }

            if ((this.opts & EnumOptions.UseNumbers) != 0)
            {
                using (writer.Operation(JavascriptOperationTypes.Literal))
                    writer.WriteLiteral(numValue);
                return(true);
            }

            if ((this.opts & EnumOptions.UseStaticFields) != 0)
            {
                using (writer.Operation(JavascriptOperationTypes.IndexerProperty))
                    context.Write(enumValue.GetType().Name).WriteAccessor(enumValue.ToString());
                return(true);
            }

            return(false);
        }