private SerializationContext(ContextMode contextMode, IStreamSource streamSource, SerializerMode serializerMode, BackgroundStream parentStream) { ContextMode = contextMode; StreamSource = Argument.NotNull(streamSource, nameof(streamSource)); SerializerMode = Argument.NotNull(serializerMode, nameof(serializerMode)); _backgroundStream = Argument.NotNull(parentStream, nameof(parentStream)); }
public SerializationContext?GetSubContext([CanBeNull] string relativeFile, ContextMode contextMode) { if (relativeFile == null) { return(this); } if (_childContexts.TryGetValue(relativeFile, out var context)) { return(context); } var streamSource = StreamSource.OpenSideLocation(relativeFile); if (streamSource == null) { return(null); } if (_backgroundStream == null) { return(null); } context = new SerializationContext(contextMode, streamSource, SerializerMode, _backgroundStream); _childContexts[relativeFile] = context; return(context); }
public SerializationContext(ContextMode contextMode, IStreamSource streamSource, SerializerMode serializerMode) { ContextMode = contextMode; StreamSource = Argument.NotNull(streamSource, nameof(streamSource)); SerializerMode = Argument.NotNull(serializerMode, nameof(serializerMode)); _backgroundStream = new BackgroundStream(); }
/// <summary> /// Configures the database context to the given mode /// </summary> public static void SetContextMode(this DbContext dbContext, ContextMode mode) { dbContext.Configuration.ProxyCreationEnabled = mode.HasFlag(ContextMode.ProxyOnly); dbContext.Configuration.LazyLoadingEnabled = mode.HasFlag(ContextMode.LazyLoading); dbContext.Configuration.AutoDetectChangesEnabled = mode.HasFlag(ContextMode.ChangeTracking); dbContext.Configuration.ValidateOnSaveEnabled = true; }
/// <inheritdoc /> public DbContext CreateContext(IDatabaseConfig config, ContextMode mode) { var context = (DbContext)Activator.CreateInstance(_contextType, BuildConnectionString(config)); context.SetContextMode(mode); return(context); }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current != null && _current.ContextId.Equals(contextId, StringComparison.OrdinalIgnoreCase)) { return(_current); } var renderService = Owner.Options.GetService <IRenderingService>(); if (renderService == null) { return(null); } var context = renderService.CreateContext(contextId); if (context != null) { context.Host = this; _mode = GetModeFrom(contextId); _current = context; } return(context); }
public void SetContext(string game, ContextMode mode) { Game = game; Mode = mode; OnContextChange?.Invoke(this, new ContextChangeEventArgs(game, mode)); }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current == null || contextId.Isi(_current.ContextId)) { foreach (var renderService in _renderServices) { if (renderService.IsSupportingContext(contextId)) { var context = renderService.CreateContext(this, contextId); if (context != null) { _mode = GetModeFrom(contextId); _current = context; } return(context); } } return(null); } return(_current); }
public SerializationContext(ContextMode contextMode, [NotNull] IStreamSource streamSource, SerializerMode serializerMode) { ContextMode = contextMode; StreamSource = streamSource; SerializerMode = serializerMode; _backgroundStream = new BackgroundStream(); }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current == null || contextId.Isi(_current.ContextId)) { var renderServices = Owner.Options.GetServices<IRenderingService>(); foreach (var renderService in renderServices) { if (renderService.IsSupportingContext(contextId)) { var context = renderService.CreateContext(this, contextId); if (context != null) { _mode = GetModeFrom(contextId); _current = context; } return context; } } return null; } return _current; }
public override IContent Route(UrlBuilder urlBuilder, ContextMode contextMode) { // Attempts to parse content ID from the path. // This only works with URLs generated with the GetUrl method, where the URL is the content ID. // If contentRepository is provided, load the content from there, otherwise return BasicContent. int id; if (int.TryParse(urlBuilder.Path, out id)) { var contentLink = new ContentReference(id); if (contentRepository != null) { return(contentRepository.Get <IContent>(contentLink)); } else { return new BasicContent { ContentLink = contentLink } }; } return(null); }
private SerializationContext(ContextMode contextMode, [NotNull] IStreamSource streamSource, SerializerMode serializerMode, [NotNull] BackgroundStream parentStream) { ContextMode = contextMode; StreamSource = streamSource; SerializerMode = serializerMode; _backgroundStream = parentStream; }
public void SetContext(ContextGame game, ContextMode mode) { currentGame = game; currentMode = mode; if (OnContextChange != null) { OnContextChange(this, new ContextChangeEventArgs(game, mode)); } }
/// <inheritdoc /> public TContext Create <TContext>(IDatabaseConfig config, ContextMode contextMode) where TContext : DbContext { var connection = string.IsNullOrEmpty(_instanceId) ? Effort.DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString()) : Effort.DbConnectionFactory.CreatePersistent(_instanceId); // Create instance of context var context = (TContext)Activator.CreateInstance(typeof(TContext), connection); // Override initializer of MoryxDbContext: Create database if not exists Database.SetInitializer(new CreateDatabaseIfNotExists <TContext>()); return(context); }
/// <inheritdoc /> public TContext Create <TContext>(IDatabaseConfig config, ContextMode contextMode) where TContext : DbContext { var wrapper = _knownModels.FirstOrDefault(k => k.DbContextType == typeof(TContext)); if (wrapper == null) { throw new InvalidOperationException("Unknown model"); } var configurator = wrapper.Configurator; return(config != null ? (TContext)configurator.CreateContext(config, contextMode) : (TContext)configurator.CreateContext(contextMode)); }
/// <summary> /// Changes the context the element is related to the given one. /// </summary> /// <param name="context">The new context.</param> public void SetContext(IRenderingContext context) { if (_mode != ContextMode.None && _mode != ContextMode.Indirect) { throw new DomException(DomError.InvalidState); } else if (context.IsFixed) { throw new DomException(DomError.InvalidState); } context.Host = this; _current = context; _mode = ContextMode.Indirect; }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current != null && contextId.Isi(_current.ContextId)) return _current; var renderService = Owner.Options.GetService<IRenderingService>(); if (renderService == null) return null; var context = renderService.CreateContext(this, contextId); if (context != null) { _mode = GetModeFrom(contextId); _current = context; } return context; }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current != null && _current.ContextId.Equals(contextId, StringComparison.OrdinalIgnoreCase)) return _current; var renderService = Owner.Options.GetService<IRenderingService>(); if (renderService == null) return null; var context = renderService.CreateContext(this, contextId); if (context != null) { _mode = GetModeFrom(contextId); _current = context; } return context; }
/// <summary> /// Gets the drawing context. /// </summary> /// <param name="contextId">A context id like 2d.</param> /// <returns>An object that defines the drawing context.</returns> public IRenderingContext GetContext(String contextId) { if (_current != null && contextId.Isi(_current.ContextId)) { return(_current); } var renderService = Owner.Options.GetService <IRenderingService>(); if (renderService == null) { return(null); } var context = renderService.CreateContext(this, contextId); if (context != null) { _mode = GetModeFrom(contextId); _current = context; } return(context); }
/// <summary> /// Возвращает контекст доверенного подключения (без пароля или Integrated Security) /// </summary> /// <param name="mode">Тип подключения.</param> /// <param name="serverNameORPath">Название сервера или директория расположения файла базы.</param> /// <param name="dataBaseName">Название базы или имя базы без расширения, расширение берётся из типа подключения.</param> /// <returns></returns> public abstract MainContext GetContext(ContextMode mode, String serverNameORPath, String dataBaseName);
/// <inheritdoc /> public IUnitOfWork <TContext> Create(ContextMode contextMode) => _internalFactory.Create(contextMode);
public void SetContextMode(ContextMode contextMode) { this.contextMode = contextMode; }
protected void EnterContext(ContextMode mode) { _contextStack.Push(mode); }
/// <summary> /// Displays the context menu /// </summary> /// <param name="mode">Display mode</param> /// <param name="data">User data</param> private void SetContext(ContextMode mode, object data = null) { Context_Mode = mode; Context_Data = data; }
public ContextChangeEventArgs(ContextGame game, ContextMode mode) { this.GameContext = game; this.ModeContext = mode; }
public void SetContext(ContextMode mode) { SetContext(currentGame, mode); }
/// <inheritdoc /> public TContext Create <TContext>(ContextMode contextMode) where TContext : DbContext => Create <TContext>(null, contextMode);
/// <inheritdoc /> public TContext Create(IDatabaseConfig config, ContextMode contextMode) { return(Manager.Create <TContext>(config, contextMode)); }
/// <inheritdoc /> public TContext Create(ContextMode contextMode) { return(Manager.Create <TContext>(contextMode)); }
public ContextChangeEventArgs(string game, ContextMode mode) { GameContext = game; ModeContext = mode; }
/// <summary> /// Creates a new HTML canvas element. /// </summary> public HtmlCanvasElement(Document owner, String prefix = null) : base(owner, TagNames.Canvas, prefix) { _renderServices = owner.Context.GetServices <IRenderingService>(); _mode = ContextMode.None; }
protected SerializerBase(ObjectBuilder builder, SimpleMapper <TContext> mapper, ContextMode contextMode) { _builder = Argument.NotNull(builder, nameof(builder)); _mapper = Argument.NotNull(mapper, nameof(mapper)); _contextMode = contextMode; }
//custom constructor to initialize the context with specific connection string and backend configuration public FluentModel(string connectionStringName, BackendConfiguration backendConfiguration, FluentModelMetadataSource metadataSource, ContextMode contextMode) : base(connectionStringName, backendConfiguration, metadataSource) { this.mode = contextMode; }
/// <summary> /// Hides the context menu /// </summary> private void ResetContext() { Context_Data = null; Context_Mode = ContextMode.None; }
/// <summary> /// Changes the context the element is related to the given one. /// </summary> /// <param name="context">The new context.</param> public void SetContext(IRenderingContext context) { if (_mode != ContextMode.None && _mode != ContextMode.Indirect) throw new DomException(DomError.InvalidState); else if (context.IsFixed) throw new DomException(DomError.InvalidState); context.Host = this; _current = context; _mode = ContextMode.Indirect; }
public override IContent Route(UrlBuilder urlBuilder, ContextMode contextMode) { return(_defaultUrlResolver.Route(urlBuilder, contextMode)); }
/// <summary> /// Creates a new HTML canvas element. /// </summary> public HtmlCanvasElement(Document owner, String prefix = null) : base(owner, Tags.Canvas, prefix) { _mode = ContextMode.None; }
/// <inheritdoc /> public IUnitOfWork <TContext> Create(IDatabaseConfig config, ContextMode contextMode) { var context = _manager.Create <TContext>(config, contextMode); return(new UnitOfWork <TContext>(context, Repositories)); }
/// <inheritdoc /> public IUnitOfWork <TContext> Create(IDatabaseConfig config, ContextMode contextMode) => _internalFactory.Create(config, contextMode);
public void SetContext(ContextMode mode) { SetContext(Game, mode); }
/// <inheritdoc /> public DbContext CreateContext(IDatabaseConfig config, ContextMode mode) { throw new NotSupportedException("Not supported by " + nameof(NullModelConfigurator)); }
public SerializationContext GetSubContext([CanBeNull] string relativeFile, ContextMode contextMode) { if (relativeFile == null) return this; SerializationContext context; if (_childContexts.TryGetValue(relativeFile, out context)) return context; IStreamSource streamSource = StreamSource.OpenSideLocation(relativeFile); if (streamSource == null) return null; context = new SerializationContext(contextMode, streamSource, SerializerMode, _backgroundStream); _childContexts[relativeFile] = context; return context; }