public void UsingNamespace(Snippets ns) { if (_namespaceAdded.ContainsKey(ns)) return; _namespaceAdded.Add(ns, null); _source.Append("using ").Append(ns).AppendLine(";"); }
public void UsingNamespace(Snippets ns) { if (_namespaceAdded.ContainsKey(ns)) return; _namespaceAdded.Add(ns, null); _source.Write("Imports ").WriteCode(ns).WriteLine(); }
protected override void Visit(ViewDataModelChunk chunk) { if (!Snippets.IsNullOrEmpty(TModel) && TModel != chunk.TModel) { throw new CompilerException(string.Format("Only one viewdata model can be declared. {0} != {1}", TModel, chunk.TModel)); } TModel = chunk.TModel; }
protected override void Visit(ViewDataModelChunk chunk) { if (_encounteredTModel && !string.Equals(TModel, chunk.TModel, StringComparison.Ordinal)) { throw new CompilerException(string.Format("Only one viewdata model can be declared. {0} != {1}", TModel, chunk.TModel)); } TModel = chunk.TModel; _encounteredTModel = true; }
internal static AttributeNode AddMethodCallingToAttributeValue(AttributeNode node, string method) { var snippets = new Snippets {new Snippet {Value = method + "("}}; snippets.AddRange(node.AsCodeInverted()); snippets.Add(new Snippet {Value= ")"}); var builder = new ExpressionBuilder(); builder.AppendExpression(snippets); var listNodes=new List<Node> {new ExpressionNode(snippets)}; return new AttributeNode(node.Name, listNodes); }
public ForEachInspector(Snippets code) { var terms = code.ToString().Split(' ', '\r', '\n', '\t').ToList(); var inIndex = terms.IndexOf("in"); if (inIndex >= 1) { Recognized = true; VariableType = string.Join(" ", terms.ToArray(), 0, inIndex - 1); VariableName = terms[inIndex - 1]; CollectionCode = string.Join(" ", terms.ToArray(), inIndex + 1, terms.Count - inIndex - 1); } }
public SourceBuilder AppendCode(IEnumerable<Snippet> snippets) { // compact snippets so vs language service doesn't have to var compacted = new Snippets(snippets.Count()); Snippet prior = null; foreach (var snippet in snippets) { if (prior != null && SnippetAreConnected(prior, snippet)) { prior = new Snippet { Value = prior.Value + snippet.Value, Begin = prior.Begin, End = snippet.End }; continue; } if (prior != null) compacted.Add(prior); prior = snippet; } if (prior != null) compacted.Add(prior); // write them out and keep mapping-to-spark source information foreach (var snippet in compacted) { if (snippet.Begin != null) { Mappings.Add(new SourceMapping { Source = snippet, OutputBegin = Source.Length, OutputEnd = Source.Length + snippet.Value.Length }); } Source.Append(snippet.Value); } return this; }
private int RunFile() { Debug.Assert(_engine != null); int result = 0; try { return(_engine.CreateScriptSourceFromFile(Options.RunFile).ExecuteProgram()); } catch (Exception e) { UnhandledException(Engine, e); result = 1; } finally { try { Snippets.SaveAndVerifyAssemblies(); } catch (Exception) { result = 1; } } return(result); }
public override Snippets Process(Chunk chunk, Snippets code) { if (code == null) { return(null); } var result = _grammar.ReformatCode(new Position(new SourceContext(code.ToString()))); if (result == null) { return(code); } if (result.Rest.PotentialLength() == 0) { return(result.Value); } return(result.Value + result.Rest.Peek(result.Rest.PotentialLength())); }
public TypeInspector(Snippets dataDeclaration) { var decl = dataDeclaration.ToString().Trim(); var lastSpace = decl.LastIndexOfAny(new[] { ' ', '\t', '\r', '\n' }); if (lastSpace < 0) { Type = dataDeclaration; return; } Name = decl.Substring(lastSpace + 1); if (!Name.ToString().ToCharArray().All(ch => char.IsLetterOrDigit(ch) || ch == '_' || ch == '@')) { Name = null; Type = dataDeclaration; return; } Type = decl.Substring(0, lastSpace).Trim(); }
public static Snippets AsCode(this AttributeNode attr) { //TODO: recapture original position to get correct files/offsets in the result var position = new Position(new SourceContext(attr.Value)); var result = _grammar.Expression(position); var unparsedLength = result.Rest.PotentialLength(); if (unparsedLength == 0) return result.Value; var snippets = new Snippets(result.Value); snippets.Add(new Snippet { Value = result.Rest.Peek(unparsedLength), Begin = result.Rest, End = result.Rest.Advance(unparsedLength) }); return snippets; }
public override Snippets ParseFragment(Position begin, Position end) { var result = _grammar.Expression(begin.Constrain(end)); var unparsedLength = result.Rest.PotentialLength(); if (unparsedLength == 0) { return(result.Value); } var snippets = new Snippets(result.Value); snippets.Add(new Snippet { Value = result.Rest.Peek(unparsedLength), Begin = result.Rest, End = result.Rest.Advance(unparsedLength) }); return(snippets); }
protected virtual async void EditOnTryMudBlazor() { // We use a separator that wont be in code so we can send 2 files later var codeFiles = "__Main.razor" + (char)31 + Snippets.GetCode(Code); // Add dialogs for dialog examples if (Code.StartsWith("Dialog")) { var regex = new Regex(@"\Show<(Dialog.*?_Dialog)\>"); var dialogCodeName = regex.Match(codeFiles).Groups[1].Value; if (dialogCodeName != string.Empty) { var dialogCodeFile = dialogCodeName + ".razor" + (char)31 + Snippets.GetCode(dialogCodeName); codeFiles = codeFiles + (char)31 + dialogCodeFile; } } // Data models if (codeFiles.Contains("MudBlazor.Examples.Data.Models")) { if (Regex.Match(codeFiles, @"\bElement\b").Success) { var elementCodeFile = "Element.cs" + (char)31 + Snippets.GetCode("Element"); codeFiles = codeFiles + (char)31 + elementCodeFile; } if (Regex.Match(codeFiles, @"\bServer\b").Success) { var serverCodeFile = "Server.cs" + (char)31 + Snippets.GetCode("Server"); codeFiles = codeFiles + (char)31 + serverCodeFile; } } var codeFileEncoded = codeFiles.ToCompressedEncodedUrl(); // var tryMudBlazorLocation = "https://localhost:5001/"; var tryMudBlazorLocation = "https://try.mudblazor.com/"; var url = $"{tryMudBlazorLocation}snippet/{codeFileEncoded}"; await JsApiService.OpenInNewTabAsync(url); }
private static void InitializeDomain() { if (_saveToAssemblies) { string _dumpDir = Path.Combine(Path.GetTempPath(), "RubyTests"); if (Directory.Exists(_dumpDir)) { Array.ForEach(Directory.GetFiles(_dumpDir), delegate(string file) { try { File.Delete(Path.Combine(_dumpDir, file)); } catch { /* nop */ } }); } else { Directory.CreateDirectory(_dumpDir); } Console.WriteLine("Generating binaries to {0}", _dumpDir); Snippets.SetSaveAssemblies(true, _dumpDir); } }
public TypeInspector(Snippets dataDeclaration) { var decl = dataDeclaration.ToString().Trim(); var lastSpace = decl.LastIndexOfAny(new[] { ' ', '\t', '\r', '\n' }); if (lastSpace < 0) { Type = dataDeclaration; return; } Name = decl.Substring(lastSpace + 1); if (!Name.ToString().ToCharArray().All(ch => char.IsLetterOrDigit(ch) || ch == '_' || ch == '@')) { Name = null; Type = dataDeclaration; return; } Type = decl.Substring(0, lastSpace).Trim(); }
private void RunTestCase(TestCase /*!*/ testCase) { _testRuntime = new TestRuntime(this, testCase); if (_verbose) { Console.WriteLine("Executing {0}", testCase.Name); } else { Console.Write('.'); } try { testCase.TestMethod(); } catch (Exception e) { PrintTestCaseFailed(); _unexpectedExceptions.Add(new MutableTuple <string, Exception>(testCase.Name, e)); } finally { Snippets.SaveAndVerifyAssemblies(); } }
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; } } }
/// <summary> /// This is the method used to execute Jupyter "normal" cells. In this case, a normal /// cell is expected to have a Q# snippet, which gets compiled and we return the name of /// the operations found. These operations are then available for simulation and estimate. /// </summary> public override ExecutionResult ExecuteMundane(string input, IChannel channel) { channel = channel.WithNewLines(); try { var code = Snippets.Compile(input); foreach (var m in code.warnings) { channel.Stdout(m); } // Gets the names of all the operations found for this snippet var opsNames = code.Elements? .Where(e => e.IsQsCallable) .Select(e => e.ToFullName().WithoutNamespace(IQSharp.Snippets.SNIPPETS_NAMESPACE)) .OrderBy(o => o) .ToArray(); return(opsNames.ToExecutionResult()); } catch (CompilationErrorsException c) { foreach (var m in c.Errors) { channel.Stderr(m); } return(ExecuteStatus.Error.ToExecutionResult()); } catch (Exception e) { channel.Stderr(e.Message); return(ExecuteStatus.Error.ToExecutionResult()); } }
public void CompressedUrlRoundtripTest() { var snippet = Snippets.GetCode("TableServerSidePaginateExample"); string urlEncodedBase64compressedCode, base64compressedCode, snippet1; byte[] bytes; // compression using (var uncompressed = new MemoryStream(Encoding.UTF8.GetBytes(snippet))) using (var compressed = new MemoryStream()) using (var compressor = new DeflateStream(compressed, CompressionMode.Compress)) { uncompressed.CopyTo(compressor); compressor.Close(); bytes = compressed.ToArray(); base64compressedCode = Convert.ToBase64String(bytes); //Console.WriteLine(base64compressedCode); urlEncodedBase64compressedCode = Uri.EscapeDataString(base64compressedCode); Console.WriteLine(urlEncodedBase64compressedCode); Console.WriteLine("Length code: " + snippet.Length); Console.WriteLine("Length compressed: " + urlEncodedBase64compressedCode.Length); } // uncompress base64compressedCode = Uri.UnescapeDataString(urlEncodedBase64compressedCode); bytes = Convert.FromBase64String(base64compressedCode); using (var uncompressed = new MemoryStream()) using (var compressedStream = new MemoryStream(bytes)) using (var uncompressor = new DeflateStream(compressedStream, CompressionMode.Decompress)) { uncompressor.CopyTo(uncompressed); uncompressor.Close(); //uncompressed.Position = 0; snippet1 = Encoding.UTF8.GetString(uncompressed.ToArray()); } // compare snippet1.Should().Be(snippet); }
/// <summary> /// Calls the current event with key data /// </summary> /// <param name="key">key data to call with</param> public virtual void CallEvent(Keys key) { Snippets?.Invoke(key, Vector2.Zero); }
/// <summary> /// Calls the current event with no data /// </summary> public virtual void CallEvent() { Snippets?.Invoke(Keys.Clear, Vector2.Zero); }
public ConditionNode(Snippets snippets) : this() { Code = snippets; }
/// <summary> /// Creates a SymbolResolver from a Snippets implementation. Only used for testing. /// </summary> internal SymbolResolver(Snippets snippets) { this.opsResolver = new OperationResolver(snippets); }
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(); }
static void SetCurrentTheme() { if (s_lightTheme == null) { s_lightTheme = new Snippets(); s_darkTheme = new Snippets(); s_lightTheme.startTick = "<color=blue>"; s_lightTheme.endTick = "</color>"; s_lightTheme.startTripleTick = "<color=purple>"; s_lightTheme.endTripleTick = "</color>"; s_lightTheme.startBold = "<color=red><b>"; s_lightTheme.endBold = "</b></color>"; s_lightTheme.startOneHash = "<size=24><b>"; s_lightTheme.endOneHash = "</b></size>"; s_lightTheme.startTwoHash = "<size=18><b>"; s_lightTheme.endTwoHash = "</b></size>"; s_lightTheme.startThreeHash = "<size=14><b>"; s_lightTheme.endThreeHash = "</b></size>"; s_lightTheme.startFourHash = "<size=12><b>"; s_lightTheme.endFourHash = "</b></size>"; s_lightTheme.startFiveHash = "<size=11><b>"; s_lightTheme.endFiveHash = "</b></size>"; s_darkTheme.startTick = "<color=cyan>"; s_darkTheme.endTick = "</color>"; s_darkTheme.startTripleTick = "<color=magenta>"; s_darkTheme.endTripleTick = "</color>"; s_darkTheme.startBold = "<color=red><b>"; s_darkTheme.endBold = "</b></color>"; s_darkTheme.startOneHash = "<size=24><b>"; s_darkTheme.endOneHash = "</b></size>"; s_darkTheme.startTwoHash = "<size=18><b>"; s_darkTheme.endTwoHash = "</b></size>"; s_darkTheme.startThreeHash = "<size=14><b>"; s_darkTheme.endThreeHash = "</b></size>"; s_darkTheme.startFourHash = "<size=12><b>"; s_darkTheme.endFourHash = "</b></size>"; s_darkTheme.startFiveHash = "<size=11><b>"; s_darkTheme.endFiveHash = "</b></size>"; } s_currentTheme = isDarkTheme() ? s_darkTheme : s_lightTheme; }
public abstract Snippets Process(Chunk chunk, Snippets code);
public void AppendExpression(Snippets code) { Flush(); _parts.Add(code); }
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 ExpressionNode(Snippets code) { Code = code; }
public ConditionNode(IEnumerable<Snippet> snippets) : this() { Code = new Snippets(snippets); }
public Snippet(Snippets snippet) { Name = snippet.Name; Information = snippet.Info; }
/// <summary> /// Creates a SymbolResolver from a Snippets implementation. Only used for testing. /// </summary> internal SymbolResolver(Snippets snippets) { this.opsResolver = new OperationResolver(snippets, snippets.Workspace, snippets.GlobalReferences); }
public ConditionNode(IEnumerable <Snippet> snippets) : this() { Code = new Snippets(snippets); }
/// <summary> /// Calls the current event with location data /// </summary> /// <param name="location">location to call with</param> public virtual void CallEvent(Vector2 location) { Snippets?.Invoke(Keys.Clear, location); }
protected void megatron_Load(object sender, EventArgs e) { //Überschrift der Aufgabe einfügen title.Text = (string)_levelData["descriptionHeader"]; megatron.Controls.Add(title); //"Löschen"-Knopf hinzufügen megatron.Controls.Add(new LiteralControl("<br />")); Button delButton = new Button(); delButton.Text = "Aufgabe löschen"; delButton.Click += DeleteTask; megatron.Controls.Add(delButton); //Zwischenüberschrift "Beschreibung" hinzufügen var topic1 = new HtmlGenericControl("h2"); topic1.InnerText = "Beschreibung"; megatron.Controls.Add(topic1); //Beschreibung zur Aufgabe einfügen beschreibung.TextMode = TextBoxMode.MultiLine; beschreibung.Text = (string)_levelData["description"]; beschreibung.Columns = Snippets.getMaxWidth(beschreibung.Text); beschreibung.Rows = Snippets.countLines(beschreibung.Text); beschreibung.ReadOnly = false; megatron.Controls.Add(beschreibung); //Unterzwischenüberschrift "Beispiel" einfügen var topic2 = new HtmlGenericControl("h3"); topic2.InnerText = "Beispiel"; megatron.Controls.Add(topic2); //Beispiel zur Beschreibung der Aufgabe einfügen beispiel.TextMode = TextBoxMode.MultiLine; beispiel.Text = (string)_levelData["example"]; beispiel.Columns = Snippets.getMaxWidth(beispiel.Text); beispiel.Rows = Snippets.countLines(beispiel.Text); beispiel.ReadOnly = false; megatron.Controls.Add(beispiel); //Zwischenüberschrift "Aufgabenstellung" hinzufügen var topic3 = new HtmlGenericControl("h2"); topic3.InnerText = "Aufgabenstellung"; megatron.Controls.Add(topic3); //Aufgabenstellung einfügen aufgabe.TextMode = TextBoxMode.MultiLine; aufgabe.Text = (string)_levelData["task"]; aufgabe.Columns = Snippets.getMaxWidth(aufgabe.Text); aufgabe.Rows = Snippets.countLines(aufgabe.Text); aufgabe.ReadOnly = false; megatron.Controls.Add(aufgabe); //Unterzwischenüberschrift "Gegeben" hinzufügen var topic4 = new HtmlGenericControl("h3"); topic4.InnerText = "Gegeben"; megatron.Controls.Add(topic4); //Gegebenen Code hinzufügen given.TextMode = TextBoxMode.MultiLine; given.Text = (string)_levelData["given"]; given.Columns = Snippets.getMaxWidth(given.Text); given.Rows = Snippets.countLines(given.Text); given.ReadOnly = false; megatron.Controls.Add(given); //Unterzwischenüberschrigt "Punkte" hinzufügen var topic5 = new HtmlGenericControl("h3"); topic5.InnerText = "Punkte"; megatron.Controls.Add(topic5); //Anzahl Punkte hinzufügen score.TextMode = TextBoxMode.Number; score.Text = ((int)_levelData["score"]).ToString(); megatron.Controls.Add(score); //"Solutions" var solutionsTopic = new HtmlGenericControl("h2"); solutionsTopic.InnerText = "Solutions"; megatron.Controls.Add(solutionsTopic); _solutionsCount = 1; string solution = Snippets.getSolution(_solutionsCount, _lvl); while (solution != String.Empty) { var solutionTopic = new HtmlGenericControl("h3"); solutionTopic.InnerText = String.Format("[[{0}]]", _solutionsCount); megatron.Controls.Add(solutionTopic); var solutionBox = new TextBox(); solutionBox.TextMode = TextBoxMode.MultiLine; solutionBox.Text = solution; solutionBox.ReadOnly = false; solutionBox.Rows = Snippets.countLines(solution); solutionBox.Columns = Snippets.getMaxWidth(solution); solutionBox.ID = "solution" + _solutionsCount; megatron.Controls.Add(solutionBox); //"Löschen"-Knopf hinzufügen var deleteButton = new Button(); deleteButton.Text = "Solution löschen"; deleteButton.ID = "deleteButton" + _solutionsCount; deleteButton.Click += DeleteSolution; megatron.Controls.Add(deleteButton); solution = Snippets.getSolution(++_solutionsCount, _lvl); } //last one was null _solutionsCount--; //add "add"-button megatron.Controls.Add(new LiteralControl("<br />")); Button addSolution = new Button(); addSolution.Text = "Solution hinzufügen"; addSolution.Click += AddSolution; megatron.Controls.Add(addSolution); //"Speichern"-Knopf hinzufügen megatron.Controls.Add(new LiteralControl("<br /><br />")); Button saveButton = new Button(); saveButton.Text = "Änderungen speichern"; saveButton.Click += Save; megatron.Controls.Add(saveButton); }
/// <summary> /// Changes the specified style to the one currently used. /// If e.InAddition is true, instead the style is added /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void snippetlist1_OnUseStyles(object sender, Snippets.UseStylesEventArgs e) { TheVM.TheDocument.InsertUseTikzLibrary(e.dependencies); if (!String.IsNullOrWhiteSpace(cmbEdgeStyles.Text) && e.InAddition) cmbEdgeStyles.Text = Helper.MergeStyles(cmbEdgeStyles.Text, e.edgestyle); else cmbEdgeStyles.Text = e.edgestyle; if (!String.IsNullOrWhiteSpace(cmbNodeStyles.Text) && e.InAddition) cmbNodeStyles.Text = Helper.MergeStyles(cmbNodeStyles.Text, e.nodestyle); else cmbNodeStyles.Text = e.nodestyle; }
}//fin del metodo colorLetras private void cbDDL_SelectedIndexChanged(object sender, EventArgs e) { Snippets snip = new Snippets(); try { switch (cbDDL.SelectedItem.ToString()) { case "Create": rtbEditor.Text += snip.create(); break; case "Create Index": rtbEditor.Text += snip.createIndex(); break; case "Create User": rtbEditor.Text += snip.createUser(); break; case "Create Function": rtbEditor.Text += snip.createFunction(); break; case "Create Proc": rtbEditor.Text += snip.createProc(); break; case "Create Database": rtbEditor.Text += snip.createDatabase(); break; case "Alter Add": rtbEditor.Text += snip.alter(); break; case "Alter Drop": rtbEditor.Text += snip.alterDrop(); break; case "Alter Alter": rtbEditor.Text += snip.alterAlter(); break; case "Alter Index": rtbEditor.Text += snip.alterIndex(); break; case "Alter User": rtbEditor.Text += snip.alterUser(); break; case "Alter Function": rtbEditor.Text += snip.alterFunction(); break; case "Alter Proc": rtbEditor.Text += snip.alterProc(); break; case "Drop": rtbEditor.Text += snip.drop(); break; case "Drop Index": rtbEditor.Text += snip.dropIndex(); break; case "Drop User": rtbEditor.Text += snip.dropUser(); break; case "Drop Function": rtbEditor.Text += snip.dropFunction(); break; case "Drop Proc": rtbEditor.Text += snip.dropProc(); break; case "Drop Database": rtbEditor.Text += snip.dropDatabase(); break; default: break; } colorLetras(); } catch (Exception) { MessageBox.Show("Teclas de acceso rapido\n ctrl + m = DML \n ctrl + d = DDL"); } }
public abstract Snippets Process(Chunk chunk, Snippets code);
public string GenerateMergeSQL(string StagingTableSchema, string StagingTableName, string TargetTableSchema, string TargetTableName, SqlConnection _con, bool CheckSchemaDrift, Logging logging) { if (CheckSchemaDrift) { SqlCommand cmd = new SqlCommand(string.Format("Select * from {0}.{1}", StagingTableSchema, StagingTableName), _con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable stagingDT = new DataTable(); da.Fill(stagingDT); cmd = new SqlCommand(string.Format("Select * from {0}.{1}", TargetTableSchema, TargetTableName), _con); da = new SqlDataAdapter(cmd); DataTable targetDT = new DataTable(); da.Fill(targetDT); bool schemaEqual = DataTableSchemaCompare.SchemaEquals(stagingDT, targetDT); if (schemaEqual == false) { logging.LogWarning(string.Format("****Schema Drift for Table {0}.{1} to {2}.{3}", StagingTableSchema, StagingTableName.Replace("#Temp_", ""), TargetTableSchema, TargetTableName.Replace("#Temp_", ""))); } } Table SourceTable = new Table { Name = StagingTableName, Schema = StagingTableSchema, PersistedCon = _con }; Table TargetTable = new Table { Name = TargetTableName, Schema = TargetTableSchema, PersistedCon = _con }; TargetTable.GetColumnsFromExistingDB(true); SourceTable.GetColumnsFromExistingDB(true); string PrimaryKeyJoin = Snippets.GenerateColumnJoinOrUpdateSnippet(SourceTable, TargetTable, "a", "b", "=", " and ", true, true, false, false, false, null, false, false); string ColList = Snippets.GenerateColumnJoinOrUpdateSnippet(SourceTable, TargetTable, "", "", "=", ",", true, true, false, false, true, null, true, false); string SelectListForInsert = Snippets.GenerateColumnJoinOrUpdateSnippet(SourceTable, TargetTable, "b", "", "", ",", true, false, false, false, true, null, true, false); string InsertList = Snippets.GenerateColumnJoinOrUpdateSnippet(SourceTable, TargetTable, "", "", "", ",", true, false, false, false, true, null, true, false); string UpdateClause = Snippets.GenerateColumnJoinOrUpdateSnippet(SourceTable, TargetTable, "b", "", "=", ",", false, false, false, false, true, null, false, false); Dictionary <string, string> SqlParams = new Dictionary <string, string> { { "TargetFullName", TargetTable.SchemaAndName() }, { "SourceFullName", SourceTable.SchemaAndName() }, { "PrimaryKeyJoin_AB", PrimaryKeyJoin }, { "UpdateClause", UpdateClause }, { "SelectListForInsert", SelectListForInsert }, { "InsertList", InsertList } }; string MergeSQL = string.Empty; if (PrimaryKeyJoin.Length >= 4) { MergeSQL = GenerateSQLStatementTemplates.GetSQL(Shared.GlobalConfigs.GetStringConfig("SQLTemplateLocation"), "GenericMerge", SqlParams); } else { MergeSQL = GenerateSQLStatementTemplates.GetSQL(Shared.GlobalConfigs.GetStringConfig("SQLTemplateLocation"), "GenericTruncateInsert", SqlParams); } return(MergeSQL); }
public void AppendExpression(Snippets code) { Flush(); //TODO: preserve the Snippet's Position data in the reconstruction _parts.Add(code); }
public override Snippets ParseFragment(Position begin, Position end) { var result = _grammar.Expression(begin.Constrain(end)); var unparsedLength = result.Rest.PotentialLength(); if (unparsedLength == 0) return result.Value; var snippets = new Snippets(result.Value); snippets.Add(new Snippet { Value = result.Rest.Peek(unparsedLength), Begin = result.Rest, End = result.Rest.Advance(unparsedLength) }); return snippets; }
public void UsingNamespace(Snippets ns) { if (_namespaceAdded.ContainsKey(ns)) return; if (_namespaceAdded.Count == 0) { _source.WriteLine("uses"); } else { _source.Write(",").WriteLine(""); } _namespaceAdded.Add(ns, null); _source.Write("").WriteCode(ns); }
public void AddFunction(AspectMetadata meta) { if (_alreadyAddedFunctions.Contains(meta.Name)) { // already added return; } _alreadyAddedFunctions.Add(meta.Name); var possibleTags = meta.PossibleTags() ?? new Dictionary <string, HashSet <string> >(); int numberOfCombinations; numberOfCombinations = possibleTags.Values.Select(lst => 1 + lst.Count).Multiply(); var usedParams = meta.UsedParameters(); var funcNameDeclaration = ""; meta.Visit(e => { if (e is Function f && f.Name.Equals(Funcs.MemberOf.Name)) { funcNameDeclaration = $"\n local funcName = \"{meta.Name.AsLuaIdentifier()}\""; } return(true); }); var expression = meta.ExpressionImplementation; var ctx = Context; _context = _context.WithAspectName(meta.Name); var body = ""; if (_useSnippets) { if (expression.Types.First() is Curry c) { expression = expression.Apply(new LuaLiteral(Typs.Tags, "tags")); } body = Utils.Lines( " local r = nil", " " + Snippets.Convert(this, "r", expression).Indent(), " return r" ); } else { body = " return " + ToLua(expression); } var impl = Utils.Lines( "--[[", meta.Description, "", "Unit: " + meta.Unit, "Created by " + meta.Author, "Uses tags: " + string.Join(", ", possibleTags.Keys), "Used parameters: " + string.Join(", ", usedParams), "Number of combintations: " + numberOfCombinations, "Returns values: ", "]]", "function " + meta.Name.AsLuaIdentifier() + "(parameters, tags, result)" + funcNameDeclaration, body, "end" ); _context = ctx; _functionImplementations.Add(impl); }
public StatementNode(Snippets code) { Code = code; }
public ConditionNode(string code) : this() { Code = new Snippets(new[] { new Snippet { Value = code } }); }
public ExpressionNode(Snippets code) { this.Code = code; }
public ConditionNode(Snippets snippets) : this() { Code = snippets; }
/// <summary> /// Initializes the code snippets. /// </summary> private void InitializeSnippets() { // "for (|;;)\n{\n}" Snippet forSnippet = new Snippet(); forSnippet.Elements.Add(new SnippetTextElement { Text = "for (" }); forSnippet.Elements.Add(new SnippetCaretElement()); forSnippet.Elements.Add(new SnippetTextElement { Text = ";;)\n{\n}" }); // "if (|)\n{\n}" Snippet ifSnippet = new Snippet(); ifSnippet.Elements.Add(new SnippetTextElement { Text = "if (" }); ifSnippet.Elements.Add(new SnippetCaretElement()); ifSnippet.Elements.Add(new SnippetTextElement { Text = ")\n{\n}" }); // "while (|)\n{\n}" Snippet whileSnippet = new Snippet(); whileSnippet.Elements.Add(new SnippetTextElement { Text = "while (" }); whileSnippet.Elements.Add(new SnippetCaretElement()); whileSnippet.Elements.Add(new SnippetTextElement { Text = ")\n{\n}" }); // "technique |\n{\npass\n{\n}\n}" Snippet techniqueSnippet = new Snippet(); techniqueSnippet.Elements.Add(new SnippetTextElement { Text = "technique " }); techniqueSnippet.Elements.Add(new SnippetCaretElement()); techniqueSnippet.Elements.Add(new SnippetTextElement { Text = "\n{\npass\n{\n}\n}" }); // "pass |\n{\n}" Snippet passSnippet = new Snippet(); passSnippet.Elements.Add(new SnippetTextElement { Text = "pass " }); passSnippet.Elements.Add(new SnippetCaretElement()); passSnippet.Elements.Add(new SnippetTextElement { Text = "\n{\n}" }); SnippetCompletionData[] snippets = { new SnippetCompletionData("for", "for loop", MultiColorGlyphs.Snippet, forSnippet), new SnippetCompletionData("if", "if statement", MultiColorGlyphs.Snippet, ifSnippet), new SnippetCompletionData("while", "while loop", MultiColorGlyphs.Snippet, whileSnippet), new SnippetCompletionData("technique", null, MultiColorGlyphs.Snippet, techniqueSnippet), new SnippetCompletionData("pass", null, MultiColorGlyphs.Snippet, passSnippet), }; foreach (SnippetCompletionData snippet in snippets) { Snippets.Add(snippet.Text, snippet); } }
public StatementNode(Snippets code) { Code = code; }
private async Task OnCopyCode() { await JSRuntime.InvokeVoidAsync("blazoriseDocs.code.copyToClipboard", Snippets.GetCode(Code)); await NotificationService.Info($"Copied code example!"); }
public async Task snippets(params string[] args) { if (!HasExecutePermission) return; if (args.Length == 0) { EmbedBuilder b = new EmbedBuilder() { Title = "Ticket Snippets", Color = Color.DarkPurple, Description = "To add a snippet:\n`!snippets add <SnippetName> <SnippetValue>`\nTo Remove a snippet:\n`!snippets remove <SnippetName>`" }; foreach(var snip in Snippets) b.AddField(snip.Key, snip.Value); await Context.Channel.SendMessageAsync("", false, b.Build()); } else { if(args.Length >= 2) { switch (args[0].ToLower()) { case "add": { string snip = args[1]; string snipval = string.Join(' ', args.Skip(2)); if (!Snippets.ContainsKey(snip)) { if(snipval.Length > 1024) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = $"wOaH bUddY", Description = $"Your snippet is tooooooo long! try adding one that less than 1000 characters" }.Build()); return; } Snippets.Add(snip, snipval); Global.SaveSnippets(); await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = $"Added **{snip}**", Description = $"Succesfully added **{snip}** to the snippets" }.Build()); } else { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = $"That snippet exists!", Description = $"someone already added that snippet!" }.Build()); } } break; case "remove": { string snip = args[1]; if (Snippets.ContainsKey(snip)) { //remove snippet Snippets.Remove(snip); Global.SaveSnippets(); await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = $"Removed **{snip}**", Description = $"Successfully removed the snippet {snip}", Color = Color.Green }.Build()); } else { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "uhm.. wat?", Description = "That snippet doesnt exist, please do `!snippets` to view the current snippets!", Color = Color.Red }.Build()); return; } } break; default: { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "uhm.. wat?", Description = "that command is unreconized :/", Color = Color.Red }.Build()); } break; } } } }
protected IRichEditDocumentServer AddImage(ArgumentCollection arguments) { if (arguments.Count <= 0) { throw new Exception("'DOCVARIABLE IMAGE' requires filename as first argument."); } var fileName = arguments[0].Value; if (string.IsNullOrWhiteSpace(fileName)) { throw new Exception("DOCVARIABLE IMAGE does not contain valid filename."); } object snippet = null; if (Snippets?.ContainsKey(fileName) ?? false) { snippet = Snippets[fileName]; if (snippet is Image) { } else { throw new Exception($"Specified snippet '{fileName}' is not supported. Snippet shall be either Book or System.Drawing.Image."); } } else { fileName = Project.Current.MapPath(fileName); } if (snippet == null && !File.Exists(fileName)) { throw new Exception($"File '{fileName}' does not exist."); } using (new UsingProcessor(() => CheckNestedFile(fileName), () => RemoveNestedFile(fileName))) { var image = snippet as Image ?? Bitmap.FromFile(fileName); float?scale = null, scaleX = null, scaleY = null; if (arguments.Count > 1) { var properties = Utils.SplitNameValueString(arguments[1].Value, ';'); foreach (var prop in properties) { if (string.IsNullOrWhiteSpace(prop.Key)) { continue; } switch (prop.Key.ToLower()) { #pragma warning disable CRRSP06 // A misspelled word has been found case "dpi": var dpi = float.Parse(prop.Value, CultureInfo.InvariantCulture); if (image is Bitmap bmp) { bmp.SetResolution(dpi, dpi); } break; case "scale": scale = float.Parse(prop.Value, CultureInfo.InvariantCulture); break; case "scalex": scaleX = float.Parse(prop.Value, CultureInfo.InvariantCulture); break; case "scaley": scaleY = float.Parse(prop.Value, CultureInfo.InvariantCulture); break; #pragma warning restore CRRSP06 // A misspelled word has been found } } } var server = new RichEditDocumentServer(); var document = server.Document; var docImage = document.Images.Append(image); if (scale.HasValue) { docImage.ScaleX = docImage.ScaleY = scale.Value; } else { if (scaleX.HasValue) { docImage.ScaleX = scaleX.Value; } if (scaleY.HasValue) { docImage.ScaleY = scaleY.Value; } } return(server); } }
private async Task CopyTextToClipboard() { await JsApiService.CopyToClipboardAsync(Snippets.GetCode(Code)); }
//GridLength oldwidth; /* private void cmdSnippets_Checked(object sender, RoutedEventArgs e) { if (cmdSnippets != null && cmdFiles != null && snippetlist1 != null) { if (sender == cmdFiles) { cmdSnippets.IsChecked = false; cmdDynPreamble.IsChecked = false; //snippetlist1.Visibility = System.Windows.Visibility.Hidden; } else if (sender == cmdSnippets) { cmdFiles.IsChecked = false; cmdDynPreamble.IsChecked = false; //snippetlist1.Visibility = System.Windows.Visibility.Visible; } else if (sender == cmdDynPreamble) { cmdFiles.IsChecked = false; cmdSnippets.IsChecked = false; //snippetlist1.Visibility = System.Windows.Visibility.Visible; } Properties.Settings.Default.LeftToolsColVisible = (cmdSnippets.IsChecked == true || cmdFiles.IsChecked == true || cmdDynPreamble.IsChecked == true); //GridLengthConverter g = new GridLengthConverter(); //if (LeftSplitterCol.Width == (GridLength)g.ConvertFrom(0)) //{ // LeftToolsCol.Width = oldwidth; // LeftSplitterCol.Width = (GridLength)g.ConvertFrom(3); //} } } private void cmdSnippets_Unchecked(object sender, RoutedEventArgs e) { if (sender == cmdFiles) { //cmdSnippets.IsChecked = false; //snippetlist1.Visibility = System.Windows.Visibility.Hidden; } else if (sender == cmdSnippets) { //cmdFiles.IsChecked = false; //snippetlist1.Visibility = System.Windows.Visibility.Hidden; } if (cmdFiles.IsChecked == false && cmdSnippets.IsChecked == false && cmdDynPreamble.IsChecked == false) { Properties.Settings.Default.LeftToolsColVisible = false; //GridLengthConverter g = new GridLengthConverter(); //oldwidth = LeftToolsCol.Width; //LeftToolsCol.Width = (GridLength)g.ConvertFrom(0); //LeftSplitterCol.Width = (GridLength)g.ConvertFrom(0); } } */ private void snippetlist1_OnInsert(object sender, Snippets.InsertEventArgs e) { //txtCode.BeginChange(); //string s = txtCode.Text, a=s.Substring(0,txtCode.CaretOffset), b=s.Substring(txtCode.CaretOffset); //txtCode.Text = a + code + b; //txtCode.EndChange(); txtCode.Document.Insert(txtCode.CaretOffset, e.code); }