private void LoadList() { lvwItemList.Items.Clear(); IAzManItem[] members = _Application.GetItems(_ItemType); foreach (IAzManItem member in members) { if ((_AuthItem == null) || (_AuthItem != null && member.Name != _AuthItem.Name)) { ListViewItem oItem = lvwItemList.Items.Add(member.Name); oItem.SubItems.Add(member.Description); oItem.SubItems.Add(member.ItemId.ToString()); } } lvwItemList.Sort(); }
/// <summary> /// Generate a CodeCompileUnit For NetSqlAzMan Check Access Helper Class /// </summary> /// <param name="nameSpace">The namespace</param> /// <param name="className">Name of the class.</param> /// <param name="rolesAllowed">if set to <c>true</c> [roles allowed].</param> /// <param name="tasksAllowed">if set to <c>true</c> [tasks allowed].</param> /// <param name="application">The IAzManApplication</param> /// <param name="language">The language.</param> /// <returns>CodeCompileUnit generated</returns> public static CodeCompileUnit GenerateCheckAccessHelperClass(string nameSpace, string className, bool rolesAllowed, bool tasksAllowed, IAzManApplication application, Language language) { CodeCompileUnit codeCompileUnit = new CodeCompileUnit(); CodeNamespace codeNamespace = null; codeNamespace = new CodeNamespace(string.Format("{0}", nameSpace)); CodeDomHelper.AddNamespaceHeaderComment(codeNamespace, new string[] { "------------------------------------------------------------------------------", " <auto-generated>", " This code was generated by NetSqlAzMan CodeDom.", " NetSqlAzMan - Andrea Ferendeles - http://netsqlazman.codeplex.com", " NetSqlAzMan Version: 3.6.0.15", " CLR Version: "+System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion, " <NetSqlAzMan-info>", " Store: "+CodeDomHelper.TransformToVariable(String.Empty, application.Store.Name, false), " Application: "+CodeDomHelper.TransformToVariable(String.Empty, application.Name, false), " Last update: "+DateTime.Now.ToString(), " </NetSqlAzMan-info>", " </auto-generated>", "------------------------------------------------------------------------------", "", "", "TODO: Add NetSqlAzMan.dll Assembly reference.", "", "", } ); CodeDomHelper.AddStandardNamespaces(codeNamespace); CodeDomHelper.AddNetSqlAzManNamespaces(codeNamespace); codeCompileUnit.Namespaces.Add(codeNamespace); #region Class Declaration CodeTypeDeclaration netSqlAzManHelperClass = new CodeTypeDeclaration(className); netSqlAzManHelperClass.IsPartial = true; netSqlAzManHelperClass.Attributes = MemberAttributes.Public; codeNamespace.Types.Add(netSqlAzManHelperClass); CodeDomHelper.AddXmlSummaryComment(netSqlAzManHelperClass, string.Format("NetSqlAzMan Check Access Helper Class for NetSqlAzMan '{0}' Application ", application.Name)); #endregion Class Declaration #region Constants CodeRegionDirective crdConstantsStart = new CodeRegionDirective(CodeRegionMode.Start, "Constants"); CodeMemberField storeNameConst = new CodeMemberField(typeof(string), "STORE_NAME"); storeNameConst.StartDirectives.Add(crdConstantsStart); storeNameConst.Attributes = MemberAttributes.FamilyOrAssembly | MemberAttributes.Const; storeNameConst.InitExpression = new CodePrimitiveExpression(application.Store.Name); CodeDomHelper.AddXmlSummaryComment(storeNameConst, "Store Name"); netSqlAzManHelperClass.Members.Add(storeNameConst); CodeMemberField applicationNameConst = new CodeMemberField(typeof(string), "APPLICATION_NAME"); applicationNameConst.Attributes = MemberAttributes.FamilyOrAssembly | MemberAttributes.Const; applicationNameConst.InitExpression = new CodePrimitiveExpression(application.Name); CodeDomHelper.AddXmlSummaryComment(applicationNameConst, "Application Name"); CodeRegionDirective crdConstantsEnd = new CodeRegionDirective(CodeRegionMode.End, "Constants"); netSqlAzManHelperClass.Members.Add(applicationNameConst); applicationNameConst.EndDirectives.Add(crdConstantsEnd); #endregion Constants #region Fields CodeRegionDirective crdFieldsStart = new CodeRegionDirective(CodeRegionMode.Start, "Fields"); CodeMemberField storageField = new CodeMemberField(typeof(IAzManStorage), "mStorage"); storageField.StartDirectives.Add(crdFieldsStart); storageField.Attributes = MemberAttributes.Family; CodeDomHelper.AddXmlSummaryComment(storageField, "NetSqlAzMan Storage reference."); netSqlAzManHelperClass.Members.Add(storageField); CodeMemberField windowsIdentityField = new CodeMemberField(typeof(WindowsIdentity), "windowsIdentity"); windowsIdentityField.Attributes = MemberAttributes.Family; CodeDomHelper.AddXmlSummaryComment(windowsIdentityField, "User Windows Principal Identity."); netSqlAzManHelperClass.Members.Add(windowsIdentityField); CodeRegionDirective crdFieldsEnd = new CodeRegionDirective(CodeRegionMode.End, "Fields"); windowsIdentityField.EndDirectives.Add(crdFieldsEnd); #endregion Fields #region Constructors { CodeConstructor constructor1 = new CodeConstructor(); netSqlAzManHelperClass.Members.Add(constructor1); constructor1.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Constructors")); constructor1.Attributes = MemberAttributes.Public; CodeDomHelper.AddXmlSummaryComment(constructor1, String.Format("Initializes a new instance of the <see cref=\"T:{0}\"/> class [Windows Users ONLY].", className)); constructor1.Comments.Add(new CodeCommentStatement("<param name=\"storageConnectionString\">The storage connection string.</param>", true)); constructor1.Comments.Add(new CodeCommentStatement("<param name=\"windowsIdentity\">The Windows Principal Identity.</param>", true)); constructor1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "storageConnectionString")); constructor1.Parameters.Add(new CodeParameterDeclarationExpression(typeof(WindowsIdentity), "windowsIdentity")); constructor1.Statements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), new CodeObjectCreateExpression(typeof(NetSqlAzMan.SqlAzManStorage), new CodeVariableReferenceExpression("storageConnectionString")))); constructor1.Statements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "windowsIdentity"), new CodeVariableReferenceExpression("windowsIdentity"))); } { CodeConstructor constructor2 = new CodeConstructor(); netSqlAzManHelperClass.Members.Add(constructor2); constructor2.Attributes = MemberAttributes.Public; CodeDomHelper.AddXmlSummaryComment(constructor2, String.Format("Initializes a new instance of the <see cref=\"T:{0}\"/> class [DB Users ONLY].", className)); constructor2.Comments.Add(new CodeCommentStatement("<param name=\"storageConnectionString\">The storage connection string.</param>", true)); constructor2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "storageConnectionString")); constructor2.Statements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), new CodeObjectCreateExpression(typeof(NetSqlAzMan.SqlAzManStorage), new CodeVariableReferenceExpression("storageConnectionString")))); constructor2.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Constructors")); } #endregion Constructors #region Enums IAzManItem[] roles = application.GetItems(ItemType.Role); IAzManItem[] tasks = application.GetItems(ItemType.Task); IAzManItem[] operations = application.GetItems(ItemType.Operation); CodeTypeDeclaration firstEnum = null; CodeTypeDeclaration lastEnum = null; if (rolesAllowed && roles.Length > 0) { CodeTypeDeclaration roleEnum = new CodeTypeDeclaration("Role"); if (firstEnum == null) firstEnum = roleEnum; lastEnum = roleEnum; roleEnum.IsEnum = true; netSqlAzManHelperClass.Members.Add(roleEnum); roleEnum.Attributes = MemberAttributes.Public; CodeDomHelper.AddXmlSummaryComment(roleEnum, "Roles Enumeration"); foreach (IAzManItem role in roles) { CodeMemberField cmf = new CodeMemberField(typeof(int), CodeDomHelper.TransformToVariable(String.Empty, role.Name, false)); CodeDomHelper.AddXmlSummaryComment(cmf, String.Format("Role {0}", role.Name)); roleEnum.Members.Add(cmf); } } if (tasksAllowed && tasks.Length > 0) { CodeTypeDeclaration taskEnum = new CodeTypeDeclaration("Task"); if (firstEnum == null) firstEnum = taskEnum; lastEnum = taskEnum; taskEnum.IsEnum = true; netSqlAzManHelperClass.Members.Add(taskEnum); taskEnum.Attributes = MemberAttributes.Public; CodeDomHelper.AddXmlSummaryComment(taskEnum, "Tasks Enumeration"); foreach (IAzManItem task in tasks) { CodeMemberField cmf = new CodeMemberField(typeof(int), CodeDomHelper.TransformToVariable(String.Empty, task.Name, false)); CodeDomHelper.AddXmlSummaryComment(cmf, String.Format("Task {0}", task.Name)); taskEnum.Members.Add(cmf); } } if (operations.Length > 0) { CodeTypeDeclaration operationsEnum = new CodeTypeDeclaration("Operation"); if (firstEnum == null) firstEnum = operationsEnum; lastEnum = operationsEnum; operationsEnum.IsEnum = true; netSqlAzManHelperClass.Members.Add(operationsEnum); operationsEnum.Attributes = MemberAttributes.Public; CodeDomHelper.AddXmlSummaryComment(operationsEnum, "Operations Enumeration"); foreach (IAzManItem operation in operations) { CodeMemberField cmf = new CodeMemberField(typeof(int), CodeDomHelper.TransformToVariable(String.Empty, operation.Name, false)); CodeDomHelper.AddXmlSummaryComment(cmf, String.Format("Operation {0}", operation.Name)); operationsEnum.Members.Add(cmf); } } if (firstEnum != null) firstEnum.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Enums")); if (lastEnum != null) lastEnum.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Enums")); #endregion Enums #region Properties CodeMemberProperty storageProperty = new CodeMemberProperty(); storageProperty.Name = "Storage"; netSqlAzManHelperClass.Members.Add(storageProperty); CodeDomHelper.AddXmlSummaryComment(storageProperty, "Gets the NetSqlAzMan Storage."); storageProperty.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Properties")); storageProperty.Attributes = MemberAttributes.Public; storageProperty.Type = new CodeTypeReference(typeof(IAzManStorage)); storageProperty.HasGet = true; storageProperty.HasSet = false; storageProperty.GetStatements.Add( new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "mStorage"))); storageProperty.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Properties")); #endregion Properties #region Methods #region OpenConnection CodeMemberMethod openConnectionMethod = new CodeMemberMethod(); netSqlAzManHelperClass.Members.Add(openConnectionMethod); openConnectionMethod.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Methods")); openConnectionMethod.Attributes = MemberAttributes.Public; openConnectionMethod.Name = "OpenConnection"; CodeDomHelper.AddXmlSummaryComment(openConnectionMethod, "Opens the connection"); openConnectionMethod.Statements.Add( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "mStorage"), "OpenConnection"))); #endregion OpenConnection #region CloseConnection CodeMemberMethod closeConnectionMethod = new CodeMemberMethod(); netSqlAzManHelperClass.Members.Add(closeConnectionMethod); closeConnectionMethod.Attributes = MemberAttributes.Public; closeConnectionMethod.Name = "CloseConnection"; CodeDomHelper.AddXmlSummaryComment(closeConnectionMethod, "Closes the connection"); closeConnectionMethod.Statements.Add( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "mStorage"), "CloseConnection"))); #endregion CloseConnection #region ItemName if (rolesAllowed && roles.Length > 0) { CodeMemberMethod itemNameForRole = new CodeMemberMethod(); CodeDomHelper.AddXmlSummaryComment(itemNameForRole, "Retrieve Item name from a Role Enum."); itemNameForRole.Comments.Add(new CodeCommentStatement("<param name=\"role\">The role.</param>", true)); itemNameForRole.Comments.Add(new CodeCommentStatement("<returns>The Role Name.</returns>", true)); netSqlAzManHelperClass.Members.Add(itemNameForRole); itemNameForRole.Name = "ItemName"; itemNameForRole.Attributes = MemberAttributes.Public; itemNameForRole.ReturnType = new CodeTypeReference(typeof(string)); itemNameForRole.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); //WORKAROUND: Switch in not implementes in CodeDom for (int i = 0; i < roles.Length; i++) { itemNameForRole.Statements.Add( new CodeConditionStatement( new CodeBinaryOperatorExpression( new CodeVariableReferenceExpression("role"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("Role"), CodeDomHelper.TransformToVariable(String.Empty, roles[i].Name, false ))), new CodeMethodReturnStatement(new CodePrimitiveExpression(roles[i].Name)))); } itemNameForRole.Statements.Add( new CodeThrowExceptionStatement( new CodeObjectCreateExpression(typeof(ArgumentException), new CodePrimitiveExpression("Unknown Role name"), new CodePrimitiveExpression("role") ))); } if (tasksAllowed && tasks.Length > 0) { CodeMemberMethod itemNameForTask = new CodeMemberMethod(); CodeDomHelper.AddXmlSummaryComment(itemNameForTask, "Retrieve Item name from a Task Enum."); itemNameForTask.Comments.Add(new CodeCommentStatement("<param name=\"task\">The task.</param>", true)); itemNameForTask.Comments.Add(new CodeCommentStatement("<returns>The Task Name.</returns>", true)); netSqlAzManHelperClass.Members.Add(itemNameForTask); itemNameForTask.Name = "ItemName"; itemNameForTask.Attributes = MemberAttributes.Public; itemNameForTask.ReturnType = new CodeTypeReference(typeof(string)); itemNameForTask.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); //WORKAROUND: Switch in not implementes in CodeDom for (int i = 0; i < tasks.Length; i++) { itemNameForTask.Statements.Add( new CodeConditionStatement( new CodeBinaryOperatorExpression( new CodeVariableReferenceExpression("task"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("Task"), CodeDomHelper.TransformToVariable(String.Empty, tasks[i].Name, false ))), new CodeMethodReturnStatement(new CodePrimitiveExpression(tasks[i].Name)))); } itemNameForTask.Statements.Add( new CodeThrowExceptionStatement( new CodeObjectCreateExpression(typeof(ArgumentException), new CodePrimitiveExpression("Unknown Task name"), new CodePrimitiveExpression("task") ))); } CodeMemberMethod itemNameForOperation = new CodeMemberMethod(); CodeDomHelper.AddXmlSummaryComment(itemNameForOperation, "Retrieve Item name from a Operation Enum."); itemNameForOperation.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The operation.</param>", true)); itemNameForOperation.Comments.Add(new CodeCommentStatement("<returns>The Operation Name.</returns>", true)); netSqlAzManHelperClass.Members.Add(itemNameForOperation); itemNameForOperation.Name = "ItemName"; itemNameForOperation.Attributes = MemberAttributes.Public; itemNameForOperation.ReturnType = new CodeTypeReference(typeof(string)); itemNameForOperation.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); //WORKAROUND: Switch in not implementes in CodeDom for (int i = 0; i < operations.Length; i++) { itemNameForOperation.Statements.Add( new CodeConditionStatement( new CodeBinaryOperatorExpression( new CodeVariableReferenceExpression("operation"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("Operation"), CodeDomHelper.TransformToVariable(String.Empty, operations[i].Name, false ))), new CodeMethodReturnStatement(new CodePrimitiveExpression(operations[i].Name)))); } itemNameForOperation.Statements.Add( new CodeThrowExceptionStatement( new CodeObjectCreateExpression(typeof(ArgumentException), new CodePrimitiveExpression("Unknown Operation name"), new CodePrimitiveExpression("operation") ))); #endregion ItemName #region CheckAccess { { CodeMemberMethod checkAccessMethod = new CodeMemberMethod(); checkAccessMethod.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod); checkAccessMethod.Attributes = MemberAttributes.Family; checkAccessMethod.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); CodeParameterDeclarationExpression pKeyValue = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod.Parameters.Add(pKeyValue); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "windowsIdentity"), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), new CodeVariableReferenceExpression("contextParameters") ))); } { CodeMemberMethod checkAccessMethod2 = new CodeMemberMethod(); checkAccessMethod2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod2); checkAccessMethod2.Attributes = MemberAttributes.Family; checkAccessMethod2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); CodeParameterDeclarationExpression pKeyValue1bis = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue1bis.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod2.Parameters.Add(pKeyValue1bis); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB User Name.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "GetDBUser", new CodeVariableReferenceExpression("dbUserName")), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod checkAccessMethod3 = new CodeMemberMethod(); checkAccessMethod3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod3); checkAccessMethod3.Attributes = MemberAttributes.Family; checkAccessMethod3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); CodeParameterDeclarationExpression pKeyValue1tris = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue1tris.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod3.Parameters.Add(pKeyValue1tris); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod3, "Checks the access [FOR custom SID ONLY]."); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "GetDBUser", new CodeVariableReferenceExpression("customSID")), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), new CodeVariableReferenceExpression("contextParameters")))); } } //With Attributes { { CodeMemberMethod checkAccessMethod = new CodeMemberMethod(); checkAccessMethod.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod); checkAccessMethod.Attributes = MemberAttributes.Family; checkAccessMethod.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; checkAccessMethod.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod.Parameters.Add(pKeyValue); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); //new checkAccessMethod.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethod.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "windowsIdentity"), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters") ))); } { CodeMemberMethod checkAccessMethod2 = new CodeMemberMethod(); checkAccessMethod2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod2); checkAccessMethod2.Attributes = MemberAttributes.Family; checkAccessMethod2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); checkAccessMethod2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; checkAccessMethod2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue1bis = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue1bis.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod2.Parameters.Add(pKeyValue1bis); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB User Name.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); //new checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethod2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "GetDBUser", new CodeVariableReferenceExpression("dbUserName")), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod checkAccessMethod3 = new CodeMemberMethod(); checkAccessMethod3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethod3); checkAccessMethod3.Attributes = MemberAttributes.Family; checkAccessMethod3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "itemName")); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); checkAccessMethod3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(bool), "operationsOnly")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; checkAccessMethod3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue1tris = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue1tris.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethod3.Parameters.Add(pKeyValue1tris); CodeDomHelper.AddXmlSummaryComment(checkAccessMethod3, "Checks the access [FOR Custom SID ONLY]."); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"itemName\">The Item Name.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"operationsOnly\">if set to <c>true</c> checks the access for operations only.</param>", true)); //new checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethod3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); checkAccessMethod3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "CheckAccess", new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "STORE_NAME"), new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(className), "APPLICATION_NAME"), new CodeVariableReferenceExpression("itemName"), new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "mStorage"), "GetDBUser", new CodeVariableReferenceExpression("customSID")), new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("DateTime"), "Now"), new CodeVariableReferenceExpression("operationsOnly"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } } #endregion CheckAccess #region GetAuthorizationType if (rolesAllowed && roles.Length > 0) { { { CodeMemberMethod getAuthorizationTypeMethodForRole = new CodeMemberMethod(); getAuthorizationTypeMethodForRole.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole); getAuthorizationTypeMethodForRole.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); CodeParameterDeclarationExpression pKeyValue2bis = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue2bis.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole.Parameters.Add(pKeyValue2bis); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForRole2 = new CodeMemberMethod(); getAuthorizationTypeMethodForRole2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole2); getAuthorizationTypeMethodForRole2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); getAuthorizationTypeMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue2 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue2.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole2.Parameters.Add(pKeyValue2); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForRole3 = new CodeMemberMethod(); getAuthorizationTypeMethodForRole3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole3); getAuthorizationTypeMethodForRole3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); getAuthorizationTypeMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole3, "Gets the Authorization Type [FOR Custom SID ONLY]."); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } } //With Attributes { { CodeMemberMethod getAuthorizationTypeMethodForRole = new CodeMemberMethod(); getAuthorizationTypeMethodForRole.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole); getAuthorizationTypeMethodForRole.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; getAuthorizationTypeMethodForRole.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue2bis = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue2bis.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole.Parameters.Add(pKeyValue2bis); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); //new getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForRole2 = new CodeMemberMethod(); getAuthorizationTypeMethodForRole2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole2); getAuthorizationTypeMethodForRole2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); getAuthorizationTypeMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; getAuthorizationTypeMethodForRole2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue2 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue2.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole2.Parameters.Add(pKeyValue2); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForRole3 = new CodeMemberMethod(); getAuthorizationTypeMethodForRole3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForRole3); getAuthorizationTypeMethodForRole3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForRole3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); getAuthorizationTypeMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; getAuthorizationTypeMethodForRole3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForRole3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForRole3, "Gets the Authorization Type [FOR Custom SID ONLY]."); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); //new getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForRole3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForRole3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("role")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } } } if (tasksAllowed && tasks.Length > 0) { { { CodeMemberMethod getAuthorizationTypeMethodForTask = new CodeMemberMethod(); getAuthorizationTypeMethodForTask.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask); getAuthorizationTypeMethodForTask.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForTask2 = new CodeMemberMethod(); getAuthorizationTypeMethodForTask2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask2); getAuthorizationTypeMethodForTask2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); getAuthorizationTypeMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue4 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue4.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask2.Parameters.Add(pKeyValue4); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForTask3 = new CodeMemberMethod(); getAuthorizationTypeMethodForTask3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask3); getAuthorizationTypeMethodForTask3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); getAuthorizationTypeMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask3, "Gets the Authorization Type [FOR Custom SID ONLY]."); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The Custom SID.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(false), new CodeVariableReferenceExpression("contextParameters")))); } } //With Attributes { { CodeMemberMethod getAuthorizationTypeMethodForTask = new CodeMemberMethod(); getAuthorizationTypeMethodForTask.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask); getAuthorizationTypeMethodForTask.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; getAuthorizationTypeMethodForTask.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); //new getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForTask2 = new CodeMemberMethod(); getAuthorizationTypeMethodForTask2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask2); getAuthorizationTypeMethodForTask2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); getAuthorizationTypeMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; getAuthorizationTypeMethodForTask2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue4 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue4.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask2.Parameters.Add(pKeyValue4); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForTask3 = new CodeMemberMethod(); getAuthorizationTypeMethodForTask3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForTask3); getAuthorizationTypeMethodForTask3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForTask3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); getAuthorizationTypeMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; getAuthorizationTypeMethodForTask3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForTask3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForTask3, "Gets the Authorization Type [FOR custom SID ONLY]."); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The Custom SID.</param>", true)); //new getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForTask3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForTask3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("task")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(false), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } } } { { CodeMemberMethod getAuthorizationTypeMethodForOperation = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation); getAuthorizationTypeMethodForOperation.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); CodeParameterDeclarationExpression pKeyValue5 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue5.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation.Parameters.Add(pKeyValue5); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodePrimitiveExpression(true), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForOperation2 = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation2); getAuthorizationTypeMethodForOperation2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); getAuthorizationTypeMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue6 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue6.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation2.Parameters.Add(pKeyValue6); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(true), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForOperation3 = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation3); getAuthorizationTypeMethodForOperation3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); getAuthorizationTypeMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation3, "Gets the Authorization Type [FOR Custom SID ONLY]."); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The Custom SID.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(true), new CodeVariableReferenceExpression("contextParameters")))); } } //With Attributes { { CodeMemberMethod getAuthorizationTypeMethodForOperation = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation); getAuthorizationTypeMethodForOperation.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; getAuthorizationTypeMethodForOperation.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue5 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue5.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation.Parameters.Add(pKeyValue5); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation, "Gets the Authorization Type [FOR Windows Users ONLY]."); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); //new getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodePrimitiveExpression(true), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForOperation2 = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation2.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation2); getAuthorizationTypeMethodForOperation2.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation2.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); getAuthorizationTypeMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; getAuthorizationTypeMethodForOperation2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue6 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue6.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation2.Parameters.Add(pKeyValue6); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation2, "Gets the Authorization Type [FOR DB Users ONLY]."); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation2.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation2.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodeVariableReferenceExpression("dbUserName"), new CodePrimitiveExpression(true), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } { CodeMemberMethod getAuthorizationTypeMethodForOperation3 = new CodeMemberMethod(); getAuthorizationTypeMethodForOperation3.Name = "GetAuthorizationType"; netSqlAzManHelperClass.Members.Add(getAuthorizationTypeMethodForOperation3); getAuthorizationTypeMethodForOperation3.Attributes = MemberAttributes.Public; getAuthorizationTypeMethodForOperation3.ReturnType = new CodeTypeReference(typeof(AuthorizationType)); getAuthorizationTypeMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); getAuthorizationTypeMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; getAuthorizationTypeMethodForOperation3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); getAuthorizationTypeMethodForOperation3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(getAuthorizationTypeMethodForOperation3, "Gets the Authorization Type [FOR custom SID ONLY]."); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The Custom SID.</param>", true)); //new getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); getAuthorizationTypeMethodForOperation3.Comments.Add(new CodeCommentStatement("<returns>The Authorization Type [AllowWithDelegation, Allow, Deny, Neutral].</returns>", true)); getAuthorizationTypeMethodForOperation3.Statements.Add( new CodeMethodReturnStatement( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "CheckAccess", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "ItemName", new CodeVariableReferenceExpression("operation")), new CodeVariableReferenceExpression("customSID"), new CodePrimitiveExpression(true), //new language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); } } #endregion GetAuthorizationType #region CheckAccess if (rolesAllowed && roles.Length > 0) { { { CodeMemberMethod checkAccessMethodForRole = new CodeMemberMethod(); checkAccessMethodForRole.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole); checkAccessMethodForRole.Attributes = MemberAttributes.Public; checkAccessMethodForRole.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); CodeParameterDeclarationExpression pKeyValue7 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue7.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole.Parameters.Add(pKeyValue7); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForRole2 = new CodeMemberMethod(); checkAccessMethodForRole2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole2); checkAccessMethodForRole2.Attributes = MemberAttributes.Public; checkAccessMethodForRole2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); checkAccessMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue8 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue8.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole2.Parameters.Add(pKeyValue8); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), new CodeVariableReferenceExpression("dbUserName"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForRole3 = new CodeMemberMethod(); checkAccessMethodForRole3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole3); checkAccessMethodForRole3.Attributes = MemberAttributes.Public; checkAccessMethodForRole3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); checkAccessMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole3, "Checks the access [FOR custom SID ONLY]."); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), new CodeVariableReferenceExpression("customSID"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } } //With Attributes { { CodeMemberMethod checkAccessMethodForRole = new CodeMemberMethod(); checkAccessMethodForRole.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole); checkAccessMethodForRole.Attributes = MemberAttributes.Public; checkAccessMethodForRole.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; checkAccessMethodForRole.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue7 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue7.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole.Parameters.Add(pKeyValue7); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); //new checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForRole2 = new CodeMemberMethod(); checkAccessMethodForRole2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole2); checkAccessMethodForRole2.Attributes = MemberAttributes.Public; checkAccessMethodForRole2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); checkAccessMethodForRole2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; checkAccessMethodForRole2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue8 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue8.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole2.Parameters.Add(pKeyValue8); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), new CodeVariableReferenceExpression("dbUserName"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForRole3 = new CodeMemberMethod(); checkAccessMethodForRole3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForRole3); checkAccessMethodForRole3.Attributes = MemberAttributes.Public; checkAccessMethodForRole3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression("Role", "role")); checkAccessMethodForRole3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; checkAccessMethodForRole3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue8 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue8.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForRole3.Parameters.Add(pKeyValue8); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForRole3, "Checks the access [FOR Custom SID ONLY]."); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"role\">The Role.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); //new checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForRole3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForRole3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("role"), new CodeVariableReferenceExpression("customSID"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForRole3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } } } if (tasksAllowed && tasks.Length > 0) { { { CodeMemberMethod checkAccessMethodForTask = new CodeMemberMethod(); checkAccessMethodForTask.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask); checkAccessMethodForTask.Attributes = MemberAttributes.Public; checkAccessMethodForTask.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); CodeParameterDeclarationExpression pKeyValue9 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue9.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask.Parameters.Add(pKeyValue9); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForTask2 = new CodeMemberMethod(); checkAccessMethodForTask2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask2); checkAccessMethodForTask2.Attributes = MemberAttributes.Public; checkAccessMethodForTask2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); checkAccessMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue10 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue10.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask2.Parameters.Add(pKeyValue10); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), new CodeVariableReferenceExpression("dbUserName"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForTask3 = new CodeMemberMethod(); checkAccessMethodForTask3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask3); checkAccessMethodForTask3.Attributes = MemberAttributes.Public; checkAccessMethodForTask3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); checkAccessMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask3, "Checks the access [FOR Custom SID ONLY]."); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The Custom SID.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), new CodeVariableReferenceExpression("customSID"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } } //With Attributes { { CodeMemberMethod checkAccessMethodForTask = new CodeMemberMethod(); checkAccessMethodForTask.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask); checkAccessMethodForTask.Attributes = MemberAttributes.Public; checkAccessMethodForTask.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; checkAccessMethodForTask.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue9 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue9.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask.Parameters.Add(pKeyValue9); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); //new checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForTask2 = new CodeMemberMethod(); checkAccessMethodForTask2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask2); checkAccessMethodForTask2.Attributes = MemberAttributes.Public; checkAccessMethodForTask2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); checkAccessMethodForTask2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; checkAccessMethodForTask2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue10 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue10.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask2.Parameters.Add(pKeyValue10); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), new CodeVariableReferenceExpression("dbUserName"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForTask3 = new CodeMemberMethod(); checkAccessMethodForTask3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForTask3); checkAccessMethodForTask3.Attributes = MemberAttributes.Public; checkAccessMethodForTask3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression("Task", "task")); checkAccessMethodForTask3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes3 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes3.Direction = FieldDirection.Out; checkAccessMethodForTask3.Parameters.Add(attributes3); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForTask3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForTask3, "Checks the access [FOR Custom SID ONLY]."); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"task\">The Task.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); //new checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForTask3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForTask3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("task"), new CodeVariableReferenceExpression("customSID"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForTask3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } } } { { CodeMemberMethod checkAccessMethodForOperation = new CodeMemberMethod(); checkAccessMethodForOperation.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation); checkAccessMethodForOperation.Attributes = MemberAttributes.Public; checkAccessMethodForOperation.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); CodeParameterDeclarationExpression pKeyValue11 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue11.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation.Parameters.Add(pKeyValue11); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForOperation2 = new CodeMemberMethod(); checkAccessMethodForOperation2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation2); checkAccessMethodForOperation2.Attributes = MemberAttributes.Public; checkAccessMethodForOperation2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); checkAccessMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); CodeParameterDeclarationExpression pKeyValue12 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue12.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation2.Parameters.Add(pKeyValue12); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), new CodeVariableReferenceExpression("dbUserName"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForOperation3 = new CodeMemberMethod(); checkAccessMethodForOperation3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation3); checkAccessMethodForOperation3.Attributes = MemberAttributes.Public; checkAccessMethodForOperation3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); checkAccessMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation3, "Checks the access [FOR custom SID ONLY]."); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), new CodeVariableReferenceExpression("customSID"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } } //With Attributes { { CodeMemberMethod checkAccessMethodForOperation = new CodeMemberMethod(); checkAccessMethodForOperation.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation); checkAccessMethodForOperation.Attributes = MemberAttributes.Public; checkAccessMethodForOperation.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); //new CodeParameterDeclarationExpression attributes = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes.Direction = FieldDirection.Out; checkAccessMethodForOperation.Parameters.Add(attributes); CodeParameterDeclarationExpression pKeyValue11 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue11.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation.Parameters.Add(pKeyValue11); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation, "Checks the access [FOR Windows Users ONLY]."); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); //new checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForOperation2 = new CodeMemberMethod(); checkAccessMethodForOperation2.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation2); checkAccessMethodForOperation2.Attributes = MemberAttributes.Public; checkAccessMethodForOperation2.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); checkAccessMethodForOperation2.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "dbUserName")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; checkAccessMethodForOperation2.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue12 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue12.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation2.Parameters.Add(pKeyValue12); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation2, "Checks the access [FOR DB Users ONLY]."); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"dbUserName\">The DB UserName.</param>", true)); //new checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation2.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation2.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), new CodeVariableReferenceExpression("dbUserName"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation2.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); } { CodeMemberMethod checkAccessMethodForOperation3 = new CodeMemberMethod(); checkAccessMethodForOperation3.Name = "CheckAccess"; netSqlAzManHelperClass.Members.Add(checkAccessMethodForOperation3); checkAccessMethodForOperation3.Attributes = MemberAttributes.Public; checkAccessMethodForOperation3.ReturnType = new CodeTypeReference(typeof(bool)); checkAccessMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression("Operation", "operation")); checkAccessMethodForOperation3.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IAzManSid), "customSID")); //new CodeParameterDeclarationExpression attributes2 = new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(List<KeyValuePair<string, string>>)), "attributes"); attributes2.Direction = FieldDirection.Out; checkAccessMethodForOperation3.Parameters.Add(attributes2); CodeParameterDeclarationExpression pKeyValue3 = new CodeParameterDeclarationExpression(language == Language.CSharp ? "KeyValuePair<string, object>[]" : "KeyValuePair(Of String, Object)()", "contextParameters"); pKeyValue3.CustomAttributes.Add(new CodeAttributeDeclaration("System.ParamArrayAttribute")); checkAccessMethodForOperation3.Parameters.Add(pKeyValue3); CodeDomHelper.AddXmlSummaryComment(checkAccessMethodForOperation3, "Checks the access [FOR custom SID ONLY]."); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"operation\">The Operation.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"customSID\">The custom SID.</param>", true)); //new checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"attributes\">Retrieved attributes.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<param name=\"contextParameters\">Context Parameters for Biz Rules.</param>", true)); checkAccessMethodForOperation3.Comments.Add(new CodeCommentStatement("<returns>True for Access Granted, False for Access Denied.</returns>", true)); checkAccessMethodForOperation3.Statements.Add(new CodeVariableDeclarationStatement(typeof(AuthorizationType), "result", new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetAuthorizationType", new CodeVariableReferenceExpression("operation"), new CodeVariableReferenceExpression("customSID"), language == Language.CSharp ? new CodeVariableReferenceExpression("out attributes") : new CodeVariableReferenceExpression("attributes"), new CodeVariableReferenceExpression("contextParameters")))); checkAccessMethodForOperation3.Statements.Add( new CodeMethodReturnStatement( new CodeBinaryOperatorExpression( new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "AllowWithDelegation")), CodeBinaryOperatorType.BooleanOr, new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression("result"), CodeBinaryOperatorType.ValueEquality, new CodeFieldReferenceExpression(new CodeVariableReferenceExpression("AuthorizationType"), "Allow")) ))); checkAccessMethodForOperation3.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Methods")); } } #endregion CheckAccess #endregion Methods return codeCompileUnit; }
/// <summary> /// Generates the item constants. /// </summary> /// <param name="nameSpace">The name space.</param> /// <param name="rolesAllowed">if set to <c>true</c> [roles allowed].</param> /// <param name="tasksAllowed">if set to <c>true</c> [tasks allowed].</param> /// <param name="application">The application.</param> /// <param name="language">The language.</param> /// <returns></returns> public static CodeCompileUnit GenerateItemConstants(string nameSpace, bool rolesAllowed, bool tasksAllowed, IAzManApplication application, Language language) { CodeCompileUnit codeCompileUnit = new CodeCompileUnit(); CodeNamespace codeNamespace = null; codeNamespace = new CodeNamespace(string.Format("{0}", nameSpace)); CodeDomHelper.AddNamespaceHeaderComment(codeNamespace, new string[] { "------------------------------------------------------------------------------", " <auto-generated>", " This code was generated by NetSqlAzMan CodeDom.", " NetSqlAzMan - Andrea Ferendeles - http://netsqlazman.codeplex.com", " NetSqlAzMan Version: 3.6.0.15", " CLR Version: "+System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion, " <NetSqlAzMan-info>", " Store: "+CodeDomHelper.TransformToVariable(String.Empty, application.Store.Name, false), " Application: "+CodeDomHelper.TransformToVariable(String.Empty, application.Name, false), " Last update: "+DateTime.Now.ToString(), " </NetSqlAzMan-info>", " </auto-generated>", "------------------------------------------------------------------------------", "", } ); codeNamespace.Imports.Add(new CodeNamespaceImport("System")); codeCompileUnit.Namespaces.Add(codeNamespace); ItemType itemType = ItemType.Role; while (true) { if (itemType == ItemType.Role && rolesAllowed || itemType == ItemType.Task && tasksAllowed || itemType == ItemType.Operation) { IAzManItem[] items = application.GetItems(itemType); if (items.Length > 0) { #region Class Declaration string className = itemType.ToString().ToUpper(); CodeTypeDeclaration netSqlAzManHelperClass = new CodeTypeDeclaration(className); netSqlAzManHelperClass.IsPartial = true; netSqlAzManHelperClass.Attributes = MemberAttributes.Public; codeNamespace.Types.Add(netSqlAzManHelperClass); CodeDomHelper.AddXmlSummaryComment(netSqlAzManHelperClass, string.Format("NetSqlAzMan {0} Helper Class for NetSqlAzMan '{1}' Application ", className.ToUpper(), application.Name)); #endregion Class Declaration foreach (IAzManItem item in items) { CodeMemberField itemNameConst = new CodeMemberField(typeof(string), CodeDomHelper.TransformToVariable(String.Empty, item.Name, true)); itemNameConst.Attributes = MemberAttributes.Public | MemberAttributes.Const; itemNameConst.InitExpression = new CodePrimitiveExpression(item.Name); CodeDomHelper.AddXmlSummaryComment(itemNameConst, String.Format("{0} '{1}'", className, item.Name)); netSqlAzManHelperClass.Members.Add(itemNameConst); } } } if (itemType == ItemType.Role) itemType = ItemType.Task; else if (itemType == ItemType.Task) itemType = ItemType.Operation; else if (itemType == ItemType.Operation) break; } return codeCompileUnit; }