private EntityIndexData CreateCustomEntityIndexData(ICachedNamedTypeSymbol cachedNamedTypeSymbol)
        {
            var data        = new EntityIndexData();
            var attribute   = cachedNamedTypeSymbol.GetAttributes(nameof(CustomEntityIndexAttribute)).Single();
            var contextType = (ITypeSymbol)attribute.ConstructorArguments[0].Value;

            var fullTypeName = cachedNamedTypeSymbol.FullTypeName;

            data.SetEntityIndexType(fullTypeName);
            data.IsCustom(true);
            data.SetEntityIndexName(fullTypeName.RemoveDots());
            data.SetHasMultiple(false);
            data.SetContextNames(
                new[]
            {
                contextType.GetFullTypeName().ShortTypeName().RemoveContextSuffix()
            });

            var getMethods = cachedNamedTypeSymbol
                             .NamedTypeSymbol
                             .GetAllMembers()
                             .Where(method => method.HasAttribute <EntityIndexGetMethodAttribute>())
                             .Select(
                method => new MethodData(
                    method.GetReturnType().GetFullTypeName(),
                    method.Name,
                    method.GetParameters()
                    .Select(p => new MemberData(p.Type.GetFullTypeName(), p.Name))
                    .ToArray()))
                             .ToArray();

            data.SetCustomMethods(getMethods);

            return(data);
        }
        public void Provide(ICachedNamedTypeSymbol cachedNamedTypeSymbol, ComponentData data)
        {
            var attrs = cachedNamedTypeSymbol.GetAttributes(nameof(EventAttribute)).ToArray();

            if (attrs.Any())
            {
                data.IsEvent(true);
                var eventData = attrs
                                .Select(attr =>
                {
                    var args = attr.ConstructorArguments;
                    return(new EventData(
                               (EventTarget)args[0].Value,
                               (EventType)args[1].Value,
                               (int)args[2].Value));
                })
                                .ToArray();

                data.SetEventData(eventData);
            }
            else
            {
                data.IsEvent(false);
            }
        }
示例#3
0
        private bool GetGenerateIndex(ICachedNamedTypeSymbol cachedNamedTypeSymbol)
        {
            var attr = cachedNamedTypeSymbol
                       .GetAttributes(nameof(DontGenerateAttribute))
                       .FirstOrDefault();

            return(attr == null || (bool)attr.ConstructorArguments[0].Value);
        }
示例#4
0
        public void Provide(ICachedNamedTypeSymbol cachedNamedTypeSymbol, ComponentData data)
        {
            var attributes = cachedNamedTypeSymbol
                             .GetAttributes(nameof(CleanupAttribute))
                             .ToArray();

            if (attributes.Any())
            {
                var cleanupData = attributes
                                  .Select(x => x.ConstructorArguments[0].Value)
                                  .Cast <CleanupMode>()
                                  .ToArray();

                data.SetCleanupData(cleanupData);
            }
        }
示例#5
0
        private string[] GetComponentNames(ICachedNamedTypeSymbol namedTypeSymbol)
        {
            // if there are not any
            var componentAttrTypeSymbols = namedTypeSymbol.GetAttributes(nameof(ComponentNameAttribute));

            if (!componentAttrTypeSymbols.Any())
            {
                var componentNames = new[]
                {
                    namedTypeSymbol.TypeName
                };

                return(componentNames);
            }

            return(componentAttrTypeSymbols
                   .SelectMany(x => x.ConstructorArguments)
                   .SelectMany(x => x.Values)
                   .Select(x => x.Value.ToString())
                   .ToArray());
        }
        public void Provide(ICachedNamedTypeSymbol cachedNamedTypeSymbol, ComponentData data)
        {
            var isUnique = cachedNamedTypeSymbol.GetAttributes(nameof(UniqueAttribute)).Any();

            data.IsUnique(isUnique);
        }
示例#7
0
        private string GetFlagPrefix(ICachedNamedTypeSymbol cachedNamedTypeSymbol)
        {
            var attr = cachedNamedTypeSymbol.GetAttributes(nameof(FlagPrefixAttribute)).SingleOrDefault();

            return(attr == null ? "is" : attr.ConstructorArguments[0].Value?.ToString());
        }
        public void Provide(ICachedNamedTypeSymbol cachedNamedTypeSymbol, ComponentData data)
        {
            var generate = !cachedNamedTypeSymbol.GetAttributes(nameof(DontGenerateAttribute)).Any();

            data.ShouldGenerateMethods(generate);
        }