public override void DoAction(AbstractModel model, bool includeOneTime) { if (!IsOneTimeOk(includeOneTime)) return; if (model == null) return; var result = EvaluateConditions(); if (!result.Result) return; if (model.Content == null) return; if (model.RootDialogModel == null) return; if (model.RootDialogModel.DialogInstance == null) return; var element = model.Content as IInputElement; if (element == null) return; FocusManager.SetFocusedElement(model.RootDialogModel.DialogInstance, element); Keyboard.Focus(element); Application.Current.DoEvents(); }
private MyAbstractViewModel GetMyAbstract() { MyAbstractViewModel model = new MyAbstractViewModel(); model.AbstractDictionary = new Dictionary <AbstractModel, List <AbstractModel> >(); AbstractManager manager = new AbstractManager(); List <AbstractModel> list = manager.GetMyList(User.Identity.Name); int i = int.MaxValue; AbstractModel temp = null; foreach (AbstractModel item in list) { if (i > item.GroupId) { model.AbstractDictionary.Add(item, new List <AbstractModel>()); temp = item; i = item.GroupId; } else { model.AbstractDictionary[temp].Add(item); } } return(model); }
static void Main1(string[] args) { try { Credential cred = new Credential { SecretId = Environment.GetEnvironmentVariable("TENCENTCLOUD_SECRET_ID"), SecretKey = Environment.GetEnvironmentVariable("TENCENTCLOUD_SECRET_KEY") }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); // 代理服务器,当你的环境下有代理服务器时设定 httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY"); clientProfile.HttpProfile = httpProfile; VpcClient client = new VpcClient(cred, "ap-guangzhou", clientProfile); ModifyAddressTemplateAttributeRequest req = new ModifyAddressTemplateAttributeRequest(); req.Addresses = new string[] { "eip-hxlqja90" }; req.AddressTemplateId = "ipm-mdunqeb6"; req.AddressTemplateName = "TestName"; ModifyAddressTemplateAttributeResponse resp = client.ModifyAddressTemplateAttributeSync(req); Console.WriteLine(AbstractModel.ToJsonString(resp)); } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.Read(); }
public virtual Task <ApiActionResponse> AuthorizeAsync(HttpContext context, AbstractModel abstractModel, CancellationToken cancellationToken) { return(Task.FromResult <ApiActionResponse>(!context.User.Identity.IsAuthenticated ? new ObjectResponse(_failureStatusCode) : null)); }
public bool Edit(AbstractModel model) { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); string sql = "INSERT INTO AbstractNodes" + "([GroupId],[Author],[CoAuthors],[Body],[KeyWords],[PreType],[Theme],[Title]) VALUES" + "(@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8);"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@p1", model.GroupId); cmd.Parameters.AddWithValue("@p2", model.Author); cmd.Parameters.AddWithValue("@p3", model.CoAuthors == null ? "" : model.CoAuthors); cmd.Parameters.AddWithValue("@p4", model.AbstarctBody); cmd.Parameters.AddWithValue("@p5", model.KeyWords); cmd.Parameters.AddWithValue("@p6", model.PresentationType); cmd.Parameters.AddWithValue("@p7", model.INCISETheme); cmd.Parameters.AddWithValue("@p8", model.AbstarctTitle); if (cmd.ExecuteNonQuery() == 1) { return(true); } else { return(false); } } }
public async Task <VodUploadResponse> Upload(string region, VodUploadRequest req) { CheckRequest(region, req); TencentCloud.Common.Credential cred = new TencentCloud.Common.Credential { SecretId = SecretId, SecretKey = SecretKey }; VodClient vodClient = new VodClient(cred, region); ApplyUploadResponse applyResp = await DoApplyRequest(vodClient, req); //Console.WriteLine(AbstractModel.ToJsonString(applyResp)); await DoUploadAction(applyResp, req); CommitUploadResponse commitResp = await DoCommitRequest(vodClient, applyResp); //Console.WriteLine(AbstractModel.ToJsonString(commitResp)); VodUploadResponse rsp = AbstractModel.FromJsonString <VodUploadResponse>(AbstractModel.ToJsonString(commitResp)); return(rsp); }
public void ApplyAbstractModel() { var routeData = new RouteData(); routeData.Values.Add("prop1", "prop1stringvalue"); routeData.Values.Add("prop2", 2); var mockContext = new Mock <IAbstractModelApplicationRequestContext>(); mockContext.Setup(m => m.RouteData).Returns(routeData); var abstractModel = new AbstractModel(); var applicator = new RouteDataAbstractModelApplicator(); applicator.ApplyAsync(mockContext.Object, abstractModel, CancellationToken.None); Assert.AreEqual(2, abstractModel.ChildCount); var prop1 = abstractModel["prop1"]; Assert.IsNotNull(prop1); Assert.AreEqual(0, prop1.ChildCount); Assert.AreEqual(1, prop1.ValueCount); Assert.AreEqual("prop1stringvalue", prop1.Values[0]); var prop2 = abstractModel["prop2"]; Assert.IsNotNull(prop2); Assert.AreEqual(0, prop2.ChildCount); Assert.AreEqual(1, prop2.ValueCount); Assert.AreEqual(2, prop2.Values[0]); }
/// <summary> /// 替换模号件号 /// </summary> /// <param name="model"></param> /// <param name="info"></param> /// <returns></returns> public static Part Replace(AbstractModel model, MoldInfoModel info) { Session theSession = Session.GetSession(); UFSession theUFSession = UFSession.GetUFSession(); Part workPart = theSession.Parts.Work; Component ct = model.GetPartComp(workPart); string OldName = model.MoldInfo.MoldNumber + "-" + model.MoldInfo.WorkpieceNumber; string newName = info.MoldNumber + "-" + info.WorkpieceNumber; string newPartPath = model.WorkpiecePath.Replace(OldName, newName); if (File.Exists(newPartPath)) { File.Delete(newPartPath); } File.Move(model.WorkpiecePath, newPartPath); if (ct != null) { model.PartTag.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null); if (Basic.AssmbliesUtils.ReplaceComp(ct, newPartPath, ct.Name.Replace(OldName, newName))) { return(ct.Prototype as Part); } return(null); } else { model.PartTag.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null); //NXOpen.PartLoadStatus partLoadStatus1; //BasePart part = theSession.Parts.OpenBaseDisplay(newPartPath, out partLoadStatus1); Tag partTag; UFPart.LoadStatus error_status; theUFSession.Part.Open(newPartPath, out partTag, out error_status); return(NXObjectManager.Get(partTag) as Part); } }
private void SendRequest(object state) { mServerResult = string.Empty; try { #if TENCENT ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("iai.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; IaiClient client = new IaiClient(mCredential, "", clientProfile); DetectFaceRequest req = DetectFaceRequest.FromJsonString <DetectFaceRequest>(state.ToString()); DetectFaceResponse resp = client.DetectFace(req).ConfigureAwait(false).GetAwaiter().GetResult(); mServerResult = AbstractModel.ToJsonString(resp); mResult = JsonUtility.FromJson <DFServerResult>(mServerResult); #endif mIsDone = true; } catch (System.Exception ex) { mServerResult = ex.Message; string[] sf = mServerResult.Split(' '); DFServerResult rs = new DFServerResult(); rs.Error = new DFError(); rs.Error.Code = sf[0].Split(':')[1]; rs.Error.Message = sf[1].Split(':')[1]; mResult = rs; mIsDone = true; } }
public void ApplyAbstractModel() { var queryCollection = new QueryCollection(new Dictionary <string, StringValues> { { "prop1", "prop1stringvalue" }, { "prop2", "2" } }); var mockContext = new Mock <IAbstractModelApplicationRequestContext>(); mockContext.Setup(m => m.Query).Returns(queryCollection); var abstractModel = new AbstractModel(); var applicator = new QueryParameterAbstractModelApplicator(); applicator.ApplyAsync(mockContext.Object, abstractModel, CancellationToken.None); Assert.AreEqual(2, abstractModel.ChildCount); var prop1 = abstractModel["prop1"]; Assert.IsNotNull(prop1); Assert.AreEqual(0, prop1.ChildCount); Assert.AreEqual(1, prop1.ValueCount); Assert.AreEqual("prop1stringvalue", prop1.Values[0]); var prop2 = abstractModel["prop2"]; Assert.IsNotNull(prop2); Assert.AreEqual(0, prop2.ChildCount); Assert.AreEqual(1, prop2.ValueCount); Assert.AreEqual("2", prop2.Values[0]); }
public void SupportMultipleValues() { var queryCollection = new QueryCollection(new Dictionary <string, StringValues> { { "multi", new[] { "one", "two" } } }); var mockContext = new Mock <IAbstractModelApplicationRequestContext>(); mockContext.Setup(m => m.Query).Returns(queryCollection); var abstractModel = new AbstractModel(); var applicator = new QueryParameterAbstractModelApplicator(); applicator.ApplyAsync(mockContext.Object, abstractModel, CancellationToken.None); Assert.AreEqual(1, abstractModel.ChildCount); var prop1 = abstractModel["multi"]; Assert.IsNotNull(prop1); Assert.AreEqual(0, prop1.ChildCount); Assert.AreEqual(2, prop1.ValueCount); Assert.AreEqual("one", prop1.Values[0]); Assert.AreEqual("two", prop1.Values[1]); }
public SuffixSensitivePerceptronModelWriter(AbstractModel model, string fileName) : base(model) { string file; Stream output; if (fileName.EndsWith(".gz")) { #if ZIPLIB output = new GZipOutputStream(new FileStream(fileName, FileMode.Create)); #else output = new GZipStream(new FileStream(fileName, FileMode.Create), CompressionMode.Compress); #endif file = fileName.Substring(0, fileName.Length - 3); } else { file = fileName; output = new FileStream(fileName, FileMode.Create); } if (file.EndsWith(".bin")) { suffixAppropriateWriter = new BinaryPerceptronModelWriter(model, output); } else { // default is ".txt" suffixAppropriateWriter = new PlainTextPerceptronModelWriter(model, output); } }
protected void ValidatePOSDictionary(POSDictionary posDic, AbstractModel posModel) { if (!posModel.ContainsOutcomes(posDic)) { throw new InvalidFormatException("Tag dictionary contains tags which are unknown by the model!"); } }
public static string recognize(string img) { try { Credential cred = new Credential { SecretId = SecretID, SecretKey = SecretKey }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("ocr.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile); GeneralBasicOCRRequest req = new GeneralBasicOCRRequest(); string strParams = String.Format("{{\"ImageBase64\":\"{0}\"}}", img); req = GeneralBasicOCRRequest.FromJsonString <GeneralBasicOCRRequest>(strParams); GeneralBasicOCRResponse resp = client.GeneralBasicOCRSync(req); JavaScriptSerializer js = new JavaScriptSerializer(); var dic = js.Deserialize <Dictionary <string, object> >(AbstractModel.ToJsonString(resp)); var list = (System.Collections.ArrayList)dic["TextDetections"]; var output = new StringBuilder(); foreach (var item in list) { output.Append(((Dictionary <string, object>)item)["DetectedText"]).Append("\n"); } return(output.ToString()); } catch (Exception e) { return(e.ToString()); } }
//internal void send() //{ // try // { // /* 必要步骤: // * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。 // * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 // * 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人, // * 以免泄露密钥对危及你的财产安全。 // * CAM密匙查询: https://console.cloud.tencent.com/cam/capi*/ // Credential cred = new Credential // { // SecretId = "我的id", // SecretKey = "密匙" // }; // /* // Credential cred = new Credential { // SecretId = Environment.GetEnvironmentVariable("TENCENTCLOUD_SECRET_ID"), // SecretKey = Environment.GetEnvironmentVariable("TENCENTCLOUD_SECRET_KEY") // };*/ // /* 非必要步骤: // * 实例化一个客户端配置对象,可以指定超时时间等配置 */ // ClientProfile clientProfile = new ClientProfile(); // /* SDK默认用TC3-HMAC-SHA256进行签名 // * 非必要请不要修改这个字段 */ // clientProfile.SignMethod = ClientProfile.SIGN_TC3SHA256; // /* 非必要步骤 // * 实例化一个客户端配置对象,可以指定超时时间等配置 */ // HttpProfile httpProfile = new HttpProfile(); // /* SDK默认使用POST方法。 // * 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求 */ // httpProfile.ReqMethod = "GET"; // /* SDK有默认的超时时间,非必要请不要进行调整 // * 如有需要请在代码中查阅以获取最新的默认值 */ // httpProfile.Timeout = 10; // 请求连接超时时间,单位为秒(默认60秒) // /* SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务 // * 则必须手动指定域名,例如sms的上海金融区域名: sms.ap-shanghai-fsi.tencentcloudapi.com */ // httpProfile.Endpoint = "sms.tencentcloudapi.com"; // // 代理服务器,当你的环境下有代理服务器时设定 // httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY"); // clientProfile.HttpProfile = httpProfile; // /* 实例化要请求产品(以sms为例)的client对象 // * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量 */ // SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile); // /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 // * 你可以直接查询SDK源码确定SendSmsRequest有哪些属性可以设置 // * 属性可能是基本类型,也可能引用了另一个数据结构 // * 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明 */ // SendSmsRequest req = new SendSmsRequest(); // /* 基本类型的设置: // * SDK采用的是指针风格指定参数,即使对于基本类型你也需要用指针来对参数赋值。 // * SDK提供对基本类型的指针引用封装函数 // * 帮助链接: // * 短信控制台: https://console.cloud.tencent.com/sms/smslist // * sms helper: https://cloud.tencent.com/document/product/382/3773 */ // req.SmsSdkAppid = "1400787878"; // /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看 */ // req.Sign = "雪雪雪个人技术站"; // /* 短信码号扩展号: 默认未开通,如需开通请联系 [sms helper] */ // req.ExtendCode = "x"; // /* 国际/港澳台短信 senderid: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */ // req.SenderId = ""; // /* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */ // req.SessionContext = ""; // /* 下发手机号码,采用 e.164 标准,+[国家或地区码][手机号] // * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号*/ // req.PhoneNumberSet = new String[] { "+8618030297576" }; // /* 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看 */ // req.TemplateID = "590943"; // /* 模板参数: 若无模板参数,则设置为空*/ // req.TemplateParamSet = new String[] { "666" }; // // 通过client对象调用DescribeInstances方法发起请求。注意请求方法名与请求对象是对应的 // // 返回的resp是一个DescribeInstancesResponse类的实例,与请求对象对应 // SendSmsResponse resp = client.SendSmsSync(req); // // 输出json格式的字符串回包 // Console.WriteLine(AbstractModel.ToJsonString(resp)); // } // catch (Exception e) // { // Console.WriteLine(e.ToString()); // } // Console.Read(); //} internal void Send() { try { Credential cred = new Credential { SecretId = "AKIDKeRJuDD5i4AKVjdwvjfLkwrUqMzLdGpW", SecretKey = "avzqRlB44AONALIzJMccMp42jBMwFIzP" }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("sms.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile); SendSmsRequest req = new SendSmsRequest(); string strParams = "{\"PhoneNumberSet\":[\"+8618030297576\"],\"TemplateID\":\"590943\",\"Sign\":\"雪雪雪个人技术站\",\"TemplateParamSet\":[\"123\"],\"SmsSdkAppid\":\"1400358718\"}"; req = SendSmsRequest.FromJsonString <SendSmsRequest>(strParams); SendSmsResponse resp = client.SendSmsSync(req); Console.WriteLine(AbstractModel.ToJsonString(resp)); } catch (Exception e) { Console.WriteLine(e.ToString()); } Console.Read(); }
public UiModule(Contexts contexts) { UiModule.contexts = contexts; instance = this; var loader = new UiResourceLoader(contexts.session.commonSession.AssetManager); AbstractModel.SetUiResourceLoader(loader); FreeGlobalVars.Loader = loader; if (UIImageLoader.LoadSpriteAsync == null) //没有通过大厅直接进入游戏 { UIImageLoader.LoadSpriteAsync = loader.RetriveSpriteAsync; } if (UIImageLoader.LoadTextureAsync == null) { UIImageLoader.LoadTextureAsync = loader.RetriveTextureAsync; } InitBlurManager(loader); InitUiSubManager(loader); AddModelSystems(); AddSystem(new UiSessionSystem(contexts)); //AddSystem(new UiPlayerDataInitSystem(contexts)); AddSystem(new ObserveUISystem(contexts)); AddSystem(this); }
public virtual async Task HandleEventAsync(UserUpdatedEventData eventData) { var user = await _userManager.GetUserByIdAsync(eventData.UserId); user.Surname = eventData.PhoneNumber; await _userManager.UpdateAsync(user); await _userManager.ChangePhoneNumberAsync(user, eventData.PhoneNumber, string.Empty); try { Credential cred = new Credential { SecretId = "AKID1sZ03uwxf9Ub", SecretKey = "JEyWwAA0bxBE4jAML" }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("sms.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; SmsClient client = new SmsClient(cred, "ap-shanghai", clientProfile); SendSmsRequest req = new SendSmsRequest(); string strParams = "{\"PhoneNumberSet\":[\"+8618538705067\"],\"TemplateID\":\"186797\",\"Sign\":\"江南艺考\",\"TemplateParamSet\":[\"王彤\",\"最近学习好\",\"成绩提升很快\"],\"SmsSdkAppid\":\"1466134967\"}"; req = SendSmsRequest.FromJsonString <SendSmsRequest>(strParams); SendSmsResponse resp = client.SendSms(req).ConfigureAwait(false).GetAwaiter().GetResult();; Logger.Info(AbstractModel.ToJsonString(resp)); } catch (Exception e) { Logger.Error(e.ToString()); } }
/// <summary> /// 验证码校验 /// </summary> /// <param name="ticket"></param> /// <param name="randstr"></param> /// <returns></returns> public async Task<ServiceResult<DescribeCaptchaResultResponse>> CaptchaAsync(string ticket, string randstr) { var result = new ServiceResult<DescribeCaptchaResultResponse>(); var ip = _httpContextAccessor.HttpContext.Request.GetClientIp(); var parameters = new { CaptchaType = "9", UserIp = ip, Ticket = ticket, Randstr = randstr, CaptchaAppId = AppSettings.TencentCloud.Captcha.APIKey, AppSecretKey = AppSettings.TencentCloud.Captcha.SecretKey, }; DoTencentCloudAction("captcha", out Credential cred, out ClientProfile clientProfile); var client = new CaptchaClient(cred, "", clientProfile); var req = AbstractModel.FromJsonString<DescribeCaptchaResultRequest>(parameters.ToJson()); var resp = await client.DescribeCaptchaResult(req); if (resp.CaptchaCode != 1) result.IsFailed(resp.CaptchaMsg); else result.IsSuccess(resp); return result; }
/// <summary> /// Constructor which takes a GISModel and a File and invokes the /// GISModelWriter appropriate for the suffix. /// </summary> /// <param name="model"> The GISModel which is to be persisted. </param> /// <param name="f"> The File in which the model is to be stored. </param> public SuffixSensitivePerceptronModelWriter(AbstractModel model, Jfile f) : base(model) { OutputStream output; string filename = f.Name; // handle the zipped/not zipped distinction if (filename.EndsWith(".gz", StringComparison.Ordinal)) { output = new GZIPOutputStream(new FileOutputStream(f)); filename = filename.Substring(0, filename.Length - 3); } else { output = new DataOutputStream(new FileOutputStream(f)); } // handle the different formats if (filename.EndsWith(".bin", StringComparison.Ordinal)) { suffixAppropriateWriter = new BinaryPerceptronModelWriter(model, new DataOutputStream(output)); } else // default is ".txt" { suffixAppropriateWriter = new PlainTextPerceptronModelWriter(model, new BufferedWriter(new OutputStreamWriter(output))); } }
public static string Translation(string srcText, string from, string to) { Credential cred = new Credential { SecretId = TengxunKey.SecretId, SecretKey = TengxunKey.SecretKey }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Timeout = 6; httpProfile.Endpoint = ("tmt.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; TmtClient client = new TmtClient(cred, "ap-guangzhou", clientProfile); TextTranslateRequest request = new TextTranslateRequest(); request.SourceText = srcText; request.Source = from; request.Target = to; request.ProjectId = 0; TextTranslateResponse response; try { response = client.TextTranslateSync(request); } catch (Exception ex) { throw ex.InnerException; } string result = AbstractModel.ToJsonString(response); var list = JsonConvert.DeserializeObject <TranslationJson>(result); return(list.TargetText); }
/// <summary> /// DoCdnAction /// </summary> /// <typeparam name="T"></typeparam> /// <param name="client"></param> /// <param name="req"></param> /// <param name="json"></param> private static void DoCdnAction<T>(out CdnClient client, out T req, string json) { DoTencentCloudAction("cdn", out Credential cred, out ClientProfile clientProfile); client = new CdnClient(cred, "", clientProfile); req = AbstractModel.FromJsonString<T>(json); }
public Controller(Game game, AbstractModel model) : base(game) { Enabled = false; Model = model; for (int i = 0; i < MaxInputs; i++) { Controls[i] = new Hashtable(); } //keyboard controls Controls[0][Keys.A] = PlayerAction.MoveLeft; Controls[0][Keys.D] = PlayerAction.MoveRight; Controls[0][Keys.W] = PlayerAction.AimUp; Controls[0][Keys.S] = PlayerAction.AimDown; Controls[0][Keys.C] = PlayerAction.Jump; Controls[0][Keys.V] = PlayerAction.Fire; Controls[0][Keys.E] = PlayerAction.NextWeapon; Controls[0][Keys.Q] = PlayerAction.PreviousWeapon; Controls[0][Keys.B] = PlayerAction.Dig; Controls[0][Keys.LeftControl] = PlayerAction.Accept; Controls[0][Keys.LeftShift] = PlayerAction.Cancel; Controls[1][Keys.Left] = PlayerAction.MoveLeft; Controls[1][Keys.Right] = PlayerAction.MoveRight; Controls[1][Keys.Up] = PlayerAction.AimUp; Controls[1][Keys.Down] = PlayerAction.AimDown; Controls[1][Keys.OemPeriod] = PlayerAction.Jump; Controls[1][Keys.OemComma] = PlayerAction.Fire; Controls[1][Keys.L] = PlayerAction.NextWeapon; Controls[1][Keys.K] = PlayerAction.PreviousWeapon; Controls[1][Keys.M] = PlayerAction.Dig; Controls[1][Keys.Enter] = PlayerAction.Accept; Controls[1][Keys.Escape] = PlayerAction.Cancel; // Gamepad controls foreach (Hashtable ht in Controls) { ht[Buttons.LeftThumbstickLeft] = PlayerAction.MoveLeft; ht[Buttons.LeftThumbstickRight] = PlayerAction.MoveRight; ht[Buttons.LeftThumbstickUp] = PlayerAction.AimUp; ht[Buttons.LeftThumbstickDown] = PlayerAction.AimDown; ht[Buttons.RightThumbstickLeft] = PlayerAction.MoveLeft; ht[Buttons.RightThumbstickRight] = PlayerAction.MoveRight; ht[Buttons.RightThumbstickUp] = PlayerAction.AimUp; ht[Buttons.RightThumbstickDown] = PlayerAction.AimDown; ht[Buttons.DPadLeft] = PlayerAction.MoveLeft; ht[Buttons.DPadRight] = PlayerAction.MoveRight; ht[Buttons.DPadUp] = PlayerAction.AimUp; ht[Buttons.DPadDown] = PlayerAction.AimDown; ht[Buttons.A] = ht[Buttons.LeftTrigger] = PlayerAction.Jump; ht[Buttons.RightTrigger] = PlayerAction.Fire; ht[Buttons.LeftShoulder] = PlayerAction.PreviousWeapon; ht[Buttons.RightShoulder] = PlayerAction.NextWeapon; ht[Buttons.Start] = PlayerAction.Accept; ht[Buttons.B] = PlayerAction.Cancel; ht[Buttons.X] = PlayerAction.Dig; } }
public bool NewAbstract(AbstractModel model, string userName) { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); SqlTransaction transaction = conn.BeginTransaction(); cmd.Transaction = transaction; cmd.CommandType = System.Data.CommandType.Text; try { cmd.CommandText = "INSERT INTO AbstractGroups([UserName]) VALUES(@pn1);"; cmd.Parameters.AddWithValue("@pn1", userName);; cmd.ExecuteNonQuery(); int groupId; cmd.CommandText = "SELECT top 1 GroupId FROM AbstractGroups WHERE UserName=@pn2 ORDER BY GroupId desc;"; cmd.Parameters.AddWithValue("@pn2", userName); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { groupId = dr.GetInt32(0); dr.Close(); } else { dr.Close(); transaction.Rollback(); return(false); } cmd.CommandText = "INSERT INTO AbstractNodes" + "([GroupId],[Author],[CoAuthors],[Body],[KeyWords],[PreType],[Theme],[Title]) VALUES" + "(@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8);"; cmd.Parameters.AddWithValue("@p1", groupId); cmd.Parameters.AddWithValue("@p2", model.Author); cmd.Parameters.AddWithValue("@p3", model.CoAuthors == null ? "" : model.CoAuthors); cmd.Parameters.AddWithValue("@p4", model.AbstarctBody); cmd.Parameters.AddWithValue("@p5", model.KeyWords); cmd.Parameters.AddWithValue("@p6", model.PresentationType); cmd.Parameters.AddWithValue("@p7", model.INCISETheme); cmd.Parameters.AddWithValue("@p8", model.AbstarctTitle); cmd.ExecuteNonQuery(); transaction.Commit(); return(true); } catch (SqlException e1) { try { transaction.Rollback(); return(false); } catch (Exception e2) { return(false); } } } }
public void ApplyMultiLayerObject() { var data = new { first = "firstvalue", inner = new { Foo = "bar", Multi = new[] { "one", "two" } } }; var mockContext = new Mock <IAbstractModelApplicationRequestContext>(); mockContext.Setup(c => c.ContentType).Returns("application/json"); mockContext.Setup(c => c.Stream) .Returns(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(data)))); var applicator = new JsonAbstractModelApplicator(); var abstractModel = new AbstractModel(); Assert.IsTrue(abstractModel.IsEmpty); applicator.ApplyAsync(mockContext.Object, abstractModel, CancellationToken.None).Wait(); Assert.IsFalse(abstractModel.IsEmpty); Assert.AreEqual(0, abstractModel.ValueCount); Assert.AreEqual(2, abstractModel.ChildCount); var first = abstractModel["first"]; Assert.IsNotNull(first); Assert.AreEqual(0, first.ChildCount); Assert.AreEqual(1, first.ValueCount); Assert.AreEqual("firstvalue", first.Values[0]); var inner = abstractModel["inner"]; Assert.IsNotNull(inner); Assert.AreEqual(2, inner.ChildCount); Assert.AreEqual(0, inner.ValueCount); var foo = inner["foo"]; Assert.IsNotNull(foo); Assert.AreEqual(0, foo.ChildCount); Assert.AreEqual(1, foo.ValueCount); Assert.AreEqual("bar", foo.Values[0]); var multi = inner["multi"]; Assert.IsNotNull(multi); Assert.AreEqual(0, multi.ChildCount); Assert.AreEqual(2, multi.ValueCount); Assert.AreEqual("one", multi.Values[0]); Assert.AreEqual("two", multi.Values[1]); }
[HttpPost]/*, ValidateAntiForgeryToken]*/ public ActionResult AbstractSave(AbstractModel model) { if (ModelState.IsValid && MainObject.CheckUserHasWriteAccess(model.MainId)) { model.Save(); } return(null); }
public StringSettingWrapper(string key, string value, AbstractModel model) { _key = key; _secureContent = new SecureString(); Model = model; foreach (var entry in value.ToCharArray()) { _secureContent.AppendChar(entry); } }
public Task ApplyAsync(IAbstractModelApplicationRequestContext context, AbstractModel abstractModel, CancellationToken cancellationToken) { foreach (var parameter in context.RouteData.Values) { abstractModel.Add(new AbstractModel(parameter.Key, parameter.Value)); } return(Task.FromResult(true)); }
public virtual void Raise(AbstractModel model) { var audit = new Audit() { Value = model.ToString() }; _auditRepository.Add(audit); _auditRepository.Complete(); }
public async Task RaiseAsync(AbstractModel model) { var audit = new Audit() { Value = model.ToString() }; await _auditRepository.AddAsync(audit); await _auditRepository.CompleteAsync(); }
protected PerceptronModelWriter(AbstractModel model) { var data = model.GetDataStructures(); numOutcomes = model.GetNumOutcomes(); PARAMS = (Context[])data[0]; OUTCOME_LABELS = (string[])data[2]; var map = (IndexHashTable<string>)data[1]; PRED_LABELS = new string[map.Size]; map.ToArray(PRED_LABELS); }
public string GetResult() { client = new TmtClient(cred, "ap-guangzhou-open", clientProfile); string strParams = "{\"SourceText\":\"" + SourceText + "\",\"Source\":\"" + Source + "\",\"Target\":\"" + Target + "\",\"ProjectId\":0}"; req = AbstractModel.FromJsonString <TextTranslateRequest>(strParams); TextTranslateResponse resp = client.TextTranslate(req).Result; return(AbstractModel.ToJsonString(resp)); }
public ButtonSettingsCommand(ISettingsManager manager, AbstractModel model, SettingsLink wrapper) : base(model) { if (wrapper == null) throw new Exception("Expected settings link wrapper"); _manager = manager; _model = model; _key = wrapper.Target; _value = wrapper.Value; }
/// <summary> /// Constructor which takes a GISModel and a File and prepares itself to /// write the model to that file. Detects whether the file is gzipped or not /// based on whether the suffix contains ".gz". /// </summary> /// <param name="model"> The GISModel which is to be persisted. </param> /// <param name="f"> The File in which the model is to be persisted. </param> public PlainTextGISModelWriter(AbstractModel model, Jfile f) : base(model) { if (f.Name.EndsWith(".gz", StringComparison.Ordinal)) { output = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(f)))); } else { output = new BufferedWriter(new FileWriter(f)); } }
public UiLoadModule(ISessionState sessionState, Contexts contexts) { // var uiRoot = GameObject.Find("ClientUIRoot"); // UiCommon.UIManager = new UIManager("ClientUIRoot"); // UiCommon.TipManager = UiCommon.UIManager.GetTipManager(); var loader = new UiResourceLoader(contexts.session.commonSession.AssetManager); AbstractModel.SetUiResourceLoader(loader); AddSystem(new UiLoadSystem(sessionState, contexts)); }
public override void DoAction(AbstractModel model, bool includeOneTime) { if (!IsOneTimeOk(includeOneTime)) return; if (model == null) return; if (model.RootDialogModel == null) return; var conditionResult = EvaluateConditions(); if (!conditionResult.Result) return; model.RootDialogModel.Result = Result; }
public override void DoAction(AbstractModel model, bool includeOneTime) { try { if (!IsOneTimeOk(includeOneTime)) return; if (model == null) return; var result = EvaluateConditions(); if (!result.Result) return; model.Visibility = Visibility.Visible; } catch (Exception e) { Log.Warn(e); } }
public override void DoAction(AbstractModel model, bool includeOneTime) { try { if (!IsOneTimeOk(includeOneTime)) return; if (model == null) return; if (model.Content == null) return; var result = EvaluateConditions(); if (!result.Result) return; if ((model.Content as TextBox) != null) { var target = model.Content as TextBox; target.SelectAll(); target.Focus(); } if ((model.Content as PasswordBox) != null) { var target = model.Content as PasswordBox; target.SelectAll(); target.Focus(); Keyboard.Focus(target); } } catch (Exception e) { Log.Warn(e); } }
public SettingsConverter(AbstractModel model, ISettingsManager manager) { _model = model; Manager = manager; }
public AbstractContentModel(AbstractModel parentModel) : base(parentModel) { FontFamily = AppearanceManager.DefaultFontFamily; FontSize = 11; }
/// <summary> /// Constructor which takes a <see cref="GISModel"/> and a <paramref name="outStream"/> and prepares itself to write the model to that stream. /// </summary> /// <param name="model">The model.</param> /// <param name="outStream">The out stream.</param> public BinaryQNModelWriter(AbstractModel model, Stream outStream) : base(model) { writer = new BinaryFileDataWriter(outStream); }
public SettingToIntegerConverter(AbstractModel model, ISettingsManager manager) : base(model,manager) { }
public AdvancedButtonHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public BannerPageModel(AbstractModel parentModel) : this(parentModel.RootDialogModel) { }
public StringSettingWrapper(string key, SecureString value, AbstractModel model) { _key = key; _secureContent = value; Model = model; }
public BackButtonHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public abstract void DoAction(AbstractModel model, bool includeOneTime);
public ControlPanelHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public TopicHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public OpenFolderHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public UrlHyperlinkModel(AbstractModel parentModel) : base(parentModel) { }
public SettingsValueHyperlinkModel(AbstractModel parentModel,ISettingsManager settingsManager) : base(parentModel) { _settingsManager = settingsManager; }
public void AddTimedMessage(AbstractModel model, string key, string text) { var wrapper = !_timerMessages.ContainsKey(key) ? new TimedMessageWrapper { Active = false, DotCount = 0,} : _timerMessages[key]; wrapper.Model = model; wrapper.BaseText = text; _timerMessages[key] = wrapper; }
protected QNModelWriter(AbstractModel model) : base(model) {}