1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<Type Name="ConditionalAttribute" FullName="System.Diagnostics.ConditionalAttribute" FullNameSP="System_Diagnostics_ConditionalAttribute" Maintainer="ecma">
<TypeSignature Language="ILASM" Value=".class public sealed serializable ConditionalAttribute extends System.Attribute" />
<TypeSignature Language="C#" Value="public sealed class ConditionalAttribute : System.Attribute" />
<MemberOfLibrary>BCL</MemberOfLibrary>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
</AssemblyInfo>
<ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
<Docs>
<summary>
<para>Indicates to compilers that a method is callable if and only if a specified
pre-processing identifier has been defined on the method.</para>
</summary>
<remarks>
<block subset="none" type="note">
<para>A <see cref="T:System.Diagnostics.ConditionalAttribute" />, which has an
associated condition <see cref="P:System.Diagnostics.ConditionalAttribute.ConditionString" />, can be attached to the
definition of a method, creating a <paramref name="conditional" /><paramref name="method" />
. Thereafter, when a compiler encounters
a call to that method, it may choose to ignore the call unless a compilation
variable is defined at the site of the call, with a value that matches
in a case-sensitive manner the <see cref="P:System.Diagnostics.ConditionalAttribute.ConditionString" /> supplied to the <see cref="T:System.Diagnostics.ConditionalAttribute" />
.</para>
<para>Note that compilers may provide several techniques to define such compilation variables, such
as:</para>
<list type="bullet">
<item>
<term>
<para>compiler command-line switches (for
example, <c>/define:DEBUG</c> )</para>
</term>
</item>
<item>
<term>
<para>environment variables in the operating system shell
(for example, <c>SET
DEBUG=1</c>)</para>
</term>
</item>
<item>
<term>
<para>as pragmas in the source code (for example, <c>#define DEBUG</c>, to define the
compilation variable, or <c>#undef DEBUG</c> to
undefine it)</para>
</term>
</item>
</list>
<para> CLS-Compliant compilers are permitted to ignore uses of the <see cref="T:System.Diagnostics.ConditionalAttribute" />
.</para>
</block>
</remarks>
<example>
<para> The following example demonstrates the use of
<see cref="T:System.Diagnostics.ConditionalAttribute" /> with a
particular compiler that supports the use of this
attribute. The <see cref="P:System.Diagnostics.ConditionalAttribute.ConditionString" /> property of the current
attribute is initialized as "DEBUG".</para>
<c>
<code lang="C#">using System;
using System.Diagnostics;
public class MyClass {
[ConditionalAttribute("DEBUG")]
public static void Display() {
Console.WriteLine("Compiled with DEBUG");
}
}
public class TestCondition {
public static void Main() {
Console.WriteLine("How was this compiled?");
MyClass.Display();
Console.WriteLine("<eop>");
}
}
</code>
</c>
<para> When this code is compiled with the
compilation-variable DEBUG defined at the callsite, the
output when run is </para>
<c>
<para>
How was this compiled?</para>
<para>Compiled with DEBUG</para>
<para><eop>
</para>
</c>
<para> When this code is
compiled without the compilation-variable DEBUG defined at the callsite, the
output when run is</para>
<c>
<para>
How was this compiled?</para>
<para><eop>
</para>
</c>
</example>
</Docs>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true)</AttributeName>
</Attribute>
</Attributes>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string conditionString)" />
<MemberSignature Language="C#" Value="public ConditionalAttribute (string conditionString);" />
<MemberType>Constructor</MemberType>
<ReturnValue />
<Parameters>
<Parameter Name="conditionString" Type="System.String" />
</Parameters>
<Docs>
<summary>
<para> Constructs and initializes a new instance of the <see cref="T:System.Diagnostics.ConditionalAttribute" /> class.</para>
</summary>
<param name="conditionString">A <see cref="T:System.String" /> that contains the pre-processing identifier that makes callable the target method of the current instance.</param>
<remarks>
<para>This constructor initializes the <see cref="P:System.Diagnostics.ConditionalAttribute.ConditionString" /> property of the current instance using
<paramref name="conditionString" />.</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="ConditionString">
<MemberSignature Language="ILASM" Value=".property string ConditionString { public hidebysig specialname instance string get_ConditionString() }" />
<MemberSignature Language="C#" Value="public string ConditionString { get; };" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>
<para>Gets the <see cref="T:System.String" /> that contains
the pre-processing identifier that makes callable the target method of the current instance.</para>
</summary>
<value>
<para>A <see cref="T:System.String" />
that contains the pre-processing identifier that makes callable the target
method of the current instance.</para>
</value>
<remarks>
<para>This property is read-only.</para>
</remarks>
</Docs>
<Excluded>0</Excluded>
</Member>
</Members>
<TypeExcluded>0</TypeExcluded>
</Type>
|