Exemple #1
0
 /// <summary>
 /// Append the command.
 /// </summary>
 public override void Build(JsBuilder builder)
 {
     builder.String.Append(Js.Var);
     Variable.Build(builder);
     builder.String.Append(Js.Equal);
     Variable.Value.Build(builder);
 }
Exemple #2
0
        /// <summary>
        /// Build a class initialization.
        /// </summary>
        public override void Build(JsBuilder builder)
        {
            // ensure the prototype is built
            builder.Add(Prototype);

            builder.String.Append("new ");
            builder.String.Append(Prototype.Name);
            builder.String.Append(Chars.BracketOpen);
            bool first = true;

            foreach (var parameter in _parameters)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    builder.String.Append(Chars.Comma);
                }
                parameter.Build(builder);
            }
            builder.String.Append(Chars.BracketClose);
            builder.String.Append(Chars.SemiColon);
            builder.String.Append(Chars.NewLine);
        }
Exemple #3
0
 public override void Build(JsBuilder builder)
 {
     if (string.IsNullOrEmpty(Name))
     {
         Name = builder.NextName;
     }
     builder.String.Append(Name);
 }
Exemple #4
0
        /// <summary>
        /// Build the javascript method.
        /// </summary>
        public override void Build(JsBuilder builder)
        {
            builder.String.Append(Js.Function);

            bool first = true;

            // iterate the parameters
            foreach (var parameter in Parameters)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    builder.String.Append(Chars.Comma);
                }
                builder.String.Append(parameter.Key);
            }
            builder.String.Append(Chars.BracketClose);
            builder.String.Append(Chars.BraceOpen);

            // iterate the parameters
            foreach (var parameter in Parameters)
            {
                if (parameter.Value == null)
                {
                    continue;
                }
                builder.String.Append(parameter.Key);
                builder.String.Append(Js.Equal);
                builder.String.Append(parameter.Key);
                builder.String.Append(Js.Or);
                parameter.Value.Build(builder);
                builder.String.Append(Chars.SemiColon);
            }

            // iterate commands within the function
            foreach (var command in Commands)
            {
                command.Build(builder);
            }

            builder.String.Append(Chars.BraceClose);
            builder.String.Append(Chars.SemiColon);
        }
Exemple #5
0
        /// <summary>
        /// Append the command.
        /// </summary>
        public override void Build(JsBuilder builder)
        {
            builder.String.Append("new ");
            builder.String.Append(Class.Prototype.Name);
            builder.String.Append(Chars.BracketOpen);
            bool first = true;

            foreach (var parameter in Parameters)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    builder.String.Append(Chars.Comma);
                }
                parameter.Build(builder);
            }
            builder.String.Append(Chars.BracketClose);
            builder.String.Append(Chars.SemiColon);
        }
Exemple #6
0
        /// <summary>
        /// Build the javascript object.
        /// </summary>
        public void Build(JsBuilder builder)
        {
            bool first = true;

            // no constructors? no problem
            if (Constructors.Count == 0)
            {
                builder.String.Append(Js.Var);
                builder.String.Append(Name);
                builder.String.Append(Js.Equal);
                builder.String.Append(Js.Function);
                builder.String.Append(Chars.BracketClose);
                builder.String.Append(Chars.BraceOpen);
                builder.String.Append(Chars.BraceClose);
                builder.String.Append(Chars.SemiColon);
            }

            // iterate constructors
            foreach (var constructor in Constructors)
            {
                builder.String.Append(Js.Var);
                builder.String.Append(Name);
                builder.String.Append(Js.Equal);
                builder.String.Append(Js.Function);

                first = true;

                // iterate the parameters
                foreach (var parameter in constructor)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        builder.String.Append(Chars.Comma);
                    }
                    builder.String.Append(parameter.Key);
                }
                builder.String.Append(Chars.BracketClose);
                builder.String.Append(Chars.BraceOpen);

                // iterate the passed parameters
                foreach (var parameter in constructor)
                {
                    builder.String.Append(Js.This);
                    builder.String.Append(parameter.Key);
                    builder.String.Append(Js.Equal);
                    if (parameter.Value == null)
                    {
                        builder.String.Append(parameter.Key);
                    }
                    else
                    {
                        builder.String.Append(parameter.Key);
                        builder.String.Append(Js.Or);
                        parameter.Value.Build(builder);
                    }
                    builder.String.Append(Chars.SemiColon);
                }

                // iterate static properties
                foreach (var property in Properties)
                {
                    builder.String.Append(property.Key);
                    builder.String.Append(Js.Equal);
                    if (property.Value == null)
                    {
                        builder.String.Append(Js.Null);
                    }
                    else
                    {
                        property.Value.Build(builder);
                    }
                    builder.String.Append(Chars.SemiColon);
                }

                if (_constructor != null)
                {
                    _constructor.Build(builder);
                }

                builder.String.Append(Chars.BraceClose);
                builder.String.Append(Chars.SemiColon);
            }

            // iterate class functions
            foreach (var method in Methods)
            {
                builder.String.Append(Name);
                builder.String.Append(Js.PrototypeReference);
                builder.String.Append(Chars.Stop);
                builder.String.Append(method.Key);
                builder.String.Append(Js.Equal);
                method.Value.Build(builder);
            }
        }
Exemple #7
0
 /// <summary>
 /// Append the command.
 /// </summary>
 public override void Build(JsBuilder builder)
 {
     builder.String.Append(Javascript);
 }
Exemple #8
0
 /// <summary>
 /// Build the javascript.
 /// </summary>
 public override void Build(JsBuilder builder)
 {
     builder.String.Append(Value);
 }
Exemple #9
0
 public override void Build(JsBuilder builder)
 {
     builder.String.Append(Chars.DoubleQuote);
     builder.String.Append(Value);
     builder.String.Append(Chars.DoubleQuote);
 }
Exemple #10
0
 /// <summary>
 /// Main method used to build javascript components.
 /// </summary>
 public abstract void Build(JsBuilder builder);