/// <inheritdoc /> public IDbCommand CreateCommand(IDbConnection connection, object parameterSource) { if (connection is null) { throw new ArgumentNullException(nameof(connection)); } if (parameterSource is null) { throw new ArgumentNullException(nameof(connection)); } if (!ParameterSourceType.IsInstanceOfType(parameterSource)) { throw new ArgumentException($"The parameter source must be of {ParameterSourceType} type."); } var cmd = connection.CreateCommand(); cmd.CommandText = SqlStatement; for (var i = 0; i < ParameterAccessors.Count; i++) { var paramAccessor = ParameterAccessors[i]; var paramValue = paramAccessor(parameterSource) ?? DBNull.Value; var p = cmd.CreateParameter(); p.ParameterName = $"@p_{i}"; p.Value = paramValue; cmd.Parameters.Add(p); } return(cmd); }
public IEnumerable <ParameterDescription> GetParameters(ParameterSourceType sourceType) { var parameters = new List <ParameterDescription>(); foreach (var model in _models) { parameters.AddRange(model.Value.GetParameters(sourceType)); } return(parameters); }
/// <summary> /// ラベル取得 /// </summary> static private string GetLabel(ParameterSourceType type) { string text = ""; switch (type) { case ParameterSourceType.RegexMatchScriptNameUpper: case ParameterSourceType.RegexMatchScriptNameLower: text = "正規表現(Regex)"; break; case ParameterSourceType.Text: text = "テキスト"; break; default: Debug.LogError("Unknown type: " + type.ToString()); break; } return(text); }
/// <summary> /// ParameterSourceTypeをテキストへ変換 /// </summary> static private string ConvertEnumToText(ParameterSourceType type) { string text = ""; switch (type) { case ParameterSourceType.RegexMatchScriptNameUpper: text = "Upper case - 正規表現(Regex)にマッチする文字列をスクリプト名から取り出す(先頭:大文字)"; break; case ParameterSourceType.RegexMatchScriptNameLower: text = "Lower case - 正規表現(Regex)にマッチする文字列をスクリプト名から取り出す(先頭:小文字)"; break; case ParameterSourceType.Text: text = "テキストそのまま"; break; default: Debug.LogError("Unknown type: " + type.ToString()); break; } return(text); }
public ParameterAttribute(ParameterSourceType sourceType) { Debug.Assert(sourceType == ParameterSourceType.Code || sourceType == ParameterSourceType.Computed); SourceType = sourceType; }
protected static bool IsParameterTypeAllowed(ParameterSourceType sourceType) { return sourceType == ParameterSourceType.Config || sourceType == ParameterSourceType.Hardware || sourceType == ParameterSourceType.Runtime || sourceType == ParameterSourceType.Data; }
public IEnumerable<ParameterDescription> GetParameters(ParameterSourceType sourceType) { return _parameters.Where(parameter => parameter.SourceType == sourceType).ToList(); }
public ParameterSourceLocator(string path, ParameterSourceType type, string description) { Path = path; Type = type; Description = description; }
protected static bool IsParameterTypeAllowed(ParameterSourceType sourceType) { return(sourceType == ParameterSourceType.Config || sourceType == ParameterSourceType.Hardware || sourceType == ParameterSourceType.Runtime || sourceType == ParameterSourceType.Data); }
public IEnumerable <ParameterDescription> GetParameters(ParameterSourceType sourceType) { return(_parameters.Where(parameter => parameter.SourceType == sourceType).ToList()); }
public ParameterDescription(string name, ParameterSourceType sourceType) : this() { Name = name; SourceType = sourceType; }
public IEnumerable<ParameterDescription> GetParameters(ParameterSourceType sourceType) { var parameters = new List<ParameterDescription>(); foreach (var model in _models) { parameters.AddRange(model.Value.GetParameters(sourceType)); } return parameters; }
public ParameterSourceSpecification(string root, ParameterSourceType type, string description) { Root = root; Type = type; Description = description; }