Esempio n. 1
0
        string generateGetMethod(EntityIndexData data, string contextName)
        {
            var template = "";

            if (data.GetEntityIndexType() == "Entitas.EntityIndex")
            {
                template = GET_INDEX_TEMPLATE;
            }
            else if (data.GetEntityIndexType() == "Entitas.PrimaryEntityIndex")
            {
                template = GET_PRIMARY_INDEX_TEMPLATE;
            }
            else
            {
                return(getCustomMethods(data));
            }

            return(template
                   .Replace("${ContextName}", contextName)
                   .Replace("${IndexName}", data.GetHasMultiple()
                    ? data.GetEntityIndexName() + data.GetMemberName().UppercaseFirst()
                    : data.GetEntityIndexName())
                   .Replace("${IndexType}", data.GetEntityIndexType())
                   .Replace("${KeyType}", data.GetKeyType())
                   .Replace("${MemberName}", data.GetMemberName()));
        }
Esempio n. 2
0
 string getCustomMethods(EntityIndexData data)
 {
     return(string.Join("\n", data.GetCustomMethods()
                        .Select(m => CUSTOM_METHOD_TEMPLATE
                                .Replace("${ReturnType}", m.returnType)
                                .Replace("${MethodName}", m.methodName)
                                .Replace("${ContextName}", data.GetContextNames()[0])
                                .Replace("${methodArgs}", string.Join(", ", m.parameters.Select(p => p.type + " " + p.name).ToArray()))
                                .Replace("${IndexType}", data.GetEntityIndexType())
                                .Replace("${IndexName}", data.GetHasMultiple()
                 ? data.GetEntityIndexName() + data.GetMemberName().UppercaseFirst()
                 : data.GetEntityIndexName())
                                .Replace("${args}", string.Join(", ", m.parameters.Select(p => p.name).ToArray()))).ToArray()));
 }
Esempio n. 3
0
 string generateMethods(EntityIndexData data, string contextName)
 {
     return(ADD_INDEX_TEMPLATE
            .Replace("${contextName}", contextName.LowercaseFirst())
            .Replace("${ContextName}", contextName)
            .Replace("${IndexName}", data.GetHasMultiple()
             ? data.GetEntityIndexName() + data.GetMemberName().UppercaseFirst()
             : data.GetEntityIndexName())
            .Replace("${Matcher}", data.GetEntityIndexName())
            .Replace("${IndexType}", data.GetEntityIndexType())
            .Replace("${KeyType}", data.GetKeyType())
            .Replace("${ComponentType}", data.GetComponentType())
            .Replace("${MemberName}", data.GetMemberName())
            .Replace("${componentName}", data.GetComponentType().ToComponentName(_ignoreNamespacesConfig.ignoreNamespaces).LowercaseFirst()));
 }
 string generateCustomMethods(EntityIndexData data)
 {
     return(ADD_CUSTOMINDEX_TEMPLATE
            .Replace("${context}", data.GetContextNames()[0].LowercaseFirst())
            .Replace("${Name}", data.GetEntityIndexName())
            .Replace("${IndexType}", data.GetEntityIndexType()));
 }
 string getCustomMethods(EntityIndexData data)
 {
     return(string.Join("\n", data.GetCustomMethods()
                        .Select(m => CUSTOM_METHOD_TEMPLATE
                                .Replace("${ReturnType}", m.ReturnType.ToCompilableString())
                                .Replace("${MethodName}", m.Name)
                                .Replace("${ContextName}", data.GetContextNames()[0])
                                .Replace("${methodArgs}", string.Join(", ", m.GetParameters().Select(p => p.ParameterType.ToCompilableString() + " " + p.Name).ToArray()))
                                .Replace("${IndexType}", data.GetEntityIndexType())
                                .Replace("${IndexName}", data.GetEntityIndexName())
                                .Replace("${args}", string.Join(", ", m.GetParameters().Select(p => p.Name).ToArray()))).ToArray()));
 }
 string generateMethods(EntityIndexData data, string contextName)
 {
     return(ADD_INDEX_TEMPLATE
            .Replace("${contextName}", contextName.LowercaseFirst())
            .Replace("${ContextName}", contextName)
            .Replace("${IndexName}", data.GetEntityIndexName())
            .Replace("${IndexType}", data.GetEntityIndexType())
            .Replace("${KeyType}", data.GetKeyType())
            .Replace("${ComponentType}", data.GetComponentType())
            .Replace("${MemberName}", data.GetMemberName())
            .Replace("${componentName}", data.GetComponentType().ToComponentName().LowercaseFirst()));
 }
 private string GenerateMethods(EntityIndexData data, string contextName)
 {
     return(ADD_INDEX_TEMPLATE
            .Replace("${contextName}", contextName)
            .Replace("${ContextName}", contextName)
            .Replace(
                "${IndexName}",
                data.GetHasMultiple()
                                         ? data.GetEntityIndexName() + data.GetMemberName().UppercaseFirst()
                                         : data.GetEntityIndexName())
            .Replace("${Matcher}", data.GetEntityIndexName())
            .Replace("${IndexType}", data.GetEntityIndexType())
            .Replace("${KeyType}", data.GetKeyType())
            .Replace("${ComponentType}", data.GetComponentType())
            .Replace("${MemberName}", data.GetMemberName())
            .Replace(
                "${componentName}",
                data.GetComponentType()
                .ToComponentName()
                .LowercaseFirst()
                .AddPrefixIfIsKeyword()));
 }
        string generateGetMethod(EntityIndexData data, string contextName)
        {
            var template = "";

            if (data.GetEntityIndexType() == "QFramework.EntityIndex")
            {
                template = GET_INDEX_TEMPLATE;
            }
            else if (data.GetEntityIndexType() == "QFramework.PrimaryEntityIndex")
            {
                template = GET_PRIMARY_INDEX_TEMPLATE;
            }
            else
            {
                return(getCustomMethods(data));
            }

            return(template
                   .Replace("${ContextName}", contextName)
                   .Replace("${IndexName}", data.GetEntityIndexName())
                   .Replace("${IndexType}", data.GetEntityIndexType())
                   .Replace("${KeyType}", data.GetKeyType())
                   .Replace("${MemberName}", data.GetMemberName()));
        }