Пример #1
0
        private static (string[] nameSemgents, string parameters) SplitToSegmentsAndParameters(
            this string token,
            PlaceholderConfig placeholderConfig,
            ITemplateConfig templateConfig,
            bool isOpen)
        {
            var prefixLength = placeholderConfig.Start.Length;

            if (!isOpen)
            {
                prefixLength += templateConfig.ClosePrefix.Length;
            }
            var suffixLength = placeholderConfig.End.Length;

            if (isOpen)
            {
                suffixLength += templateConfig.OpenSuffix.Length;
            }

            var(name, parameters) = token
                                    .Cut(prefixLength, suffixLength)
                                    .SplitBy(placeholderConfig.ParametersDelimiter);

            var segments = name.Split(placeholderConfig.NamesDelimiter);

            return(segments, parameters);
        }
Пример #2
0
    /// <summary>
    /// Get the config instance for the namespace. </summary>
    /// <param name="namespaces"> the namespaces of the config, order desc. </param>
    /// <returns> config instance </returns>
    public static async Task <IConfig> GetConfig(IEnumerable <string> namespaces)
    {
        if (namespaces == null)
        {
            throw new ArgumentNullException(nameof(namespaces));
        }
#if NET40
        var configs = await TaskEx.WhenAll(namespaces.Reverse().Distinct().Select(GetConfig)).ConfigureAwait(false);
#else
        var configs = await Task.WhenAll(namespaces.Reverse().Distinct().Select(GetConfig)).ConfigureAwait(false);
#endif
        if (configs.Length < 1)
        {
            throw new ArgumentException("namespaces not allow empty");
        }

        var config = configs.Length == 1 ? configs[0] : new MultiConfig(configs);

        if (ConfigEnablePlaceholder)
        {
            config = new PlaceholderConfig(config);
        }

        return(config);
    }
Пример #3
0
 public EngineConfig(
     PlaceholderConfig placeholder,
     ArrayConfig arrayConfig,
     ConditionConfig condition)
 {
     this.Placeholder = placeholder;
     this.Array       = arrayConfig;
     this.Condition   = condition;
 }