Beispiel #1
0
        public void TemplateChunkGenerate(string ArrayName)
        {
            if (InTemplateChunk)
            {
                throw new Exception("Exit template chunk before generating");
            }

            if (Data.GetObject(ArrayName, null, out object Obj) != DataType.Array)
            {
                throw new Exception(string.Format("Object '{0}' is not array", ArrayName));
            }

            JArray ObjArray = (JArray)Obj;
            int    Length   = NodeCount = ObjArray.Count;

            Data.UseSpecialObjectHook(GetSpecialObject, () => {
                for (int i = 0; i < Length; i++)
                {
                    NodeIndex = i;

                    JObject IndexedObj = (JObject)ObjArray[i];
                    Data.UseRootObject(IndexedObj, () => {
                        foreach (var El in TemplateChunk)
                        {
                            OpenXmlElement Clone = (OpenXmlElement)El.Clone();
                            Clone = TemplateChunkBody.AppendChild(Clone);

                            Processor.Process(TemplateChunkBody, Clone);
                        }
                    });
                }
            });
        }