Skip to content

Commit

Permalink
remove members marked as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Mar 30, 2024
1 parent 7d4a951 commit ee750b7
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 382 deletions.

This file was deleted.

21 changes: 0 additions & 21 deletions src/Smdn.Net.EchonetLite/EchoDotNetLite.Models/EchoNode.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: 2018 HiroyukiSakoh
// SPDX-FileCopyrightText: 2023 smdn <smdn@smdn.jp>
// SPDX-License-Identifier: MIT
using EchoDotNetLite.Common;
using EchoDotNetLite.Specifications;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -32,20 +31,6 @@ public EchoNode(IPAddress address, EchoObjectInstance nodeProfile)
private void OnDevicesChanged(NotifyCollectionChangedEventArgs e)
{
DevicesChanged?.Invoke(this, e);

// translate event args to raise obsolete OnCollectionChanged event
#pragma warning disable CS0618
var handler = OnCollectionChanged;

if (handler is null)
return;

if (e.TryGetAddedItem<EchoObjectInstance>(out var addedObject))
handler(this, (CollectionChangeType.Add, addedObject));

if (e.TryGetRemovedItem<EchoObjectInstance>(out var removedObject))
handler(this, (CollectionChangeType.Remove, removedObject));
#pragma warning restore CS0618
}

/// <summary>
Expand All @@ -71,12 +56,6 @@ private void OnDevicesChanged(NotifyCollectionChangedEventArgs e)
/// 変更の詳細は、イベント引数<see cref="NotifyCollectionChangedEventArgs"/>を参照してください。
/// </remarks>
public event NotifyCollectionChangedEventHandler? DevicesChanged;

/// <summary>
/// イベント オブジェクトインスタンス増減通知
/// </summary>
[Obsolete($"Use {nameof(DevicesChanged)} instead.")]
public event EventHandler<(CollectionChangeType, EchoObjectInstance)>? OnCollectionChanged;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Specialized;
using System.Collections.ObjectModel;
using System.Linq;
using EchoDotNetLite.Common;
using EchoDotNetLite.Specifications;

namespace EchoDotNetLite.Models
Expand All @@ -15,9 +14,7 @@ namespace EchoDotNetLite.Models
/// <summary>
/// ECHONET Lite オブジェクトインスタンス
/// </summary>
#pragma warning disable CA1708
public sealed class EchoObjectInstance
#pragma warning restore CA1708
{
/// <summary>
/// デフォルトコンストラクタ
Expand Down Expand Up @@ -65,20 +62,6 @@ public EchoObjectInstance(IEchonetObject classObject,byte instanceCode)
private void OnPropertiesChanged(NotifyCollectionChangedEventArgs e)
{
PropertiesChanged?.Invoke(this, e);

#pragma warning disable CS0618
// translate event args to raise obsolete OnCollectionChanged event
var handler = OnCollectionChanged;

if (handler is null)
return;

if (e.TryGetAddedItem<EchoPropertyInstance>(out var addedProperty))
handler(this, (CollectionChangeType.Add, addedProperty));

if (e.TryGetRemovedItem<EchoPropertyInstance>(out var removedProperty))
handler(this, (CollectionChangeType.Remove, removedProperty));
#pragma warning restore CS0618
}

internal void AddProperty(EchoPropertyInstance prop)
Expand Down Expand Up @@ -114,22 +97,13 @@ internal void ResetProperties(IEnumerable<EchoPropertyInstance> props)
/// </remarks>
public event NotifyCollectionChangedEventHandler? PropertiesChanged;

/// <summary>
/// イベント オブジェクトインスタンス増減通知
/// </summary>
[Obsolete($"Use {nameof(PropertiesChanged)} instead.")]
public event EventHandler<(CollectionChangeType, EchoPropertyInstance)>? OnCollectionChanged;

/// <summary>
/// プロパティマップ取得状態
/// </summary>
/// <seealso cref="EchoClient.PropertyMapAcquiring"/>
/// <seealso cref="EchoClient.PropertyMapAcquired"/>
public bool HasPropertyMapAcquired { get; internal set; } = false;

[Obsolete($"Use {nameof(HasPropertyMapAcquired)} instead.")]
public bool IsPropertyMapGet => HasPropertyMapAcquired;

/// <summary>
/// クラスグループコード、クラスグループ名
/// ECHONET機器オブジェクト詳細規定がある場合、詳細仕様
Expand All @@ -150,31 +124,16 @@ internal void ResetProperties(IEnumerable<EchoPropertyInstance> props)
/// <summary>
/// GETプロパティの一覧
/// </summary>
#pragma warning disable CA1708
public IEnumerable<EchoPropertyInstance> GetProperties => Properties.Where(static p => p.Spec.Get);

[Obsolete($"Use {nameof(GetProperties)} instead.")]
public IEnumerable<EchoPropertyInstance> GETProperties => GetProperties;
#pragma warning restore CA1708

/// <summary>
/// SETプロパティの一覧
/// </summary>
#pragma warning disable CA1708
public IEnumerable<EchoPropertyInstance> SetProperties => Properties.Where(static p => p.Spec.Set);

[Obsolete($"Use {nameof(SetProperties)} instead.")]
public IEnumerable<EchoPropertyInstance> SETProperties => SetProperties;
#pragma warning restore CA1708

/// <summary>
/// ANNOプロパティの一覧
/// </summary>
#pragma warning disable CA1708
public IEnumerable<EchoPropertyInstance> AnnoProperties => Properties.Where(static p => p.Spec.Anno);

[Obsolete($"Use {nameof(AnnoProperties)} instead.")]
public IEnumerable<EchoPropertyInstance> ANNOProperties => AnnoProperties;
#pragma warning restore CA1708
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,36 +131,22 @@ bool isPropertyGet
/// </summary>
public ReadOnlySpan<byte> ValueSpan => _value is null ? ReadOnlySpan<byte>.Empty : _value.WrittenSpan;

/// <summary>
/// プロパティ値変更イベント
/// </summary>
/// <remarks>
/// このイベントは、プロパティ値の設定が行われる場合に発生します。
/// このイベントは、設定される値が以前と同じ値の場合でも発生します。
/// </remarks>
/// <seealso cref="ValueChanged"/>
[Obsolete($"Use {nameof(ValueChanged)} instead.")]
public event EventHandler<ReadOnlyMemory<byte>>? ValueSet;

/// <summary>
/// プロパティ値に変更があった場合に発生するイベント。
/// </summary>
/// <remarks>
/// このイベントは、プロパティに異なる値が設定された場合にのみ発生します。
/// プロパティに値が設定される際、その値が以前と同じ値だった場合には発生しません。
/// </remarks>
/// <seealso cref="ValueSet"/>
public event EventHandler<(ReadOnlyMemory<byte> OldValue, ReadOnlyMemory<byte> NewValue)>? ValueChanged;

/// <summary>
/// プロパティ値を設定します。
/// </summary>
/// <remarks>
/// プロパティ値の設定が行われたあと、イベント<see cref="ValueSet"/>が発生します。
/// 設定によって値が変更された場合は、イベント<see cref="ValueChanged"/>も発生します。
/// 設定によって値が変更された場合は、イベント<see cref="ValueChanged"/>が発生します。
/// </remarks>
/// <param name="newValue">プロパティ値として設定する値を表す<see cref="ReadOnlyMemory{Byte}"/>。</param>
/// <seealso cref="ValueSet"/>
/// <seealso cref="ValueChanged"/>
public void SetValue(ReadOnlyMemory<byte> newValue)
=> WriteValue(writer => writer.Write(newValue.Span), newValueSize: newValue.Length);
Expand All @@ -169,15 +155,13 @@ public void SetValue(ReadOnlyMemory<byte> newValue)
/// プロパティ値を書き込みます。
/// </summary>
/// <remarks>
/// プロパティ値の設定が行われたあと、イベント<see cref="ValueSet"/>が発生します。
/// 書き込みによって値が変更された場合は、イベント<see cref="ValueChanged"/>も発生します。
/// 書き込みによって値が変更された場合は、イベント<see cref="ValueChanged"/>が発生します。
/// </remarks>
/// <param name="write">
/// プロパティ値を書き込むための<see cref="Action{T}"/>デリゲート。
/// 引数で渡される<see cref="IBufferWriter{Byte}"/>を介してプロパティ値として設定する内容を書き込んでください。
/// </param>
/// <exception cref="ArgumentNullException"><paramref name="write"/>が<see langword="null"/>です。</exception>
/// <seealso cref="ValueSet"/>
/// <seealso cref="ValueChanged"/>
public void WriteValue(Action<IBufferWriter<byte>> write)
=> WriteValue(write ?? throw new ArgumentNullException(nameof(write)), newValueSize: 0);
Expand Down Expand Up @@ -214,9 +198,6 @@ private void WriteValue(Action<IBufferWriter<byte>> write, int newValueSize)

write(_value);

// 変更がなくてもValueSetイベントを起こす
ValueSet?.Invoke(this, _value.WrittenMemory);

if (valueChangedHandlers is not null)
{
// 値が新規に設定される場合、以前の値から変更がある場合はValueChangedイベントを起こす
Expand Down
Loading

0 comments on commit ee750b7

Please sign in to comment.