private void FindAndDelete(string name) { if (name != null && name.Length != 0) { int hashCode = name.GetHashCode(); int count = cacheObjects.Count; for (int i = 0; i < count; i++) { CacheParam cacheParam = cacheObjects[i]; if (hashCode == cacheParam.nameHash) { Object.DestroyImmediate(cacheParam.clone); cacheObjects.Remove(cacheParam); break; } } CacheParam[] array = cacheObjects.ToArray(); count = array.Length; for (int j = 0; j < count; j++) { CacheParam cacheParam2 = array[j]; if (null == cacheParam2.clone) { cacheObjects.Remove(cacheParam2); } } } }
/// <summary> /// 写入缓存数据 /// </summary> /// <param name="param"></param> /// <returns></returns> public Task<ActionResult<string>> SetString([FromBody]CacheParam param) { //设置绝对有效期 DistributedCacheEntryOptions op = new DistributedCacheEntryOptions(); op.SetAbsoluteExpiration(new TimeSpan(0, 0, 10)); _distributedCache.SetStringAsync(param.KeyName, param.Message, op); return Task.FromResult<ActionResult<string>>(""); }
/// <summary> /// 修改对象 /// </summary> /// <param name="param"></param> /// <returns></returns> public JsonResult UpdateLog([FromBody] CacheParam param) { SysSetting sysSetting = _auditLogRepository.Get(Guid.Parse(param.Id)); sysSetting.Name = param.Message + "_修改数据1"; sysSetting.Name = param.Message + "_修改数据2"; _auditLogRepository.Update(sysSetting); return(Json(param)); }
/// <summary> /// 新增对象 /// </summary> /// <param name="param"></param> /// <returns></returns> public JsonResult InsertLog([FromBody] CacheParam param) { SysSetting sysSetting = new SysSetting() { Name = param.Message }; SysSettingDto modelInput = ObjectMapper.Map <SysSettingDto>(sysSetting); var data = _auditLogRepository.Insert(sysSetting); return(Json(data.Id)); }
/// <summary> /// 基本驱动事件 示例 /// </summary> /// <param name="param"></param> /// <returns></returns> public Task <JsonResult> DoEventAsync([FromBody] CacheParam param) { //通过事件驱动的实体对象确定所调用的事件驱动 EventDataDto dto = new EventDataDto { EventDataName = "1:创建对象" + " 2:输入值=" + param.KeyName }; //触发事件 _eventBus.TriggerAsync(this, dto); return(Task.FromResult(Json(dto.EventDataName))); }
private static Transform CreateSprites(Transform org, Transform parent, List <CacheParam> cacheObjects) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown GameObject val = new GameObject(org.get_name()); Transform val2 = val.get_transform(); UISprite component = org.GetComponent <UISprite>(); if (null != component) { UISprite uISprite = val.AddComponent <UISprite>(); uISprite.atlas = component.atlas; uISprite.spriteName = component.spriteName; uISprite.width = component.width; uISprite.height = component.height; uISprite.type = component.type; uISprite.depth = component.depth + 10000; uISprite.color = component.color; uISprite.centerType = component.centerType; uISprite.flip = component.flip; uISprite.pivot = component.pivot; } val2.SetParent(parent); val2.set_localPosition(org.get_localPosition()); val2.set_localScale(org.get_localScale()); val.set_layer(org.get_gameObject().get_layer()); val.SetActive(org.get_gameObject().get_activeSelf()); CacheParam cacheParam = new CacheParam(); cacheParam.nameHash = org.get_name().GetHashCode(); cacheParam.org = org.get_gameObject(); cacheParam.clone = val; cacheObjects.Add(cacheParam); int childCount = org.get_childCount(); for (int i = 0; i < childCount; i++) { CreateSprites(org.GetChild(i), val2, cacheObjects); } return(val2); }
/// <summary> /// 基本驱动事件 示例 /// 注册,触发,注销 /// </summary> /// <param name="param"></param> /// <returns></returns> public JsonResult DoEvent([FromBody] CacheParam param) { //触发事件 _eventBus.Trigger(this, new CustomEventData { CacheParamModel = param }); #region 还可以通过注册来实现 CustomEventHandler customEventHandler = new CustomEventHandler(); //注册 _eventBus.Register <CustomEventData>(customEventHandler.SetHandleEvent); //触发事件 _eventBus.Trigger(this, new CustomEventData { CacheParamModel = param }); //注销 _eventBus.Unregister <CustomEventData>(customEventHandler.SetHandleEvent); #endregion return(Json(param)); }
/// <summary> /// 缓存刷新 /// </summary> /// <param name="param"></param> /// <returns></returns> public async Task<ActionResult<string>> Refresh([FromBody]CacheParam param) { await _distributedCache.RefreshAsync(param.KeyName); return param.KeyName + ":数据缓存刷新"; }
/// <summary> /// 获取缓存数据 /// </summary> /// <param name="param"></param> /// <returns></returns> public async Task<ActionResult<string>> GetString([FromBody]CacheParam param) { var result = await _distributedCache.GetStringAsync(param.KeyName); return param.KeyName + ":" + result; }