private void EntitiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { foreach (var item in TargetConfig.Entities) { item.Parent.Remove(item); GlobalTrigger.OnRemoved(TargetConfig, item); } foreach (var item in TargetConfig.Entities) { GlobalTrigger.OnAdded(TargetConfig, item); } return; } if (e.NewItems != null) { foreach (EntityConfig item in e.NewItems) { GlobalTrigger.OnAdded(TargetConfig, item); } } if (e.OldItems == null) { return; } foreach (EntityConfig item in e.OldItems) { item.Parent.Remove(item); GlobalTrigger.OnRemoved(TargetConfig, item); } }
/// <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 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); } } }
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> private void AutoRegist() { GlobalTrigger.RegistTrigger <CodeGeneratorTrigger>(); foreach (var reg in Registers) { reg.AutoRegist(); } }
/// <summary> /// 载入事件处理 /// </summary> protected override void OnLoad() { if (TargetConfig.MyChilds == null) { return; } foreach (var child in TargetConfig.MyChilds) { GlobalTrigger.OnLoad(child); } }
/// <summary> /// 注册代码 /// </summary> void IAutoRegister.AutoRegist() { GlobalTrigger.RegistTrigger <ConfigTrigger>(); GlobalTrigger.RegistTrigger <OptionTrigger>(); GlobalTrigger.RegistTrigger <PropertyTrigger>(); GlobalTrigger.RegistTrigger <EntityTrigger>(); GlobalTrigger.RegistTrigger <EntityChildTrigger>(); GlobalTrigger.RegistTrigger <ProjectTrigger>(); GlobalTrigger.RegistTrigger <ProjectChildTrigger>(); GlobalTrigger.RegistTrigger <SolutionTrigger>(); }
/// <summary> /// 新增实体的方法(UI后期实现) /// </summary> private static EntityConfig AddFieldsCommand() { var window = new NewEntityWindow(); var vm = (NewEntityViewModel)window.DataContext; if (window.ShowDialog() != true) { return(null); } GlobalTrigger.OnCreate(vm.Model.Entity); return(vm.Model.Entity); }
/// <summary> /// 生成新配置 /// </summary> /// <returns></returns> public static bool NewConfigCommand(ConfigBase config) { var window = new NewConfigWindow(); var vm = (NewConfigViewModel)window.DataContext; vm.Config = config; if (window.ShowDialog() != true) { return(false); } GlobalTrigger.OnCreate(vm.Config); return(true); }
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> /// 枚举编辑的方法(UI后期实现) /// </summary> /// <param name="property"></param> /// <returns></returns> private static EnumConfig EditEnumCommand(PropertyConfig property) { var window = new EnumEdit(); var vm = (EnumEditViewModel)window.DataContext; vm.Model.Config = property.EnumConfig ?? new EnumConfig { LinkField = property.Key, Name = property.Name + "Type", Caption = property.Caption + "枚举类型", Description = property.Description }; if (window.ShowDialog() != true) { return(null); } GlobalTrigger.OnCreate(vm.Model.Config); return(vm.Model.Config); }
/// <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 ConfigCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { OnLoad(TargetConfig); return; } if (e.NewItems != null) { foreach (ConfigBase item in e.NewItems) { GlobalTrigger.OnAdded(TargetConfig, item); } } if (e.OldItems == null) { return; } foreach (ConfigBase item in e.OldItems) { GlobalTrigger.OnRemoved(TargetConfig, item); } }
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> void IAutoRegister.AutoRegist() { var name = GetType().Assembly.FullName.Split(',')[0]; //var file = Path.GetFileNameWithoutExtension(); var uri = new Uri($"/{name};component/DataTemplate/ConfigDataTemplate.xaml", UriKind.Relative); StreamResourceInfo info = Application.GetResourceStream(uri); // ReSharper disable PossibleNullReferenceException if (info != null) { var asm = XamlReader.Load(new Baml2006Reader(info.Stream)) as ResourceDictionary; DataTemplateResource.RegistResource(asm); } GlobalTrigger.RegistTrigger <ConfigTrigger>(); GlobalTrigger.RegistTrigger <ParentConfigTrigger>(); GlobalTrigger.RegistTrigger <PropertyTrigger>(); GlobalTrigger.RegistTrigger <EntityTrigger>(); GlobalTrigger.RegistTrigger <ProjectTrigger>(); GlobalTrigger.RegistTrigger <SolutionTrigger>(); CommandIoc.NewConfigCommand = NewConfigCommand; }
/// <summary> /// 设置当前解决方案 /// </summary> /// <param name="solution"></param> public static void OnSolutionLoad(SolutionConfig solution) { 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> protected override void OnLoad() { GlobalTrigger.OnLoad(TargetConfig.Option); }
/// <summary> /// 构造 /// </summary> protected ConfigBase() { GlobalTrigger.OnCtor(this); Option.Config = this; }
public void BuildActionTrigger(ref ActorPreloadTab loadInfo) { AreaEventTrigger[] triggerArray = UnityEngine.Object.FindObjectsOfType <AreaEventTrigger>(); if ((triggerArray != null) && (triggerArray.Length > 0)) { for (int i = 0; i < triggerArray.Length; i++) { AreaEventTrigger trigger = triggerArray[i]; for (int j = 0; j < trigger.TriggerActions.Length; j++) { TriggerActionWrapper triggerActionWrapper = trigger.TriggerActions[j]; if ((triggerActionWrapper != null) && (triggerActionWrapper.TimingActionsInter != null)) { for (int k = 0; k < triggerActionWrapper.TimingActionsInter.Length; k++) { if (!string.IsNullOrEmpty(triggerActionWrapper.TimingActionsInter[k].ActionName) && !this.ageCheckerSet.ContainsKey(triggerActionWrapper.TimingActionsInter[k].ActionName)) { AssetLoadBase item = new AssetLoadBase { assetPath = triggerActionWrapper.TimingActionsInter[k].ActionName }; loadInfo.ageActions.Add(item); this.ageCheckerSet.Add(triggerActionWrapper.TimingActionsInter[k].ActionName, true); } } } if ((triggerActionWrapper != null) && (triggerActionWrapper.TriggerType == EGlobalTriggerAct.TriggerShenFu)) { Singleton <ShenFuSystem> .instance.PreLoadResource(triggerActionWrapper, ref loadInfo, this); } } if ((trigger.PresetActWrapper != null) && (trigger.PresetActWrapper.TimingActionsInter != null)) { for (int m = 0; m < trigger.PresetActWrapper.TimingActionsInter.Length; m++) { if (!string.IsNullOrEmpty(trigger.PresetActWrapper.TimingActionsInter[m].ActionName) && !this.ageCheckerSet.ContainsKey(trigger.PresetActWrapper.TimingActionsInter[m].ActionName)) { AssetLoadBase base3 = new AssetLoadBase { assetPath = trigger.PresetActWrapper.TimingActionsInter[m].ActionName }; loadInfo.ageActions.Add(base3); this.ageCheckerSet.Add(trigger.PresetActWrapper.TimingActionsInter[m].ActionName, true); } } } } } GlobalTrigger[] triggerArray2 = UnityEngine.Object.FindObjectsOfType <GlobalTrigger>(); if ((triggerArray2 != null) && (triggerArray2.Length > 0)) { for (int n = 0; n < triggerArray2.Length; n++) { GlobalTrigger trigger2 = triggerArray2[n]; if ((trigger2.TriggerMatches != null) && (trigger2.TriggerMatches.Length > 0)) { for (int num6 = 0; num6 < trigger2.TriggerMatches.Length; num6++) { CTriggerMatch match = trigger2.TriggerMatches[num6]; if (((match != null) && (match.ActionList != null)) && (match.ActionList.Length > 0)) { for (int num7 = 0; num7 < match.ActionList.Length; num7++) { TriggerActionWrapper wrapper2 = match.ActionList[num7]; if ((wrapper2 != null) && (wrapper2.TimingActionsInter != null)) { for (int num8 = 0; num8 < wrapper2.TimingActionsInter.Length; num8++) { if (!string.IsNullOrEmpty(wrapper2.TimingActionsInter[num8].ActionName) && !this.ageCheckerSet.ContainsKey(wrapper2.TimingActionsInter[num8].ActionName)) { AssetLoadBase base4 = new AssetLoadBase { assetPath = wrapper2.TimingActionsInter[num8].ActionName }; loadInfo.ageActions.Add(base4); this.ageCheckerSet.Add(wrapper2.TimingActionsInter[num8].ActionName, true); } } } } } } } if ((trigger2.ActionList != null) && (trigger2.ActionList.Length > 0)) { for (int num9 = 0; num9 < trigger2.ActionList.Length; num9++) { TriggerActionWrapper wrapper3 = trigger2.ActionList[num9]; if ((wrapper3 != null) && (wrapper3.TimingActionsInter != null)) { for (int num10 = 0; num10 < wrapper3.TimingActionsInter.Length; num10++) { if (!string.IsNullOrEmpty(wrapper3.TimingActionsInter[num10].ActionName) && !this.ageCheckerSet.ContainsKey(wrapper3.TimingActionsInter[num10].ActionName)) { AssetLoadBase base5 = new AssetLoadBase { assetPath = wrapper3.TimingActionsInter[num10].ActionName }; loadInfo.ageActions.Add(base5); this.ageCheckerSet.Add(wrapper3.TimingActionsInter[num10].ActionName, true); } } } } } } } }
public void BuildActionTrigger(ref ActorPreloadTab loadInfo) { AreaEventTrigger[] array = Object.FindObjectsOfType <AreaEventTrigger>(); if (array != null && array.Length > 0) { for (int i = 0; i < array.Length; i++) { AreaEventTrigger areaEventTrigger = array[i]; for (int j = 0; j < areaEventTrigger.TriggerActions.Length; j++) { TriggerActionWrapper triggerActionWrapper = areaEventTrigger.TriggerActions[j]; if (triggerActionWrapper != null) { triggerActionWrapper.PreLoadResource(ref loadInfo, this.ageCheckerSet, this); } if (triggerActionWrapper != null && triggerActionWrapper.TriggerType == EGlobalTriggerAct.TriggerShenFu) { Singleton <ShenFuSystem> .instance.PreLoadResource(triggerActionWrapper, ref loadInfo, this); } } if (areaEventTrigger.PresetActWrapper != null) { areaEventTrigger.PresetActWrapper.PreLoadResource(ref loadInfo, this.ageCheckerSet, this); } } } GlobalTrigger[] array2 = Object.FindObjectsOfType <GlobalTrigger>(); if (array2 != null && array2.Length > 0) { for (int k = 0; k < array2.Length; k++) { GlobalTrigger globalTrigger = array2[k]; if (globalTrigger.TriggerMatches != null && globalTrigger.TriggerMatches.Length > 0) { for (int l = 0; l < globalTrigger.TriggerMatches.Length; l++) { CTriggerMatch cTriggerMatch = globalTrigger.TriggerMatches[l]; if (cTriggerMatch != null && cTriggerMatch.ActionList != null && cTriggerMatch.ActionList.Length > 0) { for (int m = 0; m < cTriggerMatch.ActionList.Length; m++) { TriggerActionWrapper triggerActionWrapper2 = cTriggerMatch.ActionList[m]; if (triggerActionWrapper2 != null) { triggerActionWrapper2.PreLoadResource(ref loadInfo, this.ageCheckerSet, this); } } } } } if (globalTrigger.ActionList != null && globalTrigger.ActionList.Length > 0) { for (int n = 0; n < globalTrigger.ActionList.Length; n++) { TriggerActionWrapper triggerActionWrapper3 = globalTrigger.ActionList[n]; if (triggerActionWrapper3 != null) { triggerActionWrapper3.PreLoadResource(ref loadInfo, this.ageCheckerSet, this); } } } } } }