/// <summary> /// 对比两个的不同,以自身为主 /// </summary> /// <param name="inputConfig"></param> /// <returns></returns> internal ResourcesConfig CheckDifference(ResourcesConfig inputConfig) { ResourcesConfig differenceConfig = new ResourcesConfig(); foreach (var item in Config) { //对于每一个自己的item,如果对方也有 if (inputConfig.Config.ContainsKey(item.Key)) { //判断版本是否相同 if (inputConfig.Config[item.Key] != item.Value) { // 如果版本不同就添加自身的数据到结果中, // 这一行代码说明,这样的对比是默认采用本类数据的,所以, // 调用的时候,应该是 服务器数据结构.CheckDifference(客户端数据结构) differenceConfig.Config.Add(item.Key, item.Value); } } else { //如果对方没有,直接加入 differenceConfig.Config.Add(item.Key, item.Value); } } //如果没有不同,说明版本完全一样 if (differenceConfig.Config.Count == 0) { Debug.Log("Nothing Difference"); return(null); } return(differenceConfig); }
/// <summary> /// 异步加载一个依赖包 /// </summary> /// <param name="relyBundleName"></param> /// <param name="callBack"></param> public static void LoadRelyBundleAsync(string relyBundleName, RelyBundleLoadCallBack callBack) { if (s_relyBundle.ContainsKey(relyBundleName)) { RelyBundle tmp = s_relyBundle[relyBundleName]; tmp.relyCount++; callBack(LoadState.CompleteState, tmp); } else { //先占位,避免重复加载 s_relyBundle.Add(relyBundleName, null); ResourcesConfig configTmp = ResourcesConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); ResourceIOTool.AssetsBundleLoadAsync(path, (LoadState state, AssetBundle bundle) => { if (!state.isDone) { callBack(state, null); } else { callBack(state, AddRelyBundle(relyBundleName, bundle)); } }); } }
public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddDbContext <AuthDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ConnectionString"), builder => builder.MigrationsAssembly(typeof(Startup).Assembly.FullName))); services.ConfigureApplicationCookie(config => { config.Cookie.Name = "BanklyDemo.Auth.Cookie"; config.LoginPath = "/Account/Login"; }); services.AddControllersWithViews(); services.AddIdentityServer() .AddInMemoryApiResources(ResourcesConfig.GetApis()) .AddInMemoryClients(ResourcesConfig.GetClients()) .AddInMemoryIdentityResources(ResourcesConfig.GetIdentityresources()) .AddDeveloperSigningCredential(); Mapper.Initialize(config => { config.AddProfile <DomainServicesMapperProfile>(); }); services.AddCors(); // Make sure you call this previous to AddMvc services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); return(services.AddDependencies()); }
private void LoadResConifg() { if (mResConfig == null) { string path = string.Format("Assets/{0}/{1}/ResConfig/ResConfig.asset", Paths.GameResRoot, mType); mResConfig = UnityEditor.AssetDatabase.LoadAssetAtPath <ResourcesConfig>(path); mResConfig.FormatDic(); } }
/// <summary> /// 读取当前本地客户端版本 /// </summary> private void ReadLocalCurentVersionData() { //记录客户端版本号 var newestVersion = PlayerPrefs.GetString(VersionDefine.PrefKey_LocalVersion); var versionData = PlayerPrefs.GetString(newestVersion); //记录客户端版本资源结构 localConfig = ResourcesConfig.Create(versionData); }
private void LoadResConifg() { if (mResConfig == null) { string path = string.Format("{0}/resconfig.{1}", mType, Def.AssetBundleSuffix); AssetBundle res = LoadABFile(path); mResConfig = res.LoadAsset <ResourcesConfig>("resconfig"); mResConfig.FormatDic(); res.Unload(true); } }
public void GenerateDefaultConfig(params object[] param) { GraphicConfig.GenerateDefaultConfig(param); AudioConfig.GenerateDefaultConfig(); LocateConfig.GenerateDefaultConfig(); ModConfig.GenerateDefaultConfig(); NetworkConfig.GenerateDefaultConfig(); CoreConfig.GenerateDefaultConfig(); InputConfig.GenerateDefaultConfig(); ResourcesConfig.GenerateDefaultConfig(); PluginConfig.GenerateDefaultConfig(); }
/// <summary> /// 下载不同的素材到不同的文件夹中 /// </summary> /// <param name="differenceConfig"></param> private void DownLoadAllDifferenceResource(ResourcesConfig differenceConfig) { if (differenceConfig == null) { return; } //把所有不同的素材添加到下载队列中 foreach (var item in differenceConfig.Config) { bundleDownloaderTool.AddDownloadBundleCommand(item.Key, item.Value); } }
/// <summary> /// 异步加载一个bundle /// </summary> /// <param name="bundleName">bundle名</param> public static void LoadBundleAsync(string bundleName, BundleLoadCallBack callBack) { ResourcesConfig configTmp = ResourcesConfigManager.GetBundleConfig(bundleName); if (configTmp == null) { Debug.LogError("LoadBundleAsync: " + bundleName + " dont exist!"); return; } string path = GetBundlePath(configTmp); LoadState state = new LoadState(); Dictionary <string, LoadState> loadStateDict = new Dictionary <string, LoadState>(); //先加载依赖包 for (int i = 0; i < configTmp.relyPackages.Length; i++) { LoadRelyBundleAsync(configTmp.relyPackages[i], (LoadState relyLoadState, RelyBundle RelyBundle) => { if (RelyBundle != null && relyLoadState.isDone) { Debug.Log(RelyBundle.bundle.name); loadStateDict.Add(RelyBundle.bundle.name, relyLoadState); state.progress += 1 / ((float)configTmp.relyPackages.Length + 1); } //所有依赖包加载完毕加载资源包 if (loadStateDict.Keys.Count == configTmp.relyPackages.Length) { ResourceIOTool.AssetsBundleLoadAsync(path, (LoadState bundleLoadState, AssetBundle bundle) => { if (bundleLoadState.isDone) { callBack(LoadState.CompleteState, AddBundle(bundleName, bundle)); } else { state.progress += bundleLoadState.progress / ((float)configTmp.relyPackages.Length + 1); callBack(state, null); } }); } else { callBack(state, null); } }); } }
static Bundle AddBundle(string bundleName, AssetBundle asset) { //Debug.Log("AddBundle " + bundleName); Bundle bundleTmp = new Bundle(); ResourcesConfig configTmp = ResourcesConfigManager.GetBundleConfig(bundleName); if (s_bundles.ContainsKey(bundleName)) { s_bundles[bundleName] = bundleTmp; } else { s_bundles.Add(bundleName, bundleTmp); } bundleTmp.bundleConfig = configTmp; if (asset != null) { bundleTmp.bundle = asset; bundleTmp.bundle.name = bundleName; bundleTmp.mainAsset = bundleTmp.bundle.mainAsset; bundleTmp.allAsset = bundleTmp.bundle.LoadAllAssets(); //延迟卸载资源,因为unity的资源卸载有时会异步 Timer.DelayCallBack(5, (obj) => { bundleTmp.bundle.Unload(false); }); //如果有缓存起来的回调这里一起回调 if (LoadAsyncDict.ContainsKey(bundleName)) { try { LoadAsyncDict[bundleName](LoadState.CompleteState, bundleTmp.mainAsset); } catch (Exception e) { Debug.Log("LoadAsync AddBundle " + e.ToString()); } } } else { Debug.LogError("AddBundle: " + bundleName + " dont exist!"); } return(bundleTmp); }
static Dictionary <string, RelyBundle> s_relyBundle = new Dictionary <string, RelyBundle>(); //所有依赖包 /// <summary> /// 同步加载一个bundles /// </summary> /// <param name="name">bundle名</param> public static Bundle LoadBundle(string bundleName) { ResourcesConfig configTmp = ResourcesConfigManager.GetBundleConfig(bundleName); string path = GetBundlePath(configTmp); //加载依赖包 for (int i = 0; i < configTmp.relyPackages.Length; i++) { LoadRelyBundle(configTmp.relyPackages[i]); } return(AddBundle(bundleName, AssetBundle.LoadFromFile(path))); }
/// <summary> /// 根据bundleName获取加载路径 /// </summary> /// <param name="bundleName"></param> /// <returns></returns> static string GetBundlePath(ResourcesConfig config) { bool isLoadByPersistent = RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(config.name, "null") == "null" ? false:true; ResLoadLocation loadType = ResLoadLocation.Streaming; //加载路径由 加载根目录 和 相对路径 合并而成 //加载根目录由配置决定 if (isLoadByPersistent) { loadType = ResLoadLocation.Persistent; } return(PathTool.GetAbsolutePath(loadType, config.path + "." + c_AssetsBundlesExpandName)); }
//加载一个依赖包 public static RelyBundle LoadRelyBundle(string relyBundleName) { RelyBundle tmp = null; if (s_relyBundle.ContainsKey(relyBundleName)) { tmp = s_relyBundle[relyBundleName]; tmp.relyCount++; } else { ResourcesConfig configTmp = ResourcesConfigManager.GetRelyBundleConfig(relyBundleName); string path = GetBundlePath(configTmp); tmp = AddRelyBundle(relyBundleName, AssetBundle.LoadFromFile(path)); } return(tmp); }
public static void LoadAsync(string name, LoadCallBack callBack) { ResourcesConfig packData = ResourcesConfigManager.GetBundleConfig(name); if (packData == null) { return; } if (m_gameLoadType == ResLoadLocation.Resource) { ResourceIOTool.ResourceLoadAsync(packData.path, callBack); } else { AssetsBundleManager.LoadAsync(name, callBack); } }
public static object Load(string name) { ResourcesConfig packData = ResourcesConfigManager.GetBundleConfig(name); if (packData == null) { throw new Exception("Load Exception not find " + name); } if (m_gameLoadType == ResLoadType.Resource) { return(Resources.Load(packData.path)); } else { return(AssetsBundleManager.Load(name)); } }
/// <summary> /// 判断资源包是否更行完毕 /// </summary> /// <param name="checkConfig"></param> internal void CheckFileDone(ResourcesConfig checkConfig) { bool allFine = true; foreach (var item in checkConfig.Config) { string checkpath = pather.GetLocalBundlePath(item.Key, item.Value); if (!File.Exists(checkpath)) { allFine = false; } } if (OnAllFine != null && allFine) { OnAllFine(); } }
public static T Load <T>(string name) where T : UnityEngine.Object { ResourcesConfig packData = ResourcesConfigManager.GetBundleConfig(name); if (packData == null) { throw new Exception("Load Exception not find " + name); } if (m_gameLoadType == ResLoadLocation.Resource) { return(Resources.Load <T>(packData.path)); } else { return(AssetsBundleManager.Load <T>(name)); } }
public static ResourcesConfigStruct AnalysisResourcesConfig2Struct(string content) { if (content == null || content == "") { throw new Exception("ResourcesConfigcontent is null ! "); } ResourcesConfigStruct result = new ResourcesConfigStruct(); Dictionary <string, object> data = (Dictionary <string, object>)FrameWork.Json.Deserialize(content); Dictionary <string, object> gameRelyBundles = (Dictionary <string, object>)data[c_relyBundleKey]; Dictionary <string, object> gameAssetsBundles = (Dictionary <string, object>)data[c_bundlesKey]; result.relyList = new Dictionary <string, ResourcesConfig>(); result.bundleList = new Dictionary <string, ResourcesConfig>(); foreach (object item in gameRelyBundles.Values) { Dictionary <string, object> tmp = (Dictionary <string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = (tmp["relyPackages"].ToString()).Split('|'); config.md5 = (string)tmp["md5"]; result.relyList.Add(config.name, config); } foreach (object item in gameAssetsBundles.Values) { Dictionary <string, object> tmp = (Dictionary <string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.bundleList.Add(config.name, config); } return(result); }
public static ResourcesConfigStruct AnalysisResourcesConfig2Struct(string content) { if (content == null || content =="") { throw new Exception("ResourcesConfigcontent is null ! "); } ResourcesConfigStruct result = new ResourcesConfigStruct(); Dictionary<string, object> data = (Dictionary<string, object>)MiniJSON.Json.Deserialize(content); Dictionary<string, object> gameRelyBundles = (Dictionary<string, object>)data[c_relyBundleKey]; Dictionary<string, object> gameAssetsBundles = (Dictionary<string, object>)data[c_bundlesKey]; result.relyList = new Dictionary<string, ResourcesConfig>(); result.bundleList = new Dictionary<string, ResourcesConfig>(); foreach (object item in gameRelyBundles.Values) { Dictionary<string, object> tmp = (Dictionary<string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.relyList.Add(config.name,config); } foreach (object item in gameAssetsBundles.Values) { Dictionary<string, object> tmp = (Dictionary<string, object>)item; ResourcesConfig config = new ResourcesConfig(); config.name = (string)tmp["name"]; config.path = (string)tmp["path"]; config.relyPackages = ((string)tmp["relyPackages"]).Split('|'); config.md5 = (string)tmp["md5"]; result.bundleList.Add(config.name,config); } return result; }
static Bundle AddBundle(string bundleName, AssetBundle aess) { Bundle bundleTmp = new Bundle(); ResourcesConfig configTmp = ResourcesConfigManager.GetBundleConfig(bundleName); if (s_bundles.ContainsKey(bundleName)) { s_bundles[bundleName] = bundleTmp; } else { s_bundles.Add(bundleName, bundleTmp); } bundleTmp.bundleConfig = configTmp; if (aess != null) { bundleTmp.bundle = aess; bundleTmp.bundle.name = bundleName; bundleTmp.mainAsset = bundleTmp.bundle.mainAsset; bundleTmp.bundle.Unload(false); //如果有缓存起来的回调这里一起回调 if (LoadAsyncDict.ContainsKey(bundleName)) { try { LoadAsyncDict[bundleName](LoadState.CompleteState, bundleTmp.mainAsset); } catch (Exception e) { Debug.Log("LoadAsync AddBundle " + e.ToString()); } } } else { Debug.LogError("AddBundle: " + bundleName + " dont exist!"); } return(bundleTmp); }
/// <summary> /// 卸载bundle /// </summary> /// <param name="bundleName"></param> public static void UnLoadBundle(string bundleName) { if (s_bundles.ContainsKey(bundleName)) { ResourcesConfig configTmp = s_bundles[bundleName].bundleConfig; //卸载依赖包 for (int i = 0; i < configTmp.relyPackages.Length; i++) { UnLoadRelyBundle(configTmp.relyPackages[i]); } s_bundles[bundleName].bundle.Unload(true); s_bundles.Remove(bundleName); } else { Debug.LogError("UnLoadBundle: " + bundleName + " dont exist !"); } }
//生成游戏中使用的配置文件 public void CreatBundelPackageConfig() { Dictionary <string, SingleField> gameConfig = new Dictionary <string, SingleField>(); Dictionary <string, ResourcesConfig> gameRelyBundles = new Dictionary <string, ResourcesConfig>(); for (int i = 0; i < relyPackages.Count; i++) { //生成游戏中使用的依赖包数据 ResourcesConfig pack = new ResourcesConfig(); pack.name = relyPackages[i].name; pack.path = relyPackages[i].path; pack.relyPackages = new string[0]; pack.md5 = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name)); //获取bundle包的md5 //pack.loadType = ResLoadType.Streaming; //默认放在沙盒路径下 gameRelyBundles.Add(pack.name, pack); } Dictionary <string, ResourcesConfig> gameAssetsBundles = new Dictionary <string, ResourcesConfig>(); for (int i = 0; i < bundles.Count; i++) { //生成游戏中使用的bundle包数据 ResourcesConfig pack = new ResourcesConfig(); pack.name = bundles[i].name; pack.path = bundles[i].path; pack.relyPackages = GetRelyPackNames(bundles[i].relyPackagesMask); //获取依赖包的名字 pack.md5 = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name)); //获取bundle包的md5 //pack.loadType = ResLoadType.Streaming; //默认放在沙盒路径下 gameAssetsBundles.Add(pack.name, pack); } gameConfig.Add(ResourcesConfigManager.c_relyBundleKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameRelyBundles))); gameConfig.Add(ResourcesConfigManager.c_bundlesKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameAssetsBundles))); //保存游戏中读取的配置文件 ConfigManager.SaveData(ResourcesConfigManager.c_configFileName, gameConfig); AssetDatabase.Refresh(); }
static void CheckBundleList(Dictionary <string, ResourcesConfig> serviceDict, Dictionary <string, ResourcesConfig> localDict) { foreach (ResourcesConfig item in serviceDict.Values) { ResourcesConfig Tmp = item; if (localDict.ContainsKey(Tmp.name)) { ResourcesConfig localTmp = localDict[Tmp.name]; if (!Tmp.md5.Equals(localTmp.md5)) { s_downLoadList.Add(Tmp); } } else { s_downLoadList.Add(Tmp); } } }
private void Main_Load(object sender, EventArgs e) { _syncContext = SynchronizationContext.Current; _service = new ResumeParseService(); PrintCpuInfo(); PrintServiceStatus(); Notice("资源加载中....."); ThreadPool.QueueUserWorkItem((w) => { ResourcesConfig.Load(); Notice("资源加载完成"); UpdateUI(() => { btnDocExt.Enabled = true; btnParse.Enabled = true; btnResumeParse.Enabled = true; btnScan.Enabled = true; }); }); }
/// <summary> /// 读取服务器版本信息 /// </summary> /// <returns></returns> private IEnumerator ReadServeNewestVersion() { string versionMessage = null; yield return(FetchMessageFromWeb(pather.WebServeVersionPath, output => versionMessage = output)); if (!string.IsNullOrEmpty(versionMessage)) { //记录当前服务器版本号 currentServeVersion = versionMessage; var serveConfigURL = pather.GetServeConfigPath(versionMessage); //Debug.Log(NewestServeConfigURL); string serverData = null; yield return(FetchMessageFromWeb(serveConfigURL, output => serverData = output)); //Debug.Log(servedata); //记录当前服务器资源结构 serveConfig = ResourcesConfig.Create(serverData); } }
public static ResourcesConfig Create(string inputMessage) { var ans = new ResourcesConfig(); if (string.IsNullOrEmpty(inputMessage)) { return(ans); } inputMessage = inputMessage.Replace("\r", string.Empty); var lines = inputMessage.Split('\n'); if (lines.Length == 0) { return(null); } foreach (var line in lines) { var sets = line.Split(':'); ans.Config.Add(sets[0], sets[1]); } return(ans); }
public void preProcess() { ResourcesConfig.Load(); string[] datas = ResumeText.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries); foreach (string n in datas) { string line = n; if ((line.Contains("前程无忧") || line.Contains("智联招聘") || line.Contains("猎聘网"))) { continue; } line = Regex.Replace(line, "[\\u00A0]+", " "); line = Regex.Replace(line, "[\\\u3000]+", " "); line = line.Replace("http://my.51job.com", " ").Replace("此简历来自猎聘网", " ").Replace("Liepin.com ", " ").Replace("最大的中文高端招聘社区", " "); line = line.Replace(":", ":").Trim(); if (!line.IsNullOrWhiteSpace()) { resumeContentList.Add(line); } } // building segmentIndexMap info this.segmentMap = SegmentSplit.GetSegments(resumeContentList); foreach (var v in segmentMap) { string key = v.Key; SectionInfo sectionInfo = v.Value; string content = getContent(sectionInfo.Start, sectionInfo.End); this.segmentTextMap[key] = content; this.sectionInfoList.Add(sectionInfo); } }
public static void RefreshResConfig() { DirectoryInfo dir = new DirectoryInfo(Application.dataPath + "/" + Paths.GameResRoot); foreach (DirectoryInfo childDir in dir.GetDirectories()) { List <SingleResCfg> configList = new List <SingleResCfg>(); string buildConfigPath = string.Format("Assets/" + Paths.GameResRoot + "/{0}/BuildConfigs.asset", childDir.Name); ABBuildConfigs configs = AssetDatabase.LoadAssetAtPath <ABBuildConfigs>(buildConfigPath); ABMarkConfig[] paths = configs.OneFloderOneBundle; foreach (var p in paths) { string abName = (p.GamePath + "." + Def.AssetBundleSuffix).ToLower(); DirectoryInfo childRootDir = new DirectoryInfo(p.AssetPath); FileInfo[] files = childRootDir.GetFiles("*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; if (file.Extension.Equals(".meta") || file.Extension.Equals(".DS_Store")) { continue; } configList.Add(new SingleResCfg(file.Name.Replace(file.Extension, ""), file.Extension, abName, "Assets/" + file.FullName.Replace("\\", "/").Replace(Application.dataPath + "/", ""))); } } paths = configs.SubFloderOneBundle; foreach (var p in paths) { DirectoryInfo assetDir = new DirectoryInfo(p.AssetPath); foreach (DirectoryInfo subDir in assetDir.GetDirectories()) { string abName = (p.GamePath + "/" + subDir.Name + "." + Def.AssetBundleSuffix).ToLower(); FileInfo[] files = subDir.GetFiles("*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; if (file.Extension.Equals(".meta") || file.Extension.Equals(".DS_Store")) { continue; } configList.Add(new SingleResCfg(file.Name.Replace(file.Extension, ""), file.Extension, abName, "Assets/" + file.FullName.Replace("\\", "/").Replace(Application.dataPath + "/", ""))); } } } paths = configs.OneAssetOneBundle; foreach (var p in paths) { string abName = (p.GamePath + "." + Def.AssetBundleSuffix).ToLower(); if (Directory.Exists(Application.dataPath + "/" + p.GamePath)) { DirectoryInfo assetDir = new DirectoryInfo(p.AssetPath); FileInfo[] files = assetDir.GetFiles("*", SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { FileInfo file = files[i]; if (file.Extension.Equals(".meta") || file.Extension.Equals(".DS_Store")) { continue; } configList.Add(new SingleResCfg(file.Name.Replace(file.Extension, ""), file.Extension, abName, "Assets/" + file.FullName.Replace("\\", "/").Replace(Application.dataPath + "/", ""))); } } else { FileInfo file = new FileInfo(p.AssetPath); configList.Add(new SingleResCfg(file.Name.Replace(file.Extension, ""), file.Extension, abName, "Assets/" + file.FullName.Replace("\\", "/").Replace(Application.dataPath + "/", ""))); } } string path = childDir.Name + "/ResConfig/ResConfig"; ResourcesConfig asset = Resources.Load <ResourcesConfig>(path); if (asset == null) { asset = ScriptableObject.CreateInstance <ResourcesConfig>(); path = "Assets/" + Paths.GameResRoot + "/" + childDir.Name + "/ResConfig/ResConfig.asset"; AssetDatabase.CreateAsset(asset, path); } asset.configs = configList.ToArray(); EditorUtility.SetDirty(asset); } }