public CsStructureMember(StructureMember member, CsType type, CsStructure structure)
            : base(member)
        {
            _member = member;
            _type = type;
            _structure = structure;

            _containedInStructure = member.Parent.Implementation as CsStructure;
        }
Esempio n. 2
0
        public override object CreateStructureMemberImplementationHelper(StructureMember member)
        {
            if (member.FieldTypeReference is IntrinsicTypeReference)
            {
                IntrinsicTypeReference reference = member.FieldTypeReference as IntrinsicTypeReference;

                return new CsStructureMember(member, _intrinsics[reference.Type], null);
            }
            else
            {
                DeclarationTypeReference reference = member.FieldTypeReference as DeclarationTypeReference;

                NamespaceName name = reference.Declaration.QualifiedName;
                string codecName = reference.Declaration.Identifier;
                bool isReferenceType = !(reference.Declaration is Enumeration);

                if (reference.Declaration.Implementation is CsStructure)
                {
                    CsStructure structure = (CsStructure)reference.Declaration.Implementation;

                    name = structure.ReferenceTypeName;
                    codecName = structure.Identifier;
                    isReferenceType = structure.IsReferenceType;
                }

                bool isInProtocolNamespace =
                    name.ContainingName.Equals(member.Parent.Parent.Name);

                CsType type;

                if (isInProtocolNamespace)
                {
                    type = new CsType(name.UnqualifiedName, isReferenceType);
                }
                else
                {
                    type = new CsType(name.ToString(), isReferenceType);
                }

                return new CsStructureMember(member, type, reference.Declaration.Implementation as CsStructure);
            }
        }