Example #1
0
 static void Main(string[] args)
 {
     try
     {
         if (!InitializeIOC())
         {
             return;
         }
         using (var iScope = myIOCContainer.BeginLifetimeScope())
         {
             var ToConsole = iScope.ResolveNamed<IOutputMethod>(ConsoleTarget);
             MessageWriterResponse resp = new MessageWriterResponse();
             resp = ToConsole.Write("Hello World");
             if (resp.Success == false)
             {
                 //additional error handling here, use ExtendedInformation to resolve the error
             }
             Console.ReadLine();
         }
     }
     catch (System.Exception consoleWriteFailed)
     {
         //would probably want some other method besides a console.write to record this failure... since that's
         //what failed in the first place
         Console.Write("Failed to Instantiate/Load Hello World Helper Process Error: {0}",consoleWriteFailed.Message);
     }
 }
Example #2
0
 public void TestHelloWorldDB()
 {
     using (var iScope = myIOCContainer.BeginLifetimeScope())
     {
         var ToConsole = iScope.ResolveNamed<IOutputMethod>(DBTarget);
         MessageWriterResponse resp = new MessageWriterResponse();
         resp = ToConsole.Write("It Doesn't Matter");
         Assert.IsTrue(resp.Success,String.Format("Output to Console Failed with the following error {0}",resp.ExtendedInformation));
     }
 }
 public MessageWriterResponse Write(string Message)
 {
     MessageWriterResponse Response = new MessageWriterResponse();
     try
     {
         Console.WriteLine("This would be written to a database");
         Response.Success = true;
         Response.ExtendedInformation = "";
     }
     catch (System.Exception ex)
     {
         Response.Success = false;
         Response.ExtendedInformation = ex.Message;
     }
     return (Response);
 }