コード例 #1
0
 protected ScriptAbs(ScriptAbs script)
 {
     Id           = script.Id;
     ScriptName   = script.ScriptName;
     ScriptStatus = script.ScriptStatus;
     ScriptPath   = script.ScriptPath;
 }
コード例 #2
0
        public static ScriptAbs GetInstance(ScriptAbs oldScript, ScriptType scriptType)
        {
            bool      hasScriptTypeChanged = oldScript != null && HasScriptTypeChanged(oldScript.ScriptType, scriptType);
            ScriptAbs newScript            = null;

            if (oldScript == null || hasScriptTypeChanged)
            {
                newScript = scriptType switch
                {
                    ScriptType.OneOff => new ScriptOneOff(),
                    ScriptType.Scheduled => new ScriptScheduled(),
                    ScriptType.ListenKey => new ScriptListenKey(),
                    _ => throw new Exception(),
                };
                if (hasScriptTypeChanged)
                {
                    newScript.Id = oldScript.Id;
                }
            }

            return(newScript ?? oldScript);
        }
コード例 #3
0
 public static bool HasScheduledTimeChanged(ScriptAbs script, ScriptAbs editedScript) =>
 script.ScriptType == ScriptType.Scheduled &&
 ((ScriptScheduled)script).ScheduledHour != ((ScriptScheduled)editedScript).ScheduledHour;