This article describes some misc technologies chosen in this software architecture.
JJ.Framework
are nuts, bolts and screws for software development. There were things missing in .NET
, so we programmed our own. These extensions to .NET
are compact and reusable. They can be found on NuGet. The lesser-tested ones on JJs-Pre-Release-Package-Feed. You can read more information of it on the GitHub repository.
They were made in the spirit of in-house developing small extensions and hiding platform-specific details behind generalized interfaces. They are sort part of the software architecture described here.
.NET
code can use configuration files, often named App.config
or Web.config
.
To access these configs
we might use JJ.Framework.Configuration
quite a bit more easily than using .NET's
System.Configuration
directly.
You might read from its README
how it works.
It does not seem to support reading out the connectionStrings
section yet. So here is an idea how that might work, would it ever be programmed.
Reading out connectionStrings
might be made similar to reading out the appSettings
. Connection strings in the App.config
or Web.config
may look as follows:
<connectionStrings>
<add name="OrderDB" connectionString="data source=192.168.XX.XX;Initial Catalog=OrderDB..." />
</connectionStrings>
This would be the classic way of reading it out:
string connectionString =
ConfigurationManager.ConnectionStrings["OrderDB"].ConnectionString;
This would be the alternative in JJ.Framework.Configuration
:
string connectionString =
ConnectionStrings<IConnectionStrings>.Get(x => x.OrderDB);
You can define an interface
to use the strongly-typed name:
internal interface IConnectionStrings
{
string OrderDB { get; }
}
Bidirectional relationship synchronization allows for automatic synchronization of related properties in a parent-child relationship. By setting the parent property, product.Supplier = mySupplier
, the child collection, mySupplier.Products
, will also be updated to include myProduct
.
This can be achieved through the use of classes such as ManyToOneRelationship
and OneToManyRelationship
from the JJ.Framework.Business
package, which can be used in various models: rich, entity, API
or otherwise.
There may be other options available. NHibernate
does not appear to do it for us automatically. However Entity Framework
might do this synchronization automatically. The LinkTo
pattern can also be used. Or hand-writing the syncing in-place.
XML
is a file format for storing and transmitting data. When working with API's
for XML
there are a few options to consider.
In most cases, it is recommended to use XElement
(LINQ to XML) instead of XmlDocument
. However, a useful feature of XmlDocument
is that it supports XPath
.
To handle nullability and uniqueness more gracefully, it is suggested to use XmlHelper
methods from JJ.Framework.Xml
or JJ.Framework.Xml.Linq
over using other API's
directly.
For converting XML
to an object graph, XmlToObjectConverter
and ObjectToXmlConverter
from JJ.Framework.Xml
and JJ.Framework.Xml.Linq
might be useful. They can offer simpler solutions than other API's
.
Embedded resources might be handy, to prevent including loose files with a deployment. Instead they are compiled right into your program files’ EXE
or DLL
. This also protects those resources a bit better against modifications.
To include a file as an embedded resource, you could set the following property in Visual Studio
:
JJ.Framework.Common
contains a Helper
class
EmbeddedResourceReader
. It makes it a little bit easier to access those resources from your code:
string text = EmbeddedResourceReader.GetText(assembly, "Ingredient_UpdateName.sql");