當前位置: 首頁>>代碼示例>>C#>>正文


C# Type.CollectionType類代碼示例

本文整理匯總了C#中NHibernate.Type.CollectionType的典型用法代碼示例。如果您正苦於以下問題:C# CollectionType類的具體用法?C# CollectionType怎麽用?C# CollectionType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CollectionType類屬於NHibernate.Type命名空間,在下文中一共展示了CollectionType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType type)
		{
			if (collection != null)
			{
				SessionImpl session = Session;
				IPersistentCollection coll;

				if (type.IsArrayType)
				{
					coll = session.GetArrayHolder(collection);
					// if no array holder we found an unwrappered array (this can't occur,
					// because we now always call wrap() before getting to here)
					// return (ah==null) ? true : searchForDirtyCollections(ah, type);
				}
				else
				{
					// if not wrappered yet, its dirty (this can't occur, because 
					// we now always call wrap() before getting to here) 
					// return ( ! (obj is AbstractPersistentCollection) ) ?
					//	true : SearchForDirtyCollections( (AbstractPersistentCollection) obj, type );
					coll = (IPersistentCollection) collection;
				}

				if (coll.IsDirty)
				{
					_dirty = true;
					return null; // NOTE: early exit
				}
			}
			return null;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:31,代碼來源:DirtyCollectionSearchVisitor.cs

示例2: ProcessReachableCollection

        /// <summary> 
        /// Initialize the role of the collection. 
        /// </summary>
        /// <param name="collection">The collection to be updated by reachibility. </param>
        /// <param name="type">The type of the collection. </param>
        /// <param name="entity">The owner of the collection. </param>
        /// <param name="session">The session.</param>
        public static void ProcessReachableCollection(IPersistentCollection collection, CollectionType type, object entity, ISessionImplementor session)
        {
            collection.Owner = entity;
            CollectionEntry ce = session.PersistenceContext.GetCollectionEntry(collection);

            if (ce == null)
            {
                // refer to comment in StatefulPersistenceContext.addCollection()
                throw new HibernateException(string.Format("Found two representations of same collection: {0}", type.Role));
            }

            // The CollectionEntry.isReached() stuff is just to detect any silly users
            // who set up circular or shared references between/to collections.
            if (ce.IsReached)
            {
                // We've been here before
                throw new HibernateException(string.Format("Found shared references to a collection: {0}", type.Role));
            }
            ce.IsReached = true;

            ISessionFactoryImplementor factory = session.Factory;
            ICollectionPersister persister = factory.GetCollectionPersister(type.Role);
            ce.CurrentPersister = persister;
            ce.CurrentKey = type.GetKeyOfOwner(entity, session); //TODO: better to pass the id in as an argument?

            if (log.IsDebugEnabled)
            {
                log.Debug("Collection found: " +
                    MessageHelper.InfoString(persister, ce.CurrentKey, factory) + ", was: " +
                    MessageHelper.InfoString(ce.LoadedPersister, ce.LoadedKey, factory) +
                    (collection.WasInitialized ? " (initialized)" : " (uninitialized)"));
            }

            PrepareCollectionForUpdate(collection, ce);
        }
開發者ID:zibler,項目名稱:zibler,代碼行數:42,代碼來源:Collections.cs

示例3: ProcessCollection

		internal override object ProcessCollection(object collection, CollectionType type)
		{

			if (collection != null)
			{
				ISessionImplementor session = Session;
				IPersistentCollection persistentCollection;

				if (type.IsArrayType)
				{
					persistentCollection = session.PersistenceContext.GetCollectionHolder(collection);
					// if no array holder we found an unwrappered array (this can't occur,
					// because we now always call wrap() before getting to here)
					// return (ah==null) ? true : searchForDirtyCollections(ah, type);
				}
				else
				{
					// if not wrappered yet, its dirty (this can't occur, because
					// we now always call wrap() before getting to here)
					// return ( ! (obj instanceof PersistentCollection) ) ?
					//true : searchForDirtyCollections( (PersistentCollection) obj, type );
					persistentCollection = (IPersistentCollection)collection;
				}

				if (persistentCollection.IsDirty)
				{
					//we need to check even if it was not initialized, because of delayed adds!
					dirty = true;
					return null; //NOTE: EARLY EXIT!
				}
			}
			return null;
		}
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:33,代碼來源:DirtyCollectionSearchVisitor.cs

示例4: ProcessArrayOrNewCollection

		private object ProcessArrayOrNewCollection(object collection, CollectionType collectionType)
		{
			if (collection == null)
			{
				return null;
			}

			ICollectionPersister persister = Session.GetCollectionPersister(collectionType.Role);

			if (collectionType.IsArrayType)
			{
				PersistentArrayHolder ah = Session.GetArrayHolder(collection);
				if (ah == null)
				{
					ah = new PersistentArrayHolder(Session, collection);
					Session.AddNewCollection(ah, persister);
					Session.AddArrayHolder(ah);
				}
				return null;
			}
			else
			{
				IPersistentCollection persistentCollection = collectionType.Wrap(Session, collection);
				Session.AddNewCollection(persistentCollection, persister);

				if (log.IsDebugEnabled)
				{
					log.Debug("Wrapped collection in role: " + collectionType.Role);
				}

				return persistentCollection; //Force a substitution!
			}
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:33,代碼來源:WrapVisitor.cs

示例5: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType type)
		{
			SessionImpl session = Session;
			object key = Key;
			ICollectionPersister persister = session.GetCollectionPersister(type.Role);

			session.RemoveCollection(persister, key);

			if (collection != null && (collection is IPersistentCollection))
			{
				IPersistentCollection wrapper = collection as IPersistentCollection;
				wrapper.SetCurrentSession(session);
				if (wrapper.WasInitialized)
				{
					session.AddNewCollection(wrapper, persister);
				}
				else
				{
					session.ReattachCollection(wrapper, wrapper.CollectionSnapshot);
				}
			}
			else
			{
				// otherwise a null or brand new collection 
				// this will also (inefficiently) handle arrays, which 
				// have no snapshot, so we can't do any better
				//processArrayOrNewCollection(collection, type);
			}

			return null;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:31,代碼來源:OnReplicateVisitor.cs

示例6: ProcessCollection

		internal override object ProcessCollection(object collection, CollectionType type)
		{

			if (collection != null)
				EvictCollection(collection, type);

			return null;
		}
開發者ID:ray2006,項目名稱:WCell,代碼行數:8,代碼來源:EvictVisitor.cs

示例7: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType type)
		{
			if (collection != null)
			{
				Session.EvictCollection(collection, type);
			}

			return null;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:9,代碼來源:EvictVisitor.cs

示例8: ProcessCollection

        internal override object ProcessCollection(object collection, CollectionType type)
        {
            ISessionImplementor session = Session;
            ICollectionPersister persister = session.Factory.GetCollectionPersister(type.Role);

            if (collection == null)
            {
                //do nothing
            }
            else
            {
                IPersistentCollection persistentCollection = collection as IPersistentCollection;
                if (persistentCollection != null)
                {
                    if (persistentCollection.SetCurrentSession(session))
                    {
                        ICollectionSnapshot snapshot = persistentCollection.CollectionSnapshot;
                        if (IsOwnerUnchanged(snapshot, persister, ExtractCollectionKeyFromOwner(persister)))
                        {
                            // a "detached" collection that originally belonged to the same entity
                            if (persistentCollection.IsDirty)
                            {
                                throw new HibernateException("reassociated object has dirty collection");
                            }
                            ReattachCollection(persistentCollection, snapshot);
                        }
                        else
                        {
                            // a "detached" collection that belonged to a different entity
                            throw new HibernateException("reassociated object has dirty collection reference");
                        }
                    }
                    else
                    {
                        // a collection loaded in the current session
                        // can not possibly be the collection belonging
                        // to the entity passed to update()
                        throw new HibernateException("reassociated object has dirty collection reference");
                    }
                }
                else
                {
                    // brand new collection
                    //TODO: or an array!! we can't lock objects with arrays now??
                    throw new HibernateException("reassociated object has dirty collection reference (or an array)");
                }
            }
            return null;
        }
開發者ID:zibler,項目名稱:zibler,代碼行數:49,代碼來源:OnLockVisitor.cs

示例9: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType collectionType)
		{
			if (collection != null && (collection is IPersistentCollection))
			{
				IPersistentCollection coll = collection as IPersistentCollection;
				if (coll.SetCurrentSession(Session))
				{
					Session.ReattachCollection(coll, coll.CollectionSnapshot);
				}
				return null;
			}
			else
			{
				return ProcessArrayOrNewCollection(collection, collectionType);
			}
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:16,代碼來源:WrapVisitor.cs

示例10: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType type)
		{
			ICollectionPersister persister = Session.GetCollectionPersister(type.Role);

			if (collection == null)
			{
				// Do nothing
			}
			else if (collection is IPersistentCollection)
			{
				IPersistentCollection coll = (IPersistentCollection) collection;

				if (coll.SetCurrentSession(Session))
				{
					ICollectionSnapshot snapshot = coll.CollectionSnapshot;
					if (SessionImpl.IsOwnerUnchanged(snapshot, persister, this.Key))
					{
						// a "detached" collection that originally belonged to the same entity
						if (coll.IsDirty)
						{
							throw new HibernateException("reassociated object has dirty collection");
						}
						Session.ReattachCollection(coll, snapshot);
					}
					else
					{
						// a "detached" collection that belonged to a different entity
						throw new HibernateException("reassociated object has dirty collection reference");
					}
				}
				else
				{
					// a collection loaded in the current session
					// can not possibly be the collection belonging
					// to the entity passed to update()
					throw new HibernateException("reassociated object has dirty collection reference");
				}
			}
			else
			{
				// brand new collection
				//TODO: or an array!! we can't lock objects with arrays now??
				throw new HibernateException("reassociated object has dirty collection reference");
			}

			return null;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:47,代碼來源:OnLockVisitor.cs

示例11: ProcessCollection

		internal override object ProcessCollection(object collection, CollectionType collectionType)
		{
			IPersistentCollection coll = collection as IPersistentCollection;
			if (coll != null)
			{
				ISessionImplementor session = Session;
				if (coll.SetCurrentSession(session))
				{
					ReattachCollection(coll, collectionType);
				}
				return null;
			}
			else
			{
				return ProcessArrayOrNewCollection(collection, collectionType);
			}
		}
開發者ID:jlevitt,項目名稱:nhibernate-core,代碼行數:17,代碼來源:WrapVisitor.cs

示例12: ReattachCollection

		/// <summary> 
		/// Reattach a detached (disassociated) initialized or uninitialized
		/// collection wrapper, using a snapshot carried with the collection wrapper
		/// </summary>
		protected internal void ReattachCollection(IPersistentCollection collection, CollectionType type)
		{
			if (collection.WasInitialized)
			{
				ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(type.Role);
				Session.PersistenceContext.AddInitializedDetachedCollection(collectionPersister, collection);
			}
			else
			{
				if (!IsCollectionSnapshotValid(collection))
				{
					throw new HibernateException("could not reassociate uninitialized transient collection");
				}
				ICollectionPersister collectionPersister = Session.Factory.GetCollectionPersister(collection.Role);
				Session.PersistenceContext.AddUninitializedDetachedCollection(collectionPersister, collection);
			}
		}
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:21,代碼來源:ProxyVisitor.cs

示例13: ProcessCollection

        internal override object ProcessCollection(object collection, CollectionType type)
        {
            if (collection == CollectionType.UnfetchedCollection)
            {
                return null;
            }

            IEventSource session = Session;
            ICollectionPersister persister = session.Factory.GetCollectionPersister(type.Role);

            object collectionKey = ExtractCollectionKeyFromOwner(persister);
            IPersistentCollection wrapper = collection as IPersistentCollection;
            if (wrapper != null)
            {
                if (wrapper.SetCurrentSession(session))
                {
                    //a "detached" collection!
                    ICollectionSnapshot snapshot = wrapper.CollectionSnapshot;
                    if (!IsOwnerUnchanged(snapshot, persister, collectionKey))
                    {
                        // if the collection belonged to a different entity,
                        // clean up the existing state of the collection
                        RemoveCollection(persister, collectionKey, session);
                    }
                    ReattachCollection(wrapper, snapshot);
                }
                else
                {
                    // a collection loaded in the current session
                    // can not possibly be the collection belonging
                    // to the entity passed to update()
                    RemoveCollection(persister, collectionKey, session);
                }
            }
            else
            {
                // null or brand new collection
                // this will also (inefficiently) handle arrays, which have
                // no snapshot, so we can't do any better
                RemoveCollection(persister, collectionKey, session);
            }

            return null;
        }
開發者ID:zibler,項目名稱:zibler,代碼行數:44,代碼來源:OnUpdateVisitor.cs

示例14: EvictCollection

		public virtual void EvictCollection(object value, CollectionType type)
		{
			IPersistentCollection pc;
			if (type.IsArrayType)
			{
				pc = Session.PersistenceContext.RemoveCollectionHolder(value);
			}
			else if (value is IPersistentCollection)
			{
				pc = (IPersistentCollection)value;
			}
			else
			{
				return; //EARLY EXIT!
			}

			IPersistentCollection collection = pc;
			if (collection.UnsetSession(Session))
				EvictCollection(collection);
		}
開發者ID:ray2006,項目名稱:WCell,代碼行數:20,代碼來源:EvictVisitor.cs

示例15: ProcessCollection

		protected override object ProcessCollection(object collection, CollectionType type)
		{
			ICollectionPersister persister = Session.GetCollectionPersister(type.Role);

			if (collection is IPersistentCollection)
			{
				IPersistentCollection wrapper = (IPersistentCollection) collection;

				if (wrapper.SetCurrentSession(Session))
				{
					//a "detached" collection!
					ICollectionSnapshot snapshot = wrapper.CollectionSnapshot;

					if (!SessionImpl.IsOwnerUnchanged(snapshot, persister, Key))
					{
						// if the collection belonged to a different entity,
						// clean up the existing state of the collection
						Session.RemoveCollection(persister, Key);
					}

					Session.ReattachCollection(wrapper, snapshot);
				}
				else
				{
					// a collection loaded in the current session
					// can not possibly be the collection belonging
					// to the entity passed to update()
					Session.RemoveCollection(persister, Key);
				}
			}
			else
			{
				// null or brand new collection
				// this will also (inefficiently) handle arrays, which have
				// no snapshot, so we can't do any better
				Session.RemoveCollection(persister, Key);
				//processArrayOrNewCollection(collection, type);
			}

			return null;
		}
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:41,代碼來源:OnUpdateVisitor.cs


注:本文中的NHibernate.Type.CollectionType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。