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
- SqlIdentifier.cs
- StrongName.cs
- CalendarTable.cs
- HandlerFactoryWrapper.cs
- StringPropertyBuilder.cs
- KeyedHashAlgorithm.cs
- SqlConnectionPoolProviderInfo.cs
- UrlPath.cs
- StorageEntityTypeMapping.cs
- ScaleTransform3D.cs
- ComplexObject.cs
- ProtocolsConfigurationEntry.cs
- SecurityPermission.cs
- FileSecurity.cs
- MemberMaps.cs
- TextWriterTraceListener.cs
- ClientScriptManagerWrapper.cs
- SymbolTable.cs
- SchemaImporter.cs
- TraceSwitch.cs
- HttpDigestClientElement.cs
- Handle.cs
- MiniAssembly.cs
- ClientTarget.cs
- Action.cs
- BrushValueSerializer.cs
- indexingfiltermarshaler.cs
- XmlLanguageConverter.cs
- XmlIlVisitor.cs
- ReadWriteControlDesigner.cs
- GeneralTransform.cs
- TimeSpanOrInfiniteConverter.cs
- GridItemPatternIdentifiers.cs
- ServerValidateEventArgs.cs
- TcpServerChannel.cs
- InputQueueChannel.cs
- CodeDomSerializationProvider.cs
- _NegotiateClient.cs
- NetMsmqSecurity.cs
- MatrixUtil.cs
- EntityDataSourceChangingEventArgs.cs
- BreakRecordTable.cs
- SQLDoubleStorage.cs
- DataGridViewLayoutData.cs
- RegexMatchCollection.cs
- StringValidator.cs
- QilReplaceVisitor.cs
- ExpressionBindings.cs
- Point3DIndependentAnimationStorage.cs
- DeviceContext2.cs
- WebBrowserNavigatingEventHandler.cs
- InternalBase.cs
- ParserHooks.cs
- FacetDescriptionElement.cs
- CompoundFileDeflateTransform.cs
- QueryAccessibilityHelpEvent.cs
- XPathNodeHelper.cs
- ProfileBuildProvider.cs
- LogRestartAreaEnumerator.cs
- SqlDataAdapter.cs
- SafeSecurityHandles.cs
- AnnotationHighlightLayer.cs
- HttpTransportSecurityElement.cs
- ManagementOperationWatcher.cs
- GetTokenRequest.cs
- HttpModulesSection.cs
- FormViewUpdatedEventArgs.cs
- ScopelessEnumAttribute.cs
- ProtocolsConfigurationHandler.cs
- HashRepartitionEnumerator.cs
- DoubleKeyFrameCollection.cs
- RowBinding.cs
- DocumentCollection.cs
- PeerResolverMode.cs
- MethodSet.cs
- GradientStop.cs
- IApplicationTrustManager.cs
- NonVisualControlAttribute.cs
- StyleSheet.cs
- LayoutDump.cs
- CounterCreationData.cs
- ByteFacetDescriptionElement.cs
- OledbConnectionStringbuilder.cs
- AttachmentService.cs
- XdrBuilder.cs
- PointKeyFrameCollection.cs
- ProviderConnectionPoint.cs
- DataColumn.cs
- TraceRecord.cs
- RuleSettingsCollection.cs
- CompModSwitches.cs
- ScrollBar.cs
- NativeMethods.cs
- ExternalException.cs
- ByteRangeDownloader.cs
- InputReferenceExpression.cs
- IListConverters.cs
- bidPrivateBase.cs
- _ContextAwareResult.cs
- XmlSchemaProviderAttribute.cs