本文整理汇总了C#中Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString方法的典型用法代码示例。如果您正苦于以下问题:C# TaskLoggingHelper.FormatResourceString方法的具体用法?C# TaskLoggingHelper.FormatResourceString怎么用?C# TaskLoggingHelper.FormatResourceString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Utilities.TaskLoggingHelper
的用法示例。
在下文中一共展示了TaskLoggingHelper.FormatResourceString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeCache
internal static StateFileBase DeserializeCache(string stateFile, TaskLoggingHelper log, Type requiredReturnType)
{
StateFileBase o = null;
try
{
if (((stateFile == null) || (stateFile.Length <= 0)) || !File.Exists(stateFile))
{
return o;
}
using (FileStream stream = new FileStream(stateFile, FileMode.Open))
{
object obj2 = new BinaryFormatter().Deserialize(stream);
o = obj2 as StateFileBase;
if ((o == null) && (obj2 != null))
{
log.LogMessageFromResources("General.CouldNotReadStateFileMessage", new object[] { stateFile, log.FormatResourceString("General.IncompatibleStateFileType", new object[0]) });
}
if ((o != null) && !requiredReturnType.IsInstanceOfType(o))
{
log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", new object[] { stateFile, log.FormatResourceString("General.IncompatibleStateFileType", new object[0]) });
o = null;
}
}
}
catch (Exception exception)
{
log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", new object[] { stateFile, exception.Message });
}
return o;
}
示例2: GetTypeLibId
private string GetTypeLibId(TaskLoggingHelper log)
{
if (this.taskItem != null)
{
return this.taskItem.ItemSpec;
}
return log.FormatResourceString("ResolveComReference.TypeLibAttrId", new object[] { this.attr.guid, this.attr.wMajorVerNum, this.attr.wMinorVerNum });
}
示例3: TestFormatResourceString2
public void TestFormatResourceString2 ()
{
tlh = new TaskLoggingHelper (task);
tlh.FormatResourceString ("MessageResource1");
}
示例4: TestFormatResourceString1
public void TestFormatResourceString1 ()
{
tlh = new TaskLoggingHelper (task);
tlh.FormatResourceString (null);
}
示例5: VerifyLogDoesNotContainResource
/// <summary>
/// Given a log and a resource string, acquires the text of that resource string and
/// compares it to the log. Assert fails if the log contain the desired string.
/// </summary>
/// <param name="e">The MockEngine that contains the log we're checking</param>
/// <param name="log">The TaskLoggingHelper that we use to load the string resource</param>
/// <param name="errorResource">The name of the resource string to check the log for</param>
/// <param name="args">Arguments needed to format the resource string properly</param>
private void VerifyLogDoesNotContainResource(MockEngine e, TaskLoggingHelper log, string messageResource, params object[] args)
{
string message = log.FormatResourceString(messageResource, args);
e.AssertLogDoesntContain(message);
}
示例6: GetTypeLibNameForTypeLibAttrs
internal static bool GetTypeLibNameForTypeLibAttrs(TaskLoggingHelper log, System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttr, out string typeLibName)
{
bool flag;
typeLibName = "";
ITypeLib typeLib = null;
try
{
try
{
System.Runtime.InteropServices.ComTypes.TYPELIBATTR typelibattr = typeLibAttr;
typeLib = (ITypeLib) Microsoft.Build.Tasks.NativeMethods.LoadRegTypeLib(ref typelibattr.guid, typelibattr.wMajorVerNum, typelibattr.wMinorVerNum, typelibattr.lcid);
}
catch (COMException exception)
{
log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLib", new object[] { typeLibAttr.guid, typeLibAttr.wMajorVerNum, typeLibAttr.wMinorVerNum, exception.Message });
return false;
}
string typeLibId = log.FormatResourceString("ResolveComReference.TypeLibAttrId", new object[] { typeLibAttr.guid.ToString(), typeLibAttr.wMajorVerNum, typeLibAttr.wMinorVerNum });
flag = GetTypeLibNameForITypeLib(log, typeLib, typeLibId, out typeLibName);
}
finally
{
if (typeLib != null)
{
Marshal.ReleaseComObject(typeLib);
}
}
return flag;
}
示例7: DeserializeCache
/// <summary>
/// Reads the specified file from disk into a StateFileBase derived object.
/// </summary>
/// <param name="stateFile"></param>
/// <returns></returns>
static internal StateFileBase DeserializeCache(string stateFile, TaskLoggingHelper log, Type requiredReturnType)
{
StateFileBase retVal = null;
// First, we read the cache from disk if one exists, or if one does not exist
// then we create one.
try
{
if (!string.IsNullOrEmpty(stateFile) && File.Exists(stateFile))
{
using (FileStream s = new FileStream(stateFile, FileMode.Open))
{
BinaryFormatter formatter = new BinaryFormatter();
object deserializedObject = formatter.Deserialize(s);
retVal = deserializedObject as StateFileBase;
// If the deserialized object is null then there would be no cast error but retVal would still be null
// only log the message if there would have been a cast error
if (retVal == null && deserializedObject != null)
{
// When upgrading to Visual Studio 2008 and running the build for the first time the resource cache files are replaced which causes a cast error due
// to a new version number on the tasks class. "Unable to cast object of type 'Microsoft.Build.Tasks.SystemState' to type 'Microsoft.Build.Tasks.StateFileBase”.
// If there is an invalid cast, a message rather than a warning should be emitted.
log.LogMessageFromResources("General.CouldNotReadStateFileMessage", stateFile, log.FormatResourceString("General.IncompatibleStateFileType"));
}
if ((retVal != null) && (!requiredReturnType.IsInstanceOfType(retVal)))
{
log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", stateFile,
log.FormatResourceString("General.IncompatibleStateFileType"));
retVal = null;
}
// If we get back a valid object and internals were changed, things are likely to be null. Check the version before we use it.
if (retVal != null && retVal._serializedVersion != CurrentSerializationVersion)
{
log.LogMessageFromResources("General.CouldNotReadStateFileMessage", stateFile, log.FormatResourceString("General.IncompatibleStateFileType"));
retVal = null;
}
}
}
}
catch (Exception e)
{
if (ExceptionHandling.IsCriticalException(e))
{
throw;
}
// The deserialization process seems like it can throw just about
// any exception imaginable. Catch them all here.
// Not being able to deserialize the cache is not an error, but we let the user know anyway.
// Don't want to hold up processing just because we couldn't read the file.
log.LogWarningWithCodeFromResources("General.CouldNotReadStateFile", stateFile, e.Message);
}
return retVal;
}
示例8: VerifyLogDoesNotContainErrorFromResource
/// <summary>
/// Given a log and a resource string, acquires the text of that resource string and
/// compares it to the log. Assert fails if the log contains the desired string.
/// </summary>
/// <param name="e">The MockEngine that contains the log we're checking</param>
/// <param name="log">The TaskLoggingHelper that we use to load the string resource</param>
/// <param name="errorResource">The name of the resource string to check the log for</param>
/// <param name="args">Arguments needed to format the resource string properly</param>
internal static void VerifyLogDoesNotContainErrorFromResource(MockEngine e, TaskLoggingHelper log, string errorResource, params object[] args)
{
string errorMessage = log.FormatResourceString(errorResource, args);
e.AssertLogDoesntContain(errorMessage);
}
示例9: GetTypeLibNameForTypeLibAttrs
/*
* Method: GetTypeLibNameForTypeLibAttrs
*
* Gets the name of given type library.
*/
internal static bool GetTypeLibNameForTypeLibAttrs(TaskLoggingHelper log, bool silent, TYPELIBATTR typeLibAttr, out string typeLibName)
{
typeLibName = "";
ITypeLib typeLib = null;
try
{
// load our type library
try
{
TYPELIBATTR attr = typeLibAttr;
typeLib = (ITypeLib)NativeMethods.LoadRegTypeLib(ref attr.guid, attr.wMajorVerNum, attr.wMinorVerNum, attr.lcid);
}
catch (COMException ex)
{
if (!silent)
{
log.LogWarningWithCodeFromResources("ResolveComReference.CannotLoadTypeLib", typeLibAttr.guid, typeLibAttr.wMajorVerNum, typeLibAttr.wMinorVerNum, ex.Message);
}
return false;
}
string typeLibId = log.FormatResourceString("ResolveComReference.TypeLibAttrId", typeLibAttr.guid.ToString(), typeLibAttr.wMajorVerNum, typeLibAttr.wMinorVerNum);
return GetTypeLibNameForITypeLib(log, silent, typeLib, typeLibId, out typeLibName);
}
finally
{
if (typeLib != null)
Marshal.ReleaseComObject(typeLib);
}
}
示例10: GetTypeLibId
/// <summary>
/// A unique id string of this reference, it's either the item spec or (in the case of a dependency ref)
/// guid and version from typelib attributes
/// </summary>
private string GetTypeLibId(TaskLoggingHelper log)
{
if (taskItem != null)
{
return taskItem.ItemSpec;
}
else
{
return log.FormatResourceString("ResolveComReference.TypeLibAttrId", attr.guid, attr.wMajorVerNum, attr.wMinorVerNum);
}
}