public override void Init(INakedObjectAdapter collection, INakedObjectAdapter[] initData) { IList wrappedCollection = AsCollection(collection); List<object> toAdd = initData.Select(no => no.Object).Where(obj => !wrappedCollection.Contains(obj)).ToList(); toAdd.ForEach(obj => wrappedCollection.Add(obj)); List<object> toRemove = wrappedCollection.Cast<object>().Where(o => !initData.Select(x => x.Object).Contains(o)).ToList(); toRemove.ForEach(wrappedCollection.Remove); }
public void Invoke(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter[] parameters, bool queryOnly, IIdentifier identifier, ISession session, ILifecycleManager lifecycleManager) { IAuditor auditor = GetAuditor(nakedObjectAdapter, lifecycleManager); IPrincipal byPrincipal = session.Principal; string memberName = identifier.MemberName; if (nakedObjectAdapter.Spec is IServiceSpec) { string serviceName = nakedObjectAdapter.Spec.GetTitle(nakedObjectAdapter); auditor.ActionInvoked(byPrincipal, memberName, serviceName, queryOnly, parameters.Select(no => no.GetDomainObject()).ToArray()); } else { auditor.ActionInvoked(byPrincipal, memberName, nakedObjectAdapter.GetDomainObject(), queryOnly, parameters.Select(no => no.GetDomainObject()).ToArray()); } }
public string InvalidReason(INakedObjectAdapter target, INakedObjectAdapter[] proposedArguments) { if (methodDelegate != null) { return (string)methodDelegate(target.GetDomainObject(), proposedArguments.Select(no => no.GetDomainObject()).ToArray()); } //Fall back (e.g. if method has > 6 params) on reflection... Log.WarnFormat("Invoking validate method via reflection as no delegate {0}.{1}", target, method); return (string)InvokeUtils.Invoke(method, target, proposedArguments); }
public override INakedObjectAdapter Invoke(INakedObjectAdapter inObjectAdapter, INakedObjectAdapter[] parameters, ILifecycleManager lifecycleManager, IMetamodelManager manager, ISession session, INakedObjectManager nakedObjectManager, IMessageBroker messageBroker, ITransactionManager transactionManager) { if (parameters.Length != paramCount) { Log.Error(actionMethod + " requires " + paramCount + " parameters, not " + parameters.Length); } object result; if (actionDelegate != null) { result = actionDelegate(inObjectAdapter.GetDomainObject(), parameters.Select(no => no.GetDomainObject()).ToArray()); } else { Log.WarnFormat("Invoking action via reflection as no delegate {0}.{1}", onType, actionMethod); result = InvokeUtils.Invoke(actionMethod, inObjectAdapter, parameters); } INakedObjectAdapter adaptedResult = nakedObjectManager.CreateAdapter(result, null, null); return adaptedResult; }
public string Execute(INakedObjectAdapter obj, INakedObjectAdapter[] parameters) { return methodDelegate(obj.GetDomainObject(), parameters.Select(no => no.GetDomainObject()).ToArray()) as string; }
public static object Invoke(MethodInfo method, INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter[] parameters) { object[] parameterPocos = parameters == null ? new object[] {} : parameters.Select(p => p == null ? null : p.Object).ToArray(); return Invoke(method, nakedObjectAdapter.Object, parameterPocos); }