public DeploymentScriptModel([NotNull] Deployment.ScriptSymbol symbol) : base(symbol, ModelType.DeploymentScript) { Parameters = new List <ParameterModel>(); Parameters.AddRange(symbol.Parameters.Select(p => new ParameterModel(p))); Definitions = DefinitionGenerator.GetDefinitions(symbol.Defs, ((Deployment.Script)symbol.FirstDeclarationOrDefault).Definitions); Options = new List <ValueModel>(); foreach (var option in ((Deployment.Script)symbol.FirstDeclarationOrDefault).Options) { switch (option) { case DeploymentOption.Success success: Options.Add(new ValueModel(success.Value, TypesOfValue.Success, success.Location)); break; case DeploymentOption.ForReboot reboot: Options.Add(new ValueModel(reboot.Value, TypesOfValue.Reboot, reboot.Location)); break; case DeploymentOption.Timeout timeout: Options.Add(new ValueModel(symbol.Timeout.Value, TypesOfValue.Timeout, timeout.Location)); break; default: Logger.Error($"unsupported option type: {option}"); break; } } ScriptReference = ScriptReference.Create(symbol); }
public static ScriptReference Create([NotNull] Deployment.ScriptSymbol symbol) { switch (symbol.ScriptReference) { case Tdl.ScriptReference.FilePath x: return(new ScriptReference.FilePath(new ValueModel(symbol, x.Path))); case Tdl.ScriptReference.SourceCode x: return(new ScriptReference.SourceCode(new ValueModel(symbol, x.Text), new ValueModel(symbol, x.Extension))); case Tdl.ScriptReference.EmbedFile x: return(new ScriptReference.EmbedFile(new ValueModel(symbol, x.Path))); default: throw new ArgumentException($"Unsupported type of ScriptReference '{symbol.ScriptReference.GetType().FullName}'.", nameof(symbol)); } }