コード例 #1
0
        /// <summary>
        /// Registers the type mappings with the Unity container.
        /// </summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>
        /// There is no need to register concrete types such as controllers or
        /// API controllers (unless you want to change the defaults), as Unity
        /// allows resolving a concrete type even if it was not previously
        /// registered.
        /// </remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below.
            // Make sure to add a Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your type's mappings here.
            // container.RegisterType<IProductRepository, ProductRepository>();
            DataFacility.Register(container);
            container.RegisterType <DbContext, CinemaSupportContext>(new TransientLifetimeManager());
            container.RegisterType <IUserStore <Actor>, UserStore <Actor> >(new TransientLifetimeManager());
            container.RegisterType <ApplicationUserManager>(new PerThreadLifetimeManager());
            //container.RegisterType<AccountController>(new TransientLifetimeManager(), new InjectionConstructor(typeof(IActorRepository), typeof(ApplicationUserManager)));

            //container.RegisterType<IAuthenticationManager>(
            //    new InjectionFactory(c => HttpContext.Current.GetOwinContext().Authentication));

            //container.RegisterType<IUserStore<Actor>, UserStore<Actor>>(new HierarchicalLifetimeManager());
            //container.RegisterType<ApplicationSignInManager>(new HierarchicalLifetimeManager());
            //container.RegisterType<ApplicationUserManager>(new HierarchicalLifetimeManager());

            container.RegisterType(typeof(ISecureDataFormat <>), typeof(SecureDataFormat <>));
            container.RegisterType <ISecureDataFormat <AuthenticationTicket>, SecureDataFormat <AuthenticationTicket> >();
            container.RegisterType <ISecureDataFormat <AuthenticationTicket>, TicketDataFormat>();
            container.RegisterType <IDataSerializer <AuthenticationTicket>, TicketSerializer>();
            container.RegisterType <IDataProtector>(
                new InjectionFactory(c => new DpapiDataProtectionProvider().Create("ASP.NET Identity")));
            ProcessingFacility.Register(container);
        }
コード例 #2
0
            private static ProcessingFacility ParseFacility([NotNull] XmlNode facilityNode, [NotNull] XmlNamespaceManager manager)
            {
                Guard.NotNull(facilityNode, nameof(facilityNode));
                Guard.NotNull(manager, nameof(manager));

                var facility = new ProcessingFacility();

                foreach (var attribute in facilityNode.Attributes.Cast <XmlAttribute>())
                {
                    switch (attribute.Name)
                    {
                    case "name":
                        facility.Name = attribute.Value;
                        break;

                    case "country":
                        facility.Country = attribute.Value;
                        break;

                    case "organisation":
                        facility.Organisation = attribute.Value;
                        break;

                    case "site":
                        facility.Site = attribute.Value;
                        break;
                    }
                }

                var softwareNodes = facilityNode.SelectNodes("safe:software", manager);

                foreach (var currentSoftwareNode in softwareNodes.Cast <XmlNode>())
                {
                    var software = new ProcessingSoftware();

                    foreach (var attribute in currentSoftwareNode.Attributes.Cast <XmlAttribute>())
                    {
                        switch (attribute.Name)
                        {
                        case "name":
                            software.Name = attribute.Value;
                            break;

                        case "version":
                            software.Version = attribute.Value;
                            break;
                        }
                    }

                    facility.Software.Add(software);
                }

                return(facility);
            }