Exemplo n.º 1
0
        public IndexerInfo(IndexerDeclarationSyntax decl, IMemberContainer parent)
        {
            var paramList = decl.ParameterList.Parameters
                            .Select(p => p.Type.ToString());

            if (decl.HasLeadingTrivia)
            {
                Documentation = GetDocumentation(decl.GetLeadingTrivia());
            }

            Name        = decl.Type.ToString() + $"[{string.Join(", ", paramList)}]";
            _parameters = Parse(decl.ParameterList);
            Parent      = parent;
            _modifiers  = decl.Modifiers
                          .ParseModifiers()
                          .WithDefaultVisibility(Parent is InterfaceInfo ?
                                                 Modifier.Public : Modifier.Private);

            ReturnType = decl.Type.ToString();
            Signature  = $"{ReturnType} this[{ParamSyntax()}]";

            var accessors = decl.AccessorList?.Accessors
                            .Select(a => new AccessorInfo(a, this));

            if (accessors != null)
            {
                Setter = accessors.FirstOrDefault(a => a.IsSetter);
                Getter = accessors.FirstOrDefault(a => a.IsGetter);
            }
            else if (decl.ExpressionBody != null)
            {
                Getter = new AccessorInfo(this);
            }
        }
Exemplo n.º 2
0
        public PropertyInfo(PropertyDeclarationSyntax decl, IMemberContainer parent)
        {
            Name = decl.Identifier.Text;
            if (decl.HasLeadingTrivia)
            {
                Documentation = GetDocumentation(decl.GetLeadingTrivia());
            }
            Parent     = parent;
            _modifiers = decl.Modifiers
                         .ParseModifiers()
                         .WithDefaultVisibility(Parent is InterfaceInfo ?
                                                Modifier.Public : Modifier.Private);

            ReturnType = decl.Type.ToString();

            var accessors = decl.AccessorList?.Accessors
                            .Select(a => new AccessorInfo(a, this));

            if (accessors != null)
            {
                Setter = accessors.FirstOrDefault(a => a.IsSetter);
                Getter = accessors.FirstOrDefault(a => a.IsGetter);
            }
            else if (decl.ExpressionBody != null)
            {
                Getter = new AccessorInfo(this);
            }

            _parameters = new List <ParameterInfo>();
            Signature   = $"{ReturnType} {Name} " + "{";
            if (HasGetter)
            {
                Signature += Getter.ToString();
            }
            if (HasSetter)
            {
                Signature += Setter.ToString();
            }
            Signature += " }";
        }