public static void Load(IList <EquipConfig> configs) { IDictionary <int, IList <EquipConfig> > positionConfigs = new Dictionary <int, IList <EquipConfig> >(); IDictionary <int, EquipConfig> idConfigs = new Dictionary <int, EquipConfig>(); IDictionary <string, EquipConfig> keyConfigs = new Dictionary <string, EquipConfig>(); IDictionary <ItemType, IList <EquipConfig> > typeConfigs = new Dictionary <ItemType, IList <EquipConfig> >(); foreach (var config in configs) { ConfigBase.Load(positionConfigs, config, config.position); ConfigBase.Load(idConfigs, config, config.id); ConfigBase.Load(keyConfigs, config, config.key); ConfigBase.Load(typeConfigs, config, config.type); } configs = configs.ToImmutableList(); positionConfigs = ToImmutableDictionary(positionConfigs); idConfigs = ToImmutableDictionary(idConfigs); keyConfigs = ToImmutableDictionary(keyConfigs); typeConfigs = ToImmutableDictionary(typeConfigs); _configs = configs; _positionConfigs = positionConfigs; _idConfigs = idConfigs; _keyConfigs = keyConfigs; _typeConfigs = typeConfigs; }
public static void GenerateCLRBindingByAnalysis(bool showTips = true) { if (showTips && !EditorUtility.DisplayDialog("注意", "确定要生成吗", "是的", "点错")) { return; } //用新的分析热更dll调用引用来生成绑定代码 ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain(); var ilrConfig = ConfigBase.Load <FrameworkRuntimeConfig>().ILRConfig; using (System.IO.FileStream fs = new System.IO.FileStream($"Assets/StreamingAssets/{ilrConfig.DllName}.dll", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { domain.LoadAssembly(fs); //Crossbind Adapter is needed to generate the correct binding code InitILRuntime(domain); var path = "Assets/_Scripts/ILRuntime/Generated"; if (Directory.Exists(path)) { Directory.Delete(path, true); } ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, "Assets/_Scripts/ILRuntime/Generated"); } AssetDatabase.Refresh(); }
public static void BuildDLL(string codeSource, string outPath, bool isDebug) { var runtimeConfig = ConfigBase.Load <FrameworkRuntimeConfig>(); var config = runtimeConfig.ILRConfig; EditorUtility.SetDirty(runtimeConfig); AssetDatabase.SaveAssets(); usePdb = config.UsePbd; //string codeSource = Application.dataPath + "/_scripts@hotfix"; //string outPath = config.DllGenPath + $"/{dllName}.dll"; List <string> allDll = new List <string>(); var allCsFiles = new List <string>(Directory.GetFiles(codeSource, "*.cs", SearchOption.AllDirectories)); try { EditorUtility.DisplayProgressBar("编译服务", "[1/2]查找引用和脚本...", 0.5f); FindDLLByCSPROJ("Assembly-CSharp.csproj", ref allDll); EditorUtility.DisplayProgressBar("编译服务", "[2/2]开始编译hotfix.dll...", 0.7f); BuildByRoslyn(allDll, allCsFiles, outPath); } finally { EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); } }
private static void ILRuntimeAutoCompile() { #if ILRUNTIME var config = ConfigBase.Load <FrameworkRuntimeConfig>().ILRConfig; if (!config.UseHotFix || !config.AutoCompile) { return; } ILRuntimeBuildDll.DebugBuild(); #endif }
public static void CreateUiCode() { var go = Selection.activeGameObject; if (go == null) { return; } _config = ConfigBase.Load <EditorConfig>(); CreateCode(go, AssetDatabase.GetAssetPath(go)); AssetDatabase.Refresh(); }
public void EditorLoad() { List <Type> allTypes = new List <Type>(); var ilrConfig = ConfigBase.Load <FrameworkRuntimeConfig>().ILRConfig; if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor) { var ilrAsm = AssemblyManager.GetAssembly(ilrConfig.DllName); allTypes.AddRange(ilrAsm.DefinedTypes); } foreach (var type in allTypes) { CheckType(type); } }
public static IRes Create() { IRes result = null; var config = ConfigBase.Load <RuntimeConfig>(); switch (config.LoadType) { case RuntimeConfig.ResType.Resources: result = new ResourcesRes(); break; case RuntimeConfig.ResType.Addressable: result = new AddressableRes(); break; } return(result); }
static AppConfig() { ConfigList = new Dictionary <string, ConfigBase>(); string configDir = Path.Combine(Application.StartupPath, ConfigurationManager.AppSettings[CONFIG_CONFIGDIR]); List <KeyValuePair <string, string> > configSettings = (List <KeyValuePair <string, string> >)ConfigurationManager.GetSection(CONFIG_CONFIGSETTING); for (int i = 0; i < configSettings.Count; i++) { KeyValuePair <string, string> pair = configSettings[i]; string serviceType = pair.Key; string configFile = pair.Value; ConfigBase config = ObjectFactory.CreateObject <ConfigBase>(ConfigurationManager.AppSettings[CONFIG_CONFIGTYPE]); config.ServerType = serviceType; config.Load(Path.Combine(configDir, configFile)); InitMessageComponents(config); ConfigList.Add(serviceType, config); } }
static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain domain) { //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用 var gameDll = AssemblyManager.GetAssembly(ConfigBase.Load <FrameworkRuntimeConfig>().GameDllName); var para = new object[] { domain }; foreach (var type in gameDll.GetTypes()) { ILRuntimeAdapterHelper.AddAdaptor(type); if (type.GetCustomAttribute(typeof(HotfixInitAttribute), false) != null) { type.GetMethods().First(info => info.GetCustomAttribute(typeof(HotfixInitAttribute)) != null) .Invoke(null, para); } } foreach (var type in typeof(ILRuntimeHelper).Assembly.GetTypes()) { ILRuntimeAdapterHelper.AddAdaptor(type); } ILRuntimeHelper.InitializeILRuntime(domain); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Stopwatch stopwatch = new Stopwatch(); DateTime startDate; var endDate = DateTime.Today.GetBusinessDay(-1); var options = new CommandLineOptions(); if (!Parser.Default.ParseArguments(args, options)) Environment.Exit(Parser.DefaultExitCodeFail); DateTime.TryParse(String.Join(".", options.startDate), out startDate); var logging = new Logging(options.LogFile); Trace.WriteLine(options.ToString()); var config = new ConfigBase(); config.Load(options.Settings); if (!options.NoDownload) { IDataSource dataSource = new Bloomberg(); dataSource.Connect(); HashSet<string> shareNames = new HashSet<string>(); // get specifications var sheet = new Sheet(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shareNames") }); var shareIDs = sheet.toShares(); shareNames.UnionWith( dataSource.GetTickers(shareIDs.ToList()) ); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("indices") }); var indexNames = sheet.toShares(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("fields") }); var fields = new List<Field>(); sheet.toFields<Field>(fields); //download index compositions if (indexNames != null && indexNames.Count() > 0) { //obtain components of indices var names = dataSource.DownloadMultipleComponents(indexNames.ToList(), "INDX_MEMBERS"); //convert tickers -> BB IDs shareNames.UnionWith(dataSource.GetTickers(names)); } LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); //delete data for shares-reload and shares-delete { sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-reload") }); var sharesReload = dataSource.GetTickers(sheet.toShares().ToList()); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-delete") }); var sharesDelete = dataSource.GetTickers(sheet.toShares().ToList()); foreach (var item in sharesDelete.Concat(sharesReload)) disk.DeleteDirectory(item.StripOfIllegalCharacters()); //delete shares-delete names from list of downloadable shares foreach (var item in sharesDelete) { if (shareNames.Contains(item)) shareNames.Remove(item); } } //download and save data stopwatch.Start(); { var shares = new SharesBatch(shareNames.ToList(), fields, dataSource, disk, startDate, endDate); shares.PerformOperations(); Trace.Write("Processing Individual: "); foreach (var shareName in shareNames) { Share share = new Share(name: shareName, fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWork(); } } dataSource.Disconnect(); //download fieldInfo { if (shareNames.Count() > 0) { dataSource.Connect(dataType: "//blp/apiflds"); disk.SetPath(options.FieldInfoDir); Share share = new Share(name: shareNames.First(), fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWorkFieldInfo(); dataSource.Disconnect(); } } stopwatch.Stop(); Trace.WriteLine("Time spent downloading from BB: " + stopwatch.Elapsed.ToString()); } //upload data via SQL connection if (!options.NoUpload) { stopwatch.Restart(); { LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWork(); } { LocalDisk disk = new LocalDisk(); disk.SetPath(options.FieldInfoDir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWorkFieldInfo(); } stopwatch.Stop(); Trace.WriteLine("Time spent uploading: " + stopwatch.Elapsed.ToString()); logging.Close(); { Console.WriteLine("Executing long job, you can force exit program, it will continue executing on server"); LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.executeScript(); } } }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Stopwatch stopwatch = new Stopwatch(); DateTime startDate; var endDate = DateTime.Today.GetBusinessDay(-1); var options = new CommandLineOptions(); if (!Parser.Default.ParseArguments(args, options)) { Environment.Exit(Parser.DefaultExitCodeFail); } DateTime.TryParse(String.Join(".", options.startDate), out startDate); var logging = new Logging(options.LogFile); Trace.WriteLine(options.ToString()); var config = new ConfigBase(); config.Load(options.Settings); if (!options.NoDownload) { IDataSource dataSource = new Bloomberg(); dataSource.Connect(); HashSet <string> shareNames = new HashSet <string>(); // get specifications var sheet = new Sheet(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shareNames") }); var shareIDs = sheet.toShares(); shareNames.UnionWith( dataSource.GetFields(shareIDs.ToList(), "ID_BB_GLOBAL") ); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("indices") }); var indexNames = sheet.toShares(); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("fields") }); var fields = new List <Field>(); sheet.toFields <Field>(fields); //download index compositions if (indexNames != null && indexNames.Count() > 0) { //obtain components of indices var names = dataSource.DownloadMultipleComponents(indexNames.ToList(), "INDX_MEMBERS"); //convert tickers -> BB IDs shareNames.UnionWith(dataSource.GetFields(names, "ID_BB_GLOBAL")); } LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); //delete data for shares-reload and shares-delete { sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-reload") }); var sharesReload = dataSource.GetFields(sheet.toShares().ToList(), "ID_BB_GLOBAL"); sheet.Download(new string[] { config.GetValue("sheetCode"), config.GetValue("shares-delete") }); var sharesDelete = dataSource.GetFields(sheet.toShares().ToList(), "ID_BB_GLOBAL"); foreach (var item in sharesDelete.Concat(sharesReload)) { disk.DeleteDirectory(item.StripOfIllegalCharacters()); } //delete shares-delete names from list of downloadable shares foreach (var item in sharesDelete) { if (shareNames.Contains(item)) { shareNames.Remove(item); } } } shareNames = new HashSet <string>(shareNames.Where(item => item.Contains("BBG") & !item.Contains(" "))); //roundtrip to tickers and back to bb_ids - as some bb_ids represent the same share var ticker = dataSource.GetFields(shareNames.ToList(), "EQY_FUND_TICKER"); var asset_class = dataSource.GetFields(shareNames.ToList(), "BPIPE_REFERENCE_SECURITY_CL_RT"); var tickers = ticker.Zip(asset_class, (first, last) => first + " " + last); HashSet <string> unique_tickers = new HashSet <string>(tickers); shareNames = new HashSet <string>(dataSource.GetFields(unique_tickers.ToList(), "ID_BB_GLOBAL").ToList()); //download and save data stopwatch.Start(); { var shares = new SharesBatch(shareNames.ToList(), fields, dataSource, disk, startDate, endDate); shares.PerformOperations(); Trace.Write("Processing Individual: "); foreach (var shareName in shareNames) { Share share = new Share(name: shareName, fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWork(); } } dataSource.Disconnect(); //download fieldInfo { if (shareNames.Count() > 0) { dataSource.Connect(dataType: "//blp/apiflds"); disk.SetPath(options.FieldInfoDir); Share share = new Share(name: shareNames.First(), fields: fields, dataSource: dataSource, fileAccess: disk, startDate: startDate, endDate: endDate); share.DoWorkFieldInfo(); dataSource.Disconnect(); } } stopwatch.Stop(); Trace.WriteLine("Time spent downloading from BB: " + stopwatch.Elapsed.ToString()); } //upload data via SQL connection if (!options.NoUpload) { stopwatch.Restart(); { LocalDisk disk = new LocalDisk(); disk.SetPath(options.Dir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWork(); } { LocalDisk disk = new LocalDisk(); disk.SetPath(options.FieldInfoDir); var database = new MySQL(config.GetValue("sqlIP"), config.GetValue("sqlUser"), config.GetValue("sqlPass"), config.GetValue("sqlDB"), disk); database.DoWorkFieldInfo(); } stopwatch.Stop(); Trace.WriteLine("Time spent uploading: " + stopwatch.Elapsed.ToString()); logging.Close(); } }
public void Init() { OUTPUT_PATH = ConfigBase.Load <FrameworkRuntimeConfig>().ILRConfig.AdaptorPath; }
static GenConfigAsset() { ConfigBase.Load <EditorConfig>(); ConfigBase.Load <RuntimeConfig>(); }