public static ApplicationUserManager Create(IdentityFactoryOptions <ApplicationUserManager> options, IOwinContext context) { //TODO: Schöner wäre: Über Owin auf Spring-Context zugreifen UserStoreAdapter userStoreAdapter = ContextRegistry.GetContext().GetObject <UserStoreAdapter>(); IUserService userService = ContextRegistry.GetContext().GetObject <IUserService>(); var manager = new ApplicationUserManager(userStoreAdapter, userService); // Konfigurieren der Überprüfungslogik für Benutzernamen. manager.UserValidator = new UserValidator <SecurityUser>(manager) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = true }; // Konfigurieren der Überprüfungslogik für Kennwörter. manager.PasswordValidator = new PasswordValidator { RequiredLength = 8, RequireNonLetterOrDigit = false, RequireDigit = true, RequireLowercase = true, RequireUppercase = true }; // Standardeinstellungen für Benutzersperren konfigurieren manager.UserLockoutEnabledByDefault = true; manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); manager.MaxFailedAccessAttemptsBeforeLockout = 10; // Registrieren von Anbietern für zweistufige Authentifizierung. Diese Anwendung verwendet telefonische und E-Mail-Nachrichten zum Empfangen eines Codes zum Überprüfen des Benutzers. // Sie können Ihren eigenen Anbieter erstellen und hier einfügen. //manager.RegisterTwoFactorProvider("Telefoncode", new PhoneNumberTokenProvider<SecurityUser> //{ // MessageFormat = "Ihr Sicherheitscode lautet {0}" //}); //manager.RegisterTwoFactorProvider("E-Mail-Code", new EmailTokenProvider<SecurityUser> //{ // Subject = "Sicherheitscode", // BodyFormat = "Ihr Sicherheitscode lautet {0}" //}); //manager.EmailService = new EmailService(); //manager.SmsService = new SmsService(); var dataProtectionProvider = options.DataProtectionProvider; if (dataProtectionProvider != null) { manager.UserTokenProvider = new DataProtectorTokenProvider <SecurityUser>(dataProtectionProvider.Create("ASP.NET Identity")); } return(manager); }
static void Main(string[] args) { IApplicationContext bootstrapContext = ContextRegistry.GetContext(); //alternatively the bootstrapContext can be created with a section in the App.Config file //IApplicationContext bootstrapContext = new XmlApplicationContext("Application-Config.xml"); IBusinessLogicLayer bl = bootstrapContext.GetObject("BL") as IBusinessLogicLayer; bl?.ValidateCustomer(); Console.Read(); }
static void Main(string[] args) { string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments) + "\\TradeHub Logs\\OrderExecutionEngine"; //Logger.LogDirectory(path); Logger.Info(path, "", ""); ApplicationController applicationController = ContextRegistry.GetContext()["ApplicationController"] as ApplicationController; if (applicationController != null) { applicationController.StartServer(); } }
public void LoadServices() { // get the Spring context var context = ContextRegistry.GetContext(); // load core services // load audio services //var // load video services // load WCF services for UPNP }
static void Main(string[] args) { var ctx = ContextRegistry.GetContext("Parent"); var o1 = (MyClass)ctx.GetObject("MyObject"); var o3 = (MyClass)ctx.GetObject("MyObject3"); var ctx2 = ContextRegistry.GetContext("child"); var o2 = (MyClass)ctx2.GetObject("MyObject2"); Console.WriteLine("{0} name: '{1}'", o1, o1.Name); Console.WriteLine("{0} name: '{1}'", o3, o3.Name); Console.WriteLine("{0} name: '{1}'", o2, o2.Name); Console.ReadLine(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //Custom dependency resolver //Se registra el encargado de resolver las instancias y dependencias IApplicationContext context = ContextRegistry.GetContext(); DependencyResolver.SetResolver(new SolucionadorDependencia(context)); }
public UmbracoWorkflowApplicationBase() { Log.Info(string.Format("Starting workflow for Umbraco {0}", Assembly.GetExecutingAssembly().GetName().Version)); var ctx = ContextRegistry.GetContext(); var eventService = (IEventService)ctx.GetObject("EventService"); Log.Debug("Registering events"); eventService.RegisterEvents(); Log.Debug("Registering custom menu items"); BaseContentTree.BeforeNodeRender += BaseContentTreeBeforeNodeRender; }
private void btnStart_Click(object sender, EventArgs e) { var ctx = ContextRegistry.GetContext(); var listener = ctx.GetObject("MessageListenerContainer") as SimpleMessageListenerContainer; if (!listener.IsRunning) { listener.Start(); } tradeOperationsGroupBox.Enabled = true; RebindQueue(txtRoutingKey.Text); }
public void Test_Init_Spring_Context_With_JsonVariableSource_Should_Correctly_Resolve_Bean_When_JSon_File_Is_Valid() { /* Given: Spring-context with JsonVariableSource */ ContextRegistry.RegisterContext(new XmlApplicationContext("..\\..\\Sample\\Valid\\sample.spring.config.xml")); /* When: Spring context is started */ SampleSpringBean sampleSpringBean = ContextRegistry.GetContext().GetObject <SampleSpringBean>(); /* Then: Bean should be resolved including properties */ sampleSpringBean.Should().NotBeNull(); sampleSpringBean.ApplicationName.Should().Be("Sample Application"); sampleSpringBean.Login.Should().Be("username"); sampleSpringBean.Password.Should().Be("top-secret123!"); }
public static void Main(string[] args) { IApplicationContext applicationContext = ContextRegistry.GetContext(); var vat = (ITaxRepository <StateRequest, StateResponse>)applicationContext["TaxCalculatorState"]; //container.Res Console.WriteLine(vat.GetVat(new StateRequest { TaxRate = 12 })); Console.ReadLine(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // designer mode if (DesignMode) { return; } configurationService = (ConfigurationService)ContextRegistry.GetContext().GetObject("ConfigurationService"); treatUnstableAsFailedCheckBox.Checked = configurationService.IsTreadUnstableAsFailed(); }
public ReaderService() { /*是通过XmlObjectFactory或者是IApplicationContext来配置可以二者选其一*/ //或者是通过XmlObjectFactory配置 //IResource input = new FileSystemResource("file:///C:/Objects.xml"); //IObjectFactory factory = new XmlObjectFactory(input); //dal = (IReaderDAL)factory.GetObject("readerDal"); //通过IApplicationContext来配置 IApplicationContext context = ContextRegistry.GetContext(); dal = (IReaderDAL)context.GetObject("readerDal"); }
/// <summary> /// Starts the program. /// </summary> /// <param name="args">The args.</param> /// <remarks></remarks> public static void Main(string[] args) { using (var ctx = ContextRegistry.GetContext()) { var amqpTemplate = (IAmqpTemplate)ctx.GetObject("IAmqpTemplate"); int i = 0; while (true) { amqpTemplate.ConvertAndSend("Hello World " + i++); Logger.Info("Hello world message sent."); Thread.Sleep(3000); } } }
public void TestObjectFactory_GetObject1() { // 利用 Spring Object Name 來依賴尋找找出我們要的 Spring Object. IApplicationContext applicationContext = ContextRegistry.GetContext(); ICourseService courseService = (ICourseService)applicationContext["courseService"]; Course course = courseService.GetCourseByCourseName("Chinese"); Assert.IsNotNull(course); Console.WriteLine("課程編號為 = " + course.CourseID); Console.WriteLine("課程名稱為 = " + course.CourseName); Console.WriteLine("課程描述為 = " + course.CourseDescription); }
private void InjectDao() { var ctx = ContextRegistry.GetContext(); AccountDao = ctx.GetObject("AccountDao") as IAccountDao; LectureCategoryDao = ctx.GetObject("LectureCategoryDao") as ILectureCategoryDao; LectureCategoryRequirementDao = ctx.GetObject("LectureCategoryRequirementDao") as ILectureCategoryRequirementDao; LectureDetailDao = ctx.GetObject("LectureDetailDao") as ILectureDetailDao; LectureTypeDao = ctx.GetObject("LectureTypeDao") as ILectureTypeDao; LectureTypeRequirementDao = ctx.GetObject("LectureTypeRequirementDao") as ILectureTypeRequirementDao; ScoreRequirementDao = ctx.GetObject("ScoreRequirementDao") as IScoreRequirementDao; SectionDao = ctx.GetObject("SectionDao") as ISectionDao; SectionRequirementDao = ctx.GetObject("SectionRequirementDao") as ISectionRequirementDao; }
protected void WirteOperationRecord(string tableName, string type, string desc, string details) { IApplicationContext ctx = ContextRegistry.GetContext(); log.Create(); log.logType = "GUID"; log.operationType = type.ToString(); log.operationTable = tableName; log.operationDesc = desc; log.logDetails = details; log.operationModuleGuid = "0"; log.logLevel = "INFO"; (ctx.GetObject("OperationLogApp") as IOperationLogApp).SubmitFormAsync(log, ""); }
protected void Application_Start(object sender, EventArgs e) { var context = ContextRegistry.GetContext(); var scheduler = (IScheduler)context.GetObject("scheduler"); scheduler.Start(); var jobDetail = new JobDetail("myJob", null, typeof(NoOpJob)); var trigger = TriggerUtils.MakeHourlyTrigger(); trigger.StartTimeUtc = DateTime.UtcNow; trigger.Name = "myTrigger"; scheduler.ScheduleJob(jobDetail, trigger); }
public void TestObjectFactory_GetObject1() { // 利用 Spring Object Name 來依賴尋找找出我們要的 Spring Object. IApplicationContext applicationContext = ContextRegistry.GetContext(); EmployeeService employeeService = (EmployeeService)applicationContext["employeeService"]; Employee empolyee = employeeService.GetEmployeeById("dennis_yen"); Assert.IsNotNull(empolyee); Console.WriteLine("員工編號為 = " + empolyee.Id); Console.WriteLine("員工姓名為 = " + empolyee.Name); Console.WriteLine("員工年齡為 = " + empolyee.Age); }
//測試Dennis的dll(Spring.net) static void Main1(string[] args) { //app.config要先加入設定的object,目前已在Assembly file內loading,要改成可變更需拿出來變resource file IApplicationContext ctx = ContextRegistry.GetContext(); IHexConverter hexConverter = ctx["hexConverter"] as IHexConverter; IByteWorker byteWorker = ctx["byteWorker"] as IByteWorker; IMac2Manager mac2Manager = ctx["mac2Manager"] as IMac2Manager; IHashWorker hashWorker = ctx["hashWorker"] as IHashWorker; IMsgUtility msgUtility = ctx["icash2AOLReqMsgUtility"] as IMsgUtility; IMsgUtility PAMReqMsgUtility = ctx["icash2PAMReqMsgUtility"] as IMsgUtility; IMsgUtility PAMRespMsgUtility = ctx["icash2PAMRespMsgUtility"] as IMsgUtility; Console.ReadKey(); }
public void InsertConsumer() { IApplicationContext ctx = ContextRegistry.GetContext(); IBLL.Owner.ConsumerIbo ibo = (IBLL.Owner.ConsumerIbo)ctx.GetObject("ConsumerBo"); FactoryBo.Owner.ConsumerFactoryBo iboFactory = (FactoryBo.Owner.ConsumerFactoryBo)ctx.GetObject("ConsumerBoFactory"); Entity.Owner.Consumer consumer = new Entity.Owner.Consumer(); consumer.LevelId = 1; consumer.CName = "tianixao"; consumer.CPassword = "******"; consumer.CDate = DateTime.Now.ToString(); //ibo.InsertConsumer(consumer); iboFactory.GetConsumerBo().InsertConsumer(consumer); }
public void SubscribeToRandomMfaSubscriptions_ChecksIfSubscribedMfaSUbscriptionsCanBeUnSubscribedAsExpected_VerifiesThourghDatabaseQuery() { // Enables only some of the subscriptions, and disables others, and checks if the subscriptions are being handled properly IIdentityAccessPersistenceRepository persistenceRepository = (IIdentityAccessPersistenceRepository)ContextRegistry.GetContext()["IdentityAccessPersistenceRepository"]; IUserRepository userRepository = (IUserRepository)ContextRegistry.GetContext()["UserRepository"]; IMfaSubscriptionRepository mfaSubscriptionRepository = (IMfaSubscriptionRepository)ContextRegistry.GetContext()["MfaSubscriptionRepository"]; string userName = "******"; User user = new User(userName, "asdf", "12345", "xyz", "*****@*****.**", Language.English, TimeZone.CurrentTimeZone, new TimeSpan(1, 1, 1, 1), DateTime.Now, "Pakistan", "", "2233344", "1234"); user.IsActivationKeyUsed = new IsActivationKeyUsed(true); user.IsUserBlocked = new IsUserBlocked(false); persistenceRepository.SaveUpdate(user); User receivedUser = userRepository.GetUserByUserName(userName); Assert.NotNull(receivedUser); IList <MfaSubscription> allSubscriptions = mfaSubscriptionRepository.GetAllSubscriptions(); Assert.IsNotNull(allSubscriptions); Assert.GreaterOrEqual(allSubscriptions.Count, 5); IList <Tuple <string, string, bool> > subscriptionsStringList = new List <Tuple <string, string, bool> >(); // Only add alternative elements from the list, but not all subscriptionsStringList.Add(new Tuple <string, string, bool>(allSubscriptions[0].MfaSubscriptionId, allSubscriptions[0].MfaSubscriptionName, true)); subscriptionsStringList.Add(new Tuple <string, string, bool>(allSubscriptions[2].MfaSubscriptionId, allSubscriptions[2].MfaSubscriptionName, true)); subscriptionsStringList.Add(new Tuple <string, string, bool>(allSubscriptions[4].MfaSubscriptionId, allSubscriptions[4].MfaSubscriptionName, true)); receivedUser.AssignMfaSubscriptions(subscriptionsStringList); persistenceRepository.SaveUpdate(receivedUser); receivedUser = userRepository.GetUserByUserName(userName); Assert.NotNull(receivedUser); bool mfaSubscription1 = receivedUser.CheckMfaSubscriptions(allSubscriptions[0].MfaSubscriptionName); Assert.IsTrue(mfaSubscription1); bool mfaSubscription2 = receivedUser.CheckMfaSubscriptions(allSubscriptions[1].MfaSubscriptionName); Assert.IsFalse(mfaSubscription2); bool mfaSubscription3 = receivedUser.CheckMfaSubscriptions(allSubscriptions[2].MfaSubscriptionName); Assert.IsTrue(mfaSubscription3); bool mfaSubscription4 = receivedUser.CheckMfaSubscriptions(allSubscriptions[3].MfaSubscriptionName); Assert.IsFalse(mfaSubscription4); bool mfaSubscription5 = receivedUser.CheckMfaSubscriptions(allSubscriptions[4].MfaSubscriptionName); Assert.IsTrue(mfaSubscription5); }
/// <summary> /// 获取IService服务对象 /// </summary> /// <returns></returns> public static IService GetService() { string name = typeof(CommonExpand).FullName; IService service = Application.Current.Properties[name] as IService; if (service == null) { DbProviderFactory.DBPROVIDER_ADDITIONAL_RESOURCE_NAME = "assembly://Chanyi.Shepherd.Dao/Chanyi.Shepherd.Dao/DbProviders.xml"; IApplicationContext context = ContextRegistry.GetContext(); service = context.GetObject <IService>("services"); Application.Current.Properties[name] = service; } return(service); }
public void MoveFinished(string boxId, string locationId) { //logger.Debug("TransportFinished! boxId, locationId " + transported); // Getting Service Objects from Spring IApplicationContext ctx = ContextRegistry.GetContext(); IMaterialMgtService materialMgt = (IMaterialMgtService)ctx.GetObject("materialMgtServiceObjectWSBinding"); // set location bool locationSet = materialMgt.SetLocation(boxId, locationId); // getting transport entry to find the endDestinationId string endDestinationId; List <Transportentry> trEntries = materialMgt.GetTransportentries().ToList(); Transportentry entry = trEntries.Find( delegate(Transportentry t) { return(t.box_id == boxId); } ); endDestinationId = entry.bin_id; if (!(endDestinationId.Equals(locationId))) { // box is not at the endDestination => CallCCSTransport again! GeneralTransportServiceProp.CallCCSTransport(boxId, endDestinationId); } else { // callback to TransportPlanning that transport was finished //callback.TransportFinished(boxId, endDestinationId); TODO logger.Debug("Box was transported to " + endDestinationId); //IGeneralTransportServiceCallback gTcallback = OperationContext.Current.GetCallbackChannel<IGeneralTransportServiceCallback>(); //gTcallback.TransportFinished(boxId, endDestinationId); GeneralTransportServiceProp.GTcallback.TransportFinished(boxId, endDestinationId); //IGeneralTransportService ct = (IGeneralTransportService) OperationContext.Current.Channel; logger.Debug("fertig"); } //logger.Debug("TransportFinished! boxId =" + boxId + " new binId=" + endDestId); }
static public string GetFlowToRoleKeyWord(RoleInfo roleInfo, int tempId) { if (roleInfo.RoleName.Contains("销售")) { return("设计"); } if (roleInfo.RoleName.Contains("设计")) { short normalFlag = (short)Heima8.OA.Model.Enum.DelFlagEnum.Normal; IApplicationContext ctx = ContextRegistry.GetContext(); var wF_TempService = ctx.GetObject("WF_TempService") as WF_TempService; var temp = wF_TempService.GetEntities(t => t.DelFlag == normalFlag && t.ID == tempId).FirstOrDefault(); if (temp != null && "小锯".Contains(temp.Remark)) { return("小锯"); } else if (temp != null && "数控".Contains(temp.Remark)) { return("数控"); } else { //todo 需要验证 } return(null); } if (roleInfo.RoleName.Contains("小锯")) { return("封边"); } if (roleInfo.RoleName.Contains("数控")) { return("封边"); } if (roleInfo.RoleName.Contains("封边")) { return("排钻"); } if (roleInfo.RoleName.Contains("排钻")) { return("包装"); } if (roleInfo.RoleName.Contains("包装")) { return("包装"); } return(null); }
internal static User getTestUser(string userTag) { IApplicationContext ctx = ContextRegistry.GetContext(); StringTestObject testObj = (StringTestObject)ctx.GetObject(userTag); User user = new User(); user.Uid = testObj.get("userDUZ"); user.Name = new PersonName(testObj.get("userName")); user.SSN = new SocSecNum(testObj.get("userSSN")); user.LogonSiteId = new SiteId(testObj.get("siteCode"), testObj.get("siteName")); user.UserName = testObj.get("accessCode"); user.Pwd = testObj.get("verifyCode"); user.PermissionString = testObj.get("context"); return(user); }
public static T GetObject <T>(bool warning = false) { IApplicationContext ctx = ContextRegistry.GetContext(); var dict = ctx.GetObjectsOfType(typeof(T)); if (warning && dict.Keys.Count == 0) { throw new WarningException("未配置类型的{0}的相关信息", typeof(T).Name); } foreach (var item in dict.Values) { return((T)item); } return(default(T)); }
public void ReleaseController(IController controller) { //get spring context IApplicationContext ctx = ContextRegistry.GetContext(); if (!ctx.ContainsObject(controller.GetType().Name)) { if (defalutf == null) { defalutf = new DefaultControllerFactory(); } defalutf.ReleaseController(controller); } }
static void Main(string[] args) { //传统的 //IUserInfoDal userInfoDal=new UserInfoDal(); //userInfoDal.Show(); //做容器创建实例 //初始化容器 IApplicationContext context = ContextRegistry.GetContext(); IUserInfoDal dal = context.GetObject("UserInfoDal") as IUserInfoDal; dal.Show(); Console.ReadKey(); }
private IList <MediaTypeProvider> GetProviders() { IList <MediaTypeProvider> providers = new List <MediaTypeProvider>(); if (!DesignMode) { IApplicationContext ctx = ContextRegistry.GetContext(); foreach (DictionaryEntry entry in ctx.GetObjectsOfType(typeof(MediaTypeProvider))) { MediaTypeProvider provider = (MediaTypeProvider)entry.Value; providers.Add(provider); } } return(providers); }
/// <summary> /// spring.net singleton object /// </summary> static void IocSingleton() { IApplicationContext appContext = ContextRegistry.GetContext(); IPerson man = appContext.GetObject("ManInstance") as IPerson; IPerson man1 = appContext.GetObject("ManInstance") as IPerson; if (man == man1) { System.Console.WriteLine("Ico Object is Equals"); } else { System.Console.WriteLine("Ico Object is not Equals"); } }