Exemplo n.º 1
0
        private string Include(string argStr)
        {
            Match match = args.Match(argStr);

            //m_log.DebugFormat("Match {0} args? {1} {2}", args.ToString(), match.Success, match.Groups.Count);
            if (match.Groups.Count == 3)
            {
                string name  = match.Groups[1].Value;
                string value = match.Groups[2].Value;
                // ignore the name which should be file
                string file = m_WebApp.LocalizePath(m_Env, value);
                //m_log.DebugFormat("[WifiScript]: Including file {0} with index = {1} (previous file is {2})", file, m_Index, m_FileName);

                string content = string.Empty;
                using (StreamReader sr = new StreamReader(file))
                {
                    if (file == m_FileName)
                    {
                        m_Index++;
                        if (m_ListOfObjects != null)
                        {
                            if (m_Index >= m_ListOfObjects.Count)
                            {
                                return(string.Empty);
                            }
                        }

                        content = sr.ReadToEnd();
                    }
                    else
                    {
                        string oldFile = m_FileName;
                        m_FileName = file;
                        List <object> nextLoo = m_ListOfObjects;
                        if (m_ListOfObjects != null && m_Index < m_ListOfObjects.Count - 1)
                        {
                            m_Index++;
                            if (m_ListOfObjects[m_Index] is List <object> )
                            {
                                //if (IsGenericList(m_ListOfObjects[m_Index].GetType()))
                                nextLoo = (List <object>)m_ListOfObjects[m_Index];
                            }
                        }
                        Processor p = new Processor(m_WebApp, m_ExtensionMethods, m_Env, nextLoo);
                        //Processor p = new Processor(m_WebApp, m_ExtensionMethods, m_Env, m_ListOfObjects);
                        string result = p.Process(sr.ReadToEnd());
                        m_FileName = oldFile;
                        return(result);
                    }
                }

                // recurse!
                if (!string.IsNullOrEmpty(content))
                {
                    return(Process(content));
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        private string Include(string argStr)
        {
            Match match = args.Match(argStr);

            //m_log.DebugFormat("Match {0} args? {1} {2}", args.ToString(), match.Success, match.Groups.Count);
            if (match.Groups.Count == 3)
            {
                string name  = match.Groups[1].Value;
                string value = match.Groups[2].Value;
                // ignore the name which should be file
                string file = m_WebApp.LocalizePath(m_Env, value);
                //m_log.DebugFormat("[WifiScript]: Including file {0} with index = {1} (previous file is {2})", file, m_Index, m_FileName);

                using (StreamReader sr = new StreamReader(file))
                {
                    if (file == m_FileName)
                    {
                        m_Index++;
                        if (m_ListOfObjects != null)
                        {
                            if (m_Index >= m_ListOfObjects.Count)
                            {
                                return(string.Empty);
                            }
                        }

                        // recurse!
                        return(Process(sr.ReadToEnd()));
                    }
                    else
                    {
                        m_FileName = file;
                        Processor p = new Processor(m_WebApp, m_ExtensionMethods, m_Env, m_ListOfObjects);
                        return(p.Process(sr.ReadToEnd()));
                    }
                }
            }

            return(string.Empty);
        }