Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- TextEditorThreadLocalStore.cs
- DataGridViewElement.cs
- OutgoingWebRequestContext.cs
- UnitySerializationHolder.cs
- InternalMappingException.cs
- PreviewPageInfo.cs
- ObjectStateFormatter.cs
- SqlFlattener.cs
- OracleDataAdapter.cs
- VisualBrush.cs
- FacetChecker.cs
- PickBranchDesigner.xaml.cs
- TaskFileService.cs
- FormatConvertedBitmap.cs
- MimeParameter.cs
- QilPatternVisitor.cs
- BinaryConverter.cs
- DbDataAdapter.cs
- User.cs
- SessionEndingCancelEventArgs.cs
- WebReference.cs
- RegistrationServices.cs
- Transform3DGroup.cs
- SchemaMapping.cs
- MultiByteCodec.cs
- WinInet.cs
- XmlName.cs
- DynamicArgumentDesigner.xaml.cs
- XmlnsCache.cs
- VirtualizingStackPanel.cs
- NativeMethods.cs
- WindowAutomationPeer.cs
- OciHandle.cs
- _SslState.cs
- TriggerCollection.cs
- _Semaphore.cs
- MarkupCompilePass2.cs
- OleDbStruct.cs
- TextElementCollectionHelper.cs
- PropertyMapper.cs
- FormParameter.cs
- WebPartUtil.cs
- SourceFileInfo.cs
- DesignerTextWriter.cs
- DbCommandTree.cs
- RichTextBoxConstants.cs
- SafePEFileHandle.cs
- ButtonChrome.cs
- DbParameterHelper.cs
- ChtmlTextWriter.cs
- TextPattern.cs
- HtmlTernaryTree.cs
- AppearanceEditorPart.cs
- NonSerializedAttribute.cs
- SmtpReplyReaderFactory.cs
- StringAnimationUsingKeyFrames.cs
- ArrayList.cs
- AttachedPropertyMethodSelector.cs
- WindowsGrip.cs
- PackUriHelper.cs
- Attributes.cs
- MethodToken.cs
- MergeFilterQuery.cs
- ParameterElementCollection.cs
- GuidelineSet.cs
- DynamicILGenerator.cs
- FieldNameLookup.cs
- ArraySortHelper.cs
- Permission.cs
- Page.cs
- MailSettingsSection.cs
- ParallelTimeline.cs
- QueryResult.cs
- D3DImage.cs
- ControlType.cs
- assemblycache.cs
- RoleManagerModule.cs
- DateTimeConverter.cs
- CardSpacePolicyElement.cs
- ObjectTag.cs
- SqlCachedBuffer.cs
- CompilerInfo.cs
- FileDialogCustomPlace.cs
- TraceHandlerErrorFormatter.cs
- WindowsListBox.cs
- ColorTranslator.cs
- _Win32.cs
- ServiceThrottle.cs
- SudsWriter.cs
- ProgressPage.cs
- HWStack.cs
- ObjectDataSource.cs
- PackageStore.cs
- WebConfigurationFileMap.cs
- DateTimeOffset.cs
- QueryOptionExpression.cs
- QilChoice.cs
- URIFormatException.cs
- Size.cs
- ParseChildrenAsPropertiesAttribute.cs