protected override void OnHandler(ParameterHandlerInfo info) { Core.Log.Warning("Starting DUCK TYPE TEST"); var helloObject = new HelloClass(); var iHello = helloObject.ActAs <IHello>(); dynamic helloDynamic = new HelloDynamicObject(); var iHelloDynamic = ((object)helloDynamic).ActAs <IHello>(); helloObject.Test(Guid.NewGuid(), "ES"); iHello.Test(Guid.NewGuid(), "ES"); helloDynamic.Test(Guid.NewGuid(), "ES"); iHelloDynamic.Test(Guid.NewGuid(), "ES"); // Core.Log.InfoBasic(helloObject.Suma(12, 12).ToString()); Core.Log.InfoBasic(iHello.Suma(12, 12).ToString()); Core.Log.InfoBasic(helloDynamic.Suma(12, 12).ToString()); Core.Log.InfoBasic(iHelloDynamic.Suma(12, 12).ToString()); for (var i = 0; i < 50; i++) { Core.Log.InfoBasic("Calling the object method"); helloObject.SayHello(); Core.Log.InfoBasic("Calling the interface method on static object"); iHello.SayHello(); Core.Log.InfoBasic("Calling the dynamic method"); helloDynamic.SayHello(); Core.Log.InfoBasic("Calling the interface method on dynamic object"); iHelloDynamic.SayHello(); } }
public void ReflectionFieldStyleDeclarationTest() { // var type = typeof(CSSStyleDeclaration); // var fields = new Dictionary<string, object>(); // // var props = type.GetProperties() // .Select(x => new // { // Attr = x.GetCustomAttributes(typeof(CssFieldAttribute), false), // Field = x // }) // .Where(x => x.Attr.Length != 0) // .ToDictionary(x => ((CssFieldAttribute) x.Attr.FirstOrDefault()).Path, x => x.Field); // // var property = this.GetType().GetProperty("XXX"); // property.SetValue(this, "Hello"); Console.WriteLine(XXX); var hello = new HelloClass(); var test = hello.GetType().GetProperty("Test"); var testValue = test.GetValue(hello, null); var pxxx = test.PropertyType.GetProperty("XXX"); pxxx.SetValue(testValue, "ONE"); Console.WriteLine(""); }
private void helloButton_Click(object sender, EventArgs e) { string userName = textBox1.Text; string welcomeMessage = HelloClass.GenerateWelcomeString(DateTime.Now, userName); MessageBox.Show(welcomeMessage); }
void OnButtonClicked(object sender, EventArgs args) { string username = usernameEntry.Text; string helloMessage = HelloClass.GenerateWelcomeString(DateTime.Now, username); DisplayAlert("w/sup buddy?", helloMessage, "k"); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); var instance = new HelloClass(); var ring = new LordOfTheRings(); ring.ShowYourself(); }
static void Main(string[] args) { if (args.Length == 0) { throw new Exception("To run the application, you need to pass at least one parameter"); } string message = HelloClass.GenerateWelcomeString(DateTime.Now, args[0]); Console.WriteLine(message); }
public void GetHello_ShouldReturnValue() { var testHello = new HelloClass(); var controller = new HelloController(); var actionResult = controller.Get() as IHttpActionResult; var contentResult = actionResult as OkNegotiatedContentResult <HelloClass>; Assert.IsNotNull(actionResult); //Times should be very close var ts = DateTime.Parse(contentResult.Content.CurrentDateTime) - DateTime.Parse(testHello.CurrentDateTime); Assert.IsTrue(Math.Abs(ts.TotalMilliseconds) < 100); }
// Program entry point. public static int Main(string[] args) { // Process command line arguments... if (0 != args.Length) { for (int x = 0; x < args.Length; x++) { Console.WriteLine("Arg: {0}", args[x]); } // One more time using foreach! Console.WriteLine("Just in case you missed it the args were:"); foreach (string s in args) { Console.WriteLine("Arg: {0}", s); } } else { Console.WriteLine("No command line args...\n"); } // Make instance of HelloClass. HelloClass c1 = new HelloClass(); c1.SayHi(); Console.WriteLine("c1.intX = {0}\nc1.intY = {1}\n", c1.intX, c1.intY); // Another instance of HelloClass. HelloClass c2; c2 = new HelloClass(100, 200); c2.SayHi(); Console.WriteLine("c2.intX = {0}\nc2.intY = {1}\n", c2.intX, c2.intY); return(0); }
public WeatherForecastController(HelloClass cls, ILogger <WeatherForecastController> logger) { _cls = cls; _logger = logger; }