예제 #1
0
파일: Page.cs 프로젝트: WolfgangSt/axiom
        /// <summary>
        /// 
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        protected override bool PrepareImpl(StreamSerializer stream)
        {
            //now do the real loading
            if (stream.ReadChunkBegin(CHUNK_ID, CHUNK_VERSION, "Page") == null)
                return false;

            // pageID check (we should know the ID we're expecting)
            int storedID = -1;
            stream.Read(out storedID);
            if (mID.Value != storedID)
            {
                LogManager.Instance.Write("Error: Tried to populate Page ID " +
                    mID.Value + " with data corresponding to page ID " + storedID);
                stream.UndoReadChunk(CHUNK_ID);
                return false;
            }

            PageManager mgr = Manager;

            while (stream.NextChunkId == PageContentCollection.CHUNK_ID)
            {
                Chunk collChunk = stream.ReadChunkBegin();
                string factoryName = string.Empty;
                stream.Read(out factoryName);
                //Supported type?
                IPageContentCollectionFactory collFact = mgr.GetContentCollectionFactory(factoryName);
                if (collFact != null)
                {
                    PageContentCollection collInst = collFact.CreateInstance();
                    if (collInst.Prepare(stream))
                    {
                        AttachContentCollection(collInst);
                    }
                    else
                    {
                        LogManager.Instance.Write("Error preparing PageContentCollection type: " +
                            factoryName + " in + " + this.ToString());

                        collFact.DestroyInstance(ref collInst);
                    }
                }
                else
                {
                    LogManager.Instance.Write("Unsupported PageContentCollection type: " +
                            factoryName + " in + " + this.ToString());

                    //skip
                    //stream.ReadChunkEnd(ref collChunk.ID);
                    stream.ReadChunkEnd(collChunk.id);
                }
            }

            return true;
        }
예제 #2
0
파일: Page.cs 프로젝트: ryan-bunker/axiom3d
		protected virtual bool PrepareImpl( StreamSerializer stream, ref PageData dataToPopulate )
		{
			//now do the real loading
			if ( stream.ReadChunkBegin( CHUNK_ID, CHUNK_VERSION, "Page" ) == null )
			{
				return false;
			}

			// pageID check (we should know the ID we're expecting)
			int storedID = -1;
			stream.Read( out storedID );
			if ( this.mID.Value != storedID )
			{
				LogManager.Instance.Write( "Error: Tried to populate Page ID {0} with data corresponding to page ID {1}",
				                           this.mID.Value,
				                           storedID );
				stream.UndoReadChunk( CHUNK_ID );
				return false;
			}

			PageManager mgr = Manager;

			while ( stream.NextChunkId == Page.CHUNK_CONTENTCOLLECTION_DECLARATION_ID )
			{
				Chunk collChunk = stream.ReadChunkBegin();
				string factoryName;
				stream.Read( out factoryName );
				stream.ReadChunkEnd( CHUNK_CONTENTCOLLECTION_DECLARATION_ID );
				//Supported type?
				IPageContentCollectionFactory collFact = mgr.GetContentCollectionFactory( factoryName );
				if ( collFact != null )
				{
					PageContentCollection collInst = collFact.CreateInstance();
					if ( collInst.Prepare( stream ) )
					{
						dataToPopulate.collectionsToAdd.Add( collInst );
					}
					else
					{
						LogManager.Instance.Write( "Error preparing PageContentCollection type: {0} in {1}", factoryName, ToString() );
						collFact.DestroyInstance( ref collInst );
					}
				}
				else
				{
					LogManager.Instance.Write( "Unsupported PageContentCollection type: {0} in {1}", factoryName, ToString() );
					//skip
					stream.ReadChunkEnd( collChunk.id );
				}
			}

			this.mModified = false;
			return true;
		}