Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / Entity / Design / AspNet / BuildProviderUtils.cs / 1305376 / BuildProviderUtils.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Web;
using System.Web.Compilation;
using System.Web.Hosting;
namespace System.Data.Entity.Design.AspNet
{
///
/// A place to put common methods used by our build providers
///
///
internal class BuildProviderUtils
{
///
/// Default constructor
///
private BuildProviderUtils()
{
}
internal static void AddArtifactReference(AssemblyBuilder assemblyBuilder, BuildProvider prov, string virtualPath)
{
// add the artifact as a resource to the DLL
using (Stream input = VirtualPathProvider.OpenFile(virtualPath))
{
// derive the resource name
string name = BuildProviderUtils.GetResourceNameForVirtualPath(virtualPath);
using (Stream resStream = assemblyBuilder.CreateEmbeddedResource(prov, name))
{
int byteRead = input.ReadByte();
while (byteRead != -1)
{
resStream.WriteByte((byte)byteRead);
byteRead = input.ReadByte();
}
}
}
}
///
/// Transforms a virtual path string into a valid resource name.
///
///
///
internal static string GetResourceNameForVirtualPath(string virtualPath)
{
string name = VirtualPathUtility.ToAppRelative(virtualPath);
Debug.Assert(name.StartsWith("~/"), "Expected app-relative path to start with ~/");
if (name.StartsWith("~/", StringComparison.OrdinalIgnoreCase))
{
name = name.Substring(2);
}
name = name.Replace("/", ".");
Debug.Assert(name.StartsWith(".") == false, "resource name unexpectedly starts with .");
return name;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Web;
using System.Web.Compilation;
using System.Web.Hosting;
namespace System.Data.Entity.Design.AspNet
{
///
/// A place to put common methods used by our build providers
///
///
internal class BuildProviderUtils
{
///
/// Default constructor
///
private BuildProviderUtils()
{
}
internal static void AddArtifactReference(AssemblyBuilder assemblyBuilder, BuildProvider prov, string virtualPath)
{
// add the artifact as a resource to the DLL
using (Stream input = VirtualPathProvider.OpenFile(virtualPath))
{
// derive the resource name
string name = BuildProviderUtils.GetResourceNameForVirtualPath(virtualPath);
using (Stream resStream = assemblyBuilder.CreateEmbeddedResource(prov, name))
{
int byteRead = input.ReadByte();
while (byteRead != -1)
{
resStream.WriteByte((byte)byteRead);
byteRead = input.ReadByte();
}
}
}
}
///
/// Transforms a virtual path string into a valid resource name.
///
///
///
internal static string GetResourceNameForVirtualPath(string virtualPath)
{
string name = VirtualPathUtility.ToAppRelative(virtualPath);
Debug.Assert(name.StartsWith("~/"), "Expected app-relative path to start with ~/");
if (name.StartsWith("~/", StringComparison.OrdinalIgnoreCase))
{
name = name.Substring(2);
}
name = name.Replace("/", ".");
Debug.Assert(name.StartsWith(".") == false, "resource name unexpectedly starts with .");
return name;
}
}
}
// 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
- EventLogEntryCollection.cs
- sqlstateclientmanager.cs
- ShapeTypeface.cs
- PermissionRequestEvidence.cs
- EnumDataContract.cs
- __Error.cs
- ActivityCompletionCallbackWrapper.cs
- CheckPair.cs
- SimpleTypeResolver.cs
- PathFigureCollection.cs
- CheckedPointers.cs
- EndpointDesigner.cs
- TransformerConfigurationWizardBase.cs
- ListViewHitTestInfo.cs
- SafeReadContext.cs
- DataShape.cs
- TreeNodeClickEventArgs.cs
- DrawingContextDrawingContextWalker.cs
- QuadraticBezierSegment.cs
- RegionInfo.cs
- Triplet.cs
- CharUnicodeInfo.cs
- RegexCaptureCollection.cs
- TraceContext.cs
- DNS.cs
- XmlHierarchicalDataSourceView.cs
- TextContainer.cs
- GlobalizationAssembly.cs
- TcpProcessProtocolHandler.cs
- CounterSample.cs
- XmlTextReaderImplHelpers.cs
- CreatingCookieEventArgs.cs
- Line.cs
- CalendarDayButton.cs
- MultiAsyncResult.cs
- EqualityArray.cs
- CodeDomSerializerBase.cs
- XmlSchema.cs
- DataSourceBooleanViewSchemaConverter.cs
- NumberSubstitution.cs
- SwitchElementsCollection.cs
- UpWmlMobileTextWriter.cs
- MenuAdapter.cs
- ProcessHostMapPath.cs
- BeginGetFileNameFromUserRequest.cs
- CustomAttribute.cs
- CommonDialog.cs
- ToolTipService.cs
- MetadataPropertyAttribute.cs
- OrthographicCamera.cs
- KeyTimeConverter.cs
- ValidatorCompatibilityHelper.cs
- CallbackTimeoutsBehavior.cs
- FileDialogPermission.cs
- ThreadPool.cs
- RunWorkerCompletedEventArgs.cs
- CodeCompileUnit.cs
- MatrixTransform.cs
- RTLAwareMessageBox.cs
- FileNameEditor.cs
- RbTree.cs
- InternalRelationshipCollection.cs
- ObjectIDGenerator.cs
- AsyncOperation.cs
- ConsumerConnectionPoint.cs
- WebOperationContext.cs
- RIPEMD160.cs
- DataGridColumn.cs
- RectConverter.cs
- ProviderUtil.cs
- FileUtil.cs
- ContentControl.cs
- Memoizer.cs
- NamespaceMapping.cs
- UnionExpr.cs
- LazyTextWriterCreator.cs
- DiscardableAttribute.cs
- Renderer.cs
- WebConfigurationManager.cs
- AppDomainUnloadedException.cs
- SspiNegotiationTokenProviderState.cs
- MD5.cs
- Thickness.cs
- NativeMethods.cs
- SystemWebExtensionsSectionGroup.cs
- DiagnosticStrings.cs
- ConfigXmlText.cs
- WebResponse.cs
- EncodingInfo.cs
- HttpResponseWrapper.cs
- FullTrustAssembly.cs
- MetadataHelper.cs
- RegistrationServices.cs
- SubtreeProcessor.cs
- DateTimeParse.cs
- TemplateLookupAction.cs
- DataSourceViewSchemaConverter.cs
- ConditionValidator.cs
- ConfigurationLockCollection.cs
- MainMenu.cs