コード例 #1
0
        private void AddMatch(string outputPath, string templatePath, ViewData data, Namespace ns, DeclaredType type)
        {
            var clone = data.Clone();

            clone.Type = type;

            AddMatch(outputPath, templatePath, clone, ns);
        }
コード例 #2
0
        private void AddMatch(string outputPath, string templatePath, ViewData data, Namespace ns)
        {
            var clone = data.Clone();

            clone.Namespace = ns;

            AddMatch(outputPath, templatePath, clone);
        }
コード例 #3
0
        private void AddMatch(string outputPath, string templatePath, ViewData data)
        {
            var path = outputPath.Replace(".spark", ".htm");
            var clone = data.Clone();

            if (clone.Types.Count == 0)
                clone.Types = (from n in data.Namespaces from t in n.Types select t).ToList();

            matches.Add(new TemplateMatch(path, templatePath, clone));
        }
コード例 #4
0
        private IList<TemplateMatch> ResolveRecursive(string current, string outputPath, string templatePath, IEnumerable<Namespace> namespaces, ViewData data)
        {
            if (Path.GetExtension(current) == ".spark")
            {
                if (current == "!namespace.spark")
                {
                    foreach (var ns in namespaces)
                    {
                        AddMatch(outputPath.Replace("!namespace", ns.Name), templatePath, data, ns);
                    }
                }
                else if (current == "!type.spark")
                {
                    var foundTypes = from n in namespaces
                                     from t in n.Types
                                     select new { Type = t, Namespace = n };
                    foreach (var found in foundTypes)
                    {
                        string name = HACK_inNamespace ? found.Type.Name : found.Namespace.Name + "." + found.Type.Name;

                        AddMatch(outputPath.Replace("!type", name), templatePath, data, found.Namespace, found.Type);
                    }
                }
                else
                    AddMatch(outputPath, templatePath, data);
            }
            else
            {
                if (!IsSpecial(current))
                {
                    string[] parts = templatePath.Substring(templatePath.IndexOf(current) + current.Length).Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

                    ResolveRecursive(parts[0], templatePath, templatePath, namespaces, data.Clone());
                }
                else if (current == "!namespace")
                {
                    string[] parts = templatePath.Substring(templatePath.IndexOf(current) + current.Length).Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

                    HACK_inNamespace = false;

                    foreach (var ns in namespaces)
                    {
                        string nsPath = templatePath.Replace(current, ns.Name);

                        HACK_inNamespace = true;

                        var clone = data.Clone();

                        clone.Namespace = ns;

                        ResolveRecursive(parts[0], nsPath, templatePath, new List<Namespace> { ns }, clone);
                    }

                    HACK_inNamespace = false;
                }
                else if (current == "!type")
                {
                    string[] parts = templatePath.Replace(current, "").Split(new[] { '\\' },
                                                                             StringSplitOptions.RemoveEmptyEntries);

                    foreach (var found in from n in namespaces
                                          from t in n.Types
                                          select new { Type = t, Namespace = n })
                    {
                        string typePath = templatePath.Replace(current, found.Namespace.Name + "." + found.Type.Name);

                        var clone = data.Clone();

                        clone.Namespace = found.Namespace;
                        clone.Type = found.Type;

                        ResolveRecursive(parts[0], typePath, templatePath, new List<Namespace> { found.Namespace }, clone);
                    }
                }
            }

            return matches;
        }
コード例 #5
0
        private void ResolveNamespaceDirectory(string head, IList<string> tail, string templatePath, IEnumerable<Namespace> namespaces, ViewData data)
        {
            HACK_inNamespace = false;

            foreach (var ns in namespaces)
            {
                string nsPath = templatePath.Replace(head, ns.Name);

                HACK_inNamespace = true;

                var clone = data.Clone();

                clone.Namespace = ns;

                ResolveRecursive(tail[0], tail.ToTail(), nsPath, templatePath, new List<Namespace> { ns }, clone);
            }

            HACK_inNamespace = false;
        }
コード例 #6
0
 private void ResolveDirectory(string head, string templatePath, IEnumerable<Namespace> namespaces, ViewData data, IList<string> tail)
 {
     if (!IsSpecial(head))
         ResolveRecursive(tail[0], tail.ToTail(), templatePath, templatePath, namespaces, data.Clone());
     else if (head == "!namespace")
         ResolveNamespaceDirectory(head, tail, templatePath, namespaces, data);
     else if (head == "!type")
         ResolveTypeDirectory(head, tail, templatePath, namespaces, data);
 }
コード例 #7
0
        private void ResolveTypeDirectory(string head, IList<string> tail, string templatePath, IEnumerable<Namespace> namespaces, ViewData data)
        {
            foreach (var found in from n in namespaces
                                  from t in n.Types
                                  select new { Type = t, Namespace = n })
            {
                string typePath = templatePath.Replace(head, found.Namespace.Name + "." + found.Type.Name);

                var clone = data.Clone();

                clone.Namespace = found.Namespace;
                clone.Type = found.Type;

                ResolveRecursive(tail[0], tail.ToTail(), typePath, templatePath, new List<Namespace> { found.Namespace }, clone);
            }
        }