-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#105 Can now enable and disable cameras using a POST to the camera en…
…d point.
- Loading branch information
Dan Done
committed
Oct 9, 2022
1 parent
bc76221
commit 8f92c0e
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace SynoAI.Models.DTOs | ||
{ | ||
public class CameraOptionsDto : UpdateDto<CameraOptionsDto> | ||
{ | ||
public bool Enabled | ||
{ | ||
get | ||
{ | ||
return _enabled; | ||
} | ||
set | ||
{ | ||
NotifyPropertyChange(); | ||
_enabled = value; | ||
} | ||
} | ||
private bool _enabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Runtime.CompilerServices; | ||
using System; | ||
|
||
namespace SynoAI.Models.DTOs | ||
{ | ||
public abstract class UpdateDto<T> | ||
{ | ||
public List<string> ChangedProperties = new List<string>(); | ||
|
||
protected void NotifyPropertyChange([CallerMemberName] string propertyName = "") | ||
{ | ||
ChangedProperties.Add(propertyName); | ||
} | ||
|
||
public bool HasChanged(Expression<Func<T, object>> expression) | ||
{ | ||
if (expression.Body is not MemberExpression body) | ||
{ | ||
body = ((UnaryExpression)expression.Body).Operand as MemberExpression; | ||
} | ||
return HasChanged(body.Member.Name); | ||
} | ||
|
||
public bool HasChanged(string propertyName) | ||
{ | ||
return ChangedProperties.Contains(propertyName); | ||
} | ||
} | ||
} |