Exemplo n.º 1
0
 public StructureMember(FieldModifier modifier, NamespaceName fieldType, string identifier, Versioning versioning, NamespaceName fieldContainer)
     : base(identifier, versioning)
 {
     _modifier = modifier;
     _fieldType = fieldType;
     _fieldContainer = fieldContainer;
 }
Exemplo n.º 2
0
 public NamespaceName(NamespaceName name, string identifier)
 {
     _name = name._name.Push(identifier);
 }
Exemplo n.º 3
0
 public StructureMember(FieldModifier modifier, NamespaceName fieldType, string identifier, Versioning versioning)
     : this(modifier, fieldType, identifier, versioning, null)
 {
 }
Exemplo n.º 4
0
        void ResolveMembers(Protocol protocol, Structure structure)
        {
            Set<NamespaceName> references = new Set<NamespaceName>();

            foreach (StructureMember member in structure.Members)
            {
                NamespaceName name = member.FieldType;
                NamespaceName qualifiedName;

                if (name.IsQualified)
                {
                    qualifiedName = name;
                }
                else
                {
                    qualifiedName = new NamespaceName(protocol.Name, name.UnqualifiedName);
                }

                if (references.Contains(qualifiedName))
                {
                    throw new SemanticException(string.Format(
                        "The member \"{0}\" in the choice \"{1}\" in the protocol \"{2}\"; " +
                        "choices can only contain structures and messages.",
                        member.Identifier, structure.Identifier, protocol.Name));
                }

                if (_declarations.ContainsKey(qualifiedName))
                {
                    member.FieldTypeReference = new DeclarationTypeReference(_declarations[qualifiedName]);
                }
                else if (!name.IsQualified && _intrinsics.ContainsKey(name.UnqualifiedName))
                {
                    member.FieldTypeReference = _intrinsics[name.UnqualifiedName];

                    if (structure.StructureKind == StructureKind.Choice)
                    {
                        throw new SemanticException(string.Format(
                            "The member \"{0}\" in the choice \"{1}\" in the protocol \"{2}\"; " +
                            "choices can only contain structures and messages.",
                            member.Identifier, structure.Identifier, protocol.Name));

                    }
                }
                else
                {
                    throw new SemanticException(string.Format(
                        "The type \"{0}\" in \"{1}\" in the protocol \"{2}\" could not be resolved.",
                        name, member.Identifier, protocol.Name));
                }

                if (member.FieldContainer != null)
                {
                    if (!member.FieldContainer.IsQualified && _containers.ContainsKey(member.FieldContainer.UnqualifiedName))
                    {
                        member.FieldContainerReference = _containers[member.FieldContainer.UnqualifiedName];
                    }
                    else
                    {
                        throw new SemanticException(string.Format(
                            "The container \"{0}\" in \"{1}\" in the protocol \"{2}\" is not a valid container type.",
                            member.FieldContainer, member.Identifier, protocol.Name));
                    }
                }
            }
        }