public static void Start() { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { Navigator.RegisterArea(typeof(IsolationClient)); WidgetsHelper.GetWidget += ctx => ctx.Entity is Entity && MixinDeclarations.IsDeclared(ctx.Entity.GetType(), typeof(IsolationMixin)) ? IsolationWidgetHelper.CreateWidget(ctx) : null; Navigator.AddSetting(new EntitySettings <IsolationEntity> { PartialViewName = _ => ViewPrefix.FormatWith("Isolation") }); Constructor.ClientManager.GlobalPreConstructors += ctx => (!MixinDeclarations.IsDeclared(ctx.Type, typeof(IsolationMixin)) || IsolationEntity.Current != null) ? null : Module["getIsolation"](ClientConstructorManager.ExtraJsonParams, ctx.Prefix, IsolationMessage.SelectAnIsolation.NiceToString(), GetIsolationChooserOptions(ctx.Type)); //Unnecessary with the filter Constructor.Manager.PreConstructors += ctx => !MixinDeclarations.IsDeclared(ctx.Type, typeof(IsolationMixin)) ? null : IsolationEntity.Override(GetIsolation(ctx.Controller.ControllerContext)); MapClient.GetColorProviders += GetMapColors; } }
public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { MixinDeclarations.AssertDeclared(typeof(BigStringEmbedded), typeof(BigStringMixin)); sb.Schema.SchemaCompleted += Schema_SchemaCompleted; BigStringMixin.PreSavingAction = PreSaving; BigStringMixin.PostRetrievingAction = PostRetrieving; } }
public static void TreeEntityMove <T>(T t, MoveTreeModel model) where T : TreeEntity, new() { TreeLogic.FixRouteAndNames(t, model); t.Save(); if (MixinDeclarations.IsDeclared(typeof(T), typeof(DisabledMixin)) && model.NewParent != null && model.NewParent.InDB(e => e.Mixin <DisabledMixin>().IsDisabled) && !t.Mixin <DisabledMixin>().IsDisabled) { t.Execute(DisableOperation.Disable); } }
public static void RegisterOperations <T>(Func <T, MoveTreeModel, T>?copy) where T : TreeEntity, new() { Graph <T> .Construct.Untyped(TreeOperation.CreateRoot).Do(c => { c.Construct = (_) => new T { ParentOrSibling = null, Level = 1, IsSibling = false }; c.Register(); }); Graph <T> .ConstructFrom <T> .Untyped(TreeOperation.CreateChild).Do(c => { c.Construct = (t, _) => new T { ParentOrSibling = t.ToLite(), Level = (short)(t.Level !+1), IsSibling = false // }; c.Register(); }); Graph <T> .ConstructFrom <T> .Untyped(TreeOperation.CreateNextSibling).Do(c => { c.Construct = (t, _) => new T { ParentOrSibling = t.ToLite(), Level = t.Level, IsSibling = true // }; c.Register(); }); new Graph <T> .Execute(TreeOperation.Save) { CanBeNew = true, CanBeModified = true, Execute = (t, _) => { if (t.IsNew) { t.Route = CalculateRoute(t); if (MixinDeclarations.IsDeclared(typeof(T), typeof(DisabledMixin)) && t.ParentOrSibling != null) { t.Mixin <DisabledMixin>().IsDisabled = t.Parent() !.Mixin <DisabledMixin>().IsDisabled; } } TreeLogic.FixName(t); } }
static Server() { Connecting += () => { ServerTypes = current.ServerTypes(); NameToType = ServerTypes.ToDictionary(a => a.Value.CleanName, a => a.Key); MixinDeclarations.Import(current.FindAllMixins()); PrimaryKey.Import(current.ImportPrimaryKeyDefinitions()); }; }
public void Complete(IEqualityComparerResolver resolver, PropertyInfo?pi) { Properties = MemberEntryFactory.GenerateList <T>(MemberOptions.Properties | MemberOptions.Typed | MemberOptions.Getter) .Where(p => !((PropertyInfo)p.MemberInfo).HasAttribute <HiddenPropertyAttribute>()) .ToDictionary(a => a.Name, a => new PropertyComparer <T>( propertyInfo: (PropertyInfo)a.MemberInfo, a.Getter !, comparer: resolver.GetEqualityComparer(((PropertyInfo)a.MemberInfo).PropertyType, (PropertyInfo)a.MemberInfo))); Mixins = !typeof(Entity).IsAssignableFrom(typeof(T)) ? null : MixinDeclarations.GetMixinDeclarations(typeof(T)).ToDictionary(t => t, t => resolver.GetEqualityComparer(t, null)); }
public static void Start(Func <Lite <IsolationEntity>, ImageSource> getIsolationIcon) { if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod())) { Constructor.Manager.PreConstructors += Constructor_PreConstructors; WidgetPanel.GetWidgets += (e, c) => e is Entity && MixinDeclarations.IsDeclared(e.GetType(), typeof(IsolationMixin)) ? new IsolationWidget().Set(Common.OrderProperty, -1.0) : null; List <Lite <IsolationEntity> > isolations = null; Server.OnOperation += context => { var iso = IsolationEntity.CurrentThreadVariable.Value; if (iso != null) { var msg = new MessageHeader <string>(iso.Item1?.Let(i => i.KeyLong())) .GetUntypedHeader("CurrentIsolation", "http://www.signumsoftware.com/Isolation"); context.OutgoingMessageHeaders.Add(msg); } }; GetIsolationIcon = getIsolationIcon; SelectIsolationInteractively = (owner, isValid) => { if (isolations == null) { isolations = Server.RetrieveAllLite <IsolationEntity>(); } var isos = isValid == null ? isolations : isolations.Where(i => isValid(i) == null).ToList(); if (SelectorWindow.ShowDialog(isos, out Lite <IsolationEntity> result, elementIcon: getIsolationIcon, elementText: iso => getIsolationIcon(iso) == null ? iso.ToString() : null, title: IsolationMessage.SelectAnIsolation.NiceToString(), message: IsolationMessage.SelectAnIsolation.NiceToString(), owner: owner)) { return(result); } return(null); }; Async.OnShowInAnotherThread += Async_OnShowInAnotherThread; Finder.Manager.TaskSearchWindow += Manager_TaskSearchWindow; } }
internal static void Start() { DescriptionManager.Invalidated += () => cache.Clear(); Schema.Current.OnMetadataInvalidated += () => cache.Clear(); var mainTypes = Schema.Current.Tables.Keys; var mixins = mainTypes.SelectMany(t => MixinDeclarations.GetMixinDeclarations(t)); var operations = OperationLogic.RegisteredOperations.Select(o => o.FieldInfo.DeclaringType); EntityAssemblies = mainTypes.Concat(mixins).Concat(operations).AgGroupToDictionary(t => t.Assembly, gr => gr.Select(a => a.Namespace).ToHashSet()); EntityAssemblies[typeof(PaginationMode).Assembly].Add(typeof(PaginationMode).Namespace); }
PropertyInfo GetPropertyInfo(LambdaExpression property, out Type mixin) { if (property == null) { throw new ArgumentNullException("property"); } Expression body = property.Body; if (body.NodeType == ExpressionType.Convert) { body = ((UnaryExpression)body).Operand; } MemberExpression ex = body as MemberExpression; if (ex == null) { throw new ArgumentException("The lambda 'property' should be an expression accessing a property"); } PropertyInfo pi = ex.Member as PropertyInfo; if (pi == null) { throw new ArgumentException("The lambda 'property' should be an expression accessing a property"); } var mce = ex.Expression as MethodCallExpression; if (ex.Expression == property.Parameters.Only()) { mixin = null; return(pi); } else if (mce != null && mce.Method.IsInstantiationOf(MixinDeclarations.miMixin)) { mixin = mce.Method.GetGenericArguments()[0]; if (!MixinDeclarations.GetMixinDeclarations(typeof(T)).Contains(mixin)) { throw new ArgumentException("The mixin {0} used in lambda 'property' is not registered".FormatWith(mixin.TypeName())); } return(pi); } else { throw new ArgumentException("The lambda 'property' should be an expression accessing a property"); } }
public static void TreeEntitySave <T>(T t) where T : TreeEntity, new() { if (t.IsNew) { t.Route = CalculateRoute(t); if (MixinDeclarations.IsDeclared(typeof(T), typeof(DisabledMixin)) && t.ParentOrSibling != null) { t.Mixin <DisabledMixin>().IsDisabled = t.Parent() !.Mixin <DisabledMixin>().IsDisabled; } } TreeLogic.FixName(t); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, bool registerAll) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { MixinDeclarations.AssertDeclared(typeof(OperationLogEntity), typeof(DiffLogMixin)); OperationLogic.SurroundOperation += OperationLogic_SurroundOperation; if (registerAll) { RegisterShouldLog <Entity>((entity, oper) => true); } } }
public static void Register <T>(IsolationStrategy strategy) where T : Entity { strategies.Add(typeof(T), strategy); if (strategy == IsolationStrategy.Isolated || strategy == IsolationStrategy.Optional) { MixinDeclarations.Register(typeof(T), typeof(IsolationMixin)); } if (strategy == IsolationStrategy.Optional) { Schema.Current.Settings.FieldAttributes((T e) => e.Mixin <IsolationMixin>().Isolation).Remove <NotNullableAttribute>(); //Remove non-null } }
public static void Start(SchemaBuilder sb, bool registerAll) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { MixinDeclarations.AssertDeclared(typeof(OperationLogEntity), typeof(DiffLogMixin)); PermissionAuthLogic.RegisterTypes(typeof(TimeMachinePermission)); OperationLogic.SurroundOperation += OperationLogic_SurroundOperation; if (registerAll) { RegisterShouldLog <Entity>((entity, oper) => true); } } }
private Dictionary <Type, FieldMixin> GenerateMixins(PropertyRoute propertyRoute, Table table, NameSequence nameSequence) { Dictionary <Type, FieldMixin> mixins = null; foreach (var t in MixinDeclarations.GetMixinDeclarations(table.Type)) { if (mixins == null) { mixins = new Dictionary <Type, FieldMixin>(); } mixins.Add(t, this.GenerateFieldMixin(propertyRoute.Add(t), nameSequence, table)); } return(mixins); }
static List <TreeInfo> FindNodesGeneric <T>(FindNodesRequest request) where T : TreeEntity { var qd = QueryLogic.Queries.QueryDescription(typeof(T)); var userFilters = request.userFilters.Select(f => f.ToFilter(qd, false)).ToList(); var frozenFilters = request.frozenFilters.Select(f => f.ToFilter(qd, false)).ToList(); var frozenQuery = QueryLogic.Queries.GetEntities(new QueryEntitiesRequest { QueryName = typeof(T), Filters = frozenFilters, Orders = new List <Order>() }) .Select(a => (T)a.Entity); var filteredQuery = QueryLogic.Queries.GetEntities(new QueryEntitiesRequest { QueryName = typeof(T), Filters = userFilters.Concat(frozenFilters).ToList(), Orders = new List <Order>() }) .Select(a => (T)a.Entity); var disabledMixin = MixinDeclarations.IsDeclared(typeof(T), typeof(DisabledMixin)); var list = filteredQuery .SelectMany(t => t.Ascendants()) .Select(t => new TreeInfo { route = t.Route, name = t.Name, lite = t.ToLite(), level = t.Level(), disabled = disabledMixin && t.Mixin <DisabledMixin>().IsDisabled, childrenCount = frozenQuery.Count(a => (bool)(a.Route.GetAncestor(1) == t.Route)), }).ToList(); var expandedChildren = request.expandedNodes.IsNullOrEmpty() ? new List <TreeInfo>() : frozenQuery .Where(t => request.expandedNodes.Contains(t.Parent().ToLite())) .SelectMany(t => t.Ascendants()) .Select(t => new TreeInfo { route = t.Route, name = t.Name, lite = t.ToLite(), level = t.Level(), disabled = disabledMixin && t.Mixin <DisabledMixin>().IsDisabled, childrenCount = frozenQuery.Count(a => (bool)(a.Route.GetAncestor(1) == t.Route)), }).ToList(); return(list.Concat(expandedChildren).ToList()); }
static IDisposable Constructor_PreConstructors(ConstructorContext ctx) { if (MixinDeclarations.IsDeclared(ctx.Type, typeof(IsolationMixin))) { Lite <IsolationEntity> isolation = GetIsolation(ctx, IsValid.TryGetC(ctx.Type)); if (isolation == null) { ctx.CancelConstruction = true; return(null); } ctx.Args.Add(isolation); return(IsolationEntity.Override(isolation)); } return(null); }
public EntityMapping(bool fillProperties) { if (fillProperties) { properties.AddRange(Validator.GetPropertyValidators(typeof(T)).Values .Where(pv => !pv.PropertyInfo.IsReadOnly()) .Select(pv => NewProperty(pv, null))); if (typeof(Entity).IsAssignableFrom(typeof(T))) { foreach (var t in MixinDeclarations.GetMixinDeclarations(typeof(T))) { properties.AddRange(Validator.GetPropertyValidators(t).Values .Where(pv => !pv.PropertyInfo.IsReadOnly()) .Select(pv => NewProperty(pv, t))); } } } }
public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <IsolationEntity>() .WithSave(IsolationOperation.Save) .WithQuery(() => iso => new { Entity = iso, iso.Id, iso.Name }); Schema.Current.AttachToUniqueFilter += entity => { var type = entity.GetType(); var hasIsolationMixin = MixinDeclarations.IsDeclared(type, typeof(IsolationMixin)); return(hasIsolationMixin == false ? null : e => e.Mixin <IsolationMixin>().Isolation.Is(entity.Mixin <IsolationMixin>().Isolation)); }; sb.Schema.EntityEventsGlobal.PreSaving += EntityEventsGlobal_PreSaving; sb.Schema.SchemaCompleted += AssertIsolationStrategies; OperationLogic.SurroundOperation += OperationLogic_SurroundOperation; Isolations = sb.GlobalLazy(() => Database.RetrieveAllLite <IsolationEntity>(), new InvalidateWith(typeof(IsolationEntity))); ProcessLogic.ApplySession += ProcessLogic_ApplySession; Validator.OverridePropertyValidator((IsolationMixin m) => m.Isolation).StaticPropertyValidation += (mi, pi) => { if (strategies.GetOrThrow(mi.MainEntity.GetType()) == IsolationStrategy.Isolated && mi.Isolation == null) { return(ValidationMessage._0IsNotSet.NiceToString(pi.NiceName())); } return(null); }; IsStarted = true; } }
internal DisconnectedStrategy(Download download, Expression <Func <T, bool> > downloadSubset, Upload upload, Expression <Func <T, bool> > uploadSubset, BasicImporter <T> importer) { if (download == Download.Subset && downloadSubset == null) { throw new InvalidOperationException("In order to use Download.Subset, use an overload that takes a downloadSubset expression"); } this.Download = download; this.DownloadSubset = downloadSubset; if (typeof(T) == typeof(DisconnectedExportEntity) && (download != Download.None || upload != Upload.None)) { throw new InvalidOperationException("{0} should have DownloadStrategy and UploadStratey = None".FormatWith(typeof(T).NiceName())); } if (upload != Upload.None) { MixinDeclarations.Register(typeof(T), typeof(DisconnectedCreatedMixin)); } if (upload == Upload.Subset) { if (uploadSubset == null) { throw new InvalidOperationException("In order to use Upload.Subset, use an overload that takes a uploadSubset expression"); } if (download == Download.None) { throw new InvalidOperationException("Upload.Subset is not compatible with Download.None, choose Upload.New instead"); } MixinDeclarations.Register(typeof(T), typeof(DisconnectedSubsetMixin)); } this.Upload = upload; this.UploadSubset = uploadSubset; this.Importer = importer; this.Exporter = download == Entities.Disconnected.Download.Replace ? new DeleteAndCopyExporter <T>() : new BasicExporter <T>(); }
MemberInfo GetMember(string fieldOrProperty) { if (fieldOrProperty.Contains(".")) { throw new ArgumentException($"{nameof(fieldOrProperty)} contains '.'"); } if (fieldOrProperty.StartsWith("[")) { var mixinName = ExtractMixin(fieldOrProperty); return(MixinDeclarations.GetMixinDeclarations(Type).FirstOrDefault(t => t.Name == mixinName) ?? throw new InvalidOperationException("{0}{1} does not exist".FormatWith(this, fieldOrProperty))); } else { var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; return((MemberInfo?)Type.GetProperty(fieldOrProperty, flags, null, null, IsCollection() ? new[] { typeof(int) } : new Type[0], null) ?? (MemberInfo?)Type.GetField(fieldOrProperty, flags) ?? throw new InvalidOperationException("{0}.{1} does not exist".FormatWith(this, fieldOrProperty))); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, Func <Pop3ConfigurationEntity, IPop3Client> getPop3Client) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { GetPop3Client = getPop3Client; MixinDeclarations.AssertDeclared(typeof(EmailMessageEntity), typeof(EmailReceptionMixin)); sb.Include <Pop3ConfigurationEntity>() .WithSave(Pop3ConfigurationOperation.Save) .WithQuery(dqm, () => s => new { Entity = s, s.Id, s.Host, s.Port, s.Username, s.EnableSSL }); sb.Include <Pop3ReceptionEntity>(); sb.Include <Pop3ReceptionExceptionEntity>(); sb.Include <EmailMessageEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.From, e.Subject, e.Template, e.State, e.Sent, SentDate = (DateTime?)e.Mixin <EmailReceptionMixin>().ReceptionInfo.SentDate, e.Package, e.Exception, }); dqm.RegisterQuery(typeof(Pop3ReceptionEntity), () => DynamicQueryCore.Auto( from s in Database.Query <Pop3ReceptionEntity>() select new { Entity = s, s.Id, s.Pop3Configuration, s.StartDate, s.EndDate, s.NewEmails, EmailMessages = s.EmailMessages().Count(), Exceptions = s.Exceptions().Count(), s.Exception, }) .ColumnDisplayName(a => a.EmailMessages, () => typeof(EmailMessageEntity).NicePluralName()) .ColumnDisplayName(a => a.Exceptions, () => typeof(ExceptionEntity).NicePluralName())); dqm.RegisterExpression((Pop3ConfigurationEntity c) => c.Receptions(), () => typeof(Pop3ReceptionEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.EmailMessages(), () => typeof(EmailMessageEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.Exceptions(), () => typeof(ExceptionEntity).NicePluralName()); dqm.RegisterExpression((ExceptionEntity r) => r.Pop3Reception(), () => typeof(Pop3ReceptionEntity).NiceName()); new Graph <Pop3ReceptionEntity> .ConstructFrom <Pop3ConfigurationEntity>(Pop3ConfigurationOperation.ReceiveEmails) { AllowsNew = true, Lite = false, Construct = (e, _) => { using (Transaction tr = Transaction.None()) { var result = e.ReceiveEmails(); return(tr.Commit(result)); } } } .Register(); SchedulerLogic.ExecuteTask.Register((Pop3ConfigurationEntity smtp, ScheduledTaskContext ctx) => smtp.ReceiveEmails().ToLite()); SimpleTaskLogic.Register(Pop3ConfigurationAction.ReceiveAllActivePop3Configurations, (ScheduledTaskContext ctx) => { if (!EmailLogic.Configuration.ReciveEmails) { throw new InvalidOperationException("EmailLogic.Configuration.ReciveEmails is set to false"); } foreach (var item in Database.Query <Pop3ConfigurationEntity>().Where(a => a.Active).ToList()) { item.ReceiveEmails(); } return(null); }); } }
public static void Start(string connectionString, bool isPostgres, string?azureStorageConnectionString, string?broadcastSecret, string?broadcastUrls, bool includeDynamic = true, bool detectSqlVersion = true) { AzureStorageConnectionString = azureStorageConnectionString; using (HeavyProfiler.Log("Start")) using (var initial = HeavyProfiler.Log("Initial")) { StartParameters.IgnoredDatabaseMismatches = new List <Exception>(); StartParameters.IgnoredCodeErrors = new List <Exception>(); string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log"); SchemaBuilder sb = new CustomSchemaBuilder { LogDatabaseName = logDatabase, Tracer = initial }; sb.Schema.Version = typeof(Starter).Assembly.GetName().Version !; sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US"); MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>(); MixinDeclarations.Register <UserEntity, UserEmployeeMixin>(); MixinDeclarations.Register <OrderDetailEmbedded, OrderDetailMixin>(); MixinDeclarations.Register <BigStringEmbedded, BigStringMixin>(); ConfigureBigString(sb); OverrideAttributes(sb); if (!isPostgres) { var sqlVersion = detectSqlVersion ? SqlServerVersionDetector.Detect(connectionString) : SqlServerVersion.AzureSQL; Connector.Default = new SqlServerConnector(connectionString, sb.Schema, sqlVersion !.Value); } else { var postgreeVersion = detectSqlVersion ? PostgresVersionDetector.Detect(connectionString) : null; Connector.Default = new PostgreSqlConnector(connectionString, sb.Schema, postgreeVersion); } CacheLogic.Start(sb, serverBroadcast: sb.Settings.IsPostgres ? new PostgresBroadcast() : broadcastSecret != null && broadcastUrls != null ? new SimpleHttpBroadcast(broadcastSecret, broadcastUrls) : null);/*Cache*/ /* LightDynamic * DynamicLogic.Start(sb, withCodeGen: false); * LightDynamic */ DynamicLogicStarter.Start(sb); if (includeDynamic)//Dynamic { DynamicLogic.CompileDynamicCode(); DynamicLogic.RegisterMixins(); DynamicLogic.BeforeSchema(sb); }//Dynamic // Framework modules TypeLogic.Start(sb); OperationLogic.Start(sb); ExceptionLogic.Start(sb); QueryLogic.Start(sb); // Extensions modules MigrationLogic.Start(sb); CultureInfoLogic.Start(sb); FilePathEmbeddedLogic.Start(sb); BigStringLogic.Start(sb); EmailLogic.Start(sb, () => Configuration.Value.Email, (template, target, message) => Configuration.Value.EmailSender); AuthLogic.Start(sb, "System", "Anonymous"); /* null); anonymous*/ AuthLogic.Authorizer = new SouthwindAuthorizer(() => Configuration.Value.ActiveDirectory); AuthLogic.StartAllModules(sb, activeDirectoryIntegration: true); AzureADLogic.Start(sb, adGroups: true, deactivateUsersTask: true); ResetPasswordRequestLogic.Start(sb); UserTicketLogic.Start(sb); SessionLogLogic.Start(sb); TypeConditionLogic.RegisterCompile <UserEntity>(SouthwindTypeCondition.UserEntities, u => u.Is(UserEntity.Current)); ProcessLogic.Start(sb); PackageLogic.Start(sb, packages: true, packageOperations: true); SchedulerLogic.Start(sb); OmniboxLogic.Start(sb); UserQueryLogic.Start(sb); UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities); UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities); UserQueryLogic.RegisterTranslatableRoutes(); ChartLogic.Start(sb, googleMapsChartScripts: false /*requires Google Maps API key in ChartClient */); UserChartLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities); UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities); UserChartLogic.RegisterTranslatableRoutes(); DashboardLogic.Start(sb, GetFileTypeAlgorithm(p => p.CachedQueryFolder)); DashboardLogic.RegisterUserTypeCondition(sb, SouthwindTypeCondition.UserEntities); DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindTypeCondition.RoleEntities); DashboardLogic.RegisterTranslatableRoutes(); ViewLogLogic.Start(sb, new HashSet <Type> { typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity) }); SystemEventLogLogic.Start(sb); DiffLogLogic.Start(sb, registerAll: true); ExcelLogic.Start(sb, excelReport: true); ToolbarLogic.Start(sb); ToolbarLogic.RegisterTranslatableRoutes(); SMSLogic.Start(sb, null, () => Configuration.Value.Sms); NoteLogic.Start(sb, typeof(UserEntity), /*Note*/ typeof(OrderEntity)); AlertLogic.Start(sb, typeof(UserEntity), /*Alert*/ typeof(OrderEntity)); FileLogic.Start(sb); TranslationLogic.Start(sb, countLocalizationHits: false); TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en")); HelpLogic.Start(sb); WordTemplateLogic.Start(sb); MapLogic.Start(sb); PredictorLogic.Start(sb, GetFileTypeAlgorithm(p => p.PredictorModelFolder)); PredictorLogic.RegisterAlgorithm(TensorFlowPredictorAlgorithm.NeuralNetworkGraph, new TensorFlowNeuralNetworkPredictor()); PredictorLogic.RegisterPublication(ProductPredictorPublication.MonthlySales, new PublicationSettings(typeof(OrderEntity))); RestLogLogic.Start(sb); RestApiKeyLogic.Start(sb); WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow); ProfilerLogic.Start(sb, timeTracker: true, heavyProfiler: true, overrideSessionTimeout: true); // Southwind modules EmployeeLogic.Start(sb); ProductLogic.Start(sb); CustomerLogic.Start(sb); OrderLogic.Start(sb); ShipperLogic.Start(sb); StartSouthwindConfiguration(sb); TypeConditionLogic.Register <OrderEntity>(SouthwindTypeCondition.CurrentEmployee, o => o.Employee.Is(EmployeeEntity.Current)); if (includeDynamic)//2 { DynamicLogic.StartDynamicModules(sb); }//2 SetupCache(sb); Schema.Current.OnSchemaCompleted(); if (includeDynamic)//3 { DynamicLogic.RegisterExceptionIfAny(); }//3 } }
public static void Start(string connectionString) { string logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log"); SchemaBuilder sb = new SchemaBuilder(); sb.Schema.Version = typeof(Starter).Assembly.GetName().Version; sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US"); MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>(); MixinDeclarations.Register <UserEntity, UserEmployeeMixin>(); OverrideAttributes(sb); SetupDisconnectedStrategies(sb); DynamicQueryManager dqm = new DynamicQueryManager(); Connector.Default = new SqlConnector(connectionString, sb.Schema, dqm, SqlServerVersion.SqlServer2012); CacheLogic.Start(sb); TypeLogic.Start(sb, dqm); OperationLogic.Start(sb, dqm); MigrationLogic.Start(sb, dqm); CultureInfoLogic.Start(sb, dqm); EmbeddedFilePathLogic.Start(sb, dqm); SmtpConfigurationLogic.Start(sb, dqm); EmailLogic.Start(sb, dqm, () => Configuration.Value.Email, et => Configuration.Value.SmtpConfiguration); AuthLogic.Start(sb, dqm, "System", null); AuthLogic.StartAllModules(sb, dqm); ResetPasswordRequestLogic.Start(sb, dqm); UserTicketLogic.Start(sb, dqm); SessionLogLogic.Start(sb, dqm); ProcessLogic.Start(sb, dqm); PackageLogic.Start(sb, dqm, packages: true, packageOperations: true); MapLogic.Start(sb, dqm); SchedulerLogic.Start(sb, dqm); QueryLogic.Start(sb); UserQueryLogic.Start(sb, dqm); UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); ChartLogic.Start(sb, dqm); UserChartLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); DashboardLogic.Start(sb, dqm); DashboardLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); ViewLogLogic.Start(sb, dqm, new HashSet <Type> { typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity) }); DiffLogLogic.Start(sb, dqm); ExceptionLogic.Start(sb, dqm); SMSLogic.Start(sb, dqm, null, () => Configuration.Value.Sms); SMSLogic.RegisterPhoneNumberProvider <PersonEntity>(p => p.Phone, p => null); SMSLogic.RegisterDataObjectProvider((PersonEntity p) => new { p.FirstName, p.LastName, p.Title, p.DateOfBirth }); SMSLogic.RegisterPhoneNumberProvider <CompanyEntity>(p => p.Phone, p => null); NoteLogic.Start(sb, dqm, typeof(UserEntity), /*Note*/ typeof(OrderEntity)); AlertLogic.Start(sb, dqm, typeof(UserEntity), /*Alert*/ typeof(OrderEntity)); FileLogic.Start(sb, dqm); TranslationLogic.Start(sb, dqm); TranslatedInstanceLogic.Start(sb, dqm, () => CultureInfo.GetCultureInfo("en")); HelpLogic.Start(sb, dqm); WordTemplateLogic.Start(sb, dqm); EmployeeLogic.Start(sb, dqm); ProductLogic.Start(sb, dqm); CustomerLogic.Start(sb, dqm); OrderLogic.Start(sb, dqm); ShipperLogic.Start(sb, dqm); StartSouthwindConfiguration(sb, dqm); TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.UserEntities, o => o.Employee.RefersTo(EmployeeEntity.Current)); TypeConditionLogic.Register <EmployeeEntity>(SouthwindGroup.UserEntities, e => e == EmployeeEntity.Current); TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.CurrentCustomer, o => o.Customer == CustomerEntity.Current); TypeConditionLogic.Register <PersonEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current); TypeConditionLogic.Register <CompanyEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current); DisconnectedLogic.Start(sb, dqm); DisconnectedLogic.BackupFolder = @"D:\SouthwindTemp\Backups"; DisconnectedLogic.BackupNetworkFolder = @"D:\SouthwindTemp\Backups"; DisconnectedLogic.DatabaseFolder = @"D:\SouthwindTemp\Database"; ProfilerLogic.Start(sb, dqm, timeTracker: true, heavyProfiler: true, overrideSessionTimeout: true); SetupCache(sb); SetSchemaNames(Schema.Current); if (logDatabase.HasText()) { SetLogDatabase(sb.Schema, new DatabaseName(null, logDatabase)); } Schema.Current.OnSchemaCompleted(); }
public static void Start(string connectionString) { using (HeavyProfiler.Log("Start")) using (var initial = HeavyProfiler.Log("Initial")) { StartParameters.IgnoredDatabaseMismatches = new List <Exception>(); StartParameters.IgnoredCodeErrors = new List <Exception>(); string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log"); SchemaBuilder sb = new CustomSchemaBuilder { LogDatabaseName = logDatabase, Tracer = initial }; sb.Schema.Version = typeof(Starter).Assembly.GetName().Version; sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US"); MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>(); MixinDeclarations.Register <UserEntity, UserEmployeeMixin>(); OverrideAttributes(sb); var detector = SqlServerVersionDetector.Detect(connectionString); Connector.Default = new SqlConnector(connectionString, sb.Schema, detector !.Value); CacheLogic.Start(sb); DynamicLogicStarter.Start(sb); DynamicLogic.CompileDynamicCode(); DynamicLogic.RegisterMixins(); DynamicLogic.BeforeSchema(sb); TypeLogic.Start(sb); OperationLogic.Start(sb); ExceptionLogic.Start(sb); MigrationLogic.Start(sb); CultureInfoLogic.Start(sb); FilePathEmbeddedLogic.Start(sb); SmtpConfigurationLogic.Start(sb); EmailLogic.Start(sb, () => Configuration.Value.Email, (et, target) => Configuration.Value.SmtpConfiguration); AuthLogic.Start(sb, "System", null); AuthLogic.StartAllModules(sb); ResetPasswordRequestLogic.Start(sb); UserTicketLogic.Start(sb); SessionLogLogic.Start(sb); ProcessLogic.Start(sb); PackageLogic.Start(sb, packages: true, packageOperations: true); SchedulerLogic.Start(sb); QueryLogic.Start(sb); UserQueryLogic.Start(sb); UserQueryLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); UserQueryLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); ChartLogic.Start(sb); UserChartLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); UserChartLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); DashboardLogic.Start(sb); DashboardLogic.RegisterUserTypeCondition(sb, SouthwindGroup.UserEntities); DashboardLogic.RegisterRoleTypeCondition(sb, SouthwindGroup.RoleEntities); ViewLogLogic.Start(sb, new HashSet <Type> { typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity) }); DiffLogLogic.Start(sb, registerAll: true); ExcelLogic.Start(sb, excelReport: true); ToolbarLogic.Start(sb); SMSLogic.Start(sb, null, () => Configuration.Value.Sms); SMSLogic.RegisterPhoneNumberProvider <PersonEntity>(p => p.Phone, p => null); SMSLogic.RegisterDataObjectProvider((PersonEntity p) => new { p.FirstName, p.LastName, p.Title, p.DateOfBirth }); SMSLogic.RegisterPhoneNumberProvider <CompanyEntity>(p => p.Phone, p => null); NoteLogic.Start(sb, typeof(UserEntity), /*Note*/ typeof(OrderEntity)); AlertLogic.Start(sb, typeof(UserEntity), /*Alert*/ typeof(OrderEntity)); FileLogic.Start(sb); TranslationLogic.Start(sb, countLocalizationHits: false); TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en")); HelpLogic.Start(sb); WordTemplateLogic.Start(sb); MapLogic.Start(sb); PredictorLogic.Start(sb, () => new FileTypeAlgorithm(f => new PrefixPair(Starter.Configuration.Value.Folders.PredictorModelFolder))); PredictorLogic.RegisterAlgorithm(CNTKPredictorAlgorithm.NeuralNetwork, new CNTKNeuralNetworkPredictorAlgorithm()); PredictorLogic.RegisterPublication(ProductPredictorPublication.MonthlySales, new PublicationSettings(typeof(OrderEntity))); RestLogLogic.Start(sb); RestApiKeyLogic.Start(sb); WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow); EmployeeLogic.Start(sb); ProductLogic.Start(sb); CustomerLogic.Start(sb); OrderLogic.Start(sb); ShipperLogic.Start(sb); StartSouthwindConfiguration(sb); TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.UserEntities, o => o.Employee == EmployeeEntity.Current); TypeConditionLogic.Register <EmployeeEntity>(SouthwindGroup.UserEntities, e => EmployeeEntity.Current.Is(e)); TypeConditionLogic.Register <OrderEntity>(SouthwindGroup.CurrentCustomer, o => o.Customer == CustomerEntity.Current); TypeConditionLogic.Register <PersonEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current); TypeConditionLogic.Register <CompanyEntity>(SouthwindGroup.CurrentCustomer, o => o == CustomerEntity.Current); ProfilerLogic.Start(sb, timeTracker: true, heavyProfiler: true, overrideSessionTimeout: true); DynamicLogic.StartDynamicModules(sb); DynamicLogic.RegisterExceptionIfAny(); SetupCache(sb); Schema.Current.OnSchemaCompleted(); } }
public static void Start(string connectionString, bool isPostgres, bool includeDynamic = true, bool detectSqlVersion = true) { using (HeavyProfiler.Log("Start")) using (var initial = HeavyProfiler.Log("Initial")) { StartParameters.IgnoredDatabaseMismatches = new List <Exception>(); StartParameters.IgnoredCodeErrors = new List <Exception>(); string?logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log"); SchemaBuilder sb = new CustomSchemaBuilder { LogDatabaseName = logDatabase, Tracer = initial }; sb.Schema.Version = typeof(Starter).Assembly.GetName().Version !; sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US"); MixinDeclarations.Register <OperationLogEntity, DiffLogMixin>(); MixinDeclarations.Register <UserEntity, UserEmployeeMixin>(); MixinDeclarations.Register <OrderDetailEmbedded, OrderDetailMixin>(); MixinDeclarations.Register <BigStringEmbedded, BigStringMixin>(); ConfigureBigString(sb); OverrideAttributes(sb); if (!isPostgres) { var sqlVersion = detectSqlVersion ? SqlServerVersionDetector.Detect(connectionString) : SqlServerVersion.AzureSQL; Connector.Default = new SqlServerConnector(connectionString, sb.Schema, sqlVersion !.Value); } else { var postgreeVersion = detectSqlVersion ? PostgresVersionDetector.Detect(connectionString) : null; Connector.Default = new PostgreSqlConnector(connectionString, sb.Schema, postgreeVersion); } CacheLogic.Start(sb, cacheInvalidator: sb.Settings.IsPostgres ? new PostgresCacheInvalidation() : null); DynamicLogicStarter.Start(sb); if (includeDynamic)//Dynamic { DynamicLogic.CompileDynamicCode(); DynamicLogic.RegisterMixins(); DynamicLogic.BeforeSchema(sb); }//Dynamic // Framework modules TypeLogic.Start(sb); OperationLogic.Start(sb); ExceptionLogic.Start(sb); QueryLogic.Start(sb); // Extensions modules MigrationLogic.Start(sb); CultureInfoLogic.Start(sb); FilePathEmbeddedLogic.Start(sb); BigStringLogic.Start(sb); EmailLogic.Start(sb, () => Configuration.Value.Email, (template, target, message) => Configuration.Value.EmailSender); AuthLogic.Start(sb, "System", "Anonymous"); /* null); anonymous*/ AuthLogic.StartAllModules(sb); ResetPasswordRequestLogic.Start(sb); UserTicketLogic.Start(sb); SessionLogLogic.Start(sb); WebAuthnLogic.Start(sb, () => Configuration.Value.WebAuthn); ProcessLogic.Start(sb); PackageLogic.Start(sb, packages: true, packageOperations: true); SchedulerLogic.Start(sb); OmniboxLogic.Start(sb); UserQueryLogic.Start(sb); UserQueryLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities); UserQueryLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities); UserQueryLogic.RegisterTranslatableRoutes(); ChartLogic.Start(sb, googleMapsChartScripts: false /*requires Google Maps API key in ChartClient */); UserChartLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities); UserChartLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities); UserChartLogic.RegisterTranslatableRoutes(); DashboardLogic.Start(sb); DashboardLogic.RegisterUserTypeCondition(sb, RG2Group.UserEntities); DashboardLogic.RegisterRoleTypeCondition(sb, RG2Group.RoleEntities); DashboardLogic.RegisterTranslatableRoutes(); ViewLogLogic.Start(sb, new HashSet <Type> { typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity) }); DiffLogLogic.Start(sb, registerAll: true); ExcelLogic.Start(sb, excelReport: true); ToolbarLogic.Start(sb); ToolbarLogic.RegisterTranslatableRoutes(); FileLogic.Start(sb); TranslationLogic.Start(sb, countLocalizationHits: false); TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en")); HelpLogic.Start(sb); WordTemplateLogic.Start(sb); MapLogic.Start(sb); RestLogLogic.Start(sb); RestApiKeyLogic.Start(sb); WorkflowLogicStarter.Start(sb, () => Starter.Configuration.Value.Workflow); ProfilerLogic.Start(sb, timeTracker: true, heavyProfiler: true, overrideSessionTimeout: true); // RG2 modules EmployeeLogic.Start(sb); ProductLogic.Start(sb); CustomerLogic.Start(sb); OrderLogic.Start(sb); ShipperLogic.Start(sb); ItemLogic.Start(sb); ItemCategoryLogic.Start(sb); StartRG2Configuration(sb); TypeConditionLogic.Register <OrderEntity>(RG2Group.UserEntities, o => o.Employee == EmployeeEntity.Current); TypeConditionLogic.Register <EmployeeEntity>(RG2Group.UserEntities, e => EmployeeEntity.Current.Is(e)); TypeConditionLogic.Register <OrderEntity>(RG2Group.CurrentCustomer, o => o.Customer == CustomerEntity.Current); TypeConditionLogic.Register <PersonEntity>(RG2Group.CurrentCustomer, o => o == CustomerEntity.Current); TypeConditionLogic.Register <CompanyEntity>(RG2Group.CurrentCustomer, o => o == CustomerEntity.Current); if (includeDynamic)//2 { DynamicLogic.StartDynamicModules(sb); }//2 SetupCache(sb); Schema.Current.OnSchemaCompleted(); if (includeDynamic)//3 { DynamicLogic.RegisterExceptionIfAny(); }//3 } }
public static void Start(string connectionString, bool includeDynamic = true) { using (HeavyProfiler.Log("Start")) using (var initial = HeavyProfiler.Log("Initial")) { string? logDatabase = Connector.TryExtractDatabaseNameWithPostfix(ref connectionString, "_Log"); SchemaBuilder sb = new CustomSchemaBuilder { LogDatabaseName = logDatabase, Tracer = initial }; sb.Schema.Version = typeof(Starter).Assembly.GetName().Version!; sb.Schema.ForceCultureInfo = CultureInfo.GetCultureInfo("en-US"); MixinDeclarations.Register<OperationLogEntity, DiffLogMixin>(); MixinDeclarations.Register<UserEntity, UserEmployeeMixin>(); OverrideAttributes(sb); var detector = SqlServerVersionDetector.Detect(connectionString); Connector.Default = new SqlConnector(connectionString, sb.Schema, detector!.Value); CacheLogic.Start(sb); } TypeLogic.Start(sb); OperationLogic.Start(sb); ExceptionLogic.Start(sb); MigrationLogic.Start(sb); CultureInfoLogic.Start(sb); FilePathEmbeddedLogic.Start(sb); EmailLogic.Start(sb, () => Configuration.Value.Email, (et, target) => Configuration.Value.EmailSender); AuthLogic.Start(sb, "System", null); AuthLogic.StartAllModules(sb); ResetPasswordRequestLogic.Start(sb); UserTicketLogic.Start(sb); ProcessLogic.Start(sb); PackageLogic.Start(sb, packages: true, packageOperations: true); SchedulerLogic.Start(sb); QueryLogic.Start(sb); UserQueryLogic.Start(sb); UserQueryLogic.RegisterUserTypeCondition(sb, AtTestGroup.UserEntities); UserQueryLogic.RegisterRoleTypeCondition(sb, AtTestGroup.RoleEntities); ChartLogic.Start(sb); UserChartLogic.RegisterUserTypeCondition(sb, AtTestGroup.UserEntities); UserChartLogic.RegisterRoleTypeCondition(sb, AtTestGroup.RoleEntities); DashboardLogic.Start(sb); DashboardLogic.RegisterUserTypeCondition(sb, AtTestGroup.UserEntities); DashboardLogic.RegisterRoleTypeCondition(sb, AtTestGroup.RoleEntities); ViewLogLogic.Start(sb, new HashSet<Type> { typeof(UserQueryEntity), typeof(UserChartEntity), typeof(DashboardEntity) }); DiffLogLogic.Start(sb, registerAll: true); ExcelLogic.Start(sb, excelReport: true); ToolbarLogic.Start(sb); FileLogic.Start(sb); TranslationLogic.Start(sb, countLocalizationHits: false); TranslatedInstanceLogic.Start(sb, () => CultureInfo.GetCultureInfo("en")); WordTemplateLogic.Start(sb); MapLogic.Start(sb); PredictorLogic.Start(sb, () => new FileTypeAlgorithm(f => new PrefixPair(Starter.Configuration.Value.Folders.PredictorModelFolder))); PredictorLogic.RegisterAlgorithm(CNTKPredictorAlgorithm.NeuralNetwork, new CNTKNeuralNetworkPredictorAlgorithm()); PredictorLogic.RegisterPublication(ProductPredictorPublication.MonthlySales, new PublicationSettings(typeof(OrderEntity))); EmployeeLogic.Start(sb); ProductLogic.Start(sb); CustomerLogic.Start(sb); OrderLogic.Start(sb); ShipperLogic.Start(sb); StartAtTestConfiguration(sb); TypeConditionLogic.Register<OrderEntity>(AtTestGroup.UserEntities, o => o.Employee == EmployeeEntity.Current); TypeConditionLogic.Register<EmployeeEntity>(AtTestGroup.UserEntities, e => EmployeeEntity.Current.Is(e)); TypeConditionLogic.Register<OrderEntity>(AtTestGroup.CurrentCustomer, o => o.Customer == CustomerEntity.Current); TypeConditionLogic.Register<PersonEntity>(AtTestGroup.CurrentCustomer, o => o == CustomerEntity.Current); TypeConditionLogic.Register<CompanyEntity>(AtTestGroup.CurrentCustomer, o => o == CustomerEntity.Current); ProfilerLogic.Start(sb, timeTracker: true, heavyProfiler: true, overrideSessionTimeout: true); if (includeDynamic) { } SetupCache(sb); Schema.Current.OnSchemaCompleted(); }
public static void RegisterOperations <T>(Func <T, MoveTreeModel, T>?copy) where T : TreeEntity, new() { Graph <T> .Construct.Untyped(TreeOperation.CreateRoot).Do(c => { c.Construct = (_) => new T { ParentOrSibling = null, Level = 1, IsSibling = false }; c.Register(); }); Graph <T> .ConstructFrom <T> .Untyped(TreeOperation.CreateChild).Do(c => { c.Construct = (t, _) => new T { ParentOrSibling = t.ToLite(), Level = (short)(t.Level !+1), IsSibling = false // }; c.Register(); }); Graph <T> .ConstructFrom <T> .Untyped(TreeOperation.CreateNextSibling).Do(c => { c.Construct = (t, _) => new T { ParentOrSibling = t.ToLite(), Level = t.Level, IsSibling = true // }; c.Register(); }); new Graph <T> .Execute(TreeOperation.Save) { CanBeNew = true, CanBeModified = true, Execute = (t, _) => { TreeEntitySave(t); } } .Register(); new Graph <T> .Execute(TreeOperation.Move) { Execute = (t, args) => { var model = args.GetArg <MoveTreeModel>(); TreeEntityMove(t, model); } } .Register(); if (copy != null) { Graph <T> .ConstructFrom <T> .Untyped(TreeOperation.Copy).Do(c => { c.Construct = (t, args) => { var model = args.GetArg <MoveTreeModel>(); var newRoute = GetNewPosition <T>(model, t); var descendants = t.Descendants().OrderBy(a => a.Route).ToList(); var hasDisabledMixin = MixinDeclarations.IsDeclared(typeof(T), typeof(DisabledMixin)); var isParentDisabled = hasDisabledMixin && model.NewParent != null && model.NewParent.InDB(e => e.Mixin <DisabledMixin>().IsDisabled); var list = descendants.Select(oldNode => { var newNode = copy !(oldNode, model); if (hasDisabledMixin) { newNode.Mixin <DisabledMixin>().IsDisabled = oldNode.Mixin <DisabledMixin>().IsDisabled || isParentDisabled; } newNode.ParentOrSibling = model.NewParent; newNode.Route = oldNode.Route.GetReparentedValue(t.Route, newRoute); newNode.SetFullName(newNode.Name); return(newNode); }).ToList(); list.SaveList(); foreach (T h in list) { CalculateFullName(h); h.Save(); } return(list.First()); }; }).Register(); } new Graph <T> .Delete(TreeOperation.Delete) { Delete = (f, args) => { TreeLogic.RemoveDescendants(f); } } .Register(); }
internal ModifiableEntity() { mixin = MixinDeclarations.CreateMixins(this); }