Skip to content

Commit

Permalink
Updated Glimpse CA warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Aug 7, 2015
1 parent 751ec8b commit 46733c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using Glimpse.Core.Framework;

namespace NuGetGallery.Diagnostics
Expand Down
11 changes: 6 additions & 5 deletions src/NuGetGallery/Diagnostics/GlimpseServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ namespace NuGetGallery.Diagnostics
{
public class GlimpseServiceLocator : IServiceLocator
{
static Dictionary<Type, object[]> _localObjects = new Dictionary<Type, object[]>();
static readonly Dictionary<Type, object[]> LocalObjects = new Dictionary<Type, object[]>();

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
static GlimpseServiceLocator()
{
var configuration = new ConfigurationService();
_localObjects.Add(typeof(IRuntimePolicy), new object[]
LocalObjects.Add(typeof(IRuntimePolicy), new object[]
{
new GlimpseRuntimePolicy(configuration.Current),
new GlimpseResourcePolicy(),
Expand All @@ -30,15 +31,15 @@ static GlimpseServiceLocator()
new Regex(@"^.*(Web|Script)Resource\.axd.*$")
})
});
_localObjects.Add(typeof(IPersistenceStore), new object[] { new ConcurrentInMemoryPersistenceStore() });
LocalObjects.Add(typeof(IPersistenceStore), new object[] { new ConcurrentInMemoryPersistenceStore() });
}

public ICollection<T> GetAllInstances<T>() where T : class
{
var instances = DependencyResolver.Current.GetServices<T>().ToList();

object[] localObjects = null;
if (_localObjects.TryGetValue(typeof (T), out localObjects))
if (LocalObjects.TryGetValue(typeof (T), out localObjects))
{
foreach (var localObject in localObjects)
{
Expand All @@ -58,7 +59,7 @@ public ICollection<T> GetAllInstances<T>() where T : class
public T GetInstance<T>() where T : class
{
object[] localObjects = null;
if (_localObjects.TryGetValue(typeof (T), out localObjects))
if (LocalObjects.TryGetValue(typeof (T), out localObjects))
{
return localObjects[0] as T;
}
Expand Down
5 changes: 0 additions & 5 deletions tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\jquery-1.4.1-vsdoc.js" />
<Content Include="Scripts\jquery-1.4.1.js" />
<Content Include="Scripts\jquery-1.4.1.min.js" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildThisFileDirectory)\..\..\build\NuGetGallery.xunit.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down

0 comments on commit 46733c8

Please sign in to comment.