ExportCodeAnalysisRuleAttribute.Description Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Deskripsi aturan. Ini harus menjadi deskripsi singkat yang dapat dibaca manusia tentang apa yang dimaksudkan aturan untuk diperingatkan terhadap atau memblokir. Bidang ini dapat dilokalkan, tetapi ini harus dilakukan dengan subkelas ExportCodeAnalysisRuleAttribute dan menimpa properti Deskripsi.
public virtual string Description { get; set; }
member this.Description : string with get, set
Public Overridable Property Description As String
Nilai Properti
Contoh
// Example of an Attribute class that supports localized descriptions:
public class TestLocalizedExportCodeAnalysisRuleAttribute : ExportCodeAnalysisRuleAttribute
{
private readonly string _descriptionResourceName;
private string _descriptionValue;
public TestLocalizedExportCodeAnalysisRuleAttribute(string id, string displayName, string descriptionResourceName)
: base(id, displayName)
{
_descriptionResourceName = descriptionResourceName;
}
public override string Description
{
get
{
if (_descriptionValue == null)
{
// Using the descriptionResourceName as the key for looking up the description in the resources file.
// MyResources is a resource file in the same project as the LocalizedExportCodeAnalysisRuleAttribute class.
// For each rule, and entry should be added to the resources file with the descriptionResourceName as the
// key and the description as the value
_descriptionValue = MyResources.ResourceManager.GetString(_descriptionResourceName);
}
return _descriptionValue;
}
}
}