Ejemplo n.º 1
0
 public static TResult Accept <TResult>(this IVisitableExtensionPoint <object> visitable,
                                        [NotNull] VisitorFactory visitorFactory,
                                        object parameter1,
                                        object parameter2)
 {
     try
     {
         return(((dynamic)visitorFactory).Visit((dynamic)visitable.ExtendedValue,
                                                (dynamic)parameter1,
                                                (dynamic)parameter2));
     }
     catch (InvalidCastException invalidCastException)
     {
         if (visitorFactory.Rethrow)
         {
             throw;
         }
         return(visitorFactory.CreateFallbackObject <TResult>(visitable.ExtendedValue,
                                                              invalidCastException,
                                                              parameter1,
                                                              parameter2));
     }
     catch (RuntimeBinderException runtimeBinderException)
     {
         if (visitorFactory.Rethrow)
         {
             throw;
         }
         return(visitorFactory.CreateFallbackObject <TResult>(visitable.ExtendedValue,
                                                              runtimeBinderException,
                                                              parameter1,
                                                              parameter2));
     }
 }
Ejemplo n.º 2
0
 public static TResult Accept <TResult>(this IVisitableExtensionPoint <object> visitable,
                                        [NotNull] VisitorFactory visitorFactory)
 {
     try
     {
         dynamic factory = visitorFactory;
         dynamic toVisit = visitable.ExtendedValue;
         TResult result  = factory.Visit(toVisit);
         return(result);
     }
     catch (InvalidCastException invalidCastException)
     {
         if (visitorFactory.Rethrow)
         {
             throw;
         }
         return(visitorFactory.CreateFallbackObject <TResult>(visitable.ExtendedValue, invalidCastException));
     }
     catch (RuntimeBinderException runtimeBinderException)
     {
         if (visitorFactory.Rethrow)
         {
             throw;
         }
         return(visitorFactory.CreateFallbackObject <TResult>(visitable.ExtendedValue, runtimeBinderException));
     }
 }
Ejemplo n.º 3
0
 public static TResult Accept <TResult>(this IVisitableExtensionPoint <object> visitable,
                                        [NotNull] VisitorFactory <TResult> visitorFactory,
                                        object parameter1)
 {
     return(Accept <TResult>(visitable, (VisitorFactory)visitorFactory, parameter1));
 }