~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core/EDMObjects/CSDL/Property/NavigationProperty.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
#region Usings
 
5
 
 
6
using System;
 
7
using System.Collections.Generic;
 
8
using System.Linq;
 
9
using System.Text;
 
10
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.Common;
 
11
using System.ComponentModel;
 
12
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.CSDL.Type;
 
13
using System.Collections;
 
14
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.MSL.Association;
 
15
using ICSharpCode.Data.EDMDesigner.Core.EDMObjects.CSDL.Common;
 
16
 
 
17
#endregion
 
18
 
 
19
namespace ICSharpCode.Data.EDMDesigner.Core.EDMObjects.CSDL.Property
 
20
{
 
21
    public class NavigationProperty : PropertyBase
 
22
    {
 
23
        #region Fields
 
24
 
 
25
        private Cardinality _cardinality;
 
26
        private Visibility _setVisibility;
 
27
        private bool _generate = true;
 
28
        private EntityType _relatedEntityType;
 
29
        private AssociationRoleMapping _mapping;
 
30
 
 
31
        #endregion
 
32
 
 
33
        #region Constructor
 
34
 
 
35
        public NavigationProperty(Association.Association association)
 
36
        {
 
37
            Association = association;
 
38
        }
 
39
 
 
40
        #endregion
 
41
 
 
42
        #region Properties
 
43
 
 
44
        public new EntityType EntityType
 
45
        {
 
46
            get { return base.EntityType as EntityType; }
 
47
            internal set { base.EntityType = value; }
 
48
        }
 
49
 
 
50
        protected override Func<TypeBase, IList> GetPropertyCollection
 
51
        {
 
52
            get
 
53
            {
 
54
                return
 
55
                    baseType =>
 
56
                    {
 
57
                        var entityType = baseType as EntityType;
 
58
                        if (entityType == null)
 
59
                            return new List<NavigationProperty>();
 
60
                        return entityType.NavigationProperties;
 
61
                    };
 
62
            }
 
63
        }
 
64
 
 
65
        public Association.Association Association { get; private set; }
 
66
 
 
67
        public EntityType RelatedEntityType
 
68
        {
 
69
            get
 
70
            {
 
71
                if (_relatedEntityType == null)
 
72
                    _relatedEntityType = Association.PropertiesEnd.First(np => np != this).EntityType;
 
73
                return _relatedEntityType;
 
74
            }
 
75
        }
 
76
 
 
77
        [DisplayName("Multiplicity")]
 
78
        public Cardinality Cardinality
 
79
        {
 
80
            get { return _cardinality; }
 
81
            set
 
82
            {
 
83
                _cardinality = value;
 
84
                OnPropertyChanged("Cardinality");
 
85
                OnCardinalityChanged();
 
86
            }
 
87
        }
 
88
 
 
89
        [DisplayName("Setter")]
 
90
        public Visibility SetVisibility
 
91
        {
 
92
            get { return _setVisibility; }
 
93
            set
 
94
            {
 
95
                _setVisibility = value;
 
96
                OnPropertyChanged("SetVisibility");
 
97
            }
 
98
        }
 
99
 
 
100
        [DisplayName("Generate")]
 
101
        public bool Generate
 
102
        {
 
103
            get { return _generate; }
 
104
            set
 
105
            {
 
106
                _generate = value;
 
107
                OnPropertyChanged("Generate");
 
108
            }
 
109
        }
 
110
 
 
111
        public AssociationRoleMapping Mapping
 
112
        {
 
113
            get
 
114
            {
 
115
                if (_mapping == null)
 
116
                    _mapping = new AssociationRoleMapping(this);
 
117
                return _mapping;
 
118
            }
 
119
        }
 
120
 
 
121
        internal bool IsDeleted { get; set; }
 
122
 
 
123
        #endregion
 
124
 
 
125
        protected override PropertyBase Create()
 
126
        {
 
127
            throw new NotImplementedException();
 
128
        }
 
129
 
 
130
        protected virtual void OnCardinalityChanged()
 
131
        {
 
132
            if (CardinalityChanged != null)
 
133
                CardinalityChanged();
 
134
        }
 
135
        public event Action CardinalityChanged;
 
136
    }
 
137
}