From 9aff64403e31227f3eca7fb39543ac66d22ca867 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 25 Oct 2020 15:55:30 -0400 Subject: [PATCH] move Plugin (now UserInterfacePlugin) from UWT to Framework --- MBS.Framework/Feature.cs | 66 ++++++++++++++++++++++++++++++ MBS.Framework/MBS.Framework.csproj | 2 + MBS.Framework/Plugin.cs | 60 +++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 MBS.Framework/Feature.cs create mode 100644 MBS.Framework/Plugin.cs diff --git a/MBS.Framework/Feature.cs b/MBS.Framework/Feature.cs new file mode 100644 index 0000000..768d6ed --- /dev/null +++ b/MBS.Framework/Feature.cs @@ -0,0 +1,66 @@ +// +// Feature.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2020 Mike Becker +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace MBS.Framework +{ + public class Feature + { + public class FeatureCollection + : System.Collections.ObjectModel.Collection + { + } + + public Guid ID { get; private set; } = Guid.Empty; + public string Title { get; private set; } = null; + + public Feature(Guid id, string title) + { + ID = id; + Title = title; + } + + public override bool Equals(object obj) + { + if (!(this is null) && (obj is null)) return false; + if (this is null && !(obj is null)) return false; + + if (obj is Feature) + { + Feature feat = (obj as Feature); + return feat.ID.Equals(ID); + } + return base.Equals(obj); + } + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public static bool operator ==(Feature left, Feature right) + { + return (left.ID == right.ID); + } + public static bool operator !=(Feature left, Feature right) + { + return (left.ID != right.ID); + } + } +} diff --git a/MBS.Framework/MBS.Framework.csproj b/MBS.Framework/MBS.Framework.csproj index adef941..6b2e350 100644 --- a/MBS.Framework/MBS.Framework.csproj +++ b/MBS.Framework/MBS.Framework.csproj @@ -74,6 +74,8 @@ + + diff --git a/MBS.Framework/Plugin.cs b/MBS.Framework/Plugin.cs new file mode 100644 index 0000000..24efbd1 --- /dev/null +++ b/MBS.Framework/Plugin.cs @@ -0,0 +1,60 @@ +// +// Plugin.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; + +namespace MBS.Framework +{ + public class Plugin + { + public virtual string Title { get; set; } = null; + public Feature.FeatureCollection ProvidedFeatures { get; } = new Feature.FeatureCollection(); + + public bool Initialized { get; private set; } = false; + public void Initialize() + { + if (Initialized) + return; + + InitializeInternal(); + Initialized = true; + } + + public Guid ID { get; set; } = Guid.Empty; + + protected virtual void InitializeInternal() + { + // this method intentionally left blank + } + + protected virtual bool IsSupportedInternal() + { + return true; + } + public bool IsSupported() + { + return IsSupportedInternal(); + } + + public Plugin() + { + } + } +}