CloakedHipster.Conventions.GetTargetType C# (CSharp) Method

GetTargetType() public method

public GetTargetType ( string name ) : string
name string
return string
        public string GetTargetType(string name)
        {
            foreach (var convention in conventions)
            {
                if (name.Contains(convention.Key))
                {
                    return convention.Value;
                }
            }

            return string.Empty;
        }

Usage Example

コード例 #1
0
        public string Process(string input, Conventions conventions)
        {
            var styles = process.Parse(input);
            var styleBuilder = new StringBuilder();

            foreach (var style in styles)
            {
                var setterBuilder = new StringBuilder();

                foreach (var mapper in mappers)
                {
                    if (!mapper.IsMatch(style))
                        continue;

                    var result = mapper.Process(style);

                    setterBuilder.AppendLine();
                    setterBuilder.AppendFormat(setterTemplate, result.Item1, result.Item2);
                }

                setterBuilder.AppendLine();
                var type = conventions.GetTargetType(style.Name);
                var targetType = "";
                if (!string.IsNullOrWhiteSpace(type))
                {
                    targetType = string.Format(" TargetType=\"{0}\"", type);
                }

                styleBuilder.AppendFormat(styleTemplate, style.Name, setterBuilder, targetType);
                styleBuilder.AppendLine();
            }

            return styleBuilder.ToString();
        }