コード例 #1
0
        private bool TryAddProperty(FunctionDefinition node, PythonType declaringType)
        {
            // We can't add a property to an unknown type. Fallback to a regular function for now.
            // TOOD: Decouple declaring types from the property.
            if (declaringType.IsUnknown())
            {
                return(false);
            }

            var dec        = node.Decorators?.Decorators;
            var decorators = dec != null?dec.ExcludeDefault().ToArray() : Array.Empty <Expression>();

            foreach (var d in decorators.OfType <NameExpression>())
            {
                switch (d.Name)
                {
                case @"property":
                    AddProperty(node, declaringType, false);
                    return(true);

                case @"abstractproperty":
                    AddProperty(node, declaringType, true);
                    return(true);
                }
            }
            return(false);
        }