示例#1
0
        internal static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            Cache = new Cache.Cache();

            CachedDistance      = Cache.Resolve <Distance>();
            CachedIsValidTarget = Cache.Resolve <IsValidTarget>();
            CachedIsInRange     = Cache.Resolve <IsInRange>();
            MinionCache         = Cache.Resolve <MinionCache>();

            CountEnemiesInRange                = Cache.Resolve <CustomCache <KeyValuePair <int, float>, int> >();
            CountAlliesInRange                 = Cache.Resolve <CustomCache <KeyValuePair <int, float>, int> >();
            CountEnemyMinionsInRange           = Cache.Resolve <CustomCache <KeyValuePair <int, float>, int> >();
            CountEnemiesInRange2               = Cache.Resolve <CustomCache <KeyValuePair <Vector3, float>, int> >();
            CountAlliesInRange2                = Cache.Resolve <CustomCache <KeyValuePair <Vector3, float>, int> >();
            CountEnemyMinionsInRange2          = Cache.Resolve <CustomCache <KeyValuePair <Vector3, float>, int> >();
            CachedAutoAttackDamage             = Cache.Resolve <CustomCache <Tuple <int, int, bool>, float> >();
            CachedAutoAttackDamage.RefreshRate = 1000;
            CachedSpellDamage             = Cache.Resolve <CustomCache <Tuple <int, int, SpellSlot>, float> >();
            CachedSpellDamage.RefreshRate = 1000;

            _initialized = true;
        }
示例#2
0
        private List <string> GetUploadFileTypes()
        {
            if (CustomCache.Get("supported-upload-types") == null)
            {
                CustomCache.Add("supported-upload-types", this.dictionaryBusiness.GetDictionary("supported-upload-types", "json"));
            }

            return((List <string>)CustomCache.Get("supported-upload-types"));
        }
示例#3
0
        public static string GetBBSStr(string str)
        {
            //int[] ic;
            string[] chars = CustomCache.Get("PersianChars") as string[];
            //var ia = Ints(out ic);
            if (chars == null)
            {
                PersianChars(out chars);
            }
            bool   flag   = false;
            string strRes = "";

            try
            {
                //str = Conversions.ToString(str.Trim());
                //str = str.Trim();

                //str = Rev(str);

                long num2 = str.Length;
                for (long i = num2; i > 0; i--)
                {
                    string mid     = Mid(str, (int)i, 1);
                    var    strTemp = Utility.Extention.SafeString(Asc(mid));
                    if (strTemp.SafeInt() < 0x80)
                    {
                        strTemp = mid;
                    }
                    else
                    {
                        strTemp = chars[strTemp.SafeInt()];
                        flag    = true;
                    }
                    strRes += strTemp;
                }
            }
            catch (Exception)
            {
                throw;
            }
            if (flag)
            {
                return(NumRev(strRes));
            }
            return(strRes);
        }
示例#4
0
        /// <summary>
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public Domain.DTO.UserManagement GetUserInformationByUserName(BaseReportFilter <UserManagementEditFilter> filter)
        {
            try
            {
                var username = filter.ReportFilter?.UserName;
                BRule.Assert(!username.IsNullOrEmpty(), RuleExceptionCodeUserManagement.UserNameIsEmpty.GetEnumDescription(),
                             (int)RuleExceptionCodeUserManagement.UserNameIsEmpty);

                var key = string.Format(pattern, username);

                var dtoCache = CustomCache.Get(key) as Domain.DTO.UserManagement;
                if (dtoCache != null)
                {
                    return(dtoCache);
                }

                //var user = AuthenticationManager.AuthenticationProvider.UserManager.FindByName(username); //TODO
                //Mapper.CreateMap<IdentityModels.ApplicationUser, Domain.DTO.UserManagement>().ForMember(dest => dest.CreateDate,
                //    opt => opt.MapFrom(src => src.CreateDate.ConvertMiladiToJalali()));
                //var model = Mapper.Map<IdentityModels.ApplicationUser, Domain.DTO.UserManagement>(user);

                var model = UserManagementService.GetUserByUserName(username);
                var party = PartyProvider.GetByUserName(username);
                if (party != null)
                {
                    var branch = PartyBranchService.GetAll().FirstOrDefault(x => x.PartyId == party.Id && x.ValidUntil == null);
                    if (branch?.BranchId != null)
                    {
                        if (branch?.BranchId != null)
                        {
                            model.BranchId = (int)branch?.BranchId;
                        }
                    }
                }

                model.RolesCodeList = AuthenticationManager.AuthenticationProvider.UserManager.GetRoles(model.Id).ToList();

                CustomCache.Insert(key, model, 1200);
                return(model);
            }
            catch (Exception ex)
            {
                Logger.ErrorException(ex.Message, ex);
                throw;
            }
        }
示例#5
0
        static MissFortune()
        {
            Q = new Spell.Targeted(SpellSlot.Q, 720);
            W = new Spell.Active(SpellSlot.W);
            E = new Spell.Skillshot(SpellSlot.E, 1000, SkillShotType.Circular)
            {
                Width = 350
            };
            R = new Spell.Skillshot(SpellSlot.R, 1400, SkillShotType.Cone)
            {
                Width = (int)Math.PI / 180 * 35
            };

            CachedComboDamage = Cache.Resolve <CustomCache <KeyValuePair <int, int>, float> >(1000);

            ColorPicker = new ColorPicker[4];

            ColorPicker[0] = new ColorPicker("MissFortuneQ", new ColorBGRA(10, 106, 138, 255));
            ColorPicker[1] = new ColorPicker("MissFortuneE", new ColorBGRA(177, 67, 191, 255));
            ColorPicker[2] = new ColorPicker("MissFortuneR", new ColorBGRA(255, 134, 0, 255));
            ColorPicker[3] = new ColorPicker("MissFortuneHpBar", new ColorBGRA(255, 134, 0, 255));

            DamageIndicator.Initalize(ColorPicker[3].Color, (int)R.Range);
            DamageIndicator.DamageDelegate = HandleDamageIndicator;

            ColorPicker[3].OnColorChange +=
                (a, b) =>
            {
                DamageIndicator.Color = b.Color;
            };

            Orbwalker.OnPostAttack += (sender, args) =>
            {
                IsAfterAttack = true;
                IsPreAttack   = false;
            };

            Orbwalker.OnPreAttack          += (target, args) => IsPreAttack = true;
            Game.OnPostTick                += args => IsAfterAttack = false;
            Obj_AI_Base.OnProcessSpellCast += Obj_AI_Base_OnProcessSpellCast;
            Spellbook.OnCastSpell          += Spellbook_OnCastSpell;
            Player.OnIssueOrder            += Player_OnIssueOrder;
            Obj_AI_Base.OnPlayAnimation    += Obj_AI_Base_OnPlayAnimation;
        }
示例#6
0
        public object GetDictionary(string dictionaryType, string outputFormat)
        {
            Logger.Info("Entering GetDictionary");

            object results = null;

            if (CustomCache.Get(dictionaryType) == null)
            {
                results = this.dictionaryBusiness.GetDictionary(dictionaryType, outputFormat);
                CustomCache.Add(dictionaryType, results);
            }
            else
            {
                results = CustomCache.Get(dictionaryType);
            }
            Logger.Debug("Logging CustomCache for dictionaryType");
            Logger.Info("Exiting GetDictionary");
            return(results);
        }
示例#7
0
        static Ashe()
        {
            Q = new Spell.Active(SpellSlot.Q);
            W = new Spell.Skillshot(SpellSlot.W, 1250, SkillShotType.Cone)
            {
                AllowedCollisionCount = 0,
                CastDelay             = 250,
                ConeAngleDegrees      = (int)(Math.PI / 180 * 40),
                Speed = 1500,
                Range = 1250,
                Width = 20
            };
            E = new Spell.Skillshot(SpellSlot.E, 30000, SkillShotType.Linear);
            R = new Spell.Skillshot(SpellSlot.R, 30000, SkillShotType.Linear, 250, 1600, 130)
            {
                AllowedCollisionCount = 0
            };

            CachedWPrediction             = StaticCacheProvider.Cache.Resolve <CustomCache <int, PredictionResult> >();
            CachedWPrediction.RefreshRate = 500;

            ColorPicker = new ColorPicker[2];

            ColorPicker[0] = new ColorPicker("AsheW", new ColorBGRA(10, 106, 138, 255));
            ColorPicker[1] = new ColorPicker("AsheR", new ColorBGRA(177, 67, 191, 255));

            ChampionTracker.Initialize(ChampionTrackerFlags.VisibilityTracker);

            Obj_AI_Base.OnProcessSpellCast += (sender, args) =>
            {
                if (sender.IsMe && args.Slot == SpellSlot.Q)
                {
                    Orbwalker.ResetAutoAttack();
                }
            };

            Orbwalker.OnPreAttack  += (a, b) => IsPreAttack = true;
            Orbwalker.OnPostAttack += (a, b) => { IsPreAttack = false; IsAfterAttack = true; };
            Game.OnPostTick        += args => IsAfterAttack = false;
        }
示例#8
0
        // GET: Cache
        public ActionResult Index()
        {
            //自己实现缓存


            for (int i = 0; i < 5; i++)
            {
                string key     = string.Format("{0}_{1}_{2}", "Program", "Count", 13);
                int    iResult = 0;
                if (CustomCache.Exist(key))
                {
                    iResult = CustomCache.Get <int>(key);
                }
                else
                {
                    iResult = Count(13);
                    CustomCache.Add(key, iResult);
                }

                Console.WriteLine("这里是第{0}次获取数据,结果为{1}", i, Count(12));
            }

            //使用内置缓存类方法如下:
            {
                string CacheKey = "CacheKey001";
                if (CacheHelper.IsCache(CacheKey))//判断缓存是否存在
                {
                    int a = 0;
                    a = CacheHelper.GetCaChe <int>(CacheKey);//获取缓存
                }
                else
                {
                    CacheHelper.CacheOjbectLocak <int>(1, CacheKey, 0);//存入缓存
                }
            }

            return(View());
        }
示例#9
0
        public static string CorePath(string name)
        {
            var address = (Dictionary <string, string>)CustomCache.Get("Core.Addresses");

            if (address != null)
            {
                return(address[name]);
            }
            address = new Dictionary <string, string>();
            var doc = GetCoreXml();
            var selectSingleNode = doc.SelectSingleNode("Address");

            if (selectSingleNode != null)
            {
                foreach (XmlNode n in selectSingleNode.ChildNodes)
                {
                    var physicalPath = PhysicalPath(n.InnerText);
                    address.Add(n.Attributes["name"].Value, physicalPath);
                }
            }
            CustomCache.Insert("Core.Addresses", address);
            return(address[name]);
        }
示例#10
0
 private static void PersianChars(out string[] codes)
 {
     codes      = new string[10000];
     codes[141] = "آ";
     codes[142] = "ئـ";
     codes[143] = "ء";
     codes[144] = "ا";
     codes[145] = "ـا";
     codes[146] = "ب";
     codes[147] = "بـ";
     codes[148] = "پ";
     codes[149] = "پـ";
     codes[150] = "ت";
     codes[151] = "تـ";
     codes[152] = "ث";
     codes[153] = "ثـ";
     codes[154] = "ج";
     codes[155] = "جـ";
     codes[156] = "چ";
     codes[157] = "چـ";
     codes[158] = "ح";
     codes[159] = "حـ";
     codes[160] = "خ";
     codes[161] = "خـ";
     codes[162] = "د";
     codes[163] = "ذ";
     codes[164] = "ر";
     codes[165] = "ز";
     codes[166] = "ژ";
     codes[167] = "س";
     codes[168] = "سـ";
     codes[169] = "ش";
     codes[170] = "شـ";
     codes[171] = "ص";
     codes[172] = "صـ";
     codes[173] = "ض";
     codes[174] = "ضـ";
     codes[175] = "ط";
     codes[224] = "ظ";
     codes[225] = "ع";
     codes[226] = "ـع";
     codes[227] = "ـعـ";
     codes[228] = "عـ";
     codes[229] = "غ";
     codes[230] = "ـغ";
     codes[231] = "ـغـ";
     codes[232] = "غـ";
     codes[233] = "ف";
     codes[234] = "فـ";
     codes[235] = "ق";
     codes[236] = "قـ";
     codes[237] = "ک";
     codes[238] = "کـ";
     codes[239] = "گ";
     codes[240] = "گـ";
     codes[241] = "ل";
     codes[242] = "لا";
     codes[243] = "لـ";
     codes[244] = "م";
     codes[245] = "مـ";
     codes[246] = "ن";
     codes[247] = "نـ";
     codes[248] = "و";
     codes[249] = "ه";
     codes[250] = "ـهـ";
     codes[251] = "هـ";
     codes[252] = "ی";
     codes[253] = "ی";
     codes[254] = "یـ";
     CustomCache.Insert("PersianChars", codes);
 }
示例#11
0
        static Ezreal()
        {
            Q = new Spell.Skillshot(SpellSlot.Q, 1300, SkillShotType.Linear, 250, 2000, 60);
            W = new Spell.Skillshot(SpellSlot.W, 1050, SkillShotType.Linear, 250, 1600, 80)
            {
                AllowedCollisionCount = int.MaxValue
            };
            E = new Spell.Skillshot(SpellSlot.E, 475, SkillShotType.Linear);
            R = new Spell.Skillshot(SpellSlot.R, 6000, SkillShotType.Linear, 1000, 2000, 160)
            {
                AllowedCollisionCount = int.MaxValue
            };

            ComboDamages = Cache.Resolve <CustomCache <int, float> >(1000);

            ColorPicker = new ColorPicker[4];

            ColorPicker[0] = new ColorPicker("EzrealQ", new ColorBGRA(10, 106, 138, 255));
            ColorPicker[1] = new ColorPicker("EzrealW", new ColorBGRA(177, 67, 191, 255));
            ColorPicker[2] = new ColorPicker("EzrealE", new ColorBGRA(255, 134, 0, 255));
            ColorPicker[3] = new ColorPicker("EzrealHpBar", new ColorBGRA(255, 134, 0, 255));

            DamageIndicator.Initalize(ColorPicker[3].Color);
            DamageIndicator.DamageDelegate = HandleDamageIndicator;

            ChampionTracker.Initialize(ChampionTrackerFlags.LongCastTimeTracker);

            Obj_AI_Base.OnBasicAttack += Obj_AI_Base_OnBasicAttack;

            Text = new Text("", new Font("calibri", 15, FontStyle.Regular));

            ColorPicker[3].OnColorChange +=
                (a, b) =>
            {
                DamageIndicator.Color = b.Color;
            };

            TearStacker.Initializer(new Dictionary <SpellSlot, float> {
                { SpellSlot.Q, 3000 }, { SpellSlot.W, 4200 }
            },
                                    () => (Player.Instance.CountEnemiesInRange(1000) == 0) && (Player.Instance.CountEnemyMinionsInRange(1000) == 0) && !HasAnyOrbwalkerFlags());

            Orbwalker.OnPreAttack += (a, b) =>
            {
                if (a.IsMe)
                {
                    return;
                }

                IsPreAttack = true;
            };

            Orbwalker.OnPostAttack += (a, b) =>
            {
                IsPreAttack  = false;
                IsPostAttack = true;
            };

            Orbwalker.OnUnkillableMinion += (target, args) =>
            {
                if (FarmMode && Q.IsReady() && (Q.GetPrediction(target).Collision == false) && (Prediction.Health.GetPrediction(target,
                                                                                                                                (int)((target.DistanceCached(Player.Instance) + Q.CastDelay) / Q.Speed * 1000)) > 0))
                {
                    Q.Cast(target.ServerPosition);
                }
            };

            ChampionTracker.OnLongSpellCast   += ChampionTracker_OnLongSpellCast;
            ChampionTracker.OnPostBasicAttack += ChampionTracker_OnPostBasicAttack;

            Obj_AI_Base.OnSpellCast += (sender, args) =>
            {
                if (Settings.Combo.WEComboKeybind && E.IsReady() && sender.IsMe && (args.Slot == SpellSlot.W))
                {
                    E.Cast(Player.Instance.Position.Extend(args.End, E.Range - 15).To3D());
                }
            };
        }
示例#12
0
        static Ezreal()
        {
            Q = new Spell.Skillshot(SpellSlot.Q, 1300, SkillShotType.Linear, 250, 2000, 60);
            W = new Spell.Skillshot(SpellSlot.W, 1050, SkillShotType.Linear, 250, 1600, 80)
            {
                AllowedCollisionCount = int.MaxValue
            };
            E = new Spell.Skillshot(SpellSlot.E, 475, SkillShotType.Linear);
            R = new Spell.Skillshot(SpellSlot.R, 6000, SkillShotType.Linear, 1000, 2000, 160)
            {
                AllowedCollisionCount = int.MaxValue
            };

            ComboDamages = Cache.Resolve <CustomCache <int, float> >(1000);

            ColorPicker = new ColorPicker[4];

            ColorPicker[0] = new ColorPicker("EzrealQ", new ColorBGRA(10, 106, 138, 255));
            ColorPicker[1] = new ColorPicker("EzrealW", new ColorBGRA(177, 67, 191, 255));
            ColorPicker[2] = new ColorPicker("EzrealE", new ColorBGRA(255, 134, 0, 255));
            ColorPicker[3] = new ColorPicker("EzrealHpBar", new ColorBGRA(255, 134, 0, 255));

            DamageIndicator.Initalize(ColorPicker[3].Color);
            DamageIndicator.DamageDelegate = HandleDamageIndicator;

            ChampionTracker.Initialize(ChampionTrackerFlags.LongCastTimeTracker);

            Obj_AI_Base.OnBasicAttack += Obj_AI_Base_OnBasicAttack;

            Text = new Text("", new Font("calibri", 15, FontStyle.Regular));

            ColorPicker[3].OnColorChange +=
                (a, b) =>
            {
                DamageIndicator.Color = b.Color;
            };

            TearStacker.Initializer(new Dictionary <SpellSlot, float> {
                { SpellSlot.Q, 5000 }, { SpellSlot.W, 15000 }
            },
                                    () => Player.Instance.CountEnemiesInRange(1000) == 0 && Player.Instance.CountEnemyMinionsInRange(1000) == 0 && !HasAnyOrbwalkerFlags());

            Orbwalker.OnPreAttack += (a, b) =>
            {
                if (a.IsMe)
                {
                    return;
                }

                IsPreAttack = true;
            };

            Orbwalker.OnPostAttack += (a, b) =>
            {
                IsPreAttack  = false;
                IsPostAttack = true;
            };

            ChampionTracker.OnLongSpellCast   += ChampionTracker_OnLongSpellCast;
            ChampionTracker.OnPostBasicAttack += ChampionTracker_OnPostBasicAttack;
        }
示例#13
0
        static void Main(string[] args)
        {
            try
            {
                {
                    //{
                    //    for (int i = 0; i < 5; i++)
                    //    {
                    //    Console.WriteLine($"Obtain {nameof(DBHelper)} for {i} times {DateTime.Now.ToString("yyyyMMdd HHmmss.fff")}");
                    //    List<Program> programList = null;
                    //    string key = $"{nameof(DBHelper)}_Query_{nameof(Program)}_{123}";

                    //        //Encapusulate this part by delegation.
                    //        //if (!CustomCache.Exist(key))
                    //        //{
                    //        //    programList = DBHelper.Query<Program>(123);
                    //        //    CustomCache.Add(key, programList);
                    //        //}
                    //        //else
                    //        //{
                    //        //    programList = CustomCache.Get<List<Program>>(key);
                    //        //}

                    //        programList = CustomCache.FindOrAdd(key, () => DBHelper.Query<Program>(123));
                    //        Console.WriteLine($"The {i} time you fetch the data is {programList.GetHashCode()}");
                    //    }
                    //}
                    //{
                    //    for (int i = 0; i < 5; i++)
                    //    {
                    //    Console.WriteLine($"Obtain {nameof(FileHelper)} for {i} times {DateTime.Now.ToString("yyyyMMdd HHmmss.fff")}");
                    //    List<Program> programList = null;
                    //    Console.WriteLine("==FileHelper==");
                    //        string key = $"{nameof(FileHelper)}_Query_{nameof(Program)}_456";
                    //        programList = CustomCache.FindOrAdd(key, () => (FileHelper.Query<Program>(456)));
                    //        Console.WriteLine($"The {i} time you fetch the data is {programList.GetHashCode()}");
                    //    }
                    //}
                    //{
                    //    for (int i = 0; i < 5; i++)
                    //    {
                    //    Console.WriteLine($"Obtain {nameof(RemoteHelper)} for {i} times {DateTime.Now.ToString("yyyyMMdd HHmmss.fff")}");
                    //    List<Program> programList = null;
                    //    Console.WriteLine("==RemoteHelper==");
                    //        string key = $"{nameof(RemoteHelper)}_Query_{nameof(Program)}_456";
                    //        programList = CustomCache.FindOrAdd(key, () => (RemoteHelper.Query<Program>(456)));
                    //        Console.WriteLine($"The {i} time you fetch the data is {programList.GetHashCode()}");
                    //    }
                    //}
                }

                //Handle the issue of data in chache changed.
                //E.g. User authorities, user->role->menu, generally stable, suit to use chache.
                //1. When a user's authorities changed, just remove it.
                {
                    //2. When a menu is changed, should not go through the whole cache or delete all , just delete the items
                    // which are relavent to the menu
                    //string key = "_System_Menu";
                    //CustomCache.RemoveCondition(s => s.Contains("_Menu_"));
                }

                {
                    //Add a time attribute to the cache data.
                    //Veryfy the validaty of cached data in an active and passive manner.
                    Console.WriteLine("===Set period of out of date of an item===");
                    string key = "_System_Menu";
                    if (CustomCache.Exist(key))
                    {
                        string result = CustomCache.Get <string>(key);
                    }
                    else
                    {
                        string result = "New item";
                        CustomCache.Add(key, result, 10);
                    }

                    //As long as the data source has changed or not during the validity period, the cache will prevail
                    if (CustomCache.Exist(key))
                    {
                        string result = CustomCache.Get <string>(key);
                    }
                    else
                    {
                        string result = "New item";
                        CustomCache.Add(key, result, 5);
                    }

                    Thread.Sleep(5000);
                    //As long as the data is expired, regardless of whether the data source has changed or not, reacquire it
                    if (CustomCache.Exist(key))
                    {
                        string result = CustomCache.Get <string>(key);
                    }
                    else
                    {
                        string result = "New item";
                        CustomCache.Add(key, result, 5);
                    }
                }



                Console.Read();
            }catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#14
0
        // GET: Main
        public ActionResult Index()
        {
            var currentRemains = CustomCache.GetRemainsAndCosts();

            return(View(currentRemains));
        }
示例#15
0
        public async Task <IActionResult> SetByKey(CustomCache request)
        {
            await _cache.SetStringAsync(request.Key, request.Value);

            return(Ok(new KeyValuePair <string, string>(request.Key, _cache.GetString(request.Key))));
        }