public virtual void Intercept(IInvocation invocation) { Method method = new Method(invocation.Method); bool snapShotEnabled = method.HasAttribute(typeof (WorkSnapshotAttribute)); LastServiceCallStatus lastServiceCallStatus = serviceExecution.Invoking(service, invocation.Method); if (lastServiceCallStatus.WasExecuted) invocation.ReturnValue = lastServiceCallStatus.ReturnValue; else { if (snapShotEnabled) serviceExecution.TakeSnapshot(); ReflectedObject reflectedServiceObject = new ReflectedObject(service); sessionReport.Begin(invocation.Method.Name); try { invocation.ReturnValue = reflectedServiceObject.Invoke(invocation.Method, invocation.Arguments); serviceExecution.Invoked(invocation.ReturnValue); } catch (Exception e) { sessionReport.Act(); serviceExecution.Error(); throw new WhiteException(string.Format("Error Invoking {0}.{1}",reflectedServiceObject.Class.Name,invocation.Method.Name),e.InnerException); } } }
public virtual void Intercept(IInvocation invocation) { if (reflectedUIItem == null) { IUIItem uiItem = window.Get(searchCriteria); if (uiItem == null) throw new UIItemSearchException("Could not find UIItem with, " + searchCriteria); reflectedUIItem = new ReflectedObject(uiItem); } try { invocation.ReturnValue = reflectedUIItem.Invoke(invocation.Method, invocation.Arguments); } catch (Exception e) { sessionReport.Act(); throw new WhiteException(string.Format("Error Invoking {0}.{1}", reflectedUIItem.Class.Name, invocation.Method.Name), e.InnerException); } }
public ScreenObjectInterceptor(AppScreen appScreen) { reflectedScreen = new ReflectedObject(appScreen); }
public virtual void Visit(ObjectVisitor visitor) { if (o == null || o.GetType().Equals(typeof (object))) return; Markable markable = o as Markable; if (markable != null && markable.IsProcessed) return; if (markable != null) markable.IsProcessed = true; @class.EachField(delegate(FieldInfo fieldInfo) { var reflectedObject = new ReflectedObject(fieldInfo.GetValue(o), leafRegister); if (TreatAsPrimitive(fieldInfo.FieldType) || leafRegister.IsIgnored(fieldInfo.FieldType)) visitor.Accept(reflectedObject); else reflectedObject.Visit(visitor); }); visitor.Accept(this); }
public virtual ComparisonStatus AreIdentical(ReflectedObject other) { ComparisonStatus comparisonStatus = ComparisonStatus.DontKnow; if (o == null && other.o != null) { Mark(ComparisonStatus.Eager, other.o); return ComparisonStatus.Eager; } if (other.o == null && o != null) return ComparisonStatus.Eager; if (leafRegister.ShouldNotMark(other.o)) return ComparisonStatus.Create(O.Equals(other.O)); if (leafRegister.IsIgnored(o.GetType())) { if (other.o != null) Mark(ComparisonStatus.Lazy, other.o); return ComparisonStatus.Lazy; } if (TreatAsPrimitive(o.GetType())) { bool equal = o.Equals(other.o); if (equal) { Mark(ComparisonStatus.Lazy, other.o); return ComparisonStatus.Lazy; } return ComparisonStatus.Eager; } if (!o.GetType().Equals(other.o.GetType())) { Mark(ComparisonStatus.Eager, other.o); return ComparisonStatus.Eager; } var markable = other.o as Markable; if (markable != null && markable.IsProcessed) return markable.ComparisonStatus; if (markable != null) markable.IsProcessed = true; List<object> otherFieldValues = other.FieldValues; List<object> myFieldValues = FieldValues; for (int i = 0; i < myFieldValues.Count; i++) { object myValue = myFieldValues[i]; object otherValue = otherFieldValues[i]; ComparisonStatus status = CompareValues(myValue, otherValue); if (Tristate.Lazy.Equals(status.State) && (otherValue is Markable && !Equals(myValue, otherValue))) status.State = Tristate.Eager; comparisonStatus.Combine(status); } Mark(comparisonStatus, other.o); return comparisonStatus; }