private Bug421071Test.TopLevelScope CreateGlobalScope() { factory = new Bug421071Test.DynamicScopeContextFactory(); Context context = factory.EnterContext(); // noinspection deprecation Bug421071Test.TopLevelScope globalScope = new Bug421071Test.TopLevelScope(this, context); Context.Exit(); return globalScope; }
/// <summary>Runs the provided action at the given optimization level</summary> public static void RunWithOptimizationLevel(ContextFactory contextFactory, ContextAction action, int optimizationLevel) { Context cx = contextFactory.EnterContext(); try { cx.SetOptimizationLevel(optimizationLevel); action.Run(cx); } finally { Context.Exit(); } }
// Context currently instanciated and initializes the context. // therefore the test will fail due to insufficient setup. // TODO: Make ContextFactory testable. public void Create_OsIsWindows_ReturnsWindowsContext() { // Arrange var loader = Substitute.For<ILibraryLoader>(); var libmapper = Substitute.For<ILibraryInterfaceMapper>(); var factory = new ContextFactory(loader, libmapper, PlatformID.Win32NT); // Act var context = factory.Create(new ContextCreationParameters{ Device = 1, Window = 1}); // Assert Assert.That(context, Is.InstanceOf<WindowsContext>()); loader.Received(1).Load("GDI32"); loader.Received(1).Load("OpenGL32"); }
protected internal override object GetInterfaceProxyHelper(ContextFactory cf, Type[] interfaces) { // XXX: How to handle interfaces array withclasses from different // class loaders? Using cf.getApplicationClassLoader() ? ClassLoader loader = interfaces[0].GetClassLoader(); Type cl = Proxy.GetProxyClass(loader, interfaces); ConstructorInfo<object> c; try { c = cl.GetConstructor(new Type[] { typeof(InvocationHandler) }); } catch (MissingMethodException ex) { // Should not happen throw Kit.InitCause(new InvalidOperationException(), ex); } return c; }
public virtual void TestSetNullForScriptableSetter() { string scriptCode = "foo.myProp = new Foo2();\n" + "foo.myProp = null;"; ContextFactory factory = new ContextFactory(); Context cx = factory.EnterContext(); try { ScriptableObject topScope = cx.InitStandardObjects(); CustomSetterAcceptNullScriptableTest.Foo foo = new CustomSetterAcceptNullScriptableTest.Foo(); // define custom setter method MethodInfo setMyPropMethod = typeof(CustomSetterAcceptNullScriptableTest.Foo).GetMethod("setMyProp", typeof(CustomSetterAcceptNullScriptableTest.Foo2)); foo.DefineProperty("myProp", null, null, setMyPropMethod, ScriptableObject.EMPTY); topScope.Put("foo", topScope, foo); ScriptableObject.DefineClass<CustomSetterAcceptNullScriptableTest.Foo2>(topScope); cx.EvaluateString(topScope, scriptCode, "myScript", 1, null); } finally { Context.Exit(); } }
public virtual void TestStrictModeError() { contextFactory = new StrictModeApiTest.MyContextFactory(); Context cx = contextFactory.EnterContext(); try { global = cx.InitStandardObjects(); try { RunScript("({}.nonexistent);"); NUnit.Framework.Assert.Fail(); } catch (EvaluatorException e) { NUnit.Framework.Assert.IsTrue(e.Message.StartsWith("Reference to undefined property")); } } finally { Context.Exit(); } }
public async void when_settling_an_overdue_payment() { var orderId = Guid.NewGuid(); var creditCardId = Guid.NewGuid(); var pickUpDate = DateTime.Now; var client = GetPaymentClient(); using (var context = ContextFactory.Invoke()) { context.RemoveAll <OrderDetail>(); context.RemoveAll <OverduePaymentDetail>(); context.SaveChanges(); var tokenizeResponse = await client.Tokenize(TestCreditCards.Visa.Number, TestCreditCards.Visa.NameOnCard, TestCreditCards.Visa.ExpirationDate, TestCreditCards.Visa.AvcCvvCvv2.ToString(), null, TestCreditCards.Visa.ZipCode, TestAccount); var token = tokenizeResponse.CardOnFileToken; var testAccount = context.Set <AccountDetail>().First(a => a.Id == TestAccount.Id); testAccount.DefaultCreditCard = creditCardId; context.RemoveAll <CreditCardDetails>(); context.SaveChanges(); context.Set <CreditCardDetails>().Add(new CreditCardDetails { CreditCardId = creditCardId, AccountId = TestAccount.Id, CreditCardCompany = "Visa", Token = token, Country = new CountryISOCode("CA"), Email = testAccount.Email, Phone = "5145552222", }); context.Set <OrderDetail>().Add(new OrderDetail { Id = orderId, AccountId = TestAccount.Id, BookingFees = 15m, CreatedDate = DateTime.Now, PickupDate = pickUpDate, PickupAddress = TestAddresses.GetAddress1(), ClientLanguageCode = SupportedLanguages.en.ToString() }); context.Set <OrderStatusDetail>().Add(new OrderStatusDetail { OrderId = orderId, IBSOrderId = 12345, VehicleNumber = "9001", Status = OrderStatus.Canceled, AccountId = TestAccount.Id, PickupDate = pickUpDate }); context.Set <OrderPairingDetail>().Add(new OrderPairingDetail { OrderId = orderId, AutoTipPercentage = 15 }); context.Set <OverduePaymentDetail>().Add(new OverduePaymentDetail { AccountId = TestAccount.Id, IBSOrderId = 12345, OrderId = orderId, TransactionDate = DateTime.Now, TransactionId = "TransId", OverdueAmount = 52.34m, ContainBookingFees = false, ContainStandaloneFees = false, IsPaid = false }); context.SaveChanges(); } var result = await client.SettleOverduePayment(null); Assert.AreEqual(true, result.IsSuccessful); var overduePayment = await client.GetOverduePayment(); Assert.IsNull(overduePayment); }
/// <summary>Runs the action successively with all available optimization levels</summary> public static void RunWithAllOptimizationLevels(ContextFactory contextFactory, ContextAction action) { RunWithOptimizationLevel(contextFactory, action, -1); RunWithOptimizationLevel(contextFactory, action, 0); RunWithOptimizationLevel(contextFactory, action, 1); }
/// <summary>Entry point for embedded applications.</summary> /// <remarks> /// Entry point for embedded applications. This method attaches /// to the given /// <see cref="Rhino.ContextFactory">Rhino.ContextFactory</see> /// with the given scope. No /// I/O redirection is performed as with /// <see cref="Main(string[])">Main(string[])</see> /// . /// </remarks> public static Program MainEmbedded(ContextFactory factory, Scriptable scope, string title) { return MainEmbeddedImpl(factory, scope, title); }
/// <summary> /// Construct filter expression for entity. /// </summary> /// <param name="entity">Entity to construct filter expression for.</param> /// <param name="typeOfFilter">Type of filter expression.</param> /// <returns>Filter expression according to entity.</returns> public Expression <Func <TEntity, bool> > ConstructFilterExpression( TEntity entity, FilterType typeOfFilter) { Expression <Func <TEntity, bool> > filterExpression = null; IEnumerable <string> primaryKeyNames = GetPrimaryKeys(); if (primaryKeyNames.Count() == 0) { throw new ArgumentException(string.Format( "'{0}' has no configured primary key.", typeof(TEntity).Name)); } List <Expression> equalityExpressions = new List <Expression>(); IEnumerable <Expression> singleExpressionList; ParameterExpression parameterExp = Expression.Parameter(typeof(TEntity), "m"); Expression pkFilter = null; Expression ukFilter = null; bool primaryKeysHaveDefaultValues = entity.HasDefaultValues(primaryKeyNames); if (!primaryKeysHaveDefaultValues && typeOfFilter != FilterType.OnlyUnique) { // If primary keys do not have their default values // add this check to equlity expression list singleExpressionList = parameterExp .ConstructEqualityExpressions( entity, primaryKeyNames); pkFilter = singleExpressionList.ConstructAndChain(); } if (typeOfFilter != FilterType.OnlyId && (primaryKeysHaveDefaultValues || typeOfFilter != FilterType.IdOptionalUnique)) { IEnumerable <PropertiesWithSource> uniqueProperties = MappingStorage.Instance.UniqueProperties.Where( m => m.SourceType.Equals(entity.GetType())); if (uniqueProperties.Count() > 0) { foreach (PropertiesWithSource unique in uniqueProperties) { /* *********************************************************** * If any of current set of properties * marked as unique is foreign key, * has default value, and appropriate navigation property is not * null and also origin of this foreign * key has any store generated primary key then this * uniqueness must be ignored. * For example if PersonId (int) and DocumentType (short) has been * set as composite unique in PersonDocument and * if PersonId is foreign key to Person, which in its term has * Primary key which is store generated and if there is no navigation * property to Person from PersonDocument or PersonDocument.Person is not null * then PersonId = 0 and DocumentType = 5 should not * be treated as unique, because the real value of PersonId * will be computed when data will be inserted. *********************************************************** */ IGraphEntityTypeManager uniqueSourceTypeManager = ContextFactory .GetEntityTypeManager(unique.SourceType.Name); bool uniquenessMustBeIgnored = false; var uniquePropertyNames = unique.Properties.Select(m => m.Name).ToList(); var uniqueForeignKeys = uniqueSourceTypeManager .GetForeignKeyDetails() .Select(m => new { TargetClass = m.FromDetails.ContainerClass, Keys = m.ToDetails.Keys.Intersect(uniquePropertyNames) }) .Where(m => m.Keys != null && m.Keys.Any()); NavigationDetail navigationDetailsOfCurrent = GetNavigationDetail(); // If unuque property is foreign key if (uniqueForeignKeys != null && uniqueForeignKeys.Any()) { foreach (var uniqueFk in uniqueForeignKeys) { // If foreign key has default value if (uniqueFk.Keys.Any(u => entity.HasDefaultValue(u))) { // Get navigation relation according to foreign key NavigationRelation navigationRelation = navigationDetailsOfCurrent .Relations .FirstOrDefault(r => r.Direction == NavigationDirection.From && r.PropertyTypeName.Equals(uniqueFk.TargetClass) && r.ToKeyNames.Intersect(uniqueFk.Keys).Any()); // If corresponding navigation property is not null // or there is no such navigation property if (navigationRelation == null || entity.GetPropertyValue(navigationRelation.PropertyName) != null) { bool foreignKeyHasStoreGeneratedPrimaryKey = uniqueFk.Keys.Any(k => { // Get origin of foreign key and check // if it has store generated key. string foreignKeyOrigin = uniqueSourceTypeManager .GetOriginOfForeignKey(k); IGraphEntityTypeManager foreignKeyOriginTypeManger = ContextFactory .GetEntityTypeManager(foreignKeyOrigin); return(foreignKeyOriginTypeManger.HasStoreGeneratedKey()); }); // If origin of foreign key has store generated Primary key if (foreignKeyHasStoreGeneratedPrimaryKey) { uniquenessMustBeIgnored = true; break; } } } } } // If uniqueness must be ignored then skip this iteration if (uniquenessMustBeIgnored) { continue; } singleExpressionList = parameterExp .ConstructEqualityExpressions( entity, unique.Properties .Select(m => m.Name).ToList()); equalityExpressions.Add(singleExpressionList.ConstructAndChain()); } if (equalityExpressions.Count > 0) { ukFilter = equalityExpressions.ConstructOrChain(); } } } equalityExpressions.Clear(); if (pkFilter != null) { equalityExpressions.Add(pkFilter); } if (ukFilter != null) { equalityExpressions.Add(ukFilter); } if (equalityExpressions.Count > 0) { Expression filterBaseExpression = typeOfFilter == FilterType.IdAndUnique ? equalityExpressions.ConstructAndChain() : equalityExpressions.ConstructOrChain(); filterExpression = Expression.Lambda <Func <TEntity, bool> >( filterBaseExpression, parameterExp); } return(filterExpression); }
public _InvocationHandler_107(object target, InterfaceAdapter adapter, ContextFactory cf, Scriptable topScope) { this.target = target; this.adapter = adapter; this.cf = cf; this.topScope = topScope; }
public ShipmentsBO(ContextFactory factory) { _factory = factory; }
public AdditionalFieldLogic() { IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext(); this.repository = new AdditionalFieldRepository(IMMRequestContext); }
public virtual void Init(ContextFactory factory) { factory.Call(new _ContextAction_77(this)); }
/// <summary> /// Obtient toutes les données du projet spécifié. /// </summary> /// <param name="projectId">L'identifiant du projet.</param> public virtual async Task <RestitutionData> GetFullProjectDetails(int projectId) => await Task.Run(async() => { using (var context = ContextFactory.GetNewContext(_securityContext.CurrentUser, _localizationManager)) { IDictionary <ProcessReferentialIdentifier, bool> referentialsUsed = await _sharedScenarioActionsOperations.GetReferentialsUse(context, projectId); Referentials referentials = await Queries.LoadAllReferentialsOfProject(context, projectId, referentialsUsed); //await context.Videos.Where(v => v.ProjectId == projectId).ToArrayAsync(); await context.ScenarioNatures.ToArrayAsync(); await context.ScenarioStates.ToArrayAsync(); await context.ActionTypes.ToArrayAsync(); await context.ActionValues.ToArrayAsync(); Project project = await context.Projects .Include(nameof(Project.Process)) .Include($"{nameof(Project.Process)}.{nameof(Procedure.Videos)}") .Include($"{nameof(Project.Process)}.{nameof(Procedure.UserRoleProcesses)}") .Include($"{nameof(Project.Process)}.{nameof(Procedure.UserRoleProcesses)}.{nameof(UserRoleProcess.User)}") .Include($"{nameof(Project.Process)}.{nameof(Procedure.UserRoleProcesses)}.{nameof(UserRoleProcess.User)}.{nameof(User.DefaultLanguage)}") .Include(nameof(Project.Scenarios)) .Include($"{nameof(Project.Scenarios)}.{nameof(Scenario.Actions)}") .Include(nameof(Project.Objective)) .FirstAsync(s => s.ProjectId == projectId); project.ScenariosCriticalPath = PrepareService.GetSummary(project, true); // Scénarios foreach (Scenario scenario in project.Scenarios.Where(s => s.OriginalScenarioId.HasValue)) { // Remapper l'original scenario.Original = project.Scenarios.Single(s => s.ScenarioId == scenario.OriginalScenarioId); ScenarioCriticalPath matchingCriticalItem = project.ScenariosCriticalPath.FirstOrDefault(i => i.Id == scenario.ScenarioId); if (matchingCriticalItem != null) { matchingCriticalItem.OriginalLabel = scenario.Original.Label; } } ProjectReferential[] projectReferentials = await context.ProjectReferentials.Where(pr => pr.ProjectId == projectId).ToArrayAsync(); User user = await context.Users.FirstAsync(u => u.UserId == project.CreatedByUserId); ModificationsUsers modificationsUsers = new ModificationsUsers { CreatedByFullName = (await context.Users.FirstAsync(u => u.UserId == project.ModifiedByUserId)).FullName, LastModifiedByFullName = (await context.Users.FirstAsync(u => u.UserId == project.ModifiedByUserId)).FullName }; Scenario[] scenarios = await context.Scenarios .Where(s => s.ProjectId == projectId) .ToArrayAsync(); await Queries.LoadScenariosDetails(context, scenarios, referentialsUsed); ILookup <int, KAction> actionsToLoad = scenarios .SelectMany(a => a.Actions) .Where(a => a.IsReduced && a.OriginalActionId.HasValue) .ToLookup(a => a.OriginalActionId.Value, a => a); if (actionsToLoad.Any()) { foreach (var duration in await _sharedScenarioActionsOperations.GetActionsBuildDurations(context, actionsToLoad.Select(g => g.Key))) { foreach (KAction action in actionsToLoad[duration.ActionId]) { action.Reduced.Saving = duration.BuildDuration - action.BuildDuration; } } } ScenarioActionHierarchyHelper.MapScenariosActionsOriginals(scenarios); return(new RestitutionData() { Project = project, ProjectCreatedByUser = user, Scenarios = scenarios, ActionCategories = referentials.Categories, ModificationsUsers = modificationsUsers, ReferentialsUse = projectReferentials, }); } });
public SubthemeRepository() : base(ContextFactory.GetContext()) { }
/// <summary> /// 默认构造函数== 程序内赋值调用 有参参数 /// </summary> public BaseManager( ) : this(ContextFactory.CurrentContext()) { }
public ContextElementHandler(ElementFactories factories) { this._factory = factories.Contexts; }
protected override ComponentTestContext CreateContext() { // NOTE: Db Context transactions are not currenty supported by the EF Core InMemory database. // An MSSQL instance is used for unit of work tests. return(ContextFactory.CreateContextWithMSSQLDb(nameof(UnitOfWork_Test))); }
/// <summary>Creates a new context.</summary> /// <remarks> /// Creates a new context. Provided as a preferred super constructor for /// subclasses in place of the deprecated default public constructor. /// </remarks> /// <param name="factory"> /// the context factory associated with this context (most /// likely, the one that created the context). Can not be null. The context /// features are inherited from the factory, and the context will also /// otherwise use its factory's services. /// </param> /// <exception cref="System.ArgumentException">if factory parameter is null.</exception> protected internal Context(ContextFactory factory) { // API class if (factory == null) { throw new ArgumentException("factory == null"); } this.factory = factory; version = VERSION_DEFAULT; optimizationLevel = codegenClass != null ? 0 : -1; maximumInterpreterStackDepth = int.MaxValue; }
static CoreObservations() { ContextFactory.ChangeAllowedNumberOfBecauseBlocksTo(2); }
/// <summary> /// Call /// <see cref="Callable.Call(Context, Scriptable, Scriptable, object[])">Callable.Call(Context, Scriptable, Scriptable, object[])</see> /// using the Context instance associated with the current thread. /// If no Context is associated with the thread, then /// <see cref="ContextFactory.MakeContext()">ContextFactory.MakeContext()</see> /// will be called to construct /// new Context instance. The instance will be temporary associated /// with the thread during call to /// <see cref="ContextAction.Run(Context)">ContextAction.Run(Context)</see> /// . /// <p> /// It is allowed but not advisable to use null for <tt>factory</tt> /// argument in which case the global static singleton ContextFactory /// instance will be used to create new context instances. /// </summary> /// <seealso cref="ContextFactory.Call(ContextAction)">ContextFactory.Call(ContextAction)</seealso> public static object Call(ContextFactory factory, Callable callable, Scriptable scope, Scriptable thisObj, object[] args) { if (factory == null) { factory = ContextFactory.GetGlobal(); } return Call(factory, new _ContextAction_476(callable, scope, thisObj, args)); }
public override void Init(string contextName, ContextFactory factory) { base.Init(contextName, factory); ParseAndSetPeriod(PeriodProperty); }
/// <summary> /// Helper method for /// <see cref="MainEmbedded(string)">MainEmbedded(string)</see> /// , etc. /// </summary> private static Program MainEmbeddedImpl(ContextFactory factory, object scopeProvider, string title) { if (title == null) { title = "Rhino JavaScript Debugger (embedded usage)"; } Program main = new Program(title); main.DoBreak(); main.SetExitAction(new Main.IProxy(Main.IProxy.EXIT_ACTION)); main.AttachTo(factory); if (scopeProvider is ScopeProvider) { main.SetScopeProvider((ScopeProvider)scopeProvider); } else { Scriptable scope = (Scriptable)scopeProvider; if (scope is Global) { Global global = (Global)scope; global.SetIn(main.GetIn()); global.SetOut(main.GetOut()); global.SetErr(main.GetErr()); } main.SetScope(scope); } main.Pack(); main.SetSize(600, 460); main.SetVisible(true); return main; }
public async Task <Image> GetImage(int imageId) { await using var context = ContextFactory.CreateDbContext(ConnectionString); return(context.Images.FirstOrDefault(i => i.Id == imageId)); }
protected internal override object NewInterfaceProxy(object proxyHelper, ContextFactory cf, InterfaceAdapter adapter, object target, Scriptable topScope) { ConstructorInfo<object> c = (ConstructorInfo<object>)proxyHelper; InvocationHandler handler = new _InvocationHandler_107(target, adapter, cf, topScope); // In addition to methods declared in the interface, proxies // also route some java.lang.Object methods through the // invocation handler. // Note: we could compare a proxy and its wrapped function // as equal here but that would break symmetry of equal(). // The reason == suffices here is that proxies are cached // in ScriptableObject (see NativeJavaObject.coerceType()) object proxy; try { proxy = c.NewInstance(handler); } catch (TargetInvocationException ex) { throw Context.ThrowAsScriptRuntimeEx(ex); } catch (MemberAccessException ex) { // Should not happen throw Kit.InitCause(new InvalidOperationException(), ex); } catch (InstantiationException ex) { // Should not happen throw Kit.InitCause(new InvalidOperationException(), ex); } return proxy; }
public async Task DeleteImage(int imageId) { await using var context = ContextFactory.CreateDbContext(ConnectionString); context.Images.Remove(context.Images.First(i => i.Id == imageId)); await context.SaveChangesAsync(); }
public AssemblyExplorer() { _contextFactory = new ContextFactory(); }
public static void SetGlobalContextFactory(ContextFactory factory) { GrabContextFactoryGlobalSetter(); globalSetter.SetContextFactoryGlobal(factory); }
public Repository2(ContextFactory factory) { Factory = factory; }
public void Initialize() { _context = ContextFactory.CreateContext(true); _shareRepository = new ShareRepository(_context); }
/// <summary> /// Synchronize keys of entity with matching entity. /// <remarks> /// In EntityFramework at one-to-one relationships, setting primary key /// of parent entity and setting state of entities to Unchanged or to Modified /// will also change primary key value of child entity. /// But vice-versa is not correct. This means that setting primary key value /// of child entity and setting state of entities to Unchanged or to Modified /// will not change primary key value of parent key, instead, it resets primary /// key value of child entity to its default value, (or to value of primary key /// of parent). /// This method is for synchronizing PKs of entity and PKs of matching entity and /// setting key of parent to key of child entities at one to relationships. /// </remarks> /// </summary> /// <param name="entity">Entity to set pk and parent key values.</param> /// <param name="matchingEntity">Found matching entity from underlying source.</param> public void SynchronizeKeys( TEntity entity, TEntity matchingEntity) { /* * * * Set keys of parent entity to value of child entity at one to one relations. * * */ IEnumerable <RelationshipDetail> associatedRealtionships = GetForeignKeyDetails() .Where(m => m.ToDetails.ContainerClass.Equals(entity.GetType().Name) && m.ToDetails.RelationshipMultiplicity == RelationshipMultiplicity.One); foreach (RelationshipDetail relationshipDetail in associatedRealtionships) { // Get parent property name from navigation details using information from foreign keys IGraphEntityTypeManager entityTypeManager = ContextFactory .GetEntityTypeManager(relationshipDetail.ToDetails.ContainerClass); string parentPropertyName = entityTypeManager .GetNavigationDetail() .Relations .Where(n => n.PropertyTypeName.Equals(relationshipDetail.FromDetails.ContainerClass) && n.SourceMultiplicity == relationshipDetail.ToDetails.RelationshipMultiplicity && n.TargetMultiplicity == relationshipDetail.FromDetails.RelationshipMultiplicity) .Select(n => n.PropertyName) .FirstOrDefault(); dynamic parent = entity.GetPropertyValue(parentPropertyName); if (parent != null) { for (int i = 0; i < relationshipDetail.FromDetails.Keys.Count; i++) { // Get matching from and to key names string fromKeyName = relationshipDetail.FromDetails.Keys[i]; string toKeyName = relationshipDetail.ToDetails.Keys[i]; ReflectionExtensions.SetPropertyValue(parent, fromKeyName, matchingEntity.GetPropertyValue(toKeyName)); } } } /* * Description: * PK value shuold be changed by using * context.Entry(entity).Property(pkName).CurrentValue = pkValue; * becasue setting value by entity.pkName = pkValue will not synchronize * it with dependent navigation properties automatically but prior method * will do it. * Primary key values of entity itself must be changed after * principal parent keys has been synchronized. Because changing * primary key value of entity using * context.Entry(entity).Property(pkName).CurrentValue = pkValue * set principal parent navigation property to null. */ IEnumerable <string> primaryKeyNames = GetPrimaryKeys(); DbEntityEntry current = Context.Entry(entity); foreach (string primaryKey in primaryKeyNames) { current.Property(primaryKey).CurrentValue = matchingEntity.GetPropertyValue(primaryKey); } }
protected override void Initialize(RequestContext requestContext) { this._DbContext = ContextFactory.GetContextPerRequest(); base.Initialize(requestContext); }
public ApiBlogsController(ContextFactory contextFactory) { _contextFactory = contextFactory; }
public static UCategory GetCategory(string idCategory) { return(ContextFactory.GetDBContext().UCategories.FirstOrDefault(c => c.Code.Contains(idCategory))); }
/// <summary> /// Gets the context. /// </summary> /// <returns>DataContextBase.</returns> protected DataContextBase GetContext() { return(ContextFactory.GetContext(this.currentClientUser.GetProfile())); }
public BaseController() { unitOfWork = ContextFactory.CreateContext(typeof(T)); Repository = unitOfWork.Repository <T>(); }
internal static Rhino.Context Enter(Rhino.Context cx, ContextFactory factory) { object helper = VMBridge.instance.GetThreadContextHelper(); Rhino.Context old = VMBridge.instance.GetContext(helper); if (old != null) { cx = old; } else { if (cx == null) { cx = factory.MakeContext(); if (cx.enterCount != 0) { throw new InvalidOperationException("factory.makeContext() returned Context instance already associated with some thread"); } factory.OnContextCreated(cx); if (factory.IsSealed() && !cx.IsSealed()) { cx.Seal(null); } } else { if (cx.enterCount != 0) { throw new InvalidOperationException("can not use Context instance already associated with some thread"); } } VMBridge.instance.SetContext(helper, cx); } ++cx.enterCount; return cx; }
public TableController() { this.publishingService = new PublishingService <Table, DraftTable, TableRepository>(ContextFactory.GetContext(System.Web.HttpContext.Current)); this.productStatusService = new ProductStatusService(ContextFactory.GetContext(System.Web.HttpContext.Current)); this.helperService = new HelperService(); }
/// <summary> /// The method implements /// <see cref="ContextFactory.Call(ContextAction)">ContextFactory.Call(ContextAction)</see> /// logic. /// </summary> internal static object Call(ContextFactory factory, ContextAction action) { Rhino.Context cx = Enter(null, factory); try { return action.Run(cx); } finally { Exit(); } }
public FileExplorer(MSpecUnitTestProvider provider, IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, UnitTestElementLocationConsumer consumer, IFile file, CheckForInterrupt interrupted) { if (file == null) { throw new ArgumentNullException("file"); } if (provider == null) { throw new ArgumentNullException("provider"); } _consumer = consumer; _file = file; _interrupted = interrupted; var project = file.GetSourceFile().ToProjectFile().GetProject(); var projectEnvoy = new ProjectModelElementEnvoy(project); var assemblyPath = UnitTestManager.GetOutputAssemblyPath(project).FullPath; var cache = new ElementCache(); var contextFactory = new ContextFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, assemblyPath, cache); var contextSpecificationFactory = new ContextSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache); var behaviorFactory = new BehaviorFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache); var behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy); _elementHandlers = new List <IElementHandler> { new ContextElementHandler(contextFactory), new ContextSpecificationElementHandler(contextSpecificationFactory), new BehaviorElementHandler(behaviorFactory, behaviorSpecificationFactory) }; }
public void setContextFactory(ContextFactory f) { this.factory = f; }
/// <summary> /// Create helper object to create later proxies implementing the specified /// interfaces later. /// </summary> /// <remarks> /// Create helper object to create later proxies implementing the specified /// interfaces later. Under JDK 1.3 the implementation can look like: /// <pre> /// return java.lang.reflect.Proxy.getProxyClass(..., interfaces). /// getConstructor(new Class[] { /// java.lang.reflect.InvocationHandler.class }); /// </pre> /// </remarks> /// <param name="interfaces">Array with one or more interface class objects.</param> protected internal virtual object GetInterfaceProxyHelper(ContextFactory cf, Type[] interfaces) { throw Context.ReportRuntimeError("VMBridge.getInterfaceProxyHelper is not supported"); }
internal MyContext(ContextFactory factory) : base(factory) { }
private InterfaceAdapter(ContextFactory cf, Type cl) { this.proxyHelper = VMBridge.instance.GetInterfaceProxyHelper(cf, new Type[] { cl }); }
/// <summary>Entry point for embedded applications.</summary> /// <remarks> /// Entry point for embedded applications. This method attaches /// to the given /// <see cref="Rhino.ContextFactory">Rhino.ContextFactory</see> /// with the given scope. No /// I/O redirection is performed as with /// <see cref="Main(string[])">Main(string[])</see> /// . /// </remarks> public static Program MainEmbedded(ContextFactory factory, ScopeProvider scopeProvider, string title) { return MainEmbeddedImpl(factory, scopeProvider, title); }
/// <summary>Attaches the debugger to the given ContextFactory.</summary> /// <remarks>Attaches the debugger to the given ContextFactory.</remarks> public virtual void AttachTo(ContextFactory factory) { Detach(); this.contextFactory = factory; this.listener = new Dim.DimIProxy(this, IPROXY_LISTEN); factory.AddListener(this.listener); }
public CtaMovimientosDal(SecurityEntities context, ContextFactory contextFactory) : base(context, contextFactory) { }
private void Blogreader() { ContextFactory cfact = new ContextFactory(); AggregatorDBContext adbcont = cfact.CreateDbContext(new string[] { "", "" }); ICollection <Author> authors = new List <Author>(); ICollection <Category> cats = new List <Category>(); List <Blog> blogs = new List <Blog>(); blogs = adbcont.Blogs.ToList(); foreach (Blog b in blogs) { string blogURL = b.BlogURL; var reader = XmlReader.Create(blogURL); var feed = SyndicationFeed.Load(reader); foreach (SyndicationItem article in feed.Items) { Post post = adbcont.Posts.FirstOrDefault(a => a.PostTitle == article.Title.Text && a.Lastupdated == article.LastUpdatedTime); if (post == null) { Post post1 = new Post(); List <ArticleAuthor> aa = new List <ArticleAuthor>(); List <ArticleCategory> ac = new List <ArticleCategory>(); post1.ArticleAuthors = aa; post1.ArticleCategories = ac; post1.Lastupdated = article.LastUpdatedTime.UtcDateTime; post1.PostDateCreated = article.PublishDate.UtcDateTime; ICollection <SyndicationLink> links = new List <SyndicationLink>(); links = article.Links; foreach (SyndicationLink l in links) { post1.absURI = l.GetAbsoluteUri().AbsoluteUri; } if (article.Title.Text.Length >= 60) { post1.PostTitle = article.Title.Text.Substring(0, 59); } else { post1.PostTitle = article.Title.Text; } post1.BlogID = b.BlogID; if (article.Summary.Text.Length > 999) { post1.Summary = article.Summary.Text.Substring(0, 998); } else { post1.Summary = article.Summary.Text; } foreach (SyndicationPerson author in article.Authors) { Author author1 = (Author)adbcont.Authors.FirstOrDefault(a => a.AuthorName == author.Name && a.AuthorEmail == author.Email); ArticleAuthor aaa = new ArticleAuthor(); if (author1 == null) { author1 = new Author(); author1.AuthorEmail = author.Email; author1.AuthorName = author.Name; author1.AuthorURI = author.Uri; adbcont.Authors.Add(author1); } aaa.Posts = post; aaa.Authors = author1; post1.ArticleAuthors.Add(aaa); } foreach (SyndicationCategory cat in article.Categories) { if (cat != null && !string.IsNullOrEmpty(cat.Name) && cat.Name != "NULL") { Category category1 = adbcont.Categories.FirstOrDefault(a => a.CategoryName == cat.Name && a.Label == cat.Label); ArticleCategory acc = new ArticleCategory(); if (category1 == null) { Category category = new Category(); category.CategoryName = cat.Name; category.Label = cat.Label; adbcont.Categories.Add(category); acc.Categories = category; acc.Posts = post1; post1.ArticleCategories.Add(acc); } } } adbcont.Posts.Add(post1); adbcont.SaveChanges(); } } } }
private void DoTest(int optimizationLevel, string expected, ContextAction action) { object o = new ContextFactory().Call(new _ContextAction_128(optimizationLevel, action)); NUnit.Framework.Assert.AreEqual(expected, o); }
public override Person First(ISpecification <Person> specification) { return(ContextFactory.GetContext().Person.Where(specification.Expression.Compile()).FirstOrDefault()); }
/// <summary> /// Create proxy object for /// <see cref="InterfaceAdapter">InterfaceAdapter</see> /// . The proxy should call /// <see cref="InterfaceAdapter.Invoke(ContextFactory, object, Scriptable, object, System.Reflection.MethodInfo, object[])">InterfaceAdapter.Invoke(ContextFactory, object, Scriptable, object, System.Reflection.MethodInfo, object[])</see> /// as implementation of interface methods associated with /// <tt>proxyHelper</tt>. /// </summary> /// <param name="proxyHelper"> /// The result of the previous call to /// <see cref="GetInterfaceProxyHelper(ContextFactory, System.Type{T}[])">GetInterfaceProxyHelper(ContextFactory, System.Type<T>[])</see> /// . /// </param> protected internal virtual object NewInterfaceProxy(object proxyHelper, ContextFactory cf, InterfaceAdapter adapter, object target, Scriptable topScope) { throw Context.ReportRuntimeError("VMBridge.newInterfaceProxy is not supported"); }
public override IQueryable <Person> Filter(ISpecification <Person> specification) { return(ContextFactory.GetContext().Person.Where(specification.Expression.Compile()).AsQueryable()); }
public virtual object Invoke(ContextFactory cf, object target, Scriptable topScope, object thisObject, MethodInfo method, object[] args) { ContextAction action = new _ContextAction_80(this, target, topScope, thisObject, method, args); return cf.Call(action); }
public override Person Update(Person itemToUpdate) { ContextFactory.GetContext().SaveChanges(); return(itemToUpdate); }
/// <summary>Detaches the debugger from the current ContextFactory.</summary> /// <remarks>Detaches the debugger from the current ContextFactory.</remarks> public virtual void Detach() { if (listener != null) { contextFactory.RemoveListener(listener); contextFactory = null; listener = null; } }
public override void SaveChanges() { ContextFactory.GetContext().SaveChanges(); }
public SNFichadasDal(SecurityEntities context, ContextFactory contextFactory) : base(context, contextFactory) { }
/// <summary> /// Attaches the debugger to the given /// <see cref="Rhino.ContextFactory">Rhino.ContextFactory</see> /// . /// </summary> public virtual void AttachTo(ContextFactory factory) { dim.AttachTo(factory); }