Refactor: Created Basic.Types.Structure

This commit is contained in:
Rick Falkvinge
2014-12-21 21:09:47 +01:00
parent 764ffeda5f
commit 7c2bb053f2
30 changed files with 351 additions and 349 deletions
+7 -8
View File
@@ -72,7 +72,7 @@
<Compile Include="Types\Financial\BasicFinancialTransactionTagSetType.cs" />
<Compile Include="Types\Financial\BasicFinancialTransactionTagType.cs" />
<Compile Include="Types\Financial\BasicFinancialValidation.cs" />
<Compile Include="Types\BasicPostalCode.cs" />
<Compile Include="Types\Structure\BasicPostalCode.cs" />
<Compile Include="Types\Financial\BasicFinancialAccount.cs" />
<Compile Include="Types\Governance\BasicMeeting.cs" />
<Compile Include="Config.cs" />
@@ -97,8 +97,8 @@
<Compile Include="Types\Security\BasicAuthority.cs" />
<Compile Include="Types\Communications\BasicAutoMail.cs" />
<Compile Include="Types\BasicChurnDataPoint.cs" />
<Compile Include="Types\BasicCity.cs" />
<Compile Include="Types\BasicCountry.cs" />
<Compile Include="Types\Structure\BasicCity.cs" />
<Compile Include="Types\Structure\BasicCountry.cs" />
<Compile Include="Types\BasicDocument.cs" />
<Compile Include="Types\BasicExpenseClaim.cs" />
<Compile Include="Types\BasicExternalCredential.cs" />
@@ -147,7 +147,7 @@
<Compile Include="Interfaces\IHandleProvider.cs" />
<Compile Include="Interfaces\IHasIdentity.cs" />
<Compile Include="Types\BasicNewsletterFeed.cs" />
<Compile Include="Types\BasicGeography.cs" />
<Compile Include="Types\Structure\BasicGeography.cs" />
<Compile Include="Types\BasicPayout.cs" />
<Compile Include="Types\BasicPayrollItem.cs" />
<Compile Include="Types\BasicPermission.cs" />
@@ -156,7 +156,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\BasicMembership.cs" />
<Compile Include="Types\BasicOrganization.cs" />
<Compile Include="Types\Structure\BasicOrganization.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
@@ -171,9 +171,8 @@
<Compile Include="Types\BasicUptakeGeography.cs" />
<Compile Include="Types\BasicVolunteer.cs" />
<Compile Include="Types\BasicVolunteerRole.cs" />
<Compile Include="Types\BasicGeographyDesignation.cs" />
<Compile Include="Types\Structure\BasicGeographyDesignation.cs" />
<Compile Include="Types\BasicCurrency.cs" />
<Compile Include="Types\GeographyWithPeople.cs" />
<Compile Include="Types\BasicInternalPollVoter.cs" />
<Compile Include="Types\XmlSerializableDictionary.cs" />
</ItemGroup>
@@ -191,4 +190,4 @@
<Folder Include="Statistics\DataPoints\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>
-19
View File
@@ -1,19 +0,0 @@
using System;
namespace Swarmops.Basic.Types
{
[Serializable]
public class BasicGeographyWithPeople
{
public int ActivistCount;
public int GeographyID;
public string GeograpyName;
public string LeadContent;
public int MemberCount;
public int OrgId = 0;
public string OrgName;
public int ParentGeographyId;
public int ParentOrgId;
public string SecondsContent;
}
}
@@ -1,42 +1,42 @@
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types
{
[Serializable]
public class BasicCity : IHasIdentity
{
public BasicCity (int cityId, string name, int countryId, int geographyId)
{
CityId = cityId;
Name = name;
CountryId = countryId;
GeographyId = geographyId;
}
public BasicCity (BasicCity original)
: this (original.CityId, original.Name, original.CountryId, original.GeographyId)
{
}
[Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)]
public BasicCity()
{
// this ctor should never be called from code
}
public int CityId { get; private set; }
public string Name { get; protected set; }
public int CountryId { get; protected set; }
public int GeographyId { get; protected set; }
#region IHasIdentity Members
public int Identity
{
get { return CityId; }
}
#endregion
}
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types.Structure
{
[Serializable]
public class BasicCity : IHasIdentity
{
public BasicCity (int cityId, string name, int countryId, int geographyId)
{
this.CityId = cityId;
this.Name = name;
this.CountryId = countryId;
this.GeographyId = geographyId;
}
public BasicCity (BasicCity original)
: this (original.CityId, original.Name, original.CountryId, original.GeographyId)
{
}
[Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)]
public BasicCity()
{
// this ctor should never be called from code
}
public int CityId { get; private set; }
public string Name { get; protected set; }
public int CountryId { get; protected set; }
public int GeographyId { get; protected set; }
#region IHasIdentity Members
public int Identity
{
get { return this.CityId; }
}
#endregion
}
}
@@ -1,69 +1,69 @@
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types
{
[Serializable]
public class BasicCountry : IHasIdentity
{
public BasicCountry (int countryId, string name, string code)
{
CountryId = countryId;
Name = name;
Code = code;
}
public BasicCountry (int countryId, string name, string code, string defaultCulture, string currencyCode,
int geographyId, int postalCodeLength)
: this (countryId, name, code)
{
Culture = defaultCulture;
CurrencyCode = currencyCode;
GeographyId = geographyId;
PostalCodeLength = postalCodeLength;
}
public BasicCountry (BasicCountry original)
: this (
original.CountryId, original.Name, original.Code, original.Culture, original.CurrencyCode,
original.GeographyId, original.PostalCodeLength)
{
}
[Obsolete ("Do not call this function directly. It exists to enable serialization.", true)]
public BasicCountry()
{
// this does not initialize the Basic Country, but exists to enable serialization.
}
public int CountryId { get; private set; }
public string Name { get; protected set; }
public string Code { get; protected set; }
public string Culture { get; protected set; }
public string CurrencyCode { get; protected set; }
public int GeographyId { get; protected set; }
public int PostalCodeLength { get; protected set; }
public int CurrencyId
{
get
{
if (Code == "SE")
{
return 1;
}
throw new NotImplementedException ("BasicCountry.CurrencyId");
}
}
#region IHasIdentity Members
public int Identity
{
get { return CountryId; }
}
#endregion
}
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types.Structure
{
[Serializable]
public class BasicCountry : IHasIdentity
{
public BasicCountry (int countryId, string name, string code)
{
this.CountryId = countryId;
this.Name = name;
this.Code = code;
}
public BasicCountry (int countryId, string name, string code, string defaultCulture, string currencyCode,
int geographyId, int postalCodeLength)
: this (countryId, name, code)
{
this.Culture = defaultCulture;
this.CurrencyCode = currencyCode;
this.GeographyId = geographyId;
this.PostalCodeLength = postalCodeLength;
}
public BasicCountry (BasicCountry original)
: this (
original.CountryId, original.Name, original.Code, original.Culture, original.CurrencyCode,
original.GeographyId, original.PostalCodeLength)
{
}
[Obsolete ("Do not call this function directly. It exists to enable serialization.", true)]
public BasicCountry()
{
// this does not initialize the Basic Country, but exists to enable serialization.
}
public int CountryId { get; private set; }
public string Name { get; protected set; }
public string Code { get; protected set; }
public string Culture { get; protected set; }
public string CurrencyCode { get; protected set; }
public int GeographyId { get; protected set; }
public int PostalCodeLength { get; protected set; }
public int CurrencyId
{
get
{
if (this.Code == "SE")
{
return 1;
}
throw new NotImplementedException ("BasicCountry.CurrencyId");
}
}
#region IHasIdentity Members
public int Identity
{
get { return this.CountryId; }
}
#endregion
}
}
@@ -1,65 +1,65 @@
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types
{
/// <summary>
/// A geographical node.
/// </summary>
[Serializable]
public class BasicGeography : IHasIdentity
{
public BasicGeography (int geographyId, int parentGeographyId, string name)
: this (geographyId, parentGeographyId, name, 0)
{
}
public BasicGeography (int geographyId, int parentGeographyId, string name, int generation)
{
GeographyId = geographyId;
ParentGeographyId = parentGeographyId;
Name = name;
Generation = generation;
}
public BasicGeography (BasicGeography original)
: this (original.GeographyId, original.ParentGeographyId, original.Name, original.Generation)
{
}
[Obsolete ("Do not use this ctor. It is provided to enable serializability.", true)]
public BasicGeography()
{
// provided for serializability - does not initialize fields
}
/// <summary>
/// The database id of this geography.
/// </summary>
public int GeographyId { get; private set; }
/// <summary>
/// The database id of the parent geography, for linking in a tree structure.
/// </summary>
public int ParentGeographyId { get; protected set; }
/// <summary>
/// The friendly name of the node (city, county, region, etc).
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The generation of this node. Used in tree-style listings.
/// </summary>
public int Generation { get; protected set; }
#region IHasIdentity Members
public int Identity
{
get { return GeographyId; }
}
#endregion
}
using System;
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types.Structure
{
/// <summary>
/// A geographical node.
/// </summary>
[Serializable]
public class BasicGeography : IHasIdentity
{
public BasicGeography (int geographyId, int parentGeographyId, string name)
: this (geographyId, parentGeographyId, name, 0)
{
}
public BasicGeography (int geographyId, int parentGeographyId, string name, int generation)
{
this.GeographyId = geographyId;
this.ParentGeographyId = parentGeographyId;
this.Name = name;
this.Generation = generation;
}
public BasicGeography (BasicGeography original)
: this (original.GeographyId, original.ParentGeographyId, original.Name, original.Generation)
{
}
[Obsolete ("Do not use this ctor. It is provided to enable serializability.", true)]
public BasicGeography()
{
// provided for serializability - does not initialize fields
}
/// <summary>
/// The database id of this geography.
/// </summary>
public int GeographyId { get; private set; }
/// <summary>
/// The database id of the parent geography, for linking in a tree structure.
/// </summary>
public int ParentGeographyId { get; protected set; }
/// <summary>
/// The friendly name of the node (city, county, region, etc).
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The generation of this node. Used in tree-style listings.
/// </summary>
public int Generation { get; protected set; }
#region IHasIdentity Members
public int Identity
{
get { return this.GeographyId; }
}
#endregion
}
}
@@ -1,27 +1,27 @@
using Swarmops.Basic.Enums;
namespace Swarmops.Basic.Types
{
public class BasicGeographyDesignation
{
public BasicGeographyDesignation (int geographyId, int countryId,
string designation, GeographyLevel geoLevelId)
{
GeographyId = geographyId;
CountryId = countryId;
Designation = designation;
GeographyLevel = geoLevelId;
}
public BasicGeographyDesignation (BasicGeographyDesignation original) :
this (original.GeographyId, original.CountryId, original.Designation, original.GeographyLevel)
{
// empty copy ctor
}
public int GeographyId { get; private set; }
public int CountryId { get; private set; }
public string Designation { get; private set; }
public GeographyLevel GeographyLevel { get; private set; }
}
using Swarmops.Basic.Enums;
namespace Swarmops.Basic.Types.Structure
{
public class BasicGeographyDesignation
{
public BasicGeographyDesignation (int geographyId, int countryId,
string designation, GeographyLevel geoLevelId)
{
this.GeographyId = geographyId;
this.CountryId = countryId;
this.Designation = designation;
this.GeographyLevel = geoLevelId;
}
public BasicGeographyDesignation (BasicGeographyDesignation original) :
this (original.GeographyId, original.CountryId, original.Designation, original.GeographyLevel)
{
// empty copy ctor
}
public int GeographyId { get; private set; }
public int CountryId { get; private set; }
public string Designation { get; private set; }
public GeographyLevel GeographyLevel { get; private set; }
}
}
@@ -1,93 +1,93 @@
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types
{
public class BasicOrganization : IHasIdentity
{
private string nameShort;
#region IHasIdentity Members
public int Identity
{
get { return OrganizationId; }
}
#endregion
public BasicOrganization()
{
}
public BasicOrganization (int organizationId, string name, string nameInternational)
{
OrganizationId = organizationId;
Name = name;
NameInternational = nameInternational;
}
public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational) :
this (organizationId, name, nameInternational)
{
ParentOrganizationId = parentOrganizationId;
}
public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational,
string nameShort, string domain, string mailPrefix, int anchorGeographyId,
bool acceptsMembers, bool autoAssignNewMembers,
int defaultCountryId)
: this (organizationId, parentOrganizationId, name, nameInternational)
{
this.nameShort = nameShort;
Domain = domain;
MailPrefix = mailPrefix;
AnchorGeographyId = anchorGeographyId;
AcceptsMembers = acceptsMembers;
AutoAssignNewMembers = autoAssignNewMembers;
DefaultCountryId = defaultCountryId;
}
public BasicOrganization (BasicOrganization original)
: this (
original.Identity, original.ParentOrganizationId, original.Name, original.NameInternational,
original.NameShort, original.Domain, original.MailPrefix, original.AnchorGeographyId,
original.AcceptsMembers, original.AutoAssignNewMembers, original.DefaultCountryId)
{
}
public int DefaultCountryId { get; protected set; }
public string Name { get; protected set; }
public string NameInternational { get; protected set; }
public string NameShort
{
get
{
if (this.nameShort.Length > 0)
{
return this.nameShort;
}
return Name;
}
set { this.nameShort = value; }
}
public string Domain { get; protected set; }
public string MailPrefix { get; protected set; }
public int AnchorGeographyId { get; protected set; }
public bool AcceptsMembers { get; protected set; }
public int OrganizationId { get; protected set; }
public int ParentOrganizationId { get; protected set; }
public bool AutoAssignNewMembers { get; protected set; }
}
using Swarmops.Basic.Interfaces;
namespace Swarmops.Basic.Types.Structure
{
public class BasicOrganization : IHasIdentity
{
private string nameShort;
#region IHasIdentity Members
public int Identity
{
get { return this.OrganizationId; }
}
#endregion
public BasicOrganization()
{
}
public BasicOrganization (int organizationId, string name, string nameInternational)
{
this.OrganizationId = organizationId;
this.Name = name;
this.NameInternational = nameInternational;
}
public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational) :
this (organizationId, name, nameInternational)
{
this.ParentOrganizationId = parentOrganizationId;
}
public BasicOrganization (int organizationId, int parentOrganizationId, string name, string nameInternational,
string nameShort, string domain, string mailPrefix, int anchorGeographyId,
bool acceptsMembers, bool autoAssignNewMembers,
int defaultCountryId)
: this (organizationId, parentOrganizationId, name, nameInternational)
{
this.nameShort = nameShort;
this.Domain = domain;
this.MailPrefix = mailPrefix;
this.AnchorGeographyId = anchorGeographyId;
this.AcceptsMembers = acceptsMembers;
this.AutoAssignNewMembers = autoAssignNewMembers;
this.DefaultCountryId = defaultCountryId;
}
public BasicOrganization (BasicOrganization original)
: this (
original.Identity, original.ParentOrganizationId, original.Name, original.NameInternational,
original.NameShort, original.Domain, original.MailPrefix, original.AnchorGeographyId,
original.AcceptsMembers, original.AutoAssignNewMembers, original.DefaultCountryId)
{
}
public int DefaultCountryId { get; protected set; }
public string Name { get; protected set; }
public string NameInternational { get; protected set; }
public string NameShort
{
get
{
if (this.nameShort.Length > 0)
{
return this.nameShort;
}
return this.Name;
}
set { this.nameShort = value; }
}
public string Domain { get; protected set; }
public string MailPrefix { get; protected set; }
public int AnchorGeographyId { get; protected set; }
public bool AcceptsMembers { get; protected set; }
public int OrganizationId { get; protected set; }
public int ParentOrganizationId { get; protected set; }
public bool AutoAssignNewMembers { get; protected set; }
}
}
@@ -1,32 +1,32 @@
using System;
namespace Swarmops.Basic.Types
{
[Serializable]
public class BasicPostalCode
{
public BasicPostalCode (int postalCodeId, string postalCode, int cityId, int countryId)
{
PostalCodeId = postalCodeId;
PostalCode = postalCode.Replace (" ", "");
CityId = cityId;
CountryId = countryId;
}
public BasicPostalCode (BasicPostalCode original)
: this (original.PostalCodeId, original.PostalCode, original.CityId, original.CountryId)
{
}
[Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)]
public BasicPostalCode()
{
// this should never be called from code
}
public int PostalCodeId { get; private set; }
public string PostalCode { get; private set; } // any whitespace removed
public int CityId { get; protected set; }
public int CountryId { get; protected set; }
}
using System;
namespace Swarmops.Basic.Types.Structure
{
[Serializable]
public class BasicPostalCode
{
public BasicPostalCode (int postalCodeId, string postalCode, int cityId, int countryId)
{
this.PostalCodeId = postalCodeId;
this.PostalCode = postalCode.Replace (" ", "");
this.CityId = cityId;
this.CountryId = countryId;
}
public BasicPostalCode (BasicPostalCode original)
: this (original.PostalCodeId, original.PostalCode, original.CityId, original.CountryId)
{
}
[Obsolete ("Do not call this ctor directly. It exists to enable serialization.", true)]
public BasicPostalCode()
{
// this should never be called from code
}
public int PostalCodeId { get; private set; }
public string PostalCode { get; private set; } // any whitespace removed
public int CityId { get; protected set; }
public int CountryId { get; protected set; }
}
}
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -4,6 +4,7 @@ using System.Data;
using System.Data.Common;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -5,6 +5,7 @@ using System.Data.Common;
using System.Diagnostics;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -3,6 +3,7 @@ using System.Data.Common;
using Swarmops.Basic.Types;
// This is the first part of Database to fully use MySql.
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Database
{
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Structure;
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Structure;
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Security;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Structure;
+1
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Financial;
+1
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Support;
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Xml.Serialization;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Interfaces;
+1
View File
@@ -6,6 +6,7 @@ using System.Text;
using System.Text.RegularExpressions;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Communications;
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Support;
+1
View File
@@ -1,5 +1,6 @@
using System;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
namespace Swarmops.Logic.Structure
{
+1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
namespace Swarmops.Logic.Structure
+1
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
+1
View File
@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
using Swarmops.Basic.Enums;
using Swarmops.Basic.Interfaces;
using Swarmops.Basic.Types;
using Swarmops.Basic.Types.Structure;
using Swarmops.Database;
using Swarmops.Database.Attributes;
using Swarmops.Logic.Communications;