kamagra how much to take

Displaying Code Groups Using The CodeGroup Base Class

Displaying Code Groups is a powerful mechanism when developing security tooling at the assembly level, representing a consortium of code sharing particular conditions for membership. This is important during assembly security analysis since the code groups during a policy grant have coupled permission sets that are subject to assessment.

To do this, a common method to list code groups is useful, so that one can consume two CodeGroup objects , one for the display group an another for the root group so that an IEnumerator object can be instantiated to iterate through each respective collection. This is accomplished through the use of the Children IList property, representing the child code groups.

Enough talk…the RecursiveCodeGroupIteration method is the workhorse of the application:

  1. private static void RecursiveCodeGroupIteration(string prefix, string indent, IEnumerator disp, IEnumerator root)
  2.         {
  3.             if (disp == null) return;
  4.             int num = 0;
  5.             CodeGroup group = null;
  6.             while (disp.MoveNext())
  7.             {
  8.                 var current = (CodeGroup)disp.Current;
  9.                 if (root == null)
  10.                 {
  11.                     num++;
  12.                 }
  13.                 else
  14.                 {
  15.                     do
  16.                     {
  17.                         if (!root.MoveNext())
  18.                         {
  19.                             // Unable to resolve group, no matches!
  20.                         }
  21.                         group = (CodeGroup)root.Current;
  22.                         num++;
  23.                     }
  24.                     while (!group.Equals(current));
  25.                 }
  26.                 string str = string.Format("{0}.{1}", prefix, num);
  27.  
  28.                 SharedDisplaySomeStandardOutput(string.Format("{0}{1}.  {2}{3}: {4}{5}", indent, str, (current.MergeLogic.Equals("Union") ? "" :
  29.                 (string.Format("({0}) ", current.MergeLogic))), (current.MembershipCondition.ToString()), (current.PermissionSetName ?? "@@Unkown@@"),
  30.                 (((current.AttributeString == null) || current.AttributeString.Equals("")) ? "" :
  31.                 (string.Format(" ({0})", current.AttributeString)))));
  32.                 if (root == null)
  33.                 {
  34.                     RecursiveCodeGroupIteration(str, string.Format("{0}   ", indent), current.Children.GetEnumerator(), null);
  35.                 }
  36.                 else
  37.                 {
  38.                     RecursiveCodeGroupIteration(str, string.Format("{0}   ", indent), current.Children.GetEnumerator(), group.Children.GetEnumerator());
  39.                 }
  40.             }
  41.  
  42.  
  43.         }
  44.         public static void SharedDisplaySomeStandardOutput(string str)
  45.         {
  46.             // whatever you are using for standard output, put it here
  47.         }

Since what standard output being used could be a lot, I just comment that out into its own static method.

Using this method is pretty straightforward, as demonstrated in the below ShowMeTheCodeGroups method taking into two CodeGroup objects as parameters:

  1. private static void ShowMeTheCodeGroups (CodeGroup display, CodeGroup root)
  2.         {
  3.             const string prefix = "1";
  4.             if (Equals(display, root))
  5.             {
  6.                 RecursiveCodeGroupIteration(prefix, "   ", display.Children.GetEnumerator(), null);
  7.             }
  8.             else
  9.             {
  10.                 RecursiveCodeGroupIteration(prefix, "   ", display.Children.GetEnumerator(), root.Children.GetEnumerator());
  11.             }
  12.         }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>