public object GetDomainObjectByOid(IOidTranslation objectId) {
            Type type = ValidateObjectId(objectId);
            string[] keys = GetKeys(objectId.InstanceId, type);

            NakedObjectSpecification spec = [email protected]().loadSpecification(type.FullName);

            NakedObject pattern = [email protected]().createTransientInstance(spec);

            PropertyInfo p = pattern.getObject().GetType().GetProperty("Id");
            ((WholeNumber) p.GetValue(pattern.getObject(), null)).setValue(int.Parse(keys.First()));

            var criteria = new TitleCriteria(spec, pattern.titleString(), false);
            TypedNakedCollection results = [email protected]().findInstances(criteria);

            if (results.size() == 0) {
                throw new ObjectResourceNotFoundNOSException(objectId.ToString());
            }

            return results.elementAt(0).getObject();
        }
Ejemplo n.º 2
0
        public object GetDomainObjectByOid(IOidTranslation objectId)
        {
            Type type = ValidateObjectId(objectId);

            string[] keys = GetKeys(objectId.InstanceId, type);

            NakedObjectSpecification spec = [email protected]().loadSpecification(type.FullName);

            NakedObject pattern = [email protected]().createTransientInstance(spec);

            PropertyInfo p = pattern.getObject().GetType().GetProperty("Id");

            ((WholeNumber)p.GetValue(pattern.getObject(), null)).setValue(int.Parse(keys.First()));

            var criteria = new TitleCriteria(spec, pattern.titleString(), false);
            TypedNakedCollection results = [email protected]().findInstances(criteria);

            if (results.size() == 0)
            {
                throw new ObjectResourceNotFoundNOSException(objectId.ToString());
            }

            return(results.elementAt(0).getObject());
        }