/// <summary> /// Gets the dependencies for a specific model elements. /// </summary> /// <param name="modelElements">List of model elements to get the dependencies for.</param> /// <param name="options">Options.</param> /// <returns>List of dependencies.</returns> public DependenciesData GetDependencies(List<ModelElement> modelElements, DependenciesRetrivalOptions options) { DependenciesData data = new DependenciesData(); List<IDependenciesItemsProvider> discardProviders = new List<IDependenciesItemsProvider>(); GetDependencies(modelElements, options, data); return data; }
private void GenerateJson() { AssetBundle.UnloadAllAssetBundles(true); DependenciesData[] datas = new DependenciesData[m_Paths.Count]; for (int i = 0; i < m_Paths.Count; i++) { if (!m_Paths[i].EndsWith(".json")) { AssetBundle mainfestAB = AssetBundle.LoadFromFile(m_Paths[i]); var mainfest = mainfestAB.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); datas[i] = DependenceUtility.Manifest2Dependence(mainfest); } else { string tempJson = System.IO.File.ReadAllText(m_Paths[i]); datas[i] = JsonUtility.FromJson <DependenciesData>(tempJson); } } string json = JsonUtility.ToJson(DependenceUtility.ConbineDependence(datas), true); File.WriteAllText(m_OutPutPath + "/depenencies.json", json); AssetDatabase.Refresh(); Debug.Log("依赖文件已替换"); }
public DependenciesData() { if (_instance != null) { throw new Exception("单件实例错误"); } _instance = this; _dependencies = new Dictionary <string, string[]>(); _fullDependencies = new Dictionary <string, string[]>(); }
/// <summary> /// Gathers dependencies for given model elements and and wraps them for display. /// </summary> /// <param name="elements">Model elements to display dependencies for.</param> /// <param name="options">Options</param> public void Set(List <ModelElement> elements, DependenciesRetrivalOptions options) { Clear(); this.retrivalOptions = options; if (elements == null) { throw new ArgumentNullException("elements"); } this.modelElements = elements; // gather dependencies if (options != null) { this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements, options); } else { this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements); } List <DependencyItem> dependencies = this.dependenciesData.ActiveDependencies; List <DependencyItemViewModel> dependenciesVM = new List <DependencyItemViewModel>(); foreach (DependencyItem item in dependencies) { dependenciesVM.Add(new DependencyItemViewModel(this.ViewModelStore, item, this.doSubscribeToEvents)); } foreach (DependencyItemViewModel item in dependenciesVM) { Add(item); } if (doSubscribeToEvents) { // subscribe to events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) { //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Subscribe(originItem.RelationshipInfo, OnElementLinkAdded); this.ViewModelStore.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); } } Sort(sortOrder, isAscending); }
// 打包 private void Build() { RefreshAssetBundleBuild(); DependenciesData dependence; string jsonPath = m_OutPutPath + "/depenencies.json"; // 增量打包时,融合原有依赖文件 if (m_incrementalPackaging) { if (File.Exists(jsonPath)) { string readJson = File.ReadAllText(jsonPath); DependenciesData oldDependencies = JsonUtility.FromJson <DependenciesData>(readJson); DependenciesData newDependencies = BuildAssetBundle(); dependence = DependenceUtility.ConbineDependence(new DependenciesData[] { oldDependencies, newDependencies }); } else { if (EditorUtility.DisplayDialog("提示", "输出路径中无依赖文件,无法进行增量打包,是否进行非增量打包", "确认", "取消")) { dependence = BuildAssetBundle(); } else { return; } } } else { dependence = BuildAssetBundle(); } string json = JsonUtility.ToJson(dependence, true); File.WriteAllText(jsonPath, json); Debug.Log("BuildAssetBundles Complete"); }
/// <summary> /// 将unity依赖转为自己的 /// </summary> /// <param name="mainfest"></param> /// <returns></returns> public static DependenciesData GenerateDependence(AssetBundleManifest mainfest) { string[] abNames = mainfest.GetAllAssetBundles(); List <SingleDepenciesData> singleDatas = new List <SingleDepenciesData>(); for (int j = 0; j < abNames.Length; j++) { var dpNames = mainfest.GetDirectDependencies(abNames[j]); if (dpNames.Length <= 0) { continue; } singleDatas.Add(new SingleDepenciesData(abNames[j], dpNames)); } var data = new DependenciesData(singleDatas.ToArray()); return(data); }
public string[] CalculateRealityPaths(string[] paths) { List <string> result = new List <string>(); foreach (var path in paths) { result.Add(path); } int index = 1; string current; string[] dependencies; while (index < result.Count + 1) { current = result[result.Count - index]; dependencies = DependenciesData.GetInstance().GetDependencies(current); if (dependencies != null) { foreach (var dep in dependencies) { if (result.Contains(dep)) { int depIndex = result.IndexOf(dep); if (depIndex > result.Count - index) { result.Remove(dep); result.Insert(0, dep); index--; } } else { result.Insert(0, dep); } } } index++; } return(result.ToArray()); }
/// <summary> /// Removes all items. /// </summary> public void Clear() { foreach (DependencyItemViewModel item in allDependencies) { if (doSubscribeToEvents) { // unsubscribe from event notifying of a specific link beeind deleted or altered this.ViewModelStore.EventManager.GetEvent <ModelElementDeletedEvent>().Unsubscribe(item.DependencyItem.ElementLink.Id, OnElementLinkDeleted); this.ViewModelStore.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Unsubscribe(item.DependencyItem.ElementLink.Id, OnElementLinkChanged); } item.Dispose(); } foreach (DependencyItemViewModel item in displayedDependencies) { if (!item.IsDisposed) { item.Dispose(); } } if (doSubscribeToEvents && dependenciesData != null) { // unsubscribe from events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) { this.ViewModelStore.EventManager.GetEvent <ModelElementLinkAddedEvent>().Unsubscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); } //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Unsubscribe(originItem.RelationshipInfo, OnElementLinkAdded); } allDependencies.Clear(); displayedDependencies.Clear(); this.modelElements = null; this.dependenciesData = null; this.EmbeddedCount = 0; this.EmbeddingCount = 0; this.ReferencedCount = 0; this.ReferencingCount = 0; }
/// <summary> /// Gathers dependencies for given model elements and and wraps them for display. /// </summary> /// <param name="elements">Model elements to display dependencies for.</param> /// <param name="excludedDomainModels">Exclude dependencies that belong to a domain model that is provied in this list.</param> /// <param name="categories">List of categories to include in the search.</param> public void Set(List <ModelElement> elements, List <ModelElement> excludedDomainModels, params DependencyItemCategory[] categories) { Clear(); if (elements == null) { throw new ArgumentNullException("elements"); } this.modelElements = elements; this.currentExcludedDomainModels = excludedDomainModels; this.currentCategories = categories; UpdateCategoriesDisplay(categories); // gather dependencies //this.dependenciesData = this.ModelData.DependenciesItemsProvider.GetDependencies(modelElements, excludedDomainModels, categories); this.dependenciesData = LanguageDSLDependenciesItemsProvider.Instance.GetDependencies(modelElements, excludedDomainModels, categories); List <DependencyItem> dependencies = this.dependenciesData.ActiveDependencies; List <DependencyItemViewModel> dependenciesVM = new List <DependencyItemViewModel>(); foreach (DependencyItem item in dependencies) { dependenciesVM.Add(new DependencyItemViewModel(this.ViewModelStore, item, this.doSubscribeToEvents)); } foreach (DependencyItemViewModel item in dependenciesVM) { Add(item); } if (doSubscribeToEvents) { // subscribe to events notifying of new dependencies beeing created //foreach(DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) // this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Subscribe(originItem.RelationshipInfo, OnElementLinkAdded); } Sort(sortOrder, isAscending); }
private void GenerateJson() { AssetBundle.UnloadAllAssetBundles(true); DependenciesData[] datas = new DependenciesData[m_Paths.Count]; for (int i = 0; i < m_Paths.Count; i++) { if (!m_Paths[i].EndsWith(".json")) { AssetBundle mainfestAB = AssetBundle.LoadFromFile(m_Paths[i]); var mainfest = mainfestAB.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); string[] abNames = mainfest.GetAllAssetBundles(); List <SingleDepenciesData> singleDatas = new List <SingleDepenciesData>(); for (int j = 0; j < abNames.Length; j++) { var dpNames = mainfest.GetDirectDependencies(abNames[j]); if (dpNames.Length <= 0) { continue; } singleDatas.Add(new SingleDepenciesData(abNames[j], dpNames)); } datas[i] = new DependenciesData(singleDatas.ToArray()); } else { string tempJson = System.IO.File.ReadAllText(m_Paths[i]); datas[i] = JsonUtility.FromJson <DependenciesData>(tempJson); } } string json = JsonUtility.ToJson(ConbineDependence(datas), true); File.WriteAllText(m_OutPutPath + "/depenencies.json", json); AssetDatabase.Refresh(); }
/// <summary> /// Removes all items. /// </summary> public void Clear() { foreach (DependencyItemViewModel item in allDependencies) { if (doSubscribeToEvents) { // unsubscribe from event notifying of a specific link beeind deleted or altered this.ViewModelStore.EventManager.GetEvent<ModelElementDeletedEvent>().Unsubscribe(item.DependencyItem.ElementLink.Id, OnElementLinkDeleted); this.ViewModelStore.EventManager.GetEvent<ModelRolePlayerChangedEvent>().Unsubscribe(item.DependencyItem.ElementLink.Id, OnElementLinkChanged); } item.Dispose(); } foreach (DependencyItemViewModel item in displayedDependencies) { if (!item.IsDisposed) item.Dispose(); } if (doSubscribeToEvents && dependenciesData != null) { // unsubscribe from events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) this.ViewModelStore.EventManager.GetEvent<ModelElementLinkAddedEvent>().Unsubscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Unsubscribe(originItem.RelationshipInfo, OnElementLinkAdded); } allDependencies.Clear(); displayedDependencies.Clear(); this.modelElements = null; this.dependenciesData = null; this.EmbeddedCount = 0; this.EmbeddingCount = 0; this.ReferencedCount = 0; this.ReferencingCount = 0; }
/// <summary> /// Gathers dependencies for given model elements and and wraps them for display. /// </summary> /// <param name="elements">Model elements to display dependencies for.</param> /// <param name="options">Options</param> public void Set(List<ModelElement> elements, DependenciesRetrivalOptions options) { Clear(); this.retrivalOptions = options; if (elements == null) throw new ArgumentNullException("elements"); this.modelElements = elements; // gather dependencies if (options != null) this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements, options); else this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements); List<DependencyItem> dependencies = this.dependenciesData.ActiveDependencies; List<DependencyItemViewModel> dependenciesVM = new List<DependencyItemViewModel>(); foreach (DependencyItem item in dependencies) dependenciesVM.Add(new DependencyItemViewModel(this.ViewModelStore, item, this.doSubscribeToEvents)); foreach (DependencyItemViewModel item in dependenciesVM) { Add(item); } if (doSubscribeToEvents) { // subscribe to events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Subscribe(originItem.RelationshipInfo, OnElementLinkAdded); this.ViewModelStore.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); } Sort(sortOrder, isAscending); }
/// <summary> /// Gets the dependencies for a specific model element. /// </summary> /// <param name="dependenciesData">Dependencies data to add new dependency and origin items to.</param> /// <param name="modelElement">Model element to get the dependencies for.</param> public abstract void GetDependencies(DependenciesData dependenciesData, ModelElement modelElement);
/// <summary> /// Gets the dependencies for a specific model element. /// </summary> /// <param name="dependenciesData">Dependencies data to add new dependency and origin items to.</param> /// <param name="modelElement">Model element to get the dependencies for.</param> /// <param name="options">Options</param> public abstract void GetDependencies(DependenciesData dependenciesData, ModelElement modelElement, DependenciesRetrivalOptions options);
/// <summary> /// Gets the dependencies for a specific model elements. /// </summary> /// <param name="modelElements">List of model elements to get the dependencies for.</param> /// <param name="options">Options.</param> /// <param name="dependenciesData">Data to add found dependencies to.</param> /// <returns>List of dependencies.</returns> public virtual DependenciesData GetDependencies(List<ModelElement> modelElements, DependenciesRetrivalOptions options, DependenciesData dependenciesData) { foreach (ModelElement modelElement in modelElements) { IDomainModelOwnable dmo = modelElement as IDomainModelOwnable; if (dmo == null) continue; DomainClassInfo info = modelElement.GetDomainClass(); foreach (DomainRoleInfo roleInfo in info.AllDomainRolesPlayed) { if (roleInfo.DomainModel.Id == CoreDomainModel.DomainModelId) continue; if (options.ShouldExcludeDomainRelationship(roleInfo.DomainRelationship.Id, roleInfo.DomainModel.Id)) continue; foreach (DependencyItemCategory category in GetAllCategories()) { if (roleInfo.IsSource && category != DependencyItemCategory.Embedding && category != DependencyItemCategory.Referencing) continue; if (!roleInfo.IsSource && category != DependencyItemCategory.Embedded && category != DependencyItemCategory.Referenced) continue; if (dmo.Store.DomainDataAdvDirectory.IsEmbeddingRelationship(roleInfo.DomainRelationship.Id)) { if (category != DependencyItemCategory.Embedded && category != DependencyItemCategory.Embedding) continue; } else if (category == DependencyItemCategory.Embedded || category == DependencyItemCategory.Embedding) continue; // add origin dependency dependenciesData.OriginDependencies.Add(new DependencyOriginItem(modelElement.Id, roleInfo.DomainRelationship, roleInfo)); // get link instances System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> links = DomainRoleInfo.GetElementLinks<ElementLink>(modelElement, roleInfo.Id); if (links.Count > 0) { foreach (ElementLink link in links) { if (category == DependencyItemCategory.Embedding || category == DependencyItemCategory.Referencing) { if (options.ShouldExcludeDomainClass(DomainRoleInfo.GetTargetRolePlayer(link))) continue; } else if (options.ShouldExcludeDomainClass(DomainRoleInfo.GetSourceRolePlayer(link))) continue; if (options.ShouldExcludeDomainRelationship(link)) continue; DependencyItem item = new DependencyItem(link, category, roleInfo.DomainRelationship, roleInfo); dependenciesData.ActiveDependencies.Add(item); } } } } } return dependenciesData; }