wx.Build.ResourceDesignator Class Reference

Inheritance diagram for wx.Build.ResourceDesignator:

Inheritance graph

List of all members.

Public Member Functions

int CompareTo (object o)
ContentFile DestinationOfExternalResource (string dirOfUsingAssembly)
bool DoNotCopyIfExternalReference (string dirOfUsingAssembly)
override bool Equals (object obj)
bool Execute (BuildToolFamilyEnv env, DateTime validityOfBuildSystem)
override int GetHashCode ()
ICollection
< RefToProject
GetProjects ()
System.Xml.Schema.XmlSchema GetSchema ()
ICollection
< IBuildProduct
GetTargets ()
DateTime GetValidity ()
DateTime GetValidityDemand ()
void ReadXml (System.Xml.XmlReader reader)
 ResourceDesignator (ContentFile resourceFile, string name, bool isThisPrivate)
 ResourceDesignator (ContentFile resourceFile, string name)
 ResourceDesignator (ContentType t, string originalFilename, string internalName)
 ResourceDesignator (ISingleFileProduct resourceFile)
 ResourceDesignator ()
override string ToString ()
void WriteXml (System.Xml.XmlWriter writer)

Static Public Member Functions

static ICollection
< ResourceDesignator
SelectExternalResources (ContentType t, string srcDirectoryPath, string searchPattern, string destDirPath)

Properties

bool IsPrivate [get]
string Name [get]
ContentFile ResourceFile [get]
ISingleFileProduct ResourceFileProject [get]


Detailed Description

Resource designators describe resources as input to the assembly linker or compiler. Instances of this class are used in instances of wx.Build.Net.CSharpAssemblyProject to define resources. Resource designators amend a content file with an internal name that this file will have as a resource in an assembly.

If the resource has been compiled into the assembly, either ZipResource or the ManifestResourceInfo may be used to read it. Use the ResourceDesignator.Name to designate the resource. Assume the following project definition.

        wx.Build.Net.CSharpAssemblyProject project = new wx.Build.Net.CSharpAssemblyProject(ProjectPreference.Default,
                    "ResourceDesignatorSample",
                    "program.exe",
                    "Exemplifies declaration and use of resources.");
        project.Resources=new wx.Build.ResourceDesignator[] {
            new wx.Build.ResourceDesignator(new wx.Build.ContentFile(wx.Build.ContentType.PNG, "APicture.png"), "APicture_PNG")
        };
Then, use the following code to access the data.
        ManifestResourceInfo rsInfo = callingAssembly.GetManifestResourceInfo("APicture_PNG");
        if (rsInfo != null)
        {
           Stream resourceStream = resourceAssembly.GetManifestResourceStream(derivate);
           BinaryReader reader = new BinaryReader(resourceStream);
           byte[] resourceBytes = reader.ReadBytes((int)resourceStream.Length);
        }
Another use case are external resources. These resource will not compiled into an assembly, but the build system will take care that these files are at the appropiate place after building the project. In this scenario, the internal name of the resource is the relative filename that will be used in the program code to load the resource. Here again we have two cases:

The following example contains a declaration for both of the abovementioned use cases.

        wx.Build.Net.CSharpAssemblyProject project = new wx.Build.Net.CSharpAssemblyProject(ProjectPreference.Default,
                    "ResourceDesignatorSample",
                    "program.exe",
                    "Exemplifies declaration and use of resources.");
        project.ExternalResources = new ResourceDesignator[] {
           new ResourceDesignator(ContentType.PNG, "..\\Images\\APictureToCopy.PNG", "Images\\APictureCopied.PNG")
           new ResourceDesignator(ContentType.PNG, "Images\\APictureAlreadyAtTheDesiredPlace.PNG")
        };

Constructor & Destructor Documentation

wx.Build.ResourceDesignator.ResourceDesignator (  ) 

Creates an empty resource. Use this CTor only to create an instance that reads its properties from an XML stream using ReadXml().

wx.Build.ResourceDesignator.ResourceDesignator ( ISingleFileProduct  resourceFile  ) 

This will assign an automatically created name to the provided resourceFile. The name will consist of the base file name without extension plus underscrore "_" plus extension of the file.

Parameters:
resourceFile Typically a content file but maybe also a project implementing ISingleFileProduct.

wx.Build.ResourceDesignator.ResourceDesignator ( ContentType  t,
string  originalFilename,
string  internalName 
)

This creates an instance referring to a resource of the provided type that will be read from the provided filename. The program code will refer to the specified internal name.

Parameters:
t Type of the resource.
originalFilename Filename of the resource.
internalName The internal name that will be used bythe program code to refer to the resource. There are 2 uswe cases:

wx.Build.ResourceDesignator.ResourceDesignator ( ContentFile  resourceFile,
string  name 
)

This designates a resource consisting of the content of resourceFile that may be retrieved by the internal name.

Parameters:
resourceFile The resource file.
name This defines the name that will be used to refer to the represented resource. 2 Use cases:
  • The name is a flat string representing the file in the manifest stream (.NET resource system). The resource designator has been used in conjunction with wx.Build.Net.CSharpAssemblyProject.Resources.
  • The name is a relative filename (relative to the produced program if the resource designator has been used in conjunction with

wx.Build.ResourceDesignator.ResourceDesignator ( ContentFile  resourceFile,
string  name,
bool  isThisPrivate 
)

This designates a resource consisting of the content of resourceFile that may be retrieved by the internal name.

Parameters:
resourceFile The source file that this instance designates.
name The internal name that will be used bythe program code to refer to the resource. There are 2 uswe cases:

Parameters:
isThisPrivate Indicates with true that the resource shall be linked privately. This flag will only be used when the resource is compiled into the manifest. If this refers to an external resource, this flag will be ignored,


Member Function Documentation

int wx.Build.ResourceDesignator.CompareTo ( object  o  ) 

ContentFile wx.Build.ResourceDesignator.DestinationOfExternalResource ( string  dirOfUsingAssembly  ) 

Use this to get the filename that a program will expect this resource to have, if this is used as external resource.

Parameters:
dirOfUsingAssembly The directory where the program resides that uses this resource. This method will expect that the program uses the internal name relatively to this directory.
Returns:
The filename that a program will expect this resource to have.

bool wx.Build.ResourceDesignator.DoNotCopyIfExternalReference ( string  dirOfUsingAssembly  ) 

True iff DestinationOfExternalResource() is equal to the resource file. In this case, the resource shall not be copied in order to build a runnable version of the program.

Parameters:
dirOfUsingAssembly The directory where the program resides that uses this resource. This method will expect that the program uses the internal name relatively to this directory.

override bool wx.Build.ResourceDesignator.Equals ( object  obj  ) 

bool wx.Build.ResourceDesignator.Execute ( BuildToolFamilyEnv  env,
DateTime  validityOfBuildSystem 
)

Simply return true .

override int wx.Build.ResourceDesignator.GetHashCode (  ) 

ICollection<RefToProject> wx.Build.ResourceDesignator.GetProjects (  ) 

Returns an array containing the resource of the resource is a project.

Implements wx.Build.IBuildProduct.

System.Xml.Schema.XmlSchema wx.Build.ResourceDesignator.GetSchema (  ) 

ICollection<IBuildProduct> wx.Build.ResourceDesignator.GetTargets (  ) 

This is a target on itself.

DateTime wx.Build.ResourceDesignator.GetValidity (  ) 

Returns validity timstamp of this object. Whenever this is equal or later than all prerequisites, this is considered consistent with the prerequisites on rebuilding.

Implements wx.Build.IBuildObject.

DateTime wx.Build.ResourceDesignator.GetValidityDemand (  ) 

This is the counterpart of the Validity . If this occurs as a prerequisite, this shall be compared with the Validity of the target in order to assess whether rebuild is necessary or not.

Implements wx.Build.IBuildObject.

void wx.Build.ResourceDesignator.ReadXml ( System.Xml.XmlReader  reader  ) 

static ICollection<ResourceDesignator> wx.Build.ResourceDesignator.SelectExternalResources ( ContentType  t,
string  srcDirectoryPath,
string  searchPattern,
string  destDirPath 
) [static]

This produces a collection of resource designators that refer to files in a particular directory. The files will be selected according to a search pattern according to System.IO.Directory.GetFiles(). The internal name will be created due to the provided destination path. Refer to , Net.CSharpAssemblyProject.ExternalResources.

Example: Assume, that directory "..\\Images" contains the files "img01.png" and "img02.jpg".

            ICollection&lt; ResourceDesignator &gt; resultPNG=ResourceDesignator.SelectExternalResources(ContentType.PNG, "..\\Images", "*.png", "..\\Images");
            ICollection&lt; ResourceDesignator &gt; resultJPG=ResourceDesignator.SelectExternalResources(ContentType.JPEG, "..\\Images", "*.jpg", "..\\Images");
            ICollection&lt; ResourceDesignator &gt; resultERROR=ResourceDesignator.SelectExternalResources(ContentType.PNG, "..\\Images", "*.*", "..\\Images");

Parameters:
t The content type that will be assumed for the resulting resources.
srcDirectoryPath The directory, where the resources will be searched.
searchPattern The search pattern including wild cards that can be interpreted by System.IO.Directory.GetFiles().
destDirPath This is the directory that will be used to create the resource name. This must be a relative path. "." or "" will cause the build procedure to place the resource side by side with the created assembly.
Returns:
Collection of resource designators that are appropriate to represent external resources.
See also:
wx.Build.Net.CSharpAssemblyProject

override string wx.Build.ResourceDesignator.ToString (  ) 

void wx.Build.ResourceDesignator.WriteXml ( System.Xml.XmlWriter  writer  ) 


Property Documentation

bool wx.Build.ResourceDesignator.IsPrivate [get]

True iff this is will be private to the assembly.

string wx.Build.ResourceDesignator.Name [get]

Returns the name that the resource will have in the assembly. If this resource will be compiled into the assembly, this is usually a flat name consisting excusively of lower case letters without dots, slashes, and backslashes. If this is an external resource, this is a relative path the will be used to compute a target position of the resource.

See also:
wx.Build.Net.CSharpAssemblyProject

ContentFile wx.Build.ResourceDesignator.ResourceFile [get]

This is the file that provides the content.

ISingleFileProduct wx.Build.ResourceDesignator.ResourceFileProject [get]

The resource is in fact a ISingleFileProduct. This is the instance actually representing the resource. This will differ from ResourceFile iff the resource is a project rather like an explicitely known file.


The wx.NET Build System.   (c) 2009-2010 Harald Meyer auf'm Hofe