From 0344fa23662a9f8478de8ff7aa7ce008ddf3d20c Mon Sep 17 00:00:00 2001 From: thepriefy Date: Fri, 27 Oct 2017 10:32:53 +0700 Subject: [PATCH 1/4] Add a .env_sample file, update gitignore, update README.md --- .env_sample | 1 + .gitignore | 4 +++- README.md | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .env_sample diff --git a/.env_sample b/.env_sample new file mode 100644 index 000000000..30857f428 --- /dev/null +++ b/.env_sample @@ -0,0 +1 @@ +export SENDGRID_API_KEY='' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 852808631..52ac3f35b 100644 --- a/.gitignore +++ b/.gitignore @@ -323,4 +323,6 @@ $RECYCLE.BIN/ *.lnk # Code -/.vscode \ No newline at end of file +/.vscode + +.env \ No newline at end of file diff --git a/README.md b/README.md index 00e3f8e95..9d1d617e1 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,24 @@ For sample implementations, see the [.NET Core Example](https://github.com/sendg - Please see the [.nuspec file](https://github.com/sendgrid/sendgrid-csharp/tree/master/nuspec). +## Setup Environment Variables + +### Initial Setup + +```bash +cp .env_sample .env +``` + +### Environment Variable + +Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example: + +```bash +echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env +echo "sendgrid.env" >> .gitignore +source ./sendgrid.env +``` + # Quick Start From bec3e491d9a2afe427ccf73b7199a96714a78b0b Mon Sep 17 00:00:00 2001 From: thepriefy Date: Sun, 29 Oct 2017 16:49:46 +0700 Subject: [PATCH 2/4] remove export --- .env_sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env_sample b/.env_sample index 30857f428..cb36926ad 100644 --- a/.env_sample +++ b/.env_sample @@ -1 +1 @@ -export SENDGRID_API_KEY='' \ No newline at end of file +SENDGRID_API_KEY='' From 048beb0919eb521ffb483fcd3b59ca8414a09502 Mon Sep 17 00:00:00 2001 From: thepriefy Date: Sun, 29 Oct 2017 16:51:55 +0700 Subject: [PATCH 3/4] update copy command --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9d1d617e1..405c4c1b3 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ For sample implementations, see the [.NET Core Example](https://github.com/sendg ### Initial Setup ```bash -cp .env_sample .env +copy .env_sample .env ``` ### Environment Variable @@ -281,4 +281,4 @@ sendgrid-csharp is guided and supported by the SendGrid [Developer Experience Te sendgrid-csharp is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-csharp are trademarks of SendGrid, Inc. # License -[The MIT License (MIT)](LICENSE.txt) \ No newline at end of file +[The MIT License (MIT)](LICENSE.txt) From edbf88f7b8eba444cdf33d941dc49204bbdf79ff Mon Sep 17 00:00:00 2001 From: thepriefy Date: Sun, 29 Oct 2017 22:19:11 +0700 Subject: [PATCH 4/4] update README.md update how to set Environment variables in C# --- README.md | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 405c4c1b3..c4f679dae 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,18 @@ Click the "New" button beneath the User Variables list. Give it the name `NAME_O For value, insert your SendGrid API key. Click "Ok", and once again in the Variable Overview and lastly, close the system properties window. +For other Windows version, you can set an environment variable like this: + +```csharp +var setKey = Environment.SetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY", value); +``` + +For example, + +```csharp +var setKey = Environment.SetEnvironmentVariable("SENDGRID_API_KEY", YOUR_API_KEY); +``` + You may need to restart your IDE to make use of the new variable. Now, if all went well, you can access the just added variable in your C# SendGrid projects! Ready for some examples? @@ -103,24 +115,6 @@ For sample implementations, see the [.NET Core Example](https://github.com/sendg - Please see the [.nuspec file](https://github.com/sendgrid/sendgrid-csharp/tree/master/nuspec). -## Setup Environment Variables - -### Initial Setup - -```bash -copy .env_sample .env -``` - -### Environment Variable - -Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example: - -```bash -echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env -echo "sendgrid.env" >> .gitignore -source ./sendgrid.env -``` - # Quick Start