Пример #1
0
        public override void Emit(ITemplateSet templateSet, System.IO.StreamWriter writer)
        {
            string comp = string.Empty;

            for (int i = 0; i < conditions.Length; i++)
            {
                if (comp != string.Empty)
                {
                    comp += " ";
                }
                comp += conditions[i];
            }

            bool satisfied = true;

            for (int i = 0; i < conditions.Length; i++)
            {
                if (templateSet.Provide(conditions[i]) == null)
                {
                    satisfied = false;
                    break;
                }
            }

            if (satisfied)
            {
                writer.WriteLine("//#ifdef {0}", comp);

                for (int i = 0; i < nodes.Length; i++)
                {
                    if (nodes[i] is ElseNode)
                    {
                        break;
                    }
                    nodes[i].Emit(templateSet, writer);
                }

                writer.Write("//#endif");
            }
            else
            {
                int i;
                for (i = 0; i < nodes.Length; i++)
                {
                    if (nodes[i] is ElseNode)
                    {
                        break;
                    }
                }

                for (; i < nodes.Length; i++)
                {
                    nodes[i].Emit(templateSet, writer);
                }
            }
        }
Пример #2
0
        public void Emit(ITemplateSet templateSet, System.IO.StreamWriter writer)
        {
            object obj = templateSet.Provide(reference);

            if (obj == null)
            {
                throw new Exception(string.Format("Missing reference {0}", reference));
            }

            writer.Write(obj.ToString());
        }
Пример #3
0
        public override void Emit(ITemplateSet templateSet, System.IO.StreamWriter writer)
        {
            object ttarget = templateSet.Provide(templateTarget);

            if (ttarget is ITemplateSet)
            {
                ITemplateSet target = ttarget as ITemplateSet;


                foreach (string s in target.Available)
                {
                    ITemplateSet set = target.Provide(s) as ITemplateSet;

                    writer.WriteLine();
                    writer.WriteLine("\t\t//#foreach instanced to '{0}'", set.Name);
                    base.Emit(set, writer);
                    writer.WriteLine("//#endfor instanced to '{0}'", set.Name);
                }
            }
            else
            {
                Console.WriteLine("Error: could not resolve target '{0}' as ITemplateSet", templateTarget);
            }
        }
Пример #4
0
 public object Provide(string name)
 {
     return(resolved.Provide(name));
 }