Content Pipeline:
- Implemented important features of the FontDescriptionImporter. Importer works now, but still needs some (optional) features - Fixed some bugs in the FontDescriptionProcessor. Building now works to the point where the ContentCompiler wants a generic writer instance
This commit is contained in:
parent
744c835883
commit
3c5e98b783
@ -2,7 +2,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using ANX.Framework.Content.Pipeline.Graphics;
|
using ANX.Framework.Content.Pipeline.Graphics;
|
||||||
using ANX.Framework.NonXNA.Development;
|
using ANX.Framework.NonXNA.Development;
|
||||||
@ -15,10 +19,10 @@ using ANX.Framework.NonXNA.Development;
|
|||||||
namespace ANX.Framework.Content.Pipeline.Importer
|
namespace ANX.Framework.Content.Pipeline.Importer
|
||||||
{
|
{
|
||||||
/// <summary>Provides methods for reading .spritefont files for use in the Content Pipeline.</summary>
|
/// <summary>Provides methods for reading .spritefont files for use in the Content Pipeline.</summary>
|
||||||
[PercentageComplete(40)]
|
[PercentageComplete(90)]
|
||||||
[Developer("SilentWarrior/Eagle Eye Studios")]
|
[Developer("SilentWarrior/Eagle Eye Studios")]
|
||||||
[TestState(TestStateAttribute.TestState.InProgress)] //Works except for the character list, because it seems there is no managed solution for getting a fonts characters
|
[TestState(TestStateAttribute.TestState.InProgress)] //Works but there should be a check whether the characters are supported
|
||||||
[ContentImporter("Spritefont", ".spritefont", DefaultProcessor = "FontDescriptionProcessor")]
|
[ContentImporter("Spritefont", ".spritefont", DefaultProcessor = "FontDescriptionProcessor", DisplayName = "FontDescription Importer - ANX Framework")]
|
||||||
public class FontDescriptionImporter : ContentImporter<FontDescription>
|
public class FontDescriptionImporter : ContentImporter<FontDescription>
|
||||||
{
|
{
|
||||||
private static ContentBuildLogger _logger;
|
private static ContentBuildLogger _logger;
|
||||||
@ -37,8 +41,10 @@ namespace ANX.Framework.Content.Pipeline.Importer
|
|||||||
return fontDescription;
|
return fontDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static FontDescription DeserializeFont(XContainer xDoc)
|
private static FontDescription DeserializeFont(XContainer xDoc)
|
||||||
{
|
{
|
||||||
|
//Check if either the XnaContent or the AnxContent attribute exists.
|
||||||
var tag = xDoc.Element("XnaContent");
|
var tag = xDoc.Element("XnaContent");
|
||||||
if (tag == null)
|
if (tag == null)
|
||||||
{
|
{
|
||||||
@ -48,42 +54,51 @@ namespace ANX.Framework.Content.Pipeline.Importer
|
|||||||
"The Xml file does not contain a valid XnaContent or AnxContent tag.");
|
"The Xml file does not contain a valid XnaContent or AnxContent tag.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for asset element to ensure this is XNA content
|
||||||
var assetNode = tag.Element("Asset");
|
var assetNode = tag.Element("Asset");
|
||||||
if (assetNode == null)
|
if (assetNode == null)
|
||||||
throw new InvalidContentException("No valid Asset element in xml source.");
|
throw new InvalidContentException("No valid Asset element in xml source.");
|
||||||
|
|
||||||
|
//Only accept assets with type FontDescription
|
||||||
var xAttribute = assetNode.Attribute("Type");
|
var xAttribute = assetNode.Attribute("Type");
|
||||||
if (xAttribute == null || xAttribute.Value != "Graphics:FontDescription")
|
if (xAttribute == null || xAttribute.Value != "Graphics:FontDescription")
|
||||||
throw new InvalidContentException("This is not a valid font description!");
|
throw new InvalidContentException("This is not a font description!");
|
||||||
|
|
||||||
|
//Check if the font name was specified
|
||||||
var fontNameElement = assetNode.Element("FontName");
|
var fontNameElement = assetNode.Element("FontName");
|
||||||
if (fontNameElement == null)
|
if (fontNameElement == null)
|
||||||
throw new InvalidContentException("No font name specified in xml source.");
|
throw new InvalidContentException("No font name specified in xml source.");
|
||||||
var fontName = fontNameElement.Value;
|
var fontName = fontNameElement.Value; // if there is a font name, store it
|
||||||
|
|
||||||
|
//Same as above, except with a conversion of the size.
|
||||||
var sizeElement = assetNode.Element("Size");
|
var sizeElement = assetNode.Element("Size");
|
||||||
if (sizeElement == null)
|
if (sizeElement == null)
|
||||||
throw new InvalidContentException("No font size specified in xml source.");
|
throw new InvalidContentException("No font size specified in xml source.");
|
||||||
var fontSize = Convert.ToInt32(sizeElement.Value);
|
var fontSize = Convert.ToInt32(sizeElement.Value);
|
||||||
|
|
||||||
|
//Check and convert the spacing
|
||||||
var spacingElement = assetNode.Element("Spacing");
|
var spacingElement = assetNode.Element("Spacing");
|
||||||
if (spacingElement == null)
|
if (spacingElement == null)
|
||||||
throw new InvalidContentException("Spacing is not defined in xml source.");
|
throw new InvalidContentException("Spacing is not defined in xml source.");
|
||||||
var fontSpacing = Convert.ToInt32(spacingElement.Value);
|
var fontSpacing = Convert.ToInt32(spacingElement.Value);
|
||||||
|
|
||||||
|
//Check for style element and try to parse it.
|
||||||
var styleElement = assetNode.Element("Style");
|
var styleElement = assetNode.Element("Style");
|
||||||
if (styleElement == null)
|
if (styleElement == null)
|
||||||
throw new InvalidContentException("No style specified in xml source.");
|
throw new InvalidContentException("No style specified in xml source.");
|
||||||
FontDescriptionStyle fontStyle;
|
FontDescriptionStyle fontStyle;
|
||||||
Enum.TryParse(styleElement.Value, out fontStyle);
|
Enum.TryParse(styleElement.Value, out fontStyle);
|
||||||
|
|
||||||
|
//Get the character regions element to iterate through the character regions
|
||||||
var charRegionsElement = assetNode.Element("CharacterRegions");
|
var charRegionsElement = assetNode.Element("CharacterRegions");
|
||||||
if (charRegionsElement == null)
|
if (charRegionsElement == null)
|
||||||
throw new InvalidContentException("No character region specified in xml source");
|
throw new InvalidContentException("No character region specified in xml source");
|
||||||
var fontCharRegions = charRegionsElement.Elements("CharacterRegion");
|
var fontCharRegions = charRegionsElement.Elements("CharacterRegion");
|
||||||
|
|
||||||
var characters = new List<char>();
|
var characters = new List<char>(); //The list that will be passed to the processor
|
||||||
foreach (var fontCharRegion in fontCharRegions)
|
foreach (var fontCharRegion in fontCharRegions)
|
||||||
{
|
{
|
||||||
|
//for each char declaration get the start and end elements
|
||||||
var startElement = fontCharRegion.Element("Start");
|
var startElement = fontCharRegion.Element("Start");
|
||||||
if (startElement == null)
|
if (startElement == null)
|
||||||
throw new InvalidContentException("Character region is invalid. Start element is missing!");
|
throw new InvalidContentException("Character region is invalid. Start element is missing!");
|
||||||
@ -92,19 +107,33 @@ namespace ANX.Framework.Content.Pipeline.Importer
|
|||||||
if (endElement == null)
|
if (endElement == null)
|
||||||
throw new InvalidContentException("Character region is invalid. Start element is missing!");
|
throw new InvalidContentException("Character region is invalid. Start element is missing!");
|
||||||
|
|
||||||
char startChar;
|
int startChar;
|
||||||
char endChar;
|
int endChar;
|
||||||
_logger.LogMessage("Start: " + startElement.Value);
|
|
||||||
_logger.LogMessage("End: " + endElement.Value);
|
//Convert the chars back to hex values, silly xml importer reads them as chars, int value '32' equals an empty string or hex value #32
|
||||||
Debugger.Break();
|
startChar = String.IsNullOrEmpty(startElement.Value) ? 32 : Convert.ToInt32(Convert.ToChar(startElement.Value));
|
||||||
startChar = Convert.ToChar(startElement.Value);
|
endChar = Convert.ToInt32(Convert.ToChar(endElement.Value));
|
||||||
endChar = Convert.ToChar(endElement.Value);
|
|
||||||
|
_logger.LogMessage("Start: '" + startElement.Value + "' (" + startChar + ")");
|
||||||
Debugger.Break();
|
_logger.LogMessage("End: '" + endElement.Value + "' (" + endChar + ")");
|
||||||
//TODO: We need a platform independet solution for getting the characters supported by a font!
|
//Check if the chars are within ASCII range
|
||||||
|
if ((startChar >= endChar) ||
|
||||||
|
(startChar < 0) || (startChar > 0xFFFF) ||
|
||||||
|
(endChar < 0) || (endChar > 0xFFFF))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Invalid character range " +
|
||||||
|
startElement.Value + " - " + endElement.Value);
|
||||||
|
}
|
||||||
|
//add each char from the range to the list
|
||||||
|
for (var i = startChar; i < endChar - 1; i++)
|
||||||
|
{
|
||||||
|
characters.Add(Convert.ToChar(i));
|
||||||
|
}
|
||||||
|
//Debugger.Break();
|
||||||
|
//TODO: We need a platform independet solution for checking the characters supported by a font! For now we pass it.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogMessage("Import of SpriteFont finished.");
|
||||||
var result = new FontDescription(fontName, fontSize, fontSpacing, fontStyle)
|
var result = new FontDescription(fontName, fontSize, fontSpacing, fontStyle)
|
||||||
{
|
{
|
||||||
Characters = characters
|
Characters = characters
|
||||||
|
@ -22,11 +22,12 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
[PercentageComplete(90)]
|
[PercentageComplete(90)]
|
||||||
[Developer("SilentWarrior/Eagle Eye Studios")]
|
[Developer("SilentWarrior/Eagle Eye Studios")]
|
||||||
[TestState(TestStateAttribute.TestState.Untested)] //due to missing importer's font character enumeration
|
[TestState(TestStateAttribute.TestState.Untested)] //due to missing importer's font character enumeration
|
||||||
[ContentProcessor]
|
[ContentProcessor(DisplayName = "FontDescription Processor - ANX Framework")]
|
||||||
public class FontDescriptionProcessor : ContentProcessor<FontDescription, SpriteFontContent>
|
public class FontDescriptionProcessor : ContentProcessor<FontDescription, SpriteFontContent>
|
||||||
{
|
{
|
||||||
public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
|
public override SpriteFontContent Process(FontDescription input, ContentProcessorContext context)
|
||||||
{
|
{
|
||||||
|
context.Logger.LogMessage("Processing of FontDescription started.");
|
||||||
if (input == null)
|
if (input == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("input");
|
throw new ArgumentNullException("input");
|
||||||
@ -104,20 +105,21 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
spriteFontContent.Texture = ConvertBitmap(bitmap);
|
spriteFontContent.Texture = ConvertBitmap(bitmap);
|
||||||
spriteFontContent.CharacterMap = input.Characters.ToList();
|
spriteFontContent.CharacterMap = input.Characters.ToList();
|
||||||
spriteFontContent.DefaultCharacter = input.DefaultCharacter;
|
spriteFontContent.DefaultCharacter = input.DefaultCharacter;
|
||||||
spriteFontContent.Glyphs = CreateOutputGlyphs();
|
spriteFontContent.Glyphs = spriteFontContent.Cropping;
|
||||||
for (int i = 0; i < input.Characters.Count; i++)
|
spriteFontContent.Kerning = new List<Vector3>();
|
||||||
|
for (var i = 0; i < input.Characters.Count; i++)
|
||||||
{
|
{
|
||||||
Vector3 value = spriteFontContent.Kerning[i];
|
var value = Vector3.Zero;
|
||||||
if (!input.UseKerning)
|
if (input.UseKerning)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
value.Y = spriteFontContent.Cropping[i].Width;
|
value.Y = spriteFontContent.Cropping[i].Width;
|
||||||
}
|
|
||||||
if (!input.UseKerning)
|
|
||||||
{
|
|
||||||
value.X = 0f;
|
value.X = 0f;
|
||||||
value.Z = 0f;
|
value.Z = 0f;
|
||||||
}
|
}
|
||||||
spriteFontContent.Kerning[i] = value;
|
spriteFontContent.Kerning.Add(value);
|
||||||
}
|
}
|
||||||
spriteFontContent.LineSpacing = (int) Math.Ceiling(font.GetHeight());
|
spriteFontContent.LineSpacing = (int) Math.Ceiling(font.GetHeight());
|
||||||
spriteFontContent.Spacing = input.Spacing;
|
spriteFontContent.Spacing = input.Spacing;
|
||||||
@ -129,7 +131,7 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
foreach (Bitmap bitmap in bitmaps)
|
foreach (Bitmap bitmap in bitmaps)
|
||||||
bitmap.Dispose();
|
bitmap.Dispose();
|
||||||
}
|
}
|
||||||
|
context.Logger.LogMessage("Processing of FontDescription finished.");
|
||||||
return spriteFontContent;
|
return spriteFontContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,9 +243,9 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
var bitmapContent = new PixelBitmapContent<Color>(bitmap.Width, bitmap.Height);
|
var bitmapContent = new PixelBitmapContent<Color>(bitmap.Width, bitmap.Height);
|
||||||
var destColor = new Color();
|
var destColor = new Color();
|
||||||
|
|
||||||
for (int x = bitmap.Width; x > 0; x--)
|
for (int x = 0; x < bitmap.Width; x++)
|
||||||
{
|
{
|
||||||
for (int y = bitmap.Height; y > 0; y--)
|
for (int y = 0; y < bitmap.Height; y++)
|
||||||
{
|
{
|
||||||
System.Drawing.Color sourceColor = bitmap.GetPixel(x, y);
|
System.Drawing.Color sourceColor = bitmap.GetPixel(x, y);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ namespace ANX.Framework.Content.Pipeline.Processors
|
|||||||
internal float Spacing { get; set; }
|
internal float Spacing { get; set; }
|
||||||
|
|
||||||
[ContentSerializer(ElementName = "Kerning", AllowNull = false)]
|
[ContentSerializer(ElementName = "Kerning", AllowNull = false)]
|
||||||
internal List<Vector3> Kerning { get; private set; }
|
internal List<Vector3> Kerning { get; set; }
|
||||||
|
|
||||||
[ContentSerializer(ElementName = "DefaultCharacter", AllowNull = true)]
|
[ContentSerializer(ElementName = "DefaultCharacter", AllowNull = true)]
|
||||||
internal char? DefaultCharacter { get; set; }
|
internal char? DefaultCharacter { get; set; }
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#region Using Statements
|
#region Using Statements
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -12,53 +14,116 @@ namespace ANX.Framework.Content.Pipeline.Serialization.Compiler
|
|||||||
{
|
{
|
||||||
public abstract class ContentTypeWriter
|
public abstract class ContentTypeWriter
|
||||||
{
|
{
|
||||||
private bool canDeserializeIntoExistingObject;
|
private List<ContentTypeWriter> _genericArgumentWriters;
|
||||||
private Type targetType;
|
|
||||||
internal readonly bool TargetIsValueType;
|
internal readonly bool TargetIsValueType;
|
||||||
|
|
||||||
|
#region CFPlatformDesc
|
||||||
|
private static readonly NetCfPlatformDescription[] NetCfDescs = new[]
|
||||||
|
{
|
||||||
|
new NetCfPlatformDescription(TargetPlatform.XBox360, new byte[]
|
||||||
|
{
|
||||||
|
132,
|
||||||
|
44,
|
||||||
|
248,
|
||||||
|
190,
|
||||||
|
29,
|
||||||
|
229,
|
||||||
|
5,
|
||||||
|
83
|
||||||
|
}, new string[]
|
||||||
|
{
|
||||||
|
"mscorlib",
|
||||||
|
"System",
|
||||||
|
"System.Xml"
|
||||||
|
}, new byte[]
|
||||||
|
{
|
||||||
|
28,
|
||||||
|
158,
|
||||||
|
37,
|
||||||
|
150,
|
||||||
|
134,
|
||||||
|
249,
|
||||||
|
33,
|
||||||
|
224
|
||||||
|
}, new Version(3, 7, 0, 0)),
|
||||||
|
new NetCfPlatformDescription(TargetPlatform.WindowsPhone, new byte[]
|
||||||
|
{
|
||||||
|
132,
|
||||||
|
44,
|
||||||
|
248,
|
||||||
|
190,
|
||||||
|
29,
|
||||||
|
229,
|
||||||
|
5,
|
||||||
|
83
|
||||||
|
}, new string[]
|
||||||
|
{
|
||||||
|
"mscorlib",
|
||||||
|
"System",
|
||||||
|
"System.Xml"
|
||||||
|
}, new byte[]
|
||||||
|
{
|
||||||
|
150,
|
||||||
|
157,
|
||||||
|
184,
|
||||||
|
5,
|
||||||
|
61,
|
||||||
|
51,
|
||||||
|
34,
|
||||||
|
172
|
||||||
|
}, new Version(3, 7, 0, 0))
|
||||||
|
};
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PublicKeyToken
|
||||||
|
private static readonly byte[] WindowsPublicKeyToken = new byte[]
|
||||||
|
{
|
||||||
|
132,
|
||||||
|
44,
|
||||||
|
248,
|
||||||
|
190,
|
||||||
|
29,
|
||||||
|
229,
|
||||||
|
5,
|
||||||
|
83
|
||||||
|
};
|
||||||
|
#endregion
|
||||||
|
|
||||||
protected ContentTypeWriter(Type targetType)
|
protected ContentTypeWriter(Type targetType)
|
||||||
{
|
{
|
||||||
this.targetType = targetType;
|
TargetType = targetType;
|
||||||
|
TargetIsValueType = targetType.IsValueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetStrongTypeName(Type type, TargetPlatform targetPlatform)
|
internal static string GetStrongTypeName(Type type, TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
string text = ContentTypeWriter.GetTypeName(type);
|
string text = GetTypeName(type);
|
||||||
if (!string.IsNullOrEmpty(type.Namespace))
|
if (!string.IsNullOrEmpty(type.Namespace))
|
||||||
{
|
{
|
||||||
text = type.Namespace + '.' + text;
|
text = type.Namespace + '.' + text;
|
||||||
}
|
}
|
||||||
return text + ", " + ContentTypeWriter.GetAssemblyFullName(type.Assembly, targetPlatform);
|
return text + ", " + GetAssemblyFullName(type.Assembly, targetPlatform);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetAssemblyFullName(Assembly assembly, TargetPlatform targetPlatform)
|
internal static string GetAssemblyFullName(Assembly assembly, TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
AssemblyName assemblyName = assembly.GetName();
|
AssemblyName assemblyName = assembly.GetName();
|
||||||
//ContentTypeWriter.NetCFPlatformDescription[] netCFDescs = ContentTypeWriter.NetCFDescs;
|
NetCfPlatformDescription[] netCfDescs = NetCfDescs;
|
||||||
//for (int i = 0; i < netCFDescs.Length; i++)
|
foreach (var netCfPlatformDescription in netCfDescs.Where(netCfPlatformDescription => netCfPlatformDescription.TargetPlatform == targetPlatform))
|
||||||
//{
|
{
|
||||||
// ContentTypeWriter.NetCFPlatformDescription netCFPlatformDescription = netCFDescs[i];
|
assemblyName = (AssemblyName)assemblyName.Clone();
|
||||||
// if (netCFPlatformDescription.TargetPlatform == targetPlatform)
|
if (ContentTypeWriter.KeysAreEqual(assemblyName.GetPublicKeyToken(), WindowsPublicKeyToken))
|
||||||
// {
|
{
|
||||||
// assemblyName = (AssemblyName)assemblyName.Clone();
|
assemblyName.SetPublicKeyToken(netCfPlatformDescription.PublicKeyToken);
|
||||||
// if (ContentTypeWriter.KeysAreEqual(assemblyName.GetPublicKeyToken(), ContentTypeWriter.WindowsPublicKeyToken))
|
break;
|
||||||
// {
|
}
|
||||||
// assemblyName.SetPublicKeyToken(netCFPlatformDescription.PublicKeyToken);
|
var netCfAssemblies = netCfPlatformDescription.NetCfAssemblies;
|
||||||
// break;
|
if (netCfAssemblies.Any(value => assemblyName.Name.Equals(value, StringComparison.InvariantCulture)))
|
||||||
// }
|
{
|
||||||
// string[] netCFAssemblies = netCFPlatformDescription.NetCFAssemblies;
|
assemblyName.Version = netCfPlatformDescription.NetCfAssemblyVersion;
|
||||||
// for (int j = 0; j < netCFAssemblies.Length; j++)
|
assemblyName.SetPublicKeyToken(netCfPlatformDescription.NetCfPublicKeyToken);
|
||||||
// {
|
}
|
||||||
// string value = netCFAssemblies[j];
|
}
|
||||||
// if (assemblyName.Name.Equals(value, StringComparison.InvariantCulture))
|
|
||||||
// {
|
|
||||||
// assemblyName.Version = netCFPlatformDescription.NetCFAssemblyVersion;
|
|
||||||
// assemblyName.SetPublicKeyToken(netCFPlatformDescription.NetCFPublicKeyToken);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
return assemblyName.FullName;
|
return assemblyName.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,50 +133,86 @@ namespace ANX.Framework.Content.Pipeline.Serialization.Compiler
|
|||||||
Type declaringType = type.DeclaringType;
|
Type declaringType = type.DeclaringType;
|
||||||
if (declaringType != null)
|
if (declaringType != null)
|
||||||
{
|
{
|
||||||
text = ContentTypeWriter.GetTypeName(declaringType) + '+' + text;
|
text = GetTypeName(declaringType) + '+' + text;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool KeysAreEqual(byte[] a, byte[] b)
|
||||||
|
{
|
||||||
|
if (a.Length != b.Length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < a.Length; i++)
|
||||||
|
{
|
||||||
|
if (a[i] != b[i])
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
internal string GetGenericArgumentRuntimeTypes(TargetPlatform targetPlatform)
|
internal string GetGenericArgumentRuntimeTypes(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
System.Diagnostics.Debugger.Break();
|
//System.Diagnostics.Debugger.Break();
|
||||||
return "";
|
//return "";
|
||||||
|
|
||||||
//if (this.genericArgumentWriters == null)
|
if (_genericArgumentWriters == null)
|
||||||
//{
|
{
|
||||||
// return string.Empty;
|
return string.Empty;
|
||||||
//}
|
}
|
||||||
//string text = string.Empty;
|
var text = string.Empty;
|
||||||
//for (int i = 0; i < this.genericArgumentWriters.Count; i++)
|
for (var i = 0; i < _genericArgumentWriters.Count; i++)
|
||||||
//{
|
{
|
||||||
// if (i > 0)
|
if (i > 0)
|
||||||
// {
|
{
|
||||||
// text += ',';
|
text += ',';
|
||||||
// }
|
}
|
||||||
// object obj = text;
|
object obj = text;
|
||||||
// text = string.Concat(new object[]
|
text = string.Concat(new[]
|
||||||
// {
|
{
|
||||||
// obj,
|
obj,
|
||||||
// '[',
|
'[',
|
||||||
// this.genericArgumentWriters[i].GetRuntimeType(targetPlatform),
|
_genericArgumentWriters[i].GetRuntimeType(targetPlatform),
|
||||||
// ']'
|
']'
|
||||||
// });
|
});
|
||||||
//}
|
}
|
||||||
//return '[' + text + ']';
|
return '[' + text + ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DoInitialize(ContentCompiler compiler)
|
||||||
|
{
|
||||||
|
Initialize(compiler);
|
||||||
|
if (TargetType.IsGenericType)
|
||||||
|
{
|
||||||
|
_genericArgumentWriters = new List<ContentTypeWriter>();
|
||||||
|
Type[] genericArguments = TargetType.GetGenericArguments();
|
||||||
|
foreach (var type in genericArguments)
|
||||||
|
{
|
||||||
|
_genericArgumentWriters.Add(compiler.GetTypeWriter(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string GetRuntimeReader(TargetPlatform targetPlatform);
|
public abstract string GetRuntimeReader(TargetPlatform targetPlatform);
|
||||||
|
|
||||||
public virtual string GetRuntimeType(TargetPlatform targetPlatform)
|
public virtual string GetRuntimeType(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var text = GetTypeName(TargetType);
|
||||||
|
if (!string.IsNullOrEmpty(TargetType.Namespace))
|
||||||
|
{
|
||||||
|
text = TargetType.Namespace + '.' + text;
|
||||||
|
}
|
||||||
|
text += GetGenericArgumentRuntimeTypes(targetPlatform);
|
||||||
|
return text + ", " + GetAssemblyFullName(TargetType.Assembly, targetPlatform);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Initialize(ContentCompiler compiler)
|
protected virtual void Initialize(ContentCompiler compiler)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal virtual bool ShouldCompressContent(TargetPlatform targetPlatform, Object value)
|
protected internal virtual bool ShouldCompressContent(TargetPlatform targetPlatform, Object value)
|
||||||
@ -121,20 +222,16 @@ namespace ANX.Framework.Content.Pipeline.Serialization.Compiler
|
|||||||
|
|
||||||
protected internal abstract void Write(ContentWriter output, Object value);
|
protected internal abstract void Write(ContentWriter output, Object value);
|
||||||
|
|
||||||
public virtual bool CanDeserializeIntoExistingObject
|
public virtual bool CanDeserializeIntoExistingObject
|
||||||
{
|
{
|
||||||
get
|
get;
|
||||||
{
|
set;
|
||||||
return canDeserializeIntoExistingObject;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type TargetType
|
public Type TargetType
|
||||||
{
|
{
|
||||||
get
|
get;
|
||||||
{
|
set;
|
||||||
return this.targetType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int TypeVersion
|
public virtual int TypeVersion
|
||||||
@ -144,5 +241,22 @@ namespace ANX.Framework.Content.Pipeline.Serialization.Compiler
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class NetCfPlatformDescription
|
||||||
|
{
|
||||||
|
public TargetPlatform TargetPlatform;
|
||||||
|
public byte[] PublicKeyToken;
|
||||||
|
public string[] NetCfAssemblies;
|
||||||
|
public byte[] NetCfPublicKeyToken;
|
||||||
|
public Version NetCfAssemblyVersion;
|
||||||
|
public NetCfPlatformDescription(TargetPlatform targetPlatform, byte[] publicKeyToken, string[] netCfAssemblies, byte[] netCfPublicKeyToken, Version netCfAssemblyVersion)
|
||||||
|
{
|
||||||
|
TargetPlatform = targetPlatform;
|
||||||
|
PublicKeyToken = publicKeyToken;
|
||||||
|
NetCfAssemblies = netCfAssemblies;
|
||||||
|
NetCfPublicKeyToken = netCfPublicKeyToken;
|
||||||
|
NetCfAssemblyVersion = netCfAssemblyVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user