本文整理汇总了C#中System.Web.Compilation.AssemblyBuilder.CreateEmbeddedResource方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.CreateEmbeddedResource方法的具体用法?C# AssemblyBuilder.CreateEmbeddedResource怎么用?C# AssemblyBuilder.CreateEmbeddedResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Compilation.AssemblyBuilder
的用法示例。
在下文中一共展示了AssemblyBuilder.CreateEmbeddedResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCode
public override void GenerateCode (AssemblyBuilder assemblyBuilder)
{
base.GenerateCode (assemblyBuilder);
SchematronParser schParser = (SchematronParser)this.Parser;
IXsltProcessor proc = Processors.Xslt [schParser.ProcessorName];
IXPathNavigable schemaDoc;
using (TextReader textReader = OpenReader())
schemaDoc = proc.ItemFactory.CreateNodeReadOnly (textReader, new XmlParsingOptions { BaseUri = this.PhysicalPath });
Stream resourceStream;
try {
resourceStream = assemblyBuilder.CreateEmbeddedResource (this, this.ValidatorUri.AbsolutePath);
} catch (ArgumentException) {
throw CreateCompileException (String.Format (CultureInfo.InvariantCulture, "There is already another type generated with the name '{0}'.", this.GeneratedTypeFullName));
}
using (resourceStream) {
using (MemoryStream copyStream = new MemoryStream()) {
try {
using (XmlWriter writer = XmlWriter.Create(copyStream))
proc.BuildSchematronValidatorStylesheet (schemaDoc, writer);
} catch (ProcessorException ex) {
throw CreateCompileException (ex);
}
copyStream.Position = 0;
copyStream.WriteTo (resourceStream);
// test compilation
copyStream.Position = 0;
try {
proc.Compile (copyStream, new XsltCompileOptions { BaseUri = this.PhysicalPath });
} catch (ProcessorException ex) {
throw CreateCompileException (ex);
}
}
}
}
示例2: AddArtifactReference
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();
}
}
}
}
示例3: SetupEmbeddedResource
private static void SetupEmbeddedResource(AssemblyBuilder assemblyBuilder,
BuildProvider prov, XmlElement xmlElement, string resourceName)
{
using (Stream resStream = assemblyBuilder.CreateEmbeddedResource(prov, resourceName))
{
EntityDesignerUtils.OutputXmlElementToStream(xmlElement, resStream);
}
}
示例4: GenerateResourceFile
private void GenerateResourceFile(AssemblyBuilder assemblyBuilder, IResourceReader reader) {
// Get the name of the generated .resource file
string resourceFileName;
if (_ns == null) {
// In the case where we don't generate code, just name the resource file
// after the virtual file
resourceFileName = UrlPath.GetFileNameWithoutExtension(VirtualPath) + ".resources";
}
else if (_cultureName == null) {
// Name the resource file after the generated class, since that's what the
// generated class expects
resourceFileName = _ns + "." + _typeName + ".resources";
}
else {
// If it's a non-default resource, include the culture in the name
resourceFileName = _ns + "." + _typeName + "." + _cultureName + ".resources";
}
// Make it lower case, since GetManifestResourceStream (which we use later on) is
// case sensitive
resourceFileName = resourceFileName.ToLower(CultureInfo.InvariantCulture);
Stream outputStream = null;
try {
try {
try {
}
finally {
// Put the assignment in a finally block to avoid a ThreadAbortException from
// causing the created stream to not get assigned and become leaked (Dev10 bug 844463)
outputStream = assemblyBuilder.CreateEmbeddedResource(this, resourceFileName);
}
}
catch (ArgumentException) {
// This throws an ArgumentException if the resource file name was already added.
// Catch the situation, and give a better error message (VSWhidbey 87110)
throw new HttpException(SR.GetString(SR.Duplicate_Resource_File, VirtualPath));
}
// Create an output stream from the .resource file
using (outputStream) {
using (ResourceWriter writer = new ResourceWriter(outputStream)) {
// Enable resource writer to be target-aware
writer.TypeNameConverter = System.Web.UI.TargetFrameworkUtil.TypeNameConverter;
// Copy the resources
foreach (DictionaryEntry de in reader) {
writer.AddResource((string)de.Key, de.Value);
}
}
}
}
finally {
// Always close the stream to avoid a ThreadAbortException from causing the stream
// to be leaked (Dev10 bug 844463)
if (outputStream != null) {
outputStream.Close();
}
}
}
示例5: GenerateResourceFile
private void GenerateResourceFile(AssemblyBuilder assemblyBuilder, IResourceReader reader)
{
string str;
if (this._ns == null)
{
str = UrlPath.GetFileNameWithoutExtension(base.VirtualPath) + ".resources";
}
else if (this._cultureName == null)
{
str = this._ns + "." + this._typeName + ".resources";
}
else
{
str = this._ns + "." + this._typeName + "." + this._cultureName + ".resources";
}
str = str.ToLower(CultureInfo.InvariantCulture);
Stream stream = null;
try
{
try
{
try
{
}
finally
{
stream = assemblyBuilder.CreateEmbeddedResource(this, str);
}
}
catch (ArgumentException)
{
throw new HttpException(System.Web.SR.GetString("Duplicate_Resource_File", new object[] { base.VirtualPath }));
}
using (stream)
{
using (ResourceWriter writer = new ResourceWriter(stream))
{
writer.TypeNameConverter = new Func<Type, string>(TargetFrameworkUtil.TypeNameConverter);
foreach (DictionaryEntry entry in reader)
{
writer.AddResource((string) entry.Key, entry.Value);
}
}
}
}
finally
{
if (stream != null)
{
stream.Close();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:53,代码来源:BaseResourcesBuildProvider.cs