From 46f51427c86ad8cb0f695adcd6c93a7a29a8f496 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 17 Feb 2022 17:12:31 +0200 Subject: Added "syntax highlighting" styling and implemented it in the connect to mysql article --- src/styles.css | 38 ++++++++++++++++++++++ .../connect-to-mysql-in-dotnet-ef/article.md | 31 ++++++++---------- 2 files changed, 51 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/styles.css b/src/styles.css index aa08868..ecafe29 100644 --- a/src/styles.css +++ b/src/styles.css @@ -326,6 +326,44 @@ blockquote > :last-child { box-sizing: border-box; } +/* Syntax highlighting (colours are inspired from gruvbox) */ + +code span { + background-color: inherit; +} + +.cst, .chr { /* Constant, Chars */ + color: #d787af; +} + +.com { /* Comment */ + color: #8a8a8a; +} + +.kwd { /* Keyword */ + color: #d75f5f; +} + +.kwD { /* Second keyword color */ + color: #87af87; +} + +.kWD { /* Third keyword color */ + color: #ff8700; +} + +.typ { /* Type */ + color: #ffaf00; +} + +.cls { /* Class */ + color: #87afaf; +} + +.fnc, .str { /* Function names, Strings */ + color: #afaf00; +} + /* OpenSans font */ @font-face { diff --git a/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md b/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md index 775bab1..4b3a5da 100644 --- a/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md +++ b/src/tutorials/connect-to-mysql-in-dotnet-ef/article.md @@ -50,9 +50,8 @@ The method requires at least two arguments: connection string and `MySql` server For the server version argument, create a new object of type `MySqlServerVersion` and give it's constructor a new object of type `Version`, to which you give the version numbers. The result should look something like this: -``` -.UseMySql(CONNECTION_STRING, new MySqlServerVersion(new System.Version(8, 0, 21))) -``` +
.UseMySql(CONNECTION_STRING, new MySqlServerVersion(new System.Version(8, 0, 21)))
+
Where `CONNECTION_STRING` is a (constant) variable that contains your connection string, and 8, 0, 21 are the version numbers. @@ -63,17 +62,15 @@ For `ASP.NET` applications, the connection must be put inside the `ConfigureServ The result should look something along the lines of: -``` -// This method gets called by the runtime. Use this method to add services to the container. -public void ConfigureServices(IServiceCollection services) +
// This method gets called by the runtime. Use this method to add services to the container.
+public void ConfigureServices(IServiceCollection services)
 {   
-	...                 
-	services.AddDbContext(opt =>
-	{
-		opt.UseMySql(...);
-	}); 
-}
-```
+    ...
+    services.AddDbContext<AppDbContext>(opt =>
+    {
+        opt.UseMySql(...);
+    });
+}

### DBContext child class @@ -81,10 +78,8 @@ public void ConfigureServices(IServiceCollection services) Another way to connect is via a `DBContext` child class (so, inside your own DB context). Just, override the `OnConfiguring` method and call the `.UseMySql` method from the `optionsBuilder` parameter. -``` -protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
-	optionsBuilder.UseMySql(...);
-}
-```
+    optionsBuilder.UseMySql(...);
+}

-- cgit v1.3.1-26-gb76a