public void InvalidRegionMode ()
		{
			CodeRegionDirective crd = new CodeRegionDirective (
				(CodeRegionMode) int.MaxValue, "mono");
			Assert.AreEqual (int.MaxValue, (int) crd.RegionMode, "#1");
			crd.RegionMode = (CodeRegionMode) int.MinValue;
			Assert.AreEqual (int.MinValue, (int) crd.RegionMode, "#2");
		}
示例#2
0
		public void Constructor1_Deny_Unrestricted ()
		{
			CodeRegionDirective crd = new CodeRegionDirective (CodeRegionMode.Start, "mono");
			Assert.AreEqual (CodeRegionMode.Start, crd.RegionMode, "RegionMode");
			crd.RegionMode = CodeRegionMode.End;
			Assert.AreEqual ("mono", crd.RegionText, "RegionText");
			crd.RegionText = String.Empty;
		}
示例#3
0
		public void Constructor0_Deny_Unrestricted ()
		{
			CodeRegionDirective crd = new CodeRegionDirective ();
			Assert.AreEqual (CodeRegionMode.None, crd.RegionMode, "RegionMode");
			crd.RegionMode = CodeRegionMode.Start;
			Assert.AreEqual (String.Empty, crd.RegionText, "RegionText");
			crd.RegionText = "mono";
		}
		public void Constructor1 () {
			string regionText = "mono";
			CodeRegionMode regionMode = CodeRegionMode.Start;

			CodeRegionDirective crd = new CodeRegionDirective (regionMode, 
				regionText);
			Assert.AreEqual (regionMode, crd.RegionMode, "#1");
			Assert.IsNotNull (crd.RegionText, "#2");
			Assert.AreSame (regionText, crd.RegionText, "#3");

			crd = new CodeRegionDirective (regionMode, (string) null);
			Assert.AreEqual (regionMode, crd.RegionMode, "#4");
			Assert.IsNotNull (crd.RegionText, "#5");
			Assert.AreEqual (string.Empty, crd.RegionText, "#6");
		}
		public void Constructor0 ()
		{
			CodeRegionDirective crd = new CodeRegionDirective ();

			Assert.AreEqual (CodeRegionMode.None, crd.RegionMode, "#1");
			Assert.IsNotNull (crd.RegionText, "#2");
			Assert.AreEqual (string.Empty, crd.RegionText, "#3");

			crd.RegionText = null;
			Assert.IsNotNull (crd.RegionText, "#4");
			Assert.AreEqual (string.Empty, crd.RegionText, "#5");

			string regionText = "mono";
			crd.RegionText = regionText;
			Assert.AreSame (regionText, crd.RegionText, "#6");
		}
示例#6
0
 private static void ValidateRegionDirective(CodeRegionDirective e) {
     if (e.RegionText.IndexOfAny(newLineChars) != -1)
         throw new ArgumentException(SR.GetString(SR.InvalidRegion, e.RegionText));
 }
示例#7
0
		void GenerateCodeRegionDirective (CodeRegionDirective region)
		{
			switch (region.RegionMode) {
				case CodeRegionMode.Start:
					Output.Write ("#region ");
					Output.WriteLine (region.RegionText);
					return;
				case CodeRegionMode.End:
					Output.WriteLine ("#endregion");
					return;
			}
		}
示例#8
0
        // Create a CodeDOM graph.
        static void CreateGraph(CodeCompileUnit cu)
        {
            cu.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start,
                                                           "Compile Unit Region"));
            cu.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End,
                                                         string.Empty));
            CodeChecksumPragma pragma1 = new CodeChecksumPragma();

            pragma1.FileName            = "c:\\temp\\test\\OuterLinePragma.txt";
            pragma1.ChecksumAlgorithmId = HashMD5;
            pragma1.ChecksumData        = new byte[] { 0xAA, 0xAA };
            cu.StartDirectives.Add(pragma1);
            CodeChecksumPragma pragma2 = new CodeChecksumPragma("test.txt", HashSHA1, new byte[] { 0xBB, 0xBB, 0xBB });

            cu.StartDirectives.Add(pragma2);

            CodeNamespace ns = new CodeNamespace("Namespace1");

            ns.Imports.Add(new CodeNamespaceImport("System"));
            ns.Imports.Add(new CodeNamespaceImport("System.IO"));
            cu.Namespaces.Add(ns);
            ns.Comments.Add(new CodeCommentStatement("Namespace Comment"));
            CodeTypeDeclaration cd = new CodeTypeDeclaration("Class1");

            ns.Types.Add(cd);

            cd.Comments.Add(new CodeCommentStatement("Outer Type Comment"));
            cd.LinePragma = new CodeLinePragma("c:\\temp\\test\\OuterLinePragma.txt", 300);

            CodeMemberMethod method1 = new CodeMemberMethod();

            method1.Name       = "Method1";
            method1.Attributes = (method1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;


            CodeMemberMethod method2 = new CodeMemberMethod();

            method2.Name       = "Method2";
            method2.Attributes = (method2.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;
            method2.Comments.Add(new CodeCommentStatement("Method 2 Comment"));

            cd.Members.Add(method1);
            cd.Members.Add(method2);

            cd.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start,
                                                           "Outer Type Region"));

            cd.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End,
                                                         string.Empty));

            CodeMemberField field1 = new CodeMemberField(typeof(String), "field1");

            cd.Members.Add(field1);
            field1.Comments.Add(new CodeCommentStatement("Field 1 Comment"));

            CodeRegionDirective codeRegionDirective1 = new CodeRegionDirective(CodeRegionMode.Start,
                                                                               "Field Region");

            field1.StartDirectives.Add(codeRegionDirective1);
            CodeRegionDirective codeRegionDirective2 = new CodeRegionDirective(CodeRegionMode.End,
                                                                               "");

            codeRegionDirective2.RegionMode = CodeRegionMode.End;
            codeRegionDirective2.RegionText = string.Empty;
            field1.EndDirectives.Add(codeRegionDirective2);

            CodeSnippetStatement snippet1 = new CodeSnippetStatement();

            snippet1.Value = "            Console.WriteLine(field1);";

            CodeRegionDirective regionStart = new CodeRegionDirective(CodeRegionMode.End, "");

            regionStart.RegionText = "Snippet Region";
            regionStart.RegionMode = CodeRegionMode.Start;
            snippet1.StartDirectives.Add(regionStart);
            snippet1.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty));

            // CodeStatement example
            CodeConstructor constructor1 = new CodeConstructor();

            constructor1.Attributes = (constructor1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;
            CodeStatement codeAssignStatement1 = new CodeAssignStatement(
                new CodeFieldReferenceExpression(
                    new CodeThisReferenceExpression(),
                    "field1"),
                new CodePrimitiveExpression("value1"));

            codeAssignStatement1.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "Statements Region"));
            cd.Members.Add(constructor1);
            codeAssignStatement1.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty));
            method2.Statements.Add(codeAssignStatement1);
            method2.Statements.Add(snippet1);
        }
示例#9
0
        static void Main(string[] args)
        {
            #region Declare CodeDOM graph objects
            CodeCompileUnit codeCompileUnit = null; ;
            CodeNamespace codeNameSpace = null;
            CodeNamespaceImport codeNameSpaceImport = null;
            CodeCommentStatement codeCommentStatement = null;
            CodeTypeDeclaration codeTypeDeclaration = null;
            CodeRegionDirective codeRegionDirectiveStart = null;
            CodeRegionDirective codeRegionDirectiveEnd = null;
            CodeMemberProperty codeMemberProperty = null;
            CodeMemberMethod codeMemberMethod = null;
            CodeParameterDeclarationExpression codeParameterDeclarationExpression = null;
            CodeMethodReturnStatement codeMethodReturnStatement = null;
            CodeMemberField codeMemberField = null;
            CodeFieldReferenceExpression codeFieldReferenceExpression = null;
            CodeAssignStatement codeAssignStatement = null;
            CodeMethodInvokeExpression codeMethodInvokeExpression = null;
            CodeTryCatchFinallyStatement codeTryCatchFinallyStatement = null;
            CodeThrowExceptionStatement codeThrowExceptionStatement = null;
            CodeCatchClause codeCatchClause = null;
            CodeConstructor codeConstructor = null;
            CodeBaseReferenceExpression codeBaseReferenceExpression = null;
            CodeSnippetExpression codeSnippetExpression = null;
            #endregion

            #region Create Code Compile Unit
            codeCompileUnit = new CodeCompileUnit();
            #endregion

            #region Create Namespace
            codeNameSpace = new CodeNamespace("MyCodeDOMNamespace");
            codeCompileUnit.Namespaces.Add(codeNameSpace);
            #endregion

            #region Create Imports/Using
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "System"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "System.IO"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "System.Collections"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "System.Collections.Generic"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "System.Linq"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            codeNameSpaceImport = new CodeNamespaceImport()
            {
                Namespace = "GenerateCode"
            };
            codeNameSpace.Imports.Add(codeNameSpaceImport);
            #endregion

            #region Create Comments
            codeCommentStatement = new CodeCommentStatement();
            codeCommentStatement.Comment = new CodeComment()
            {
                Text = "This is a regular comment",
                DocComment = false
            };
            codeNameSpace.Comments.Add(codeCommentStatement);
            codeCommentStatement = new CodeCommentStatement();
            codeCommentStatement.Comment = new CodeComment()
            {
                Text = "This is a documentation comment",
                DocComment = true
            };
            codeNameSpace.Comments.Add(codeCommentStatement);
            #endregion

            #region Create Interface Type
            //you do not need an interface
            codeTypeDeclaration = new CodeTypeDeclaration()
            {
                Name = "IMyType",
                TypeAttributes = TypeAttributes.Public,
                IsClass = false,
                IsEnum = false,
                IsInterface = true,
                IsPartial = false,
                IsStruct = false
            };
            codeNameSpace.Types.Add(codeTypeDeclaration);
            #endregion

            #region Create Region for Interface
            //note: region is one of the few directives supported
            //generally regions are used for conditional compilation issues
            //since the code is being generated dynamically,
            //just generate the code you want and don't work about directives
            codeRegionDirectiveStart = new CodeRegionDirective(CodeRegionMode.Start, "Start IMyType");
            codeRegionDirectiveEnd = new CodeRegionDirective(CodeRegionMode.End, "Start IMyType");
            codeTypeDeclaration.StartDirectives.Add(codeRegionDirectiveStart);
            codeTypeDeclaration.EndDirectives.Add(codeRegionDirectiveEnd);
            #endregion

            #region create property declaration for interface
            codeMemberProperty = new CodeMemberProperty()
            {
                Name = "MyProperty",
                Type = new CodeTypeReference(typeof(string)),
                HasGet = true,
                HasSet = true
            };
            codeTypeDeclaration.Members.Add(codeMemberProperty);
            #endregion

            #region create method decalration for interface
            codeMemberMethod = new CodeMemberMethod()
            {
                Name = "MyMethod",
                ReturnType = new CodeTypeReference(typeof(int))
            };
            codeParameterDeclarationExpression = new CodeParameterDeclarationExpression()
            {
                Name = "MyParameter",
                Type = new CodeTypeReference(typeof(string))
            };
            codeMemberMethod.Parameters.Add(codeParameterDeclarationExpression);
            codeTypeDeclaration.Members.Add(codeMemberMethod);
            #endregion

            #region Create Class that implements an Interface
            //you do not need to implement an interface just create the class
            codeTypeDeclaration = new CodeTypeDeclaration()
            {
                Name = "MyBaseType",
                TypeAttributes = TypeAttributes.Public,
                IsClass = true,
                IsEnum = false,
                IsInterface = false,
                IsPartial = false,
                IsStruct = false
            };
            codeTypeDeclaration.BaseTypes.Add("IMyType");
            codeNameSpace.Types.Add(codeTypeDeclaration);
            #endregion

            #region create constructor for class
            codeConstructor = new CodeConstructor()
            {
                Attributes = MemberAttributes.Public
            };
            codeParameterDeclarationExpression = new CodeParameterDeclarationExpression()
            {
                Name = "MyParameter",
                Type = new CodeTypeReference(typeof(string))
            };
            codeConstructor.Parameters.Add(codeParameterDeclarationExpression);
            codeAssignStatement = new CodeAssignStatement()
            {
                Left = new CodePropertyReferenceExpression()
                {
                    TargetObject = new CodeThisReferenceExpression(),
                    PropertyName = "MyProperty"
                },
                Right = new CodeFieldReferenceExpression()
                {
                    FieldName = "MyParameter"
                }
            };
            codeConstructor.Statements.Add(codeAssignStatement);
            codeTypeDeclaration.Members.Add(codeConstructor);
            #endregion

            #region create property declaration for the class that implements the interface
            //for some reason default getters and setters were not implemented in codedom
            codeMemberField = new CodeMemberField()
            {
                Name = "_MyProperty",
                Type = new CodeTypeReference(typeof(string)),
                Attributes = MemberAttributes.Private
            };
            codeTypeDeclaration.Members.Add(codeMemberField);
            codeMemberProperty = new CodeMemberProperty()
            {
                Name = "MyProperty",
                Type = new CodeTypeReference(typeof(string)),
                Attributes = MemberAttributes.Public,
                HasGet = true,
                HasSet = true
            };
            codeFieldReferenceExpression = new CodeFieldReferenceExpression()
            {
                TargetObject = new CodeThisReferenceExpression(),
                FieldName = "_MyProperty"
            };
            codeMethodReturnStatement = new CodeMethodReturnStatement()
            {
                Expression = codeFieldReferenceExpression
            };
            codeMemberProperty.GetStatements.Add(codeMethodReturnStatement);
            codeAssignStatement = new CodeAssignStatement()
            {
                Left = new CodeFieldReferenceExpression()
                {
                    TargetObject = new CodeThisReferenceExpression(),
                    FieldName = "_MyProperty"
                },
                Right = new CodeFieldReferenceExpression()
                {
                    TargetObject = null,
                    FieldName = "value"
                }
            };
            codeMemberProperty.SetStatements.Add(codeAssignStatement);
            codeTypeDeclaration.Members.Add(codeMemberProperty);
            #endregion

            #region create method decalration for the class that implements the interface
            codeMemberMethod = new CodeMemberMethod()
            {
                Name = "MyMethod",
                ReturnType = new CodeTypeReference(typeof(int)),
                Attributes = MemberAttributes.Public,
            };
            codeMemberMethod.ImplementationTypes.Add("IMytype");
            codeParameterDeclarationExpression = new CodeParameterDeclarationExpression()
            {
                Name = "MyParameter",
                Type = new CodeTypeReference(typeof(string))
            };
            codeMemberMethod.Parameters.Add(codeParameterDeclarationExpression);
            codeTryCatchFinallyStatement = new CodeTryCatchFinallyStatement();
            codeMethodInvokeExpression = new CodeMethodInvokeExpression()
            {
                Method = new CodeMethodReferenceExpression()
                {
                    TargetObject = new CodeTypeReferenceExpression()
                    {
                        Type = new CodeTypeReference(typeof(int))
                    },
                    MethodName = "Parse"
                }
            };
            codeMethodInvokeExpression.Parameters.Add(new CodeFieldReferenceExpression() { FieldName = "MyParameter" });
            codeMethodReturnStatement = new CodeMethodReturnStatement();
            codeMethodReturnStatement.Expression = codeMethodInvokeExpression;
            codeTryCatchFinallyStatement.TryStatements.Add(codeMethodReturnStatement);
            codeThrowExceptionStatement = new CodeThrowExceptionStatement()
            {
                ToThrow = new CodeFieldReferenceExpression()
                {
                    FieldName = "ex"
                }
            };
            codeCatchClause = new CodeCatchClause()
            {
                CatchExceptionType = new CodeTypeReference(typeof(System.Exception)),
                LocalName = "ex",
            };
            codeCatchClause.Statements.Add(codeThrowExceptionStatement);
            codeTryCatchFinallyStatement.CatchClauses.Add(codeCatchClause);
            codeMemberMethod.Statements.Add(codeTryCatchFinallyStatement);
            codeTypeDeclaration.Members.Add(codeMemberMethod);
            #endregion

            #region Create Region for Class
            codeRegionDirectiveStart = new CodeRegionDirective(CodeRegionMode.Start, "Start MyBaseType");
            codeRegionDirectiveEnd = new CodeRegionDirective(CodeRegionMode.End, "Start MyBaseType");
            codeTypeDeclaration.StartDirectives.Add(codeRegionDirectiveStart);
            codeTypeDeclaration.EndDirectives.Add(codeRegionDirectiveEnd);
            #endregion

            #region create class that inherits a base clase
            codeTypeDeclaration = new CodeTypeDeclaration()
            {
                Name = "MyType",
                TypeAttributes = TypeAttributes.Public,
                IsClass = true,
                IsEnum = false,
                IsInterface = false,
                IsPartial = false,
                IsStruct = false
            };
            codeTypeDeclaration.BaseTypes.Add("MyBaseType");
            codeNameSpace.Types.Add(codeTypeDeclaration);
            #endregion

            #region create constructor for class
            codeConstructor = new CodeConstructor()
            {
                Attributes = MemberAttributes.Public
            };
            codeParameterDeclarationExpression = new CodeParameterDeclarationExpression()
            {
                Name = "MyParameter",
                Type = new CodeTypeReference(typeof(string))
            };
            codeConstructor.Parameters.Add(codeParameterDeclarationExpression);
            codeFieldReferenceExpression = new CodeFieldReferenceExpression()
            {
                FieldName = "MyParameter"
            };
            codeConstructor.BaseConstructorArgs.Add(codeFieldReferenceExpression);
            codeTypeDeclaration.Members.Add(codeConstructor);
            #endregion

            #region create method that uses the current assembly
            codeMemberMethod = new CodeMemberMethod()
            {
                Name = "GetDataFromCurrentlyExecutingAssembly",
                Attributes = MemberAttributes.Public,
                ReturnType = new CodeTypeReference(typeof(void))
            };
            codeMethodInvokeExpression = new CodeMethodInvokeExpression()
            {
                Method = new CodeMethodReferenceExpression()
                {
                    TargetObject = new CodeTypeReferenceExpression()
                    {
                        Type = new CodeTypeReference(typeof(Console))
                    },
                    MethodName = "WriteLine"
                }
            };
            //sometimes you can cheat and just add the code
            codeSnippetExpression = new CodeSnippetExpression()
            {
                Value = @"
                            CurrentlyExecutingAssemblyClass currentlyExecutingAssemblyClass=new CurrentlyExecutingAssemblyClass(""Hello World"");
                            Console.WriteLine(currentlyExecutingAssemblyClass.CurrentlyExecutingProperty);
                        "
            };
            codeMemberMethod.Statements.Add(codeSnippetExpression);
            codeTypeDeclaration.Members.Add(codeMemberMethod);
            #endregion

            #region Create Region for Class
            codeRegionDirectiveStart = new CodeRegionDirective(CodeRegionMode.Start, "Start MyType");
            codeRegionDirectiveEnd = new CodeRegionDirective(CodeRegionMode.End, "Start MyType");
            codeTypeDeclaration.StartDirectives.Add(codeRegionDirectiveStart);
            codeTypeDeclaration.EndDirectives.Add(codeRegionDirectiveEnd);
            #endregion

            #region render code
            string sourceCS = string.Empty;
            StringBuilder stringBuilder = new StringBuilder();
            CodeDomProvider codeDomProvider = null;

            //Bracing style Block->same line C->new line
            //GenerateCodeFromCompileUnit reserves the right to rearrange your code the way it knows best
            CodeGeneratorOptions codeGeneratorOptions = new CodeGeneratorOptions()
                {
                    BracingStyle = "C",
                    VerbatimOrder = false,
                    BlankLinesBetweenMembers = true,
                    ElseOnClosing = false
                };
            //in c#
            using (StringWriter stringWriter = new StringWriter())
            {
                codeDomProvider = new CSharpCodeProvider();
                codeDomProvider.GenerateCodeFromCompileUnit(codeCompileUnit,
                                                            stringWriter,
                                                            codeGeneratorOptions);
                sourceCS = stringWriter.ToString();

            }
            //in visualbasic
            string sourceVB = string.Empty;
            using (StringWriter stringWriter = new StringWriter())
            {
                codeDomProvider = new VBCodeProvider();
                codeDomProvider.GenerateCodeFromCompileUnit(codeCompileUnit,
                                                            stringWriter,
                                                            codeGeneratorOptions);
                sourceVB = stringWriter.ToString();
            }

            //output source
            //Console.WriteLine(sourceCS);
            //Console.ReadLine();
            //Console.WriteLine(sourceVB);
            //Console.ReadLine();
            #endregion

            #region declare compiler objects
            CompilerParameters compilerParameters = null;
            CompilerResults compilerResults = null;
            int lineNumber = 0;
            #endregion

            #region compile CS source
            CSharpCodeProvider csharpCodeProvider = null;

            Console.WriteLine("Compiling CSharp:");
            foreach (string sourceLine in sourceCS.Split('\r'))
            {
                Console.WriteLine(string.Format("{0}:{1}", ++lineNumber, sourceLine.Replace("\n", "")));
            }

            csharpCodeProvider = new CSharpCodeProvider();
            compilerParameters = new CompilerParameters()
                {
                    GenerateExecutable = false,
                    GenerateInMemory = true,
                    IncludeDebugInformation = true
                };
            compilerParameters.ReferencedAssemblies.Add("System.dll");
            compilerParameters.ReferencedAssemblies.Add("System.Linq.dll");
            //reference currently executing assembly
            compilerParameters.ReferencedAssemblies.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);
            compilerResults = null;
            //compilerResults = csharCodeProvider.CompileAssemblyFromDom(compilerParameters, codeCompileUnit);
            compilerResults = csharpCodeProvider.CompileAssemblyFromSource(compilerParameters, sourceCS);
            if (compilerResults.Errors.Count > 0)
            {
                //error line numbers for compileunit are always off from source code
                Console.WriteLine("Errors building assembly.");
                foreach (CompilerError error in compilerResults.Errors)
                {
                    Console.WriteLine(string.Format("\tLine: {0}\r\n\tErrorNumber: {1}\r\n\tErrorText: {2}\r\n", error.Line, error.ErrorNumber, error.ErrorText));
                }
            }
            else
            {
                Console.WriteLine("Success");
            }
            #endregion

            #region compile VB source
            //VBCodeProvider vbCodeProvider = null;

            //Console.WriteLine("Compiling VB:");
            //foreach (string sourceLine in sourceVB.Split('\r'))
            //{
            //    Console.WriteLine(string.Format("{0}:{1}", ++lineNumber, sourceLine.Replace("\n", "")));
            //}

            //vbCodeProvider = new VBCodeProvider();
            //compilerParameters = new CompilerParameters()
            //{
            //    GenerateExecutable = false,
            //    GenerateInMemory = true,
            //    IncludeDebugInformation = true
            //};
            //compilerParameters.ReferencedAssemblies.Add("System.dll");
            //compilerParameters.ReferencedAssemblies.Add("System.Linq.dll");
            ////reference currently executing assembly
            //compilerParameters.ReferencedAssemblies.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);
            //compilerResults = null;
            ////compilerResults = csharCodeProvider.CompileAssemblyFromDom(compilerParameters, codeCompileUnit);
            //compilerResults = vbCodeProvider.CompileAssemblyFromSource(compilerParameters, sourceVB);
            //if (compilerResults.Errors.Count > 0)
            //{
            //    //error line numbers for compileunit are always off from source code
            //    Console.WriteLine("Errors building assembly.");
            //    foreach (CompilerError error in compilerResults.Errors)
            //    {
            //        Console.WriteLine(string.Format("\tLine: {0}\r\n\tErrorNumber: {1}\r\n\tErrorText: {2}\r\n", error.Line, error.ErrorNumber, error.ErrorText));
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("Success");
            //}
            #endregion

            #region use assembly
            if (compilerResults.Errors.Count == 0)
            {
                Assembly assembly = compilerResults.CompiledAssembly;
                Type myType = assembly.GetType("MyCodeDOMNamespace.MyType");

                Console.WriteLine("Setting MyProperty to a hard coded value of 123.");
                var myTypeInstance1 = assembly.CreateInstance("MyCodeDOMNamespace.MyType", false, BindingFlags.CreateInstance, null, new string[] { "123" }, null, null);
                Console.WriteLine("The value of MyProperty is {0}", myType.GetProperty("MyProperty").GetValue(myTypeInstance1));

                Console.WriteLine("Setting MyProperty to a referenced value of {0}", myValue);
                var myTypeInstance2 = assembly.CreateInstance("MyCodeDOMNamespace.MyType", false, BindingFlags.CreateInstance, null, new string[] { myValue }, null, null);
                Console.WriteLine("The value of MyProperty is {0}", myType.GetProperty("MyProperty").GetValue(myTypeInstance2));

                Console.WriteLine("Invoking method to get value from current running assembly");
                var myTypeInstance3 = assembly.CreateInstance("MyCodeDOMNamespace.MyType", false, BindingFlags.CreateInstance, null, new string[] { myValue }, null, null);
                myType.InvokeMember("GetDataFromCurrentlyExecutingAssembly", BindingFlags.InvokeMethod, null, myTypeInstance3, null);

                /*
                string CurrentAppDomain = Thread.GetDomain().FriendlyName;
                AppDomainSetup appDomainSetup = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
                    DisallowBindingRedirects = false,
                    DisallowCodeDownload = true,
                    ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
                };

                AppDomain appDomain = AppDomain.CreateDomain("MyAppDomain", null, appDomainSetup);
                */
            }
            #endregion

            Console.ReadLine();
        }
 private void GenerateCodeRegionDirective(CodeRegionDirective regionDirective) {
     // VB does not support regions within statement blocks
     if (IsGeneratingStatements()) {
         return;
     }
     if (regionDirective.RegionMode == CodeRegionMode.Start) {
         Output.Write("#Region \"");
         Output.Write(regionDirective.RegionText);
         Output.WriteLine("\"");
     }
     else if (regionDirective.RegionMode == CodeRegionMode.End) {
         Output.WriteLine("#End Region");
     }
 }        
示例#11
0
        private static void DomainObjectPropertiesCode(DomainObjectConfig obj, CodeTypeDeclaration targetClass)
        {
            bool isFirstProperty = true;
            CodeMemberProperty lastProperty = null;
            foreach (DomainPropertyConfig propConfig in obj.Property)
            {
                CodeMemberField propertyCodeConst = null;
                CodeMemberProperty prop = null;
                DomainPropertyCode(propConfig, out propertyCodeConst, out prop);

                targetClass.Members.Add(propertyCodeConst);

                // начало региона свойств
                if (isFirstProperty)
                {
                    CodeRegionDirective startPropertiesRegion = new CodeRegionDirective(CodeRegionMode.Start, PropertyRegionName);
                    propertyCodeConst.StartDirectives.Add(startPropertiesRegion);
                    isFirstProperty = false;
                }

                targetClass.Members.Add(prop);
                lastProperty = prop;
            }

            // закрываем регион свойств
            if (lastProperty != null)
            {
                CodeRegionDirective endPropertiesRegion = new CodeRegionDirective(CodeRegionMode.End, string.Empty);
                lastProperty.EndDirectives.Add(endPropertiesRegion);
            }
        }
示例#12
0
        private CodeTypeDeclaration CreateDataContext(XDocument dtmlXml, IEnumerable<DocType> docTypes)
        {
            string methodName = "OnCreated";
            CodeExpressionStatement statement = new CodeExpressionStatement(new CodeMethodInvokeExpression(null, methodName, new CodeExpression[0]));

            string dataContextName = dtmlXml.Root.Attribute("DataContextName").Value;
            //ensure the naming is standard
            if (!dataContextName.ToUpper().Contains("DATACONTEXT"))
            {
                dataContextName += "DataContext";
            }
            CodeTypeDeclaration dataContext = new CodeTypeDeclaration(dataContextName);
            dataContext.BaseTypes.Add("UmbracoDataContext");
            dataContext.IsClass = true;
            dataContext.IsPartial = true;

            string partialOnCreated = string.Empty;
            if (IsCSharpCodeProvider())
            {
                partialOnCreated = " partial void " + methodName + "();\r\n";
            }
            else
            {
                partialOnCreated = " Partial Private Void " + methodName + "()\r\nEnd Sub\r\n";
            }
            CodeSnippetTypeMember onCreated = new CodeSnippetTypeMember(partialOnCreated);
            CodeRegionDirective region = new CodeRegionDirective(CodeRegionMode.Start, "Partials");
            onCreated.StartDirectives.Add(region);
            onCreated.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "Partials"));
            dataContext.Members.Add(onCreated);

            //constructor with no arguments
            CodeConstructor ctor = new CodeConstructor();
            ctor.Attributes = MemberAttributes.Public;
            ctor.BaseConstructorArgs.Add(new CodePropertyReferenceExpression());
            ctor.Statements.Add(statement);
            dataContext.Members.Add(ctor);

            //constructor that takes an umbracoDataProvider
            ctor = new CodeConstructor();
            ctor.Attributes = MemberAttributes.Public;
            ctor.Parameters.Add(new CodeParameterDeclarationExpression("UmbracoDataProvider", "provider"));
            ctor.BaseConstructorArgs.Add(new CodePropertyReferenceExpression(null, "provider"));
            ctor.Statements.Add(statement);
            dataContext.Members.Add(ctor);

            //Generate the Tree<TDocType> for each docType
            foreach (var dt in docTypes)
            {
                string name = dt.TypeName;
                if (this.PluralizeCollections)
                {
                    name = PluraliseName(dt.TypeName);
                }
                var t = new CodeTypeReference("Tree");
                t.TypeArguments.Add(dt.TypeName);

                CodeMemberProperty p = new CodeMemberProperty();
                p.Name = name;
                p.Type = t;
                p.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                p.HasGet = true;
                p.HasSet = false;

                if (!Args.IsInterface)
                {
                    p.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodeMethodInvokeExpression(
                        new CodeMethodReferenceExpression(
                            new CodeThisReferenceExpression(),
                            "LoadTree",
                            new CodeTypeReference[] {
                                    new CodeTypeReference(dt.TypeName)
                                }),
                            new CodeExpression[0])
                        )
                    );
                }

                dataContext.Members.Add(p);
            }
            return dataContext;
        }
示例#13
0
        protected virtual CodeRegionDirective Rewrite(CodeRegionDirective source, ref bool didRewrite)
        {
            if (source == null)
            {
                return source;
            }

            bool didChildRewrite = false;
            CodeRegionDirective result = new CodeRegionDirective();
            result.RegionText = source.RegionText;
            result.RegionMode = this.Rewrite(source.RegionMode, ref didChildRewrite);
            this.Rewrite(result.UserData, source.UserData, ref didChildRewrite);
            if (didChildRewrite)
            {
                didRewrite = true;
                return result;
            }
            else
            {
                return source;
            }
        }
 private void GenerateCodeRegionDirective(CodeRegionDirective regionDirective) {
     if (regionDirective.RegionMode == CodeRegionMode.Start) {
         Output.Write("#region ");
         Output.WriteLine(regionDirective.RegionText);
     }
     else if (regionDirective.RegionMode == CodeRegionMode.End) {
         Output.WriteLine("#endregion");
     }
 }
示例#15
0
        /// <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;
        }
示例#16
0
 private void GenerateCodeRegionDirective(CodeRegionDirective regionDirective)
 {
     if (!this.IsGeneratingStatements())
     {
         if (regionDirective.RegionMode == CodeRegionMode.Start)
         {
             base.Output.Write("#Region \"");
             base.Output.Write(regionDirective.RegionText);
             base.Output.WriteLine("\"");
         }
         else if (regionDirective.RegionMode == CodeRegionMode.End)
         {
             base.Output.WriteLine("#End Region");
         }
     }
 }
 /// <summary>
 /// Visits a <see cref="CodeRegionDirective"/>.
 /// </summary>
 /// <param name="codeRegionDirective">The <see cref="CodeRegionDirective"/> to visit.</param>
 protected virtual void VisitCodeRegionDirective(CodeRegionDirective codeRegionDirective)
 {
 }