none
Silverlight with Unity 2.0 Framework

    Question

  • Dear Experts

    i am new to Unity Framework 2.0 with Silverligt.

    i need to use unityframework, to register the xaml page and to resolve the xaml page.

    can anyone give the samples or steps how to use unity framework with Silverlight 4.

    Thanks in Advance.

    Monday, August 22, 2011 4:18 AM

Answers

  • Hi,

    Confused about XAML? Could you show us those XAML. The purpose of UNITY is to return an instance of Interface.

    //Interface

    public interface IUnitOfWork
        {
            /// <summary>
            /// Saves changes to all objects that have changed within the unit of work.
            /// </summary>
            void SaveChanges();
        }

    //Implement

    public class UnitOfWork : IUnitOfWork
        {
            /// <summary>
            /// Saves changes to all objects that have changed within the unit of work.
            /// </summary>
            void SaveChanges()

            {

                   Alert("My name is JavaScript + HTML5");

            }
        }

    //How to use.

    private static IUnityContainer container;

    private static void InitializeDependencyInjectionContainer()
            {
                container = new UnityContainerFactory().CreateConfiguredContainer();           
                var serviceLocator = new UnityServiceLocator(container);
                ServiceLocator.SetLocatorProvider(() => serviceLocator);
                DependencyResolver.SetResolver(new UnityDependencyResolver(container));
            }

            private static void InitializeIUnitOfWork()
            {
                UnitOfWork unitofwork = ServiceLocator.Current.GetInstance<IUnitOfWork>();//this line will return an instance of UnitOfWork.
                unitofwork.save();          
            }    

     

     

    Wednesday, August 24, 2011 3:37 AM

All replies

  • Hi,

    You need these assemblies

    Microsoft.Practices.ServiceLocation

    Microsoft.Practices.Unity

    Microsoft.Practices.Unity.Configuration

    Microsoft.Practices.Unity.Interception

    Microsoft.Practices.Unity.Interception.Configuration

     

    Unity Application Block on MSDN:

    http://www.msdn.com/unity

    Wednesday, August 24, 2011 1:53 AM
  • Hi Jerry and thaicarrot

    Thanks for your reply, i have already visited thest 2 links which you have posted. i need to know how to register and Resolve xaml dynamically.

    Wednesday, August 24, 2011 3:17 AM
  • Hi,

    Confused about XAML? Could you show us those XAML. The purpose of UNITY is to return an instance of Interface.

    //Interface

    public interface IUnitOfWork
        {
            /// <summary>
            /// Saves changes to all objects that have changed within the unit of work.
            /// </summary>
            void SaveChanges();
        }

    //Implement

    public class UnitOfWork : IUnitOfWork
        {
            /// <summary>
            /// Saves changes to all objects that have changed within the unit of work.
            /// </summary>
            void SaveChanges()

            {

                   Alert("My name is JavaScript + HTML5");

            }
        }

    //How to use.

    private static IUnityContainer container;

    private static void InitializeDependencyInjectionContainer()
            {
                container = new UnityContainerFactory().CreateConfiguredContainer();           
                var serviceLocator = new UnityServiceLocator(container);
                ServiceLocator.SetLocatorProvider(() => serviceLocator);
                DependencyResolver.SetResolver(new UnityDependencyResolver(container));
            }

            private static void InitializeIUnitOfWork()
            {
                UnitOfWork unitofwork = ServiceLocator.Current.GetInstance<IUnitOfWork>();//this line will return an instance of UnitOfWork.
                unitofwork.save();          
            }    

     

     

    Wednesday, August 24, 2011 3:37 AM