private int GetOutputSize(bool primary)
 {
     using (var stream = new NullStream())
     {
         using (var writer = new GenWriter(stream))
         {
             if (primary)
             {
                 GenFragmentGenerator.Generate(GenDataDef, writer, GenObject, Fragment);
             }
             else
             {
                 GenFragmentGenerator.GenerateSecondary(GenDataDef, writer, GenObject, Fragment);
             }
             writer.Flush();
             return((int)writer.Stream.Length);
         }
     }
 }
        private string ExpandSecondary()
        {
            var outputSize = GetOutputSize(false);

            if (outputSize == 0)
            {
                return("");
            }
            using (var stream = new MemoryStream(outputSize))
            {
                using (var writer = new GenWriter(stream))
                {
                    GenFragmentGenerator.GenerateSecondary(GenDataDef, writer, GenObject, Fragment);
                    writer.Flush();
                    stream.Seek(0, SeekOrigin.Begin);
                    using (var reader = new StreamReader(stream))
                        return(reader.ReadToEnd());
                }
            }
        }
Esempio n. 3
0
 public void Generate(GenDataBase genDataBase, GenWriter genWriter)
 {
     GenFragmentGenerator.Generate(genDataBase.GenDataDef, genWriter, genDataBase.Root, Profile);
 }