public static OperationContext CreateSystemContext(this EntityApp app) { Util.Check(app != null, "App may not be null."); var sysContext = new OperationContext(app, UserInfo.System); return(sysContext); }
public static IEntitySession OpenSystemSession(this EntityApp app) { Util.Check(app != null, "App may not be null."); var sysContext = new OperationContext(app, UserInfo.System); return(new EntitySession(sysContext)); }
public OperationContext(EntityApp app, UserInfo user = null, WebCallContext webContext = null, ILog log = null, DbConnectionReuseMode connectionMode = DbConnectionReuseMode.NoReuse, ProcessType?processType = null, Guid?processId = null) { App = app; User = user ?? UserInfo.Anonymous; WebContext = webContext; Log = log ?? new DefaultOperationLog(this); DbConnectionMode = connectionMode; ProcessId = processId; if (WebContext != null) { ProcessType = ProcessType.WebRequest; } else { if (processType == null) { ProcessType = (processId == null) ? ProcessType.User : ProcessType.BackgroundProcess; } else { ProcessType = processType.Value; } } }
public static IEntitySession OpenSystemSession(this EntityApp app) { Util.CheckParam(app, nameof(app)); var ctx = app.CreateSystemContext(); return(ctx.OpenSession()); }
public static int GetPropertySize <TEntity>(this EntityApp app, Expression <Func <TEntity, object> > selector) { var propName = ExpressionHelper.GetSelectedProperty(selector); var ent = app.Model.GetEntityInfo(typeof(TEntity), throwIfNotFound: true); var member = ent.GetMember(propName, throwIfNotFound: true); return(member.Size); }
/// <summary>Opens entity session.</summary> /// <param name="app">Entity app.</param> /// <param name="user">User info, optional.</param> /// <returns>Entity session instance.</returns> public static IEntitySession OpenSession(this EntityApp app, UserInfo user = null) { Util.Check(app != null, "App may not be null."); user = user ?? UserInfo.Anonymous; var anonContext = new OperationContext(app, user); return(new EntitySession(anonContext)); }
//.NET framework's GetHashCode() is not guaranteed to be stable between .NET versions. // If we want to keep hashes in database, we need a stable hash implementation public static int ComputeStableHash(this EntityApp app, string value) { if (string.IsNullOrWhiteSpace(value)) { return(0); } var hasher = app.GetService <IHashingService>(); return(hasher.ComputeHash(value)); }
/// <summary>Constructs a new instance of the <c>EntityModule</c> class. </summary> /// <param name="area">Primary entity area to register module entities.</param> /// <param name="name">Module name.</param> /// <param name="description">Optional. Module description.</param> /// <param name="version">Module version.</param> public EntityModule(EntityArea area, string name, string description = null, Version version = null) { Area = area; App = Area.App; Util.Check(App.Status == EntityAppStatus.Created, "Module may not be added to an entity app after it is initialized."); Name = name; Description = description; Version = version ?? new Version("1.0.0.0"); App.AddModule(this); }
public OperationContext(EntityApp app, UserInfo user = null, WebCallContext webContext = null, DbConnectionReuseMode connectionMode = DbConnectionReuseMode.NoReuse) { App = app; User = user ?? UserInfo.Anonymous; WebContext = webContext; DbConnectionMode = connectionMode; LocalLog = new MemoryLog(this); Disposables = new ConcurrentDisposableSet(); }
//Used for creating System-level context within user operation public OperationContext(OperationContext parentContext, UserInfo user) { App = parentContext.App; User = user; WebContext = parentContext.WebContext; LocalLog = parentContext.LocalLog; UserSession = parentContext.UserSession; DataSourceName = parentContext.DataSourceName; DbConnectionMode = parentContext.DbConnectionMode; Disposables = parentContext.Disposables; }
public static int GetPropertySize <TEntity>(this EntityApp app, Expression <Func <TEntity, object> > selector) { var ent = app.Model.GetEntityInfo(typeof(TEntity)); Util.Check(ent != null, "Type {0} is not a registered entity, cannot retrieve property size.", typeof(TEntity)); var propName = ReflectionHelper.GetSelectedProperty(selector); var member = ent.GetMember(propName); Util.Check(member != null, "Property {0} not found on entity {1}.", propName, typeof(TEntity)); return(member.Size); }
/// <summary>Imports services from external service provider. </summary> /// <param name="fromApp">External service provider, usually another entity applications.</param> /// <param name="serviceTypes">Types of services to import.</param> public void ImportServices(EntityApp fromApp, params Type[] serviceTypes) { foreach (var type in serviceTypes) { var serv = fromApp.GetService(type); if (serv != null) { this._services[type] = serv; } } }
public ServiceEventArgs(EntityApp app, Type serviceType, object serviceInstance) { App = app; ServiceType = serviceType; ServiceInstance = serviceInstance; }
public AppInitEventArgs(EntityApp app, EntityAppInitStep step) { App = app; Step = step; }
internal void OnServiceAdded(EntityApp app, Type serviceType, object serviceInstance) { ServiceAdded?.Invoke(this, new ServiceEventArgs(app, serviceType, serviceInstance)); }
public EntityAppEvents(EntityApp app) { _app = app; }
// The constructor is internal, use EntityModelSetup.AddArea method internal EntityArea(EntityApp app, string name) { App = app; Util.CheckNotEmpty(name, "SchemaName may not be empty."); Name = name.Trim().ToLowerInvariant(); }
/// <summary>Opens an entity session for an anonymous user. </summary> /// <param name="app">Entity app instance.</param> /// <returns>An entity session.</returns> public static IEntitySession OpenSession(this EntityApp app) { var context = new OperationContext(app, UserInfo.Anonymous); return(new EntitySession(context)); }
public static Vita.Data.Runtime.Database GetDefaultDatabase(this EntityApp app) { return(app.DataAccess.GetDataSources().FirstOrDefault()?.Database); }
/// <summary>Checks if an entity is registered with entity model. /// For use in customizable models when several versions might exist for different environments, /// and some entities are excluded in some models.</summary> /// <param name="app">Entity app.</param> /// <param name="entityType">The type of entity to check.</param> /// <returns>True if the entity is part of the model; otherwise, false.</returns> public static bool IsRegisteredEntity(this EntityApp app, Type entityType) { return(app.Model.EntitiesByType.ContainsKey(entityType)); }
public static OperationContext CreateSystemContext(this EntityApp app) { var ctx = new OperationContext(app, UserInfo.System); return(ctx); }