/// <summary> /// Creates object from given revision ID returning the last commited state. /// This method is not usable on new uncommited objects, because they dont have commited state. /// Returned object is read only. /// </summary> /// <typeparam name="T">Type of object instance expected</typeparam> /// <param name="revisionId">Revision ID to create</param> /// <returns>Entity object instance</returns> public T SpawnImmutable <T>(Guid revisionId) { if (isolatedProvider.GetNodeState(revisionId) == NodeState.Created) { throw new ArgumentException("Operation not allowed for uncommited instance"); } object proxy = null; if (!immutableProxyMap.TryGetProxy(revisionId, out proxy)) { proxy = proxyCreatorService.NewObject <T>(runtimeProxyFacade, revisionId, true); immutableProxyMap.AddProxy(revisionId, proxy); } return((T)proxy); }
/// <summary> /// Creates object from given revision ID. If object version was /// altered in the workspace object returned would also appear altered. /// Returned object can be changed, but must be assigned in a tree to be reachable by the Commit. /// </summary> /// <typeparam name="T">Type of object instance expected</typeparam> /// <param name="revisionId">Revision ID to spawn</param> /// <returns>Entity object instance</returns> public T Spawn <T>(Guid revisionId) { object proxy = null; if (!mutableProxyMap.TryGetProxy(revisionId, out proxy)) { proxy = proxyCreatorService.NewObject <T>(runtimeProxyFacade, revisionId, false); mutableProxyMap.AddProxy(revisionId, proxy); } return((T)proxy); }
private object GetProxyInstance(bool isReadOnly, Guid referenceId, Guid typeId) { if (referenceId.Equals(Constants.NullReferenceNodeId)) { return(null); } else { object proxy = null; IProxyMap map = mutableProxyMap; var collectionService = collectionInstancesService; var objectService = objectInstancesService; if (isReadOnly) { map = immutableProxyMap; collectionService = immutableCollectionInstancesService; objectService = immutableInstancesService; } if (!map.TryGetProxy(referenceId, out proxy)) { if (typeId.Equals(Guid.Empty)) { if (collectionService.IsCollectionInstance(referenceId)) // TODO (nsabo) Merge this information into proxy static data { typeId = collectionService.GetInstanceTypeId(referenceId); } else { // Get type ID of referenced instance typeId = objectService.GetInstanceTypeId(referenceId); } } // Create proxy object proxy = proxyCreatorService.NewObject(this, typeId, referenceId, isReadOnly); // Add to proxy map map.AddProxy(referenceId, proxy); } return(proxy); } }