Fixes work item 26981.

[TFS Changeset #65996]
This commit is contained in:
codegecko
2010-05-06 14:06:58 +00:00
parent 4b92b3edf0
commit f84067e7ee

View File

@@ -796,44 +796,34 @@ namespace umbraco
}
Assembly appCodeAssembly;
try
{
if (Directory.GetFiles(GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "App_Code",
try {
if (Directory.Exists(GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "App_Code") {
if (Directory.GetFiles(GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "App_Code",
"*.*",
SearchOption.AllDirectories).Length > 0)
{
appCodeAssembly = Assembly.Load("__code");
Type[] appCodeType = appCodeAssembly.GetExportedTypes();
if (appCodeType.Length == 0)
{
Log.Add(LogTypes.System, Node.GetCurrent().Id, String.Format("Could not load types in App_Code ({0}) for XSLT extensions. Ensure you have used the public keyword to ensure class and method exposure.", appCodeAssembly.FullName));
}
else
{
// create an instance and add it to the extensions list
foreach (Type tp in appCodeType)
{
object[] tpAttributes = tp.GetCustomAttributes(typeof(XsltExtensionAttribute), true);
foreach (XsltExtensionAttribute tpAttribute in tpAttributes)
{
if (tpAttribute.Namespace != String.Empty)
{
extensions.Add(tpAttribute.Namespace, Activator.CreateInstance(tp));
}
else
{
extensions.Add(tp.FullName, Activator.CreateInstance(tp));
SearchOption.AllDirectories).Length > 0) {
appCodeAssembly = Assembly.Load("__code");
Type[] appCodeType = appCodeAssembly.GetExportedTypes();
if (appCodeType.Length == 0) {
Log.Add(LogTypes.System, Node.GetCurrent().Id, String.Format("Could not load types in App_Code ({0}) for XSLT extensions. Ensure you have used the public keyword to ensure class and method exposure.", appCodeAssembly.FullName));
} else {
// create an instance and add it to the extensions list
foreach (Type tp in appCodeType) {
object[] tpAttributes = tp.GetCustomAttributes(typeof(XsltExtensionAttribute), true);
foreach (XsltExtensionAttribute tpAttribute in tpAttributes) {
if (tpAttribute.Namespace != String.Empty) {
extensions.Add(tpAttribute.Namespace, Activator.CreateInstance(tp));
} else {
extensions.Add(tp.FullName, Activator.CreateInstance(tp));
}
}
}
}
}
} else {
Directory.CreateDirectory(GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + "App_Code");
}
}
catch (FileNotFoundException)
{ //Do nothing - just means there's nothing to load.
}
catch (Exception ex)
{
} catch (FileNotFoundException) { //Do nothing - just means there's nothing to load.
} catch (Exception ex) {
throw new Exception("Could not load App_Code classes for XSLT extensions.", ex);
}