예제 #1
0
        private ShardedSubcriteriaImpl CreateSubCriteria(ISubcriteriaFactory factory)
        {
            // first build our sharded subcrit
            var subCrit = new ShardedSubcriteriaImpl(shards, parent);

            foreach (IShard shard in shards)
            {
                // see if we already have a concreate Criteria object for each shard
                if (shardToCriteriaMap[shard] != null)
                {
                    // we already have a concreate Criteria for this shard, so create
                    // a subcrit for it using the provided factory
                    factory.CreateSubcriteria(this, shardToEventListMap[shard]);
                }
                else
                {
                    // we do not yet have a concrete Criteria object for this shard
                    // so register an event that will create a proper subcrit when we do
                    ICriteriaEvent subCriteriaEvent = new CreateSubcriteriaEvent(factory,
                                                                                 subCrit.SubcriteriaRegistrar(
                                                                                     shard), shardToCriteriaMap,
                                                                                 shardToEventListMap);
                    shardToEventListMap[shard].Add(subCriteriaEvent);
                }
            }
            return(subCrit);
        }
예제 #2
0
        /**
         * Creating sharded subcriteria is tricky.  We need to give the client a
         * reference to a ShardedSubcriteriaImpl (which to the client just looks like
         * a Criteria object).  Then, for each shard where the Criteria has already been
         * established we need to create the actual subcriteria, and for each shard
         * where the Criteria has not yet been established we need to register an
         * event that will create the Subcriteria when the Criteria is established.
         */
        private ShardedSubcriteriaImpl CreateSubcriteria(ISubcriteriaFactory factory)
        {
            var subCrit = new ShardedSubcriteriaImpl(shards, this);

            foreach (IShard shard in shards)
            {
                ICriteria crit = shard.GetCriteriaById(criteriaId);
                if (crit != null)
                {
                    factory.CreateSubcriteria(crit, NoCriteriaEvents);
                }
                else
                {
                    var subCriteriaEvent = new CreateSubcriteriaEvent(factory,
                                                                      subCrit.SubcriteriaRegistrar(
                                                                          shard),
                                                                      subCrit.ShardToCriteriaMap,
                                                                      subCrit.ShardToEventListMap);
                    shard.AddCriteriaEvent(criteriaId, subCriteriaEvent);
                }
            }
            return(subCrit);
        }