Skip to content

Instantly share code, notes, and snippets.

@chadmyers
Created January 10, 2012 20:19
Show Gist options
  • Save chadmyers/1590956 to your computer and use it in GitHub Desktop.
Save chadmyers/1590956 to your computer and use it in GitHub Desktop.
using System;
using System.Reflection;
using FubuCore.Reflection;
namespace FubuCore.Binding
{
public class MapWebToPhysicalPathFamily : StatelessConverter
{
public override bool Matches(PropertyInfo property)
{
return property.HasAttribute<MapWebToPhysicalPathAttribute>();
}
public override object Convert(IPropertyContext context)
{
var strVal = context.PropertyValue as String;
return strVal.IsNotEmpty()
? strVal.ToPhysicalPath()
: strVal;
}
}
}
public static string ToPhysicalPath(this string webRelativePath)
{
if (!_isAbsolute(webRelativePath))
{
webRelativePath = _combine("~", webRelativePath);
}
return _mapPath(webRelativePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment