WebResourceAttribute.PerformSubstitution Propiedad

Definición

Obtiene o establece un valor booleano que determina si durante el procesamiento del recurso incrustado al que hizo referencia la clase WebResourceAttribute, se analizan y se reemplazan otras direcciones URL del recurso Web con la ruta de acceso completa al recurso.Gets or sets a Boolean value that determines whether, during processing of the embedded resource referenced by the WebResourceAttribute class, other Web resource URLs are parsed and replaced with the full path to the resource.

public:
 property bool PerformSubstitution { bool get(); void set(bool value); };
public bool PerformSubstitution { get; set; }
member this.PerformSubstitution : bool with get, set
Public Property PerformSubstitution As Boolean

Valor de propiedad

Es true si los recursos incrustados están resueltos durante el procesamiento del recurso; en caso contrario, es false.true if embedded resources are resolved during processing of the resource; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo consultar el valor PerformSubstitution de la propiedad.The following code example demonstrates how to query the value of the PerformSubstitution property. En este ejemplo, el WebResourceAttribute atributo del archivo HTML Help. htm se define con la PerformSubstitution propiedad establecida en true.In this example, the WebResourceAttribute attribute of the HTML file Help.htm is defined with the PerformSubstitution property set to true.

Este ejemplo de código forma parte de un ejemplo más extenso proporcionado WebResourceAttribute para la clase.This code example is part of a larger example provided for the WebResourceAttribute class.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS.Controls" %>
<%@ Import Namespace="System.Reflection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
            
    // Get the assembly metatdata.
    Type clsType = typeof(MyCustomControl);
    Assembly a = clsType.Assembly;

    // Iterate through the attributes for the assembly.
    foreach (Attribute attr in Attribute.GetCustomAttributes(a))
    {
      //Check for WebResource attributes.
      if (attr.GetType() == typeof(WebResourceAttribute))
      {
        WebResourceAttribute wra = (WebResourceAttribute)attr;
        Response.Write("Resource in the assembly: " + wra.WebResource.ToString() +
          " with ContentType = " + wra.ContentType.ToString() +
          " and PerformsSubstitution = " + wra.PerformSubstitution.ToString() + "</br>");
      }
    }
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebResourceAttribute Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <AspNetSamples:MyCustomControl id="MyCustomControl1" runat="server">
      </AspNetSamples:MyCustomControl>    
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB.Controls" %>
<%@ Import Namespace="System.Reflection" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Get the assembly metatdata.
    Dim clsType As Type = GetType(MyCustomControl)
    Dim a As Assembly = clsType.Assembly
    
    For Each attr As Attribute In Attribute.GetCustomAttributes(a)
      'Check for WebResource attributes.
      If attr.GetType() Is GetType(WebResourceAttribute) Then
        Dim wra As WebResourceAttribute = CType(attr, WebResourceAttribute)
        Response.Write("Resource in the assembly: " & wra.WebResource.ToString() & _
        " with ContentType = " & wra.ContentType.ToString() & _
        " and PerformsSubstitution = " & wra.PerformSubstitution.ToString() & "</br>")
      End If
    Next attr
    
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebResourceAttribute Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <AspNetSamples:MyCustomControl id="MyCustomControl1" runat="server">
      </AspNetSamples:MyCustomControl>    
    </div>
    </form>
</body>
</html>

A continuación se muestra un ejemplo de un recurso web HTML que podría usarse en este ejemplo.An example of an HTML Web resource that could be used in this example is shown next. Tenga en cuenta WebResource que la sintaxis se usa cuando se PerformSubstitution establece la true propiedad en para el recurso.Note that the WebResource syntax is used when you set the PerformSubstitution property to true for the resource.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html >

<head>

<title>Included Help Page</title>

</head>

<body>

<div>

<img alt="help image" src=<% = WebResource("image1.jpg") %> />

Included help file.

</div>

</body>

</html>

Comentarios

Cuando se transmite un recurso del ensamblado a la respuesta, en este momento se pueden resolver las referencias a otros recursos Web de los recursos incrustados, si PerformSubstitution la propiedad está establecida trueen.When a resource is streamed from the assembly to the response, references to other Web resources in the embedded resources can be resolved at this time, if the PerformSubstitution property is set to true.

Se aplica a