public static AttributeData GetPhpScriptAttribute(this TypeSymbol symbol)
        {
            var attrs = symbol.GetAttributes();

            for (int i = 0; i < attrs.Length; i++)
            {
                var a        = attrs[i];
                var fullname = MetadataHelpers.BuildQualifiedName((a.AttributeClass as NamedTypeSymbol)?.NamespaceName, a.AttributeClass.Name);
                if (fullname == CoreTypes.PhpScriptAttributeFullName)
                {
                    return(a);
                }
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets [PhpType] attribute and its parameters.
        /// </summary>
        public static bool TryGetPhpTypeAttribute(this TypeSymbol symbol, out string typename, out string filename)
        {
            var attrs = symbol.GetAttributes();

            for (int i = 0; i < attrs.Length; i++)
            {
                var a        = attrs[i];
                var fullname = MetadataHelpers.BuildQualifiedName((a.AttributeClass as NamedTypeSymbol)?.NamespaceName, a.AttributeClass.Name);
                if (fullname == CoreTypes.PhpTypeAttributeFullName)
                {
                    var args = a.CommonConstructorArguments;
                    typename = (string)args[0].Value;
                    filename = (string)args[1].Value;
                    return(true);
                }
            }

            //
            typename = filename = null;
            return(false);
        }