public void ToStringTest() { ResXFileRef r = new ResXFileRef("mono.bmp", "Bitmap"); Assert.AreEqual("mono.bmp;Bitmap", r.ToString(), "#1"); r = new ResXFileRef("mono.bmp", "Bitmap", Encoding.UTF8); Assert.AreEqual("mono.bmp;Bitmap;utf-8", r.ToString(), "#2"); r = new ResXFileRef("mono.bmp", "Bitmap", (Encoding)null); Assert.AreEqual("mono.bmp;Bitmap", r.ToString(), "#3"); }
/// <include file='doc\ResXDataNode.uex' path='docs/doc[@for="ResXDataNode.GetValue"]/*' /> /// <devdoc> /// Get the value contained in this datanode /// </devdoc> public object GetValue(ITypeResolutionService typeResolver) { if (value != null) { return(value); } object result = null; if (FileRefFullPath != null) { Type objectType = ResolveType(FileRefType, typeResolver); if (objectType != null) { // we have the FQN for this type if (FileRefTextEncoding != null) { fileRef = new ResXFileRef(FileRefFullPath, FileRefType, Encoding.GetEncoding(FileRefTextEncoding)); } else { fileRef = new ResXFileRef(FileRefFullPath, FileRefType); } TypeConverter tc = TypeDescriptor.GetConverter(typeof(ResXFileRef)); result = tc.ConvertFrom(fileRef.ToString()); } else { string newMessage = SR.GetString(SR.TypeLoadExceptionShort, FileRefType); TypeLoadException newTle = new TypeLoadException(newMessage); throw (newTle); } } else if (result == null && nodeInfo.ValueData != null) { // it's embedded, we deserialize it result = GenerateObjectFromDataNodeInfo(nodeInfo, typeResolver); } else { // schema is wrong and say minOccur for Value is 0, // but it's too late to change it... // we need to return null here vswhidbey 180605 return(null); } return(result); }
public void Constructor1_TypeName_Null() { #if NET_2_0 try { new ResXFileRef("mono.bmp", (string)null); Assert.Fail("#1"); } catch (ArgumentNullException ex) { Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2"); Assert.IsNotNull(ex.Message, "#3"); Assert.IsNotNull(ex.ParamName, "#4"); Assert.AreEqual("typeName", ex.ParamName, "#5"); Assert.IsNull(ex.InnerException, "#6"); } #else ResXFileRef r = new ResXFileRef("mono.bmp", (string)null); Assert.AreEqual("mono.bmp;", r.ToString()); #endif }