Example #1
0
        public InterfaceGroup InterfaceMapping(SpecInterfaceGroup prototype)
        {
            InterfaceGroup group = new InterfaceGroup(prototype);

            foreach (var map in interfaceMaps)
            {
                var match = map.Match(prototype.Name);
                if (!match.Success)
                {
                    continue;
                }
                group.Namespace = match.Result(map.Namespace);
                var classChain = match.Result(map.Class);
                if (classChain.Contains("::"))
                {
                    group.Class = classChain.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    group.Class = new[] { classChain };
                }
                group.FileOutput = match.Result(map.FileOutput);
                if (map.CamelCase)
                {
                    group.Namespace = group.Namespace.ToCamelCase();
                    for (int i = 0; i < group.Class.Length; i++)
                    {
                        var value = group.Class[i].ToCamelCase();
                        if (value.Length > 0 && char.IsDigit(value[0]))
                        {
                            value = "_" + value;
                        }
                        group.Class[i] = value;
                    }
                    group.FileOutput =
                        Path.GetFileNameWithoutExtension(group.FileOutput).ToCamelCase()
                        + Path.GetExtension(group.FileOutput);
                }
                else
                {
                    for (int i = 0; i < group.Class.Length; i++)
                    {
                        var value = group.Class[i];
                        if (value.Length > 0 && char.IsDigit(value[0]))
                        {
                            value = "_" + value;
                        }
                        group.Class[i] = value;
                    }
                }
            }
            return(group);
        }
Example #2
0
 public InterfaceGroup(SpecInterfaceGroup group)
 {
     SpecGroup = group;
 }