public AuthService(SignInManager <User> sim, UserManager <User> um, IJwtGenerator jwt, TContext context, IConfiguration configuration) { _signInManager = sim; _userManager = um; _jwt = jwt; _context = context; _configuration = configuration; }
public void Enter(TContext context, TState state) { var enter = _configuration.OnEnter; if (enter != null) { enter(context, state); } }
protected override void DoUnhandledCommand(TContext context, byte[] command) { base.DoUnhandledCommand(context, command); context.TcpConnection.Socket.ReadBytes(1); if (context.TcpConnection.Socket.InputBuffer.IndexOf("\n") == 0) { context.TcpConnection.Socket.ReadBytes(1); } }
private void TPT_or_TPC_model_with_PK_property_to_different_columns_in_different_tables_roundtrips <TContext>() where TContext : BaseContextForPkNaming, new() { using (var context = new TContext()) { context.Database.Initialize(force: false); try { ProviderAgnosticConfiguration.SuspendExecutionStrategy = true; using (new TransactionScope()) { var baseEntity = context.Bases.Add( new BaseForPKNaming { Id = 1, Foo = "Foo1" }); var derivedEntity = context.Deriveds.Add( new DerivedForPKNaming { Id = 2, Foo = "Foo2", Bar = "Bar2" }); context.SaveChanges(); context.Entry(baseEntity).State = EntityState.Detached; context.Entry(derivedEntity).State = EntityState.Detached; var foundBase = context.Bases.Single(e => e.Id == baseEntity.Id); var foundDerived = context.Deriveds.Single(e => e.Id == derivedEntity.Id); Assert.Equal("Foo1", foundBase.Foo); Assert.Equal("Foo2", foundDerived.Foo); Assert.Equal("Bar2", foundDerived.Bar); Assert.True(context.Database.SqlQuery <int>("select base_id from base_table").Any()); Assert.True(context.Database.SqlQuery <int>("select derived_id from derived_table").Any()); if (typeof(TContext) == typeof(ContextForPkNamingTPC)) { Assert.True(context.Database.SqlQuery <string>("select base_foo from base_table").Any()); Assert.True(context.Database.SqlQuery <string>("select derived_foo from derived_table").Any()); } } } finally { ProviderAgnosticConfiguration.SuspendExecutionStrategy = false; } } }
public void Exit(TContext context, TState state) { var exit = _configuration.OnExit; if (exit != null) { exit(context, state); } }
public void Trigger(TContext context, TState state, TEvent @event) { var trigger = _configuration.OnTrigger; if (trigger != null) { trigger(context, state, @event); } }
/// <summary> /// Dispose the TContext object that is associated to the current HTTP request /// </summary> /// <typeparam name="TContext"></typeparam> public static void DisposeContext <TContext>() where TContext : DbContext { string contextName = typeof(TContext).Name; TContext dataContext = HttpContext.Current.Items[contextName] as TContext; if (dataContext != null) { dataContext.Dispose(); } }
public static Character GetCharacter(this TContext ctx, CharacterMode mode, int userId, string clientUUID) { if (mode == CharacterMode.AUTH) { return(ctx.Characters.SingleOrDefault(x => x.UserId == userId)); } else { return(ctx.Characters.SingleOrDefault(x => x.UUID == clientUUID)); } }
public static async Task<APIAccountRole[]> GetRolesForAccount(int accountId) { #if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7 using (var ctx = new TContext()) { return await ctx.APIAccountsRoles.Where(x => x.AccountId == accountId).ToArrayAsync(); } #else return null; #endif }
/// <summary> /// Initializes a new instance of the <see cref="ChangeBundle"/> class. /// </summary> /// <param name="i_Property">The numerical property to change.</param> /// <param name="i_Context">The change context.</param> public ChangeBundle(NumericalProperty <TNumerical, TContext, TModifierReader> i_Property, TContext i_Context = default(TContext)) { Log.DebugAssert(i_Property != null, "Invalid null property."); m_Property = i_Property; m_BaseValue = i_Property.m_BaseValue; m_ChangeTypeMask = ENumericalPropertyChangeType.Bundle; m_AddModifiers = new List <INumericalPropertyModifier <TNumerical, TContext, TModifierReader> >(); m_RemoveModifiers = new List <INumericalPropertyModifier <TNumerical, TContext, TModifierReader> >(); m_Context = i_Context; m_Applied = false; }
public static async Task<APIAccount> FindByName(string name) { #if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7 using (var ctx = new TContext()) { return await ctx.APIAccounts.FirstOrDefaultAsync(x => x.Username == name); } #else return null; #endif }
/// <summary> /// Returns the current TContext object that is associated to the current HTTP request. /// </summary> /// <typeparam name="TContext">Context type</typeparam> /// <returns>A TContext object that is associated to current HTTP request</returns> public static TContext GetContext <TContext>() where TContext : DbContext, new() { var dataContext = HttpContext.Current.Items[typeof(TContext).Name] as TContext; if (dataContext == null) { dataContext = new TContext(); System.Web.HttpContext.Current.Items.Add(typeof(TContext).Name, dataContext); } return(dataContext); }
public SelectExprWithContextEnumerator Init( SelectExprWithContextEnumerable <T, TR, TContext> parent, IPoolingEnumerator <T> src, TContext context, Func <TContext, T, TR> condition) { _src = src; _parent = parent; _context = context; _condition = condition; return(this); }
private static bool SaveCharacterItems(TContext ctx, bool save, Player player, int characterId, Item[] items, ItemType type, SlotItem[] existing) { for (var i = 0; i < items.Length; i++) { if (!SaveCharacterItem(ctx, save, player, characterId, type, items[i], i, existing)) { return(false); } } return(true); }
protected override void DoAfterCommandHandler(TContext AContext) { base.DoAfterCommandHandler(AContext); if (AContext.TcpConnection.Socket.InputBuffer.PeekByte(0) == 13) { AContext.TcpConnection.Socket.InputBuffer.Remove(0); } if (AContext.TcpConnection.Socket.InputBuffer.PeekByte(0) == 10) { AContext.TcpConnection.Socket.InputBuffer.Remove(0); } }
public static Character NewCharacter ( TContext ctx, CharacterMode mode, string auth, string clientUUID, int health, int maxHealth, int mana, int maxMana, int spawnX, int spawnY, int hair, byte hairDye, bool[] hideVisual, byte difficulty, Microsoft.Xna.Framework.Color hairColor, Microsoft.Xna.Framework.Color skinColor, Microsoft.Xna.Framework.Color eyeColor, Microsoft.Xna.Framework.Color shirtColor, Microsoft.Xna.Framework.Color underShirtColor, Microsoft.Xna.Framework.Color pantsColor, Microsoft.Xna.Framework.Color shoeColor, int anglerQuests ) { return(NewCharacter ( ctx, mode, auth, clientUUID, health, maxHealth, mana, maxMana, spawnX, spawnY, hair, hairDye, DataEncoding.EncodeInteger(hideVisual), difficulty, DataEncoding.EncodeColor(hairColor), DataEncoding.EncodeColor(skinColor), DataEncoding.EncodeColor(eyeColor), DataEncoding.EncodeColor(shirtColor), DataEncoding.EncodeColor(underShirtColor), DataEncoding.EncodeColor(pantsColor), DataEncoding.EncodeColor(shoeColor), anglerQuests )); }
public void Run(TContext context) { try { var task = this.Func(context, Monad.Value); task.Wait(); this.Task.SetResult(task.Result); } catch (Exception ex) { this.Task.SetException(ex); } }
public SerializerBuilderOnUnpacedParameter( SerializerBuilder <TContext, TConstruct, TObject> builder, TContext context, Type itemType, TConstruct memberName, TConstruct store ) { this.Builder = builder; this.Context = context; this._itemType = itemType; this.MemberName = memberName; this._store = store; }
public SelectManyExprWithContextEnumerator Init( SelectManyExprWithContextEnumerable <T, TR, TContext> parent, IPoolingEnumerator <T> src, Func <T, TContext, IPoolingEnumerable <TR> > mutator, TContext context) { _src = src; _finished = false; _parent = parent; _mutator = mutator; _context = context; _currentEnumerator = default; return(this); }
public static ReadOnlyMetadataCollection <NavigationProperty> GetNavigationProperties <TEntity, TContext>() where TContext : DbContext { ObjectContext objectContext; using (TContext context = Activator.CreateInstance <TContext>()) { objectContext = ((IObjectContextAdapter)context).ObjectContext; } var container = objectContext.MetadataWorkspace.GetEntityContainer(objectContext.DefaultContainerName, DataSpace.CSpace); var navigationProperties = ((EntityType)container.BaseEntitySets.First(bes => bes.ElementType.Name == typeof(TEntity).Name).ElementType).NavigationProperties; return(navigationProperties); }
public JobWrapper ( CreateInB<TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> state, IEntitySynchronizationLogger logger, TContext context) { if (state == null) throw new ArgumentNullException (nameof (state)); if (logger == null) throw new ArgumentNullException (nameof (logger)); _state = state; _logger = logger; _context = context; }
public SerializerBuilderOnPackingParameter( SerializerBuilder <TContext, TConstruct, TObject> builder, TContext context, TConstruct item, Type itemType, string memberName ) { this.Builder = builder; this.Context = context; this.Item = item; this._itemType = itemType; this.MemberName = memberName; }
async ValueTask IAsyncDisposable.DisposeAsync() { if (_contextPool != null) { if (!_contextPool.Return(Context)) { ((IDbContextPoolable)Context).SetPool(null); await Context.DisposeAsync().ConfigureAwait(false); } _contextPool = null; Context = null; } }
void IDisposable.Dispose() { if (_contextPool != null) { if (!_contextPool.Return(Context)) { ((IDbContextPoolable)Context).SetPool(null); Context.Dispose(); } _contextPool = null; Context = null; } }
internal IndividualDiagnosticSourceListener( DiagnosticListener diagnosticListener, IDiagnosticEventHandler eventHandler, DiagnosticSourceListenerBase <TContext> telemetryDiagnosticSourceListener, TContext context, ActiveSubsciptionManager subscriptionManager) { this.diagnosticListener = diagnosticListener; this.eventHandler = eventHandler; this.Context = context; this.telemetryDiagnosticSourceListener = telemetryDiagnosticSourceListener; this.subscriptionManager = subscriptionManager; this.subscriptionManager.Attach(this); }
public void Rollback(TContext context) { if (_rollback != null) { try { _rollback(context); } catch (Exception error) { throw new InvalidOperationException(string.Format(Properties.Resources.CantRollbackStage, _name), error); } } }
public void Execute(TContext context) { if (_execute != null) { try { _execute(context); } catch (Exception error) { throw new InvalidOperationException(string.Format(Properties.Resources.CantExecuteStage, _name), error); } } }
public Executor( IConfigurationProvider configuration, TContext context, TState state) { configuration.EnsureNotNull("configuration"); state.EnsureNotNull("state"); _stateConfigList = configuration.States.Select(s => new StateConfiguration(s)).ToArray(); _eventConfigList = configuration.Events.Select(e => new EventConfiguration(e)).ToArray(); Context = context; State = state; OnEnter(); }
public object Map(object from, object to, TContext context) { if (to == null) { to = _constructor(); } var toList = (IList)to; toList.Clear(); MapperUtils.CopyToList((IEnumerable)from, toList, _typeMapper, context); return(to); }
public XmlSerializationOptions(XmlSerializationOptions <TContext> options) { if (options == null) { Encoding = Helper.UTF8Unsigned; Context = default(TContext); XmlDeclarationType = 0; } else { Encoding = options.Encoding ?? Helper.UTF8Unsigned; Context = options.Context; XmlDeclarationType = options.XmlDeclarationType; } }
public IDbProvider GetDbProvider <TContext>() where TContext : BaseDbContext, new() { BaseDbContext context; var dbkey = typeof(TContext).FullName; if (this.contexts.TryGetValue(dbkey, out context)) { return(new EfDbProvider(context)); } context = new TContext(); this.contexts.Add(dbkey, context); return(new EfDbProvider(context)); }
// Savechanges represents the number of of objects written to the underlying database public UnitOfWork(DbOptions opt) { DbContextOptions <TContext> options; // Connects to our actual database options = new DbContextOptionsBuilder <TContext>() .UsingSqlServer(opt.ConnectionString) .Options; // Ensures that the database exsists context = new TContext(options); context.Database.EnsureCreated(); }
public static async Task<APIAccount> FindByNameAsync(string name) { #if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7 using (var ctx = new TContext()) { return await ctx.APIAccounts.FirstOrDefaultAsync(x => x.Username == name); } #elif DAPPER using (var ctx = DatabaseFactory.CreateConnection()) { using (var txn = ctx.BeginTransaction()) return await ctx.FirstOrDefaultAsync<APIAccount>(new { Username = name }, transaction: txn); } #else return null; #endif }
public static async Task<APIAccountRole[]> GetRolesForAccount(long accountId) { #if ENTITY_FRAMEWORK_6 || ENTITY_FRAMEWORK_7 using (var ctx = new TContext()) { return await ctx.APIAccountsRoles.Where(x => x.AccountId == accountId).ToArrayAsync(); } #elif DAPPER using (var ctx = DatabaseFactory.CreateConnection()) { using (var txn = ctx.BeginTransaction()) return (await ctx.WhereAsync<APIAccountRole>(new { AccountId = accountId }, transaction: txn)).ToArray(); } #else return null; #endif }