示例#1
0
        public IDbCommand GetNpgsqlCommandOnly(string sql, object parameters = null)
        {
            if (parameters == null)
            {
                return(new NpgsqlCommand(sql));
            }
            else
            {
                SetParams(sql, parameters);

                var cmd = new NpgsqlCommand(sql);

                if (!Params.Any())
                {
                    return(cmd);
                }

                foreach (var keyValuePair in Params)
                {
                    cmd.Parameters.AddWithValue(keyValuePair.Key, keyValuePair.Value);
                }

                return(cmd);
            }
        }
示例#2
0
        public void Add(ParametrType type, object value)
        {
            if (Params.Any(x => x.Key == type))
            {
                return;
            }

            Params.Add(type, value);
        }
        public virtual void AddParamter([NotNull] IGuidGenerator guidGenerator, [NotNull] string name, [NotNull] string expression)
        {
            Check.NotNull(guidGenerator, nameof(guidGenerator));

            if (Params.Any(p => p.Name == name))
            {
                return;
            }
            Params.Add(new EntityRuleParam(guidGenerator.Create(), Id, name, expression, TenantId));
        }
示例#4
0
        private string Gettext()
        {
            if (Localizer is null)
            {
                CompositionRoot.WriteMissingInitializationErrorMessage();
                return(MsgId);
            }

            return(Params.Any() ? Localizer.Catalog.GetString(MsgId, Params) : Localizer.Catalog.GetString(MsgId));
        }
示例#5
0
 public Options(params string[] args)
 {
     Junk = args.String()
            .Split(args.Parse(Const.CommandPrefix + @"\S+"), StringSplitOptions.RemoveEmptyEntries)
            .ReplaceAll(Const.AliasPrefix, Const.GetValue)
            .ToArray();
     Params = args.ReplaceAll(@"(--|-)", "/")
              .SelectMany(value => _list.Where(param => param.Cmds.Contains(value)))
              .OrderBy(o => o.Order);
     Verbose = Params.Any(o => o.Cmds.Contains("/v"));
     Help    = Params.Any(o => o.Cmds.Contains("/help"));
 }
示例#6
0
 public override void ClearData()
 {
     base.ClearData();
     uniqueChildProperties?.Clear();
     if (Params == null || !Params.Any())
     {
         return;
     }
     foreach (var ghParam in Params)
     {
         ghParam?.ClearData();
     }
 }
        private string FormatParms()
        {
            string output = "(";

            if (Params != null && Params.Any())
            {
                var parameters = Params.Where((p) => p != ReturnProperty);
                foreach (var parm in parameters)
                {
                    output += parm.Decompile() + (parm != parameters.Last() ? ", " : String.Empty);
                }
            }
            return(output + ")");
        }
示例#8
0
        private string LoadJson()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\"Name\":\"" + ReturnType.Name + "\"");
            sb.Append(",\"ReturnType\":\"" + ReturnType.FullName + "\"");
            sb.Append(",\"SecurityZone\":\"" + SecurityZone + "\"");

            sb.Append("," + base.Json);

            sb.Append(",\"Params\":[");
            Func <WSParam, bool>   isAccessibleParam = x => x.READ_ACCESS_MODE.ACCESS_LEVEL <= UserRole;
            Func <WSParam, string> jFunc             = (x => "{" + (x is WSTableParam ? ((WSTableParam)x).Json : x.Json) + "}");

            if (Params != null && Params.Any(isAccessibleParam))
            {
                List <string> paramList = new List <string>();
                foreach (WSParam param in Params.Where(isAccessibleParam))
                {
                    if (param is WSTableParam)
                    {
                        WSTableParam tParam = (WSTableParam)param;
                        if (tParam.IsAssociation)
                        {
                            WSSource src = CFunc.GetSourceByType(tParam.DataType.GetEntityType());
                            if (src != null && src.AccessLevel <= UserRole)
                            {
                                paramList.Add("{" + tParam.Json + "}");
                            }
                        }
                        else
                        {
                            paramList.Add("{" + tParam.Json + "}");
                        }
                    }
                    else
                    {
                        paramList.Add("{" + param.Json + "}");
                    }
                }
                sb.Append(paramList.Aggregate((a, b) => a + "," + b));
            }
            sb.Append("]");

            return(sb.ToString());
        }
        public void LoadFromDropFile(string content)
        {
            QueryFile.Id      = 0;
            QueryFile.Name    = "";
            QueryFile.Content = content;
            Params.Clear();

            MatchCollection matches = Regex.Matches(content, @"(?<!\w)@\w+");

            foreach (Match match in matches)
            {
                if (!Params.Any(t => t.Key == match.Value))
                {
                    this.Params.Add(new SqlParamView(match.Value, ""));
                }
            }
        }
示例#10
0
        public ParamSet Expand(uint[] names)
        {
            var ret = new List <uint[]>();

            if (!Params.Any() || Params.First().All(p => p != 0))
            {
                return(this);
            }

            var added = new HashSet <string>();

            foreach (var paramArray in Params)
            {
                var expanded = ExpandVariables(paramArray, 0, names, added);
                ret.AddRange(expanded);
            }
            return(new ParamSet(ret));
        }
 private string Gettext()
 {
     return(Params.Any() ? Localizer.Gettext(MsgId, Params) : Localizer.Gettext(MsgId));
 }
示例#12
0
 /// <summary>
 /// Body中是否有值
 /// </summary>
 /// <returns></returns>
 public bool HasAny() => _customConent != null || Params.Any(it => it.Location == HttpParamLocation.Body);
示例#13
0
        /// <summary>
        /// Add the new parameters created and remove the deleted, keeping the saved values, using the name as a reference.
        /// </summary>
        /// <param name="parameters"></param>
        public void UpdateParameters(Params parameters)
        {
            int index;

            Action remove = delegate { };

            foreach (var param in _referenceData)
            {
                if (parameters.Any(x => x.Name != param.Name))
                {
                    var temp = param;

                    remove += () =>
                    {
                        if (!temp.IsPersistent)
                        {
                            if (temp.Type == ParamVariableType.Int)
                            {
                                _intData.RemoveAt(temp.IndexInCollection);
                            }
                            else if (temp.Type == ParamVariableType.Float)
                            {
                                _floatData.RemoveAt(temp.IndexInCollection);
                            }
                            else if (temp.Type == ParamVariableType.Bool)
                            {
                                _boolData.RemoveAt(temp.IndexInCollection);
                            }
                            else
                            {
                                _eventData.RemoveAt(temp.IndexInCollection);
                            }
                        }

                        _referenceData.Remove(temp);
                    };
                }
            }

            remove();

            foreach (var param in parameters)
            {
                if (_referenceData.Any(x => x.Name == param.Name))
                {
                    continue;
                }

                if (param.IsPersistent)
                {
                    _referenceData.Add(parameters[param.Name]);
                    continue;
                }

                if (param.Type == ParamVariableType.Int)
                {
                    var value = parameters.GetInt(param.Name).Value;

                    _intData.Add(new IntSerializedParamVariable()
                    {
                        Name = param.Name, Value = value
                    });
                    index = _intData.Count - 1;
                }

                else if (param.Type == ParamVariableType.Float)
                {
                    var value = parameters.GetFloat(param.Name).Value;

                    _floatData.Add(new FloatSerializedParamVariable()
                    {
                        Name = param.Name, Value = value
                    });
                    index = _floatData.Count - 1;
                }

                else
                {
                    var value = parameters.GetBool(param.Name).Value;

                    _boolData.Add(new BoolSerializedParamVaraible()
                    {
                        Name = param.Name, Value = value
                    });
                    index = _boolData.Count - 1;
                }

                _referenceData.Add(new ParamReferenceVariable
                {
                    Name              = param.Name,
                    Type              = param.Type,
                    Accessibility     = param.access,
                    EngineGraph       = param.graph,
                    IsPersistent      = false,
                    IndexInCollection = index
                });
            }
        }