示例#1
0
        public IHttpActionResult PutStatusDescription(int id, StatusDescription statusDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != statusDescription.ID)
            {
                return(BadRequest());
            }

            db.Entry(statusDescription).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StatusDescriptionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (m_ObjPropertyCollection != null ? m_ObjPropertyCollection.GetHashCode() : 0);
         result = (result * 397) ^ (CharacterSet != null ? CharacterSet.GetHashCode() : 0);
         result = (result * 397) ^ (ContentEncoding != null ? ContentEncoding.GetHashCode() : 0);
         result = (result * 397) ^ (ContentType != null ? ContentType.GetHashCode() : 0);
         result = (result * 397) ^ (Headers != null ? Headers.GetHashCode() : 0);
         result = (result * 397) ^ IsFromCache.GetHashCode();
         result = (result * 397) ^ IsMutuallyAuthenticated.GetHashCode();
         result = (result * 397) ^ LastModified.GetHashCode();
         result = (result * 397) ^ (Method != null ? Method.GetHashCode() : 0);
         result = (result * 397) ^ (OriginalReferrerUrl != null ? OriginalReferrerUrl.GetHashCode() : 0);
         result = (result * 397) ^ (OriginalUrl != null ? OriginalUrl.GetHashCode() : 0);
         result = (result * 397) ^ (ProtocolVersion != null ? ProtocolVersion.GetHashCode() : 0);
         result = (result * 397) ^ (Referrer != null ? Referrer.GetHashCode() : 0);
         result = (result * 397) ^ (ResponseUri != null ? ResponseUri.GetHashCode() : 0);
         result = (result * 397) ^ (Server != null ? Server.GetHashCode() : 0);
         result = (result * 397) ^ StatusCode.GetHashCode();
         result = (result * 397) ^ (StatusDescription != null ? StatusDescription.GetHashCode() : 0);
         result = (result * 397) ^ (Step != null ? Step.GetHashCode() : 0);
         result = (result * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         result = (result * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         result = (result * 397) ^ DownloadTime.GetHashCode();
         return(result);
     }
 }
示例#3
0
 /// <summary>
 /// Compare expected status description with response status code
 /// </summary>
 /// <param name="expectedStatusDescription">Expected Status description</param>
 /// <returns>True if description matches expected status description</returns>
 public bool AssertStatusDescription(string expectedStatusDescription)
 {
     if (StatusDescription == null)
     {
         return(false);
     }
     return(StatusDescription.Equals(expectedStatusDescription));
 }
示例#4
0
        /// <summary>
        /// Pretty output for this exception
        /// </summary>
        /// <returns>Request, response and errors</returns>
        public override string ToString()
        {
            // Used for the LogResponse Action
            string retVal = string.Empty;

            retVal += string.Format("Request: {0}\n", LastDataPosted);
            retVal += string.Format("Response: {0} {1}\n", StatusCode.ToString(), StatusDescription.ToString());
            retVal += string.Format("Errors: {0}\n", string.Join(", ", _errors.ToList().Select(e => e.Message).ToArray()));
            return(retVal);
        }
示例#5
0
        public IHttpActionResult GetStatusDescription(int id)
        {
            StatusDescription statusDescription = db.StatusDescriptions.Find(id);

            if (statusDescription == null)
            {
                return(NotFound());
            }

            return(Ok(statusDescription));
        }
示例#6
0
        public IHttpActionResult PostStatusDescription(StatusDescription statusDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StatusDescriptions.Add(statusDescription);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = statusDescription.ID }, statusDescription));
        }
示例#7
0
        public IHttpActionResult DeleteStatusDescription(int id)
        {
            StatusDescription statusDescription = db.StatusDescriptions.Find(id);

            if (statusDescription == null)
            {
                return(NotFound());
            }

            db.StatusDescriptions.Remove(statusDescription);
            db.SaveChanges();

            return(Ok(statusDescription));
        }
示例#8
0
        public override string ToString()
        {
            var str = "Success: {0}, Status: {1} ({2})".FormatInvariant(
                Success,
                (int)(Status.HasValue ? Status.Value : 0),
                Status.HasValue ? Status.Value.ToString() : "".NaIfEmpty()
                );

            if (StatusDescription.HasValue() && Status.HasValue && !StatusDescription.IsCaseInsensitiveEqual(Status.Value.ToString()))
            {
                return(str + ". Description: " + StatusDescription);
            }

            return(str);
        }
        // todo: set FX in SO
        private void OnStatusRemoved(StatusDescription desc)
        {
            switch (desc.statusType)
            {
            case StatusType.SpeedUp:
                playerMove.moveSpeed -= 3;
                break;

            case StatusType.SpeedDown:
                playerMove.moveSpeed += 2;
                break;

            default:
                break;
            }
        }
    public UnitComponentData( UnitComponentData _src )
    {
        this.m_Name = _src.m_Name ;
        this.m_HP = new StandardParameter( _src.m_HP ) ;
        this.m_Energy = new StandardParameter( _src.m_Energy ) ;
        this.m_Generation = new StandardParameter( _src.m_Generation ) ;
        this.m_Effect = new StandardParameter( _src.m_Effect ) ;

        this.m_Status = _src.m_Status ;
        this.m_StatusDescription = new StatusDescription( _src.m_StatusDescription ) ;
        this.m_Effect_HP_Curve = new InterpolateTable( _src.m_Effect_HP_Curve ) ;

        this.m_ReloadEnergy = new StandardParameter( _src.m_ReloadEnergy ) ;
        this.m_ReloadGeneration = new StandardParameter( _src.m_ReloadGeneration ) ;
        this.m_WeaponReloadStatus = _src.m_WeaponReloadStatus ;

        this.m_ComponentParam = new ComponentParam( _src.m_ComponentParam ) ;
        this.m_WeaponParam = new WeaponParam( _src.m_WeaponParam ) ;
    }
示例#11
0
        RenderAnsi(ArrayList strCollection, int indentation, int maxWidth)
        {
            string indent    = StringUtil.Padding(indentation);
            string secRemain = string.Empty;

            if (SecondsRemaining >= 0)
            {
                secRemain = SecondsRemaining.ToString() + "s";
            }

            int secRemainLength = secRemain.Length + 1;

            // limit progress bar to 120 chars as no need to render full width
            if (PSStyle.Instance.Progress.MaxWidth > 0 && maxWidth > PSStyle.Instance.Progress.MaxWidth)
            {
                maxWidth = PSStyle.Instance.Progress.MaxWidth;
            }

            // if the activity is really long, only use up to half the width
            string activity;

            if (Activity.Length > maxWidth / 2)
            {
                activity = Activity.Substring(0, maxWidth / 2) + PSObjectHelper.Ellipsis;
            }
            else
            {
                activity = Activity;
            }

            // 4 is for the extra space and square brackets below and one extra space
            int barWidth = maxWidth - activity.Length - indentation - 4;

            var sb      = new StringBuilder();
            int padding = maxWidth + PSStyle.Instance.Progress.Style.Length + PSStyle.Instance.Reverse.Length + PSStyle.Instance.ReverseOff.Length;

            sb.Append(PSStyle.Instance.Reverse);

            int maxStatusLength = barWidth - secRemainLength - 1;

            if (maxStatusLength > 0 && StatusDescription.Length > barWidth - secRemainLength)
            {
                sb.Append(StatusDescription.AsSpan(0, barWidth - secRemainLength - 1));
                sb.Append(PSObjectHelper.Ellipsis);
            }
            else
            {
                sb.Append(StatusDescription);
            }

            int emptyPadLength = barWidth + PSStyle.Instance.Reverse.Length - sb.Length - secRemainLength;

            if (emptyPadLength > 0)
            {
                sb.Append(string.Empty.PadRight(emptyPadLength));
            }

            sb.Append(secRemain);

            if (PercentComplete > 0 && PercentComplete < 100 && barWidth > 0)
            {
                int barLength = PercentComplete * barWidth / 100;
                if (barLength >= barWidth)
                {
                    barLength = barWidth - 1;
                }

                if (barLength < sb.Length)
                {
                    sb.Insert(barLength + PSStyle.Instance.Reverse.Length, PSStyle.Instance.ReverseOff);
                }
            }
            else
            {
                sb.Append(PSStyle.Instance.ReverseOff);
            }

            strCollection.Add(
                StringUtil.Format(
                    "{0}{1}{2} [{3}]{4}",
                    indent,
                    PSStyle.Instance.Progress.Style,
                    activity,
                    sb.ToString(),
                    PSStyle.Instance.Reset)
                .PadRight(padding));
        }
示例#12
0
        protected sealed override void setValue(object value)
        {
            var response = value as IRestResponse;

            if (Request != null)
            {
                Request.SetValue(response.Request);
            }

            if (ErrorMessage != null)
            {
                ErrorMessage.SetValue(response.ErrorMessage);
            }

            if (ResponseStatus != null)
            {
                ResponseStatus.SetValue(response.ResponseStatus);
            }

            if (Headers != null)
            {
                foreach (var header in Headers)
                {
                    var headerValue = response.Headers.FirstOrDefault(h => h.Name == header.Key);
                    if (headerValue != null)
                    {
                        header.Value.SetValue(headerValue.Value);
                    }
                }
            }

            if (Cookies != null)
            {
                foreach (var cookie in Cookies)
                {
                    var cookieValue = response.Cookies.FirstOrDefault(c => c.Name == cookie.Key);
                    if (cookieValue != null)
                    {
                        cookie.Value.SetValue(cookieValue.Value);
                    }
                }
            }

            if (Server != null)
            {
                Server.SetValue(response.Server);
            }

            if (ResponseUri != null)
            {
                ResponseUri.SetValue(response.ResponseUri);
            }

            if (ErrorException != null)
            {
                ErrorException.SetValue(response.ErrorException);
            }

            if (RawBytes != null)
            {
                RawBytes.SetValue(response.RawBytes);
            }

            if (IsSuccessful != null)
            {
                IsSuccessful.SetValue(response.IsSuccessful);
            }

            if (StatusCode != null)
            {
                StatusCode.SetValue(response.StatusCode);
            }

            if (Content != null)
            {
                Content.SetValue(response.Content);
            }

            if (ContentEncoding != null)
            {
                ContentEncoding.SetValue(response.ContentEncoding);
            }

            if (ContentLength != null)
            {
                ContentLength.SetValue(response.ContentLength);
            }

            if (ContentType != null)
            {
                ContentType.SetValue(response.ContentType);
            }

            if (StatusDescription != null)
            {
                StatusDescription.SetValue(response.StatusDescription);
            }

            if (ProtocolVersion != null)
            {
                ProtocolVersion.SetValue(response.ProtocolVersion);
            }

            setExtraValues(response);
        }
 public StatusDescription( StatusDescription _src )
 {
     high = _src.high ;
     low = _src.low ;
     zero = _src.zero ;
 }
 public bool RemoveStatus(StatusDescription desc, bool rmall = false)
 {
     return(sbCtrl.RemoveStatus(desc, rmall));
 }
 public void AddStatus(StatusDescription desc, bool continuous = true)
 {
     sbCtrl.AddStatus(desc, continuous);
 }
示例#16
0
 protected override void SendHeaders()
 {
     using (var ms = new MemoryStream())
     {
         using (var w = ms.UTF8StreamWriter())
         {
             w.Write(string.Format("HTTP/{0}.{1} {2} {3}\r\n", MajorVersion, MinorVersion, (uint)StatusCode, StatusDescription.Replace("\n", string.Empty).Replace("\r", string.Empty)));
             foreach (KeyValuePair <string, string> kvp in Headers)
             {
                 w.Write(string.Format("{0}: {1}\r\n", kvp.Key.Replace("\r", string.Empty).Replace("\n", string.Empty), kvp.Value.Replace("\r", string.Empty).Replace("\n", string.Empty)));
             }
             w.Write("\r\n");
         }
         byte[] b = ms.ToArray();
         m_Output.Write(b, 0, b.Length);
         m_Output.Flush();
     }
     m_IsHeaderSent = true;
 }