static void Main(string[] args) { add += new DelEventHandler(replace); add.Invoke(); Console.ReadLine(); }
static void Main(string[] args) { add += new DelEventHandler(USA); add += new DelEventHandler(INDIA); add += new DelEventHandler(ENGLAND); add += new DelEventHandler(GERMANY); add.Invoke(); Console.ReadKey(); }
static void Main(string[] args) { add += new DelEventHandler(USA); add += new DelEventHandler(India); add += new DelEventHandler(England); add.Invoke(); Console.ReadLine(); }
static void Main(string[] args) { add += new DelEventHandler(USA); // so instanced used for calling bcz all are in same class add += new DelEventHandler(India); add += new DelEventHandler(England); add.Invoke(); Console.ReadLine(); }
private static void Getdata(Employee e) { Console.WriteLine($"Employee id : {e.GetId()}"); add += new DelEventHandler(OnGetId); Console.WriteLine($"Employee name : {e.GetName()}"); add += new DelEventHandler(OnGetName); Console.WriteLine($"Employee Department : {e.GetDepartmentName()}"); add += new DelEventHandler(OnGetDname); add.Invoke(); }
static void Main(string[] args) { add += new DelEventHandler(India); add += new DelEventHandler(USA); add += new DelEventHandler(England); add.Invoke(); Console.WriteLine("*******************************Event Handling********************"); EventHandling.ImplementEvent(); }
private static void Main(string[] args) { Excercise1(); Excercise2(); Excercise3(); Excercise4(); empty += new DelEventHandler(Cow); empty += new DelEventHandler(Hen); empty += new DelEventHandler(Horse); empty += new DelEventHandler(Sheep); empty += new DelEventHandler(Emydex); empty.Invoke(); Console.ReadKey(); }
public Program() { // desing a button over form Button btn = new Button(); btn.Parent = this; btn.Text = "Hit Me"; btn.Location = new Point(100, 100); //Event handler is assigned to // the button click event btn.Click += new EventHandler(onClcik); add += new DelEventHandler(Initiate); //invoke the event add(); }
protected void btnSignIn_Click(object sender, EventArgs e) { try { conn.Open(); command.Connection = conn; command.CommandType = CommandType.StoredProcedure; //set the commandText to the name of our stored procedure command.CommandText = "[dbo].[Login]"; //provide values for the procedure's parameters command.Parameters.AddWithValue("@Username", txtUserName.Text); command.Parameters.AddWithValue("@PasswordHash", GetMd5Hash(txtPassword.Text)); //execute the command SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { //reader.Read(); // int userId = Convert.ToInt32(reader["UserId"]); // string roles = reader["Roles"].ToString(); string roles = reader.GetSqlValue(6).ToString(); reader.Close(); HttpCookie S00140633 = new HttpCookie("LoggedIn"); Response.Cookies.Clear(); // Set the new expiry date - to thirty days from now DateTime expiryDate; if (cbxRemember.Checked) { //creates an autorization cookie which lasts a month expiryDate = DateTime.Now.AddDays(30); } else { //creates an autorization cookie which lasts a month expiryDate = DateTime.Now.AddHours(1); // FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true); } // Create a new forms auth ticket FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(2, txtUserName.Text, DateTime.Now, expiryDate, true, roles); // Encrypt the ticket string encryptedTicket = FormsAuthentication.Encrypt(ticket); // Create a new authentication cookie - and set its expiration date HttpCookie authenticationCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); authenticationCookie.Expires = ticket.Expiration; // Add the cookie to the response. Response.Cookies.Add(authenticationCookie); HttpContext.Current.ApplicationInstance.CompleteRequest(); Response.Redirect("Index.aspx", false); } // if login fails the event and delaegate is called. Alerts message and number of attempts else { Application.Lock(); int atts = Convert.ToInt32(Application["Attempts"]) + 1; Application["Attempts"] = atts; Application.UnLock(); MyEvent += new DelEventHandler(attemptsMade); //** Step 3 **// MyEvent += new DelEventHandler(attemptsLeft); MyEvent(atts); reader.Close(); } } catch (Exception ex) { lblError.Text = "Oops Something went wrong. Please Try again"; } finally { conn.Close(); } }
internal EventHandlerData(MethodInfo method, object instance) { _event = (DelEventHandler)Delegate.CreateDelegate(typeof(DelEventHandler), instance, method, true); _attribute = method.GetCustomAttribute <EventHandlerAttribute>(); }