public static AnyValue Convert(IEnumerable <Notification> notifications)
            {
                IList <AnyValue> @out = new List <AnyValue>();

                foreach (Notification notification in notifications)
                {
                    InputPosition   pos             = notification.Position;                // position is optional
                    bool            includePosition = !pos.Equals(InputPosition.empty);
                    int             size            = includePosition ? 5 : 4;
                    MapValueBuilder builder         = new MapValueBuilder(size);

                    builder.Add("code", stringValue(notification.Code));
                    builder.Add("title", stringValue(notification.Title));
                    builder.Add("description", stringValue(notification.Description));
                    builder.Add("severity", stringValue(notification.Severity.ToString()));

                    if (includePosition)
                    {
                        // only add the position if it is not empty
                        builder.Add("position", VirtualValues.map(new string[] { "offset", "line", "column" }, new AnyValue[] { intValue(pos.Offset), intValue(pos.Line), intValue(pos.Column) }));
                    }

                    @out.Add(builder.Build());
                }
                return(VirtualValues.fromList(@out));
            }
Exemple #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }

            TestNotification that = ( TestNotification )o;

            if (!string.ReferenceEquals(_code, null) ?!_code.Equals(that._code) :!string.ReferenceEquals(that._code, null))
            {
                return(false);
            }
            if (!string.ReferenceEquals(_title, null) ?!_title.Equals(that._title) :!string.ReferenceEquals(that._title, null))
            {
                return(false);
            }
            if (!string.ReferenceEquals(_description, null) ?!_description.Equals(that._description) :!string.ReferenceEquals(that._description, null))
            {
                return(false);
            }
            if (_severityLevel != that._severityLevel)
            {
                return(false);
            }
            return(_position != null?_position.Equals(that._position) : that._position == null);
        }
Exemple #3
0
        /// <summary>
        /// Returns true if TemperatureZone instances are equal
        /// </summary>
        /// <param name="other">Instance of TemperatureZone to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TemperatureZone other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     InputPosition == other.InputPosition ||
                     InputPosition != null &&
                     InputPosition.Equals(other.InputPosition)
                 ) &&
                 (
                     OutputPosition == other.OutputPosition ||
                     OutputPosition != null &&
                     OutputPosition.Equals(other.OutputPosition)
                 ) &&
                 (
                     Zone == other.Zone ||
                     Zone != null &&
                     Zone.Equals(other.Zone)
                 ));
        }