Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Function.cs « SchemaObjectModel « EntityModel « Data « System « System.Data.Entity « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 30a10dceeb17365695146df49e24a26726f8dc0b (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
//---------------------------------------------------------------------
// <copyright file="Function.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner       [....]
// @backupOwner [....]
//---------------------------------------------------------------------

namespace System.Data.EntityModel.SchemaObjectModel
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Data.Entity;
    using System.Data.Metadata.Edm;
    using System.Diagnostics;
    using System.Xml;

    /// <summary>
    /// class representing the Schema element in the schema
    /// </summary>
    internal class Function : SchemaType
    {
        #region Instance Fields
        // if adding properties also add to InitializeObject()!
        private bool _isAggregate = false;
        private bool _isBuiltIn = false;
        private bool _isNiladicFunction = false;
        protected bool _isComposable = true;
        protected FunctionCommandText _commandText = null;
        private string _storeFunctionName = null;
        protected SchemaType _type = null;
        private string _unresolvedType = null;
        protected bool _isRefType = false;
        // both are not specified
        protected SchemaElementLookUpTable<Parameter> _parameters = null;
        protected List<ReturnType> _returnTypeList = null;
        private CollectionKind _returnTypeCollectionKind = CollectionKind.None;
        private ParameterTypeSemantics _parameterTypeSemantics;
        private string _schema;

        private string _functionStrongName;
        #endregion

        #region Static Fields

        private static System.Text.RegularExpressions.Regex s_typeParser = new System.Text.RegularExpressions.Regex(@"^(?<modifier>((Collection)|(Ref)))\s*\(\s*(?<typeName>\S*)\s*\)$", System.Text.RegularExpressions.RegexOptions.Compiled);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static void RemoveTypeModifier(ref string type, out TypeModifier typeModifier, out bool isRefType)
        {
            isRefType = false;
            typeModifier = TypeModifier.None;

            System.Text.RegularExpressions.Match match = s_typeParser.Match(type);
            if (match.Success)
            {
                type = match.Groups["typeName"].Value;
                switch (match.Groups["modifier"].Value)
                {
                    case "Collection":
                        typeModifier = TypeModifier.Array;
                        return;
                    case "Ref":
                        isRefType = true;
                        return;
                    default:
                        Debug.Assert(false, "Unexpected modifier: " + match.Groups["modifier"].Value);
                        break;
                }
            }
            
        }

        internal static string GetTypeNameForErrorMessage(SchemaType type, CollectionKind colKind, bool isRef)
        {
            string typeName = type.FQName;
            if (isRef)
            {
                typeName = "Ref(" + typeName + ")";
            }
            switch (colKind)
            {
                case CollectionKind.Bag:
                    typeName = "Collection(" + typeName + ")";
                    break;
                default:
                    Debug.Assert(colKind == CollectionKind.None, "Unexpected CollectionKind");
                    break;
            }
            return typeName;
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// ctor for a schema function
        /// </summary>
        public Function(Schema parentElement)
            : base(parentElement)
        {
        }
        #endregion

        #region Public Properties

        public bool IsAggregate
        {
            get
            {
                return _isAggregate;
            }
            internal set
            {
                _isAggregate = value;
            }
        }

        public bool IsBuiltIn
        {
            get
            {
                return _isBuiltIn;
            }
            internal set
            {
                _isBuiltIn = value;
            }
        }

        public bool IsNiladicFunction
        {
            get
            {
                return _isNiladicFunction;
            }
            internal set
            {
                _isNiladicFunction = value;
            }
        }

        public bool IsComposable
        {
            get
            {
                return _isComposable;
            }
            internal set
            {
                _isComposable = value;
            }
        }

        public string CommandText
        {
            get
            {
                if (_commandText != null)
                {
                    return _commandText.CommandText;
                }
                return null;
            }
        }

        public ParameterTypeSemantics ParameterTypeSemantics
        {
            get
            {
                return _parameterTypeSemantics;
            }
            internal set
            {
                _parameterTypeSemantics = value;
            }
        }

        public string StoreFunctionName
        {
            get
            {
                return _storeFunctionName;
            }
            internal set
            {
                Debug.Assert(value != null, "StoreFunctionName should never be set null value");
                _storeFunctionName = value;
            }
        }

        public virtual SchemaType Type
        {
            get
            {
                if (null != _returnTypeList)
                {
                    Debug.Assert(_returnTypeList.Count == 1, "Shouldn't use Type if there could be multiple return types");
                    return this._returnTypeList[0].Type;
                }
                else
                {
                    return this._type;
                }
            }
        }

        public IList<ReturnType> ReturnTypeList
        {
            get
            {
                return null != _returnTypeList ? new ReadOnlyCollection<ReturnType>(_returnTypeList) : null;
            }
        }

        public SchemaElementLookUpTable<Parameter> Parameters
        {
            get
            {
                if (_parameters == null)
                {
                    _parameters = new SchemaElementLookUpTable<Parameter>();
                }
                return _parameters;
            }
        }

        public CollectionKind CollectionKind
        {
            get
            {
                return _returnTypeCollectionKind;
            }
            internal set
            {
                _returnTypeCollectionKind = value;
            }
        }

        public override string Identity
        {
            get
            {
                if (String.IsNullOrEmpty(_functionStrongName))
                {
                    string name = this.FQName;
                    System.Text.StringBuilder stringBuilder = new Text.StringBuilder(name);
                    bool first = true;
                    stringBuilder.Append('(');
                    foreach (Parameter parameter in this.Parameters)
                    {
                        if (!first)
                        {
                            stringBuilder.Append(',');
                        }
                        else
                        {
                            first = false;
                        }
                        stringBuilder.Append(Helper.ToString(parameter.ParameterDirection));
                        stringBuilder.Append(' ');
                        // we don't include the facets in the identity, since we are *not*
                        // taking them into consideration inside the 
                        // RankFunctionParameters method of TypeResolver.cs

                        parameter.WriteIdentity(stringBuilder);
                    }
                    stringBuilder.Append(')');
                    _functionStrongName = stringBuilder.ToString();
                }
                return _functionStrongName;
            }
        }

        public bool IsReturnAttributeReftype
        {
            get
            {
                return _isRefType;
            }
        }

        public virtual bool IsFunctionImport { get { return false; } }

        public string DbSchema
        {
            get
            {
                return _schema;
            }
        }

        #endregion

        #region Protected Properties
        protected override bool HandleElement(XmlReader reader)
        {
            if (base.HandleElement(reader))
            {
                return true;
            }
            else if (CanHandleElement(reader, XmlConstants.CommandText))
            {
                HandleCommandTextFunctionElment(reader);
                return true;
            }
            else if (CanHandleElement(reader, XmlConstants.Parameter))
            {
                HandleParameterElement(reader);
                return true;
            }
            else if (CanHandleElement(reader, XmlConstants.ReturnTypeElement))
            {
                HandleReturnTypeElement(reader);
                return true;
            }
            else if (Schema.DataModel == SchemaDataModelOption.EntityDataModel)
            {
                if (CanHandleElement(reader, XmlConstants.ValueAnnotation))
                {
                    // EF does not support this EDM 3.0 element, so ignore it.
                    SkipElement(reader);
                    return true;
                }
                else if (CanHandleElement(reader, XmlConstants.TypeAnnotation))
                {
                    // EF does not support this EDM 3.0 element, so ignore it.
                    SkipElement(reader);
                    return true;
                }
            }
            return false;
        }

        protected override bool HandleAttribute(XmlReader reader)
        {
            if (base.HandleAttribute(reader))
            {
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ReturnType))
            {
                HandleReturnTypeAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.AggregateAttribute))
            {
                HandleAggregateAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.BuiltInAttribute))
            {
                HandleBuiltInAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.StoreFunctionName))
            {
                HandleStoreFunctionNameAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.NiladicFunction))
            {
                HandleNiladicFunctionAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.IsComposable))
            {
                HandleIsComposableAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.ParameterTypeSemantics))
            {
                HandleParameterTypeSemanticsAttribute(reader);
                return true;
            }
            else if (CanHandleAttribute(reader, XmlConstants.Schema))
            {
                HandleDbSchemaAttribute(reader);
                return true;
            }

            return false;
        }
        #endregion

        #region Internal Methods

        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_unresolvedType != null)
            {
                Debug.Assert(Schema.DataModel != SchemaDataModelOption.ProviderManifestModel, "ProviderManifest cannot have ReturnType as an attribute");
                Schema.ResolveTypeName(this, UnresolvedReturnType, out _type);
            }

            if (null != _returnTypeList)
            {
                foreach (ReturnType returnType in _returnTypeList)
                {
                    returnType.ResolveTopLevelNames();
                }
            }

            foreach (Parameter parameter in this.Parameters)
            {
                parameter.ResolveTopLevelNames();
            }
        }

        /// <summary>
        /// Perform local validation on function definition.
        /// </summary>
        internal override void Validate()
        {
            base.Validate();

            if (_type != null && _returnTypeList != null)
            {
                AddError(ErrorCode.ReturnTypeDeclaredAsAttributeAndElement, EdmSchemaErrorSeverity.Error, Strings.TypeDeclaredAsAttributeAndElement);
            }

            // only call Type if _returnTypeList is empty, to ensure that we don't it when 
            // _returnTypeList has more than one element.
            if (this._returnTypeList == null && this.Type == null)
            {
                // Composable functions and function imports must declare return type.
                if (this.IsComposable)
                {
                    AddError(ErrorCode.ComposableFunctionOrFunctionImportWithoutReturnType, EdmSchemaErrorSeverity.Error,
                        Strings.ComposableFunctionOrFunctionImportMustDeclareReturnType);
                }
            }
            else
            {
                // Non-composable functions (except function imports) must not declare a return type.
                if (!this.IsComposable && !this.IsFunctionImport)
                {
                    AddError(ErrorCode.NonComposableFunctionWithReturnType, EdmSchemaErrorSeverity.Error,
                        Strings.NonComposableFunctionMustNotDeclareReturnType);
                }
            }

            if (Schema.DataModel != SchemaDataModelOption.EntityDataModel)
            {
                if (IsAggregate)
                {

                    // Make sure that the function has exactly one parameter and that takes
                    // a collection type
                    if (Parameters.Count != 1)
                    {
                        AddError(ErrorCode.InvalidNumberOfParametersForAggregateFunction,
                                 EdmSchemaErrorSeverity.Error,
                                 this,
                                 System.Data.Entity.Strings.InvalidNumberOfParametersForAggregateFunction(FQName));
                    }
                    else if (Parameters.GetElementAt(0).CollectionKind == CollectionKind.None)
                    {
                        // Since we have already checked that there should be exactly one parameter, it should be safe to get the
                        // first parameter for the function
                        Parameter param = Parameters.GetElementAt(0);

                        AddError(ErrorCode.InvalidParameterTypeForAggregateFunction,
                                 EdmSchemaErrorSeverity.Error,
                                 this,
                                 System.Data.Entity.Strings.InvalidParameterTypeForAggregateFunction(param.Name, FQName));
                    }

                }

                if (!this.IsComposable)
                {
                    // All aggregates, built-in and niladic functions must be composable, so throw error here.
                    if (this.IsAggregate ||
                        this.IsNiladicFunction ||
                        this.IsBuiltIn)
                    {
                        AddError(ErrorCode.NonComposableFunctionAttributesNotValid, EdmSchemaErrorSeverity.Error,
                            Strings.NonComposableFunctionHasDisallowedAttribute);
                    }
                }

                if (null != this.CommandText)
                {
                    // Functions with command text are not composable.
                    if (this.IsComposable)
                    {
                        AddError(ErrorCode.ComposableFunctionWithCommandText, EdmSchemaErrorSeverity.Error,
                            Strings.CommandTextFunctionsNotComposable);
                    }

                    // Functions with command text cannot declare store function name.
                    if (null != this.StoreFunctionName)
                    {
                        AddError(ErrorCode.FunctionDeclaresCommandTextAndStoreFunctionName, EdmSchemaErrorSeverity.Error,
                            Strings.CommandTextFunctionsCannotDeclareStoreFunctionName);
                    }
                }
            }

            if (Schema.DataModel == SchemaDataModelOption.ProviderDataModel)
            {
                // In SSDL function may return a primitive value or a collection of rows with scalar props.
                // It is not possible to encode "collection of rows" in the ReturnType attribute, so the only check needed here is to make sure that the type is scalar and not a collection.
                if (_type != null && (_type is ScalarType == false || _returnTypeCollectionKind != Metadata.Edm.CollectionKind.None))
                {
                    AddError(ErrorCode.FunctionWithNonPrimitiveTypeNotSupported,
                             EdmSchemaErrorSeverity.Error,
                             this,
                             System.Data.Entity.Strings.FunctionWithNonPrimitiveTypeNotSupported(GetTypeNameForErrorMessage(_type, _returnTypeCollectionKind, _isRefType), this.FQName));
                }
            }

            if (_returnTypeList != null)
            {
                foreach (ReturnType returnType in _returnTypeList)
                {
                    // FunctiomImportElement has additional validation for return types.
                    returnType.Validate();
                }
            }

            if (_parameters != null)
            {
                foreach (var parameter in _parameters)
                {
                    parameter.Validate();
                }
            }

            if (_commandText != null)
            {
                _commandText.Validate();
            }
        }

        internal override void ResolveSecondLevelNames()
        {
            foreach (var parameter in _parameters)
            {
                parameter.ResolveSecondLevelNames();
            }
        }

        internal override SchemaElement Clone(SchemaElement parentElement)
        {
            // We only support clone for FunctionImports.
            throw Error.NotImplemented();
        }
        protected void CloneSetFunctionFields(Function clone)
        {
            clone._isAggregate = _isAggregate;
            clone._isBuiltIn = _isBuiltIn;
            clone._isNiladicFunction = _isNiladicFunction;
            clone._isComposable = _isComposable;
            clone._commandText = _commandText;
            clone._storeFunctionName = _storeFunctionName;
            clone._type = _type;
            clone._returnTypeList = _returnTypeList;
            clone._returnTypeCollectionKind = _returnTypeCollectionKind;
            clone._parameterTypeSemantics = _parameterTypeSemantics;
            clone._schema = _schema;
            clone.Name = this.Name;

            // Clone all the parameters
            foreach (Parameter parameter in this.Parameters)
            {
                AddErrorKind error = clone.Parameters.TryAdd((Parameter)parameter.Clone(clone));
                Debug.Assert(error == AddErrorKind.Succeeded, "Since we are cloning a validated function, this should never fail.");
            }
        }
        #endregion

        #region Internal Properties
        /// <summary>
        /// 
        /// </summary>
        /// <value></value>
        internal string UnresolvedReturnType
        {
            get
            {
                return _unresolvedType;
            }
            set
            {
                _unresolvedType = value;
            }
        }
        #endregion //Internal Properties

        #region Private Methods

        /// <summary>
        /// The method that is called when a DbSchema attribute is encountered.
        /// </summary>
        /// <param name="reader">An XmlReader positioned at the Type attribute.</param>
        private void HandleDbSchemaAttribute(XmlReader reader)
        {
            Debug.Assert(Schema.DataModel == SchemaDataModelOption.ProviderDataModel, "We shouldn't see this attribute unless we are parsing ssdl");
            Debug.Assert(reader != null);

            _schema = reader.Value;
        }

        /// <summary>
        /// Handler for the Version attribute
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Version attribute</param>
        private void HandleAggregateAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            bool isAggregate = false;
            HandleBoolAttribute(reader, ref isAggregate);
            IsAggregate = isAggregate;
        }

        /// <summary>
        /// Handler for the Namespace attribute
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Namespace attribute</param>
        private void HandleBuiltInAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            bool isBuiltIn = false;
            HandleBoolAttribute(reader, ref isBuiltIn);
            IsBuiltIn = isBuiltIn;
        }

        /// <summary>
        /// Handler for the Alias attribute
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Alias attribute</param>
        private void HandleStoreFunctionNameAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            string value = reader.Value.ToString();
            if (!String.IsNullOrEmpty(value))
            {
                value = value.Trim();
                StoreFunctionName = value;
            }
        }

        /// <summary>
        /// Handler for the NiladicFunctionAttribute attribute
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Namespace attribute</param>
        private void HandleNiladicFunctionAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            bool isNiladicFunction = false;
            HandleBoolAttribute(reader, ref isNiladicFunction);
            IsNiladicFunction = isNiladicFunction;
        }

        /// <summary>
        /// Handler for the IsComposableAttribute attribute
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Namespace attribute</param>
        private void HandleIsComposableAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            bool isComposable = true;
            HandleBoolAttribute(reader, ref isComposable);
            IsComposable = isComposable;
        }

        private void HandleCommandTextFunctionElment(XmlReader reader)
        {
            Debug.Assert(reader != null);

            FunctionCommandText commandText = new FunctionCommandText(this);
            commandText.Parse(reader);
            _commandText = commandText;
        }

        protected virtual void HandleReturnTypeAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);
            Debug.Assert(UnresolvedReturnType == null);

            string type;
            if (!Utils.GetString(Schema, reader, out type))
                return;

            TypeModifier typeModifier;

            RemoveTypeModifier(ref type, out typeModifier, out _isRefType);

            switch (typeModifier)
            {
                case TypeModifier.Array:
                    CollectionKind = CollectionKind.Bag;
                    break;
                case TypeModifier.None:
                    break;
                default:
                    Debug.Assert(false, "RemoveTypeModifier already checks for this");
                    break;
            }

            if (!Utils.ValidateDottedName(Schema, reader, type))
                return;

            UnresolvedReturnType = type;
        }

        /// <summary>
        /// Handler for the Parameter Element
        /// </summary>
        /// <param name="reader">xml reader currently positioned at Parameter Element</param>
        protected void HandleParameterElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            Parameter parameter = new Parameter(this);

            parameter.Parse(reader);

            Parameters.Add(parameter, true, Strings.ParameterNameAlreadyDefinedDuplicate);
        }

        /// <summary>
        /// Handler for the ReturnType element
        /// </summary>
        /// <param name="reader">xml reader currently positioned at ReturnType element</param>
        protected void HandleReturnTypeElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            ReturnType returnType = new ReturnType(this);

            returnType.Parse(reader);

            if (this._returnTypeList == null)
            {
                this._returnTypeList = new List<ReturnType>();
            }
            this._returnTypeList.Add(returnType);
        }

        /// <summary>
        /// Handles ParameterTypeSemantics attribute
        /// </summary>
        /// <param name="reader"></param>
        private void HandleParameterTypeSemanticsAttribute(XmlReader reader)
        {
            Debug.Assert(reader != null);

            string value = reader.Value;

            if (String.IsNullOrEmpty(value))
            {
                return;
            }

            value = value.Trim();

            if (!String.IsNullOrEmpty(value))
            {
                switch (value)
                {
                    case "ExactMatchOnly":
                        ParameterTypeSemantics = ParameterTypeSemantics.ExactMatchOnly;
                        break;
                    case "AllowImplicitPromotion":
                        ParameterTypeSemantics = ParameterTypeSemantics.AllowImplicitPromotion;
                        break;
                    case "AllowImplicitConversion":
                        ParameterTypeSemantics = ParameterTypeSemantics.AllowImplicitConversion;
                        break;
                    default:
                        // don't try to use the name of the function, because we are still parsing the 
                        // attributes, and we may not be to the name attribute yet.
                        AddError(ErrorCode.InvalidValueForParameterTypeSemantics, EdmSchemaErrorSeverity.Error, reader,
                            System.Data.Entity.Strings.InvalidValueForParameterTypeSemanticsAttribute(
                                          value));

                        break;
                }
            }
        }

        #endregion
    }
}