public void ModifyUserDetails(ModifyUserDetailsRequest request) { AuthenticationActions.ModifyUserDetailsAction action = PolicyInjection.Create <AuthenticationActions.ModifyUserDetailsAction>(); action.Execute( Translators.ModifyUserDetailsTranslator.TranslateFromServiceToBusiness(request.ModifyUserDetailsParameters)); }
public FindOutputManagersResponse FindOutputManagers(FindOutputManagersRequest request) { IClaimsIdentity identity = (IClaimsIdentity)Thread.CurrentPrincipal.Identity; string upn = identity.Claims.FindAll(c => { return(c.ClaimType == ClaimTypes.Upn); }).First().Value; InitializationActions.FindOutputManagersAction action = PolicyInjection.Create <InitializationActions.FindOutputManagersAction>(); InitializationEntities.FindOutputManagersParameters parameters = Translators.FindOutputManagersTranslator.TranslateFromServiceToBusiness(request.FindOutputManagersParameters); //parameters.UserPrincipalIdentity = upn; /* user@domain */ //parameters.UserIdentity = upn.Split('@')[0]; InitializationEntities.FindOutputManagersResult r = action.Execute(); FindOutputManagersResponse response = new FindOutputManagersResponse(); response.FindOutputManagerResult = GenericMapper.MapNew <DataContracts.FindOutputManagerResult>(r); response.FindOutputManagerResult.OutputManagers = GenericMapper.MapListNew <DataContracts.OutputManagerCollection, InitializationEntities.FindOutputManagerResult, DataContracts.OutputManager>( r.OutputManagers, Translators.FindOutputManagersTranslator.TranslateFromBusinessToService); return(response); }
protected void Button1_Click(object sender, EventArgs e) { cn.com.webxml.www.WeatherWebService ws = new cn.com.webxml.www.WeatherWebService(); string[] r = ws.getWeatherbyCityName(this.TextBox_CityName.Text); this.TextBox1.Text = " "; if (r == null) { this.TextBox1.Text = "无" + this.TextBox_CityName.Text + "城市的天气信息"; return; } foreach (string i in r) { this.TextBox1.Text += i; } Employee emp = PolicyInjection.Create <Employee>(); emp.Name = "weather"; emp.Work(); Response.Write(emp + "<br/>"); }
public InterfaceTracingStatusResult Execute() { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[schemaName]; string connectionString = settings.ConnectionString; ITracingDao tracingDao = PolicyInjection.Create <TracingDao, ITracingDao>(connectionString); IList <CheckInterfaceTracingResult> resultList = null; resultList = tracingDao.CheckInterfaceTracing(new CheckInterfaceTracingParameters()); InterfaceTracingStatusResult result = new InterfaceTracingStatusResult(); if (resultList != null && resultList.Count > 0) { if (resultList[0].LoggOn) { result.LoggIsOn = true; result.LoggStops = resultList[0].LoggStarted.AddSeconds(resultList[0].LoggInterval); } else { result.LoggIsOn = false; result.LoggStops = null; } } return(result); }
public void DoWork() { Employee emp = PolicyInjection.Create <Employee>(); emp.Name = "Lele"; emp.Work(); }
static void Main(string[] args) { //BMIProcessor BMI = new BMIProcessor(); //上面這行改為底下這樣 BMIProcessor BMI = PolicyInjection.Create <BMIProcessor>(); //其餘程式碼完全不變 BMI.Height = 170; BMI.Weight = 70; //計算BMI var ret = BMI.Calculate(); Console.WriteLine($"\nBMI : {ret}"); Console.ReadKey(); //測試exception BMI.Height = 0; BMI.Weight = 0; //計算BMI ret = BMI.Calculate(); Console.WriteLine($"\nBMI : {ret}"); Console.ReadKey(); }
public static T GetMethod <T>(Auth auth) where T : MethodBase { var method = PolicyInjection.Create <T>(); method.Auth = auth; return(method); }
public FindUserDetailsResponse FindUserDetails(FindUserDetailsRequest request) { IClaimsIdentity identity = (IClaimsIdentity)Thread.CurrentPrincipal.Identity; string upn = identity.Claims.FindAll(c => { return(c.ClaimType == ClaimTypes.Upn); }).First().Value; AuthenticationActions.FindUserDetailsAction action = PolicyInjection.Create <AuthenticationActions.FindUserDetailsAction>(); AuthenticationEntities.FindUserDetailsParameters parameters = Translators.FindUserDetailsTranslator.TranslateFromServiceToBusiness(request.FindUserDetailsParameters); parameters.UserPrincipalIdentity = upn; /* user@domain */ parameters.UserIdentity = upn.Split('@')[0]; AuthenticationEntities.FindUserDetailsResult r = action.Execute(parameters); FindUserDetailsResponse response = new FindUserDetailsResponse(); response.FindUserDetailsResult = GenericMapper.MapNew <DataContracts.FindUserDetailsResult>(r); response.FindUserDetailsResult.UserWarehouses = GenericMapper.MapListNew <DataContracts.UserWarehouseCollection, AuthenticationEntities.FindUserWarehousesResult, DataContracts.UserWarehouse>( r.Warehouses, Translators.FindUserDetailsTranslator.TranslateFromBusinessToService); response.FindUserDetailsResult.UserCompanies = GenericMapper.MapListNew <DataContracts.UserCompanyCollection, AuthenticationEntities.FindUserCompaniesResult, DataContracts.UserCompany>( r.Companies, Translators.FindUserDetailsTranslator.TranslateFromBusinessToService); return(response); }
public void CanCreateWrappedObject() { SetupContainer("CanCreateWrappedObject"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(); Assert.IsNotNull(wrappable); Assert.IsTrue(RemotingServices.IsTransparentProxy(wrappable)); }
public void CanCreateWrappedObject() { IConfigurationSource configurationSource = CreateConfigurationSource("CanCreateWrappedObject"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(configurationSource); Assert.IsNotNull(wrappable); Assert.IsTrue(RemotingServices.IsTransparentProxy(wrappable)); }
// 定义单例模式将PolicyInjection.Create<UserOperation>()产生的这个对象传出去,这样就避免了在调用处写这些东西 public static TestTool GetInstance() { if (oUserOpertion == null) { oUserOpertion = PolicyInjection.Create <TestTool>(); } return(oUserOpertion); }
//定义单例模式将PolicyInjection.Create<UserOperation>()产生的这个对象传出去,这样就避免了在调用处写这些东西 public static UserOperation GetInstance() { if (oUserOpertion == null) { oUserOpertion = PolicyInjection.Create <UserOperation>(); } return(oUserOpertion); }
public void StaticFacadeUsesTheCurrentServiceLocator() { GlobalCountCallHandler.Calls.Clear(); var interceptionConfigurationSource = new DictionaryConfigurationSource(); interceptionConfigurationSource.Add( PolicyInjectionSettings.SectionName, new PolicyInjectionSettings { Policies = { new PolicyData("policy") { MatchingRules = { new CustomMatchingRuleData("always", typeof(AlwaysMatchingRule)) }, Handlers = { new CustomCallHandlerData("count", typeof(GlobalCountCallHandler)) { Attributes ={ { "callhandler","count" } } } } } } }); var interceptionLocator = EnterpriseLibraryContainer.CreateDefaultContainer(interceptionConfigurationSource); var noInterceptionLocator = EnterpriseLibraryContainer.CreateDefaultContainer(new DictionaryConfigurationSource()); try { EnterpriseLibraryContainer.Current = interceptionLocator; var interceptedWrappable = PolicyInjection.Create <Wrappable>(); interceptedWrappable.Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls.Count); GlobalCountCallHandler.Calls.Clear(); EnterpriseLibraryContainer.Current = noInterceptionLocator; var nonInterceptedWrappable = PolicyInjection.Create <Wrappable>(); nonInterceptedWrappable.Method(); Assert.AreEqual(0, GlobalCountCallHandler.Calls.Count); } finally { EnterpriseLibraryContainer.Current = null; GlobalCountCallHandler.Calls.Clear(); interceptionLocator.Dispose(); noInterceptionLocator.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { Employee emp = PolicyInjection.Create <Employee>(); emp.Name = "Lele"; emp.Work(); Response.Write(emp); }
public void CanInterceptWrappedObjectWithNonGenericMethods() { SetupContainer("CanCreateWrappedObject"); Wrappable wrappable = (Wrappable)PolicyInjection.Create(typeof(Wrappable)); wrappable.Method2(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanCreateWrappedObject"]); }
public void CanInterceptCallsToDerivedOfMBRO() { SetupContainer("CanInterceptCallsToDerivedOfMBRO"); DerivedWrappable wrappable = PolicyInjection.Create <DerivedWrappable>(); wrappable.Method2(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallsToDerivedOfMBRO"]); }
public void InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes() { SetupContainer("InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes"); DerivedWrappable wrappable = PolicyInjection.Create <DerivedWrappable>(); wrappable.Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes"]); }
public void CanInterceptWrappedObject() { SetupContainer("CanCreateWrappedObject"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(); wrappable.Method2(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanCreateWrappedObject"]); }
public GetSystemTimeResponse GetSystemTime() { GetSystemTimeAction action = PolicyInjection.Create <GetSystemTimeAction>(); GetSystemTimeResponse response = new GetSystemTimeResponse(); response.GetSystemTimeResult = GetSystemTimeResultTranslator.TranslateFromBusinessToService(action.Execute()); return(response); }
public void CanInterceptCallsToMBROOverInterface() { SetupContainer("CanInterceptCallsToMBROOverInterface"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(); ((Interface)wrappable).Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallsToMBROOverInterface"]); }
public void CanCreateWrappedObjectOverInterfaceWithNonGenericMethods() { SetupContainer("CanCreateWrappedObjectOverInterface"); Interface wrappedOverInterface = (Interface)PolicyInjection.Create(typeof(WrappableThroughInterface), typeof(Interface)); wrappedOverInterface.Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanCreateWrappedObjectOverInterface"]); }
public OutputHandlerServiceAdapter() { lock (_createOutputActionLock) { if (_createOutputAction == null) { _createOutputAction = PolicyInjection.Create <CreateOutputAction>(); } } }
public void CanInterceptCallFromBaseOfWrappedInterface() { SetupContainer("CanInterceptCallFromBaseOfWrappedInterface"); Interface wrappedOverInterface = PolicyInjection.Create <WrappableThroughInterface, Interface>(); wrappedOverInterface.Method3(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallFromBaseOfWrappedInterface"]); }
static void Main() { //PolicyInjection.SetPolicyInjector(new PolicyInjector()); Employee emp = PolicyInjection.Create <Employee>(); emp.Name = "Lele"; emp.Work(); Console.WriteLine(emp); Console.Read(); }
public LogonResponse Logon(LogonRequest request) { AuthenticationActions.LogonAction action = PolicyInjection.Create <AuthenticationActions.LogonAction>(); AuthenticationEntities.LogonResult resultParams = action.Execute(Translators.LogonTranslator.TranslateFromServiceToBusiness(request.LogonParameters)); LogonResponse response = new LogonResponse(); response.LogonResult = Translators.LogonTranslator.TranslateFromBusinessToService(resultParams); return(response); }
public void CanInterceptCallFromBaseOfWrappedInterface() { GlobalCountCallHandler.Calls.Clear(); IConfigurationSource configurationSource = CreateConfigurationSource("CanInterceptCallFromBaseOfWrappedInterface"); Interface wrappedOverInterface = PolicyInjection.Create <WrappableThroughInterface, Interface>(configurationSource); wrappedOverInterface.Method3(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallFromBaseOfWrappedInterface"]); }
public void CanInterceptWrappedObject() { GlobalCountCallHandler.Calls.Clear(); IConfigurationSource configurationSource = CreateConfigurationSource("CanCreateWrappedObject"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(configurationSource); wrappable.Method2(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanCreateWrappedObject"]); }
public void CanInterceptCallsToDerivedOfMBRO() { GlobalCountCallHandler.Calls.Clear(); IConfigurationSource configurationSource = CreateConfigurationSource("CanInterceptCallsToDerivedOfMBRO"); DerivedWrappable wrappable = PolicyInjection.Create <DerivedWrappable>(configurationSource); wrappable.Method2(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallsToDerivedOfMBRO"]); }
public void InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes() { GlobalCountCallHandler.Calls.Clear(); IConfigurationSource configurationSource = CreateConfigurationSource("InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes"); DerivedWrappable wrappable = PolicyInjection.Create <DerivedWrappable>(configurationSource); wrappable.Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["InterfaceImplementationsOnDerivedClassesAreWrappedMultipleTimes"]); }
public void CanInterceptCallsToMBROOverInterface() { GlobalCountCallHandler.Calls.Clear(); IConfigurationSource configurationSource = CreateConfigurationSource("CanInterceptCallsToMBROOverInterface"); Wrappable wrappable = PolicyInjection.Create <Wrappable>(configurationSource); ((Interface)wrappable).Method(); Assert.AreEqual(1, GlobalCountCallHandler.Calls["CanInterceptCallsToMBROOverInterface"]); }