public static Forecast GetForecast()
    {
        try {
            var excludeBlocks = new Exclude[]
            {
            Exclude.alerts,
            Exclude.minutely,
            Exclude.hourly,
            //Exclude.daily,
            Exclude.flags
            };

            var request = new ForecastIORequest(ApiKey, 46.280613f, -119.340984f, DateTime.Now, Unit.us, null, excludeBlocks);
            var forecast = request.Get();
            return new Forecast(forecast.daily.data[0].apparentTemperatureMax,
                forecast.daily.data[0].apparentTemperatureMin,
                forecast.currently.temperature,
                forecast.currently.summary,
                forecast.currently.icon);
        }
        catch (WebException ex)
        {
            return new Forecast(0, 0, 0, "The weather man called in sick.", "broken");
        }
    }
 public ForecastIORequest(string apiKey, float latF, float longF, Unit unit, Extend[] extend = null, Exclude[] exclude = null)
 {
     _apiKey = apiKey;
     _latitude = latF.ToString(CultureInfo.InvariantCulture);
     _longitude = longF.ToString(CultureInfo.InvariantCulture);
     _unit = Enum.GetName(typeof(Unit), unit);
     _extend = (extend != null) ? RequestHelpers.FormatExtendString(extend) : "";
     _exclude = (exclude != null) ? RequestHelpers.FormatExcludeString(exclude) : "";
 }
 public ForecastIORequest(string _apiKey, float _lat, float _long, Unit _unit, Extend[] _extend = null, Exclude[] _exclude = null)
 {
     apiKey = _apiKey;
     latitude = _lat.ToString(CultureInfo.InvariantCulture);
     longitude = _long.ToString(CultureInfo.InvariantCulture);
     unit = Enum.GetName(typeof(Unit), _unit);
     extend = (_extend != null) ? RequestHelpers.FormatExtendString(_extend) : "";
     exclude = (_exclude != null) ? RequestHelpers.FormatExcludeString(_exclude) : "";
 }
Esempio n. 4
0
		public PCExclude(string name, Exclude type, string label = "")
			: base(name)
		{
			Type = type;
			Label = label;
			Guid pageId;
			if (Type == Exclude.Page && Guid.TryParse(name, out pageId))
			{
				PageId = pageId;
			}
		}
 public ForecastIORequest(string apiKey, float latF, float longF, DateTime time, Unit unit, Language? lang = null, Extend[] extend = null, Exclude[] exclude = null)
 {
     _apiKey = apiKey;
     _latitude = latF.ToString(CultureInfo.InvariantCulture);
     _longitude = longF.ToString(CultureInfo.InvariantCulture);
     _time = time.ToUTCString();
     _unit = Enum.GetName(typeof(Unit), unit);
     _extend = (extend != null) ? RequestHelpers.FormatExtendString(extend) : "";
     _exclude = (exclude != null) ? RequestHelpers.FormatExcludeString(exclude) : "";
     _lang = (lang != null) ? RequestHelpers.FormatLanguageEnum(lang) : Language.en.ToString();
 }
 public Task <long> SortedSetRemoveRangeByValueAsync(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetRemoveRangeByValueAsync(ToInner(key), min, max, exclude, flags));
 }
 public Task <RedisValue[]> SortedSetRangeByValueAsync(RedisKey key, RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetRangeByValueAsync(ToInner(key), min, max, exclude, skip, take, flags));
 }
 public Task <long> SortedSetLengthAsync(RedisKey key, double min = -1.0 / 0.0, double max = 1.0 / 0.0, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetLengthAsync(ToInner(key), min, max, exclude, flags));
 }
Esempio n. 9
0
 public long SortedSetRemoveRangeByScore(RedisKey key, double start, double stop, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(this.Inner.SortedSetRemoveRangeByScore(this.ToInner(key), start, stop, exclude, flags));
 }
Esempio n. 10
0
 public long SortedSetLength(RedisKey key, double min = -1.0 / 0.0, double max = 1.0 / 0.0, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(this.Inner.SortedSetLength(this.ToInner(key), min, max, exclude, flags));
 }
 public Task<long> RemoveRangeByScoreAsync(double start, double stop, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return RedisAsync.SortedSetRemoveRangeByScoreAsync(Key, start, stop, exclude, flags);
 }
Esempio n. 12
0
        public async Task <string[]> SortedSetRangeByScoreAsync(string key, DateTime?startTime, DateTime?stopTime, Exclude exclude = Exclude.None, Order order = Order.Ascending)
        {
            var start = double.NegativeInfinity;
            var stop  = double.PositiveInfinity;

            if (startTime.HasValue)
            {
                start = (startTime.Value.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
            }
            if (stopTime.HasValue)
            {
                stop = (stopTime.Value.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
            }
            var arry = await database.SortedSetRangeByScoreAsync(key, start, stop, exclude, order);

            return(arry.ToStringArray());
        }
 public RedisValue[] SortedSetRangeByValue(RedisKey key, RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetRangeByValue(ToInner(key), min, max, exclude, order, skip, take, flags));
 }
 public Task<long> LengthAsync(double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return RedisAsync.SortedSetLengthAsync(Key, min, max, exclude, flags);
 }
 public Task<long> RemoveRangeByValueAsync(RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return RedisAsync.SortedSetRemoveRangeByValueAsync(Key, min, max, exclude, flags);
 }
 public long RemoveRangeByValue(RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return RedisSync.SortedSetRemoveRangeByValue(Key, min, max, exclude, flags);
 }
Esempio n. 17
0
 /// <summary>
 /// 获取集合数量
 /// </summary>
 /// <returns></returns>
 public long GetLongCount(double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None)
 {
     return(Database.SortedSetLength(SetKey, min, max, exclude));
 }
Esempio n. 18
0
 /// <summary>
 /// Returns the specified range of elements in the sorted set stored at key. By default the elements are considered to be ordered from the lowest to the highest score. Lexicographical order is used for elements with equal score.
 /// Start and stop are used to specify the min and max range for score values. Similar to other range methods the values are inclusive.
 /// </summary>
 /// <param name="start">The minimum score to filter by.</param>
 /// <param name="stop">The maximum score to filter by.</param>
 /// <param name="exclude">Which of <paramref name="start" /> and <paramref name="stop" /> to exclude (defaults to both inclusive).</param>
 /// <param name="order">The order to sort by (defaults to ascending).</param>
 /// <param name="skip">How many items to skip.</param>
 /// <param name="take">How many items to take.</param>
 /// <returns>List of elements in the specified score range.</returns>
 public RedisValue[] GetRangeByScore(double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1)
 {
     return(Database.SortedSetRangeByScore(SetKey, start, stop, exclude, order, skip, take));
 }
Esempio n. 19
0
 /// <summary>
 /// Gets a subrange of this sorted set range.
 /// </summary>
 internal IEnumerable <SortedSetEntry> Subrange(double start, double end, Exclude exclude)
 {
     return(_sortedSet.Where(elem => IsMatch(elem.Score, start, end, exclude)));
 }
Esempio n. 20
0
 internal int RemoveByScore(double start, double end, Exclude exclude)
 {
     return(_sortedSet.RemoveWhere(elem => IsMatch(elem.Score, start, end, exclude)));
 }
Esempio n. 21
0
 public PackageDependency AsReadOnly()
 {
     return(new PackageDependency(Id, VersionSpec, null, Exclude?.Split(',').Select(s => s.Trim()).ToList()));
 }
 public Task<RedisValue[]> RangeByValueAsync(RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return RedisAsync.SortedSetRangeByValueAsync(Key, min, max, exclude, skip, take, flags);
 }
        public async Task <ConcurrentDictionary <string, double> > SortedSetRangeByScoreWithScoresAsync(string key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1)
        {
            var result = await _redisDatabase.SortedSetRangeByScoreWithScoresAsync(key, start, stop, exclude, order, skip, take);

            return(result.ToConcurrentDictionary());
        }
Esempio n. 24
0
 public RedisValue[] SortedSetRangeByScore(RedisKey key, double start = -1.0 / 0.0, double stop = 1.0 / 0.0, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return(this.Inner.SortedSetRangeByScore(this.ToInner(key), start, stop, exclude, order, skip, take, flags));
 }
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (Pattern.Expression != null)
            {
                targetCommand.AddParameter("Pattern", Pattern.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (SimpleMatch.Expression != null)
            {
                targetCommand.AddParameter("SimpleMatch", SimpleMatch.Get(context));
            }

            if (CaseSensitive.Expression != null)
            {
                targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context));
            }

            if (Quiet.Expression != null)
            {
                targetCommand.AddParameter("Quiet", Quiet.Get(context));
            }

            if (List.Expression != null)
            {
                targetCommand.AddParameter("List", List.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (NotMatch.Expression != null)
            {
                targetCommand.AddParameter("NotMatch", NotMatch.Get(context));
            }

            if (AllMatches.Expression != null)
            {
                targetCommand.AddParameter("AllMatches", AllMatches.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (Context.Expression != null)
            {
                targetCommand.AddParameter("Context", Context.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Esempio n. 26
0
 public long SortedSetRemoveRangeByValue(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(this.Inner.SortedSetRemoveRangeByValue(this.ToInner(key), min, max, exclude, flags));
 }
Esempio n. 27
0
 public static async Task <RedisValue[]> SortedSetRangeByScorePagingAsync(this IDatabase database, RedisKey key, double start, double stop, int pageIndex, int pageSize = 10, Exclude exclude = Exclude.None, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None)
 {
     return(await database.SortedSetRangeByScoreAsync(key,
                                                      start,
                                                      stop,
                                                      exclude,
                                                      order,
                                                      pageIndex *pageSize,
                                                      pageIndex *pageSize + pageSize - 1,
                                                      flags));
 }
Esempio n. 28
0
 public Task <SortedSetEntry[]> SortedSetRangeByScoreWithScoresAsync(RedisKey key, double start = -1.0 / 0.0, double stop = 1.0 / 0.0, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetRangeByScoreWithScoresAsync(ToInner(key), start, stop, exclude, order, skip, take, flags));
 }
Esempio n. 29
0
 public RedisValue[] SortedSetRangeByValue(string key, RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, long skip = 0, long take = -1, int dbNum = -1, object asyncState = null, CommandFlags flags = CommandFlags.None)
 {
     try
     {
         return(this.Database(dbNum, asyncState).SortedSetRangeByValue(key, min, max, exclude, skip, take, flags));
     }
     catch { }
     return(null);
 }
Esempio n. 30
0
 public Task <long> SortedSetRemoveRangeByScoreAsync(RedisKey key, double start, double stop, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
 {
     return(Inner.SortedSetRemoveRangeByScoreAsync(ToInner(key), start, stop, exclude, flags));
 }
Esempio n. 31
0
 public long SortedSetRemoveRangeByScore(string key, double start, double stop, Exclude exclude = Exclude.None, int dbNum = -1, object asyncState = null, CommandFlags flags = CommandFlags.None)
 {
     try
     {
         return(this.Database(dbNum, asyncState).SortedSetRemoveRangeByScore(key, start, stop, exclude, flags));
     }
     catch { }
     return(long.MinValue);
 }
Esempio n. 32
0
        public override bool Execute()
        {
            Log.LogTaskName("GetDirectories");
            Log.LogTaskProperty("Path", Path);
            Log.LogTaskProperty("Pattern", Pattern);
            Log.LogTaskProperty("Option", Option);
            Log.LogTaskProperty("Exclude", Exclude);

            var path    = Path.Replace('\\', '/').TrimEnd('/');
            var exclude = new HashSet <string> ();
            var items   = new List <ITaskItem> ();
            IEnumerable <string> dirs;
            SearchOption         option;

            if (!string.IsNullOrEmpty(Option))
            {
                if (!Enum.TryParse(Option, out option))
                {
                    Log.LogError("Unknown search option: {0}", Option);
                    return(false);
                }
            }
            else
            {
                option = SearchOption.TopDirectoryOnly;
            }

            if (!Directory.Exists(path))
            {
                Directories = items.ToArray();

                return(!Log.HasLoggedErrors);
            }

            if (!string.IsNullOrEmpty(Pattern))
            {
                dirs = Directory.EnumerateDirectories(path, Pattern, option);
            }
            else
            {
                dirs = Directory.EnumerateDirectories(path, "*.*", option);
            }

            if (!string.IsNullOrEmpty(Exclude))
            {
                foreach (var rpath in Exclude.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var full = System.IO.Path.Combine(path, rpath.Replace('\\', '/'));
                    exclude.Add(full);
                }
            }

            foreach (var dir in dirs)
            {
                if (!exclude.Contains(dir))
                {
                    items.Add(new TaskItem(dir));
                }
            }

            Directories = items.ToArray();

            return(!Log.HasLoggedErrors);
        }
Esempio n. 33
0
 public long SortedSetLength(string key, double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None, int dbNum = -1, object asyncState = null, CommandFlags flags = CommandFlags.None)
 {
     try
     {
         return(this.Database(dbNum, asyncState).SortedSetLength(key, min, max, exclude, flags));
     }
     catch { }
     return(long.MinValue);
 }
Esempio n. 34
0
 /// <summary>
 /// 获取集合数量的异步方法
 /// </summary>
 /// <returns></returns>
 public async Task <long> CountAsync(double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None)
 {
     return(await Database.SortedSetLengthAsync(SetKey, min, max, exclude));
 }
Esempio n. 35
0
 public SortedSetEntry[] SortedSetRangeByScoreWithScores(string key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, int dbNum = -1, object asyncState = null, CommandFlags flags = CommandFlags.None)
 {
     try
     {
         return(this.Database(dbNum, asyncState).SortedSetRangeByScoreWithScores(key, start, stop, exclude, order, skip, take, flags));
     }
     catch { }
     return(null);
 }
Esempio n. 36
0
        public async Task <string[]> SortedSetRangeByScoreAsync(string key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending)
        {
            var arry = await database.SortedSetRangeByScoreAsync(key, start, stop, exclude, order);

            return(arry.ToStringArray());
        }
Esempio n. 37
0
 public static string FormatExcludeString(Exclude[] _input)
 {
     return string.Join(",", _input.Select(i => Enum.GetName(typeof(Exclude), i)));
 }
Esempio n. 38
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Value.Expression != null)
            {
                targetCommand.AddParameter("Value", Value.Get(context));
            }

            if (PassThru.Expression != null)
            {
                targetCommand.AddParameter("PassThru", PassThru.Get(context));
            }

            if (Path.Expression != null)
            {
                targetCommand.AddParameter("Path", Path.Get(context));
            }

            if (LiteralPath.Expression != null)
            {
                targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Include.Expression != null)
            {
                targetCommand.AddParameter("Include", Include.Get(context));
            }

            if (Exclude.Expression != null)
            {
                targetCommand.AddParameter("Exclude", Exclude.Get(context));
            }

            if (Force.Expression != null)
            {
                targetCommand.AddParameter("Force", Force.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (NoNewline.Expression != null)
            {
                targetCommand.AddParameter("NoNewline", NoNewline.Get(context));
            }

            if (Encoding.Expression != null)
            {
                targetCommand.AddParameter("Encoding", Encoding.Get(context));
            }

            if (Stream.Expression != null)
            {
                targetCommand.AddParameter("Stream", Stream.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
		public void Can_exclude_properties()
		{
			JsConfig<Exclude>.ExcludePropertyNames = new[] { "Id" };

			var dto = new Exclude { Id = 1, Key = "Value" };

			Assert.That(dto.ToJson(), Is.EqualTo("{\"Key\":\"Value\"}"));
			Assert.That(dto.ToJsv(), Is.EqualTo("{Key:Value}"));
		}
Esempio n. 40
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Include != null ? Include.GetHashCode() : 0) * 397) ^ (Exclude != null ? Exclude.GetHashCode() : 0));
     }
 }
 public Task<SortedSetEntry[]> RangeByScoreWithScoresAsync(double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return RedisAsync.SortedSetRangeByScoreWithScoresAsync(Key, start, stop, exclude, order, skip, take, flags);
 }
 public void Can_exclude_properties_scoped() {
     var dto = new Exclude {Id = 1, Key = "Value"};
     using (var config = JsConfig.BeginScope()) {
         config.ExcludePropertyReferences = new[] {"Exclude.Id"};
         Assert.That(dto.ToJson(), Is.EqualTo("{\"Key\":\"Value\"}"));
         Assert.That(dto.ToJsv(), Is.EqualTo("{Key:Value}"));
     }
 }
Esempio n. 43
0
 /// <summary>
 /// Removes all elements in the sorted set stored at key with a score between min and max (inclusive by default).
 /// </summary>
 /// <param name="start">The minimum score to remove.</param>
 /// <param name="stop">The maximum score to remove.</param>
 /// <param name="exclude">Which of <paramref name="start" /> and <paramref name="stop" /> to exclude (defaults to both inclusive).</param>
 async Task <long> IAsyncSortSet <TValue> .RemoveRangeByScoreAsync(double start, double stop, Exclude exclude)
 {
     return(await Database.SortedSetRemoveRangeByScoreAsync(this.SetKey, start, stop, exclude));
 }
Esempio n. 44
0
 /// <summary>
 /// Removes all elements in the sorted set stored at key with a score between min and max (inclusive by default).
 /// </summary>
 /// <param name="min">The minimum value to remove.</param>
 /// <param name="max">The maximum value to remove.</param>
 /// <param name="exclude">Which of <paramref name="min" /> and <paramref name="max" /> to exclude (defaults to both inclusive).</param>
 async Task <long> IAsyncSortSet <TValue> .RemoveRangeByValueAsync(RedisValue min, RedisValue max, Exclude exclude)
 {
     return(await Database.SortedSetRemoveRangeByValueAsync(this.SetKey, min, max, exclude));
 }
 public RedisValue[] RangeByScore(double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0, long take = -1, CommandFlags flags = CommandFlags.None)
 {
     return RedisSync.SortedSetRangeByScore(Key, start, stop, exclude, order, skip, take, flags);
 }