internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) { m_peerProcesses = new Dictionary<int, Process>(); m_peerID = Guid.NewGuid(); }
protected virtual int GetHvoUsing(IdentityMap map) { var canonicalId = map.GetObjectOrIdWithHvoFromGuid(Guid); // This will force an exception rather than an infinite loop if we don't get back a subclass // that doesn't need the map. return ((ICmObjectOrIdInternal) canonicalId).GetHvo(null); }
public override void InitializeConfiguration() { _Entities = new IdentityMap(); _Scalars = new Dictionary<string,object>(); _Loads = new Hashtable(); _RWL = new ReaderWriterLock(); }
protected ClientServerBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) { }
internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc, IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings) { m_peerProcesses = new Dictionary<int, Process>(); m_peerID = Guid.NewGuid(); #if __MonoCS__ // /dev/shm is not guaranteed to be available on all systems, so fall back to temp m_commitLogDir = Directory.Exists("/dev/shm") ? "/dev/shm" : Path.GetTempPath(); #endif }
public void get_value_on_first_request() { var target = Target.Random(); var serializer = new TestsSerializer(); var map = new IdentityMap(serializer, null); var target2 = map.Get<Target>(target.Id, serializer.ToJson(target), null); target2.Id.ShouldBe(target.Id); target2.ShouldNotBeTheSameAs(target); }
public void get_value_on_first_request_with_lazy_json() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); var target2 = map.Get<Target>(target.Id, () => serializer.ToJson(target)); target2.Id.ShouldBe(target.Id); target2.ShouldNotBeTheSameAs(target); }
public void TestSimpleObjectMap() { IdentityMap<SimpleObject> simpleMap = new IdentityMap<SimpleObject>(); simpleMap.Add(new SimpleObject(), Guid.NewGuid()); simpleMap.Add(new SimpleObject(), Guid.NewGuid()); simpleMap.Add(new SimpleObject(), Guid.NewGuid()); simpleMap.Add(new SimpleObject(), Guid.NewGuid()); foreach (SimpleObject curObj in simpleMap.GetEnumerable()) { Console.WriteLine(curObj.ToString()); } }
public void get_with_concrete_type() { var serializer = new JsonNetSerializer(); var camaro = new NulloIdentityMapTests.Camaro(); var json = serializer.ToJson(camaro); var map = new IdentityMap(serializer); map.Get<NulloIdentityMapTests.Car>(camaro.Id, typeof(NulloIdentityMapTests.Camaro), json) .ShouldBeOfType<NulloIdentityMapTests.Camaro>() .Id.ShouldBe(camaro.Id); }
public void remove_item() { var target = Target.Random(); var target2 = Target.Random(); target2.Id = target.Id; var serializer = new JilSerializer(); var map = new IdentityMap(serializer); var target3 = map.Get<Target>(target.Id, serializer.ToJson(target)); // now remove it map.Remove<Target>(target.Id); var target4 = map.Get<Target>(target.Id, serializer.ToJson(target2)); target4.ShouldNotBeNull(); target4.ShouldNotBeTheSameAs(target3); }
public void get_value_on_subsequent_requests_with_lazy_json() { var target = Target.Random(); var serializer = new TestsSerializer(); var map = new IdentityMap(serializer, null); var target2 = map.Get <Target>(target.Id, () => new FetchResult <Target>(target, serializer.ToJson(target).ToReader(), null)); var target3 = map.Get <Target>(target.Id, () => new FetchResult <Target>(target, serializer.ToJson(target).ToReader(), null)); var target4 = map.Get <Target>(target.Id, () => new FetchResult <Target>(target, serializer.ToJson(target).ToReader(), null)); var target5 = map.Get <Target>(target.Id, () => new FetchResult <Target>(target, serializer.ToJson(target).ToReader(), null)); target2.Id.ShouldBe(target.Id); target3.Id.ShouldBe(target.Id); target4.Id.ShouldBe(target.Id); target5.Id.ShouldBe(target.Id); target2.ShouldBeTheSameAs(target3); target2.ShouldBeTheSameAs(target4); target2.ShouldBeTheSameAs(target5); }
public void get_value_on_subsequent_requests() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); var target2 = map.Get<Target>(target.Id, serializer.ToJson(target)); var target3 = map.Get<Target>(target.Id, serializer.ToJson(target)); var target4 = map.Get<Target>(target.Id, serializer.ToJson(target)); var target5 = map.Get<Target>(target.Id, serializer.ToJson(target)); target2.Id.ShouldBe(target.Id); target3.Id.ShouldBe(target.Id); target4.Id.ShouldBe(target.Id); target5.Id.ShouldBe(target.Id); target2.ShouldBeTheSameAs(target3); target2.ShouldBeTheSameAs(target4); target2.ShouldBeTheSameAs(target5); }
public void get_value_on_subsequent_requests() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); var target2 = map.Get <Target>(target.Id, serializer.ToJson(target)); var target3 = map.Get <Target>(target.Id, serializer.ToJson(target)); var target4 = map.Get <Target>(target.Id, serializer.ToJson(target)); var target5 = map.Get <Target>(target.Id, serializer.ToJson(target)); target2.Id.ShouldBe(target.Id); target3.Id.ShouldBe(target.Id); target4.Id.ShouldBe(target.Id); target5.Id.ShouldBe(target.Id); target2.ShouldBeTheSameAs(target3); target2.ShouldBeTheSameAs(target4); target2.ShouldBeTheSameAs(target5); }
public MatchupResultViewModel( MatchupResult result, IdentityMap<User> userMap, Map gameMap ) { Timestamp = result.Timestamp; HowRecent = ( DateTime.Now - Timestamp ).ToShortString() + " ago"; Comment = result.Comment; Team1Score = result.Team1Score; Team2Score = result.Team2Score; Winner = result.Winner; this.Map = gameMap; Team1PlayerNames = result .Team1UserIds .Select( userMap.Lookup ) .Select(user => user.Name) .ToList(); Team2PlayerNames = result .Team2UserIds .Select( userMap.Lookup ) .Select(user => user.Name) .ToList(); }
public IActionResult Quiz(Questions question, string action) { if (!ModelState.IsValid) { ViewBag.Problem = question.problem; return(View(question)); } IdentityMap.Get().Last().yanswer = question.yanswer; if (IdentityMap.Get().Last().answer == Convert.ToInt32(question.yanswer)) { IdentityMap.rights++; } IdentityMap.alls++; if (action == "Finish") { return(RedirectToAction("QuizResult")); } Questions act = new Questions(); ViewBag.Problem = act.problem; IdentityMap.AddAction(act); return(View(act)); }
public bool Add(ITerm <Value> Term, Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap, Dictionary <string, HashSet <long> > ResolvedSchedule, bool CheckForPerRisk = true) { Subject NodeIdentity = Term.GetSubject(); bool IsAddSuccessful = true; if (NodeIdentity == null) { NodeIdentity = EMPTYSUBJECTCONSTRAINT; } TermCollection TermCollection = (IdentityMap.ContainsKey(NodeIdentity) ? IdentityMap[NodeIdentity].GetContent() : new TermCollection(NodeIdentity)); // Switching off the following check intentionally, in order to allow redundant terms //if (TermCollection.Contains(Term)) // throw new ArgumentException("A term node with the same identity (i.e. subject) already contains this term in its collection!"); IsAddSuccessful = TermCollection.Add(Term); if (IsAddSuccessful && !IdentityMap.ContainsKey(NodeIdentity)) { TermNode _TermNode = new TermNode(TermCollection); IsAddSuccessful &= base.Add(_TermNode); if (IsAddSuccessful) { IdentityMap.Add(NodeIdentity, _TermNode); // A newly added term node (i.e. with no parent or child links) is both a root and a leaf, trivially. IsAddSuccessful &= RootNodes.Add(_TermNode); ExecutionState.RegisterModificationInGraphTopology(); } } return(IsAddSuccessful); }
public void Test_SearchResult_NotFound() { Customer customer1 = new Customer(null) { Number = "001" }; Customer customer2 = new Customer(null) { Number = "002" }; Customer customer3 = new Customer(null) { Number = "003" }; Customer customer4 = new Customer(null) { Number = "004", Name = "John Doe" }; Customer customer5 = new Customer(null) { Number = "005" }; IIdentityMap <Customer> map = new IdentityMap <Customer>(); map.AddEntity(customer1); map.AddEntity(customer2); map.AddEntity(customer3); map.AddEntity(customer4); map.AddEntity(customer5); Assert.AreEqual(5, map.Count); Customer matchedCustomer = map.SearchBy() .SetFilter(customer => customer.Number, "007") .GetEntity(); Assert.IsNull(matchedCustomer); }
public void Test_Identity_Updates() { Customer customer1 = new Customer(null) { Number = "001", Name = "John Doe" }; IIdentityMap <Customer> map = new IdentityMap <Customer>(); map.AddEntity(customer1); customer1.Number = "002"; map.AddEntity(customer1); //Updating primary key values Customer matchedCustomer = map.SearchBy().SetFilter(customer => customer.Number, "002").GetEntity(); Customer notFoundCustomer = map.SearchBy().SetFilter(customer => customer.Number, "001").GetEntity(); Assert.AreEqual(1, map.Count); Assert.IsTrue(notFoundCustomer == null); Assert.IsNotNull(matchedCustomer); Assert.AreEqual(customer1.Number, matchedCustomer.Number); Assert.AreEqual(customer1.Name, matchedCustomer.Name); }
/// <summary> /// Get the {@link CollectionLoadContext} associated with the given /// {@link ResultSet}, creating one if needed. /// </summary> /// <param name="resultSet">The result set for which to retrieve the context. </param> /// <returns> The processing context. </returns> public CollectionLoadContext GetCollectionLoadContext(DbDataReader resultSet) { CollectionLoadContext context = null; if (collectionLoadContexts == null) { collectionLoadContexts = IdentityMap.Instantiate(8); } else { context = (CollectionLoadContext)collectionLoadContexts[resultSet]; } if (context == null) { if (log.IsDebugEnabled()) { log.Debug("constructing collection load context for result set [{0}]", resultSet); } context = new CollectionLoadContext(this, resultSet); collectionLoadContexts[resultSet] = context; } return(context); }
public void Store(object entity) { Type entityType = entity.GetType(); PropertyInfo identityProperty = CouchDatabase.CouchDocumentConvention.GetIdentityPropertyFor(entityType); object id = null; if (identityProperty != null) { id = GetIdentityValueFor(entity, identityProperty); if (id == null) { id = CouchDatabase.CouchDocumentConvention.GenerateIdentityFor(identityProperty.PropertyType); identityProperty.SetValue(entity, id, null); } } if (id != null) { if (IdentityMap.ContainsKey(id.ToString())) { if (ReferenceEquals(IdentityMap[id.ToString()], entity)) { return; } throw new NonUniqueEntityException("Attempted to associate a different entity with id '" + id + "'."); } var entityMetadata = new EntityMetadata { Key = id.ToString(), Revision = String.Empty }; EntityMetadataMap.Add(entity, entityMetadata); IdentityMap[id.ToString()] = entity; } }
public IdentityMap <T> GetAllRiskItemsOfType <T>() where T : Identity { IdentityMap <T> idMapT = new IdentityMap <T>(); List <RiskItem> vRiskItem = new List <RiskItem>(); foreach (CoverNode cn in this.m_trCoverNode.MapIntIdToNode.Values) { //add the covernode vRiskItem.Add(cn); if (cn.Subject != null) { foreach (RiskItem riskItem in cn.Subject.Schedule.SetSchedule) { vRiskItem.Add(riskItem); if (riskItem is _Contract) { //drill into the contract List <RiskItem> vIndirectRiskItem = ((_Contract)riskItem).GetAllRiskItems().GetAllObjects(); foreach (RiskItem riskItemNested in vIndirectRiskItem) { vRiskItem.Add(riskItemNested); } } } } } foreach (T riskItem in vRiskItem.OfType <T>()) { idMapT.AddObjectToMap((T)riskItem); } return(idMapT); }
�������� //process cascade save/update at the start of a flush to discover �������� //any newly referenced entity that must be passed to saveOrUpdate(), �������� //and also apply orphan delete ��������private void PrepareEntityFlushes(IEventSource session) �������� { ������������log.Debug("processing flush-time cascades"); � ������������ICollection list = IdentityMap.ConcurrentEntries(session.PersistenceContext.EntityEntries); ������������//safe from concurrent modification because of how entryList() is implemented on IdentityMap ������������foreach(DictionaryEntry me in list) ������������ { ����������������EntityEntry entry = (EntityEntry)me.Value; ����������������Status status = entry.Status; ����������������if(status == Status.Loaded || status == Status.Saving) ���������������� { ��������������������CascadeOnFlush(session, entry.Persister, me.Key, Anything); ���������������� } ������������ } �������� }
public void SaveChanges() { if (!_unitOfWork.HasAnyUpdates()) { return; } assertNotDisposed(); _connection.BeginTransaction(); applyProjections(); _sessionListeners.Each(x => x.BeforeSaveChanges(this)); var batch = new UpdateBatch(_store, _connection, IdentityMap.Versions, WriterPool); var changes = _unitOfWork.ApplyChanges(batch); try { _connection.Commit(); IdentityMap.ClearChanges(); } catch (Exception) { // This code has a try/catch in it to stop // any errors from propogating from the rollback _connection.Rollback(); throw; } Logger.RecordSavedChanges(this, changes); _sessionListeners.Each(x => x.AfterCommit(this, changes)); }
public void Test_Clear_Identities() { Customer customer1 = new Customer(null) { Number = "001" }; Customer customer2 = new Customer(null) { Number = "002" }; Customer customer3 = new Customer(null) { Number = "003" }; Customer customer4 = new Customer(null) { Number = "004", Name = "John Doe" }; Customer customer5 = new Customer(null) { Number = "005" }; IIdentityMap <Customer> map = new IdentityMap <Customer>(); map.AddEntity(customer1); map.AddEntity(customer2); map.AddEntity(customer3); map.AddEntity(customer4); map.AddEntity(customer5); Assert.AreEqual(5, map.Count); map.ClearEntities(); Assert.AreEqual(0, map.Count); }
/// <summary> /// Constructor /// </summary> /// <param name="identityMap"></param> internal CmObjectSurrogateRepository(IdentityMap identityMap) { if (identityMap == null) throw new ArgumentNullException("identityMap"); m_identityMap = identityMap; }
public SearchTransactions(IdentityMap im, ClientManager clientManager) { _im = im; _clientManager = clientManager; }
public MagazineCatalog(UnitOfWork unitOfWork, IdentityMap im) { _unitOfWork = unitOfWork; _im = im; }
public virtual void OnPersist(PersistEvent @event) { OnPersist(@event, IdentityMap.Instantiate(10)); }
public override void Visit(IdentityMap <MediaTypeDto, MediaType> map) { map.Dto.ID = map.Entity.ID; }
protected override IDictionary GetMergeMap(object anything) { return(IdentityMap.Invert((IDictionary)anything)); }
public ModelCopyCatalog(UnitOfWork unitOfWork, IdentityMap im) { _unitOfWork = unitOfWork; _im = im; }
internal static IObjectServer OpenServerFileInternal(FdoCache cache, IdentityMap identityMap, string databasePath, int port, out IServerConfiguration serverConfig) { IObjectServer databaseServer = null; serverConfig = null; try { serverConfig = ConfigureServer(cache, identityMap); databaseServer = Db4oClientServer.OpenServer(serverConfig, databasePath, port); databaseServer.GrantAccess(kUser, kPassword); } catch (Exception) { if (databaseServer != null) { databaseServer.Close(); databaseServer.Dispose(); } throw; } return databaseServer; }
public PersonCatalog(UnitOfWork unitOfWork, IdentityMap im) { _unitOfWork = unitOfWork; _im = im; }
public Session(string connectionInfo) { this.Id = Guid.NewGuid(); this.map = new IdentityMap(); this.DbInfo = new DbSessionInfo(connectionInfo); }
public EmployeeRepository(IdentityMap<Employee> identityMap) { _identityMap = identityMap; }
public override void Visit(IdentityMap <TrackDto, Track> map) { map.Dto.ID = map.Entity.ID; }
public StubEmployeeRepository(IdentityMap <Employee> employeeMap, Employee employeeToFind) { _employeeMap = employeeMap; _employeeToFind = employeeToFind; }
protected override IDictionary GetIdentityMap() { return(IdentityMap.InstantiateSequenced(10)); }
// Doc: // Network Server: http://developer.db4o.com/Documentation/Reference/db4o-7.13/net35/reference/html/reference/client-server/networked/network_server.html // CommonConfiguration interface: http://developer.db4o.com/documentation/reference/db4o-7.12/java/api/com/db4o/config/CommonConfiguration.html /// <summary> /// Configure the db4o server with different settings. /// This is is only and should only be used by the remote database service. (FwRemoteDatabaseConnectorService) /// </summary> private static IServerConfiguration ConfigureServer(FdoCache cache, IdentityMap identityMap) { // These configuration settings are based on Randy's original db4o embedded back end. IServerConfiguration serverConfig = Db4oClientServer.NewServerConfiguration(); serverConfig.TimeoutServerSocket = (int)TimeSpan.FromHours(24).TotalMilliseconds; serverConfig.Common.RegisterTypeHandler( new CmObjectSurrogateTypeHandlerPredicate(), CmObjectSurrogateTypeHandler); serverConfig.Common.RegisterTypeHandler( new CustomFieldInfoTypeHandlerPredicate(), new CustomFieldInfoTypeHandler()); serverConfig.Common.RegisterTypeHandler( new ModelVersionNumberTypeHandlerPredicate(), new ModelVersionNumberTypeHandler()); // "A tuning hint: If callbacks are not used, you can turn this // feature off, to prevent db4o from looking for callback methods // in persistent classes. This will increase the performance on // system startup...In client/server environment this setting // should be used on both client and server. " serverConfig.Common.Callbacks = false; // "This method must be called before opening a database... // Performance may be improved by running db4o without using weak // references durring memory management at the cost of higher // memory consumption or by alternatively implementing a manual // memory management scheme using ExtObjectContainer.purge(java.lang.Object) // ...Setting the value to false causes db4o to use hard references // to objects, preventing the garbage collection process from // disposing of unused objects. // REVIEW (SteveMiller): May want to review the setting of WeakReferences // with Randy, and revisit the decision on setting it to false. serverConfig.Common.WeakReferences = false; // "advises db4o to try instantiating objects with/without calling // constructors...In client/server environment this setting should // be used on both client and server. serverConfig.Common.CallConstructors = false; serverConfig.Common.ActivationDepth = kActivationDepth; serverConfig.Common.UpdateDepth = kUpdateDepth; // "tuning feature: configures whether db4o checks all persistent // classes upon system startup, for added or removed fields. " //-- // There is a db4o bugg in the serialization of the query when // DetectSchemaChanges = false and using QueryByExample. See: // http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9894/afv/topic/Default.aspx#28040 serverConfig.Common.DetectSchemaChanges = kfDetectSchemaChanges; // tuning feature: configures whether db4o should try to // instantiate one instance of each persistent class on system // startup. serverConfig.Common.TestConstructors = false; // The standard setting is 1 allowing for a maximum database file // size of 2GB. This value can be increased to allow larger // database files, although some space will be lost to padding // because the size of some stored objects will not be an exact // multiple of the block size. A recommended setting for large // database files is 8, since internal pointers have this length. serverConfig.File.BlockSize = kBlockSize; // "configures the size of BTree nodes in indexes. Default setting: 100 // Lower values will allow a lower memory footprint and more efficient // reading and writing of small slots. Higher values will reduce the // overall number of read and write operations and allow better // performance at the cost of more RAM use...This setting should be // used on both client and server in client-server environment. serverConfig.Common.BTreeNodeSize = kBTreeNodeSize; serverConfig.Common.StringEncoding = StringEncodings.Utf8(); // Queries need to be executed in Snapshot mode so that the results // aren't changed by transactions that happen while the query is // in progress. Details on query mode can be found at: // http://developer.db4o.com/Documentation/Reference/db4o-7.12/net35/reference/Content/configuration/common/query_modes.htm serverConfig.Common.Queries.EvaluationMode(QueryEvaluationMode.Snapshot); // For each of ObjectClass(type), Randy originally had .Indexed(true); // For surrogates we have a custom serializer so we don't need db4o trying to read // (or especially write) things it is connected to. And there is nothing they connect // to that requires cascading deletes. var type = typeof(CmObjectSurrogate); serverConfig.Common.ObjectClass(type).CascadeOnDelete(true); serverConfig.Common.ObjectClass(type).UpdateDepth(kUpdateDepth); serverConfig.Common.ObjectClass(type).MinimumActivationDepth(kActivationDepth); serverConfig.Common.ObjectClass(type).MaximumActivationDepth(kActivationDepth); type = typeof(CustomFieldInfo); serverConfig.Common.ObjectClass(type).CascadeOnDelete(true); serverConfig.Common.ObjectClass(type).UpdateDepth(kUpdateDepth); serverConfig.Common.ObjectClass(type).MinimumActivationDepth(kActivationDepth); serverConfig.Common.ObjectClass(type).MaximumActivationDepth(kActivationDepth); type = typeof(ModelVersionNumber); serverConfig.Common.ObjectClass(type).CascadeOnDelete(true); serverConfig.Common.ObjectClass(type).UpdateDepth(kUpdateDepth); serverConfig.Common.ObjectClass(type).MinimumActivationDepth(kActivationDepth); serverConfig.Common.ObjectClass(type).MaximumActivationDepth(kActivationDepth); return serverConfig; }
/// <summary> /// The point of this subclass is to do this efficiently! /// </summary> protected override int GetHvoUsing(IdentityMap identityMap) { return Hvo; }
public MusicCatalog(UnitOfWork unitOfWork, IdentityMap im) { _unitOfWork = unitOfWork; _im = im; }
int ICmObjectOrIdInternal.GetHvo(IdentityMap map) { return GetHvoUsing(map); }
public virtual void OnMerge(MergeEvent @event) { OnMerge(@event, IdentityMap.Instantiate(10)); }
public void get_value_on_subsequent_requests_with_lazy_json() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer, null); var target2 = map.Get<Target>(target.Id, () => new FetchResult<Target>(target, serializer.ToJson(target))); var target3 = map.Get<Target>(target.Id, () => new FetchResult<Target>(target, serializer.ToJson(target))); var target4 = map.Get<Target>(target.Id, () => new FetchResult<Target>(target, serializer.ToJson(target))); var target5 = map.Get<Target>(target.Id, () => new FetchResult<Target>(target, serializer.ToJson(target))); target2.Id.ShouldBe(target.Id); target3.Id.ShouldBe(target.Id); target4.Id.ShouldBe(target.Id); target5.Id.ShouldBe(target.Id); target2.ShouldBeTheSameAs(target3); target2.ShouldBeTheSameAs(target4); target2.ShouldBeTheSameAs(target5); }
public virtual void OnRefresh(RefreshEvent @event) { OnRefresh(@event, IdentityMap.Instantiate(10)); }
public MatchupModule( IDatabase database, Settings settings, IEnumerable<IMatchupProposer> proposers ) : base(database) { this.proposers = proposers.ToArray(); Get[Route.FindTeams] = o => { var model = new FindTeamsModel() { Game = game, AvailablePlayers = database.GetPlayersForGame( game.Id ).OrderBy( player => player.Name ).ToArray(), AlgorithmName = App.MatchupProposer.GetType().Name, }; return View[Route.FindTeams, model]; }; Get[Route.SetMatchupProposer] = o => { var model = new SetMatchupProposerViewModel( proposers, App.MatchupProposer ); return View[Route.SetMatchupProposer, model]; }; Post[Route.SetMatchupProposer] = o => { var request = this.Bind<SetMatchupProposerRequest>(); var matchupProposer = GetAlgorithm( request.SelectedAlgorithmTypeName ); App.MatchupProposer = matchupProposer; return Response.AsRedirect( Route.FindTeams ); }; Get[Route.GetProposedMatchups] = o => { var request = this.Bind<GetProposedMatchupsRequest>(); var proposer = App.MatchupProposer; var response = new GetProposedMatchupsResponse(); try { var gameKey = (string)o.gameKey; var game = database.GetGameByKey( gameKey ); if ( null == request.PlayerIds || request.PlayerIds.Count < 2 ) { throw new Exception( "Two or more players must be selected" ); } var players = request.PlayerIds.Select( database.GetUserById ).ToArray(); var proposedMatchups = proposer.GetMatchups( game, players ).OrderBy( matchup => matchup.Imbalance ).ToArray(); proposedMatchups = CleanUp( proposedMatchups ); response.ProposedMatchups = proposedMatchups; } catch ( Exception e ) { response.ErrorMessage = e.Message; } return View[Route.GetProposedMatchups, response]; }; Post[Route.PresentMatchupForSaving] = o => { var json = (string)Request.Form.matchup; var matchup = json.FromJson<ProposedMatchup>(); return View[Route.SaveMatchupResult, new SaveMatchupResultViewModel(matchup, database.GetMaps(matchup.Game.Id))]; }; Post[Route.SaveMatchupResult] = o => { var result = this.Bind<MatchupResult>(); database.SaveMatchupResult( result ); return Response.AsRedirect( Route.ViewResults ); }; Get[Route.ViewResults] = o => { var game = database.GetGameByKey( o.gameKey ); var matchupResults = database.GetMatchupResultsByGame( game.Id ); var userMap = new IdentityMap<User>( database.GetUserById ); var model = new List<MatchupResultViewModel>(); foreach ( var matchupResult in matchupResults ) { var map = database.GetMapById(matchupResult.MapId); model.Add(new MatchupResultViewModel(matchupResult, userMap, map)); } return View[Route.ViewResults, model]; }; Get[Route.SelectPlayers] = o => { var model = new SelectPlayersViewModel(); var users = database.GetUsers(); var playersForGame = database.GetPlayersForGame( this.game.Id ); foreach ( var user in users ) { model.SelectableUsers.Add( new Selectable<User> { Item = user, IsSelected = playersForGame.Any( user1 => user1.Id == user.Id ), } ); } return View[Route.SelectPlayers, model]; }; Post[Route.SelectPlayers] = o => { var request = this.Bind<SelectPlayersRequest>(); database.SetActivePlayersForGame( game.Id, request.UserIds ); return Response.AsRedirect( Route.FindTeams ); }; }
protected virtual IDictionary GetIdentityMap() { return(IdentityMap.Instantiate(10)); }
public void has_negative() { var serializer = new JilSerializer(); var map = new IdentityMap(serializer); map.Has<Target>(Guid.NewGuid()).ShouldBeFalse(); }
public void retrieve() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); map.Store(target.Id, target); map.Retrieve<Target>(target.Id).ShouldBeTheSameAs(target); }
public void EjectAllOfType(Type type) { IdentityMap.RemoveAllOfType(type); }
public EmployeeRepository() { _employeeMap = new IdentityMap<Employee>(); }
public void has_positive() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); map.Store(target.Id, target); map.Has<Target>(target.Id).ShouldBeTrue(); }
public void store() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer, null); map.Store(target.Id, target); map.Get<Target>(target.Id, "").ShouldBeTheSameAs(target); }
/// <summary> /// Returns copy-entity mappings /// </summary> /// <returns></returns> public IDictionary InvertMap() { return(IdentityMap.Invert(entityToCopyMap)); }
public void get_value_on_first_request_with_lazy_json() { var target = Target.Random(); var serializer = new JilSerializer(); var map = new IdentityMap(serializer); var json = serializer.ToJson(target); var clonedTarget = serializer.FromJson<Target>(json); var target2 = map.Get<Target>(target.Id, () => { return new FetchResult<Target>(clonedTarget, json); }); target2.Id.ShouldBe(target.Id); target2.ShouldNotBeTheSameAs(target); }
// This is used only by the factory methods (on IdentifyMap) that create one. static internal ICmObjectId FromGuid(Guid guid, IdentityMap map) { return map.GetCanonicalID(new CmObjectId(guid)); }
public Portfolio() { this.m_idMapContract = new IdentityMap <T>(); }
public void get_with_miss_in_database() { var serializer = new JilSerializer(); var map = new IdentityMap(serializer); map.Get<Target>(Guid.NewGuid(), () => null).ShouldBeNull(); }
public CacheCommandProcessor(IdentityMap entities, ReaderWriterLock rwl) { _Entities = entities; _RWL = rwl; }