I stumbled across the entire Microsoft Localization Extensions section the other day. IStringLocalizer/ILocalizedString, all that.
I've already got a hand-rolled approach to localization in my current app (.NET 6, WPF, Prism), but I would gladly convert over to this if appropriate; Because it's much easier for a new developer coming on a project to understand something when there are reams of standard MS documentation about it rather than trying to guess what I had in mind.
But virtually every discussion or example of IStringLocalizer that I can find seems to relates to ASP.NET or at least web apps. The docs all seem to assume you're writing ASP.NET.
So are these extensions meant just for ASP.NET and web apps? Is anyone using this approach outside of web apps? And if so can anyone point me to any examples?
-Joe
No, as by docs (2021):
In this article, you will learn how to use the IStringLocalizer and IStringLocalizerFactory implementations. All of the example source code in this article relies on the Microsoft.Extensions.Localization and Microsoft.Extensions.Hosting NuGet packages. For more information on hosting, see .NET Generic Host.
There is no mention of being asp.net specific, although, asp.net applications obviously tend to make use of it as well.
The examples do not use asp.net.
I've used the resx file approach in the early days a lot in WPF applications - although slightly different, I see no reason why it wouldn't work in any regular application.
Brief overview, I am working with Visual Studio 2017 and .Net Core 2.1. I am about to begin development on a website which will handle integrating 3 existing pieces of software which our company uses.
I have created WCF services already for use by some of the applications I have developed, but for this project, there are multiple APIs which I will be utilizing. It's quite possible that I may need to use these APIs in other projects down the road.
I apologize if this is an opinionated question, but here it goes, do you think it is good design to develop one central API which wraps all the calls to the integrated system APIs? My thoughts were that in this way, I only have to write the code once for making the desired API calls and I can then add to this API as I see fit moving forward, ie. another system API is needed.
Please feel free to give advice, I am still learning and appreciate constructive advice. I am using this to get started on building my API using .Net Core 2.1, https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-2.1
If the APIs are related then yes it does make sense to create a single assembly to call those for you and deal with the responses. You'd then consume that assembly in all your other apps.
However, if the APIs are completely different and require different set ups, then it may make more sense to create an assembly wrapper for each to keep the concerns separate.
You don't want to confuse the APIs. If anyone was to look at your code or assembly, they should be able to say that it relates to what it describes and not have to guess.
I am designing a windows form application. I want also to provide a web based front for the same application. I understand that I need to redesign the UI part wholly and I am ready for that.
But what I would like to know is that what architecture should I follow during development of the windows form so that the maximum part can be reusable. By maximum part I mean the data access logic, the business logic etc.
I am planning to use Rocket Framework http://rocketframework.codeplex.com/ for windows application design. Are any one familiar with it? Please suggest.
After a lot of R&D and extensive study I finally settled here: https://github.com/geersch/ModelViewPresenter It is an MVP architecture written by Christophe Geers. It supports all I needed- Architecture for winform, web portability support, Entity Framework. Really nice and easy to use.
Additional reading:
http://www.cerquit.com/blogs/post/MVP-Part-I-e28093-Building-it-from-Scratch.aspx
MVP or MVVM should enable use to re-use portions of your application.
Of Interest?: Implementing MVC with Windows Forms
I have an old MFC app written in Visual Studio 6. This will at some point be rewritten in C# .NET. However, before then I have to write a couple of new Windows services for the existing application. The others were written in ATL. What I would prefer to do is write these new services in C# .NET so that when the rest of the application is rewritten, these don't need to be.
Is it going to be possible to call the interfaces on the libraries hosted in a .NET windows service from the old application? If so, could you please explain how.
Absolutely. You're looking for a feature of .NET called COM-Interop.
http://msdn.microsoft.com/en-us/library/kew41ycz%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/magazine/cc163494.aspx
The second link has an ATL example.
EDIT:
Based on your feedback in the comments, let me expand on this...
Ah - you're right about the sample on that page.
The first link is really where you want to start for all the details. If you follow the links, you'll find this page:
"Exposing .NET Framework Components to COM"
http://msdn.microsoft.com/en-us/library/zsfww439%28v=vs.71%29.aspx
Essentially, it's just a matter of applying a series of attributes to your classes and properties, and then generating the appropriate registry entries on the client machine (which .NET has a tool to do - see: http://msdn.microsoft.com/en-us/library/bctyca52%28v=vs.71%29.aspx)
I've done this several times myself for .NET projects people needed to call from VC++ and/or VB6.
Some other links that might be of interest:
http://www.codeproject.com/KB/COM/nettocom.aspx <-- Perfect example of what you're trying to do.
http://www.codeproject.com/KB/COM/Universal_CCW.aspx
I've done this exact thing with an MFC-based C++ application in Visual Studio 2008 and a .NET-based C# Windows service.
First, if you have not created the C# Windows services yet, I've got a couple of tutorials for creating the basic framework. The first tutorial provides a step-by-step procedure for creating the service and writing events to an application-specific event log. The second tutorial shows how to modify the service to install and uninstall itself from the command line, which I find of great use.
Second, you need to decide how you are going to communicate between your MFC application and your Windows service. Any kind of inter-process communication (IPC) model will work - sockets, pipes, shared memory, WCF, etc. Since you are wanting to migrate to .NET anyway, I would recommend using Windows Communication Foundation (WCF), which is the way I've done it. Specifically, I chose the named pipe aspect of WCF for my communication method based on the chart shown here.
If you go down the WCF route, you'll benefit from the fact that the communication between application and service is .NET-based. Thus, when you move your application to .NET, the communication mechanism won't have to be rewritten. The trick in the meantime is getting your MFC application to use the WCF code. To do this, write the WCF client code in a .NET assembly using C#. Then, use a C++ dll to bridge the gap between your MFC code and the .NET assembly. I've got another tutorial with step-by-step instructions for how to do this.
Hope this helps.
I'm wondering if there are any architectural frameworks out there to create desktop or standalone applications, in Java or C# for instance. It seems that there are tons of them available for web applications but I can't find many good resources on frameworks or architectural best-practices for desktop development.
Ideally I would like to know if there is any source code available of desktop applications that would be considered to have a good architecture or are built with a certain framework.
While not directly related to desktop applications if you are looking for decent source code for well written projects I asked a similar question:
Open source C# projects that have extremely high code quality to learn from.
People gave some pretty good suggestions there:
Scott Hanselman's The Weekly Source Code series (usually
managed C#)
Code written by Microsoft Patterns & Practices team.
SharpDevelop (written in C#)
Mono (most of the framework in C#)
Paint.Net (written in C#)
NHibernate (written in C#)
The Castle Project (written in C#)
xUnit (written in C#)
.Net Framework Source Code
In the lightweight app category, JSR 296 for Java (to be in future Java 7 possibly) is a framework handling the basics like resource management and actions. Lots of links here:
http://tech.puredanger.com/java7#jsr296
Scaling up a bit, you could look at various RCP frameworks like:
Eclipse RCP: http://wiki.eclipse.org/index.php/Rich_Client_Platform
NetBeans Platform: http://www.netbeans.org/products/platform/
Spring RCP: http://spring-rich-c.sourceforge.net/1.0.0/index.html
Comparison article: http://www.infoq.com/news/eclipse-rcp-netbeans-platform
UPDATE: It has been mentioned (by Mark Reinhold at Devoxx '08) that JSR 296 will be included in Java 7.
Further update: JSR 296 is dead. JavaFX is the current direction for client-side Java.
There's a new .NET architectural guidance package from Microsoft patterns & practices for WPF that is code named "Prism" -- it's basically a "next generation" Composite UI Application Block (without the SCSF tooling). It uses Dependency injection, Composite pattern throughout, etc.
There is a pretty good DNRTV screencast demoing it.
Check Microsoft's Smart Client Software Factory. It contains code samples and documentation.
Overview
This software factory provides proven
solutions to common challenges found
while building and operating composite
smart client applications. It helps
architects and developers build
modular systems that can be built and
deployed by independent teams.
Applications built with the software
factory use proven practices for
operations, such as centralized
exception logging.
The software factory contains a
collection of reusable components and
libraries, Visual Studio 2008 solution
templates, wizards and extensions,
How-to topics, automated tests,
extensive architecture documentation,
patterns, and a reference
implementation. The software factory
uses Windows Forms, Windows
Presentation Foundation, Windows
Communication Foundation, and the
Enterprise Library 3.1 – May 2007
release. With this release, the
Composite UI Application Block is
included in the software factory.
In Java, Naked Objects -- http://nakedobjects.org/home/index.shtml
JMatter -- implementation of naked objects -- http://jmatter.org/. pretty good.
both of them are open source.
On the Java side, there are several projects aimed at Rich Client Platforms (RCP is the new buzzword for 'desktop' apps):
Eclipse RCP (if you are OK using SWT
instead of Swing)
Spring RCP (which
is in the process of being
overhauled into Spring Desktop)
NetBeans RCP (which I'm not
particularly impressed with, but
that is getting some traction)
JSR 296 (Application Framework) - I
actually really like this one
Google any of the above and you'll get tons of info.
You can use some of the same approaches in client development that you use in web development, such as Model View Presenter. The System.Windows.Forms namespace has everything you need to build a client application in C#, with the rest of the .NET Framework available to provide the services you need (such as IO and remoting).
As far as source code for solid architectures in desktop apps, look at the code for Paint.NET and SharpDevelop. Both have very different approaches that will be interesting to you.
Sorry for the .NET slant of this reply. It's what I know best. :)
I would recommend CSLA .NET framework by Rockford Lhotka: http://www.lhotka.net/cslanet/Default.aspx
It comes will full source code as well as sample client applications built in ASP.NET, WinForms and WPF.
I just found the Composite Application Guidance for WPF and Silverlight which looks very interesting. It was published in February 2009.
We develop in .NET technologies here.
Our friends here working on client applications develop their software to the Model View Presenter design pattern that is often associated with Web Development. For them they find it works very well, I believe it may be worth checking out.
The Smart Client Factory (mentioned by Panos) may also be useful to you, though it's not a framework but more of a library of best practice solutions to common problems.
Specifically to organized presentation framework of ui functions we have been using infonode docking windows, that's a windowing framework using an eclipse like appearance (drag views anywhere, close them, undock them etc., skinnable of course). there's a gpl version for open source products out, altough afaik the developer licence is not that expensive ($299 each).
Check IdeaBlade's Cabana For DotNet C#.
http://www.ideablade.com/CAB.html
Cabana Sample App
The Cabana application is a simple smart client reference app with a crisp, feature-rich user experience that is easy to deploy and operate over the web. Cabana demonstrates:
An easy approach to the Composite UI Application Block from Microsoft ’s Patterns & Practices Group.
Maintainable, reusable code through UI composition.
Separation of Model (business logic and data access) from Presentation.
The Model-View-Presenter pattern.
Performance tuning.
And more.
I recently published DesktopBootstrap. It's my attempt to factor out many of the common elements of creating medium to large scale desktop apps.
You can find it here.