Skip to content

Commit

Permalink
last commit before new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Jan 7, 2014
1 parent 5278578 commit 43f04a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,41 @@ protected BaseFileRegistrationProvider()

#region CompositeFileHandlerPath config

string _compositeFileHandlerPath;
bool _compositeFileHandlerPathInitialized;
//set the default
private string _compositeFileHandlerPath = "~/DependencyHandler.axd";
private volatile bool _compositeFileHandlerPathInitialized = false;

protected string GetCompositeFileHandlerPath(HttpContextBase http)
protected internal string GetCompositeFileHandlerPath(HttpContextBase http)
{
lock (this)
{
if (!_compositeFileHandlerPathInitialized)
{
//if (_compositeFileHandlerPath != null && _compositeFileHandlerPath.StartsWith("~/"))
_compositeFileHandlerPath = VirtualPathUtility.ToAbsolute(_compositeFileHandlerPath, http.Request.ApplicationPath);
_compositeFileHandlerPathInitialized = true;
}

return _compositeFileHandlerPath;
}
if (!_compositeFileHandlerPathInitialized)
{
lock (this)
{
//double check
if (!_compositeFileHandlerPathInitialized)
{
if (string.IsNullOrWhiteSpace(_compositeFileHandlerPath))
{
throw new InvalidOperationException("The compositeFileHandlerPath cannot be empty");
}
//we may need to convert this to a real path
if (_compositeFileHandlerPath.StartsWith("~/"))
{
_compositeFileHandlerPath = VirtualPathUtility.ToAbsolute(_compositeFileHandlerPath, http.Request.ApplicationPath);
}
//set the flag, we're done
_compositeFileHandlerPathInitialized = true;
}
}
}
return _compositeFileHandlerPath;
}

#endregion

#region Provider Initialization

public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
public override void Initialize(string name, NameValueCollection config)
{
base.Initialize(name, config);

Expand All @@ -109,17 +121,11 @@ public override void Initialize(string name, System.Collections.Specialized.Name
// WebsiteBaseUrl = WebsiteBaseUrl.TrimEnd('/');
//}

_compositeFileHandlerPath = null;
_compositeFileHandlerPathInitialized = true;

if (config != null)
{
_compositeFileHandlerPath = config["compositeFileHandlerPath"];
if (string.IsNullOrEmpty(_compositeFileHandlerPath))
_compositeFileHandlerPath = null;
else if (_compositeFileHandlerPath.StartsWith("~/"))
_compositeFileHandlerPathInitialized = false;
}
if (config != null && config["compositeFileHandlerPath"] != null)
{
_compositeFileHandlerPath = config["compositeFileHandlerPath"];
}

}

#endregion
Expand Down
2 changes: 2 additions & 0 deletions ClientDependency.UnitTests/ClientDependencySettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public void Settings_Min_Sections_Defined()
Assert.AreEqual(typeof(CompositeFileProcessingProvider), settings.DefaultCompositeFileProcessingProvider.GetType());
Assert.AreEqual(0, settings.ConfigSection.CompositeFileElement.MimeTypeCompression.Count);
Assert.AreEqual(0, settings.ConfigSection.CompositeFileElement.RogueFileCompression.Count);

Assert.AreEqual("/DependencyHandler.axd", settings.DefaultFileRegistrationProvider.GetCompositeFileHandlerPath(ctxFactory.Context));
}


Expand Down

0 comments on commit 43f04a9

Please sign in to comment.