@@ -28,9 +28,11 @@ internal static class Extensions
2828 private static PropertyInfo etagConcurrencyPropertiesProperty = typeof ( ETag ) . GetProperty (
2929 PropertyNameOfConcurrencyProperties , BindingFlags . NonPublic | BindingFlags . Instance ) ;
3030
31+ // TODO GithubIssue#485 considering move to API class DI instance
3132 private static ConcurrentDictionary < IEdmEntitySet , bool > concurrencyCheckFlags
3233 = new ConcurrentDictionary < IEdmEntitySet , bool > ( ) ;
3334
35+ // TODO GithubIssue#485 considering move to API class DI instance
3436 private static ConcurrentDictionary < IEdmStructuredType , IDictionary < string , PropertyAttributes > >
3537 typePropertiesAttributes
3638 = new ConcurrentDictionary < IEdmStructuredType , IDictionary < string , PropertyAttributes > > ( ) ;
@@ -80,7 +82,8 @@ public static IReadOnlyDictionary<string, object> CreatePropertyDictionary(
8082 PropertyAttributes attributes ;
8183 if ( propertiesAttributes != null && propertiesAttributes . TryGetValue ( propertyName , out attributes ) )
8284 {
83- if ( ( isCreation && attributes . IgnoreForCreation ) || ( ! isCreation && attributes . IgnoreForUpdate ) )
85+ if ( ( isCreation && ( attributes & PropertyAttributes . IgnoreForCreation ) != PropertyAttributes . None )
86+ || ( ! isCreation && ( attributes & PropertyAttributes . IgnoreForUpdate ) != PropertyAttributes . None ) )
8487 {
8588 // Will not get the properties for update or creation
8689 continue ;
@@ -116,7 +119,7 @@ public static IDictionary<string, PropertyAttributes> RetrievePropertiesAttribut
116119 foreach ( var property in edmType . DeclaredProperties )
117120 {
118121 var annotations = model . FindVocabularyAnnotations ( property ) ;
119- PropertyAttributes attributes = null ;
122+ var attributes = PropertyAttributes . None ;
120123 foreach ( var annotation in annotations )
121124 {
122125 var valueAnnotation = annotation as EdmAnnotation ;
@@ -125,34 +128,22 @@ public static IDictionary<string, PropertyAttributes> RetrievePropertiesAttribut
125128 continue ;
126129 }
127130
128- if ( valueAnnotation . Term . Namespace == CoreVocabularyModel . ImmutableTerm . Namespace
129- && valueAnnotation . Term . Name == CoreVocabularyModel . ImmutableTerm . Name )
131+ if ( valueAnnotation . Term . IsSameTerm ( CoreVocabularyModel . ImmutableTerm ) )
130132 {
131133 var value = valueAnnotation . Value as EdmBooleanConstant ;
132134 if ( value != null && value . Value )
133135 {
134- if ( attributes == null )
135- {
136- attributes = new PropertyAttributes ( ) ;
137- }
138-
139- attributes . IgnoreForUpdate = true ;
136+ attributes |= PropertyAttributes . IgnoreForUpdate ;
140137 }
141138 }
142139
143- if ( valueAnnotation . Term . Namespace == CoreVocabularyModel . ComputedTerm . Namespace
144- && valueAnnotation . Term . Name == CoreVocabularyModel . ComputedTerm . Name )
140+ if ( valueAnnotation . Term . IsSameTerm ( CoreVocabularyModel . ComputedTerm ) )
145141 {
146142 var value = valueAnnotation . Value as EdmBooleanConstant ;
147143 if ( value != null && value . Value )
148144 {
149- if ( attributes == null )
150- {
151- attributes = new PropertyAttributes ( ) ;
152- }
153-
154- attributes . IgnoreForUpdate = true ;
155- attributes . IgnoreForCreation = true ;
145+ attributes |= PropertyAttributes . IgnoreForUpdate ;
146+ attributes |= PropertyAttributes . IgnoreForCreation ;
156147 }
157148 }
158149
@@ -161,7 +152,7 @@ public static IDictionary<string, PropertyAttributes> RetrievePropertiesAttribut
161152 }
162153
163154 // Add property attributes to the dictionary
164- if ( attributes != null )
155+ if ( attributes != PropertyAttributes . None )
165156 {
166157 if ( propertiesAttributes == null )
167158 {
@@ -241,5 +232,15 @@ public static IEdmTypeReference GetTypeReference(this Type type, IEdmModel model
241232
242233 return type . GetPrimitiveTypeReference ( ) ;
243234 }
235+
236+ public static bool IsSameTerm ( this IEdmTerm sourceTerm , IEdmTerm targetTerm )
237+ {
238+ if ( sourceTerm . Namespace == targetTerm . Namespace && sourceTerm . Name == targetTerm . Name )
239+ {
240+ return true ;
241+ }
242+
243+ return false ;
244+ }
244245 }
245246}
0 commit comments