Classe IgnoreAttribute

Spécifie qu'une méthode appliquée à un DomainService n'est pas une opération de domaine.

Espace de noms: System.ServiceModel.DomainServices.Server
Assembly : System.ServiceModel.DomainServices.Server (dans system.servicemodel.domainservices.server.dll)

Utilisation

'Utilisation
Dim instance As IgnoreAttribute

Syntaxe

'Déclaration
<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False, Inherited:=True)> _
Public NotInheritable Class IgnoreAttribute
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true)] 
public sealed class IgnoreAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field, AllowMultiple=false, Inherited=true)] 
public ref class IgnoreAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) */ 
public final class IgnoreAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field, AllowMultiple=false, Inherited=true) 
public final class IgnoreAttribute extends Attribute

Exemple

L'exemple suivant illustre une méthode dans un service de domaine, qui est appelée par une opération de domaine, mais n'est pas exposée en tant qu'opération de domaine.

Public Sub InsertCustomer(ByVal customer As Customer)
    If (customer.SalesPerson = String.Empty) Then
        customer.SalesPerson = RetrieveSalesPersonForCompany(customer.CompanyName)
    End If

    If ((customer.EntityState = EntityState.Detached) _
                = False) Then
        Me.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Added)
    Else
        Me.ObjectContext.Customers.AddObject(customer)
    End If
End Sub

<Ignore()> _
Public Function RetrieveSalesPersonForCompany(ByVal companyname As String) As String
    Dim salesPersonToAssign As String = "unassigned"

    Dim customers As List(Of Customer)
    customers = GetCustomers().Where(Function(c) c.CompanyName = companyname).ToList()

    If (customers.Count > 0) Then
        salesPersonToAssign = customers.First().SalesPerson
    End If

    Return salesPersonToAssign
End Function
public void InsertCustomer(Customer customer)
{
    if (customer.SalesPerson == String.Empty)
    {
        customer.SalesPerson = RetrieveSalesPersonForCompany(customer.CompanyName);
    }

    if ((customer.EntityState != EntityState.Detached))
    {
        this.ObjectContext.ObjectStateManager.ChangeObjectState(customer, EntityState.Added);
    }
    else
    {
        this.ObjectContext.Customers.AddObject(customer);
    }
}

[Ignore]
public string RetrieveSalesPersonForCompany(string companyname)
{
    string salesPersonToAssign = "unassigned";

    List<Customer> customers = GetCustomers().Where(c => c.CompanyName == companyname).ToList();
    if (customers.Count > 0)
    {
        salesPersonToAssign = customers.First().SalesPerson;
    }

    return salesPersonToAssign;
}

Notes

Vous utilisez l'attribut IgnoreAttribute pour faire en sorte qu'une méthode appliquée à un service de domaine ne soit pas exposée en tant qu'opération de domaine.

Hiérarchie d'héritage

System.Object
   System.Attribute
    System.ServiceModel.DomainServices.Server.IgnoreAttribute

Sécurité des threads

Tous les membres publics statiques (Partagés dans Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Plateformes

Plateformes de développement

Windows XP Édition familiale, Windows XP Professionnel, Windows Server 2003 , Windows Server 2008 et Windows 2000

Plateformes cibles

Change History

Voir aussi

Référence

Membres IgnoreAttribute
Espace de noms System.ServiceModel.DomainServices.Server