示例#1
0
        public INakedObjectAdapter RecreateInstance(IOid oid, ITypeSpec spec)
        {
            INakedObjectAdapter adapter = nakedObjectManager.GetAdapterFor(oid);

            if (adapter != null)
            {
                if (!adapter.Spec.Equals(spec))
                {
                    throw new AdapterException(Log.LogAndReturn($"Mapped adapter is for a different type of object: {spec.FullName}; {adapter}"));
                }
                return(adapter);
            }
            object obj = CreateObject(spec);

            return(nakedObjectManager.AdapterForExistingObject(obj, oid));
        }
        public INakedObjectAdapter RecreateInstance(IOid oid, ITypeSpec spec)
        {
            Log.DebugFormat("RecreateInstance oid: {0} hint: {1}", oid, spec);
            INakedObjectAdapter adapter = nakedObjectManager.GetAdapterFor(oid);

            if (adapter != null)
            {
                if (!adapter.Spec.Equals(spec))
                {
                    throw new AdapterException(string.Format("Mapped adapter is for a different type of object: {0}; {1}", spec.FullName, adapter));
                }
                return(adapter);
            }
            Log.DebugFormat("Recreating instance for {0}", spec);
            object obj = CreateObject(spec);

            return(nakedObjectManager.AdapterForExistingObject(obj, oid));
        }