Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / BuildTasks / Microsoft / Build / Tasks / Windows / MergeLocalizationDirectives.cs / 1 / 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
- ListControl.cs
- StreamMarshaler.cs
- DocumentPageView.cs
- CommandHelpers.cs
- _NativeSSPI.cs
- SettingsPropertyValueCollection.cs
- PrimitiveCodeDomSerializer.cs
- x509store.cs
- DataGridViewHitTestInfo.cs
- NavigationPropertyEmitter.cs
- Keywords.cs
- SqlColumnizer.cs
- Property.cs
- InstallerTypeAttribute.cs
- RawKeyboardInputReport.cs
- FilteredReadOnlyMetadataCollection.cs
- FtpRequestCacheValidator.cs
- JapaneseLunisolarCalendar.cs
- InputProcessorProfiles.cs
- RawStylusInputCustomData.cs
- LayeredChannelListener.cs
- SettingsPropertyValue.cs
- TextBoxAutomationPeer.cs
- __FastResourceComparer.cs
- TrackingCondition.cs
- WebPartConnectionsConnectVerb.cs
- ObjectHelper.cs
- BinaryWriter.cs
- OpenFileDialog.cs
- PropertyMapper.cs
- DataGridViewSelectedCellCollection.cs
- MultiPartWriter.cs
- DataGridViewRowPrePaintEventArgs.cs
- SqlGatherProducedAliases.cs
- GraphicsState.cs
- RegisteredScript.cs
- SystemIPv6InterfaceProperties.cs
- SocketException.cs
- ImagingCache.cs
- MimeBasePart.cs
- __ComObject.cs
- Input.cs
- PackageProperties.cs
- Empty.cs
- TreeNodeMouseHoverEvent.cs
- followingsibling.cs
- DataServiceRequest.cs
- RayMeshGeometry3DHitTestResult.cs
- MissingFieldException.cs
- Rijndael.cs
- ClusterRegistryConfigurationProvider.cs
- Permission.cs
- VirtualDirectoryMappingCollection.cs
- TerminatingOperationBehavior.cs
- EntityDataSourceColumn.cs
- ChainOfDependencies.cs
- ContentValidator.cs
- DesignTimeVisibleAttribute.cs
- WebBrowserContainer.cs
- EventProperty.cs
- DataBindingHandlerAttribute.cs
- ColorConvertedBitmap.cs
- AdornedElementPlaceholder.cs
- NamespaceList.cs
- contentDescriptor.cs
- StubHelpers.cs
- CompilerGlobalScopeAttribute.cs
- X509ChainPolicy.cs
- DataGridViewCellStyle.cs
- ResourceSet.cs
- ObjectSet.cs
- WebPartChrome.cs
- ResolveNameEventArgs.cs
- Point4D.cs
- OdbcPermission.cs
- BufferModesCollection.cs
- AggregateNode.cs
- GrammarBuilderRuleRef.cs
- ToolStripDropDownMenu.cs
- OutputScope.cs
- FontFamilyConverter.cs
- ExpressionVisitorHelpers.cs
- X509UI.cs
- CancellationToken.cs
- WaitHandleCannotBeOpenedException.cs
- XsltArgumentList.cs
- ApplicationServiceHelper.cs
- BindingGraph.cs
- GlyphManager.cs
- TaskFileService.cs
- Base64Encoding.cs
- DebugView.cs
- clipboard.cs
- RelationshipEntry.cs
- HistoryEventArgs.cs
- ComponentEvent.cs
- ProxyElement.cs
- TextLineBreak.cs
- MetadataElement.cs
- LiteralText.cs