Ejemplo n.º 1
0
        public GetAccessTokenResult GetAccessToken(string appId, string appSecret)
        {
            var cacheKey = appId;

            if (IGetAccessTokenCache != null)
            {
                var cacheObj = IGetAccessTokenCache.Get(cacheKey);
                if (ToolFactory.CreateIValidatorTool().IsNotEmpty(cacheObj))
                {
                    return(cacheObj);
                }
            }
            string url    = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", appId, appSecret);
            var    client = ToolFactory.Ioc.Get <IHttpClient>();
            var    result = client.DownloadToString(url);

            if (WeiXinHelper.IsFailureInvokeWeiXinAPI(result))
            {
                throw new Exception(result);
            }
            var iJson       = ToolFactory.CreateIJsonSerializeTool();
            var accessToken = iJson.DeserializeFromString <GetAccessTokenResult>(result);

            if (IGetAccessTokenCache != null)
            {
                IGetAccessTokenCache.Set(cacheKey, accessToken);
            }
            return(accessToken);
        }
Ejemplo n.º 2
0
        public static void performToolAction(byte toolIndex, byte toolUpgradeLevel, short xTile, short yTile, string locationName, byte facingDirection, short seed, long who)
        {
            Tool         toolFromDescription = ToolFactory.getToolFromDescription(toolIndex, (int)toolUpgradeLevel);
            GameLocation locationFromName    = Game1.getLocationFromName(locationName);

            Game1.otherFarmers[who].CurrentTool = toolFromDescription;
            Game1.recentMultiplayerRandom       = new Random((int)seed);
            if (locationFromName == null)
            {
                if (toolFromDescription is MeleeWeapon)
                {
                    Game1.otherFarmers[who].faceDirection((int)facingDirection);
                    (toolFromDescription as MeleeWeapon).DoDamage(Game1.currentLocation, (int)xTile, (int)yTile, Game1.otherFarmers[who].facingDirection, 1, Game1.otherFarmers[who]);
                }
                else
                {
                    toolFromDescription.DoFunction(Game1.currentLocation, (int)xTile, (int)yTile, 1, Game1.otherFarmers[who]);
                }
            }
            else if (toolFromDescription is MeleeWeapon)
            {
                Game1.otherFarmers[who].faceDirection((int)facingDirection);
                (toolFromDescription as MeleeWeapon).DoDamage(locationFromName, (int)xTile, (int)yTile, Game1.otherFarmers[who].facingDirection, 1, Game1.otherFarmers[who]);
            }
            else
            {
                toolFromDescription.DoFunction(locationFromName, (int)xTile, (int)yTile, 1, Game1.otherFarmers[who]);
            }
            if (Game1.IsServer)
            {
                MultiplayerUtility.broadcastToolAction(toolFromDescription, (int)xTile, (int)yTile, locationName, facingDirection, seed, who);
            }
        }
Ejemplo n.º 3
0
Archivo: Lt.cs Proyecto: sdBruLi/Csharp
        protected override string GetErrorMsgTpl()
        {
            StringBuilder enSb          = new StringBuilder();
            StringBuilder zhSb          = new StringBuilder();
            var           tIProgramTool = ToolFactory.CreateIProgramTool();

            if (tIProgramTool.IsNumericType(this.Value))
            {
                enSb.AppendFormat("{{FieldName}} must be less than {0}", this.Max);
                zhSb.AppendFormat("{{FieldName}}必须少于{0}", this.Max);
                return(this.mILanguageTool.Get(enSb.ToString(), zhSb.ToString()));
            }
            if (tIProgramTool.IsStringType(Value))
            {
                enSb.AppendFormat("{{FieldName}} length must be less than {0}", this.Max);
                zhSb.AppendFormat("{{FieldName}}长度必须少于{0}", this.Max);
                return(this.mILanguageTool.Get(enSb.ToString(), zhSb.ToString()));
            }
            if (tIProgramTool.IsDateTimeType(Value))
            {
                var dMaxString = ToolFactory.CreateICalenderTool().Format(Max);
                enSb.AppendFormat("{{FieldName}} must be less than {0}", dMaxString);
                zhSb.AppendFormat("{{FieldName}}必须少于{0}", dMaxString);
                return(this.mILanguageTool.Get(enSb.ToString(), zhSb.ToString()));
            }
            throw new Exception("无法自动检测比较类型");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 生成签名
        /// 签名在线验证工具:
        /// http://mch.weixin.qq.com/wiki/tools/signverify/
        /// </summary>
        /// <param name="stringADict">参与签名生成的参数列表</param>
        /// <param name="apiSecretKey">商家私钥</param>
        /// <returns></returns>
        public static string GetSign(IDictionary <string, string> stringADict, string apiSecretKey)
        {
            var sb         = new StringBuilder();
            var sortedDict = new SortedDictionary <string, string>(stringADict);//参数名ASCII码从小到大排序(字典序);

            foreach (var item in sortedDict)
            {
                if (string.IsNullOrEmpty(item.Value))
                {
                    continue;                                  //参数的值为空不参与签名;
                }
                if (string.Compare(item.Key, "sign", true) == 0)
                {
                    continue;                                                 // 参数中为签名的项,不参加计算
                }
                sb.Append(item.Key).Append("=").Append(item.Value).Append("&");
            }
            var string1 = sb.ToString();

            string1 = string1.Remove(string1.Length - 1, 1);
            sb.Append("key=").Append(apiSecretKey);                                                          //在stringA最后拼接上key=(API密钥的值)得到stringSignTemp字符串
            var stringSignTemp = sb.ToString();
            var sign           = ToolFactory.CreateICryptogramTool().MD5(stringSignTemp, "UTF-8").ToUpper(); //对stringSignTemp进行MD5运算,再将得到的字符串所有字符转换为大写,得到sign值signValue。

            return(sign);
        }
Ejemplo n.º 5
0
        private void LoadTools(GameState gameState)
        {
            String      toolSpritePath = "Sprites/Tools/";
            ToolFactory toolFactory    = new ToolFactory();

            foreach (ExistingTools et in Enum.GetValues(typeof(ExistingTools)))
            {
                Texture2D toolSprite = ContentManager.Load <Texture2D>(toolSpritePath + et.ToString());
                switch (et)
                {
                case ExistingTools.pickaxe:
                    Pickaxe.ToolSprite = toolSprite;
                    break;

                case ExistingTools.rope:
                    Rope.ToolSprite = toolSprite;
                    break;

                default:
                    MyDebugger.WriteLine(
                        string.Format("GameObject '{0}' cannot be created", true));
                    break;
                }

                Tool tool = toolFactory.Create(new Obj {
                    Type = et.ToString()
                });
                gameState.AddTool(et, tool);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取jsapi_ticket
        /// jsapi_ticket是公众号用于调用微信JS接口的临时票据。
        /// 正常情况下,jsapi_ticket的有效期为7200秒,通过access_token来获取。
        /// 由于获取jsapi_ticket的api调用次数非常有限,频繁刷新jsapi_ticket会导致api调用受限,影响自身业务,开发者必须在自己的服务全局缓存jsapi_ticket 。
        /// </summary>
        /// <param name="accessToken">微信全局access_token</param>
        /// <returns></returns>
        public GenericExecResult <string> GetJsTickect(string accessToken)
        {
            var cacheJsTickect = _ICache.Get <string>(CacheJsTickectId);

            if (ToolFactory.CreateIValidatorTool().IsNotEmpty(cacheJsTickect))
            {
                return(new GenericExecResult <string>()
                {
                    Success = true,
                    Data = cacheJsTickect
                });
            }
            ;
            var url            = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", accessToken);
            var downloadResult = WeiXinHelper.DownloadToString(url);

            if (WeiXinHelper.IsFailureInvokeWeiXinAPI(downloadResult))
            {
                return(WeiXinHelper.FromDownloadResultToErrorGenericExecResult(downloadResult));
            }
            var jsTicket = WeiXinHelper.ToGetJsTickectResultDto(downloadResult.Data).ticket;

            _ICache.Set(CacheJsTickectId, jsTicket, DateTime.Now.AddSeconds(CacheJsTickectExpireTimeoutSecond));
            return(new GenericExecResult <string>()
            {
                Success = true,
                Data = jsTicket
            });
        }
Ejemplo n.º 7
0
        static void createTestTools(ToolBox tb)
        {
            ToolFactory tf = new ToolFactory();

            var ma1 = tf.CreateAirplane("myAirplane1");

            ma1.Age       = 2;
            ma1.BaseWorth = new Worth(5, 10);
            tb.AddTool(ma1);
            ma1.Birthday();

            var mb1 = tf.CreateBike("myBike");

            mb1.Age       = 6;
            mb1.BaseWorth = new Worth(60, 30);
            tb.AddTool(mb1);

            var ms1 = tf.CreateSubmarine("mySubmarine");

            ms1.Age       = 9;
            ms1.BaseWorth = new Worth(30, 20);
            tb.AddTool(ms1);

            tb.DeleteTool(ms1);

            tb.ChangeAccelarate(100);
        }
Ejemplo n.º 8
0
        private void FieldPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_isLocked)
            {
                return;
            }

            _lwlcTool = ToolFactory.NewLWLCTool();

            _lwlcResultDataTable = _lwlcTool.Data;

            if (_selectedFeature.Fields.Count(f => f.IsSelected) >= 1)
            {
                _toolParameter = new BindingList <IToolParameter>(_lwlcTool.ToolParameterContainer.ToolParameter);

                //ProgressDialog.ShowProgressDialog("Running LWLC Tool", (Action) _lwlcTool.Run);
                ProgressDialogBuilder progressDialogBuilder = new ProgressDialogBuilder((Action <ProgressHandler>)_lwlcTool.Run);
                progressDialogBuilder.SetTitle("Running LWLC Tool").Build().Show();
            }
            else
            {
                RegisterToolParameterEvents();
            }

            PropertyChanged.Notify(() => LWLCParameter);
            PropertyChanged.Notify(() => LWLCResult);

            CommandManager.InvalidateRequerySuggested();
        }
Ejemplo n.º 9
0
        private void FieldPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_isLocked)
            {
                return;
            }

            _wlcTool = ToolFactory.NewWLCTool();

            _toolParameter = new BindingList <IToolParameter>(_wlcTool.ToolParameterContainer.ToolParameter);


            if (_selectedFeature.Fields.Count(f => f.IsSelected) >= 1)
            {
                _wlcTool.Run();

                _wlcResultDataTable = _wlcTool.Data;
            }

            RegisterToolParameterEvents();

            PropertyChanged.Notify(() => WLCParameter);
            PropertyChanged.Notify(() => WLCResult);

            CommandManager.InvalidateRequerySuggested();
        }
Ejemplo n.º 10
0
        public void Tools_Count_is_Not_0_Create_by_ToolFactory_According_to_Correct_Config_File()
        {
            // Act & Arrange
            var expectedToolCount = ToolFactory.CreateToolsAccordingTo(@"c:\config\DynamicToolBox.xml").Count();

            // Assert
            Assert.AreNotEqual(0, expectedToolCount);
        }
Ejemplo n.º 11
0
 public void AddFilter(IEnumerable <AbstractFilter> filters)
 {
     if (ToolFactory.CreateIValidatorTool().IsEmpty(this.Filters))
     {
         this.Filters = new List <AbstractFilter>();
     }
     this.Filters.AddRange(filters);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Generate every item known to man, or at least those we're interested
        /// in using for categorization.
        /// </summary>
        ///
        /// <remarks>
        /// Substantially based on code from Pathoschild's LookupAnything mod.
        /// </remarks>
        ///
        /// <returns>A collection of all of the item entries.</returns>
        private IEnumerable <Item> DiscoverItems()
        {
            // upgradable tools
            yield return(ToolFactory.getToolFromDescription(ToolFactory.axe, Tool.stone));

            yield return(ToolFactory.getToolFromDescription(ToolFactory.hoe, Tool.stone));

            yield return(ToolFactory.getToolFromDescription(ToolFactory.pickAxe, Tool.stone));

            yield return(ToolFactory.getToolFromDescription(ToolFactory.wateringCan, Tool.stone));

            yield return(ToolFactory.getToolFromDescription(ToolFactory.fishingRod, Tool.stone));

            // other tools
            yield return(new MilkPail());

            yield return(new Shears());

            yield return(new Pan());

            yield return(new MagnifyingGlass());

            yield return(new Wand());

            // equipment
            foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\Boots").Keys)
            {
                yield return(new Boots(id));
            }

            foreach (int id in Game1.content.Load <Dictionary <int, string> >("Data\\hats").Keys)
            {
                yield return(new Hat(id));
            }

            for (int id = Ring.ringLowerIndexRange; id <= Ring.ringUpperIndexRange; id++)
            {
                yield return(new Ring(id));
            }

            // weapons
            foreach (var item in ItemHelper.GetWeapons())
            {
                yield return(item);
            }

            // objects
            foreach (int id in Game1.objectInformation.Keys)
            {
                if (id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange)
                {
                    continue; // handled separated
                }
                yield return(new StardewObject(id, 1));
            }
        }
Ejemplo n.º 13
0
        public T FirstOrDefault <T>(IWhereGetter where, IOrderByGetter orderByGetter = null) where T : class
        {
            var list = this.FindByProperties <T>(where, orderByGetter);

            if (ToolFactory.CreateIValidatorTool().IsEmpty(list))
            {
                return(null);
            }
            return(list[0]);
        }
Ejemplo n.º 14
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //string configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "app.config");

            //if (File.Exists(configFile))
            //dockPanel.LoadFromXml(configFile, GetContentFromPersistString);

            ShowToolWindow(ToolFactory.CreateTool <LevelExplorer>(Context));
            //ShowToolWindow(ToolFactory.CreateTool<MiNetConsole>(Context), DockState.DockBottom);
        }
Ejemplo n.º 15
0
 private void baseDoFunction(GameLocation location, int x, int y, int power, Farmer who)
 {
     this.lastUser = who;
     Game1.recentMultiplayerRandom = new Random((int)(short)Game1.random.Next((int)short.MinValue, 32768));
     ToolFactory.getIndexFromTool(this);
     if (who.FarmerSprite.currentAnimationIndex <= 0)
     {
         return;
     }
     MeleeWeapon.timedHitTimer = 500;
 }
Ejemplo n.º 16
0
 public static ICriteria AddOrder(ICriteria iCriteria, IEnumerable <OrderBy> orderBys)
 {
     if (ToolFactory.CreateIValidatorTool().IsEmpty(orderBys))
     {
         return(iCriteria);
     }
     foreach (var orderBy in orderBys)
     {
         iCriteria.AddOrder(ToOrder(orderBy));
     }
     return(iCriteria);
 }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            var context     = new ToolFactory();
            var timecontext = context.getDbContext();
            IStudentComtemlateRepository studentComtemlateRepository = new StudentComtemlateRepository(timecontext);
            IEmployComtemplateRepository employComtemplateRepository = new EmployComtemplateRepository(timecontext);

            //计算学生每日 每时段填报情况
            studentComtemlateRepository.CompTemplateStudent();
            //计算教职工 每 每时段填报情况
            employComtemplateRepository.CompTemplateEmploy();
        }
Ejemplo n.º 18
0
        public WLCToolViewModel()
        {
            _mcdaExtension = MCDAExtension.GetExtension();

            _wlcTool = ToolFactory.NewWLCTool();

            _wlcResultDataTable = _wlcTool.Data;

            _selectedFeaturePropertyChangedEventHandler = _mcdaExtension.RegisterPropertyHandler(x => x.SelectedFeature, SelectedFeaturePropertyChanged);

            //we have to call our own update method to make sure we have a result column
            SelectedFeaturePropertyChanged(this, null);
        }
Ejemplo n.º 19
0
        public GetQRCodeTicketResultDto GetQRCodeTicket(string accessToken, QRCodePostDataDto qrCodePostDataDto)
        {
            var weiXinUrl = string.Format(WEIXIN_CREATE_QR_URL, accessToken);

            IHttpClient client      = ToolFactory.BLLIoc.Get <IHttpClient>();
            var         iJsonHelper = ToolFactory.CreateIJsonSerializeTool();
            var         postData    = iJsonHelper.SerializeToString(qrCodePostDataDto);
            var         postResult  = client.Post(weiXinUrl, postData);

            WeiXinHelper.IsFailureInvokeWeiXinAPIThrowException(postResult);
            var result = iJsonHelper.DeserializeFromString <GetQRCodeTicketResultDto>(postResult);

            return(result);
        }
 public MenuBarViewModel(IServiceProvider provider, PackFileService packfileService, ToolFactory toolFactory)
 {
     _serviceProvider             = provider;
     _packfileService             = packfileService;
     _toolFactory                 = toolFactory;
     OpenSettingsWindowCommand    = new RelayCommand(ShowSettingsDialog);
     OpenPackFileCommand          = new RelayCommand(OpenPackFile);
     CreateNewPackFileCommand     = new RelayCommand(CreatePackFile);
     OpenAssetEditorFolderCommand = new RelayCommand(OpenAssetEditorFolder);
     OpenKitbashEditorCommand     = new RelayCommand(OpenKitbasherTool);
     OpenAnimMetaDecocderCommand  = new RelayCommand(OpenAnimMetaDecocder);
     OpenMountCreatorCommand      = new RelayCommand(OpenMountCreator);
     OpenPropCreatorCommand       = new RelayCommand(OpenPropCreatorEditor);
 }
Ejemplo n.º 21
0
        public BaseController()
        {
            IEntityTool iEntityTool = ToolFactory.CreateIEntityTool();

            if (System.Web.HttpContext.Current.Request.QueryString.Count != 0)
            {
                var queryStringBinder = iEntityTool.CreateINVCollectionBinder(System.Web.HttpContext.Current.Request.QueryString);
                queryStringBinder.Bind <BaseController>(this);
            }
            if (System.Web.HttpContext.Current.Request.Form.Count != 0)
            {
                var formBinder = iEntityTool.CreateINVCollectionBinder(System.Web.HttpContext.Current.Request.Form);
                formBinder.Bind <BaseController>(this);
            }
        }
Ejemplo n.º 22
0
Archivo: Lt.cs Proyecto: sdBruLi/Csharp
        public override bool Valid(object pObject)
        {
            var tIValidatorTool = ToolFactory.CreateIValidatorTool();
            var tIProgramTool   = ToolFactory.CreateIProgramTool();

            if (tIProgramTool.IsStringType(pObject))
            {
                if (tIValidatorTool.IsEmpty(pObject))
                {
                    return(true);
                }
                else
                {
                    var objString = pObject.ToString();
                    var decMax    = Convert.ToDecimal(Max);
                    if (objString.Length < decMax)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            if (tIProgramTool.IsNumericType(pObject))
            {
                decimal decObj = Convert.ToDecimal(pObject);
                var     decMax = Convert.ToDecimal(Max);
                return(decObj < decMax);
            }
            if (tIProgramTool.IsDateTimeType(pObject))
            {
                if (Max == null)
                {
                    return(true);
                }
                if (pObject == null)
                {
                    return(false);
                }
                DateTime dObj = Convert.ToDateTime(pObject);
                DateTime dMax = Convert.ToDateTime(Max);

                return(dObj < dMax);
            }
            throw new Exception("无法自动检测比较类型");
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 调用微信发送红包接口
        /// 请求Url	https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack
        /// 是否需要证书	是(证书及使用说明详见商户证书)
        /// 请求方式	POST
        /// </summary>
        /// <param name="certFilePath">证书位置</param>
        /// <param name="certPwd">证书密码</param>
        /// <param name="nonce_str">String(32) 随机字符串,不长于32位</param>
        /// <param name="sign">
        /// String(32)
        /// 详见签名生成算法,https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3
        /// </param>
        /// <param name="mch_billno">
        /// String(28)
        /// 商户订单号(每个订单号必须唯一)
        /// 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。
        /// 接口根据商户订单号支持重入,如出现超时可再调用。</param>
        /// <param name="mch_id">String(32) 微信支付分配的商户号</param>
        /// <param name="wxappid">
        /// 微信分配的公众账号ID(企业号corpid即为此appId)。
        /// 接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),
        /// 不能为APP的appid(在open.weixin.qq.com申请的)。
        /// </param>
        /// <param name="send_name">String(32) 红包发送者名称</param>
        /// <param name="re_openid">String(32) 接受红包的用户 用户在wxappid下的openid</param>
        /// <param name="total_amount">付款金额,单位分</param>
        /// <param name="total_num">红包发放总人数,total_num=1</param>
        /// <param name="wishing">String(128) 红包祝福语</param>
        /// <param name="client_ip">String(15) 调用接口的机器Ip地址</param>
        /// <param name="act_name">String(32) 活动名称</param>
        /// <param name="remark">String(256) 备注信息</param>
        /// <returns></returns>
        public Entities.SendRedPackResult SendRedPack(string certFilePath, string certPwd,
                                                      string nonce_str, string sign, string mch_billno,
                                                      string mch_id, string wxappid, string send_name, string re_openid, int total_amount,
                                                      int total_num, string wishing, string client_ip, string act_name, string remark)
        {
            //<xml>
            //     <sign><![CDATA[E1EE61A91C8E90F299DE6AE075D60A2D]]></sign>
            //     <mch_billno><![CDATA[0010010404201411170000046545]]></mch_billno>
            //     <mch_id><![CDATA[888]]></mch_id>
            //     <wxappid><![CDATA[wxcbda96de0b165486]]></wxappid>
            //     <send_name><![CDATA[send_name]]></send_name>
            //     <re_openid><![CDATA[onqOjjmM1tad-3ROpncN-yUfa6uI]]></re_openid>
            //     <total_amount><![CDATA[200]]></total_amount>
            //     <total_num><![CDATA[1]]></total_num>
            //     <wishing><![CDATA[恭喜发财]]></wishing>
            //     <client_ip><![CDATA[127.0.0.1]]></client_ip>
            //     <act_name><![CDATA[新年红包]]></act_name>
            //     <remark><![CDATA[新年红包]]></remark>
            //     <nonce_str><![CDATA[50780e0cca98c8c8e814883e5caa672e]]></nonce_str>
            // </xml>
            SortedDictionary <string, string> sortedDictParams = new SortedDictionary <string, string>();

            sortedDictParams.Add("sign", sign);
            sortedDictParams.Add("mch_billno", mch_billno);
            sortedDictParams.Add("mch_id", mch_id);
            sortedDictParams.Add("wxappid", wxappid);
            sortedDictParams.Add("send_name", send_name);
            sortedDictParams.Add("re_openid", re_openid);
            sortedDictParams.Add("total_amount", total_amount.ToString());
            sortedDictParams.Add("total_num", total_num.ToString());
            sortedDictParams.Add("wishing", wishing);
            sortedDictParams.Add("client_ip", client_ip);
            sortedDictParams.Add("act_name", act_name);
            sortedDictParams.Add("remark", remark);
            sortedDictParams.Add("nonce_str", nonce_str);

            var             postXmlData     = WeiXinHelper.BuildPostXmlData(sortedDictParams);
            var             url             = string.Format("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack");
            var             client          = ToolFactory.Ioc.Get <IHttpClient>();
            X509Certificate x509Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFilePath, certPwd);

            var result = client.Post(url, postXmlData, x509Certificate, new RemoteCertificateValidationCallback(CheckValidationResult));


            var sendRedPackResult = ToolFactory.CreateIXmlSerializeTool().DeserializeFromString <SendRedPackResult>(result);

            return(sendRedPackResult);
        }
Ejemplo n.º 24
0
        public object Bind(object obj)
        {
            var type = obj.GetType();

            var iProgramTool = ToolFactory.CreateIProgramTool();

            foreach (var propertyPath in this._NameValueCollection.AllKeys)
            {
                if (string.IsNullOrEmpty(propertyPath))
                {
                    continue;
                }

                var nvValues = this._NameValueCollection.GetValues(propertyPath);

                if (nvValues == null || nvValues.Length == 0)
                {
                    continue;
                }

                var bindingFlags = BindingFlags.IgnoreCase | BindingFlags.Instance |
                                   BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty;

                var property = ReflectorHelper.GetPropertyInfoOrDefault(type, propertyPath, bindingFlags);

                if (property == null)
                {
                    continue;
                }

                object realValue    = null;
                var    propertyType = property.PropertyType;

                try
                {
                    realValue = iProgramTool.ChanageType(nvValues, property.PropertyType);
                }
                catch
                {
                }

                if (realValue != null)
                {
                    ReflectorHelper.SetProperty(obj, propertyPath, realValue, null);
                }
            }
            return(obj);
        }
Ejemplo n.º 25
0
        public IList <WeiXinAccount> GetBasicAccountInfos(string accessToken, IList <GetBasicAccountInfosParam> getBasicAccountInfosParams)
        {
            var user_list = new GetBasicAccountInfosParamUserList()
            {
                user_list = getBasicAccountInfosParams
            };
            var url      = string.Format("https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token={0}", accessToken);
            var client   = ToolFactory.Ioc.Get <IHttpClient>();
            var postData = ToolFactory.CreateIJsonSerializeTool().SerializeToString(user_list);
            var result   = client.Post(url, postData);

            WeiXinHelper.IsFailureInvokeWeiXinAPIThrowException(result);
            var modelResult = WeiXinHelper.JsonHelper().DeserializeFromString <GetBasicAccountInfosResultUserInfoList>(result);

            return(modelResult.user_info_list);
        }
Ejemplo n.º 26
0
        public virtual void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.lastUser = who;
            short seed = (short)Game1.random.Next((int)short.MinValue, 32768);

            if (Game1.IsClient && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                ToolDescription indexFromTool = ToolFactory.getIndexFromTool(this);
                Game1.client.sendMessage((byte)7, new object[7]
                {
                    (object)indexFromTool.index,
                    (object)indexFromTool.upgradeLevel,
                    (object)(short)x,
                    (object)(short)y,
                    (object)location.name,
                    (object)(byte)who.FacingDirection,
                    (object)seed
                });
            }
            else if (Game1.IsServer && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                MultiplayerUtility.broadcastToolAction(this, x, y, location.name, (byte)who.FacingDirection, seed, who.uniqueMultiplayerID);
            }
            if (this.isHeavyHitter() && !(this is MeleeWeapon))
            {
                Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 4.0), (float)(100 + Game1.random.Next(50)));
                location.damageMonster(new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), this.upgradeLevel + 1, (this.upgradeLevel + 1) * 3, false, who);
            }
            if (!(this is MeleeWeapon) || who.UsingTool && Game1.mouseClickPolling < 50 && ((this as MeleeWeapon).type != 1 && (this as MeleeWeapon).initialParentTileIndex != 47) && (MeleeWeapon.timedHitTimer <= 0 && who.FarmerSprite.indexInCurrentAnimation == 5 && (double)who.FarmerSprite.timer < (double)who.FarmerSprite.interval / 4.0))
            {
                return;
            }
            if ((this as MeleeWeapon).type == 2 && (this as MeleeWeapon).isOnSpecial)
            {
                (this as MeleeWeapon).doClubFunction(who);
            }
            else
            {
                if (who.FarmerSprite.indexInCurrentAnimation <= 0)
                {
                    return;
                }
                MeleeWeapon.timedHitTimer = 500;
            }
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            if (!Env.ProcessEnvArguments(args))
            {
                return;
            }


            var tool = ToolFactory.Create(Env.Tool.Value);

            if (!tool.ProcessArguments(Env.Args))
            {
                return;
            }

            tool.Run();
        }
Ejemplo n.º 28
0
        public static T RequestParam <T>(string parameterName, T defaultValue = default(T))
        {
            IValidatorTool validator       = ToolFactory.CreateIValidatorTool();
            var            srcRequestValue = Request[parameterName];

            if (validator.IsEmpty(srcRequestValue))
            {
                return(default(T));
            }
            T value = ToolFactory.CreateIProgramTool().ChanageType <T>(srcRequestValue);

            if (value == null && defaultValue != null)
            {
                return(defaultValue);
            }
            return(value);
        }
Ejemplo n.º 29
0
        public void UnGZip()
        {
            var filePath = @"d:\2.gz";

            var jsonHelper = ToolFactory.CreateIJsonSerializeTool();

            using (var sr = GZipHelper.UnGZipToStreamReader(filePath))
            {
                while (sr.EndOfStream == false)
                {
                    var l    = sr.ReadLine();
                    var json = l + "]}";
                }
            }

            var i = 0;
        }
Ejemplo n.º 30
0
        private void SelectedFeaturePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_isLocked)
            {
                return;
            }

            _lwlcTool = ToolFactory.NewLWLCTool();

            _toolParameter = new BindingList <IToolParameter>(_lwlcTool.ToolParameterContainer.ToolParameter);

            if (_selectedFeature != null)
            {
                foreach (var currentField in _selectedFeature.Fields)
                {
                    currentField.UnRegisterPropertyHandler(_listOfpropertyChangedEventHandlersForFieldIsSelected);
                }
            }

            _selectedFeature = _mcdaExtension.SelectedFeature;

            if (_selectedFeature != null)
            {
                foreach (var currentField in _selectedFeature.Fields)
                {
                    _listOfpropertyChangedEventHandlersForFieldIsSelected.Add(currentField.RegisterPropertyHandler(f => f.IsSelected, FieldPropertyChanged));
                }

                if (_selectedFeature.Fields.Count(f => f.IsSelected) >= 1)
                {
                    //ProgressDialog.ShowProgressDialog("Running LWLC Tool", (Action)_lwlcTool.Run);

                    ProgressDialogBuilder progressDialogBuilder = new ProgressDialogBuilder((Action <ProgressHandler>)_lwlcTool.Run);
                    progressDialogBuilder.SetTitle("Running LWLC Tool").Build().Show();

                    _lwlcResultDataTable = _lwlcTool.Data;
                }
            }

            RegisterToolParameterEvents();

            PropertyChanged.Notify(() => LWLCParameter);
            PropertyChanged.Notify(() => LWLCResult);

            CommandManager.InvalidateRequerySuggested();
        }
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model = model;
            _solverResult = data;

            var jobFactory = new JobFactory();
            var skillFactory = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory = new ToolFactory();
            var zoneFactory = new ZoneFactory();
            var shiftFactory = new ShiftFactory();
            
            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager = new JobManager(jobConverter);
            _zoneManager = new ZoneManager(zoneConverter);
        }