Exemplo n.º 1
0
        private static void InitCSharpRuntime()
        {
            var csharpPairs = _watcherDict.Where(pair => !pair.Value.IsPython)
                              .OrderByDescending(t => t.Value.CompileLevel).ToList();

            foreach (var pair in csharpPairs)
            {
                string name = pair.Key;
                if (Directory.Exists(pair.Value.Path))
                {
                    var files = Directory.GetFiles(pair.Value.Path, pair.Value.Filter, SearchOption.AllDirectories);
                    foreach (var fileName in files)
                    {
                        LoadScript(fileName);
                    }
                    UpdateAssembly(name, files, pair.Value);
                    TraceLog.ReleaseWrite("CSharp {0} script successfully compiled.", name);
                }
            }
        }
Exemplo n.º 2
0
        private static void TickCallback(object state)
        {
            try
            {
                HashSet <string> tmp  = new HashSet <string>();
                var localChangedFiles = Interlocked.Exchange <HashSet <string> >(ref _changedFiles, tmp);
                var changeDirs        = new Dictionary <string, FileWatcherInfo>();
                foreach (var fileName in localChangedFiles)
                {
                    var script = LoadScript(fileName);
                    if (script != null &&
                        script is CSharpFileInfo &&
                        !string.IsNullOrEmpty(script.GroupName) &&
                        _watcherDict.ContainsKey(script.GroupName))
                    {
                        changeDirs[script.GroupName] = _watcherDict[script.GroupName];
                    }
                }

                var paris = changeDirs.OrderByDescending(t => t.Value.CompileLevel).ToList();
                foreach (var changeDir in paris)
                {
                    string name       = changeDir.Key;
                    var    srciptList = _scriptCodeCache.Where(pair => pair.Value.GroupName == name);
                    var    filenames  = srciptList.Select(t => t.Value.FileName).ToArray();
                    UpdateAssembly(name, filenames, changeDir.Value);
                    foreach (var pair in srciptList)
                    {
                        pair.Value.ObjType = null;
                    }
                }
                if (paris.Count > 0)
                {
                    InitPythonRuntime(true);
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("TickCallback error:{0}", ex);
            }
        }