static void Main(string[] args) { dynamic p = new Person() { FirstName = "Sarah" }; Console.WriteLine(p.FirstName); //FindProperties(p); dynamic c = new CallMe(); c.Spot(); c.SpotRun(); c.RunSpotRun(); c.Dick(); c.Dick("call", "Jane"); dynamic e = new ExpandoObject(); e.JokeName = "StretchArmstrong"; e.JokeEfficacy = 0; e.HowDidTheJokeGoOver = (Action) (() => Console.WriteLine("It went over like a fart in church")); e.HowDidTheJokeGoOver(); }
private async void OnCallMe() { _canCallMe = false; CallMe.ChangeCanExecute(); await Task.Delay(1000); _canCallMe = true; CallMe.ChangeCanExecute(); }
public void AbortWhileBegin () { HttpListener listener = new HttpListener (); listener.Prefixes.Add ("http://127.0.0.1:9001/abortwhilebegin/"); listener.Start (); CallMe cm = new CallMe (); listener.BeginGetContext (cm.Callback, listener); listener.Abort (); if (false == cm.Event.WaitOne (3000, false)) Assert.Fail ("This should not time out."); Assert.IsNotNull (cm.Error); Assert.AreEqual (typeof (ObjectDisposedException), cm.Error.GetType (), "Exception type"); cm.Dispose (); }
public void AbortWhileBegin() { HttpListener listener = NetworkHelpers.CreateAndStartHttpListener("http://127.0.0.1:", out var _, "/abortwhilebegin/"); CallMe cm = new CallMe(); listener.BeginGetContext(cm.Callback, listener); listener.Abort(); if (false == cm.Event.WaitOne(3000, false)) { Assert.Fail("This should not time out."); } Assert.IsNotNull(cm.Error); Assert.AreEqual(typeof(ObjectDisposedException), cm.Error.GetType(), "Exception type"); cm.Dispose(); }
public AvgBlogRankByPK() { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); _sqlConnString = config.GetConnectionString("DefaultSql"); sqlCon = new SqlConnection(_sqlConnString); // will be used by ADO not EF #if DEBUG var t = typeof(AvgBlogRankByPK); //foreach (var m in t.GetMethods().Where(m2 => m2.CustomAttributes.Any(a => a.AttributeType.Name == "BenchmarkAttribute"))) //{ // Console.WriteLine("{1}\t{0}", m.Name, m.CustomAttributes.Count()); // var yyy = CallMe.CreateDelegate(typeof(CallMe), this, m.Name); //} methods = t.GetMethods() .Where(m2 => m2.CustomAttributes .Any(a => a.AttributeType.Name == "BenchmarkAttribute")) .Select(m => (CallMe)CallMe.CreateDelegate(typeof(CallMe), this, m.Name)).ToArray(); #endif }
/// <summary> /// callbackFunction - a function to be called when a connection is made. /// Your SpaceWars client will provide this function when it invokes ConnectedToServer. /// ConnectedToServer should attempt to connect to the server via a provided hostname. /// It should save the callback function in a socket state object for use when data arrives. /// It will need to create a socket and then use the BeginConnect method. /// Note this method takes the "state" object and /// "regurgitates" it back to you when a connection is made, thus allowing communication between this function and the ConnectedToServer function (below). /// </summary> /// <param name="callbackFunction">a function to be called when a connection is made</param> /// <param name="hostname">the name of the server to connect to</param> /// <returns></returns> public static SocketState ConnectToServer(CallMe callMe, string hostName) { System.Diagnostics.Debug.WriteLine("connecting to " + hostName); // Create a TCP/IP socket. Socket socket; IPAddress ipAddress; Networking.MakeSocket(hostName, out socket, out ipAddress); SocketState state = new SocketState(socket, -1); state.callMe = callMe; IAsyncResult result = state.theSocket.BeginConnect(ipAddress, Networking.DEFAULT_PORT, ConnectedCallback, state); bool success = result.AsyncWaitHandle.WaitOne(3000, true); if (!socket.Connected) { socket.Close(); throw new ApplicationException("Could not connect to server."); } return(state); }
private string GetEmailContent(CallMe.CallMeEntityRow callMe) { StringBuilder email = new StringBuilder(); email.Append("<B> First Name: </B>").Append(callMe.name_forename).Append("<BR/>"); email.Append("<B> SurName: </B>").Append(callMe.name_surname).Append("<BR/>"); email.Append("<B> Telephone: </B>").Append(callMe.telephone).Append("<BR/>"); email.Append("<B> Mobile: </B>").Append(callMe.cell_number).Append("<BR/>"); email.Append("<B> EMail: </B>").Append(callMe.email).Append("<BR/>"); email.Append("<B> Company Name: </B>").Append(callMe.company_name).Append("<BR/>"); email.Append("<B> Company Website: </B>").Append(callMe.company_website).Append("<BR/>"); email.Append("<B> Postal Address: </B>").Append(callMe.postal_adress).Append("<BR/>"); email.Append("<B> Postcode: </B>").Append(callMe.postal_code).Append("<BR/>"); email.Append("<B> Comments: </B>").Append(callMe.comments).Append("<BR/>"); return email.ToString(); }