2016-08-10 6 views
2

나는 사용자 지정 특성이 실버 라이트 클라이언트에서 사용할 수없는 속성 :서버 측

[System.AttributeUsage(System.AttributeTargets.Property)] 
public class MyCustomAttribute : System.Attribute 
{ 
} 

그것은 클라이언트에 표시 클래스를했다 MyCustomAttribute.shared.cs라는 파일에 선언의 IT가에서 온다 자동 완성/클라이언트의 InteliSense.

나는 Entity는 WCF의 RIAServices하여 데이터베이스에서 반환하고 실버 라이트 클라이언트에 전달 내 클래스의 속성에 추가 : 나는 시도하고 속성이있는 경우 볼 때, 그러나

public partial class MyClass 
{ 
    [Required(AllowEmptyStrings=true)] 
    [Display(ResourceType=typeof(ResourceFile), Name="ResourceName")] 
    [MyCustom] 
    public string MyProperty { get; set; } 
} 

속성은 목록에없는입니다 첨부 : 반환되는 속성의

PropertyInfo prop = GetProperty(myType, "MyProperty"); 
object[] attributes = prop.GetCustomAttributes(false); 
foreach (object attribute in attributes) 
{ 
    if (attribute is MyCustomAttribute) 
    { 
     // Do my stuff here 
    } 
} 

없음 MyCustomAttribute을하지 않습니다.

나는 클라이언트 측에서 생성 된 코드를 확인했고,이 속성은 다음과 같습니다

/// <summary> 
    /// Gets or sets the 'BarcodeNumber' value. 
    /// </summary> 
    [ConcurrencyCheck()] 
    [DataMember()] 
    [Display(Name="ResourceName", ResourceType=typeof(ResourceFile))] 
    [Required(AllowEmptyStrings=true)] 
    [RoundtripOriginal()] 
    public string MyProperty 
    { 
     .... 
    } 

가 그래서, 분명히 내 속성은 클라이언트에 복사되지 않습니다.

무엇이 누락 되었습니까?

답변

1

내가 놓친 것은 사용자 정의 코드 생성기를 작성하여 기본 속성을 확장하여 새로운 속성을 인식 할 수 있어야한다는 것입니다.

과정은 웹에 다양한 장소에 설명되어 있습니다 :

.NET - WCF RIA Services code generatie naar je hand zetten (문서가 영어로되어 있습니다) 그러나

T4 Code Generator for WCF RIA Services

, 우리는 이것이 단지 하나 구현하는 과잉이 될 것이라고 결정 하나의 속성에 대한 속성은 우리가 필요로하는 기능을 구현하기 위해 (비즈니스 로직을 기반으로 한) 다른 접근 방식을 사용했습니다.