Пример #1
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (StartTime != null)
                {
                    hashCode = hashCode * 59 + StartTime.GetHashCode();
                }

                if (EndTime != null)
                {
                    hashCode = hashCode * 59 + EndTime.GetHashCode();
                }

                if (Stdout != null)
                {
                    hashCode = hashCode * 59 + Stdout.GetHashCode();
                }

                if (Stderr != null)
                {
                    hashCode = hashCode * 59 + Stderr.GetHashCode();
                }

                if (ExitCode != null)
                {
                    hashCode = hashCode * 59 + ExitCode.GetHashCode();
                }

                return(hashCode);
            }
        }
Пример #2
0
            public virtual void Print()
            {
                if (msg_recorder != null)
                {
                    //
                    // This line is useful when debugging messages recorder
                    //
                    // Console.WriteLine ("RECORDING: {0} {1} {2}", code, location, message);
                    msg_recorder.AddMessage(this);
                    return;
                }

                if (reporting_disabled)
                {
                    return;
                }

                StringBuilder msg = new StringBuilder();

                if (!location.IsNull)
                {
                    msg.Append(location.ToString());
                    msg.Append(" ");
                }
                msg.AppendFormat("{0} CS{1:0000}: {2}", MessageType, code, message);

                //
                //
                if (Stderr == Console.Error)
                {
                    Stderr.WriteLine(ColorFormat(msg.ToString()));
                }
                else
                {
                    Stderr.WriteLine(msg.ToString());
                }

                if (extra_info != null)
                {
                    foreach (string s in extra_info)
                    {
                        Stderr.WriteLine(s + MessageType + ")");
                    }
                }

                if (Stacktrace)
                {
                    Console.WriteLine(FriendlyStackTrace(new StackTrace(true)));
                }

                if (Fatal)
                {
                    if (!IsWarning || WarningsAreErrors)
                    {
                        throw new Exception(message);
                    }
                }

                Check(code);
            }
Пример #3
0
        public void Dispose()
        {
            Stdin.Dispose();
            Stdout.Dispose();
            Stderr.Dispose();

            CloseCore();
        }
Пример #4
0
        /// <summary>
        /// Returns true if TesExecutor instances are equal
        /// </summary>
        /// <param name="other">Instance of TesExecutor to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TesExecutor other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Image == other.Image ||
                     Image != null &&
                     Image.Equals(other.Image)
                     ) &&
                 (
                     Command == other.Command ||
                     Command != null &&
                     Command.SequenceEqual(other.Command)
                 ) &&
                 (
                     Workdir == other.Workdir ||
                     Workdir != null &&
                     Workdir.Equals(other.Workdir)
                 ) &&
                 (
                     Stdin == other.Stdin ||
                     Stdin != null &&
                     Stdin.Equals(other.Stdin)
                 ) &&
                 (
                     Stdout == other.Stdout ||
                     Stdout != null &&
                     Stdout.Equals(other.Stdout)
                 ) &&
                 (
                     Stderr == other.Stderr ||
                     Stderr != null &&
                     Stderr.Equals(other.Stderr)
                 ) &&
                 (
                     Env == other.Env ||
                     Env != null &&
                     Env.SequenceEqual(other.Env)
                 ));
        }
        /// <summary>
        /// This method is called internally when data is received and fed to this Request. It basically sets this request's properties
        /// or appends data to the streams. Override it and call the base method itself to implement your own logics and checking.
        /// </summary>
        protected virtual void AddReceivedRecord(RecordBase rec)
        {
            if (rec == null)
            {
                throw new ArgumentNullException("rec");
            }

            switch (rec.RecordType)
            {
            case RecordType.FCGIBeginRequest:
                // Make sure we are not getting a BeginRequest once again, as this could be serious.
                if (BeginRequestReceived)
                {
                    throw new InvalidOperationException("A BeginRequest Record has already been received by this Request");
                }

                BeginRequestReceived = true;
                RequestId            = ((BeginRequestRecord)rec).RequestId;
                break;

            case RecordType.FCGIEndRequest:
                // Make sure we are not getting a BeginRequest once again, as this could be serious.
                if (EndRequestReceived)
                {
                    throw new InvalidOperationException("An EndRequest Record has already been received by this Request");
                }

                EndRequestReceived = true;
                break;

            case RecordType.FCGIParams:
                Params.AppendStream(((StreamRecordBase)rec).Contents);
                break;

            case RecordType.FCGIStdin:
                Stdin.AppendStream(((StreamRecordBase)rec).Contents);
                break;

            case RecordType.FCGIStdout:
                Stdout.AppendStream(((StreamRecordBase)rec).Contents);
                break;

            case RecordType.FCGIStderr:
                Stderr.AppendStream(((StreamRecordBase)rec).Contents);
                break;
            }
        }
Пример #6
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Image != null)
                {
                    hashCode = hashCode * 59 + Image.GetHashCode();
                }

                if (Command != null)
                {
                    hashCode = hashCode * 59 + Command.GetHashCode();
                }

                if (Workdir != null)
                {
                    hashCode = hashCode * 59 + Workdir.GetHashCode();
                }

                if (Stdin != null)
                {
                    hashCode = hashCode * 59 + Stdin.GetHashCode();
                }

                if (Stdout != null)
                {
                    hashCode = hashCode * 59 + Stdout.GetHashCode();
                }

                if (Stderr != null)
                {
                    hashCode = hashCode * 59 + Stderr.GetHashCode();
                }

                if (Env != null)
                {
                    hashCode = hashCode * 59 + Env.GetHashCode();
                }

                return(hashCode);
            }
        }
Пример #7
0
        /// <summary>
        /// Returns true if TesExecutorLog instances are equal
        /// </summary>
        /// <param name="other">Instance of TesExecutorLog to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TesExecutorLog other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     StartTime == other.StartTime ||
                     StartTime != null &&
                     StartTime.Equals(other.StartTime)
                     ) &&
                 (
                     EndTime == other.EndTime ||
                     EndTime != null &&
                     EndTime.Equals(other.EndTime)
                 ) &&
                 (
                     Stdout == other.Stdout ||
                     Stdout != null &&
                     Stdout.Equals(other.Stdout)
                 ) &&
                 (
                     Stderr == other.Stderr ||
                     Stderr != null &&
                     Stderr.Equals(other.Stderr)
                 ) &&
                 (
                     ExitCode == other.ExitCode ||
                     ExitCode != null &&
                     ExitCode.Equals(other.ExitCode)
                 ));
        }
Пример #8
0
 public void Dispose()
 {
     Stdout?.Dispose();
     Stderr?.Dispose();
 }