private ITestNaked DoInvoke(int page, params object[] parameters) { ResetLastMessage(); AssertIsValidWithParms(parameters); INakedObjectAdapter[] parameterObjectsAdapter = parameters.AsTestNakedArray(manager).Select(x => x.NakedObject).ToArray(); INakedObjectAdapter[] parms = actionSpec.RealParameters(owningObject.NakedObject, parameterObjectsAdapter); INakedObjectAdapter target = actionSpec.RealTarget(owningObject.NakedObject); INakedObjectAdapter result = actionSpec.GetFacet<IActionInvocationFacet>().Invoke(target, parms, page, lifecycleManager, metamodelManager, session, manager, messageBroker, transactionManager); if (result == null) { return null; } if (result.Spec.IsCollection) { return factory.CreateTestCollection(result); } return factory.CreateTestObject(result); }
public void LookupMethodMultiple() { RootObjectDefinition feedDef = new RootObjectDefinition(typeof(NewsFeed)); feedDef.IsSingleton = false; feedDef.PropertyValues.Add("name", "Bingo"); RootObjectDefinition testObjectDef = new RootObjectDefinition(typeof(TestObject)); testObjectDef.IsSingleton = false; testObjectDef.PropertyValues.Add("name", "Miki Nakatani"); RootObjectDefinition managerDef = new RootObjectDefinition(typeof(TestObjectAndNewsFeedFactory)); managerDef.MethodOverrides.Add(new LookupMethodOverride("CreateNewsFeed", "feed")); managerDef.MethodOverrides.Add(new LookupMethodOverride("CreateTestObject", "test")); DefaultListableObjectFactory factory = new DefaultListableObjectFactory(); factory.RegisterObjectDefinition("manager", managerDef); factory.RegisterObjectDefinition("feed", feedDef); factory.RegisterObjectDefinition("test", testObjectDef); TestObjectAndNewsFeedFactory manager = (TestObjectAndNewsFeedFactory)factory["manager"]; INewsFeedManager newsFeedManager = manager; NewsFeed feed1 = newsFeedManager.CreateNewsFeed(); Assert.IsNotNull(feed1, "The CreateNewsFeed() method is not being replaced."); NewsFeed feed2 = newsFeedManager.CreateNewsFeed(); // assert that the object (prototype) is definitely being looked up each time... Assert.IsFalse(ReferenceEquals(feed1, feed2)); ITestObjectFactory toFactory = manager; ITestObject to1 = toFactory.CreateTestObject(); Assert.IsNotNull(to1, "The CreateTestObject() method is not being replaced."); ITestObject to2 = toFactory.CreateTestObject(); // assert that the object (prototype) is definitely being looked up each time... Assert.IsFalse(ReferenceEquals(to1, to2)); }
private ITestNaked DoInvoke(int page, params object[] parameters) { ResetLastMessage(); AssertIsValidWithParms(parameters); var parameterObjectsAdapter = parameters.AsTestNakedArray(framework.NakedObjectManager).Select(x => x.NakedObject).ToArray(); var parms = actionSpec.RealParameters(owningObject.NakedObject, parameterObjectsAdapter); var target = actionSpec.RealTarget(owningObject.NakedObject); var result = actionSpec.GetFacet <IActionInvocationFacet>().Invoke(target, parms, page, framework); if (result == null) { return(null); } if (result.Spec.IsCollection) { return(factory.CreateTestCollection(result)); } return(factory.CreateTestObject(result)); }