Esempio n. 1
0
 private static IEnumerable <EdmError> ConversionError(EdmLocation location, string typeName, string typeKindName)
 {
     return(new[] { new EdmError(location, EdmErrorCode.TypeSemanticsCouldNotConvertTypeReference, Edm.Strings.TypeSemantics_CouldNotConvertTypeReference(typeName ?? EdmConstants.Value_UnnamedType, typeKindName)) });
 }
Esempio n. 2
0
 public CyclicComplexType(string qualifiedName, EdmLocation location)
     : base(qualifiedName, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicComplex, Edm.Strings.Bad_CyclicComplex(qualifiedName)) })
 {
 }
        /// <summary>
        /// Try parse enum members specified in a string value from declared schema types
        /// </summary>
        /// <param name="value">Enum value string</param>
        /// <param name="model">The model for resolving enum type.</param>
        /// <param name="location">The location of the enum member in csdl</param>
        /// <param name="result">Parsed enum members</param>
        /// <returns>True for successfully parsed, false for failed</returns>
        internal static bool TryParseEnumMember(string value, IEdmModel model, EdmLocation location, out IEnumerable<IEdmEnumMember> result)
        {
            result = null;
            if (value == null || model == null)
            {
                return false;
            }

            bool isUnresolved = false;
            var enumValues = value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (!enumValues.Any())
            {
                return false;
            }

            string enumTypeName = enumValues[0].Split('/').FirstOrDefault();
            if (string.IsNullOrEmpty(enumTypeName))
            {
                return false;
            }

            IEdmEnumType enumType = model.FindType(enumTypeName) as IEdmEnumType;

            if (enumType == null)
            {
                enumType = new UnresolvedEnumType(enumTypeName, location);
                isUnresolved = true;
            }
            else if (enumValues.Count() > 1 && (!enumType.IsFlags || !EdmEnumValueParser.IsEnumIntergeType(enumType)))
            {
                return false;
            }

            List<IEdmEnumMember> enumMembers = new List<IEdmEnumMember>();
            foreach (var enumValue in enumValues)
            {
                string[] path = enumValue.Split('/');
                if (path.Count() != 2)
                {
                    return false;
                }

                if (path[0] != enumTypeName)
                {
                    return false;
                }

                if (!isUnresolved)
                {
                    IEdmEnumMember member = enumType.Members.SingleOrDefault(m => m.Name == path[1]);
                    if (member == null)
                    {
                        return false;
                    }

                    enumMembers.Add(member);
                }
                else
                {
                    enumMembers.Add(new UnresolvedEnumMember(path[1], enumType, location));
                }
            }

            result = enumMembers;
            return true;
        }
Esempio n. 4
0
 public UnresolvedParameter(IEdmOperation declaringOperation, string name, EdmLocation location)
     : base(new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedParameter, Edm.Strings.Bad_UnresolvedParameter(name)) })
 {
     this.Name = name ?? string.Empty;
     this.DeclaringOperation = declaringOperation;
 }
Esempio n. 5
0
 private static IEnumerable<EdmError> ConversionError(EdmLocation location, string typeName, string typeKindName)
 {
     return new[] { new EdmError(location, EdmErrorCode.TypeSemanticsCouldNotConvertTypeReference, Edm.Strings.TypeSemantics_CouldNotConvertTypeReference(typeName ?? EdmConstants.Value_UnnamedType, typeKindName)) };
 }
Esempio n. 6
0
 public CyclicEntityContainer(string name, EdmLocation location)
     : base(name, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicEntityContainer, Edm.Strings.Bad_CyclicEntityContainer(name)) })
 {
 }