View AzureTableStorage.cs
This file contains 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
public class AzureTableStorage<T> where T : TableEntity, IAzureStorageTable, new() | |
{ | |
CloudStorageAccount storageAccount = CloudStorageAccount.Parse( | |
CloudConfigurationManager.GetSetting("StorageConnectionString")); | |
CloudTableClient tableClient; | |
CloudTable table; | |
public AzureTableStorage(string tableName) | |
{ |
View EjemploRandom1.cs
This file contains 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
static void EjemploRandom1() | |
{ | |
for (int i = 0; i <= 10; i++) | |
{ | |
var seed = Environment.TickCount; | |
var random = new Random(seed); | |
var value = random.Next(0, 5); | |
Console.WriteLine($"Iteración {i} - semilla {seed} - valor {value}"); | |
} |
View EjemploRandom2.cs
This file contains 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
static void EjemploConTickCount() | |
{ | |
var seed = Environment.TickCount; | |
var random = new Random(seed); | |
for (int i = 0; i <= 10; i++) | |
{ | |
var value = random.Next(0, 5); | |
Console.WriteLine($"Iteración {i} - semilla {seed} - valor {value}"); | |
} |
View EjemploRandom3.cs
This file contains 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
static void EjemploRandom3() | |
{ | |
for (int i = 0; i <= 10; i++) | |
{ | |
var guid = Guid.NewGuid(); | |
var justNumbers = new String(guid.ToString().Where(Char.IsDigit).ToArray()); | |
var seed = int.Parse(justNumbers.Substring(0, 4)); | |
var random = new Random(seed); | |
var value = random.Next(0, 5); |
View CreateTableFromEntity.cs
This file contains 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
public static string GetCreateTableQuery<T>(IEnumerable<T> list, string tableName) | |
{ | |
Type type = typeof(T); | |
var properties = type.GetProperties(); | |
var query = new StringBuilder(); | |
query.Append($"CREATE TABLE {tableName} ("); | |
foreach (PropertyInfo info in properties) | |
{ |
View BulkUploadToSql.cs
This file contains 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
public class BulkUploadToSql<T> | |
{ | |
public IList<T> InternalStore { get; set; } | |
public string TableName { get; set; } | |
public int CommitBatchSize { get; set; } = 1000; | |
public SqlConnection Connection { get; set; } | |
public async Task Commit() | |
{ | |
if (InternalStore.Count > 0) |
View ProgramAsync.cs
This file contains 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.Threading.Tasks; | |
namespace ConsoleAsyncDemo | |
{ | |
static class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Main().Wait(); | |
} |
View SecurityProtocol.cs
This file contains 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
System.Net.ServicePointManager.SecurityProtocol = | |
SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | | |
SecurityProtocolType.Tls12; |
View CreateCosmosDbAndCollection.ps1
This file contains 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
#Source: https://stackoverflow.com/questions/52722373/create-database-and-collection-on-cosmos-db-sql-api-inside-azuredevopps-vsts | |
param($endpoint, $masterKey, $databaseName, $collectionName, $collectionRUs, $partitionKey) | |
Add-Type -AssemblyName System.Web | |
Add-Type -TypeDefinition @" | |
public enum CosmosResourceType | |
{ | |
Database, | |
Collection | |
} |
View tracer.cs
This file contains 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
public void Execute(IServiceProvider serviceProvider) | |
{ | |
ITracingService tracer = (ITracingService) serviceProvider.GetService(typeof(ITracingService)); | |
tracer.Trace("Traza que queremos dejar"); | |
} |