Esempio n. 1
0
        public override void OnActionExecuting(ActionExecutingContext c)
        {
            var key          = string.Concat(Name, "-", c.HttpContext.Request.UserHostAddress);
            var allowExecute = false;

            if (HttpRuntime.Cache[key] == null)
            {
                HttpRuntime.Cache.Add(key,
                                      true,                                       // is this the smallest data we can have?
                                      null,                                       // no dependencies
                                      DateTime.Now.AddMilliseconds(Milliseconds), // absolute expiration
                                      Cache.NoSlidingExpiration,
                                      CacheItemPriority.Low,
                                      null); // no callback

                allowExecute = true;
            }

            if (!allowExecute)
            {
                if (String.IsNullOrEmpty(Message))
                {
                    Message = "You may only perform this action every {n} milliseconds.";
                }

                c.Result = new ContentResult {
                    Content = Message.Replace("{n}", Milliseconds.ToString())
                };
                // see 409 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
                c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict;
            }
        }
Esempio n. 2
0
 public string ToString(string format)
 {
     format = format.Replace("YYYY", Years.ToString());
         format = format.Replace("MM", Months.ToString());
         format = format.Replace("DD", Days.ToString());
         format = format.Replace("hh", Hours.ToString());
         format = format.Replace("mm", Minutes.ToString());
         format = format.Replace("ss", Seconds.ToString());
         format = format.Replace("ms", Milliseconds.ToString());
         return format;
 }
Esempio n. 3
0
        public override string ToString()
        {
            switch (Type)
            {
            case PropertyType.Null:                 return("null");

            case PropertyType.Calculated:           return("calculated");

            case PropertyType.Bool:                 return(Bool.ToString());

            case PropertyType.String:               return("string: " + StringHandle.ToString());

            case PropertyType.MultiValue:           return("multi: " + MultiValueHandle.ToString());

            case PropertyType.Enum:                 return("enum: " + Enum.ToString());

            case PropertyType.Color:                return("color: " + Color.ToString());

            case PropertyType.Integer:              return(Integer.ToString() + " (integer)");

            case PropertyType.Fractional:           return(Fractional.ToString() + " (fractional)");

            case PropertyType.Percentage:           return(Percentage.ToString() + "%");

            case PropertyType.AbsLength:            return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (abs)");

            case PropertyType.RelLength:            return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (rel)");

            case PropertyType.HtmlFontUnits:        return(HtmlFontUnits.ToString() + " (html font units)");

            case PropertyType.RelHtmlFontUnits:     return(RelativeHtmlFontUnits.ToString() + " (relative html font units)");

            case PropertyType.Multiple:             return(Integer.ToString() + "*");

            case PropertyType.Pixels:               return(Pixels.ToString() + "px");

            case PropertyType.Ems:                  return(Ems.ToString() + "em");

            case PropertyType.Exs:                  return(Exs.ToString() + "ex");

            case PropertyType.Milliseconds:         return(Milliseconds.ToString() + "ms");

            case PropertyType.kHz:                  return(kHz.ToString() + "kHz");

            case PropertyType.Degrees:              return(Degrees.ToString() + "deg");
            }

            return("unknown value type");
        }
Esempio n. 4
0
 public override string ToString() =>
 string.Join(',', new string[]
             { SurveyType.ToString(),
               WaterDepth.ToString(),
               X.ToString(),
               Y.ToString(),
               GNSSAltitude.ToString(),
               GNSSHeading.ToString(),
               GNSSSpeed.ToString(),
               MagneticHeading.ToString(),
               MinRange.ToString(),
               MaxRange.ToString(),
               WaterTemperature.ToString(),
               WaterSpeed.ToString(),
               HardwareTime.ToString(),
               Frequency.ToString(),
               Milliseconds.ToString() + '\n' });
Esempio n. 5
0
        string IUrlParameter.GetString(IConnectionConfigurationValues settings)
        {
            if (this == MinusOne)
            {
                return("-1");
            }
            if (this == Zero)
            {
                return("0");
            }
            if (Factor.HasValue && Interval.HasValue)
            {
                return(ToString());
            }

            return(Milliseconds.ToString());
        }
Esempio n. 6
0
 public override string ToString()
 {
     if (Addresses.Length != 0)
     {
         return($"{Addresses.Length.ToString("#,#", CultureInfo.InvariantCulture)} results -" +
                $" {Access.Process.Id.ToString("x8").ToUpper()}-" +
                $"{Access.Process.MainModule.ModuleName} " +
                $"({Milliseconds.ToString("0.000 ms")})");
     }
     else
     {
         return($"we've not got results -" +
                $" {Access.Process.Id.ToString("x8").ToUpper()}-" +
                $"{Access.Process.MainModule.ModuleName} " +
                $"({Milliseconds.ToString("0.000 ms")})");
     }
 }
Esempio n. 7
0
        public override void OnActionExecuting(ActionExecutingContext c)
        {
            var key = string.Concat(Name, "-", c.HttpContext.Request.HttpContext.Connection.RemoteIpAddress);

            if (!Cache.TryGetValue(key, out bool entry))
            {
                var cacheEntryOptions = new MemoryCacheEntryOptions()
                                        .SetAbsoluteExpiration(TimeSpan.FromMilliseconds(Milliseconds));

                Cache.Set(key, true, cacheEntryOptions);
            }
            else
            {
                if (string.IsNullOrEmpty(Message))
                {
                    Message = "You may only perform this action every {n} milliseconds.";
                }

                c.Result = new ContentResult {
                    Content = Message.Replace("{n}", Milliseconds.ToString())
                };
                c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict;
            }
        }
Esempio n. 8
0
 public override string ToString()
 {
     return(TotalHours.ToString().PadLeft(2, '0') + ":" + Minutes.ToString().PadLeft(2, '0') + ":" + Seconds.ToString().PadLeft(2, '0') + "." + Milliseconds.ToString().PadLeft(3, '0'));
 }
Esempio n. 9
0
 public override string ToString()
 {
     return(Years + "y " + Months + "m " + Days + "d " + Hours + "h " + Minutes + "min " + Seconds + "s " + Milliseconds.ToString("000") + "ms");
 }
Esempio n. 10
0
 protected override void Write(string[] args)
 {
     args[1] = Milliseconds.ToString();
     args[2] = "ms";
 }