Exemple #1
0
        private void AmInRole_Click(object sender, System.EventArgs e)
        {
            label.Text  = "";
            this.Cursor = Cursors.WaitCursor;

            try
            {
                // The 'using' construct below results in a call to Dispose on exiting the
                // curly braces. It could be replaced with an explicit call to Object.Dispose
                // This is a C#-specific construct.
                //
                // It is important to dispose COM+ objects as soon as possible so that
                // COM+ metadata such as context does not remain in memory unnecessarily
                // and so that COM+ services such as Object Pooling work properly.
                using (RBSecurityObject test = new RBSecurityObject())
                {
                    if (test.IsCallerInDemoRole())
                    {
                        label.Text = "You ARE in RBSecurityDemoRole";
                    }
                    else
                    {
                        label.Text = "You are NOT in RBSecurityDemoRole";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Could not create RBSecurityObject");
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
Exemple #2
0
        private void WhoAmI_Click(object sender, System.EventArgs e)
        {
            label.Text  = "";
            this.Cursor = Cursors.WaitCursor;

            try
            {
                // The using keyword is to have the COM+ object disposed
                // directly when finished running the code inside the using section.
                // This is to release the COM+ Object on the server as soon as
                // possible.
                using (RBSecurityObject test = new RBSecurityObject())
                {
                    label.Text = test.WhoIsCaller();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Could not create RBSecurityObject");
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }