Exemple #1
0
 public QueryParam(QueryParamType type, string name, string queryName = null)
 {
     this.type      = type;
     this.name      = name;
     keyword        = name + ":";
     this.queryName = queryName ?? name;
 }
Exemple #2
0
 /// <summary>
 /// Appends new query parameters to the query.
 /// </summary>
 /// <param name="paramType">Type of the parameter.</param>
 /// <param name="value">Value for the query parameter.</param>
 public void AppendQuery(QueryParamType paramType, string value)
 {
     if (IsMutuallyExclusive(paramType))
         QueryParams.Add(paramType, Utility.UriEncodeUnsafe(value));
     else
         Trace.WriteLine(paramType +
                         " can not be added due to the existance of other mutually exclusive query parameter");
 }
        /// <summary>
        /// Converts a QueryParamType to an NpgsqlDbTyp
        /// </summary>
        /// <param name="value">The value to convert</param>
        /// <returns>The NpgsqlDbType that matches our internal type</returns>
        public static NpgsqlDbType ToNpgsql(this QueryParamType value)
        {
            switch (value)
            {
            case QueryParamType.Bit:
                return(NpgsqlDbType.Bit);

            case QueryParamType.Boolean:
                return(NpgsqlDbType.Boolean);

            case QueryParamType.Box:
                return(NpgsqlDbType.Box);

            case QueryParamType.ByteArray:
                return(NpgsqlDbType.Bytea);

            case QueryParamType.Char:
                return(NpgsqlDbType.Char);

            case QueryParamType.Circle:
                return(NpgsqlDbType.Circle);

            case QueryParamType.Date:
                return(NpgsqlDbType.Date);

            case QueryParamType.Double:
                return(NpgsqlDbType.Double);

            case QueryParamType.Integer:
                return(NpgsqlDbType.Integer);

            case QueryParamType.IpAddress:
                return(NpgsqlDbType.Cidr);

            case QueryParamType.Json:
                return(NpgsqlDbType.Json);

            case QueryParamType.Line:
                return(NpgsqlDbType.Line);

            case QueryParamType.LineSegment:
                return(NpgsqlDbType.LSeg);

            case QueryParamType.Long:
                return(NpgsqlDbType.Bigint);

            case QueryParamType.MacAddress:
                return(NpgsqlDbType.MacAddr);

            case QueryParamType.Money:
                return(NpgsqlDbType.Money);

            case QueryParamType.Numeric:
                return(NpgsqlDbType.Numeric);

            case QueryParamType.Path:
                return(NpgsqlDbType.Path);

            case QueryParamType.Point:
                return(NpgsqlDbType.Point);

            case QueryParamType.Polygon:
                return(NpgsqlDbType.Polygon);

            case QueryParamType.Short:
                return(NpgsqlDbType.Smallint);

            case QueryParamType.Single:
                return(NpgsqlDbType.Real);

            case QueryParamType.Text:
                return(NpgsqlDbType.Text);

            case QueryParamType.Time:
                return(NpgsqlDbType.Time);

            case QueryParamType.TimeSpan:
                return(NpgsqlDbType.Interval);

            case QueryParamType.TimeStamp:
                return(NpgsqlDbType.Timestamp);

            case QueryParamType.Uuid:
                return(NpgsqlDbType.Uuid);

            case QueryParamType.VarBit:
                return(NpgsqlDbType.Varbit);

            case QueryParamType.VarChar:
                return(NpgsqlDbType.Varchar);

            case QueryParamType.Xml:
                return(NpgsqlDbType.Xml);

            default:
                throw new NotSupportedException("No PGSQL command defined for " + value);
            }
        }
Exemple #4
0
        private bool IsMutuallyExclusive(QueryParamType paramType)
        {
            switch (paramType)
            {
            case QueryParamType.CanAll:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanOpen:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanOwned:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanReported:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanStarred:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanNew:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.CanToVerify:
                if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("can");
                    return(true);
                }
                return(false);

            case QueryParamType.Author:
                if (!ExclusionSet.Contains("id"))
                {
                    return(true);
                }
                return(false);

            case QueryParamType.Id:
                if (!ExclusionSet.Contains("id") && ExclusionSet.Count == 0)
                {
                    ExclusionSet.Add("id");
                    return(true);
                }
                return(false);

            case QueryParamType.Label:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("label");
                    return(true);
                }
                return(false);

            case QueryParamType.Owner:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("owner");
                    return(true);
                }
                return(false);

            case QueryParamType.PublishedDateMin:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("published");
                    return(true);
                }
                return(false);

            case QueryParamType.PublishedDateMax:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("published");
                    return(true);
                }
                return(false);

            case QueryParamType.QueryString:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("query");
                    return(true);
                }
                return(false);

            case QueryParamType.Status:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("status");
                    return(true);
                }
                return(false);

            case QueryParamType.Stars:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("stars");
                    return(true);
                }
                return(false);

            case QueryParamType.MaxResults:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("maxresult");
                    return(true);
                }
                return(false);

            case QueryParamType.UpdatedDateMin:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("update");
                    return(true);
                }
                return(false);

            case QueryParamType.UpdatedDateMax:
                if (!ExclusionSet.Contains("id"))
                {
                    ExclusionSet.Add("update");
                    return(true);
                }
                return(false);

            default:
                return(true);
            }
        }
 /// <summary>
 /// Creates a new query parameter with the given name and type
 /// </summary>
 /// <param name="name">The name for the parameter</param>
 /// <param name="type">The type for the parameter</param>
 public QueryParam(string name, QueryParamType type)
 {
     Name = name;
     Type = type;
 }
 /// <summary>
 /// Creates a new DataField attribute
 /// </summary>
 /// <param name="fieldName">The name of the field in the database</param>
 /// <param name="fieldType">The database parameter type for the field</param>
 public DataField(string fieldName, QueryParamType fieldType)
 {
     FieldName = fieldName;
     FieldType = fieldType;
 }
Exemple #7
0
 private bool IsMutuallyExclusive(QueryParamType paramType)
 {
     switch (paramType)
     {
         case QueryParamType.CanAll:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanOpen:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanOwned:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanReported:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanStarred:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanNew:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.CanToVerify:
             if (!ExclusionSet.Contains("can") && !ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("can");
                 return true;
             }
             return false;
         case QueryParamType.Author:
             if (!ExclusionSet.Contains("id"))
                 return true;
             return false;
         case QueryParamType.Id:
             if (!ExclusionSet.Contains("id") && ExclusionSet.Count == 0)
             {
                 ExclusionSet.Add("id");
                 return true;
             }
             return false;
         case QueryParamType.Label:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("label");
                 return true;
             }
             return false;
         case QueryParamType.Owner:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("owner");
                 return true;
             }
             return false;
         case QueryParamType.PublishedDateMin:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("published");
                 return true;
             }
             return false;
         case QueryParamType.PublishedDateMax:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("published");
                 return true;
             }
             return false;
         case QueryParamType.QueryString:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("query");
                 return true;
             }
             return false;
         case QueryParamType.Status:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("status");
                 return true;
             }
             return false;
         case QueryParamType.Stars:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("stars");
                 return true;
             }
             return false;
         case QueryParamType.MaxResults:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("maxresult");
                 return true;
             }
             return false;
         case QueryParamType.UpdatedDateMin:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("update");
                 return true;
             }
             return false;
         case QueryParamType.UpdatedDateMax:
             if (!ExclusionSet.Contains("id"))
             {
                 ExclusionSet.Add("update");
                 return true;
             }
             return false;
         default:
             return true;
     }
 }