This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserEditorsRepository.vb
50 lines (45 loc) · 1.53 KB
/
UserEditorsRepository.vb
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
Imports System
Imports System.Collections.Generic
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.Repository
Namespace DefaultEditor
Public Class UserEditorsRepository
Inherits DefaultEditorsRepository
Private EditorsCache As New Dictionary(Of EditorType, RepositoryItem)()
Public Overrides Function GetRepositoryItem(ByVal type As Type) As RepositoryItem
If type.Equals(GetType(DateTime)) Then
Return GetRepositoryItem(EditorType.DateTime)
ElseIf type.Equals(GetType(Boolean)) Then
Return GetRepositoryItem(EditorType.Boolean)
Else
Return MyBase.GetRepositoryItem(type)
End If
End Function
Private Overloads Function GetRepositoryItem(ByVal editorType As EditorType) As RepositoryItem
If EditorsCache.ContainsKey(editorType) Then
Return EditorsCache(editorType)
End If
Dim result As RepositoryItem = CreateRepositoryItem(editorType)
EditorsCache.Add(editorType, result)
Return result
End Function
Private Function CreateRepositoryItem(ByVal editorType As EditorType) As RepositoryItem
Select Case editorType
Case EditorType.DateTime
Return New RepositoryItemTextEdit()
Case EditorType.Boolean
Dim result As New RepositoryItemRadioGroup()
result.Columns = 2
result.Items.Add(New RadioGroupItem(True, "Yes"))
result.Items.Add(New RadioGroupItem(False, "No"))
Return result
Case Else
Return New RepositoryItemTextEdit()
End Select
End Function
Private Enum EditorType
DateTime
[Boolean]
End Enum
End Class
End Namespace