C# Class FlatRedBall.Content.ContentBuilder

This class wraps the MSBuild functionality needed to build XNA Framework content dynamically at runtime. It creates a temporary MSBuild project in memory, and adds whatever content files you choose to this project. It then builds the project, which will create compiled .xnb content files in a temporary directory. After the build finishes, you can use a regular ContentManager to load these temporary .xnb files in the usual way.
Inheritance: IDisposable
Datei anzeigen Open project: vchelaru/FlatRedBall

Public Methods

Method Description
Add ( string filename, string name, string importer, string processor ) : void

Adds a new content file to the MSBuild project. The importer and processor are optional: if you leave the importer null, it will be autodetected based on the file extension, and if you leave the processor null, data will be passed through without any processing.

Build ( ) : string

Builds all the content files which have been added to the project, dynamically creating .xnb files in the OutputDirectory. Returns an error message if the build fails.

Clear ( ) : void

Removes all content files from the MSBuild project.

ContentBuilder ( ) : System

Creates a new content builder.

Dispose ( ) : void

Disposes the content builder when it is no longer required.

IsReferencingAssembly ( string assemblyName ) : bool
ReferenceAssembly ( string assemblyName ) : void
RemoveReferencedAssembly ( string assemblyName ) : void
Save ( ) : void

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Implements the standard .NET IDisposable pattern.

Private Methods

Method Description
CreateBuildProject ( ) : void

Creates a temporary MSBuild content project in memory.

CreateTempDirectory ( ) : void

Creates a temporary directory in which to build content.

DeleteTempDirectory ( ) : void

Deletes our temporary directory when we are finished with it.

PurgeStaleTempDirectories ( ) : void

Ideally, we want to delete our temp directory when we are finished using it. The DeleteTempDirectory method (called by whichever happens first out of Dispose or our finalizer) does exactly that. Trouble is, sometimes these cleanup methods may never execute. For instance if the program crashes, or is halted using the debugger, we never get a chance to do our deleting. The next time we start up, this method checks for any temp directories that were left over by previous runs which failed to shut down cleanly. This makes sure these orphaned directories will not just be left lying around forever.

Method Details

Add() public method

Adds a new content file to the MSBuild project. The importer and processor are optional: if you leave the importer null, it will be autodetected based on the file extension, and if you leave the processor null, data will be passed through without any processing.
public Add ( string filename, string name, string importer, string processor ) : void
filename string
name string
importer string
processor string
return void

Build() public method

Builds all the content files which have been added to the project, dynamically creating .xnb files in the OutputDirectory. Returns an error message if the build fails.
public Build ( ) : string
return string

Clear() public method

Removes all content files from the MSBuild project.
public Clear ( ) : void
return void

ContentBuilder() public method

Creates a new content builder.
public ContentBuilder ( ) : System
return System

Dispose() public method

Disposes the content builder when it is no longer required.
public Dispose ( ) : void
return void

Dispose() protected method

Implements the standard .NET IDisposable pattern.
protected Dispose ( bool disposing ) : void
disposing bool
return void

IsReferencingAssembly() public method

public IsReferencingAssembly ( string assemblyName ) : bool
assemblyName string
return bool

ReferenceAssembly() public method

public ReferenceAssembly ( string assemblyName ) : void
assemblyName string
return void

RemoveReferencedAssembly() public method

public RemoveReferencedAssembly ( string assemblyName ) : void
assemblyName string
return void

Save() public method

public Save ( ) : void
return void