Ejemplo n.º 1
0
        /// <summary>
        ///     获取属性
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var attributeLists = GetCompileAttributeList(node.AttributeLists);

            // accessor 就是获取 Set get

            ICompileMethod get = null;
            ICompileMethod set = null;

            if (node.AccessorList != null)
            {
                foreach (var temp in node.AccessorList.Accessors)
                {
                    if (temp.Keyword.Text == "get")
                    {
                        get = new CompileMethod(GetCompileAttributeList(temp.AttributeLists), "get");
                    }
                    else if (temp.Keyword.Text == "set")
                    {
                        set = new CompileMethod(GetCompileAttributeList(temp.AttributeLists), "set");
                    }
                }
            }

            var compileProperty = new CompileProperty(node.Type.ToString(), attributeLists, node.Identifier.ToString())
            {
                SetMethod = set,
                GetMethod = get
            };

            foreach (var temp in node.Modifiers)
            {
                compileProperty.MemberModifiers |= SyntaxKindToMemberModifiers(temp.Kind());
            }

            var type = _lastType;

            type.AddCompileProperty(compileProperty);

            return(base.VisitPropertyDeclaration(node));
        }
Ejemplo n.º 2
0
 public void AddCompileMethod(ICompileMethod member)
 {
     _methods.Add(member);
 }