Beispiel #1
0
        private void btnAuthorizationB_Click(object sender, RoutedEventArgs e)
        {
            txtAuthorizationB.Text = String.Empty;

            SLPrincipal.Logout();
            SLPrincipal.Login("ClassARole", (o, e2) =>
            {
                bool pass = true;

                try
                {
                    ClassB1 classB1 = new ClassB1();
                    try
                    {
                        classB1.A = "test";
                        pass      = false;
                    }
                    catch (SecurityException ex)
                    { }
                    classB1.B = "test";
                    if (classB1.B != "test")
                    {
                        pass = false;
                    }

                    ClassB2 classB2 = new ClassB2();
                    try
                    {
                        classB2.A = "test";
                        pass      = false;
                    }
                    catch (SecurityException ex)
                    { }
                    classB2.B = "test";
                    if (classB2.B != "test")
                    {
                        pass = false;
                    }
                }
                catch (Exception ex)
                {
                    pass = false;
                }

                if (pass)
                {
                    txtAuthorizationB.Text = "Pass";
                }
                else
                {
                    txtAuthorizationB.Text = "Fail";
                }
            });
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            CriteraDelegate exampleDelegate1 = new CriteraDelegate(ExecuteCritera1);
            CriteraDelegate exampleDelegate2 = new CriteraDelegate(ExecuteCritera2);
            CriteraManager  manager          = new CriteraManager();

            manager.RegisterCritera(typeof(InterfaceB1), exampleDelegate2);
            manager.RegisterCritera(typeof(InterfaceB2), exampleDelegate2);
            manager.RegisterCritera(typeof(InterfaceC), exampleDelegate1);
            ClassB1 b1 = new ClassB1();
            ClassB2 b2 = new ClassB2();
            ClassC  c  = new ClassC();

            manager.Execute(b1, "Should execute delegate 2");
            manager.Execute(b2, "Should execute delegate 2");
            manager.Execute(c, "Should execute delegate 1");
        }
Beispiel #3
0
    private void btnAuthorizationB_Click(object sender, RoutedEventArgs e)
    {
      txtAuthorizationB.Text = String.Empty;

      SLPrincipal.Logout();
      SLPrincipal.Login("ClassARole", (o, e2) =>
      {
        bool pass = true;

        try
        {
          ClassB1 classB1 = new ClassB1();
          try
          {
            classB1.A = "test";
            pass = false;
          }
          catch (SecurityException ex)
          { }
          classB1.B = "test";
          if (classB1.B != "test")
            pass = false;

          ClassB2 classB2 = new ClassB2();
          try
          {
            classB2.A = "test";
            pass = false;
          }
          catch (SecurityException ex)
          { }
          classB2.B = "test";
          if (classB2.B != "test")
            pass = false;
        }
        catch (Exception ex)
        {
          pass = false;
        }

        if (pass)
        {
          txtAuthorizationB.Text = "Pass";
        }
        else
        {
          txtAuthorizationB.Text = "Fail";
        }
      });
    }
Beispiel #4
0
 public void TwoArgsWithInterface(InterfaceB x, ClassB2 y)
 {
     AmbigousMethodsTests.Output = "OneArgWithInterface_InterfaceBClassB2";
 }
Beispiel #5
0
 public void OneArgWithInterface(ClassB2 x)
 {
     AmbigousMethodsTests.Output = "OneArgWithInterface_ClassB2";
 }