using System; namespace DDD.MVVM { /// /// UI 요소를 ViewModel 속성에 바인딩하기 위한 Attribute /// Inspector에서 바인딩 정보를 시각적으로 확인할 수 있도록 지원 /// [System.AttributeUsage(System.AttributeTargets.Field)] public class BindToAttribute : System.Attribute { /// /// 바인딩할 ViewModel 속성의 경로 (nameof 사용 권장) /// public string PropertyPath { get; } /// /// 값 변환기 타입 (선택사항) /// public System.Type ConverterType { get; } /// /// 바인딩 Attribute 생성자 /// /// 바인딩할 속성 경로 (nameof 사용 권장) /// 값 변환기 타입 (선택사항) public BindToAttribute(string propertyPath, System.Type converterType = null) { PropertyPath = propertyPath; ConverterType = converterType; } } // /// // /// 타입 안전한 바인딩 Attribute (제네릭 버전) // /// 특정 ViewModel 타입에 대한 바인딩을 명시적으로 지정 // /// // /// 바인딩할 ViewModel 타입 // [System.AttributeUsage(System.AttributeTargets.Field)] // public class BindToAttribute : System.Attribute where TViewModel : class // { // /// // /// 바인딩할 ViewModel 속성의 경로 // /// // public string PropertyPath { get; } // // /// // /// 값 변환기 타입 (선택사항) // /// // public System.Type ConverterType { get; } // // /// // /// 타입 안전한 바인딩 Attribute 생성자 // /// // /// 바인딩할 속성 경로 // /// 값 변환기 타입 (선택사항) // public BindToAttribute(string propertyPath, System.Type converterType = null) // { // PropertyPath = propertyPath; // ConverterType = converterType; // } // } /// /// 컬렉션 바인딩을 위한 Attribute /// 동적으로 생성되는 UI 요소들을 컬렉션에 바인딩 /// [System.AttributeUsage(System.AttributeTargets.Field)] public class BindCollectionAttribute : System.Attribute { /// /// 바인딩할 컬렉션 속성의 경로 /// public string PropertyPath { get; } /// /// 아이템 프리팹의 필드명 또는 속성명 /// public string ItemPrefabReference { get; } /// /// 컬렉션 바인딩 Attribute 생성자 /// /// 바인딩할 컬렉션 속성 경로 /// 아이템 프리팹 참조 public BindCollectionAttribute(string propertyPath, string itemPrefabReference = null) { PropertyPath = propertyPath; ItemPrefabReference = itemPrefabReference; } } /// /// 커맨드 바인딩을 위한 Attribute /// 버튼 클릭 등의 이벤트를 ViewModel 메서드에 바인딩 /// [System.AttributeUsage(System.AttributeTargets.Field)] public class BindCommandAttribute : System.Attribute { /// /// 바인딩할 ViewModel 메서드 이름 /// public string MethodName { get; } /// /// 커맨드 바인딩 Attribute 생성자 /// /// 바인딩할 메서드 이름 public BindCommandAttribute(string methodName) { MethodName = methodName; } } }