Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / BuildTasks / Microsoft / Build / Tasks / Windows / MergeLocalizationDirectives.cs / 1305600 / MergeLocalizationDirectives.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: The task that merges all the localization directives files // // History: // 06/15/2005 garyyang - created // //--------------------------------------------------------------------------- using System; using System.IO; using System.Text; using System.Xml; using System.Runtime.InteropServices; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using MS.Internal.Globalization; using MS.Internal.Tasks; using MS.Utility; // For SR // Since we disable PreSharp warnings in this file, we first need to disable warnings // about unknown message numbers and unknown pragmas. #pragma warning disable 1634, 1691 namespace Microsoft.Build.Tasks.Windows { ////// This task merges the localization directives files of single bamls /// into one file corresponding to for the compiled assembly. /// public sealed class MergeLocalizationDirectives : Task { //-------------------------------- // Constructor //-------------------------------- ////// Default constructor of the task /// public MergeLocalizationDirectives() : base(SR.ResourceManager) { } //-------------------------------- // Public methods //-------------------------------- ////// Method invoked by MSBuild to merge localization files of single bamls to /// one file for the whole Assembly. /// public override bool Execute() { TaskHelper.DisplayLogo(Log, SR.Get(SRID.MergeLocalizationDirectivesTask)); if (GeneratedLocalizationFiles.Length > 0) { try { string absoluteFilePath = Path.Combine( Directory.GetCurrentDirectory(), _outputFile ); using (StreamWriter streamWriter = new StreamWriter( new FileStream(absoluteFilePath, FileMode.Create), new UTF8Encoding(true) ) ) { Log.LogMessageFromResources(SRID.CommentFileGenerating, _outputFile); streamWriter.WriteLine("<" + LocComments.LocDocumentRoot + ">"); // keey things simple and fast. Just keep appending the // xml fragments that are already outputed. foreach (ITaskItem item in GeneratedLocalizationFiles) { using (StreamReader locStreamReader = new StreamReader(item.ItemSpec)) { // directly concat Xml fragments streamWriter.WriteLine(locStreamReader.ReadToEnd()); } } streamWriter.WriteLine("" + LocComments.LocDocumentRoot + ">"); Log.LogMessageFromResources(SRID.CommentFileGenerated, _outputFile); } } catch (Exception e) { // PreSharp Complaint 6500 - do not handle null-ref or SEH exceptions. if (e is NullReferenceException || e is SEHException) { throw; } else { Log.LogErrorFromException(e); return false; } } #pragma warning disable 6500 catch // Non-CLS compliant errors { Log.LogErrorWithCodeFromResources(SRID.NonClsError); return false; } #pragma warning restore 6500 } return true; } //-------------------------------- // Public properties //-------------------------------- ////// The list of localization directives files for individual Bamls. /// [Required] public ITaskItem[] GeneratedLocalizationFiles { get { return _generatedLocalizationFiles; } set { _generatedLocalizationFiles = value; } } ////// The output path of the compiled assembly /// [Required] [Output] public string OutputFile { get { return _outputFile; } set { _outputFile = value; } } //--------------------------------- // Private members //--------------------------------- private ITaskItem[] _generatedLocalizationFiles; private string _outputFile; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: The task that merges all the localization directives files // // History: // 06/15/2005 garyyang - created // //--------------------------------------------------------------------------- using System; using System.IO; using System.Text; using System.Xml; using System.Runtime.InteropServices; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using MS.Internal.Globalization; using MS.Internal.Tasks; using MS.Utility; // For SR // Since we disable PreSharp warnings in this file, we first need to disable warnings // about unknown message numbers and unknown pragmas. #pragma warning disable 1634, 1691 namespace Microsoft.Build.Tasks.Windows { ////// This task merges the localization directives files of single bamls /// into one file corresponding to for the compiled assembly. /// public sealed class MergeLocalizationDirectives : Task { //-------------------------------- // Constructor //-------------------------------- ////// Default constructor of the task /// public MergeLocalizationDirectives() : base(SR.ResourceManager) { } //-------------------------------- // Public methods //-------------------------------- ////// Method invoked by MSBuild to merge localization files of single bamls to /// one file for the whole Assembly. /// public override bool Execute() { TaskHelper.DisplayLogo(Log, SR.Get(SRID.MergeLocalizationDirectivesTask)); if (GeneratedLocalizationFiles.Length > 0) { try { string absoluteFilePath = Path.Combine( Directory.GetCurrentDirectory(), _outputFile ); using (StreamWriter streamWriter = new StreamWriter( new FileStream(absoluteFilePath, FileMode.Create), new UTF8Encoding(true) ) ) { Log.LogMessageFromResources(SRID.CommentFileGenerating, _outputFile); streamWriter.WriteLine("<" + LocComments.LocDocumentRoot + ">"); // keey things simple and fast. Just keep appending the // xml fragments that are already outputed. foreach (ITaskItem item in GeneratedLocalizationFiles) { using (StreamReader locStreamReader = new StreamReader(item.ItemSpec)) { // directly concat Xml fragments streamWriter.WriteLine(locStreamReader.ReadToEnd()); } } streamWriter.WriteLine("" + LocComments.LocDocumentRoot + ">"); Log.LogMessageFromResources(SRID.CommentFileGenerated, _outputFile); } } catch (Exception e) { // PreSharp Complaint 6500 - do not handle null-ref or SEH exceptions. if (e is NullReferenceException || e is SEHException) { throw; } else { Log.LogErrorFromException(e); return false; } } #pragma warning disable 6500 catch // Non-CLS compliant errors { Log.LogErrorWithCodeFromResources(SRID.NonClsError); return false; } #pragma warning restore 6500 } return true; } //-------------------------------- // Public properties //-------------------------------- ////// The list of localization directives files for individual Bamls. /// [Required] public ITaskItem[] GeneratedLocalizationFiles { get { return _generatedLocalizationFiles; } set { _generatedLocalizationFiles = value; } } ////// The output path of the compiled assembly /// [Required] [Output] public string OutputFile { get { return _outputFile; } set { _outputFile = value; } } //--------------------------------- // Private members //--------------------------------- private ITaskItem[] _generatedLocalizationFiles; private string _outputFile; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewRowDividerDoubleClickEventArgs.cs
- AuthenticatingEventArgs.cs
- OutputScope.cs
- ExponentialEase.cs
- SoapSchemaExporter.cs
- AnchorEditor.cs
- SamlConditions.cs
- XmlDataFileEditor.cs
- TreePrinter.cs
- MenuAdapter.cs
- QilIterator.cs
- ListView.cs
- MenuItem.cs
- RemoteWebConfigurationHostStream.cs
- PerformanceCounterCategory.cs
- ShutDownListener.cs
- CompilationUnit.cs
- XmlSerializationGeneratedCode.cs
- ComboBoxAutomationPeer.cs
- EntityClientCacheKey.cs
- Parameter.cs
- XmlEncoding.cs
- HttpApplication.cs
- ConfigXmlElement.cs
- QuaternionRotation3D.cs
- Activator.cs
- UpdateCommandGenerator.cs
- PropertyReference.cs
- StatusBarAutomationPeer.cs
- Console.cs
- ListViewInsertionMark.cs
- LineBreak.cs
- LZCodec.cs
- EditCommandColumn.cs
- ObjectStateFormatter.cs
- NamespaceQuery.cs
- SingleConverter.cs
- TreeNodeBinding.cs
- XmlHierarchicalDataSourceView.cs
- DataGridViewLinkColumn.cs
- GPStream.cs
- OwnerDrawPropertyBag.cs
- MappingMetadataHelper.cs
- ArgumentNullException.cs
- GridSplitterAutomationPeer.cs
- SQLSingle.cs
- CLSCompliantAttribute.cs
- StreamInfo.cs
- Instrumentation.cs
- LockRecoveryTask.cs
- COM2ColorConverter.cs
- MailBnfHelper.cs
- TreeView.cs
- BaseDataBoundControl.cs
- ping.cs
- InputMethodStateTypeInfo.cs
- ToolBar.cs
- SmiTypedGetterSetter.cs
- Point3DAnimationBase.cs
- ItemCollection.cs
- DialogResultConverter.cs
- InternalResources.cs
- DayRenderEvent.cs
- ColumnHeaderConverter.cs
- RelAssertionDirectKeyIdentifierClause.cs
- PreservationFileReader.cs
- Int64Converter.cs
- XmlSchemaCollection.cs
- AssociatedControlConverter.cs
- WindowsToolbar.cs
- Number.cs
- AutomationProperties.cs
- Knowncolors.cs
- TabOrder.cs
- WindowsScrollBar.cs
- CreateUserErrorEventArgs.cs
- DefaultClaimSet.cs
- Codec.cs
- BlurEffect.cs
- EventRoute.cs
- PropertyGroupDescription.cs
- HtmlGenericControl.cs
- TimeSpanSecondsConverter.cs
- GenericsInstances.cs
- Vector3D.cs
- RegexInterpreter.cs
- ObjectStorage.cs
- AccessDataSourceDesigner.cs
- TcpActivation.cs
- MatrixCamera.cs
- MultiAsyncResult.cs
- EdmConstants.cs
- SystemPens.cs
- ChtmlTextWriter.cs
- WebPartMovingEventArgs.cs
- InputReportEventArgs.cs
- CultureInfo.cs
- Marshal.cs
- BitmapEffectState.cs
- TextRangeEdit.cs