Logo

¡Bienvenido a Stratos!

Acceder

Foros



Duda c# y pipeline

Iniciado por blau, 19 de Marzo de 2011, 04:35:46 PM

« anterior - próximo »

blau

Buenas tengo un fallo que me esta volviendo loco, cuando ejecuto este codigo:

Código (AstroLegacy | Astro.cs) [Seleccionar]
Cell cell2 = Content.Load<Cell>("cell1");

Para cargar esto:

Código (Content | cell1.xml) [Seleccionar]

<?xml version="1.0" encoding="utf-8"?>
<XnaContent>
  <Asset Type="AstroLegacy.Cell">
    <Guid>00000000-0000-0000-0000-000000000000</Guid>
    <Pasos>false true true true</Pasos>
  </Asset>
</XnaContent>




Falla en el siguiente codigo diciendo que no encuentra un ContentTypeReader para AstroLegacy.Entity
input.ReadRawObject<Entity>(cell as Entity);   

Y no entiendo por que, ya que en el EntityWriter estoy devolviendo bien la ruta al EntityReader

¿A alguien se le ocurre que puede estar pasando?

Código (Core | Cell.cs) [Seleccionar]

public class Cell : Entity
    {
        ....
        .... 
        public class CellReader : ContentTypeReader<Cell>
        {
            protected override Cell Read(ContentReader input, Cell existingInstance)
            {
                Cell cell = existingInstance;

                Debug.Assert(cell == null, "Existe ya la celda?");

                cell = new Cell();
             
                input.ReadRawObject<Entity>(cell as Entity);

                cell.Pasos = input.ReadObject<bool[]>();

                return cell;
            }
        }
    }   


Código (Core | Entity.cs) [Seleccionar]

   public abstract class Entity : BaseObject
    {
        //- PROPIEDADES ---------------------------------------------------------------------------------------------------------
        public Environment Environment { get; private set; }
        public Entity Parent { get; private set; }
        ....
        ....
        //- READER --------------------------------------------------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------------------------------
        public class EntityReader : ContentTypeReader<Entity>
        {
            protected override Entity Read(ContentReader input, Entity existingInstance)
            {
                Entity entity = existingInstance;

                Debug.Assert(entity != null, "No existe ya la entidad?");

                input.ReadRawObject<BaseObject>(entity as BaseObject);

                return entity;
            }
        }


Código (Core | BaseObject.cs) [Seleccionar]

public abstract class BaseObject : IDisposable
    {
        //- PROPIEDADES ---------------------------------------------------------------------------------------------------------
        public Guid Guid { get; set; }
        public string Name { get; set; }
        public bool IsDisposed { get; private set; }
        .....
        .....       
        public class BaseObjectReader : ContentTypeReader<BaseObject>
        {
            protected override BaseObject Read(ContentReader input, BaseObject existingInstance)
            {
                BaseObject BaseObject = existingInstance;

                Debug.Assert(BaseObject != null, "No existe ya el astro object?");
               
                BaseObject.Guid = new Guid(input.ReadString());
                BaseObject.Name = input.ReadString();

                return BaseObject;
            }
        }
    }


Código ( Pipeline | BaseObjectWriter.cs) [Seleccionar]

   [ContentTypeWriter]
    public class BaseObjectWriter : ContentTypeWriter<BaseObject>
    {
        protected override void Write(ContentWriter output, BaseObject value)
        {
            output.Write(value.Guid.ToString());
            output.Write(value.Name);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(BaseObject.BaseObjectReader).AssemblyQualifiedName;
        }

        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return typeof(BaseObject).AssemblyQualifiedName;
        }       
    }


Código ( Pipeline | EntityWriter.cs) [Seleccionar]

[ContentTypeWriter]
    public class EntityWriter : ContentTypeWriter<Entity>
    {
        protected override void Write(ContentWriter output, Entity value)
        {           
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(Entity.EntityReader).AssemblyQualifiedName;
        }

        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return typeof(Entity).AssemblyQualifiedName;
        }       
    }


Código ( Pipeline | CellWriter.cs) [Seleccionar]

[ContentTypeWriter]
    public class CellWriter : ContentTypeWriter<Cell>
    {       
        protected override void Write(ContentWriter output, Cell value)
        {
            output.Write(value.Guid.ToString());
            output.WriteObject<bool[]>(value.Pasos);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(Cell.CellReader).AssemblyQualifiedName;
        }

        public override string GetRuntimeType(TargetPlatform targetPlatform)
        {
            return typeof(Cell).AssemblyQualifiedName;
        }       
    }

blau

Nada, ya esta solucionado. ;)

No escribia la entidad... el copiar pegar que daño hace de vez en cuando... :)


[ContentTypeWriter]
    public class CellWriter : ContentTypeWriter<Cell>
    {       
        protected override void Write(ContentWriter output, Cell value)
        {
            output.WriteRawObject<Entity>(value as Entity);
            output.WriteObject<bool[]>(value.Pasos);
        }






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.
Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.