public void WriteText(Stream stream, IMacroExpander macro = null)
 {
     using (StreamReader reader = new StreamReader(stream))
     {
         WriteText(reader.ReadToEnd(), macro);
     }
 }
        public void WriteText(Assembly assembly, string ressourceId, IMacroExpander macro = null)
        {
            string assemblyName = assembly.GetName().Name;

            if (!ressourceId.StartsWith(assemblyName))
            {
                ressourceId = String.Format("{0}.{1}", assemblyName, ressourceId);
            }
            using (Stream stream = assembly.GetManifestResourceStream(ressourceId))
            {
                WriteText(stream, macro);
            }
        }
 public void WriteText(string text, IMacroExpander macro = null)
 {
     string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
     foreach (string line in lines)
     {
         if (macro != null)
         {
             WriteLine(macro.Subst(line));
         }
         else
         {
             WriteLine(line);
         }
     }
 }
        private void ProcessPrimaryKey(MetaInfoTable table)
        {
            metaProvider.GetPrimaryKey(table);
            if (table.PrimaryKey != null)
            {
                XmlNode pkNode = md.CreateElement("PrimaryId");
                if (table.PrimaryKey.Columns.Count > 1)
                {
                    md.AddAttribute("name", table.PrimaryKey.Name);
                }
                md.AddAttribute("persistentName", table.PrimaryKey.PersistentName);
                foreach (MetaInfoColumn col in table.PrimaryKey.Columns)
                {
                    md.CreateElement("OnAttribute");
                    md.AddAttribute("name", col.Name);
                    pkNode.AppendChild(md.CurrentNode);
                }

                // Try to attach generator by name
                if (table.PrimaryKey.Columns.Count == 1)
                {
                    IMacroExpander macro = Genie.Config.Macro.CreateChild();
                    macro.SetMacro("%TABLE%", table.Name);
                    string            generatorTemplate = PersistenceLayerConfig.NamingConvention.Params.ValueByName("Generator.Template", "%TABLE%");
                    MetaInfoGenerator gen = Generators.FindByName(table.Schema, macro.Subst(generatorTemplate), false);
                    if (gen == null)
                    {
                        macro.SetMacro("%TABLE%", table.PersistentName);
                        gen = Generators.FindByPersistentName(table.PersistentSchema, macro.Subst(generatorTemplate), false);
                    }
                    if (gen != null)
                    {
                        md.CurrentNode = pkNode;
                        md.AddAttribute("generator", gen.Name);
                        gen.Node = md.Document.DocumentElement.RemoveChild(gen.Node);
                        md.Document.DocumentElement.InsertBefore(gen.Node, table.Node);
                    }
                }

                table.Node.AppendChild(pkNode);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CSF.Zpt.Metal.MetalVisitor"/> class.
 /// </summary>
 /// <param name="expander">The macro expander to use.</param>
 public MetalVisitor(IMacroExpander expander = null)
 {
     _macroExpander = expander?? new MacroExpander();
 }
Beispiel #6
0
        private static void _reportException(MacroContext context, IMacroExpander expander,
            Exception e)
        {
            context.ReportMessage(Message.Create(MessageSeverity.Error,
                String.Format(
                    Resources.MacroSession_ExceptionDuringExpansionOfMacro,
                    expander.HumanId, context.Function.LogicalId,
                    e.Message), context.Invocation.Position, MessageClasses.ExceptionDuringCompilation));
#if DEBUG
            Console.WriteLine(e);
#endif
        }