Esempio n. 1
0
        EntityIndexData createEntityIndexData(Type type, List <PublicMemberInfo> infos)
        {
            var data = new EntityIndexData();

            var info      = infos.Single(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1);
            var attribute = (AbstractEntityIndexAttribute)info.attributes.Single(attr => attr.attribute is AbstractEntityIndexAttribute).attribute;

            data.SetEntityIndexType(getEntityIndexType(attribute));
            data.IsCustom(false);
            data.SetEntityIndexName(type.ToCompilableString().RemoveComponentSuffix().RemoveDots());
            data.SetKeyType(info.type.ToCompilableString());
            data.SetComponentType(type.ToCompilableString());
            data.SetComponentName(type.ToCompilableString().ShortTypeName().RemoveComponentSuffix());
            data.SetMemberName(info.name);

            var contextNames = ContextsComponentDataProvider.GetContextNames(type);

            if (contextNames.Length == 0)
            {
                contextNames = new [] { _defaultContextName };
            }
            data.SetContextNames(contextNames);

            return(data);
        }
Esempio n. 2
0
        private EntityIndexData[]               createEntityIndexData(INamedTypeSymbol type, List <ISymbol> infos)
        {
            var hasMultiple = infos.Count(i => i.CountAttribute(typeof(AbstractEntityIndexAttribute)) == 1) > 1;

            return(infos
                   .Where(i => i.CountAttribute(typeof(AbstractEntityIndexAttribute)) == 1)
                   .Select(info => {
                var data = new EntityIndexData();
                var attribute = info.GetAttribute(typeof(AbstractEntityIndexAttribute));
                var entityIndexType = GetEntityIndexType(attribute.AttributeClass);
                var typeName = (info is IFieldSymbol fieldSymbol)
                                                ? fieldSymbol.Type.ToDisplayString(  )
                                                : (info is IPropertySymbol symbol)
                                                        ? symbol.Type.ToDisplayString(  )
                                                        : null;

                data.SetEntityIndexType(entityIndexType.ToString(  ));
                data.IsCustom(false);
                data.SetEntityIndexName(type.ToString().ToComponentName(_contexts.Get <Settings>().Is <IgnoreNamespaces>()));
                data.SetKeyType(typeName);
                data.SetComponentType(type.ToString(  ));
                data.SetMemberName(info.Name);
                data.SetHasMultiple(hasMultiple);
                data.SetContextNames(type.GetContextNames(  ).ToArray(  ));

                return data;
            }).ToArray());
        }
        private EntityIndexData[] CreateEntityIndexData(ICachedNamedTypeSymbol cachedNamedTypeSymbol, IEnumerable <MemberData> memberData)
        {
            var hasMultiple = memberData
                              .Count(i => i.memberFieldSymbol.GetAttributes()
                                     .HasAttribute(nameof(AbstractEntityIndexAttribute), canInherit: true)) > 1;

            return(memberData
                   .Where(i => i.memberFieldSymbol.GetAttributes()
                          .HasAttribute(nameof(AbstractEntityIndexAttribute), canInherit: true))
                   .Select(
                       info =>
            {
                var data = new EntityIndexData();
                var attribute = info.memberFieldSymbol.GetAttributes()
                                .GetAttributes(nameof(AbstractEntityIndexAttribute), canInherit: true)
                                .Single();

                data.SetEntityIndexType(GetEntityIndexType(attribute));
                data.IsCustom(false);
                data.SetEntityIndexName(cachedNamedTypeSymbol.FullTypeName.ToComponentName());
                data.SetKeyType(info.compilableTypeString);
                data.SetComponentType(cachedNamedTypeSymbol.FullTypeName);
                data.SetMemberName(info.name);
                data.SetHasMultiple(hasMultiple);
                data.SetContextNames(_contextsComponentDataProvider.GetContextNamesOrDefault(cachedNamedTypeSymbol));

                return data;
            })
                   .ToArray());
        }
Esempio n. 4
0
        private EntityIndexData[] CreateEntityIndexData(Type type, List <PublicMemberInfo> infos)
        {
            var hasMultiple = infos.Count(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1) >
                              1;

            return(infos
                   .Where(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1)
                   .Select(
                       info =>
            {
                var data = new EntityIndexData();
                var attribute = (AbstractEntityIndexAttribute)info.attributes
                                .Single(attr => attr.attribute is AbstractEntityIndexAttribute)
                                .attribute;

                data.SetEntityIndexType(GetEntityIndexType(attribute));
                data.IsCustom(false);
                data.SetEntityIndexName(type.ToCompilableString().ToComponentName());
                data.SetKeyType(info.type.ToCompilableString());
                data.SetComponentType(type.ToCompilableString());
                data.SetMemberName(info.name);
                data.SetHasMultiple(hasMultiple);
                data.SetContextNames(_contextsComponentDataProvider.GetContextNamesOrDefault(type));

                return data;
            })
                   .ToArray());
        }
        EntityIndexData createEntityIndexData(Type type, List <PublicMemberInfo> infos)
        {
            var data = new EntityIndexData();

            var info      = infos.Single(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1);
            var attribute = (AbstractEntityIndexAttribute)info.attributes.Single(attr => attr.attribute is AbstractEntityIndexAttribute).attribute;

            data.SetEntityIndexType(getEntityIndexType(attribute));
            data.IsCustom(false);
            data.SetEntityIndexName(type.ToCompilableString().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces));
            data.SetKeyType(info.type.ToCompilableString());
            data.SetComponentType(type.ToCompilableString());
            data.SetMemberName(info.name);
            data.SetContextNames(_contextsComponentDataProvider.GetContextNamesOrDefault(type));

            return(data);
        }
Esempio n. 6
0
        private EntityIndexData[]               createEntityIndexData(Type type, List <PublicMemberInfo> infos)
        {
            var hasMultiple = infos.Count(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1) > 1;

            return(infos
                   .Where(i => i.attributes.Count(attr => attr.attribute is AbstractEntityIndexAttribute) == 1)
                   .Select(info => {
                var data = new EntityIndexData();
                var attribute = (AbstractEntityIndexAttribute)info.attributes.Single(attr => attr.attribute is AbstractEntityIndexAttribute).attribute;

                data.SetEntityIndexType(getEntityIndexType(attribute));
                data.IsCustom(false);
                data.SetEntityIndexName(type.ToCompilableString().ToComponentName(_contexts.settings.isIgnoreNamespaces));
                data.SetKeyType(info.type.ToCompilableString());
                data.SetComponentType(type.ToCompilableString());
                data.SetMemberName(info.name);
                data.SetHasMultiple(hasMultiple);
                data.SetContextNames(ReflectionToCompsSystem.TypeToContextNames[type].ToArray(  ));

                return data;
            }).ToArray());
        }