Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 5
0
 public ParameterAttribute(ParameterSourceType sourceType)
 {
     Debug.Assert(sourceType == ParameterSourceType.Code || sourceType == ParameterSourceType.Computed);
     SourceType = sourceType;
 }
Exemplo n.º 6
0
 protected static bool IsParameterTypeAllowed(ParameterSourceType sourceType)
 {
     return sourceType == ParameterSourceType.Config || sourceType == ParameterSourceType.Hardware || sourceType == ParameterSourceType.Runtime || sourceType == ParameterSourceType.Data;
 }
Exemplo n.º 7
0
 public IEnumerable<ParameterDescription> GetParameters(ParameterSourceType sourceType)
 {
     return _parameters.Where(parameter => parameter.SourceType == sourceType).ToList();
 }
Exemplo n.º 8
0
 public ParameterSourceLocator(string path, ParameterSourceType type, string description)
 {
     Path        = path;
     Type        = type;
     Description = description;
 }
Exemplo n.º 9
0
 protected static bool IsParameterTypeAllowed(ParameterSourceType sourceType)
 {
     return(sourceType == ParameterSourceType.Config || sourceType == ParameterSourceType.Hardware || sourceType == ParameterSourceType.Runtime || sourceType == ParameterSourceType.Data);
 }
Exemplo n.º 10
0
 public IEnumerable <ParameterDescription> GetParameters(ParameterSourceType sourceType)
 {
     return(_parameters.Where(parameter => parameter.SourceType == sourceType).ToList());
 }
Exemplo n.º 11
0
 public ParameterAttribute(ParameterSourceType sourceType)
 {
     Debug.Assert(sourceType == ParameterSourceType.Code || sourceType == ParameterSourceType.Computed);
     SourceType = sourceType;
 }
Exemplo n.º 12
0
 public ParameterDescription(string name, ParameterSourceType sourceType)
     : this()
 {
     Name       = name;
     SourceType = sourceType;
 }
Exemplo n.º 13
0
 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;
 }