コード例 #1
0
ファイル: CompilableFile.cs プロジェクト: RuanPitout88/Oxide
 internal virtual void OnCompilationStarted()
 {
     //Interface.Oxide.LogDebug("Compiling plugin: {0}", Name);
     LastCompiledAt = LastModifiedAt;
     timeoutTimer?.Destroy();
     timeoutTimer = timer.Once(60f, OnCompilationTimeout);
 }
コード例 #2
0
 internal void OnCompilationSucceeded(CompiledAssembly compiledAssembly)
 {
     if (timeoutTimer == null)
     {
         Interface.Oxide.LogWarning($"Ignored unexpected plugin compilation: {Name}");
         return;
     }
     timeoutTimer?.Destroy();
     timeoutTimer        = null;
     IsCompilationNeeded = false;
     CompilationQueuedAt = 0f;
     CompiledAssembly    = compiledAssembly;
     CompileCallback?.Invoke(true);
 }
コード例 #3
0
 internal void OnCompilationFailed()
 {
     if (timeoutTimer == null)
     {
         Interface.Oxide.LogWarning($"Ignored unexpected plugin compilation failure: {Name}");
         return;
     }
     timeoutTimer?.Destroy();
     timeoutTimer        = null;
     CompilationQueuedAt = 0f;
     LastCompiledAt      = default(DateTime);
     CompileCallback?.Invoke(false);
     IsCompilationNeeded = false;
 }
コード例 #4
0
ファイル: CompilableFile.cs プロジェクト: yas-online/Oxide
 internal void OnCompilationSucceeded(CompiledAssembly compiledAssembly)
 {
     if (timeoutTimer == null)
     {
         Interface.Oxide.LogWarning($"Ignored unexpected plugin compilation: {Name}");
         return;
     }
     timeoutTimer?.Destroy();
     timeoutTimer = null;
     IsCompilationNeeded = false;
     CompilationQueuedAt = 0f;
     CompiledAssembly = compiledAssembly;
     CompileCallback?.Invoke(true);
 }
コード例 #5
0
ファイル: CompilableFile.cs プロジェクト: yas-online/Oxide
 internal virtual void OnCompilationStarted()
 {
     //Interface.Oxide.LogDebug("Compiling plugin: {0}", Name);
     LastCompiledAt = LastModifiedAt;
     timeoutTimer?.Destroy();
     timeoutTimer = null;
     Interface.Oxide.NextTick(() =>
     {
         timeoutTimer?.Destroy();
         timeoutTimer = timer.Once(60f, OnCompilationTimeout);
     });
 }
コード例 #6
0
ファイル: CompilableFile.cs プロジェクト: yas-online/Oxide
 internal void OnCompilationFailed()
 {
     if (timeoutTimer == null)
     {
         Interface.Oxide.LogWarning($"Ignored unexpected plugin compilation failure: {Name}");
         return;
     }
     timeoutTimer?.Destroy();
     timeoutTimer = null;
     CompilationQueuedAt = 0f;
     LastCompiledAt = default(DateTime);
     CompileCallback?.Invoke(false);
     IsCompilationNeeded = false;
 }
コード例 #7
0
        private void OnMessage(ObjectStreamConnection <CompilerMessage, CompilerMessage> connection, CompilerMessage message)
        {
            if (message == null)
            {
                Interface.Oxide.NextTick(() =>
                {
                    OnCompilerFailed("Compiler disconnected."); // TODO: Expand, warn about possible missing depdencies?
                    Shutdown();
                });
                return;
            }
            switch (message.Type)
            {
            case CompilerMessageType.Assembly:
                var compilation = compilations[message.Id];
                if (compilation == null)
                {
                    Interface.Oxide.LogWarning("CSharp compiler compiled an unknown assembly!");     // TODO: Clarify?
                    return;
                }
                compilation.endedAt = Interface.Oxide.Now;
                var stdOutput = (string)message.ExtraData;
                if (stdOutput != null)
                {
                    foreach (var line in stdOutput.Split('\r', '\n'))
                    {
                        var match = fileErrorRegex.Match(line.Trim());
                        for (var i = 1; i < match.Groups.Count; i++)
                        {
                            var value = match.Groups[i].Value;
                            if (value.Trim() == string.Empty)
                            {
                                continue;
                            }
                            var fileName         = value.Basename();
                            var scriptName       = fileName.Substring(0, fileName.Length - 3);
                            var compilablePlugin = compilation.plugins.SingleOrDefault(pl => pl.ScriptName == scriptName);
                            if (compilablePlugin == null)
                            {
                                Interface.Oxide.LogError("Unable to resolve script error to plugin: {0}", line);
                                continue;
                            }
                            var missingRequirements = compilablePlugin.Requires.Where(name => !compilation.IncludesRequiredPlugin(name));
                            if (missingRequirements.Any())
                            {
                                compilablePlugin.CompilerErrors = $"Missing dependencies: {missingRequirements.ToSentence()}";
                            }
                            else
                            {
                                compilablePlugin.CompilerErrors = line.Trim().Replace(Interface.Oxide.PluginDirectory + Path.DirectorySeparatorChar, string.Empty);
                            }
                        }
                    }
                }
                compilation.Completed((byte[])message.Data);
                compilations.Remove(message.Id);
                idleTimer?.Destroy();
                if (AutoShutdown)
                {
                    Interface.Oxide.NextTick(() =>
                    {
                        idleTimer?.Destroy();
                        if (AutoShutdown)
                        {
                            idleTimer = Interface.Oxide.GetLibrary <Core.Libraries.Timer>().Once(60, Shutdown);
                        }
                    });
                }
                break;

            case CompilerMessageType.Error:
                Interface.Oxide.LogError("Compilation error: {0}", message.Data);
                compilations[message.Id].Completed();
                compilations.Remove(message.Id);
                idleTimer?.Destroy();
                if (AutoShutdown)
                {
                    Interface.Oxide.NextTick(() =>
                    {
                        idleTimer?.Destroy();
                        idleTimer = Interface.Oxide.GetLibrary <Core.Libraries.Timer>().Once(60, Shutdown);
                    });
                }
                break;

            case CompilerMessageType.Ready:
                connection.PushMessage(message);
                if (!ready)
                {
                    ready = true;
                    while (messageQueue.Count > 0)
                    {
                        connection.PushMessage(messageQueue.Dequeue());
                    }
                }
                break;
            }
        }
コード例 #8
0
ファイル: PluginCompiler.cs プロジェクト: AEtherSurfer/Oxide
 private void OnMessage(ObjectStreamConnection<CompilerMessage, CompilerMessage> connection, CompilerMessage message)
 {
     if (message == null)
     {
         Interface.Oxide.NextTick(() =>
         {
             OnCompilerFailed("Compiler disconnected.");
             Shutdown();
         });
         return;
     }
     switch (message.Type)
     {
         case CompilerMessageType.Assembly:
             var compilation = compilations[message.Id];
             if (compilation == null)
             {
                 Interface.Oxide.LogWarning("CSharp compiler compiled an unknown assembly!");
                 return;
             }
             compilation.endedAt = Interface.Oxide.Now;
             var stdOutput = (string)message.ExtraData;
             if (stdOutput != null)
             {
                 foreach (var line in stdOutput.Split('\r', '\n'))
                 {
                     var match = fileErrorRegex.Match(line.Trim());
                     for (var i = 1; i < match.Groups.Count; i++)
                     {
                         var value = match.Groups[i].Value;
                         if (value.Trim() == string.Empty) continue;
                         var file_name = value.Basename();
                         var script_name = file_name.Substring(0, file_name.Length - 3);
                         var compilable_plugin = compilation.plugins.SingleOrDefault(pl => pl.ScriptName == script_name);
                         if (compilable_plugin == null)
                         {
                             Interface.Oxide.LogError("Unable to resolve script error to plugin: " + line);
                             continue;
                         }
                         var missing_requirements = compilable_plugin.Requires.Where(name => !compilation.IncludesRequiredPlugin(name));
                         if (missing_requirements.Any())
                             compilable_plugin.CompilerErrors = $"Missing dependencies: {missing_requirements.ToSentence()}";
                         else
                             compilable_plugin.CompilerErrors = line.Trim().Replace(Interface.Oxide.PluginDirectory + Path.DirectorySeparatorChar, string.Empty);
                     }
                 }
             }
             compilation.Completed((byte[])message.Data);
             compilations.Remove(message.Id);
             idleTimer?.Destroy();
             if (AutoShutdown)
             {
                 Interface.Oxide.NextTick(() =>
                 {
                     idleTimer?.Destroy();
                     if (AutoShutdown) idleTimer = Interface.Oxide.GetLibrary<Core.Libraries.Timer>().Once(60, Shutdown);
                 });
             }
             break;
         case CompilerMessageType.Error:
             Interface.Oxide.LogError("Compilation error: {0}", message.Data);
             compilations[message.Id].Completed();
             compilations.Remove(message.Id);
             idleTimer?.Destroy();
             if (AutoShutdown)
             {
                 Interface.Oxide.NextTick(() =>
                 {
                     idleTimer?.Destroy();
                     idleTimer = Interface.Oxide.GetLibrary<Core.Libraries.Timer>().Once(60, Shutdown);
                 });
             }
             break;
         case CompilerMessageType.Ready:
             connection.PushMessage(message);
             if (!ready)
             {
                 ready = true;
                 while (messageQueue.Count > 0)
                     connection.PushMessage(messageQueue.Dequeue());
             }
             break;
     }
 }
コード例 #9
0
ファイル: PluginTimers.cs プロジェクト: yas-online/Oxide
 public Timer(Core.Libraries.Timer.TimerInstance instance)
 {
     this.instance = instance;
 }
コード例 #10
0
 public Timer(Core.Libraries.Timer.TimerInstance instance)
 {
     this.instance = instance;
 }
コード例 #11
0
ファイル: PluginCompiler.cs プロジェクト: HalfShotz/Oxide
 private void OnMessage(ObjectStreamConnection<CompilerMessage, CompilerMessage> connection, CompilerMessage message)
 {
     if (message == null)
     {
         Interface.Oxide.NextTick(OnShutdown);
         return;
     }
     switch (message.Type)
     {
         case CompilerMessageType.Assembly:
             var compilation = pluginComp[message.Id];
             compilation.endedAt = Interface.Oxide.Now;
             var stdOutput = (string)message.ExtraData;
             if (stdOutput != null)
             {
                 foreach (var line in stdOutput.Split('\r', '\n'))
                 {
                     var match = fileErrorRegex.Match(line.Trim());
                     for (var i = 1; i < match.Groups.Count; i++)
                     {
                         var value = match.Groups[i].Value;
                         if (value.Trim() == string.Empty) continue;
                         var file_name = value.Basename();
                         var script_name = file_name.Substring(0, file_name.Length - 3);
                         var compilable_plugin = compilation.plugins.SingleOrDefault(pl => pl.ScriptName == script_name);
                         if (compilable_plugin == null)
                         {
                             Interface.Oxide.LogError("Unable to resolve script error to plugin: " + line);
                             continue;
                         }
                         var missing_requirements = compilable_plugin.Requires.Where(name => compilation.plugins.Single(pl => pl.Name == name).CompilerErrors != null).ToArray();
                         if (missing_requirements.Length > 0)
                             compilable_plugin.CompilerErrors = $"{compilable_plugin.ScriptName}'s dependencies: {missing_requirements.ToSentence()}";
                         else
                             compilable_plugin.CompilerErrors = line.Trim().Replace(Interface.Oxide.PluginDirectory + "\\", string.Empty);
                     }
                 }
             }
             Interface.Oxide.NextTick(() => compilation.callback((byte[])message.Data, compilation.Duration));
             pluginComp.Remove(message.Id);
             idleTimer?.Destroy();
             idleTimer = Interface.Oxide.GetLibrary<Core.Libraries.Timer>().Once(60, OnShutdown);
             break;
         case CompilerMessageType.Error:
             Interface.Oxide.LogError("Compilation error: {0}", message.Data);
             var comp = pluginComp[message.Id];
             Interface.Oxide.NextTick(() => comp.callback(null, 0));
             pluginComp.Remove(message.Id);
             idleTimer?.Destroy();
             idleTimer = Interface.Oxide.GetLibrary<Core.Libraries.Timer>().Once(60, OnShutdown);
             break;
         case CompilerMessageType.Ready:
             connection.PushMessage(message);
             if (!ready)
             {
                 ready = true;
                 while (compQueue.Count > 0)
                     connection.PushMessage(compQueue.Dequeue());
             }
             break;
     }
 }