Skip to content

Commit e52cf37

Browse files
committed
Convert NuGetGallery.Services to SDK-style project
1 parent e22f95e commit e52cf37

4 files changed

Lines changed: 41 additions & 416 deletions

File tree

src/NuGetGallery.Services/Configuration/ConfigurationService.cs

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Threading.Tasks;
1212
using System.Web;
1313
using System.Web.Configuration;
14-
using Microsoft.WindowsAzure.ServiceRuntime;
1514
using NuGet.Services.Configuration;
1615
using NuGet.Services.KeyVault;
1716
using NuGetGallery.Configuration.SecretReader;
@@ -168,21 +167,8 @@ public async Task<string> ReadSettingAsync(string settingName)
168167

169168
public string ReadRawSetting(string settingName)
170169
{
171-
string value;
172-
173-
value = GetCloudServiceSetting(settingName);
174-
175-
if (value == "null")
176-
{
177-
value = null;
178-
}
179-
else if (string.IsNullOrEmpty(value))
180-
{
181-
var cstr = GetConnectionString(settingName);
182-
value = cstr != null ? cstr.ConnectionString : GetAppSetting(settingName);
183-
}
184-
185-
return value;
170+
var cstr = GetConnectionString(settingName);
171+
return cstr != null ? cstr.ConnectionString : GetAppSetting(settingName); ;
186172
}
187173

188174
protected virtual HttpRequestBase GetCurrentRequest()
@@ -210,39 +196,6 @@ private async Task<IPackageDeleteConfiguration> ResolvePackageDelete()
210196
return await ResolveConfigObject(new PackageDeleteConfiguration(), PackageDeletePrefix);
211197
}
212198

213-
protected virtual string GetCloudServiceSetting(string settingName)
214-
{
215-
// Short-circuit if we've already determined we're not in the cloud
216-
if (_notInCloudService)
217-
{
218-
return null;
219-
}
220-
221-
string value = null;
222-
try
223-
{
224-
if (RoleEnvironment.IsAvailable)
225-
{
226-
value = RoleEnvironment.GetConfigurationSettingValue(settingName);
227-
}
228-
else
229-
{
230-
_notInCloudService = true;
231-
}
232-
}
233-
catch (TypeInitializationException)
234-
{
235-
// Not in the role environment...
236-
_notInCloudService = true; // Skip future checks to save perf
237-
}
238-
catch (Exception)
239-
{
240-
// Value not present
241-
return null;
242-
}
243-
return value;
244-
}
245-
246199
protected virtual string GetAppSetting(string settingName)
247200
{
248201
return WebConfigurationManager.AppSettings[settingName];
@@ -291,4 +244,4 @@ private string GetHttpsSiteRoot()
291244
return "https://" + siteRoot.Substring(7);
292245
}
293246
}
294-
}
247+
}

0 commit comments

Comments
 (0)