From 3d050e019e2c3a489a1a5d979f86b66029f64b80 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 10 Jun 2015 02:46:17 +0200 Subject: [PATCH] * NpgsqlCircleProvider.cs: implements a Circle provider * NpgsqlContentProvider.csproj: new circle provider * CircleManager.cs: initializes the default provider * CircleProvider.cs: Makes abstract the CircleProvider class --- NpgsqlContentProvider/ChangeLog | 6 ++ NpgsqlContentProvider/NpgsqlCircleProvider.cs | 97 +++++++++++++++++++ .../NpgsqlContentProvider.csproj | 1 + yavscModel/ChangeLog | 6 ++ yavscModel/Circles/CircleManager.cs | 4 +- yavscModel/Circles/CircleProvider.cs | 32 +++--- 6 files changed, 125 insertions(+), 21 deletions(-) create mode 100644 NpgsqlContentProvider/NpgsqlCircleProvider.cs diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index 4f9894ec..b0b46312 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,9 @@ +2015-06-10 Paul Schneider + + * NpgsqlCircleProvider.cs: implements a Circle provider + + * NpgsqlContentProvider.csproj: new circle provider + 2015-06-09 Paul Schneider * NpgsqlContentProvider.csproj: Helps to fix packaging, and diff --git a/NpgsqlContentProvider/NpgsqlCircleProvider.cs b/NpgsqlContentProvider/NpgsqlCircleProvider.cs new file mode 100644 index 00000000..6ae3bb02 --- /dev/null +++ b/NpgsqlContentProvider/NpgsqlCircleProvider.cs @@ -0,0 +1,97 @@ +// +// NpgsqlCircleProvider.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +using System; +using Yavsc.Model.Circles; +using System.Collections.Specialized; +using System.Configuration; + +namespace WorkFlowProvider +{ + /// + /// Npgsql circle provider. + /// + public class NpgsqlCircleProvider : CircleProvider + { + /// + /// Initializes a new instance of the class. + /// + public NpgsqlCircleProvider () + { + } + + #region implemented abstract members of CircleProvider + /// + /// Add the specified owner, title and users. + /// + /// Owner. + /// Title. + /// Users. + public override void Add (string owner, string title, string[] users) + { + throw new NotImplementedException (); + } + /// + /// Delete the specified owner and title. + /// + /// Owner. + /// Title. + public override void Delete (string owner, string title) + { + throw new NotImplementedException (); + } + /// + /// Get the specified owner and title. + /// + /// Owner. + /// Title. + public override Circle Get (string owner, string title) + { + throw new NotImplementedException (); + } + /// + /// List this instance. + /// + public override CircleInfoCollection List () + { + throw new NotImplementedException (); + } + + #endregion + + string cnxstr = null; + string applicationName = null; + /// + /// Initialize this object using the specified name and config. + /// + /// Name. + /// Config. + public override void Initialize (string name, NameValueCollection config) + { + if ( string.IsNullOrWhiteSpace(config ["connectionStringName"])) + throw new ConfigurationErrorsException ("No name for Npgsql connection string found"); + + cnxstr = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString; + applicationName = config["applicationName"] ?? "/"; + } + + } +} + diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.csproj b/NpgsqlContentProvider/NpgsqlContentProvider.csproj index a402c4bc..39308bf4 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.csproj +++ b/NpgsqlContentProvider/NpgsqlContentProvider.csproj @@ -47,6 +47,7 @@ + diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog index 455d1db6..78f6d602 100644 --- a/yavscModel/ChangeLog +++ b/yavscModel/ChangeLog @@ -1,3 +1,9 @@ +2015-06-10 Paul Schneider + + * CircleManager.cs: initializes the default provider + + * CircleProvider.cs: Makes abstract the CircleProvider class + 2015-06-10 Paul Schneider * Circle.cs: diff --git a/yavscModel/Circles/CircleManager.cs b/yavscModel/Circles/CircleManager.cs index f349829b..f5a0f280 100644 --- a/yavscModel/Circles/CircleManager.cs +++ b/yavscModel/Circles/CircleManager.cs @@ -66,8 +66,10 @@ namespace Yavsc.Model.Circles ProviderSettingsCollection providerSettings = pSection.Providers; if (pSection.DefaultProvider != null) { - ConstructorInfo ci = Type.GetType (providerSettings [pSection.DefaultProvider].Type).GetConstructor (Type.EmptyTypes); + var pSetDef = providerSettings [pSection.DefaultProvider]; + ConstructorInfo ci = Type.GetType (pSetDef.Type).GetConstructor (Type.EmptyTypes); defaultProvider = ci.Invoke (Type.EmptyTypes) as CircleProvider; + defaultProvider.Initialize (pSection.DefaultProvider,pSetDef.Parameters); } /* diff --git a/yavscModel/Circles/CircleProvider.cs b/yavscModel/Circles/CircleProvider.cs index cebabb32..07687806 100644 --- a/yavscModel/Circles/CircleProvider.cs +++ b/yavscModel/Circles/CircleProvider.cs @@ -31,43 +31,35 @@ namespace Yavsc.Model.Circles /// /// Circle provider. /// - public class CircleProvider: ProviderBase + public abstract class CircleProvider: ProviderBase { /// - /// Add the specified title and users. + /// Add the specified owner, title and users. /// + /// Owner. /// Title. /// Users. - public void Add(string owner, string title, string [] users) - { - throw new NotImplementedException (); - } + public abstract void Add(string owner, string title, string [] users); + /// - /// Delete the specified id. + /// Delete the specified owner and title. /// + /// Owner. /// Title. - public void Delete(string owner, string title) - { - throw new NotImplementedException (); - } + public abstract void Delete(string owner, string title) ; /// - /// Get the specified id. + /// Get the specified owner and title. /// + /// Owner. /// Title. - public Circle Get(string owner, string title) - { - throw new NotImplementedException (); - } + public abstract Circle Get(string owner, string title); /// /// List this instance. /// - public CircleInfoCollection List() - { - throw new NotImplementedException (); - } + public abstract CircleInfoCollection List(); }