private void LocalVariableImpl(Chunk chunk, Snippets name, Snippets type, Snippets value) { DeclareVariable(name); if (Snippets.IsNullOrEmpty(type) || String.Equals(type, "var")) { CodeIndent(chunk) .Write("Dim ") .WriteCode(name); } else { CodeIndent(chunk) .Write("Dim ") .WriteCode(name) .Write(" As ") .WriteCode(type); } if (!Snippets.IsNullOrEmpty(value)) { _source.Write(" = ").WriteCode(value); } _source.WriteLine(); CodeDefault(); }
protected override void Visit(ViewDataChunk chunk) { string key = chunk.Key; Snippets name = chunk.Name; Snippets snippets2 = chunk.Type ?? "object"; if (!this._globalSymbols.ContainsKey((string)name)) { this._globalSymbols.Add((string)name, null); } if (this._viewDataAdded.ContainsKey((string)name)) { if (this._viewDataAdded[(string)name] != (key + ":" + ((string)snippets2))) { throw new CompilerException(string.Format("The view data named {0} cannot be declared with different types '{1}' and '{2}'", name, snippets2, this._viewDataAdded[(string)name])); } } else { this._viewDataAdded.Add((string)name, key + ":" + ((string)snippets2)); this._source.Write("Public ReadOnly Property ").WriteCode(name).Write("() As ").WriteCode(snippets2).WriteLine().AddIndent().WriteLine("Get").AddIndent(); if (Snippets.IsNullOrEmpty(chunk.Default)) { this.CodeIndent(chunk).Write("Return CType(ViewData.Eval(\"").Write(key).Write("\"),").WriteCode(snippets2).WriteLine(")"); } else { this.CodeIndent(chunk).Write("Return CType(If(ViewData.Eval(\"").Write(key).Write("\"),").WriteCode(chunk.Default).Write("),").WriteCode(snippets2).WriteLine(")"); } this._source.RemoveIndent().WriteLine("End Get").RemoveIndent().WriteLine("End Property"); this.CodeDefault(); } }
protected override void Visit(ConditionalChunk chunk) { if (!Snippets.IsNullOrEmpty(chunk.Condition)) { Examine(chunk.Condition); } Accept(chunk.Body); }
protected override void Visit(ViewDataChunk chunk) { var key = chunk.Key; var name = chunk.Name; var type = chunk.Type ?? "object"; if (!_globalSymbols.ContainsKey(name)) { _globalSymbols.Add(name, null); } if (_viewDataAdded.ContainsKey(name)) { if (_viewDataAdded[name] != key + ":" + type) { throw new CompilerException( string.Format("The view data named {0} cannot be declared with different types '{1}' and '{2}'", name, type, _viewDataAdded[name])); } return; } _viewDataAdded.Add(name, key + ":" + type); //_source.WriteCode(type).Write(" ").WriteLine(name); _source .Write("Public ReadOnly Property ") .WriteCode(name) .Write("() As ") .WriteCode(type) .WriteLine().AddIndent() .WriteLine("Get").AddIndent(); if (Snippets.IsNullOrEmpty(chunk.Default)) { CodeIndent(chunk) .Write("Return CType(ViewData.Eval(\"") .Write(key) .Write("\"),") .WriteCode(type) .WriteLine(")"); } else { CodeIndent(chunk) .Write("Return CType(If(ViewData.Eval(\"") .Write(key) .Write("\"),") .WriteCode(chunk.Default) .Write("),") .WriteCode(type) .WriteLine(")"); } _source .RemoveIndent().WriteLine("End Get") .RemoveIndent().WriteLine("End Property"); CodeDefault(); }
protected override void Visit(ViewDataModelChunk chunk) { if (!Snippets.IsNullOrEmpty(chunk.TModelAlias)) { this._source.WriteCode(chunk.TModel).Write(" ").WriteCode(chunk.TModelAlias).WriteLine(); this.CodeIndent(chunk).WriteLine("{get {return ViewData.Model;}}"); this.CodeDefault(); } }
protected override void Visit(LocalVariableChunk chunk) { if (Snippets.IsNullOrEmpty(chunk.Value)) { this._source.Append("var ").Append((string)chunk.Name).AppendLine(" = null;"); } else { this._source.Append("var ").Append((string)chunk.Name).Append(" = ").Append((string)chunk.Value).AppendLine(";"); } }
protected override void Visit(LocalVariableChunk chunk) { this.DeclareVariable((string)chunk.Name); this.CodeIndent(chunk).WriteCode(chunk.Type).Write(" ").WriteCode(chunk.Name); if (!Snippets.IsNullOrEmpty(chunk.Value)) { this._source.Write(" = ").WriteCode(chunk.Value); } this._source.WriteLine(";"); this.CodeDefault(); }
protected override void Visit(ViewDataModelChunk chunk) { if (!Snippets.IsNullOrEmpty(chunk.TModelAlias)) { this._source.Write("Public ReadOnly Property ").WriteCode(chunk.TModelAlias).Write("() As ").WriteCode(chunk.TModel).WriteLine().AddIndent(); this._source.WriteLine("Get").AddIndent(); this._source.WriteLine("Return ViewData.Model"); this._source.RemoveIndent().WriteLine("End Get"); this._source.RemoveIndent().WriteLine("End Property"); this.CodeDefault(); } }
protected override void Visit(LocalVariableChunk chunk) { _variables.Declare(chunk.Name); var value = chunk.Value; if (Snippets.IsNullOrEmpty(value)) { value = "None"; } _source.Write(chunk.Name).Write("=").WriteLine(value); }
private void Examine(Snippets code) { if (!Snippets.IsNullOrEmpty(code)) { string str = code.ToString(); foreach (Entry entry in this._entries) { if (!entry.Detected && str.Contains(entry.Expression)) { entry.Detected = true; } } } }
protected override void Visit(AssignVariableChunk chunk) { if (!_variables.IsDeclared(chunk.Name)) { _variables.Declare(chunk.Name); } var value = chunk.Value; if (Snippets.IsNullOrEmpty(value)) { value = "nil"; } _source.Write(chunk.Name).Write("=").WriteLine(value); }
protected override void Visit(DefaultVariableChunk chunk) { if (IsVariableDeclared(chunk.Name)) { return; } DeclareVariable(chunk.Name); CodeIndent(chunk).WriteCode(chunk.Type).Write(" ").Write(chunk.Name); if (!Snippets.IsNullOrEmpty(chunk.Value)) { _source.Write(" = ").WriteCode(chunk.Value); } _source.WriteLine(";"); CodeDefault(); }
void Examine(Snippets code) { if (Snippets.IsNullOrEmpty(code)) { return; } var codeString = code.ToString(); foreach (var entry in _entries) { if (entry.Detected) { continue; } if (codeString.Contains(entry.Expression)) { entry.Detected = true; } } }
public override string ToString() { return(string.Format("UserID={0};SnippetsCount={1}", UserID, Snippets.IsNullOrEmpty() ? 0 : Snippets.Count)); }