private void CheckPlatforms( PlatformHelper helper, string expectedPlatforms, string checkPlatforms ) { string[] expected = expectedPlatforms.Split( new char[] { ',' } ); string[] check = checkPlatforms.Split( new char[] { ',' } ); foreach( string testPlatform in check ) { bool shouldPass = false; foreach( string platform in expected ) if ( shouldPass = platform.ToLower() == testPlatform.ToLower() ) break; bool didPass = helper.IsPlatformSupported( testPlatform ); if ( shouldPass && !didPass ) Assert.Fail( "Failed to detect {0}", testPlatform ); else if ( didPass && !shouldPass ) Assert.Fail( "False positive on {0}", testPlatform ); else if ( !shouldPass && !didPass ) Assert.AreEqual( "Only supported on " + testPlatform, helper.Reason ); } }
internal static TAttribute GetCustomAttribute <TAttribute>(Type element) where TAttribute : Attribute { return(PlatformHelper.GetCustomAttribute <TAttribute>(element, true)); }
public void ConstantsCheck() { // The constants are file paths for frameworks / dylibs // unless the latest OS is used there's likely to be missing ones // so we run this test only on the latest supported (matching SDK) OS var sdk = new Version(Constants.SdkVersion); #if MONOMAC if (!PlatformHelper.CheckSystemVersion(sdk.Major, sdk.Minor)) #elif __WATCHOS__ if (!WatchKit.WKInterfaceDevice.CurrentDevice.CheckSystemVersion(sdk.Major, sdk.Minor)) #else if (!UIDevice.CurrentDevice.CheckSystemVersion(sdk.Major, sdk.Minor)) #endif { Assert.Ignore($"Constants only verified using the latest OS version ({sdk.Major}.{sdk.Minor})"); } var c = typeof(Constants); foreach (var fi in c.GetFields()) { if (!fi.IsPublic) { continue; } var s = fi.GetValue(null) as string; switch (fi.Name) { case "Version": case "SdkVersion": Assert.True(Version.TryParse(s, out _), fi.Name); break; #if !XAMCORE_4_0 #if __TVOS__ case "PassKitLibrary": // not part of tvOS break; #endif case "libcompression": // bad (missing) suffix Assert.True(CheckLibrary(s), fi.Name); break; #endif #if !__MACOS__ case "ChipLibrary": case "ThreadNetworkLibrary": case "MediaSetupLibrary": case "MLComputeLibrary": // Xcode 12 beta 2 does not ship these framework/headers for the simulators if (Runtime.Arch == Arch.DEVICE) { Assert.True(CheckLibrary(s), fi.Name); } break; #endif #if __TVOS__ case "MetalPerformanceShadersLibrary": // not supported in tvOS (12.1) simulator so load fails if (Runtime.Arch == Arch.SIMULATOR) { break; } goto default; #endif default: if (fi.Name.EndsWith("Library", StringComparison.Ordinal)) { #if __IOS__ if (fi.Name == "CoreNFCLibrary") { // NFC is currently not available on iPad if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { continue; } // Phone works unless Xcode 12 on simulator if ((Runtime.Arch == Arch.SIMULATOR) && TestRuntime.CheckXcodeVersion(12, 0)) { continue; } } #endif #if __MACOS__ // Only available in macOS 10.15.4+ if (fi.Name == "AutomaticAssessmentConfigurationLibrary" && !TestRuntime.CheckXcodeVersion(11, 4)) { continue; } #endif #if __WATCHOS__ // added with watchOS 4 (mistake) if (fi.Name == "VisionLibrary") { continue; } #endif Assert.True(CheckLibrary(s), fi.Name); } else { Assert.Fail($"Unknown '{fi.Name}' field cannot be verified - please fix me!"); } break; } } }
public void ResetTipOk() { PlatformHelper.RestartApp(); }
/// <summary> /// Converts a string to a Date value. /// </summary> /// <param name="text">String text to convert.</param> /// <param name="targetValue">After invocation, converted value.</param> /// <returns>true if the value was converted; false otherwise.</returns> internal static bool TryUriStringToDate(string text, out Date targetValue) { return(PlatformHelper.TryConvertStringToDate(text, out targetValue)); }
private bool EnterScene(int sceneId) { PlatformHelper.UMEvent("SceneChange", sceneId.ToString()); //如果目标场景一致,就不用再加载资源了 if (GameLogic.Instance != null && GameLogic.Instance.Scene != null && GameLogic.Instance.Scene.SceneTypeId == sceneId) { var player = ObjManager.Instance.MyPlayer; if (null == player) { Logger.Error("EnterScene null == player"); return(false); } Logger.Debug("Resume to this scene."); ObjManager.Instance.RemoveObjExceptPlayer(); player.StopMove(); player.RemoveAllBuff(); //服务端会重新同步buff player.LeaveAutoCombat(); ChangeSceneOver(); mIsLoadSceneOver = true; return(true); } //判断目标场景资源和当前场景资源是否一样,如果一样就不Load直接把当前Obj删除掉,等服务端同步来新的Obj do { var player = ObjManager.Instance.MyPlayer; //判断必要条件 if (null == player || null == GameLogic.Instance) { break; } //判断当前场景 if (GameLogic.Instance.Scene == null) { break; } var table1 = Table.GetScene(GameLogic.Instance.Scene.SceneTypeId); var table2 = Table.GetScene(sceneId); if (null == table1 || null == table2) { break; } //是同一个场景资源 if (0 != table1.ResName.CompareTo(table2.ResName)) { break; } var isPhaseDungeon = false; { var fuben1 = Table.GetFuben(table1.FubenId); if (null != fuben1) { if (eDungeonAssistType.PhaseDungeon == (eDungeonAssistType)fuben1.AssistType) { isPhaseDungeon = true; } } if (!isPhaseDungeon) { var fuben2 = Table.GetFuben(table2.FubenId); if (null != fuben2) { if (eDungeonAssistType.PhaseDungeon == (eDungeonAssistType)fuben2.AssistType) { isPhaseDungeon = true; } } } } //是否有其中一个是相位副本 if (!isPhaseDungeon) { break; } ObjManager.Instance.RemoveObjExceptPlayer(); CurrentSceneTypeId = sceneId; GameLogic.Instance.Scene.ClearLastScene(false); GameLogic.Instance.Scene.LoadTable(); var data = PlayerDataManager.Instance.mInitBaseAttr; var pos = GameLogic.GetTerrainPosition(data.X, data.Y); player.StopMove(); player.RemoveAllBuff(); //服务端会重新同步buff player.LeaveAutoCombat(); //如果是相位副本,就自动战斗 if (-1 != GameLogic.Instance.Scene.TableScene.FubenId) { var tableFuben = Table.GetFuben(GameLogic.Instance.Scene.TableScene.FubenId); if (null != tableFuben) { if (eDungeonAssistType.PhaseDungeon == (eDungeonAssistType)tableFuben.AssistType) { player.EnterAutoCombat(); } } } else { //如果是出副本,就自动交任务 MissionManager.Instance.OnEnterNormalScene(); } player.Position = pos; //通知服务端客户端已经切完了 ChangeSceneOver(); EventDispatcher.Instance.DispatchEvent(new RefresSceneMap(sceneId)); EventDispatcher.Instance.DispatchEvent(new SceneTransition_Event()); Logger.Debug("Resume to this scene."); OnLoadSceneOver(); return(true); } while (false); Logger.Debug("Loading new scene."); var tbscene = Table.GetScene(sceneId); if (tbscene == null) { var log = string.Format("ERROR::!Table.Scene.ContainsKey({0})", sceneId); Logger.Info(log); return(false); } //放在GameLogic的Destroy里了 //ObjManager.Instance.RemoveAllObj(); //UIManager.Instance.Destroy(); //ComplexObjectPool.Destroy(); if (GameLogic.Instance != null) { if (GameLogic.Instance.Scene != null) { GameLogic.Instance.Scene.ClearLastScene(); } } CurrentSceneTypeId = sceneId; ++EnterSceneCounter; var sceneName = tbscene.ResName; //Logger.Info("---------------{" + sceneName + "}-------------"); Application.LoadLevel("Loading"); return(true); }
public static void Initialize(bool enableInternalLogger = false, bool enableInternalDebugLogger = false) { InternalLogger.EnableLogger(enableInternalLogger, enableInternalDebugLogger); PlatformHelper.InitializeSingleton(new iOSPlatformHelper()); iOSHorizontalListViewRenderer.Initialize(); }
public ActionResult GSheet(string gSheetUrl) { //gSheetUrl = // "https://docs.google.com/spreadsheets/d/1MXehuMdxTRZusvJdQhoz4PBlIQY5-V43K96SaKHNTlE/edit#gid=0"; var leads = Helpers.GSheetHelper.GetContactInfoFromGSheet(gSheetUrl); if (leads == null) { return(RedirectToAction("Index")); } var jobLevels = dbNew.JobLevels.ToList(); foreach (var lead in leads) { var contact = dbNew.Contacts.FirstOrDefault(c => c.email == lead.Email); if (lead.Email != "") { if (contact == null) { contact = new Contact(); contact.email = lead.Email; dbNew.Contacts.Add(contact); dbNew.Entry(contact).State = EntityState.Added; } else { dbNew.Entry(contact).State = EntityState.Modified; } contact.first_name = lead.FirstName; contact.last_name = lead.LastName; contact.prooflink = lead.Prooflink; if (lead.Country != "") { var country = dbNew.Countries.FirstOrDefault(countr => countr.Name == lead.Country); if (country != null) { contact.Country = country; } } if (lead.Title != "") { var title = dbNew.Titles.FirstOrDefault(t => t.Name == lead.Title); if (title == null) { title = new Title { Name = lead.Title }; var jobLevel = dbNew.JobLevels.FirstOrDefault(jl => lead.Title.Contains(jl.Name)); if (jobLevel == null) { jobLevel = jobLevels.FirstOrDefault(jl => PlatformHelper.FindByParts(lead.Title, jl.Name)); } if (jobLevel != null) { title.JobLevel = jobLevel; } dbNew.Titles.Add(title); dbNew.Entry(title).State = EntityState.Added; } contact.Title = title; } } if (lead.Company != "") { var company = dbNew.Companies.FirstOrDefault(comp => comp.name == lead.Company); if (company == null) { company = new Company(); company.name = lead.Company; dbNew.Companies.Add(company); dbNew.Entry(company).State = EntityState.Added; } else { dbNew.Entry(company).State = EntityState.Modified; } if (!String.IsNullOrEmpty(lead.Industry)) { var industry = dbNew.Industries.FirstOrDefault(ind => ind.Name == lead.Industry); if (industry == null) { var aliasIndustry = dbNew.IndustryAliases.Include(indAlias => indAlias.Industry).FirstOrDefault(indAlias => indAlias.Name == lead.Industry); if (aliasIndustry == null) { dbNew.IndustryAliases.Add(new IndustryAlias { Name = lead.Industry }); } else if (aliasIndustry.Industry != null) { company.Industries.Add(aliasIndustry.Industry); company.PrimaryIndustry = aliasIndustry.Industry; } } else { company.Industries.Add(industry); company.PrimaryIndustry = industry; } } company.SetDomain(lead.Email); company.employees_prooflink = lead.EmpployeesProoflink; company.revenue_prooflink = lead.RevenueProoflink; company.SetMinMaxEmployees(lead.Employees); company.SetMinMaxRevenue(lead.Revenue); if (contact != null) { contact.Company = company; } } /*if (lead.Title != "") * { * var title = dbNew.Titles.FirstOrDefault(t => t.Name == lead.Title); * if (title == null) * { * title = new Title(); * title.Name = lead.Title; * dbNew.Titles.Add(title); * dbNew.Entry(title).State = EntityState.Added; * } * * if (contact != null) * { * contact.Title = title; * } * }*/ dbNew.SaveChanges(); } return(RedirectToAction("Index")); }
/// <summary> /// 攻击按钮 /// </summary> /// <param name="skillId">技能Id</param> /// <returns></returns> public bool OnAttackBtnClick(int skillId, bool selectTarget = true) { Logger.Info("OnAttackBtnClick SkillID = " + skillId); PlatformHelper.Event("Skill", "Manual", skillId); var myself = ObjManager.Instance.MyPlayer; //表格数据 var data = Table.GetSkill(skillId); if (data == null) { return(false); } if (selectTarget) { TargetObj = ObjManager.Instance.SelectTargetForSkill(myself, data); } //目标类型 var targetType = (SkillTargetType)ObjMyPlayer.GetSkillData_Data(data, eModifySkillType.TargetType); if (targetType == SkillTargetType.SELF || targetType == SkillTargetType.CIRCLE) { return(UseSkill(myself.GetObjId(), skillId)); } if (targetType == SkillTargetType.SECTOR) { var targetObj = TargetObj; if (targetObj != null) { myself.FaceTo(targetObj.Position); return(UseSkill(myself.GetObjId(), skillId, targetObj.GetObjId())); } return(UseSkill(myself.GetObjId(), skillId)); } if (targetType == SkillTargetType.RECT) { var targetObj = TargetObj; if (targetObj != null) { myself.FaceTo(targetObj.Position); return(UseSkill(myself.GetObjId(), skillId)); } return(UseSkill(myself.GetObjId(), skillId)); } if (targetType == SkillTargetType.SINGLE || targetType == SkillTargetType.TARGET_CIRCLE || targetType == SkillTargetType.TARGET_RECT || targetType == SkillTargetType.TARGET_SECTOR) { var targetObj = TargetObj; if (targetObj == null || targetObj.Dead) { targetObj = ObjManager.Instance.SelectNearestCharacter(ObjManager.Instance.MyPlayer.Position, character => !character.Dead && ObjManager.Instance.MyPlayer.IsMyEnemy(character)); } if (null == targetObj || targetObj.Dead) { EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(713)); return(false); } return(SelectTarget(targetObj.gameObject, skillId)); } Logger.Info("Unknow target type[{0}]", targetType); return(false); return(false); }
private void BuildDependenciesHelpText(IEnumerable <Type> types, StringBuilder sb, List <TestParameterInfo> parameterInfos) { var selectors = new Dictionary <Type, Dictionary <string, Type> >(); var selectorArguments = new Dictionary <Type, ImplementationSelectorAttribute>(); this.CalculateAttributeMap(types, selectors, selectorArguments); sb.AppendLine("The following parameters can be used to specify which components should be used:"); sb.AppendLine(); foreach (var k in selectors.OrderBy(t => selectorArguments[t.Key].TestArgumentName)) { var contractType = k.Key; var isa = selectorArguments[contractType]; var possibleOptions = k.Value; string testArgumentName = isa.TestArgumentName; if (possibleOptions.Count > 1 || (!isa.IsRequired && isa.DefaultImplementation == null)) { sb.AppendFormat( CultureInfo.InvariantCulture, "{0}: {1}{2}{3} {4}. Possible values:", testArgumentName, isa.IsRequired ? " (required)" : string.Empty, isa.IsGlobal ? " (global)" : string.Empty, isa.IsTransient ? " (transient)" : string.Empty, isa.HelpText).AppendLine(); var possibleValuesList = new List <KeyValuePair <string, string> >(); foreach (var option in possibleOptions.OrderBy(c => c.Key)) { string helpText = null; var ina = PlatformHelper.GetCustomAttribute <ImplementationNameAttribute>(option.Value); if (ina != null) { helpText = ina.HelpText; } sb.AppendFormat(CultureInfo.InvariantCulture, " {0}{1}{2}", option.Key.PadRight(20), (isa.DefaultImplementation == option.Key) ? "[*DEFAULT*] " : string.Empty, helpText); sb.AppendLine(); possibleValuesList.Add(new KeyValuePair <string, string>(option.Key, helpText)); } if (isa.DefaultImplementation == null) { sb.Append(" (the default is to use none)").AppendLine(); } var tpi = new TestParameterInfo { ParameterName = testArgumentName, ParameterCategory = "Dependencies", HelpText = isa.HelpText, DefaultValue = isa.DefaultImplementation, CurrentValue = isa.DefaultImplementation, PossibleValues = new IndexedKeyValuePairCollection(possibleValuesList.ToList()), }; tpi.PossibleValues.SelectedIndex = possibleValuesList.Select(p => p.Key).ToList().IndexOf(tpi.CurrentValue); parameterInfos.Add(tpi); } } }
public static void Main(string[] args) { if (Thread.CurrentThread.Name != "Main Thread") { Thread.CurrentThread.Name = "Main Thread"; } if (File.Exists("BuildIsXNA.txt")) { File.Delete("BuildIsXNA.txt"); } if (File.Exists("BuildIsFNA.txt")) { File.Delete("BuildIsFNA.txt"); } File.WriteAllText($"BuildIs{(typeof(Game).Assembly.FullName.Contains("FNA") ? "FNA" : "XNA")}.txt", ""); // macOS is FUN. if (PlatformHelper.Is(MonoMod.Utils.Platform.MacOS)) { // https://github.com/mono/mono/blob/79b6e3f256a59ede74596ce82547f320bf1e9a99/mono/metadata/filewatcher.c#L66 Environment.SetEnvironmentVariable("MONO_DARWIN_USE_KQUEUE_FSW", "1"); } if (File.Exists("everest-launch.txt")) { args = File.ReadAllLines("everest-launch.txt") .Select(l => l.Trim()) .Where(l => !l.StartsWith("#")) .SelectMany(l => l.Split(' ')) .Concat(args) .ToArray(); } else { using (StreamWriter writer = File.CreateText("everest-launch.txt")) { writer.WriteLine("# Add any Everest launch flags here."); writer.WriteLine("# Lines starting with # are ignored."); writer.WriteLine("# All options here are disabled by default."); writer.WriteLine(); writer.WriteLine("# Windows only: open a separate log console window."); writer.WriteLine("#--console"); writer.WriteLine(); writer.WriteLine("# FNA only: force OpenGL (might be necessary to bypass a load crash on some PCs)."); writer.WriteLine("#--graphics OpenGL"); writer.WriteLine(); if (File.Exists("launch.txt")) { using (StreamReader reader = File.OpenText("launch.txt")) { writer.WriteLine(); writer.WriteLine(); writer.WriteLine("# The following options are migrated from the old launch.txt and force-disabled."); writer.WriteLine("# Some of them might not work anymore or cause unwanted effects."); writer.WriteLine(); writer.WriteLine(); for (string line; (line = reader.ReadLine()) != null;) { writer.Write("#"); writer.WriteLine(line); } } File.Delete("launch.txt"); } } } if (File.Exists("everest-env.txt")) { foreach (string line in File.ReadAllLines("everest-env.txt")) { if (line.StartsWith("#")) { continue; } int index = line.IndexOf('='); if (index == -1) { continue; } string key = line.Substring(0, index).Trim(); if (key.StartsWith("'") && key.EndsWith("'")) { key = key.Substring(1, key.Length - 2); } string value = line.Substring(index + 1).Trim(); if (value.StartsWith("'") && value.EndsWith("'")) { value = value.Substring(1, value.Length - 2); } if (key.EndsWith("!")) { key = key.Substring(0, key.Length - 1); } else { value = value .Replace("\\r", "\r") .Replace("\\n", "\n") .Replace($"${{{key}}}", Environment.GetEnvironmentVariable(key) ?? ""); } Environment.SetEnvironmentVariable(key, value); } } if (args.Contains("--console") && PlatformHelper.Is(MonoMod.Utils.Platform.Windows)) { AllocConsole(); } if (args.Contains("--nolog")) { MainInner(args); return; } if (File.Exists("log.txt")) { if (new FileInfo("log.txt").Length > 0) { // move the old log.txt to the LogHistory folder. // note that the cleanup will only be done when the core module is loaded: the settings aren't even loaded right now, // so we don't know how many files we should keep. if (!Directory.Exists("LogHistory")) { Directory.CreateDirectory("LogHistory"); } File.Move("log.txt", Path.Combine("LogHistory", LogRotationHelper.GetFileNameByDate(File.GetLastWriteTime("log.txt")))); } else { // log is empty! (this actually happens more often than you'd think, because of Steam re-opening Celeste) // just delete it. File.Delete("log.txt"); } } using (Stream fileStream = new FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete)) using (StreamWriter fileWriter = new StreamWriter(fileStream, Console.OutputEncoding)) using (LogWriter logWriter = new LogWriter { STDOUT = Console.Out, File = fileWriter }) { try { Console.SetOut(logWriter); MainInner(args); } finally { if (logWriter.STDOUT != null) { Console.SetOut(logWriter.STDOUT); logWriter.STDOUT = null; } } } }
/// <summary> /// Loads the projects from the file system and stores them in an /// instance variable. /// </summary> /// <param name="gacCache"><see cref="GacCache" /> instance to use to determine whether an assembly is located in the Global Assembly Cache.</param> /// <param name="refResolver"><see cref="ReferencesResolver" /> instance to use to determine location and references of assemblies.</param> /// <param name="explicitProjectDependencies">TODO</param> /// <exception cref="BuildException">A project GUID in the solution file does not match the actual GUID of the project in the project file.</exception> protected void LoadProjects(GacCache gacCache, ReferencesResolver refResolver, Hashtable explicitProjectDependencies) { Log(Level.Verbose, "Loading projects..."); FileSet excludes = _solutionTask.ExcludeProjects; foreach (ProjectEntry projectEntry in ProjectEntries) { string projectPath = projectEntry.Path; string projectGuid = projectEntry.Guid; // determine whether project is on case-sensitive filesystem, bool caseSensitive = PlatformHelper.IsVolumeCaseSensitive(projectPath); // indicates whether the project should be skipped (excluded) bool skipProject = false; // check whether project should be excluded from build foreach (string excludedProjectFile in excludes.FileNames) { if (string.Compare(excludedProjectFile, projectPath, !caseSensitive, CultureInfo.InvariantCulture) == 0) { Log(Level.Verbose, "Excluding project '{0}'.", projectPath); // do not load project skipProject = true; // we have a match, so quit looking break; } } if (skipProject) { // remove dependencies for excluded projects if (explicitProjectDependencies.ContainsKey(projectGuid)) { explicitProjectDependencies.Remove(projectGuid); } // project was excluded, move on to next project continue; } Log(Level.Verbose, "Loading project '{0}'.", projectPath); ProjectBase p = _solutionTask.ProjectFactory.LoadProject(this, _solutionTask, _tfc, gacCache, refResolver, _outputDir, projectPath); if (p == null) { Log(Level.Warning, "Project '{0}' is of unsupported type. Skipping.", projectPath); // skip the project continue; } if (p.Guid == null || p.Guid.Length == 0) { p.Guid = FindGuidFromPath(projectPath); } // add project to entry projectEntry.Project = p; // set project build configuration SetProjectBuildConfiguration(projectEntry); } // add explicit dependencies (as set in VS.NET) to individual projects foreach (DictionaryEntry dependencyEntry in explicitProjectDependencies) { string projectGuid = (string)dependencyEntry.Key; Hashtable dependencies = (Hashtable)dependencyEntry.Value; ProjectEntry projectEntry = ProjectEntries[projectGuid]; if (projectEntry == null) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Dependencies for project \'{0}\' could not be analyzed." + " Project is not included.", projectGuid), Location.UnknownLocation); } ProjectBase project = projectEntry.Project; // make sure project is loaded if (project == null) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Dependencies for project \'{0}\' could not be analyzed." + " Project is not loaded.", projectGuid), Location.UnknownLocation); } foreach (string dependentProjectGuid in dependencies.Keys) { ProjectEntry dependentEntry = ProjectEntries[dependentProjectGuid]; if (dependentEntry == null || dependentEntry.Project == null) { Log(Level.Warning, "Project \"{0}\": ignored dependency" + " on project \"{1}\", which is not included.", project.Name, dependentProjectGuid); continue; } project.ProjectDependencies.Add(dependentEntry.Project); } } }
private IEnumerator CommitMissionCoroutine(int id) { using (new BlockingLayerHelper(0)) { var msg = NetManager.Instance.CommitMission(id); yield return(msg.SendAndWaitUntilDone()); if (msg.State != MessageState.Reply) { Logger.Debug("MessageState.Reply CommitMissionCoroutine mission[{0}]", msg.State); yield break; } var errorCode = (ErrorCodes)msg.ErrorCode; if (ErrorCodes.OK != errorCode) { Logger.Debug("CommitMissionCoroutine ErrorCode[{0}] mission[{1}]", msg.ErrorCode, id); if (ErrorCodes.Error_NotHaveMission == errorCode) { PlayerDataManager.Instance.ApplyMissions(-1); EventDispatcher.Instance.DispatchEvent(new Close_UI_Event(UIConfig.MissionFrame)); } else // if (ErrorCodes.Error_ItemNoInBag_All == errorCode) { EventDispatcher.Instance.DispatchEvent(new UIEvent_ErrorTip(errorCode)); } yield break; } //删除已经提交的任务 if (null != MissionData) { MissionData.Datas.Remove(id); } //原有任务数据 var data = Instance.MissionData.Datas; //交完任务后服务端同步过来变化的任务 var missions = msg.Response.Missions; //收集一下新的可接的任务 var listAcceptableMission = new List <int>(); { // foreach(var pair in missions) var __enumerator4 = (missions).GetEnumerator(); while (__enumerator4.MoveNext()) { var pair = __enumerator4.Current; { var newMission = pair.Value; MissionBaseModel mission = null; if (!data.TryGetValue(newMission.MissionId, out mission)) { mission = new MissionBaseModel { MissionId = newMission.MissionId }; data.Add(newMission.MissionId, mission); } //收集一下新的可接的任务 if (eMissionState.Acceptable == (eMissionState)newMission.Exdata[0]) { listAcceptableMission.Add(mission.MissionId); } for (var i = 0; i != 5; ++i) { mission.Exdata[i] = newMission.Exdata[i]; } } } } //if (id != msg.Response) //{ // Logger.Debug("Response[{0}] != mission[{1}]", msg.Response, id); // id = msg.Response; //} EventDispatcher.Instance.DispatchEvent(new Event_UpdateMissionData()); Logger.Debug("Complete mission[{0}]", id); PlatformHelper.UMEvent("Mission", "Complete", id); OnCommitMission(id, listAcceptableMission); } }
public IEnumerator StoreBuyCoroutine(int index, int count = 1) { using (new BlockingLayerHelper(0)) { var msg = NetManager.Instance.StoreBuy(index, count, mServiceType); yield return(msg.SendAndWaitUntilDone()); if (msg.State == MessageState.Reply) { OnClickBuyInfoClose(); if (msg.ErrorCode == (int)ErrorCodes.OK) { var tbStore = Table.GetStore(index); //购买成功 EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(431)); var cellData = GetCellData(index); if (cellData.ExData != -1) { cellData.Limit -= count; if (cellData.Limit <= 0) { cellData.CanUse = false; } //钻石商城和绑钻商城通用相同扩展数据,同步刷新限购次数。 if (DataModel.StoreType == 15 || DataModel.StoreType == 16) { var type = DataModel.StoreType == 15 ? 16 : 15; if (mStoreCache.ContainsKey(type)) { foreach (var item in mStoreCache[type]) { if (item.ItemId == tbStore.ItemId) { item.Limit = cellData.Limit; item.CanUse = cellData.CanUse; break; } } } } } if (tbStore == null) { yield break; } var flagId = tbStore.BugSign; if (flagId != -1) { var flag = PlayerDataManager.Instance.GetFlag(flagId); if (flag == false) { PlayerDataManager.Instance.SetFlag(flagId, true); UpdateStoreList(); } } if (DataModel.StoreType == 15) { PlatformHelper.UMEvent("DiamondShopExpend", tbStore.Name.ToString(), tbStore.NeedValue * count); } PlatformHelper.UMEvent("BuyItem", tbStore.Name.ToString(), count); } else if (msg.ErrorCode == (int)ErrorCodes.Error_ItemNoInBag_All) { var e = new ShowUIHintBoard(430); EventDispatcher.Instance.DispatchEvent(e); } else { UIManager.Instance.ShowNetError(msg.ErrorCode); Logger.Error("StoreBuy....StoreId= {0}...ErrorCode...{1}", index, msg.ErrorCode); } } else { Logger.Error("StoreBuy............State..." + msg.State); } } }
public virtual void Restart() { PlatformHelper.RunApplication(Path.Combine(StoragePaths.AppFolder, StoragePaths.AppEntryFile), string.Empty); }
bool Skip(Type t) { switch (t.Name) { case "IKPictureTaker": // radar://29311598 case "AVAssetResourceLoader": case "AVAssetResourceLoadingRequest": case "AVAssetResourceLoadingContentInformationRequest": case "SCNRenderer": case "NSStream": case "NSSharingServicePicker": case "NSCache": case "NSToolbar": case "NSComboBox": case "NSComboBoxCell": case "IKScannerDeviceView": case "NSUserActivity": case "NSFontPanel": case "AVAudioRecorder": case "MKMapView": case "SKScene": case "NSSpeechRecognizer": case "NSClickGestureRecognizer": case "NSPopover": // These classes don't do well when you instance them without support return(true); case "SCNLayer": case "SCNProgram": if (Asserts.IsAtLeastElCapitan && IntPtr.Size == 4) { return(true); } break; case "CBCentralManager": if (IntPtr.Size == 4 && PlatformHelper.CheckSystemVersion(10, 13)) // Removed from 32-bit in macOS 10.13 { return(true); } break; case "AVCaptureView": // Deallocating a AVCaptureView makes it trigger a permission dialog, which we don't want, so just skip this type. return(true); case "GKGameCenterViewController": // the native 'init' method returned nil. if (PlatformHelper.CheckSystemVersion(11, 0)) { return(true); } break; case "SKView": // on vms results on a crash return(TestRuntime.IsVM); } switch (t.Namespace) { case "QTKit": return(true); // QTKit has been removed from macos. } return(false); }
private string GetShellCommandPrefix() { return(PlatformHelper.IsWindows() ? "/c " : ""); }
public async Task Mastery(string region, string summonerName, string championName) { RiotData data = new RiotData(); RiotClient riotClient = new RiotClient(OptionManager.RiotKey); DataLibrary.Champion champion = null; Discord.EmbedBuilder builder = null; var championList = data.Champions.Where(x => x.name.ToLower().Equals(championName.ToLower())).ToList(); if (championList.Count < 1) { championList = new RiotData().Champions.Where(x => x.name.ToLower().Contains(championName.ToLower())) .ToList(); } champion = championList[0]; if (champion != null) { var summoner = riotClient.Summoner.GetSummonerByName(summonerName, PlatformHelper.StringToPlatform(region)); var masteries = riotClient.Masteries.GetchampionMasteries(PlatformHelper.StringToPlatform(region), summoner.SummonerId); var championMastery = masteries.FirstOrDefault(x => x.ChampionId == champion.ChampionId); builder = Builders.BaseBuilder($"{summoner.Name} mastery for {champion.name}", "", Color.DarkBlue, null, $"http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/{champion.key}.png"); builder.AddInlineField("Level", championMastery.Level); builder.AddInlineField("Points", championMastery.ChampionPoints); } else { builder = Builders.ErrorBuilder("Champion was not found"); } await ReplyAsync("", embed : builder.Build()); }
public static void Main(string[] args) { CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Log.Start(LogTypes.All); CUOEnviroment.GameThread = Thread.CurrentThread; CUOEnviroment.GameThread.Name = "CUO_MAIN_THREAD"; #if !DEBUG AppDomain.CurrentDomain.UnhandledException += (s, e) => { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine("######################## [START LOG] ########################"); #if DEV_BUILD sb.AppendLine($"ClassicUO [DEV_BUILD] - {CUOEnviroment.Version} - {DateTime.Now}"); #else sb.AppendLine($"ClassicUO [STANDARD_BUILD] - {CUOEnviroment.Version} - {DateTime.Now}"); #endif sb.AppendLine ($"OS: {Environment.OSVersion.Platform} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}"); sb.AppendLine($"Thread: {Thread.CurrentThread.Name}"); sb.AppendLine(); if (Settings.GlobalSettings != null) { sb.AppendLine($"Shard: {Settings.GlobalSettings.IP}"); sb.AppendLine($"ClientVersion: {Settings.GlobalSettings.ClientVersion}"); sb.AppendLine(); } sb.AppendFormat("Exception:\n{0}\n", e.ExceptionObject); sb.AppendLine("######################## [END LOG] ########################"); sb.AppendLine(); sb.AppendLine(); Log.Panic(e.ExceptionObject.ToString()); string path = Path.Combine(CUOEnviroment.ExecutablePath, "Logs"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (LogFile crashfile = new LogFile(path, "crash.txt")) { crashfile.WriteAsync(sb.ToString()).RunSynchronously(); } }; #endif ReadSettingsFromArgs(args); #if DEV_BUILD if (!_skipUpdates) { Network.Updater updater = new Network.Updater(); if (updater.Check()) { return; } } #endif if (!_skipUpdates) { if (CheckUpdate(args)) { return; } } if (CUOEnviroment.IsHighDPI) { Environment.SetEnvironmentVariable("FNA_GRAPHICS_ENABLE_HIGHDPI", "1"); } Environment.SetEnvironmentVariable("FNA3D_BACKBUFFER_SCALE_NEAREST", "1"); Environment.SetEnvironmentVariable("FNA3D_OPENGL_FORCE_COMPATIBILITY_PROFILE", "1"); Environment.SetEnvironmentVariable(SDL.SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + Path.Combine(CUOEnviroment.ExecutablePath, "Data", "Plugins")); string globalSettingsPath = Settings.GetSettingsFilepath(); if (!Directory.Exists(Path.GetDirectoryName(globalSettingsPath)) || !File.Exists(globalSettingsPath)) { // settings specified in path does not exists, make new one { // TODO: Settings.GlobalSettings.Save(); } } Settings.GlobalSettings = ConfigurationResolver.Load <Settings>(globalSettingsPath); CUOEnviroment.IsOutlands = Settings.GlobalSettings.ShardType == 2; ReadSettingsFromArgs(args); // still invalid, cannot load settings if (Settings.GlobalSettings == null) { Settings.GlobalSettings = new Settings(); Settings.GlobalSettings.Save(); } if (!CUOEnviroment.IsUnix) { string libsPath = Path.Combine(CUOEnviroment.ExecutablePath, Environment.Is64BitProcess ? "x64" : "x86"); SetDllDirectory(libsPath); } if (string.IsNullOrWhiteSpace(Settings.GlobalSettings.UltimaOnlineDirectory)) { Settings.GlobalSettings.UltimaOnlineDirectory = CUOEnviroment.ExecutablePath; } const uint INVALID_UO_DIRECTORY = 0x100; const uint INVALID_UO_VERSION = 0x200; uint flags = 0; if (!Directory.Exists(Settings.GlobalSettings.UltimaOnlineDirectory) || !File.Exists(UOFileManager.GetUOFilePath("tiledata.mul"))) { flags |= INVALID_UO_DIRECTORY; } string clientVersionText = Settings.GlobalSettings.ClientVersion; if (!ClientVersionHelper.IsClientVersionValid(Settings.GlobalSettings.ClientVersion, out ClientVersion clientVersion)) { Log.Warn($"Client version [{clientVersionText}] is invalid, let's try to read the client.exe"); // mmm something bad happened, try to load from client.exe [windows only] if (!ClientVersionHelper.TryParseFromFile(Path.Combine(Settings.GlobalSettings.UltimaOnlineDirectory, "client.exe"), out clientVersionText) || !ClientVersionHelper.IsClientVersionValid(clientVersionText, out clientVersion)) { Log.Error("Invalid client version: " + clientVersionText); flags |= INVALID_UO_VERSION; } else { Log.Trace($"Found a valid client.exe [{clientVersionText} - {clientVersion}]"); // update the wrong/missing client version in settings.json Settings.GlobalSettings.ClientVersion = clientVersionText; } } if (flags != 0) { if ((flags & INVALID_UO_DIRECTORY) != 0) { Client.ShowErrorMessage(ResGeneral.YourUODirectoryIsInvalid); } else if ((flags & INVALID_UO_VERSION) != 0) { Client.ShowErrorMessage(ResGeneral.YourUOClientVersionIsInvalid); } PlatformHelper.LaunchBrowser(ResGeneral.ClassicUOLink); } else { switch (Settings.GlobalSettings.ForceDriver) { case 1: // OpenGL Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", "OpenGL"); break; case 2: // Vulkan Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", "Vulkan"); break; } Client.Run(); } Log.Trace("Closing..."); }
/// <summary> /// Returns true if a JumpList can be instantiated at this time. /// </summary> public static bool CanShowJumpList() { return(PlatformHelper.RunningOnWin7OrHigher()); }
public static void Main(string[] args) { Thread.CurrentThread.Name = "Main Thread"; if (File.Exists("launch.txt")) { args = File.ReadAllLines("launch.txt") .Select(l => l.Trim()) .Where(l => !l.StartsWith("#")) .SelectMany(l => l.Split(' ')) .Concat(args) .ToArray(); } else { using (StreamWriter writer = File.CreateText("launch.txt")) { writer.WriteLine("# Add any Everest launch flags here. Lines starting with # are ignored."); writer.WriteLine(); writer.WriteLine("# If you're having graphics issues with the FNA version on Windows,"); writer.WriteLine("# remove the # from the following line to enable using Direct3D."); writer.WriteLine("#--d3d"); writer.WriteLine(); writer.WriteLine("# If you've got an Intel GPU, are using the FNA version on Windows and"); writer.WriteLine("# are 100% sure that you want to use Intel's possibly broken OpenGL drivers,"); writer.WriteLine("# remove the # from the following line to revert to using OpenGL."); writer.WriteLine("#--no-d3d"); writer.WriteLine(); } } if (args.Contains("--console") && PlatformHelper.Is(MonoMod.Utils.Platform.Windows)) { AllocConsole(); } // PlatformHelper is part of MonoMod. // Environment.OSVersion.Platform is good enough as well, but Everest consistently uses PlatformHelper. // The following is based off of https://github.com/FNA-XNA/FNA/wiki/4:-FNA-and-Windows-API#direct3d-support if (PlatformHelper.Is(MonoMod.Utils.Platform.Windows)) { bool useD3D = args.Contains("--d3d"); try { // Keep all usage of System.Management in a separate method. // Member references are resolved as soon as a method is called. // This means that if System.Management cannot be found due to // f.e. the use of MonoKickstart, this method won't even get as // far as checking the platform. if (DoesGPUHaveBadOpenGLDrivers()) { useD3D = true; } } catch { // Silently catch all exceptions: Method and type load errors, // permission / access related exceptions and whatnot. } if (args.Contains("--no-d3d")) { useD3D = false; } if (useD3D) { Environment.SetEnvironmentVariable("FNA_OPENGL_FORCE_ES3", "1"); Environment.SetEnvironmentVariable("SDL_OPENGL_ES_DRIVER", "1"); } } if (File.Exists("log.txt")) { File.Delete("log.txt"); } using (Stream fileStream = new FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete)) using (StreamWriter fileWriter = new StreamWriter(fileStream, Console.OutputEncoding)) using (LogWriter logWriter = new LogWriter { STDOUT = Console.Out, File = fileWriter }) { Console.SetOut(logWriter); try { Everest.ParseArgs(args); orig_Main(args); } catch (Exception e) { e.LogDetailed("CRITICAL"); ErrorLog.Write("OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!"); ErrorLog.Open(); return; } Everest.Events.Celeste.Shutdown(); Console.SetOut(logWriter.STDOUT); logWriter.STDOUT = null; } }
/// <summary> /// Converts the object to ODataValue, the result could be null, the original primitive object, ODataNullValue, /// ODataEnumValue, ODataCollectionValue, ODataResource, ODataEntityReferenceLinks, ODataEntityReferenceLinks, or /// a list of ODataResource. /// </summary> /// <param name="paramName">The name of the <see cref="UriOperationParameter"/>. Used for error reporting.</param> /// <param name="value">The value of the <see cref="UriOperationParameter"/>.</param> /// <param name="needsSpecialEscaping">True if the result need special escaping.</param> /// <param name="useEntityReference">If true, use entity reference, instead of entity to serialize the parameter.</param> /// <returns>The converted result.</returns> private object ConvertToODataValue(string paramName, object value, ref bool needsSpecialEscaping, bool useEntityReference) { Object valueInODataFormat = null; if (value == null) { needsSpecialEscaping = true; } else if (value is ODataNullValue) { valueInODataFormat = value; needsSpecialEscaping = true; } else { ClientEdmModel model = this.requestInfo.Model; IEdmType edmType = model.GetOrCreateEdmType(value.GetType()); Debug.Assert(edmType != null, "edmType != null"); ClientTypeAnnotation typeAnnotation = model.GetClientTypeAnnotation(edmType); Debug.Assert(typeAnnotation != null, "typeAnnotation != null"); switch (edmType.TypeKind) { case EdmTypeKind.Primitive: // Client lib internal conversion to support DateTime if (value is DateTime) { valueInODataFormat = PlatformHelper.ConvertDateTimeToDateTimeOffset((DateTime)value); } else { valueInODataFormat = value; } needsSpecialEscaping = true; break; case EdmTypeKind.Enum: string typeNameInEdm = this.requestInfo.GetServerTypeName(model.GetClientTypeAnnotation(edmType)); valueInODataFormat = new ODataEnumValue( ClientTypeUtil.GetEnumValuesString(value.ToString(), typeAnnotation.ElementType), typeNameInEdm ?? typeAnnotation.ElementTypeName); needsSpecialEscaping = true; break; case EdmTypeKind.Collection: IEdmCollectionType edmCollectionType = edmType as IEdmCollectionType; Debug.Assert(edmCollectionType != null, "edmCollectionType != null"); IEdmTypeReference itemTypeReference = edmCollectionType.ElementType; Debug.Assert(itemTypeReference != null, "itemTypeReference != null"); ClientTypeAnnotation itemTypeAnnotation = model.GetClientTypeAnnotation(itemTypeReference.Definition); Debug.Assert(itemTypeAnnotation != null, "itemTypeAnnotation != null"); valueInODataFormat = ConvertToCollectionValue(paramName, value, itemTypeAnnotation, useEntityReference); break; case EdmTypeKind.Complex: case EdmTypeKind.Entity: Debug.Assert(edmType.TypeKind == EdmTypeKind.Complex || value != null, "edmType.TypeKind == EdmTypeKind.Complex || value != null"); Debug.Assert(typeAnnotation != null, "typeAnnotation != null"); valueInODataFormat = ConvertToEntityValue(value, typeAnnotation.ElementType, useEntityReference); break; default: // EdmTypeKind.Row // EdmTypeKind.EntityReference throw new NotSupportedException(Strings.Serializer_InvalidParameterType(paramName, edmType.TypeKind)); } Debug.Assert(valueInODataFormat != null, "valueInODataFormat != null"); } return(valueInODataFormat); }
public override ImmutableArray <MSBuildInstance> GetInstances() { if (!PlatformHelper.IsMono) { return(NoInstances); } // Don't try to resolve to MSBuild assemblies under the installed Mono path unless OmniSharp // is actually running on the installed Mono runtime. The problem is that, when running standalone // on its own embedded Mono runtime, OmniSharp carries it's own "GAC" of dependencies. // And, loading Microsoft.Build.* assemblies from the installed Mono location might have different // dependencies that aren't included in OmniSharp's GAC. This can result in strange failures during // design-time build that are difficult to diagnose. However, if OmniSharp is actually running on the // installed Mono runtime, Mono's GAC will be used and dependencies will be properly located. So, in // that case we can use the Microsoft.Build.* assemblies located under the installed Mono path. var monoRuntimePath = PlatformHelper.GetMonoRuntimePath(); if (monoRuntimePath == null) { Logger.LogDebug("Could not retrieve Mono runtime path"); return(NoInstances); } string processFileName; try { processFileName = Process.GetCurrentProcess().MainModule.FileName; } catch (Exception ex) { Logger.LogDebug(ex, "Failed to retrieve current process file name"); return(NoInstances); } if (!string.Equals(processFileName, monoRuntimePath, StringComparison.OrdinalIgnoreCase)) { Logger.LogDebug("Can't use installed Mono because OmniSharp isn't running on it"); return(NoInstances); } var path = PlatformHelper.GetMonoMSBuildDirPath(); if (path == null) { return(NoInstances); } // Double-check Mono version. MSBuild support in versions earlier than 5.2.0 is // too experimental to use. var monoVersion = PlatformHelper.GetMonoVersion(); if (monoVersion == null) { Logger.LogDebug("Could not retrieve Mono version"); return(NoInstances); } if (monoVersion < new Version("5.2.0")) { Logger.LogDebug($"Found Mono MSBuild but it could not be used because it is version {monoVersion} and in needs to be >= 5.2.0"); return(NoInstances); } var toolsPath = FindMSBuildToolsPath(path); if (toolsPath == null) { Logger.LogDebug($"Mono MSBuild could not be used because an MSBuild tools path could not be found."); return(NoInstances); } // Look for Microsoft.Build.dll in the tools path. If it isn't there, this is likely a Mono layout on Linux // where the 'msbuild' package has not been installed. var microsoftBuildPath = Path.Combine(toolsPath, "Microsoft.Build.dll"); if (!File.Exists(microsoftBuildPath)) { Logger.LogDebug($"Mono MSBuild could not be used because '{microsoftBuildPath}' does not exist."); if (Platform.Current.OperatingSystem == Utilities.OperatingSystem.Linux) { Logger.LogWarning(@"It looks like you have Mono 5.2.0 or greater installed but MSBuild could not be found. Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support."); } return(NoInstances); } var propertyOverrides = ImmutableDictionary.CreateBuilder <string, string>(StringComparer.OrdinalIgnoreCase); var localMSBuildPath = FindLocalMSBuildDirectory(); if (localMSBuildPath != null) { var localRoslynPath = Path.Combine(localMSBuildPath, "Current", "Bin", "Roslyn"); propertyOverrides.Add("CscToolPath", localRoslynPath); propertyOverrides.Add("CscToolExe", "csc.exe"); } return(ImmutableArray.Create( new MSBuildInstance( nameof(DiscoveryType.Mono), toolsPath, new Version(15, 0), DiscoveryType.Mono, propertyOverrides.ToImmutable()))); }
/// <inheritdoc /> public Task <CloudMetadataResult> GetClusterMetadataAsync( string url, SocketOptions socketOptions, SSLOptions sslOptions) { #if NET452 return(GetWithWebRequestAsync(url, socketOptions, sslOptions)); #else if (PlatformHelper.RuntimeSupportsCloudTlsSettings()) { return(GetWithHttpClientAsync(url, socketOptions, sslOptions)); } throw new NotSupportedException("DataStax Astra support in .NET Core requires .NET Core 2.1 runtime or later. " + "The HTTPS implementation of .NET Core 2.0 and below don't work when some TLS settings are set. " + $"The runtime that is being used is: .NET Core {PlatformHelper.GetNetCoreVersion()}"); #endif }
/// <summary> /// Converts a string to a TimeOfDay value. /// </summary> /// <param name="text">String text to convert.</param> /// <param name="targetValue">After invocation, converted value.</param> /// <returns>true if the value was converted; false otherwise.</returns> internal static bool TryUriStringToTimeOfDay(string text, out TimeOfDay targetValue) { return(PlatformHelper.TryConvertStringToTimeOfDay(text, out targetValue)); }
/// <summary> /// Checks if Win32 functionality should be used /// </summary> public static Boolean ShouldUseWin32() { return(PlatformHelper.IsRunningOnWindows()); }
/// <summary> /// Formats the literal without a type prefix, quotes, or escaping. /// </summary> /// <param name="value">The non-null value to format.</param> /// <returns>The formatted literal, without type marker or quotes.</returns> private static string FormatRawLiteral(object value) { Debug.Assert(value != null, "value != null"); string stringValue = value as string; if (stringValue != null) { return(stringValue); } if (value is bool) { return(XmlConvert.ToString((bool)value)); } if (value is byte) { return(XmlConvert.ToString((byte)value)); } #if ODATA_SERVICE || ODATA_CLIENT if (value is DateTime) { // Since the server/client supports DateTime values, convert the DateTime value // to DateTimeOffset and use XmlConvert to convert to String. // If datetime kind is unspecified, then treat it as UTC. #if ODATA_SERVICE DateTimeOffset dto = WebUtil.ConvertDateTimeToDateTimeOffset((DateTime)value); #elif ODATA_CLIENT DateTimeOffset dto = PlatformHelper.ConvertDateTimeToDateTimeOffset((DateTime)value); #endif return(XmlConvert.ToString(dto)); } #endif if (value is decimal) { return(XmlConvert.ToString((decimal)value)); } if (value is double) { string formattedDouble = XmlConvert.ToString((double)value); formattedDouble = SharedUtils.AppendDecimalMarkerToDouble(formattedDouble); return(formattedDouble); } if (value is Guid) { return(value.ToString()); } if (value is short) { return(XmlConvert.ToString((Int16)value)); } if (value is int) { return(XmlConvert.ToString((Int32)value)); } if (value is long) { return(XmlConvert.ToString((Int64)value)); } if (value is sbyte) { return(XmlConvert.ToString((SByte)value)); } if (value is float) { return(XmlConvert.ToString((Single)value)); } byte[] array = value as byte[]; if (array != null) { return(ConvertByteArrayToKeyString(array)); } if (value is Date) { return(value.ToString()); } if (value is DateTimeOffset) { return(XmlConvert.ToString((DateTimeOffset)value)); } if (value is TimeOfDay) { return(value.ToString()); } if (value is TimeSpan) { return(EdmValueWriter.DurationAsXml((TimeSpan)value)); } Geography geography = value as Geography; if (geography != null) { return(WellKnownTextSqlFormatter.Create(true).Write(geography)); } Geometry geometry = value as Geometry; if (geometry != null) { return(WellKnownTextSqlFormatter.Create(true).Write(geometry)); } ODataEnumValue enumValue = value as ODataEnumValue; if (enumValue != null) { return(enumValue.Value); } throw SharedUtils.CreateExceptionForUnconvertableType(value); }
//查看邮件 public IEnumerator DelectMailsCoroutine(Uint64Array mails) { using (new BlockingLayerHelper(0)) { var msg = NetManager.Instance.DeleteMail(mails); yield return(msg.SendAndWaitUntilDone()); if (msg.State == MessageState.Reply) { if (msg.ErrorCode == (int)ErrorCodes.OK) { EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(418)); { var mailList = new List <MailCellData>(DataModel.MailCells.ToArray()); var list11 = mails.Items; var listCount11 = list11.Count; var isReset = false; for (var i11 = 0; i11 < listCount11; ++i11) { var mail = list11[i11]; { var data = GetMailCellData(mail); PlatformHelper.UMEvent("Mail", "Delete", data.Name); if (data == DataModel.SelectData) { isReset = true; } data.Id = 0; mailList.Remove(data); DataModel.IsSelectAll = false; } } DataModel.MailCells = new ObservableCollection <MailCellData>(mailList); DataModel.CellCount = DataModel.MailCells.Count; if (isReset && DataModel.CellCount > 0) { OnApplyMail(0); } else { ResetSelectMailInfo(); } } AnalyseNotice(); } else { UIManager.Instance.ShowNetError(msg.ErrorCode); Logger.Error("ReceiveMail Error!............ErrorCode..." + msg.ErrorCode); } } else { Logger.Error("ReceiveMail Error!............State..." + msg.State); } } }
public static bool MatchingConditionals(this ICustomAttributeProvider cap, AssemblyNameReference asmName = null) { if (cap == null) { return(true); } if (!cap.HasCustomAttributes) { return(true); } Platform plat = PlatformHelper.Current; bool status = true; foreach (CustomAttribute attrib in cap.CustomAttributes) { if (attrib.AttributeType.FullName == "MonoMod.MonoModOnPlatform") { CustomAttributeArgument[] plats = (CustomAttributeArgument[])attrib.ConstructorArguments[0].Value; for (int i = 0; i < plats.Length; i++) { if (PlatformHelper.Is((Platform)plats[i].Value)) { // status &= true; continue; } } status &= plats.Length == 0; continue; } if (attrib.AttributeType.FullName == "MonoMod.MonoModIfFlag") { string flag = (string)attrib.ConstructorArguments[0].Value; bool value; if (!InlineRT.MonoModRule.Modder.SharedData.TryGetValue(flag, out object valueObj) || !(valueObj is bool)) { if (attrib.ConstructorArguments.Count == 2) { value = (bool)attrib.ConstructorArguments[1].Value; } else { value = true; } } else { value = (bool)valueObj; } status &= value; continue; } if (attrib.AttributeType.FullName == "MonoMod.MonoModTargetModule") { string name = (string)attrib.ConstructorArguments[0].Value; status &= asmName.Name == name || asmName.FullName == name; continue; } } return(status); }
//领取邮件 public IEnumerator ReceiveMailsCoroutine(Uint64Array mails) { using (new BlockingLayerHelper(0)) { var msg = NetManager.Instance.ReceiveMail(mails); yield return(msg.SendAndWaitUntilDone()); if (msg.State == MessageState.Reply) { if (msg.ErrorCode == (int)ErrorCodes.OK) { //DataModel.IsSelectAll = false; var receieve = msg.Response; if (receieve == 0) { //您包裹已满! var e = new ShowUIHintBoard(302); EventDispatcher.Instance.DispatchEvent(e); yield break; } if (mails.Items.Count == receieve) { EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(420)); } else { //背包已满,不能领取全部邮件 GameUtils.ShowHintTip(3200006); } for (var i = 0; i < receieve; i++) { var id = mails.Items[i]; var data = GetMailCellData(id); data.State = 2; if (data.IsApply) { { // foreach(var item in data.InfoData.Items) var __enumerator10 = (data.InfoData.Items).GetEnumerator(); while (__enumerator10.MoveNext()) { var item = __enumerator10.Current; { item.ItemId = -1; item.Count = 0; } } } } PlatformHelper.UMEvent("Mail", "GetItem", data.Name); } AnalyseNotice(); } else if (msg.ErrorCode == (int)ErrorCodes.Error_MailNotFind || msg.ErrorCode == (int)ErrorCodes.Error_MailReceiveOver) { //邮件没有找到 var e = new ShowUIHintBoard(msg.ErrorCode + 200000000); EventDispatcher.Instance.DispatchEvent(e); } else { var e = new ShowUIHintBoard(msg.ErrorCode + 200000000); EventDispatcher.Instance.DispatchEvent(e); Logger.Error("ReceiveMail Error!............ErrorCode..." + msg.ErrorCode); } } else { Logger.Error("ReceiveMail Error!............State..." + msg.State); } } }
private string GetShellName() { return(PlatformHelper.IsWindows() ? "cmd" : "bash"); }
private void SaveRequest(object obj) { var platformHelper = new PlatformHelper(); platformHelper.SaveOnline(_application); }