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();
		}
Example #2
0
		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);
		}
Example #3
0
		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
		}
Example #6
0
        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);
        }
Example #7
0
        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());
            }
        }
Example #9
0
        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);


        }
Example #10
0
        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);

        }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
        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();
        }
Example #15
0
        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));
        }
Example #16
0
        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);
        }
Example #17
0
        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);
        }
Example #18
0
        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);
        }
Example #19
0
        /// <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);
        }
Example #20
0
        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;
            }
        }
Example #21
0
        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);
        }
Example #22
0
        �������� //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);
                    ����������������
                }
                ������������
            }

            ��������
        }
Example #23
0
        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));
        }
Example #24
0
        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);
        }
Example #25
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="identityMap"></param>
		internal CmObjectSurrogateRepository(IdentityMap identityMap)
		{
			if (identityMap == null) throw new ArgumentNullException("identityMap");
			m_identityMap = identityMap;
		}
Example #26
0
 public SearchTransactions(IdentityMap im, ClientManager clientManager)
 {
     _im            = im;
     _clientManager = clientManager;
 }
Example #27
0
 public MagazineCatalog(UnitOfWork unitOfWork, IdentityMap im)
 {
     _unitOfWork = unitOfWork;
     _im         = im;
 }
 public virtual void OnPersist(PersistEvent @event)
 {
     OnPersist(@event, IdentityMap.Instantiate(10));
 }
Example #29
0
 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));
 }
Example #31
0
 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;
		}
Example #33
0
 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;
 }
Example #36
0
 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;
 }
Example #38
0
 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;
		}
Example #40
0
		/// <summary>
		/// The point of this subclass is to do this efficiently!
		/// </summary>
		protected override int GetHvoUsing(IdentityMap identityMap)
		{
			return Hvo;
		}
Example #41
0
 public MusicCatalog(UnitOfWork unitOfWork, IdentityMap im)
 {
     _unitOfWork = unitOfWork;
     _im         = im;
 }
Example #42
0
		int ICmObjectOrIdInternal.GetHvo(IdentityMap map)
		{
			return GetHvoUsing(map);
		}
 public virtual void OnMerge(MergeEvent @event)
 {
     OnMerge(@event, IdentityMap.Instantiate(10));
 }
Example #44
0
        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);
        }
Example #45
0
 public virtual void OnRefresh(RefreshEvent @event)
 {
     OnRefresh(@event, IdentityMap.Instantiate(10));
 }
Example #46
0
        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 );
            };
        }
Example #47
0
 protected virtual IDictionary GetIdentityMap()
 {
     return(IdentityMap.Instantiate(10));
 }
Example #48
0
        public void has_negative()
        {
            var serializer = new JilSerializer();

            var map = new IdentityMap(serializer);
            map.Has<Target>(Guid.NewGuid()).ShouldBeFalse();
        }
 public Session(string connectionInfo)
 {
     this.Id     = Guid.NewGuid();
     this.map    = new IdentityMap();
     this.DbInfo = new DbSessionInfo(connectionInfo);
 }
Example #50
0
        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);

        }
Example #51
0
 public void EjectAllOfType(Type type)
 {
     IdentityMap.RemoveAllOfType(type);
 }
 public EmployeeRepository()
 {
     _employeeMap = new IdentityMap<Employee>();
 }
Example #53
0
        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();

        }
Example #54
0
        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);
        }
Example #55
0
 /// <summary>
 /// Returns copy-entity mappings
 /// </summary>
 /// <returns></returns>
 public IDictionary InvertMap()
 {
     return(IdentityMap.Invert(entityToCopyMap));
 }
Example #56
0
        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);
        }
Example #57
0
		// 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));
		}
Example #58
0
 public Portfolio()
 {
     this.m_idMapContract = new IdentityMap <T>();
 }
Example #59
0
        public void get_with_miss_in_database()
        {
            var serializer = new JilSerializer();

            var map = new IdentityMap(serializer);
            map.Get<Target>(Guid.NewGuid(), () => null).ShouldBeNull();
        }
Example #60
0
 public CacheCommandProcessor(IdentityMap entities, ReaderWriterLock rwl)
 {
     _Entities = entities;
     _RWL = rwl;
 }