From 01d797cf3384c10a8b5582417db131d7c6c57076 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 5 Nov 2012 11:26:11 +0000 Subject: [PATCH] Added public ctors (that can't be called compile-time) for City, Country, PostalCode, for serializability --- Logic/Structure/City.cs | 7 +++++++ Logic/Structure/Country.cs | 6 ++++++ Logic/Structure/PostalCode.cs | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Logic/Structure/City.cs b/Logic/Structure/City.cs index 76c18296..14ad30d9 100644 --- a/Logic/Structure/City.cs +++ b/Logic/Structure/City.cs @@ -12,6 +12,13 @@ namespace Activizr.Logic.Structure { } + // public ctor needed for serialization + [Obsolete ("Do not call this function directly. It is intended only for use in serialization.", true)] + public City(): base (0, string.Empty, 0, 0) + { + // this instance is NOT initalized, and intended to be used only in serialization. + } + public Geography Geography { diff --git a/Logic/Structure/Country.cs b/Logic/Structure/Country.cs index 6d4f972b..005091d9 100644 --- a/Logic/Structure/Country.cs +++ b/Logic/Structure/Country.cs @@ -13,6 +13,12 @@ namespace Activizr.Logic.Structure { } + [Obsolete ("Do not call this function directly. It is only intended for use in serialization.", true)] + public Country(): base (0, string.Empty, string.Empty) + { + // this ctor does NOT initialize the instance, but is provided to allow for serialization + } + public static Country FromBasic (BasicCountry basic) { return new Country(basic); diff --git a/Logic/Structure/PostalCode.cs b/Logic/Structure/PostalCode.cs index 28f9d3d5..4b220119 100644 --- a/Logic/Structure/PostalCode.cs +++ b/Logic/Structure/PostalCode.cs @@ -9,12 +9,18 @@ namespace Activizr.Logic.Structure [Serializable] public class PostalCode: BasicPostalCode { - public PostalCode (BasicPostalCode basic): + private PostalCode (BasicPostalCode basic): base (basic) { // constructor } + [Obsolete ("Do not call this constructor directly. It is intended only for serialization.", true)] + public PostalCode(): base (string.Empty, string.Empty, string.Empty) + { + // this ctor does NOT initialize the instance. It is provided to allow for serialization. + } + static public PostalCode FromBasic (BasicPostalCode basic) { return new PostalCode(basic);