Exemplo n.º 1
0
 public static TEither Bind(
     this TEither src,
     Func <IStgCtrl, TEither> func)
 {
     if (src.IsRight)
     {
         int       passtime = 0;
         Stopwatch stw      = new Stopwatch();
         func(src.Right);
         while (passtime < src.TimeOutSec)
         {
             stw.Start();
             if (src.Right.Query(src.Right.Status)
                 == src.Right.StatusOK)
             {
                 return(src);                                                 // Right
             }
             else
             {
                 stw.Stop();
             }
             passtime = ( int )(stw.ElapsedMilliseconds / 1000);
         }
     }
     return(new TEither());            // Left No Log
 }
Exemplo n.º 2
0
        public static TEither Bind(
            this TEither src,
            Func <IStgCtrl, TEither> func,
            string log)
        {
            //var timenow = DateTime.Now.ToString("HH-mm-ss");
            string nextlog = "[Function Error] : " + log;

            if (src.IsRight)
            {
                int       passtime = 0;
                Stopwatch stw      = new Stopwatch();
                func(src.Right);
                while (passtime < src.TimeOutSec)
                {
                    stw.Start();
                    if (src.Right.Query(src.Right.Status)
                        == src.Right.StatusOK)
                    {
                        return(src);                                                 // Function Success -> Right
                    }
                    else
                    {
                        stw.Stop();
                    }
                    passtime = ( int )(stw.ElapsedMilliseconds / 1000);
                }
                return(new TEither(nextlog));                  // Function Fail
            }
            return(new TEither(new StringBuilder()
                               .Append(src.Left)
                               .Append(Environment.NewLine)
                               .Append(nextlog)
                               .ToString()));                                                 // Pass Left
        }
Exemplo n.º 3
0
 public static LEither <A> ToLEither <A>(
     this TEither self,
     A value)
 {
     return(self.IsRight
                                 ? new LEither <A>(value, self.Left)
                                 : new LEither <A>(self.Left, false));
 }