2015-12-09 09:57:45 -08:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-03-09 08:15:18 -08:00
|
|
|
|
using Microsoft.DotNet.ProjectModel.Server.Models;
|
2015-12-09 09:57:45 -08:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.ProjectModel.Server.Messengers
|
|
|
|
|
{
|
2016-01-02 00:44:59 -08:00
|
|
|
|
internal class GlobalErrorMessenger : Messenger<ProjectSnapshot>
|
2015-12-09 09:57:45 -08:00
|
|
|
|
{
|
|
|
|
|
public GlobalErrorMessenger(Action<string, object> transmit)
|
|
|
|
|
: base(MessageTypes.Error, transmit)
|
|
|
|
|
{ }
|
|
|
|
|
|
2016-01-02 00:44:59 -08:00
|
|
|
|
protected override bool CheckDifference(ProjectSnapshot local, ProjectSnapshot remote)
|
2015-12-09 09:57:45 -08:00
|
|
|
|
{
|
|
|
|
|
return remote != null && Equals(local.GlobalErrorMessage, remote.GlobalErrorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-02 22:53:20 -08:00
|
|
|
|
protected override void SendPayload(ProjectSnapshot local, Action<object> send)
|
2015-12-09 09:57:45 -08:00
|
|
|
|
{
|
2016-03-02 22:53:20 -08:00
|
|
|
|
if (local.GlobalErrorMessage != null)
|
|
|
|
|
{
|
|
|
|
|
send(local.GlobalErrorMessage);
|
|
|
|
|
}
|
2016-03-09 08:15:18 -08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
send(new ErrorMessage
|
|
|
|
|
{
|
|
|
|
|
Message = null,
|
|
|
|
|
Path = null,
|
|
|
|
|
Line = -1,
|
|
|
|
|
Column = -1
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-12-09 09:57:45 -08:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 00:44:59 -08:00
|
|
|
|
protected override void SetValue(ProjectSnapshot local, ProjectSnapshot remote)
|
2015-12-09 09:57:45 -08:00
|
|
|
|
{
|
|
|
|
|
remote.GlobalErrorMessage = local.GlobalErrorMessage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|