This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SqlDataContext : ISqlDataContext { | |
| private readonly SqlConnection _connection; | |
| public SqlDataContext(string connectionString) | |
| { | |
| _connection = CreateConnection(connectionString); | |
| } | |
| public IDataReader ExecuteReader(string storedProcedureName, ICollection<SqlParameter> parameters) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare @encrypt varbinary(200) | |
| select @encrypt = EncryptByPassPhrase('key', 'abc' ) //abc is the data you want to encrypt | |
| select @encrypt | |
| select convert(varchar(100),DecryptByPassPhrase('key', @encrypt )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I've got an interface with some async functions. | |
| Methods returning Task, I believe. async is an implementation detail, so it can't be applied to interface methods. | |
| Some of the classes that implements the interface does not have anything to await, and some might just throw. | |
| In these cases, you can take advantage of the fact that async is an implementation detail. | |
| If you have nothing to await, then you can just return Task.FromResult: | |
| public Task<int> Success() // note: no "async" | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| When developing an ASP .NET MVC or WebAPI based application, we eventually need to read configurations from <appSettings> section of Web.Config file. Here is an example entry from my imaginary project: | |
| <configuration> | |
| <!-- other config sections --> | |
| <appSettings> | |
| <add key="app.name" value="My Application" /> | |
| <add key="app.domain" value="mydomain.com" /> | |
| <add key="encryption.algorithm" value="TripleDES" /> | |
| <add key="encryption.key" value="MY_KEY" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.Net.Http; | |
| using System.Net; | |
| namespace HTTP_Test |
NewerOlder