public void CreateTableName() { StringBuilder sb=new StringBuilder(); RandomStringGenerator randomStringGenerator=new RandomStringGenerator(); for (int i = 0; i <= 100; i++) { sb.AppendFormat("\"{0}\"",randomStringGenerator.GetRandomStringAlfa(3)); if (i != 100) sb.Append(","); } Console.WriteLine(sb); }
public UrlShortnerService(string storageAccountName, string storageAccountSecret,string baseUrl,bool useMemoryCache=true) { this.storageAccount = new CloudStorageAccount(new StorageCredentials(storageAccountName, storageAccountSecret), true); ServicePoint tableServicePoint = ServicePointManager.FindServicePoint(storageAccount.TableEndpoint); tableServicePoint.UseNagleAlgorithm = false; tableClient = storageAccount.CreateCloudTableClient(); if(useMemoryCache) this.Cache=MemoryCache.Default; randomStringGenerator=new RandomStringGenerator(); foreach (var s in tables) { var table = tableClient.GetTableReference(s); table.CreateIfNotExists(tableRequestOptions); tableList.Add(s,table); } this.baseUrl = baseUrl.ToLowerInvariant(); if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/"; }
public UrlShortnerService(string storageAccountName, string storageAccountSecret, string baseUrl, string masterToken, bool useMemoryCache = true) { this.storageAccount = new CloudStorageAccount(new StorageCredentials(storageAccountName, storageAccountSecret), true); ServicePoint tableServicePoint = ServicePointManager.FindServicePoint(storageAccount.TableEndpoint); tableServicePoint.UseNagleAlgorithm = false; tableClient = storageAccount.CreateCloudTableClient(); if (useMemoryCache) { this.Cache = MemoryCache.Default; } randomStringGenerator = new RandomStringGenerator(); foreach (var s in tables) { var table = tableClient.GetTableReference(s); table.CreateIfNotExists(tableRequestOptions); tableList.Add(s, table); } this.baseUrl = baseUrl.ToLowerInvariant(); if (!this.baseUrl.EndsWith("/")) { this.baseUrl += "/"; } if (string.IsNullOrWhiteSpace(masterToken)) { _masterToken = randomStringGenerator.GetRandomString(100); } else { _masterToken = masterToken; } }