Wpf configuration service like global.asax - wpf

I am working on WPF Application.I am using Auto Mapper in WCF services. In My project I have different kind of layer like Service layer, Business Layer , Presentation Layer , I want to work on Service Layer that is (WCF).
In Auto Mapper there is creation of map
Mapper.Initialize(Item=> Item.CreateMap<Model.Person, PersonInfo>());
Mapper.Initialize(Item=> Item.CreateMap<Model.Bank, BankInfo>());
Mapper.Initialize(Item=> Item.CreateMap<Data, Model.DataInfo>());
When ever I call function at that every time it will call as per application perfomance.
I want to make as per global in application.That is Create once in application and use as many time as they can
How to Implement this concept of globalization at service layer in WPF application.
There is no concept of global.asax is WPF Application.then how to implement that concept of globalization of mapper initilization
Thank you.

Related

MVC and Winforms share code

I have an MVC webapp and am creating a Winforms app. The methods I have created and use in the MVC app will also be used by the Winforms app. Is there a way I can share the code between them so that I can update it all in one place? Maybe turn those methods into a dll that they both use? If so, how do I go about doing that?

Design decision to migrate Silverlight application

I have a silverlight application, it has pretty complex UI. In some forms I am using MVVM pattern. However there are many forms where code behind file has most of the form logic code (no view model).
Silverlight application is having both business and UI logic. There is a WCF service which SL application is directly calling. This WCF service is a data service (DB logic).
I want to migrate silverlight application into HTML5. I have following questions.
There are many links to migrate the SL application to HTML5 (even using MVVM pattern). Many suggests to use some JS framework library like AngularJS/Knockout. Can you please tell me which one works best for migration from SL?
Where would I put the business logic? Can I write my business logic using JS library? Also in case I write business logic using some library then won't it expose all my logic to client?
In case JS library is not the right thing to write the business logic then what other technology I should use? WebAPI or something else?
Atul Sureka
For Server Side Code Reusablity (MVVM) Code use AngularJS/KendoUI
Use C# Object to JavaScript Object Convrsion
Server Side Logic we can Re-Use, Client Side Logic C# to Java Script
User Rest API's

Bootstrapping Windsor Castle IoC in WPF application

I am used to using Windsor Castle IoC with MVC web applications so I'm a little familiar with registering components and bootstrapping the application.
I am now trying to create my first WPF application and I'm a little lost....
In a typical MVC project I would register all my components in Application_Start in the Global.asax file.
Also, in the Global.asax I would do something like this :
_container = new WindsorContainer();
var myControllerFactory = new MyControllerFactory(_container.Kernel);
ControllerBuilder.Current.SetControllerFactory(myControllerFactory);
In MyControllerFactory which inherits from DefaultControllerFactory I would resolve the Controller given to me, thus all the controllers being used would have their dependencies resolved automatically.
How could I do this in a WPF application ?
I created a class called ContainerBootstrapper that registers my components, and now I'm wondering how I use this in my MainWindow so every time I call a component, it's dependencies are resolved automatically...
Unlike MVC, WPF does not provide framework for decoupled UI development out of the box. There are several out there (such as Caliburn.Micro which implements the MVVM pattern) that sit on top of WPF and provide integration for a variety of IoC containers as well as other features you may find useful in WPF development.
Alternatively, you will need to manage the container directly. i.e. instantiate and initialise the container in App.xaml.cs or MainWindow.xaml.cs and ensure that new object construction via your container's Resolve() function. If it is a non-trivial app, you will probably want to integrate this into your app's navigation routines.

Sending abstract class with DomainService WCF service to Silverlight

I was using a simple WCF service with silverlight but I wanted to validate data with annotations and I didn't want to write a whole new layer in silverlight project. So I decided to switch to using a DomainService, created through generating code in the silverlight project.
Now comes the trouble. I have a parent class and about 10 derived classes. Through WCF, I was able to just use the base class. Now I am trying to use a DomainService with the base class decorated with the KnownType attribute. The problem is now those attributes get replicated in silverlight client and a compilation error is thrown. Anybody know how to use DomainService with inheritance? I want to deliver only the information from the base class.
I don't completely follow what your problem is, but this is a great tutorial on how to use Domain Services in Silverlight, and the example includes an abstract base class for all entities, similar to what I think you're doing.

webservice upload and progress

Please help me with this one, I'm not sure what the correct, or best approach is. Basically I have a webservice which takes a byte stream, enabling a c# winform application to upload files to the webservice.
What I need is for the winform to upload in the background one file at a time (using basic multithread, it tries to upload them all at once). I also need to drop in there a progress bar.
How should I do it? Any ideas? I have the feeling it should be fairly straight forward. I think the application should start a new thread for the first file, wait until it's finished then dispose of the thread, create a new one for the next file and so on.
It completely depends on the technology you are using on the client side to access the web service.
If that technology allows for customization of the client proxy to the point where you can intercept transmission of messages (WCF allows this, I can't recall how much the old web services reference does), then you should be able to add your hook to see when the bytes are processed/sent.
Based on bookstorecowboy's comment about using the old "web reference" functionality in .NET, I believe that it generated proxies that derive from the SoapHttpClientProtocol class.
This being the case, I would recommend creating a custom class that derives from the SoapHttpClientProtocol class, overriding the GetWriterForMessage method. In this, you are supposed to return an XmlWriter given the Stream that is passed as a property on the SoapClientMessage parameter.
You would also create a custom class that derives from Stream which takes a Stream instance and forwards all the calls to that instance.
The only difference is that in the Write methods, you would fire an event indicating how many bytes were written.
You would then get the Stream that is exposed on the SoapClientMessage passed to the GetWriterForMessage and wrap it in your custom Stream implementation. You would also connect your event handlers here as well.
With that stream, you would create the XmlWriter and return it.
Then, for your proxies, you would use this new class that derives from SoapHttpClientProtocol and have the proxies derive from that.
As for ASP.NET 2.0 web services ("Old web services ") you could add web services extension to alter and extend it's behavior .
You could also add custom Http module .
It allows you aceess up to the stream level .
see Soap Extensions,Http Modules

Resources