本文整理汇总了C#中System.Resources.ResXDataNode.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ResXDataNode.GetValue方法的具体用法?C# ResXDataNode.GetValue怎么用?C# ResXDataNode.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResXDataNode
的用法示例。
在下文中一共展示了ResXDataNode.GetValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public void Add(ResXDataNode entry, bool isSource = true)
{
try
{
if (isSource)
{
// ソース
this.ResxTranslatorTable.AddResxTranslatorTableRow(
entry.Name,
entry.GetValue((ITypeResolutionService)null).ToString(),
string.Empty,
entry.Comment
);
}
else
{
// ターゲット
this.ResxTranslatorTable.AddResxTranslatorTableRow(
entry.Name,
string.Empty,
entry.GetValue((ITypeResolutionService)null).ToString(),
entry.Comment
);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例2: Update
public void Update(ResxTranslatorTableRow row, ResXDataNode entry, bool isSource = true)
{
try
{
if (null == row) return;
if (isSource)
{
// ソース
row.SourceValue = entry.GetValue((ITypeResolutionService)null).ToString();
}
else
{
// ターゲット
row.TargetValue = entry.GetValue((ITypeResolutionService)null).ToString();
}
// コメント
if (string.IsNullOrWhiteSpace(row.Comment))
{
row.Comment = entry.Comment;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
示例3: ITRSNotUsedWhenCreatedNew
public void ITRSNotUsedWhenCreatedNew ()
{
ResXDataNode node;
node = new ResXDataNode ("along", 34L);
object obj = node.GetValue (new ReturnIntITRS ());
Assert.IsInstanceOfType (typeof (long), obj, "#A1");
}
示例4: Regex
static Regex csharpFormat = new Regex(@"(^|[^\{])\{\d\}"); // matches "{0}" unless the first bracket is escaped, e.g. "{{0}"
public ResourceItem(ResXDataNode data)
{
if (data == null) throw new ArgumentNullException();
if (data != null) {
_name = data.Name;
_value = data.GetValue(_assemblyname) as String;
_metadata_comment = data.Comment;
if (!String.IsNullOrEmpty(Value)) {
// Since this is being read from .resx, assume it's a .Net/C# style string
if (csharpFormat.IsMatch(Value)) _metadata_flags |= TranslationFlags.csharpFormatString;
}
}
}
示例5: LoadingFileFails
public void LoadingFileFails ()
{
string corruptFile = Path.GetTempFileName ();
ResXFileRef fileRef = new ResXFileRef (corruptFile, typeof (serializable).AssemblyQualifiedName);
File.AppendAllText (corruptFile, "corrupt");
ResXDataNode node = new ResXDataNode ("aname", fileRef);
node.GetValue ((AssemblyName []) null);
}
示例6: AddResource
public void AddResource (ResXDataNode node)
{
if (node == null)
throw new ArgumentNullException ("node");
if (writer == null)
InitWriter ();
if (node.IsWritable)
WriteWritableNode (node);
else if (node.FileRef != null)
AddResource (node.Name, node.FileRef, node.Comment);
else
AddResource (node.Name, node.GetValue ((AssemblyName []) null), node.Comment);
}
示例7: InterestingString
// Is this data node an interesting string?
bool InterestingString(ResXDataNode dataNode)
{
string name = dataNode.Name;
object value = dataNode.GetValue(noAssemblies);
if (value != null && value is string) {
if ((string) value == "" || name == "")
return false;
if (name == "$this.Text" || (! name.StartsWith(">>") && ! name.StartsWith("$")))
return true;
}
return false;
}
示例8: ParseDataNode
private void ParseDataNode(XmlTextReader reader, bool isMetaData) {
DataNodeInfo nodeInfo = new DataNodeInfo();
nodeInfo.Name = reader[ResXResourceWriter.NameStr];
string typeName = reader[ResXResourceWriter.TypeStr];
string alias = null;
AssemblyName assemblyName = null;
if (!string.IsNullOrEmpty(typeName)) {
alias = GetAliasFromTypeName(typeName);
}
if (!string.IsNullOrEmpty(alias)) {
assemblyName = aliasResolver.ResolveAlias(alias);
}
if (assemblyName != null )
{
nodeInfo.TypeName = GetTypeFromTypeName(typeName) + ", " + assemblyName.FullName;
}
else {
nodeInfo.TypeName = reader[ResXResourceWriter.TypeStr];
}
nodeInfo.MimeType = reader[ResXResourceWriter.MimeTypeStr];
bool finishedReadingDataNode = false;
nodeInfo.ReaderPosition = GetPosition(reader);
while(!finishedReadingDataNode && reader.Read()) {
if(reader.NodeType == XmlNodeType.EndElement && ( reader.LocalName.Equals(ResXResourceWriter.DataStr) || reader.LocalName.Equals(ResXResourceWriter.MetadataStr) )) {
// we just found </data>, quit or </metadata>
finishedReadingDataNode = true;
} else {
// could be a <value> or a <comment>
if (reader.NodeType == XmlNodeType.Element) {
if (reader.Name.Equals(ResXResourceWriter.ValueStr)) {
WhitespaceHandling oldValue = reader.WhitespaceHandling;
try {
// based on the documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmltextreaderclasswhitespacehandlingtopic.asp
// this is ok because:
// "Because the XmlTextReader does not have DTD information available to it,
// SignificantWhitepsace nodes are only returned within the an xml:space='preserve' scope."
// the xml:space would not be present for anything else than string and char (see ResXResourceWriter)
// so this would not cause any breaking change while reading data from Everett (we never outputed
// xml:space then) or from whidbey that is not specifically either a string or a char.
// However please note that manually editing a resx file in Everett and in Whidbey because of the addition
// of xml:space=preserve might have different consequences...
reader.WhitespaceHandling = WhitespaceHandling.Significant;
nodeInfo.ValueData = reader.ReadString();
} finally {
reader.WhitespaceHandling = oldValue;
}
} else if (reader.Name.Equals(ResXResourceWriter.CommentStr)) {
nodeInfo.Comment = reader.ReadString();
}
} else {
// weird, no <xxxx> tag, just the inside of <data> as text
nodeInfo.ValueData = reader.Value.Trim();
}
}
}
if (nodeInfo.Name==null) {
throw new ArgumentException(SR.GetString(SR.InvalidResXResourceNoName, nodeInfo.ValueData));
}
ResXDataNode dataNode = new ResXDataNode(nodeInfo, BasePath);
if(UseResXDataNodes) {
resData[nodeInfo.Name] = dataNode;
} else {
IDictionary data = (isMetaData ? resMetadata : resData);
if(assemblyNames == null) {
data[nodeInfo.Name] = dataNode.GetValue(typeResolver);
} else {
data[nodeInfo.Name] = dataNode.GetValue(assemblyNames);
}
}
}
示例9: AddResource_WithComment
public void AddResource_WithComment ()
{
ResXResourceWriter w = new ResXResourceWriter (fileName);
ResXDataNode node = new ResXDataNode ("key", "value");
node.Comment = "comment is preserved";
w.AddResource (node);
w.Generate ();
w.Close ();
ResXResourceReader r = new ResXResourceReader (fileName);
ITypeResolutionService typeres = null;
r.UseResXDataNodes = true;
int count = 0;
foreach (DictionaryEntry o in r)
{
string key = o.Key.ToString();
node = (ResXDataNode)o.Value;
string value = node.GetValue (typeres).ToString ();
string comment = node.Comment;
Assert.AreEqual ("key", key, "key");
Assert.AreEqual ("value", value, "value");
Assert.AreEqual ("comment is preserved", comment, "comment");
Assert.AreEqual (0, count, "too many nodes");
count++;
}
r.Close ();
File.Delete (fileName);
}
示例10: AddNode
private static void AddNode(List<FileNode> nodes, Dictionary<string, NodeDto> resourceNodes, ResXDataNode entry)
{
NodeDto node;
if (!resourceNodes.TryGetValue(entry.Name, out node))
{
node = new NodeDto
{
Name = entry.Name,
Source = (string)entry.GetValue((ITypeResolutionService)null)
};
}
nodes.Add(new FileNode(
node.Name,
(string)entry.GetValue((ITypeResolutionService)null),
node.Source,
node.Text,
entry.Comment
));
}
示例11: ParseDataNode
private void ParseDataNode (bool meta)
{
Hashtable hashtable = ((meta && ! useResXDataNodes) ? hashtm : hasht);
Point pos = new Point (xmlReader.LineNumber, xmlReader.LinePosition);
string name = GetAttribute ("name");
string type_name = GetAttribute ("type");
string mime_type = GetAttribute ("mimetype");
string comment = null;
string value = GetDataValue (meta, out comment);
ResXDataNode node = new ResXDataNode (name, mime_type, type_name, value, comment, pos, BasePath);
if (useResXDataNodes) {
hashtable [name] = node;
return;
}
if (name == null)
throw new ArgumentException (string.Format (CultureInfo.CurrentCulture,
"Could not find a name for a resource. The resource value was '{0}'.",
node.GetValue ((AssemblyName []) null).ToString()));
// useResXDataNodes is false, add to dictionary of values
if (assemblyNames != null) {
try {
hashtable [name] = node.GetValue (assemblyNames);
} catch (TypeLoadException ex) {
// different error messages depending on type of resource, hacky solution
if (node.handler is TypeConverterFromResXHandler)
hashtable [name] = null;
else
throw ex;
}
} else { // there is a typeresolver or its null
try {
hashtable [name] = node.GetValue (typeresolver);
} catch (TypeLoadException ex) {
if (node.handler is TypeConverterFromResXHandler)
hashtable [name] = null;
else
throw ex;
}
}
}
示例12: ParseDataNode
private void ParseDataNode(XmlTextReader reader, bool isMetaData)
{
DataNodeInfo nodeInfo = new DataNodeInfo {
Name = reader["name"]
};
string str = reader["type"];
string aliasFromTypeName = null;
AssemblyName name = null;
if (!string.IsNullOrEmpty(str))
{
aliasFromTypeName = this.GetAliasFromTypeName(str);
}
if (!string.IsNullOrEmpty(aliasFromTypeName))
{
name = this.aliasResolver.ResolveAlias(aliasFromTypeName);
}
if (name != null)
{
nodeInfo.TypeName = this.GetTypeFromTypeName(str) + ", " + name.FullName;
}
else
{
nodeInfo.TypeName = reader["type"];
}
nodeInfo.MimeType = reader["mimetype"];
bool flag = false;
nodeInfo.ReaderPosition = this.GetPosition(reader);
while (!flag && reader.Read())
{
if ((reader.NodeType == XmlNodeType.EndElement) && (reader.LocalName.Equals("data") || reader.LocalName.Equals("metadata")))
{
flag = true;
}
else
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name.Equals("value"))
{
WhitespaceHandling whitespaceHandling = reader.WhitespaceHandling;
try
{
reader.WhitespaceHandling = WhitespaceHandling.Significant;
nodeInfo.ValueData = reader.ReadString();
continue;
}
finally
{
reader.WhitespaceHandling = whitespaceHandling;
}
}
if (reader.Name.Equals("comment"))
{
nodeInfo.Comment = reader.ReadString();
}
continue;
}
nodeInfo.ValueData = reader.Value.Trim();
}
}
if (nodeInfo.Name == null)
{
throw new ArgumentException(System.Windows.Forms.SR.GetString("InvalidResXResourceNoName", new object[] { nodeInfo.ValueData }));
}
ResXDataNode node = new ResXDataNode(nodeInfo, this.BasePath);
if (this.UseResXDataNodes)
{
this.resData[nodeInfo.Name] = node;
}
else
{
IDictionary dictionary = isMetaData ? this.resMetadata : this.resData;
if (this.assemblyNames == null)
{
dictionary[nodeInfo.Name] = node.GetValue(this.typeResolver);
}
else
{
dictionary[nodeInfo.Name] = node.GetValue(this.assemblyNames);
}
}
}