Skip to content
Permalink
Browse files

Enterprise Library 6 feature (#474)

* EntLib 6 upgrade

Adding the ability to use Enterprise Library 6 for the data access layer.

Also includes a couple grammer fixes, and a formatting fix for the html report that gets generated.

* Deepload with LoadCollections fix

When deeploading the new LoadCollections was not being correctly honored.

* Replace tabs with spaces

Formatting modifications
  • Loading branch information...
jeremeguenther authored and niemyjski committed Jun 11, 2019
1 parent 00b8e4b commit 6d18f3882a8b4f08108a225aa848450be11a019c
@@ -0,0 +1,45 @@
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Src="..\..\TemplateLib\CommonSqlCode.cs" Inherits="MoM.Templates.CommonSqlCode" Description="" Debug="True" ResponseEncoding="UTF-8" NoWarn="0108,0618,1572,1573,1574,0162,2002" %>

<%@ Property Name="WebsiteNameSpace" Type="System.String" Category="Data" Description="Website Namespace." %>
<%@ Property Name="UseWebAppProject" Type="System.Boolean" Default="false" Category="06b. Website - Advanced" Description="Indicates if a Web Application Project file should be generated." %>
<%@ Property Name="EntLibVersion" Type="MoM.Templates.EntLibVersion" Default="v5_0" Category="02. Framework Generation - Optional" Description="Indicates the Enterprise Library version to use. Options include v3, v5, and v6" %>

<%@ Assembly Name="SchemaExplorer" %>
<%@ Assembly Name="System.Design" %>
<%@ Import Namespace="SchemaExplorer" %>
#region Using Directives

using System;
<% if (EntLibVersion == MoM.Templates.EntLibVersion.v6_0) { %>
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Logging;
<% } %>

#endregion

namespace <%= WebsiteNameSpace %>
{
<% if ( UseWebAppProject ) { %>
[CLSCompliant(false)]
<% } %>
public class Global : System.Web.HttpApplication
{
/// <summary>
/// Configuration for starting up the application
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Start(object sender, EventArgs e)
{
<% if (EntLibVersion == MoM.Templates.EntLibVersion.v6_0) { %>
// configure logging for Enterprise Library 6
IConfigurationSource config = ConfigurationSourceFactory.Create();
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
Logger.SetLogWriter(new LogWriterFactory().Create());
ExceptionManager exManager = factory.CreateManager();
ExceptionPolicy.SetExceptionManager(factory.CreateManager());
<% } %>
}
}
}
@@ -8,6 +8,7 @@
<%@ Property Name="DALNameSpace" Optional="False" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Assembly Name="SchemaExplorer" %>
#region Using directives

using System;
using System.ComponentModel;
using System.Security;
@@ -17,7 +18,6 @@ using System.Web.Profile;
using <%= BLLNameSpace %>;
using <%= DALNameSpace %>;

using Microsoft.Practices.EnterpriseLibrary.Security;
#endregion Using directives

namespace <%=NameSpace%>
@@ -8,6 +8,7 @@
<%@ Property Name="DALNameSpace" Optional="False" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Assembly Name="SchemaExplorer" %>
#region Using directives

using System;
using System.ComponentModel;
using System.Security;
@@ -17,7 +18,6 @@ using System.Web.Profile;
using <%= BLLNameSpace %>;
using <%= DALNameSpace %>;

using Microsoft.Practices.EnterpriseLibrary.Security;
#endregion Using directives

namespace <%=NameSpace%>
@@ -6,8 +6,10 @@
<%@ Property Name="NameSpace" Optional="False" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Property Name="BLLNameSpace" Optional="False" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Property Name="DALNameSpace" Optional="False" Type="System.String" Category="Style" Description="Object Namespace." %>
<%@ Property Name="EntLibVersion" Type="MoM.Templates.EntLibVersion" Default="v5_0" Category="02. Framework Generation - Optional" Description="Indicates the Enterprise Library version to use. Options include v2, v3, v3.1 and v4" %>
<%@ Assembly Name="SchemaExplorer" %>
#region Using directives

using System;
using System.ComponentModel;
using System.Security;
@@ -16,8 +18,9 @@ using System.Security.Principal;
using System.Web.Profile;
using <%= BLLNameSpace %>;
using <%= DALNameSpace %>;

<% if(EntLibVersion == MoM.Templates.EntLibVersion.v3_1 || EntLibVersion == MoM.Templates.EntLibVersion.v5_0) { %>
using Microsoft.Practices.EnterpriseLibrary.Security;
<% } %>
#endregion Using directives

namespace <%=NameSpace%>
@@ -29,13 +32,17 @@ namespace <%=NameSpace%>
public partial class SecurityContextBase<Entity> where Entity : IEntity, new()
{
#region Fields

private object profile = null;
private IIdentity identity = null;
private IPrincipal principal = null;
private IAuthorizationProvider ruleProvider = null;
//private ISecurityCacheProvider securityCacheProvider = null;
private static readonly string ruleProviderKey = "NetTiers.RuleProvider";
private static object syncObject = new object();
<% if(EntLibVersion == MoM.Templates.EntLibVersion.v3_1 || EntLibVersion == MoM.Templates.EntLibVersion.v5_0) { %>
private IAuthorizationProvider ruleProvider = null;
//private ISecurityCacheProvider securityCacheProvider = null;
<% } %>

#endregion Fields

#region Properties
@@ -66,6 +73,7 @@ namespace <%=NameSpace%>
set { principal = value; }
}

<% if(EntLibVersion == MoM.Templates.EntLibVersion.v3_1 || EntLibVersion == MoM.Templates.EntLibVersion.v5_0) { %>
/// <summary>
/// The Current Authorization Rule Provider
/// </summary>
@@ -89,9 +97,12 @@ namespace <%=NameSpace%>
}
}
}
#endregion Properties
<% } %>

#endregion Properties

#region Constructors

/// <summary>
/// Initializes a new instance of the SecurityContext class.
/// </summary>
@@ -100,14 +111,17 @@ namespace <%=NameSpace%>
this.Identity = System.Threading.Thread.CurrentPrincipal.Identity;
this.Principal = System.Threading.Thread.CurrentPrincipal;
}

#endregion Constructors

#region Public methods

/// <summary>
/// Determine whether user is authorized for the rule based on the rule provider
/// </summary>
public virtual bool IsAuthorized(string ruleToCheck)
{
{
<% if(EntLibVersion == MoM.Templates.EntLibVersion.v3_1 || EntLibVersion == MoM.Templates.EntLibVersion.v5_0) { %>
try
{
if (ConnectionScope.Current.DataProvider.EnableMethodAuthorization)
@@ -120,9 +134,11 @@ namespace <%=NameSpace%>
//Method has yet to be configured in config file
//throw;
}
<% } %>

return true;
}

#endregion Public methods
}
}

0 comments on commit 6d18f38

Please sign in to comment.
You can’t perform that action at this time.