зеркало из https://github.com/microsoft/Tx.git
Support for "length" attribute for strings in the manifest
This commit is contained in:
Родитель
ddefb19fcc
Коммит
b44091452b
|
@ -5,5 +5,5 @@ using System.Reflection;
|
||||||
[assembly: AssemblyCompany("MS Open Tech")]
|
[assembly: AssemblyCompany("MS Open Tech")]
|
||||||
[assembly: AssemblyProduct("Tx (LINQ to Logs and Traces)")]
|
[assembly: AssemblyProduct("Tx (LINQ to Logs and Traces)")]
|
||||||
[assembly: AssemblyCopyright("Copyright © MS Open Tech 2012")]
|
[assembly: AssemblyCopyright("Copyright © MS Open Tech 2012")]
|
||||||
[assembly: AssemblyVersion("1.0.40213.0")]
|
[assembly: AssemblyVersion("1.0.40311.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.40213.0")]
|
[assembly: AssemblyFileVersion("1.0.40311.0")]
|
|
@ -23,7 +23,7 @@ namespace Tx.Windows
|
||||||
public ManifestParser(string manifest)
|
public ManifestParser(string manifest)
|
||||||
{
|
{
|
||||||
XElement localization;
|
XElement localization;
|
||||||
XElement resources;
|
XElement resources = null;
|
||||||
|
|
||||||
_root = XElement.Parse(manifest);
|
_root = XElement.Parse(manifest);
|
||||||
_instrumentation = _root.Element(ElementNames.Instrumentation);
|
_instrumentation = _root.Element(ElementNames.Instrumentation);
|
||||||
|
@ -31,7 +31,10 @@ namespace Tx.Windows
|
||||||
{
|
{
|
||||||
_instrumentation = _root.Element(ElementNames.Instrumentation1);
|
_instrumentation = _root.Element(ElementNames.Instrumentation1);
|
||||||
localization = _root.Element(ElementNames.Localization1);
|
localization = _root.Element(ElementNames.Localization1);
|
||||||
|
|
||||||
|
if (localization != null)
|
||||||
resources = localization.Element(ElementNames.Resources1);
|
resources = localization.Element(ElementNames.Resources1);
|
||||||
|
|
||||||
if (resources != null)
|
if (resources != null)
|
||||||
_stringTable = resources.Element(ElementNames.StringTable1);
|
_stringTable = resources.Element(ElementNames.StringTable1);
|
||||||
}
|
}
|
||||||
|
@ -281,8 +284,19 @@ using System;");
|
||||||
if (order > 0)
|
if (order > 0)
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
|
var length = f.Attribute(AttributeNames.Length);
|
||||||
|
|
||||||
|
if (null != length)
|
||||||
|
{
|
||||||
|
sb.AppendFormat(" [EventField(\"{0}\", \"{1}\")]",
|
||||||
|
f.Attribute(AttributeNames.InType).Value, length.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sb.AppendFormat(" [EventField(\"{0}\")]",
|
sb.AppendFormat(" [EventField(\"{0}\")]",
|
||||||
f.Attribute(AttributeNames.InType).Value);
|
f.Attribute(AttributeNames.InType).Value);
|
||||||
|
}
|
||||||
|
|
||||||
sb.AppendLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
if (f.Attribute(AttributeNames.Map) == null)
|
if (f.Attribute(AttributeNames.Map) == null)
|
||||||
|
@ -765,6 +779,7 @@ using System;");
|
||||||
public const string Message = "message";
|
public const string Message = "message";
|
||||||
public const string EventGuid = "eventGUID";
|
public const string EventGuid = "eventGUID";
|
||||||
public const string MofValue = "mofValue";
|
public const string MofValue = "mofValue";
|
||||||
|
public const string Length = "length";
|
||||||
public const string Level = "level";
|
public const string Level = "level";
|
||||||
public const string Channel = "channel";
|
public const string Channel = "channel";
|
||||||
public const string Chid = "chid";
|
public const string Chid = "chid";
|
||||||
|
|
|
@ -379,17 +379,17 @@ namespace Tx.Windows
|
||||||
|
|
||||||
public string ReadAnsiStringPrefixLen()
|
public string ReadAnsiStringPrefixLen()
|
||||||
{
|
{
|
||||||
int length = ReadInt16();
|
// reads a string, assuming the lenght was win:UInt32 right before it in the manifest
|
||||||
string str = Marshal.PtrToStringAnsi((IntPtr) _data, length);
|
string str = Marshal.PtrToStringAnsi((IntPtr) _data, (int)_length);
|
||||||
_data += length;
|
_data += _length;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReadUnicodeStringPrefixLen()
|
public string ReadUnicodeStringPrefixLen()
|
||||||
{
|
{
|
||||||
int length = ReadInt16()/2;
|
// reads a string, assuming the lenght was win:UInt32 right before it in the manifest
|
||||||
var chars = new char[length];
|
var chars = new char[_length];
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < _length; i++)
|
||||||
{
|
{
|
||||||
chars[i] = (char) ReadInt16();
|
chars[i] = (char) ReadInt16();
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,13 @@ namespace Tx.Windows
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "win:UnicodeString":
|
case "win:UnicodeString":
|
||||||
|
if (!String.IsNullOrEmpty(attribute.Length))
|
||||||
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (int.TryParse(attribute.Length, out len))
|
if (int.TryParse(attribute.Length, out len))
|
||||||
{
|
|
||||||
readExpression = MakeExpression(r => r.ReadUnicodeString(len), reader);
|
readExpression = MakeExpression(r => r.ReadUnicodeString(len), reader);
|
||||||
|
else
|
||||||
|
readExpression = MakeExpression(r => r.ReadUnicodeStringPrefixLen(), reader);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,7 +133,18 @@ namespace Tx.Windows
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "win:AnsiString":
|
case "win:AnsiString":
|
||||||
|
if (!String.IsNullOrEmpty(attribute.Length))
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
if (int.TryParse(attribute.Length, out len))
|
||||||
|
readExpression = MakeExpression(r => r.ReadAnsiString(len), reader);
|
||||||
|
else
|
||||||
|
readExpression = MakeExpression(r => r.ReadAnsiStringPrefixLen(), reader);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
readExpression = MakeExpression(r => r.ReadAnsiString(), reader);
|
readExpression = MakeExpression(r => r.ReadAnsiString(), reader);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "win:FILETIME":
|
case "win:FILETIME":
|
||||||
|
|
Загрузка…
Ссылка в новой задаче