XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

can someone direct me to info About GameAssembly?

Last post 05-12-2008 11:48 AM by mtnPhil. 3 replies.
  • 05-12-2008 7:29 AM

    can someone direct me to info About GameAssembly?

    Everything in ContantPiple line is explained, accept of a little black box in: GetRuntimeType and GetRuntimeReader. the return value of those two is Unclear to me... sometimes it's a string wnd sometimes it's this "gameAssebmly", which i understand it return the same string that we can write by our selfs.

    There are some questions and i have 3 books of xna which explains about the Contant Pipeline, and non of them says how to build this string or what are all the tags that can be used in this strings. they jusg say : writhe this, and write that.

    every one show it in a different way, which just make me more confused. understand this, i can just make as they say , but i need to undrestand.

    for example some book and/or tutorials say i need to implement two functions: GameRuntimeType and GetRuntimeReader while others "forget" about the GameRuntimeType, why?

    also, everyone has a differend way to return the assembly, few examples:

    "microsoft xna unleashed":
    public override string GetRuntimeType (TargetPlatform targetPlatform)
    {
    return "XELibrary.Skybox, " +
    "XELibrary, Version=1.0.0.0, Culture=neutral";
    }

    public override string GetRuntimeReader (TargetPlatform targetPlatform)
    {
    return "XELibrary.SkyboxReader, " +
    "XELibrary, Version=1.0.0.0, Culture=neutral";
    }

    "microsoft xna agme studio creators club":

    public override string GetRuntimeType (TargetPlatform targetPlatform)
    {
    return typeof(MyTerrain).AssemlyQualifiedName; // explanation????
    }

    public override string GetRuntimeReader (TargetPlatform targetPlatform)
    {
    return "TerrImporter.TerrReader, " +
    "TerrImporter, Version=1.0.0.0, Culture=neutral";
    }

    I someone explain in details what is the structure of this string, whay essential and what is not, what more tags there are to add if i need and what is Culture?

    also, what string the command typeof (MyCustomClass).AssemblyQualifiedName , returns? and why the use of typeof? why take the type of the MyCustomClass from the first place?

    thanks for your kind help


  • 05-12-2008 8:59 AM In reply to

    Re: can someone direct me to info About GameAssembly?

    For GetRuntimeReader, the string you return is the fully-qualified .NET name of the class that inherits from ContentTypeReader<> and implements a reader for the data type being exported.  In a nutshell, the string is a "locator" for the class and gives the run-time all the information it needs to find and load the right class.  The string breaks down as follows:

    "ClassName, AssemblyName, Version, Culture"

    • ClassName:  The full name of the class, including namespace.
    • AssemblyName:  The name of the assembly (minus .dll/.exe) containing the class specified in ClassName.  i.e. if the class is contained in MyGame.exe, then this is simple "MyGame".
    • Version:  The assembly version to load.  This allows you to support multiple versions concurrently.
    • Culture:  The culture of the assembly to load.  You can have multiple assemblies to handle different locales.  Unless you're explicitly internationalizing your code, just use "neutral".


    For the terrain example above, the string breaks down as: "Load class TerrImporter.TerrReader from assembly TerrImporter of version 1.0.0.0 in the neutral (default) locale."

    The same holds for GetRuntimeType.  The difference is you are returning the fully-qualified .NET name of the class/struct that represents the data type you are exporting.  Let's say you have a data class Foo.  In the content pipeline, you'll likely implement FooContent and FooWriter.  FooContent is the data container during content pipeline processing, and FooWriter writes this container to disk.  At run-time, you load a Foo object using FooReader.  Even though Foo and FooContent are different classes, they represent the same data.  One of the reasons to do it this way is so you do not have circular dependencies between content pipeline code and game code.  Of course, FooWriter needs some way to tell the content manager that the data type contained within the XNB file is actually a Foo object.  That is the purpose of GetRuntimeType.

    Now if the run-time data class is visible as compile-time, as in the case of the terrain example above, you can just use typeof and extract the AssemblyQualifiedName as a property on Type.  If the type is in another assembly and not visible at compile-time, then you cannot use this method.  typeof() just returns a Type object representing the parameter type, and AssemblyQualifiedName just returns the string format given above.
    New Microsoft DirectX/XNA MVP  (*evil laugh*)
  • 05-12-2008 11:36 AM In reply to

    Re: can someone direct me to info About GameAssembly?

    Thank you very much for filling the missing part in the pazzle.

    It seems that i understook correctly, since your explanation is almost exatly what i had in mind. accept i don't know much about asseblies since i'm a C++ programmer, probebly i need to go and serch it at the c# help, not xna.

    also, the part that i don't understand 100% is the part that you use the type of the class to access it's object member AssemblyQualifiedName. since when Types have members? is it part of C#? i don't recall something similar in C++.
  • 05-12-2008 11:48 AM In reply to

    Re: can someone direct me to info About GameAssembly?

    Just a warning... I had to use the FullName of the type, not the AssemblyQualifiedName, as AQN was too strong and is different on XBOX vs windows (but the content pipeline is run only on Windows, so it generated a name that didn't work on XBOX for the GetRuntimeReader).

    And yes, in C# getting the type of an object gives you a Type object which has members.  C# is a different language than c++ :-)

Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG