Skip to content

Commit

Permalink
fix: 修复CA1030, CA1031错误
Browse files Browse the repository at this point in the history
  • Loading branch information
leven99 committed Oct 24, 2019
1 parent ee45af0 commit 0ccd611
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 192 deletions.
46 changes: 6 additions & 40 deletions Models/TimerM.cs
Expand Up @@ -4,8 +4,12 @@

namespace OSDA.Models
{
internal class TimerModel : MainWindowBase, IDisposable
internal class TimerModel : MainWindowBase
{
#region 字段
private static Timer SystemTimer = null; /* 该对象持续存在于整个应用程序运行期间 */
#endregion

/// <summary>
/// 状态栏 - 系统时间
/// </summary>
Expand All @@ -26,8 +30,6 @@ public string SystemTime
}
}

private static Timer SystemTimer = null;

public void InitSystemClockTimer()
{
SystemTimer = new Timer
Expand All @@ -47,18 +49,15 @@ private void SystemTimer_Elapsed(object sender, ElapsedEventArgs e)

private string SystemTimeData()
{
string SystemTime;
DateTime systemTime = DateTime.Now;

SystemTime = string.Format(cultureInfo, "{0}年{1}月{2}日 {3}:{4}:{5}",
return string.Format(cultureInfo, "{0}年{1}月{2}日 {3}:{4}:{5}",
systemTime.Year.ToString("0000", cultureInfo),
systemTime.Month.ToString("00", cultureInfo),
systemTime.Day.ToString("00", cultureInfo),
systemTime.Hour.ToString("00", cultureInfo),
systemTime.Minute.ToString("00", cultureInfo),
systemTime.Second.ToString("00", cultureInfo));

return SystemTime;
}

public void TimerDataContext()
Expand All @@ -67,38 +66,5 @@ public void TimerDataContext()

InitSystemClockTimer();
}

#region IDisposable Support
private bool disposedValue = false;

/// <summary>
/// 受保护的 Dispose 方法实现
/// </summary>
/// <param name="disposing"></param>
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
/* 释放托管资源(如果需要) */
}

SystemTimer.Dispose();
SystemTimer = null;

disposedValue = true;
}
}

/// <summary>
/// SerialPort 字段 IDisposable 接口的 Dispose 方法实现(无参数)
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}
8 changes: 4 additions & 4 deletions ViewModels/MainWindowBase.cs
Expand Up @@ -4,20 +4,20 @@

namespace OSDA.ViewModels
{
public class MainWindowBase : INotifyPropertyChanged
internal class MainWindowBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// 提供区域性信息
/// </summary>
internal CultureInfo cultureInfo = new CultureInfo(CultureInfo.CurrentUICulture.Name);

public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// 提供属性更改事件的方法
/// </summary>
/// <param name="propertyName"></param>
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
internal void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;

Expand Down

0 comments on commit 0ccd611

Please sign in to comment.