当前位置: 首页>>代码示例>>C#>>正文


C# TaskLoggingHelper.FormatResourceString方法代码示例

本文整理汇总了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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:StateFileBase.cs

示例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 });
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ComReferenceInfo.cs

示例3: TestFormatResourceString2

		public void TestFormatResourceString2 ()
		{
			tlh = new TaskLoggingHelper (task);
			tlh.FormatResourceString ("MessageResource1");
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:5,代码来源:TaskLoggingHelperTest.cs

示例4: TestFormatResourceString1

		public void TestFormatResourceString1 ()
		{
			tlh = new TaskLoggingHelper (task);
			tlh.FormatResourceString (null);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:5,代码来源:TaskLoggingHelperTest.cs

示例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);
 }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:13,代码来源:ResGen_Tests.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:ComReference.cs

示例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;
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:63,代码来源:StateFileBase.cs

示例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);
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:13,代码来源:AxTlbBaseTask_Tests.cs

示例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);
            }
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:38,代码来源:ComReference.cs

示例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);
     }
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:15,代码来源:ComReferenceInfo.cs


注:本文中的Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。