Пример #1
0
        public static StatementExecutable CreateExecutable(string[] domainIDAccessTree, string statementBlockID, string statement, bool parametric, bool cache)
        {
            Loader.Initialize(() => {
                Application.Dispose();
                StatementFactory.Dispose();
            });

            try
            {
                string blockKey =
                    string.Format(
                        "BLOCKCALL_{0}_{1}",
                        string.Join<string>("_", domainIDAccessTree),
                        statementBlockID.Replace('.', '_')
                    );

                string executableName =
                    StatementFactory.Current.Get(blockKey, statement, parametric, cache);

                if (string.IsNullOrEmpty(executableName))
                    throw new Exception.GrammerException();

                return new StatementExecutable(executableName, blockKey, null);
            }
            catch (System.Exception ex)
            {
                return new StatementExecutable(string.Empty, string.Empty, ex);
            }
        }
Пример #2
0
        public static Application Prepare(string executableName)
        {
            Loader.Initialize(() => {
                Application.Dispose();
                StatementFactory.Dispose();
            });

            string applicationKey =
                string.Format("KEY-{0}_{1}", Loader.Current.Path, executableName);

            Application application;

            if (!Application._ApplicationCache.TryGetValue(applicationKey, out application))
            {
                application = new Application(executableName);
                application.AddSearchPath(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                application.AddSearchPath(Loader.Current.Path);

                if (!application.Load())
                {
                    Loader.Reload();
                    return(Application.Prepare(executableName));
                }

                if (!Application._ApplicationCache.TryAdd(applicationKey, application))
                {
                    return(Application.Prepare(executableName));
                }
            }

            return(application);
        }
Пример #3
0
 public static void ClearCache()
 {
     Application.Dispose();
     StatementFactory.Dispose();
 }