private void LoadSolution(string directory, string file, bool isGlobal) { var sluFile = Path.Combine(directory, file); using (WorkModelScope.CreateScope(WorkModel.Loding)) { try { _solution = DeSerializer <SolutionConfig>(sluFile) ?? new SolutionConfig { Name = "GlobalConfig", Caption = "全局配置", Description = "全局配置" }; } catch (Exception exception) { Trace.WriteLine(exception); _solution = new SolutionConfig(); } SolutionConfig.SetCurrentSolution(_solution); _solution.IsGlobal = isGlobal; _solution.SaveFileName = sluFile; try { LoadProjects(directory); } catch (Exception ex) { Trace.WriteLine(ex); } GlobalTrigger.OnLoad(_solution); } }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { using (LoadingModeScope.CreateScope()) { SolutionModel model = new SolutionModel { Solution = TargetConfig }; model.RepairByLoaded(); model.ResetStatus(); model.OnSolutionLoad(); TargetConfig.Projects.CollectionChanged += ConfigCollectionChanged; TargetConfig.Enums.CollectionChanged += ConfigCollectionChanged; TargetConfig.ApiItems.CollectionChanged += ConfigCollectionChanged; TargetConfig.NotifyItems.CollectionChanged += ConfigCollectionChanged; TargetConfig.Entities.CollectionChanged += EntitiesCollectionChanged; foreach (var cfg in TargetConfig.Enums) { GlobalTrigger.OnLoad(cfg); } foreach (var cfg in TargetConfig.ApiItems) { GlobalTrigger.OnLoad(cfg); } foreach (var cfg in TargetConfig.NotifyItems) { GlobalTrigger.OnLoad(cfg); } } }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { base.OnLoad(); using (WorkModelScope.CreateScope(WorkModel.Repair)) { foreach (var cfg in TargetConfig.Classifies) { GlobalTrigger.OnLoad(cfg); } TargetConfig.Option.IsReference = TargetConfig.Entities.Count > 0 && TargetConfig.Entities.All(p => p.IsReference); foreach (var entity in TargetConfig.Entities) { entity.Project = TargetConfig.Name; entity.Parent = TargetConfig; GlobalTrigger.OnLoad(entity); } foreach (var entity in TargetConfig.ApiItems) { entity.Project = TargetConfig.Name; entity.Parent = TargetConfig; GlobalTrigger.OnLoad(entity); } foreach (var entity in TargetConfig.Enums) { entity.Project = TargetConfig.Name; entity.Parent = TargetConfig; GlobalTrigger.OnLoad(entity); } TargetConfig.Entities.CollectionChanged += OnEntityCollectionChanged; TargetConfig.Enums.CollectionChanged += OnEnumCollectionChanged; TargetConfig.ApiItems.CollectionChanged += OnApiCollectionChanged; } }
private static void OnPropertiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (NotificationObject.IsLoadingMode || _inPropertiesCollectionChanged) { return; } var entity = sender as EntityConfig; if (entity == null) { return; } try { _inPropertiesCollectionChanged = true; if (!entity.IsModify) { entity.IsModify = true; } switch (e.Action) { case NotifyCollectionChangedAction.Reset: entity.LastProperties.Clear(); entity.LastProperties.AddRange(entity.Properties.Where(p => !p.Discard)); foreach (var property in entity.LastProperties) { property.StatusChanged += OnFieldStatusChanged; GlobalTrigger.OnLoad(property); } return; } if (e.NewItems != null && e.NewItems.Count > 0) { foreach (PropertyConfig property in e.NewItems) { property.Identity = ++entity.MaxIdentity; property.Index = entity.Properties.Max(p => p.Index) + 1; entity.LastProperties.Add(property); property.StatusChanged += OnFieldStatusChanged; GlobalTrigger.OnAdded(entity, property); } } if (e.OldItems != null && e.OldItems.Count > 0) { foreach (PropertyConfig property in e.OldItems) { entity.LastProperties.Remove(property); property.StatusChanged -= OnFieldStatusChanged; GlobalTrigger.OnRemoved(entity, property); } } } finally { _inPropertiesCollectionChanged = false; } }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { if (TargetConfig.MyChilds == null) { return; } foreach (var child in TargetConfig.MyChilds) { GlobalTrigger.OnLoad(child); } }
private void OnEntityCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (WorkContext.IsNoChangedNotify || _inEntityCollectionChanged) { return; } if (!(sender is ProjectConfig project)) { return; } try { _inEntityCollectionChanged = true; if (!project.IsModify) { project.IsModify = true; } switch (e.Action) { case NotifyCollectionChangedAction.Reset: foreach (var entity in project.Entities) { GlobalTrigger.OnLoad(entity); } return; } if (e.NewItems != null && e.NewItems.Count > 0) { foreach (EntityConfig entity in e.NewItems) { GlobalTrigger.OnLoad(entity); } } if (e.OldItems != null && e.OldItems.Count > 0) { foreach (EntityConfig entity in e.OldItems) { GlobalTrigger.OnRemoved(project, entity); } } } finally { _inEntityCollectionChanged = false; } }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { using (LoadingModeScope.CreateScope()) { foreach (var cfg in TargetConfig.Classifies) { GlobalTrigger.OnLoad(cfg); } TargetConfig.IsReference = TargetConfig.Entities.All(p => p.IsReference); foreach (var entity in TargetConfig.Entities) { entity.Project = TargetConfig.Name; entity.Parent = TargetConfig; foreach (var field in entity.Properties) { field.Parent = entity; } } } }
private void LoadSolution(string directory, string file, bool isGlobal) { var sluFile = Path.Combine(directory, file); using (LoadingModeScope.CreateScope()) { try { _solution = DeSerializer <SolutionConfig>(sluFile) ?? new SolutionConfig { Name = "GlobalConfig", Caption = "全局配置", Description = "全局配置" }; } catch (Exception exception) { Debug.WriteLine(exception); _solution = new SolutionConfig(); } _solution.IsGlobal = isGlobal; _solution.FileName = sluFile; try { LoadProjects(directory); LoadTypedefs(directory); LoadEnums(directory); LoadApi(directory); LoadNotify(directory); } catch (Exception ex) { Trace.WriteLine(ex); } GlobalTrigger.OnLoad(_solution); } }
/// <summary> /// 设置当前解决方案 /// </summary> /// <param name="solution"></param> public static void SetCurrentSolution(SolutionConfig solution) { SolutionConfig.SetCurrentSolution(solution); GlobalTrigger.Reset(); GlobalTrigger.OnLoad(solution); }
/// <summary> /// 设置当前解决方案 /// </summary> /// <param name="solution"></param> public static void OnSolutionLoad(SolutionConfig solution) { GlobalTrigger.OnLoad(solution); }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { GlobalTrigger.OnLoad(TargetConfig.Option); }