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 / UpdateManifestForBrowserApplication.cs / 1 / UpdateManifestForBrowserApplication.cs
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// UpdateManifestForBrowserApplication.cs
//
// Update application manifest for browser-hosted application.
//
// spec: http://avalon/app/Compilation/Avalon-MSBUILD%20Tasks.doc
//
// vivekd Created 06/17/2004
// weibz update and cleanup 06/10/2005
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Build.Tasks;
using System.Xml;
using System.Xml.XPath;
using Microsoft.Build.Tasks.Windows;
using System.Collections;
using MS.Utility;
using MS.Internal.Tasks;
// Since we disable PreSharp warnings in this file, PreSharp warning is unknown to C# compiler.
// We first need to disable warnings about unknown message numbers and unknown pragmas.
#pragma warning disable 1634, 1691
namespace Microsoft.Build.Tasks.Windows
{
#region Manifest Creator Task class
///
/// Class of UpdateManifestForBrowserApplication
///
public sealed class UpdateManifestForBrowserApplication : Task
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructors
///
public UpdateManifestForBrowserApplication()
: base(SR.ResourceManager)
{
}
#endregion Constructors
//-----------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Add hostInBrowser element node to the application manifest file.
///
///
public override bool Execute()
{
bool successful = true;
TaskHelper.DisplayLogo(Log, SR.Get(SRID.UpdateManifestForBrowserApplicationTask));
if (HostInBrowser != true)
{
// HostInBrowser is not true, don't modify the manifest.
// Stop here.
return successful;
}
try
{
string appManifestFile = ApplicationManifest[0].ItemSpec;
XmlDocument manifestDocument;
XmlTextReader manifestReader = null;
XmlTextWriter manifestWriter = null;
//Read the manifest
try
{
manifestReader = new XmlTextReader(appManifestFile);
manifestDocument = new XmlDocument();
manifestDocument.Load(manifestReader);
}
finally
{
if (manifestReader != null)
{
// Close the manifest reader
manifestReader.Close();
}
}
// NOTE:
//
// manifestReader must be closed before the manfiestWriter can
// update the document on the same manifest file.
//
//Get to entryPoint XML
XmlNodeList entryPointList = manifestDocument.GetElementsByTagName(c_entryPoint);
XmlNode entryPoint = entryPointList[0];
//Create element node for browser entry point
XmlElement hostInBrowser;
hostInBrowser = manifestDocument.CreateElement(c_hostInBrowser, c_asmv3);
// Append HostInBrowser node to the end of list of children of entryPoint.
entryPoint.AppendChild(hostInBrowser);
// Update the manifest file.
try
{
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8);
manifestWriter.Formatting = Formatting.Indented;
manifestWriter.Indentation = 4;
manifestDocument.WriteTo(manifestWriter);
}
finally
{
if (manifestWriter != null)
{
// Close the manifest writer
manifestWriter.Close();
}
}
}
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);
successful = false;
}
}
#pragma warning disable 6500
catch // Non-cls compliant errors
{
Log.LogErrorWithCodeFromResources(SRID.NonClsError);
successful = false;
}
#pragma warning restore 6500
return successful;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Host In Browser
///
///
[Required]
public bool HostInBrowser
{
get { return _hostInBrowser; }
set
{
_hostInBrowser = value;
}
}
///
/// Application Manifest File
///
///
[Required]
public ITaskItem[] ApplicationManifest
{
get { return _applicationmanifest; }
set { _applicationmanifest = value; }
}
#endregion Public Properties
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private ITaskItem[] _applicationmanifest;
private bool _hostInBrowser = false;
//
// Put some predefined element or attribute name in below
// const strings.
//
private const string c_entryPoint = "entryPoint";
private const string c_hostInBrowser ="hostInBrowser";
private const string c_asmv3= "urn:schemas-microsoft-com:asm.v3";
#endregion Private Fields
}
#endregion Manifest Creator Task class
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// UpdateManifestForBrowserApplication.cs
//
// Update application manifest for browser-hosted application.
//
// spec: http://avalon/app/Compilation/Avalon-MSBUILD%20Tasks.doc
//
// vivekd Created 06/17/2004
// weibz update and cleanup 06/10/2005
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Build.Tasks;
using System.Xml;
using System.Xml.XPath;
using Microsoft.Build.Tasks.Windows;
using System.Collections;
using MS.Utility;
using MS.Internal.Tasks;
// Since we disable PreSharp warnings in this file, PreSharp warning is unknown to C# compiler.
// We first need to disable warnings about unknown message numbers and unknown pragmas.
#pragma warning disable 1634, 1691
namespace Microsoft.Build.Tasks.Windows
{
#region Manifest Creator Task class
///
/// Class of UpdateManifestForBrowserApplication
///
public sealed class UpdateManifestForBrowserApplication : Task
{
//------------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructors
///
public UpdateManifestForBrowserApplication()
: base(SR.ResourceManager)
{
}
#endregion Constructors
//-----------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Add hostInBrowser element node to the application manifest file.
///
///
public override bool Execute()
{
bool successful = true;
TaskHelper.DisplayLogo(Log, SR.Get(SRID.UpdateManifestForBrowserApplicationTask));
if (HostInBrowser != true)
{
// HostInBrowser is not true, don't modify the manifest.
// Stop here.
return successful;
}
try
{
string appManifestFile = ApplicationManifest[0].ItemSpec;
XmlDocument manifestDocument;
XmlTextReader manifestReader = null;
XmlTextWriter manifestWriter = null;
//Read the manifest
try
{
manifestReader = new XmlTextReader(appManifestFile);
manifestDocument = new XmlDocument();
manifestDocument.Load(manifestReader);
}
finally
{
if (manifestReader != null)
{
// Close the manifest reader
manifestReader.Close();
}
}
// NOTE:
//
// manifestReader must be closed before the manfiestWriter can
// update the document on the same manifest file.
//
//Get to entryPoint XML
XmlNodeList entryPointList = manifestDocument.GetElementsByTagName(c_entryPoint);
XmlNode entryPoint = entryPointList[0];
//Create element node for browser entry point
XmlElement hostInBrowser;
hostInBrowser = manifestDocument.CreateElement(c_hostInBrowser, c_asmv3);
// Append HostInBrowser node to the end of list of children of entryPoint.
entryPoint.AppendChild(hostInBrowser);
// Update the manifest file.
try
{
manifestWriter = new XmlTextWriter(appManifestFile, System.Text.Encoding.UTF8);
manifestWriter.Formatting = Formatting.Indented;
manifestWriter.Indentation = 4;
manifestDocument.WriteTo(manifestWriter);
}
finally
{
if (manifestWriter != null)
{
// Close the manifest writer
manifestWriter.Close();
}
}
}
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);
successful = false;
}
}
#pragma warning disable 6500
catch // Non-cls compliant errors
{
Log.LogErrorWithCodeFromResources(SRID.NonClsError);
successful = false;
}
#pragma warning restore 6500
return successful;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Host In Browser
///
///
[Required]
public bool HostInBrowser
{
get { return _hostInBrowser; }
set
{
_hostInBrowser = value;
}
}
///
/// Application Manifest File
///
///
[Required]
public ITaskItem[] ApplicationManifest
{
get { return _applicationmanifest; }
set { _applicationmanifest = value; }
}
#endregion Public Properties
//------------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private ITaskItem[] _applicationmanifest;
private bool _hostInBrowser = false;
//
// Put some predefined element or attribute name in below
// const strings.
//
private const string c_entryPoint = "entryPoint";
private const string c_hostInBrowser ="hostInBrowser";
private const string c_asmv3= "urn:schemas-microsoft-com:asm.v3";
#endregion Private Fields
}
#endregion Manifest Creator Task class
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PropertyConverter.cs
- ControlAdapter.cs
- InputLanguageManager.cs
- TrackingProfile.cs
- SessionEndingEventArgs.cs
- HandlerFactoryCache.cs
- Error.cs
- TransformGroup.cs
- XmlSerializerSection.cs
- GridView.cs
- SqlDependencyUtils.cs
- SoapTypeAttribute.cs
- ComponentSerializationService.cs
- TreeViewImageKeyConverter.cs
- NonVisualControlAttribute.cs
- NumericUpDown.cs
- XmlSerializerFormatAttribute.cs
- DummyDataSource.cs
- FunctionNode.cs
- OpenTypeLayout.cs
- MemoryMappedFileSecurity.cs
- Constraint.cs
- EnumMember.cs
- SafeFileMappingHandle.cs
- RemoteWebConfigurationHost.cs
- DateRangeEvent.cs
- JoinGraph.cs
- ApplicationBuildProvider.cs
- FlowDocument.cs
- BitStream.cs
- MenuCommand.cs
- SelectionEditor.cs
- CookieParameter.cs
- AutoFocusStyle.xaml.cs
- RSAPKCS1SignatureFormatter.cs
- AssociationSetMetadata.cs
- TargetFrameworkAttribute.cs
- SystemDiagnosticsSection.cs
- ColorMatrix.cs
- TableItemStyle.cs
- ObjectDataSourceStatusEventArgs.cs
- SQLInt64Storage.cs
- ReturnValue.cs
- HttpCapabilitiesBase.cs
- SingleTagSectionHandler.cs
- InstanceKeyView.cs
- ToolStripItemDataObject.cs
- MdiWindowListItemConverter.cs
- SizeChangedEventArgs.cs
- Gdiplus.cs
- TextureBrush.cs
- ComplexObject.cs
- COM2PictureConverter.cs
- BinaryMessageEncodingBindingElement.cs
- Viewport2DVisual3D.cs
- StartUpEventArgs.cs
- AspNetSynchronizationContext.cs
- CustomAttributeSerializer.cs
- X509SecurityToken.cs
- DbConnectionPool.cs
- ObjectQuery_EntitySqlExtensions.cs
- EncoderBestFitFallback.cs
- FormsAuthenticationUserCollection.cs
- Viewport2DVisual3D.cs
- securitycriticaldataClass.cs
- NameValueSectionHandler.cs
- SmiSettersStream.cs
- CommunicationObjectManager.cs
- ProtocolState.cs
- FileSystemWatcher.cs
- Point3D.cs
- DataException.cs
- LineBreak.cs
- DoubleCollectionValueSerializer.cs
- EventsTab.cs
- TextChangedEventArgs.cs
- StylusPlugInCollection.cs
- RestClientProxyHandler.cs
- DecimalAnimationBase.cs
- DateTimeConverter.cs
- CollaborationHelperFunctions.cs
- Rect3D.cs
- ValueExpressions.cs
- XmlFormatWriterGenerator.cs
- XamlTypeMapper.cs
- JavaScriptObjectDeserializer.cs
- AmbientValueAttribute.cs
- SoapIncludeAttribute.cs
- XamlStream.cs
- EntityDataSourceDesignerHelper.cs
- RealizationContext.cs
- TdsParserSessionPool.cs
- WaitHandle.cs
- Int32CAMarshaler.cs
- _FtpDataStream.cs
- Crc32Helper.cs
- EdmComplexPropertyAttribute.cs
- DecoderFallback.cs
- OleAutBinder.cs
- HelpPage.cs