예제 #1
0
파일: Program.cs 프로젝트: berczeck/.Net
        static void Main(string[] args)
        {
            int valor = 2;

            TryFactory.Try(
                () =>
            {
                throw new SerializationException();
            }
                ).Catch <Exception>(ManejarError);


            TryFactory.Try(() =>
            {
                Prueba pt = new Prueba();
                pt.Suma(valor, valor, valor, valor);
                Console.WriteLine();
            }).Catch <ArgumentException, ArgumentNullException>(ManejarError);

            TryOpenFile();
            TryWithUsing();
            string origen = string.Empty;

            TryFactory.Try(() => Console.WriteLine("")).Catch <Exception, string>(TryCatchWeb.ControlError, origen);
            TryFactory.Try(() => Console.WriteLine("")).Catch <Exception>(ManejarError);
            TryFactory.Try(() => Console.WriteLine("")).Catch(TryCatchWeb.ControlError, origen);
            TryFactory.Try(() => Console.WriteLine("")).Catch(ManejarError);
            TryFactory.Try(() => Console.WriteLine("")).Catch <Exception, ArgumentNullException, string>(TryCatchWeb.ControlError, origen);
            TryFactory.Try(() => Console.WriteLine("")).Catch <Exception, ArgumentNullException>(ManejarError);

            Console.ReadLine();
        }
예제 #2
0
파일: Program.cs 프로젝트: berczeck/.Net
 private static void TryOpenFile()
 {
     TryFactory.Try(() =>
     {
         using (var stream = File.OpenRead(ruta))
         {
             Trace.WriteLine(stream.Length);
         }
     })
     .Catch <FileNotFoundException, DirectoryNotFoundException>(ManejarError);
 }
예제 #3
0
파일: Program.cs 프로젝트: berczeck/.Net
 private static void TryWithUsing()
 {
     TryFactory.TryUsing(() => File.OpenRead(ruta), stream => Trace.WriteLine(stream.Length))
     .Catch <FileNotFoundException, DirectoryNotFoundException>(ManejarError);
 }