private static int MenuItemSorter(System.Tuple <ToolStripMenuItem, int, IEnumerable <Action> > m1, System.Tuple <ToolStripMenuItem, int, IEnumerable <Action> > m2) { var p = m1.Item2 - m2.Item2; if (p != 0) { return(p); } return(string.Compare(m1.Item1.Text, m2.Item1.Text, StringComparison.InvariantCulture)); }
public static void dAvgPool2d(float[] dx, int[] x_shape, System.Tuple <int, int> kernel_size, System.Tuple <int, int> stride, System.Tuple <int, int> padding, System.Tuple <int, int> dilation, float[] dy, int[] y_shape) { int x_width = x_shape[3]; int x_height = x_shape[2]; int x_channel = x_shape[1]; int x_batch = x_shape[0]; int y_width = y_shape[3]; int y_height = y_shape[2]; int y_channel = y_shape[1]; int y_batch = y_shape[0]; int stride_x = stride.Item2; int stride_y = stride.Item1; int padding_x = padding.Item2; int padding_y = padding.Item1; int dilation_x = dilation.Item2; int dilation_y = dilation.Item1; int kernel_width = kernel_size.Item2; int kernel_height = kernel_size.Item1; int norm = kernel_width * kernel_height; for (int b = 0; b < x_batch; b++) { Parallel.For(0, x_channel, (int c) => { for (int ox = 0; ox < y_width; ox++) { var ix_ = ox * stride_x - padding_x; for (int oy = 0; oy < y_height; oy++) { var iy_ = oy * stride_y - padding_y; float grad = dy[((c * y_batch + b) * y_height + oy) * y_width + ox] / norm; for (int fx = 0; fx < kernel_width; fx++) { var ix = ix_ + fx * dilation_x; if ((ix >= x_width) || (ix < 0)) { continue; } for (int fy = 0; fy < kernel_height; fy++) { var iy = iy_ + fy * dilation_y; if ((iy >= x_height) || (iy < 0)) { continue; } dx[((c * x_batch + b) * x_height + iy) * x_width + ix] += grad; } } } } }); } }
public override void _Ready() { Mesh = GetNode <MeshInstance>("MeshInstance"); ShaderMaterial Mat = new ShaderMaterial(); Mat.Shader = Items.TileShader; Mat.SetShaderParam("texture_albedo", Items.Textures[Type]); GetNode <MeshInstance>("MeshInstance").MaterialOverride = Mat; CurrentChunkTuple = World.GetChunkTuple(Translation); }
public void RemoveResponse(Type protoType, object handler, MethodInfo method) { int objIx = this.GetProtoTypeIx(protoType); //going to add a response tuple to our object var toRemove = new System.Tuple <MethodInfo, object>(method, handler); if (this.handlers[objIx].Remove(toRemove)) { Debug.Log($"Removed message handler {handler.GetType()}"); } }
public static ReportDataSource TopListPerCount(bool platce) { string field = "prijemce.ico"; if (platce) { field = "platce.ico"; } int size = 300; AggregationContainerDescriptor <HlidacStatu.Lib.Data.Smlouva> aggs = new AggregationContainerDescriptor <HlidacStatu.Lib.Data.Smlouva>() .Terms("perIco", m => m .Field(field) .Size(size) ); var res = HlidacStatu.Lib.Data.Smlouva.Search.RawSearch("{\"query_string\": { \"query\": \"-id:pre*\" } }", 1, 0, anyAggregation: aggs); ReportDataSource rdsPerIco = new ReportDataSource(new ReportDataSource.Column[] { new ReportDataSource.Column() { Name = "IČO", HtmlRender = (s) => { System.Tuple <string, string> data = (System.Tuple <string, string>)s; return(string.Format("<a href='/subjekt/{0}'>{1}</a>", data.Item2, data.Item1.Replace("&", "&"))); }, TextRender = (s) => { return(((System.Tuple <string, string>)s).Item1.ToString()); } }, new ReportDataSource.Column() { Name = "Počet smluv", HtmlRender = (s) => { return(HlidacStatu.Util.RenderData.NiceNumber(HlidacStatu.Util.ParseTools.ToDecimal((string)s) ?? 0, html: true)); }, OrderValueRender = (s) => { return(HlidacStatu.Util.RenderData.OrderValueFormat(HlidacStatu.Util.ParseTools.ToDecimal((string)s) ?? 0)); } }, } ); foreach (Nest.KeyedBucket <object> val in ((BucketAggregate)res.Aggregations["perIco"]).Items) { HlidacStatu.Lib.Data.Firma f = HlidacStatu.Lib.Data.Firmy.Get((string)val.Key); if (f != null && (!f.PatrimStatu() || platce)) { rdsPerIco.AddRow( new Tuple <string, string>(HlidacStatu.Lib.Data.Firmy.GetJmeno((string)val.Key), (string)val.Key), val.DocCount.ToString() ); } } return(rdsPerIco); }
public async void ChangeImage() { Base.GameManager.Instance.ShowLoadingScreen(); System.Tuple <Sprite, string> image = await ImageHelper.LoadSpriteAndSaveToDb(); if (image != null) { PlayerPrefsHelper.SaveString(projectTile.ProjectId + "/image", image.Item2); projectTile.TopImage.sprite = image.Item1; } Close(); Base.GameManager.Instance.HideLoadingScreen(); }
public static void Store(int location, System.Tuple <float, float, float> updated) { MelonPreferences_Entry <string> melonPref = Main.savedColors; try { var Dict = GetSavedColors(); Dict[location] = updated; melonPref.Value = string.Join(";", Dict.Select(s => String.Format("{0},{1},{2},{3}", s.Key, s.Value.Item1.ToString("F5").TrimEnd('0'), s.Value.Item2.ToString("F5").TrimEnd('0'), s.Value.Item3.ToString("F5").TrimEnd('0')))); Main.cat.SaveToFile(); } catch (System.Exception ex) { Main.Logger.Error($"Error storing new saved color\n" + ex.ToString()); } }
public CommonToken(System.Tuple <ITokenSource, ICharStream> source, int type, int channel, int start, int stop) { this.source = source; this._type = type; this._channel = channel; this.start = start; this.stop = stop; if (source.Item1 != null) { this._line = source.Item1.Line; this.charPositionInLine = source.Item1.Column; } }
private static void AddBonesOfGameObjectToAllPlayers(System.Tuple <GameObject, bool, DynamicBone[], DynamicBoneCollider[], bool> player) { if (player.Item1 != localPlayer) { if (NDBConfig.onlyForMeAndFriends) { if (!player.Item5) { IceLogger.Log($"Not adding bones of player {avatarsInScene.First((x) => x.Value.Item1 == player.Item1).Key} because settings only allow friends"); return; } } if (NDBConfig.disallowDesktoppers) { if (!player.Item2) { IceLogger.Log($"Not adding bones of player {avatarsInScene.First((x) => x.Value.Item1 == player.Item1).Key} because settings disallow desktopper"); return; } } } foreach (DynamicBone db in player.Item3) { if (db == null) { continue; } ApplyBoneSettings(db); } if (NDBConfig.onlyOptimize) { return; } foreach (DynamicBone[] playersColliders in avatarsInScene.Where((x) => SelectBonesWithRules(x) && x.Value.Item1 != player.Item1).Select((x) => x.Value.Item3)) { foreach (DynamicBone playerBone in playersColliders) { foreach (DynamicBoneCollider playerCollider in player.Item4) { if (ColliderMeetsRules(playerCollider, player)) { AddColliderToBone(playerBone, playerCollider); } } } } }
protected virtual object EvalVariableExpr(ParseTree tree, params object[] paramlist) { List <Object> varList = new List <Object>(); Object maybeVarDef = this.GetValue(tree, TokenType.VariableDef, 0); if (maybeVarDef != null) { //First we have a canonical variableDecl from the first VariableDef, then we clone that for any others. sinter.PSE.variableDecleration varDef = (sinter.PSE.variableDecleration)maybeVarDef; System.Tuple <String, bool> varref = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, 0); if ((bool)varref.Item2 == false) //We can't use an array reference here, just ignore any array ref { varDef.name = (String)varref.Item1; varList.Add(varDef); } int ii = 1; varref = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, ii); while (varref != null) { sinter.PSE.variableDecleration thisVarDef = (sinter.PSE.variableDecleration)varDef.Clone(); if ((bool)varref.Item2 == false) //We can't use an array reference here, just ignore any array ref { thisVarDef.name = (String)varref.Item1; varList.Add(thisVarDef); } ii++; varref = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, ii); } } else { sinter.PSE.variableAssignment varAssign = (sinter.PSE.variableAssignment) this.GetValue(tree, TokenType.Assignment, 0); System.Tuple <String, bool> varRef = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, 0); varAssign.gPROMSPath = (String)varRef.Item1; varList.Add(varAssign); // if((bool)varRef.Item2 == false) { //We can't use an array reference here, just ignore any array ref // } int ii = 1; varRef = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, ii); while (varRef != null) { sinter.PSE.variableAssignment thisVarAssign = (sinter.PSE.variableAssignment)varAssign.Clone(); thisVarAssign.gPROMSPath = (String)varRef.Item1; varList.Add(thisVarAssign); ii++; varRef = (System.Tuple <String, bool>) this.GetValue(tree, TokenType.VariableRef, ii); } } return(varList); }
public void SetFairy(int nPage, System.Tuple <Vector3, Vector3> vFairy, System.Tuple <Vector3, Vector3> vBalloon) { UITexture uiFairy = _uiFairy; FairyTexture fairyTexture = _listFairyTexture[nPage]; uiFairy.mainTexture = fairyTexture.item1; _uiFairy.localSize = vFairy.Item1; _uiFairy.transform.localPosition = vFairy.Item2; _uiFairy.alpha = 1f; _uiBalloon.mainTexture = Resources.Load <Texture2D>($"Textures/Startup/PictureStoryShow/info{nPage + 1}_fuki"); _uiBalloon.localSize = vBalloon.Item1; _uiBalloon.transform.localPosition = vBalloon.Item2; _uiBalloon.alpha = 0f; }
public System.Tuple <Task, CancellationTokenSource> Execute(ScriptLanguage language, string scriptCode, TextWriter outputChannel) { // If there is an existing runner then nuke that one if (m_CurrentlyRunningScript != null) { throw new CannotInterruptRunningScriptException(); } if ((m_CurrentLanguageDomainPair != null) && (m_CurrentLanguageDomainPair.Item1 != language)) { // Different language requested so nuke the domain UnloadCurrentScriptDomain(); } if (m_CurrentLanguageDomainPair == null) { var scriptDomain = m_AppDomainBuilder("ScriptDomain", AppDomainPaths.Core); m_CurrentLanguageDomainPair = new System.Tuple <ScriptLanguage, AppDomain>(language, scriptDomain); } IExecuteScripts executor = LoadExecutor(language, m_CurrentLanguageDomainPair.Item2, outputChannel); var source = new CancellationTokenSource(); var token = new CancelScriptToken(source.Token); var result = Task.Factory.StartNew( () => { try { executor.Execute(scriptCode, token); } finally { m_CurrentlyRunningScript = null; if (m_CurrentToken != null) { m_CurrentToken.Dispose(); m_CurrentToken = null; } } }, source.Token, TaskCreationOptions.LongRunning, m_Scheduler); m_CurrentlyRunningScript = result; m_CurrentToken = source; return(new System.Tuple <Task, CancellationTokenSource>(result, source)); }
private void OnCivGainedCity(System.Tuple <ICivilization, ICity> data) { var civ = data.Item1; var city = data.Item2; foreach (var freeBuilding in GetFreeBuildingsForCiv(civ).ToList()) { if (FreeBuildingApplier.CanApplyFreeBuildingToCity(freeBuilding, city)) { FreeBuildingApplier.ApplyFreeBuildingToCity(freeBuilding, city); RemoveFreeBuildingFromCiv(freeBuilding, civ); } } }
public void ShowBaloon(int nPage, System.Tuple <Vector3, Vector3> vBalloon, Action onFinished) { _uiBalloon.mainTexture = Resources.Load <Texture2D>($"Textures/Startup/PictureStoryShow/info{nPage + 1}_fuki"); _uiBalloon.localSize = vBalloon.Item1; _uiBalloon.transform.localPosition = vBalloon.Item2; _uiBalloon.alpha = 0f; _uiBalloon.transform.LTValue(_uiBalloon.alpha, 1f, 0.15f).setEase(LeanTweenType.linear).setOnUpdate(delegate(float x) { _uiBalloon.alpha = x; }) .setOnComplete((Action) delegate { Dlg.Call(ref onFinished); }); }
void IGreeterRpc_NoReply.GreetTuple(System.Tuple <string, string> value) { var _writer_ = NetPool.DataWriterPool.Alloc(); try { _writer_.Write((int)IGreeterRpc_Enum.GreetTuple); NetDataSerializer.Serialize <System.Tuple <string, string> >(_writer_, value); SendRequest(_writer_); } finally { NetPool.DataWriterPool.Free(_writer_); } }
public override bool CanFit() { for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Tuple <int, int> pos = new System.Tuple <int, int>(i, j); if (GameManager.cells.ContainsKey(pos) && (!GameManager.cells[pos].isFull && !GameManager.cells[pos].blocked)) { return(true); } } } return(false); }
public static void EndGame(DataStreamReader stream) { stream.ReadUInt(); byte numberOfScores = stream.ReadByte(); List <System.Tuple <int, ushort> > idScorePairs = new List <System.Tuple <int, ushort> >(); for (int i = 0; i < numberOfScores; i++) { var temp = new System.Tuple <int, ushort>(stream.ReadInt(), stream.ReadUShort()); } EndGameReceived?.Invoke(idScorePairs); }
public void FetchChild(CriteriaBase criteria, System.Tuple <IObjectPortal <IBusinessItem>, IBusinessItemDal, IMobileDependency <IObjectPortal <IBusinessItem> > > d) { var dtos = d.Item2.Fetch(criteria.Guid); foreach (var dto in dtos) { // We allow the Fetch calls (and delegates) to have multiple parameters // But the IHandleXYZ interface can only have one criteria as a parameter // with a tuple to handle multiple parameters // ObjectPortal will bridge the two by turning the multiple paramters to a tuple Add(d.Item1.FetchChild(Tuple.Create <CriteriaBase, BusinessItemDto>(criteria, dto))); } this._newChild = d.Item3; }
private void Reposition() { if (CONTAINER.GetType() == typeof(IGMDataItem.Box)) { ((IGMDataItem.Box)CONTAINER).Draw(true); System.Tuple <Rectangle, Point, Rectangle> dims = ((IGMDataItem.Box)CONTAINER).Dims; if ((_options & Box_Options.Center) != 0) { CONTAINER.X = _bounding.Width / 2 - dims.Item1.Width / 2; } if ((_options & Box_Options.Middle) != 0) { CONTAINER.Y = _bounding.Height / 2 - dims.Item1.Height / 2; } } }
public CanonAndRadarCombiList(IEnumerable <IKanon> canons, IEnumerable <IRadar> radars) { List = new List <System.Tuple <IKanon, IRadar> >(); foreach (IKanon canon in canons) { List.Add(new System.Tuple <IKanon, IRadar>(canon, null)); } // Add the radars to the canons int i = 0; foreach (IRadar radar in radars) { List[i] = new System.Tuple <IKanon, IRadar>(List[i].Item1, radar); } }
public IActionResult PrintBarCode(string idList) { string commaString = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(idList)); string[] strDecodedIdList = commaString.Split(",", StringSplitOptions.RemoveEmptyEntries); long[] decodedIdList = new long[strDecodedIdList.Length]; for (int i = 0; i < strDecodedIdList.Length; i++) { decodedIdList[i] = long.Parse(strDecodedIdList[i]); } List <string> imgDataList = new List <string>(); CommonRepository.UseDbContext(dbContext => { var dataList = dbContext.Set <RfidCard>().Where(x => decodedIdList.Contains(x.RecordId)).Select (x => new { x.WorkshopCode, x.WorkshopName, x.ProductionCode, x.ProductionName, x.RfidNo, Qty = x.IssueQty } ).ToList(); ViewBag.DataList = new List <Tuple <string, string, int, string> >(); foreach (var item in dataList) { string json = item.ToJson(); string base64String = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(json), Base64FormattingOptions.None) .Replace("+", "$_$_$_$_$"); imgDataList.Add(base64String); System.Tuple <string, string, int, string> tuple = Tuple.Create <string, string, int, string> (item.WorkshopName + "(" + item.WorkshopCode + ")", item.ProductionName + "(" + item.ProductionCode + ")", item.Qty, item.RfidNo); base.ViewBag.DataList.Add(tuple); } }); ViewBag.BarcodeDataList = imgDataList; return(View("Imms/MFC/RfidCard/PrintBarCode")); }
private void OnUnitGainedNewOwner(System.Tuple <IUnit, ICivilization> data) { var unit = data.Item1; var newOwner = data.Item2; if ((this as IUnit) == unit) { var meshRenderer = GetComponentInChildren <MeshRenderer>(); if (meshRenderer != null && newOwner != null) { meshRenderer.material.color = newOwner.Template.Color; } PromotionParser.SetMovementSummary(ConcreteMovementSummary, this); PromotionParser.SetCombatSummary(ConcreteCombatSummary, this); } }
public object Evaluate(System.Tuple <Expression, Type> exprType, Type elementType, Type ienumerableExpressionType) { var repoInfo = RepoFinder.CreateRepository(exprType.Item2, ComponentsLoadLevel.Always); object returnObject = null; using (repoInfo.Item1) { //TODO: call it with reduced rights var queryResult = repoInfo.Item2.GetMethod("ExecuteDetachedExpression") .Invoke(repoInfo.Item1, new object[] { exprType.Item1, elementType, ienumerableExpressionType }); var attr = (BoxToAttribute)exprType.Item2.GetCustomAttributes(typeof(BoxToAttribute), false).FirstOrDefault(); if (queryResult != null) { if (attr.BoxingType == elementType) { var transformerType = typeof(Box.NHibernateBoxTransformation <,>) .MakeGenericType(elementType, exprType.Item2); var transformer = context.Resolve(transformerType); if (ienumerableExpressionType == null) { var qrl = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(exprType.Item2)); qrl.Add(queryResult); transformerType.GetProperty("Entries").SetValue(transformer, qrl, null); var box = (IBox)transformerType.GetMethod("ToBox").Invoke(transformer, null) as IBox; returnObject = box.Count > 0 ? box[0] : null; } else { transformerType.GetProperty("Entries").SetValue(transformer, queryResult, null); var box = transformerType.GetMethod("ToBox").Invoke(transformer, null) as IBox; returnObject = box; } } else { returnObject = queryResult; } } } return(returnObject); }
public override void _PhysicsProcess(float Delta) { Mesh.SetRotationDegrees(new Vector3(0, Mesh.RotationDegrees.y + (360 * Delta * RPS), 0)); Life += Delta; if (PhysicsEnabled) { Momentum = MoveAndSlide(Momentum, new Vector3(0, 1, 0), floorMaxAngle: 50); if (!CurrentChunkTuple.Equals(World.GetChunkTuple(Translation))) //We just crossed into a different chunk { World.Chunks[CurrentChunkTuple].Items.Remove(this); CurrentChunkTuple = World.GetChunkTuple(Translation); World.AddItemToChunk(this); Net.SteelRpc(World.Self, nameof(World.DropOrUpdateItem), Type, Translation, Momentum, GetName()); } if (IsOnFloor()) { //Doing friction Vector3 Horz = new Vector3(Momentum.x, 0, Momentum.z); Horz = Horz.Normalized() * Mathf.Clamp(Horz.Length() - (Friction * Delta), 0, Mathf.Abs(MaxFallSpeed)); Momentum.x = Horz.x; Momentum.z = Horz.z; if (Horz.Length() <= 0) { PhysicsEnabled = false; } } if (PhysicsEnabled) { Momentum.y -= Gravity * Delta; if (Momentum.y < MaxFallSpeed) { Momentum.y = MaxFallSpeed; } } else { Momentum = new Vector3(0, 0, 0); World.Grid.AddItem(this); } } }
public static void DecryptString(MethodDef decryption) { foreach (TypeDef type in module.Types) { foreach (MethodDef method in type.Methods) { //Instanciating a new stack to push int and string //Information about the stack : https://docs.microsoft.com/en-us/dotnet/api/system.collections.stack?view=netcore-3.1 //https://www.tutorialsteacher.com/csharp/csharp-stack Stack stack = new Stack(); if (method.HasBody && method.Body.HasInstructions) { for (int i = 0; i < method.Body.Instructions.Count; i++) { if (method.Body.Instructions[i].OpCode == OpCodes.Ldstr) { string operand = (string)method.Body.Instructions[i].Operand; System.Tuple <string, int> tuple = new System.Tuple <string, int>(operand, i); stack.Push(tuple); } else if (method.Body.Instructions[i].IsLdcI4()) { int operand = method.Body.Instructions[i].GetLdcI4Value(); System.Tuple <int, int> tuple = new System.Tuple <int, int>(operand, i); stack.Push(tuple); } else if (method.Body.Instructions[i].OpCode == OpCodes.Call && method.Body.Instructions[i].Operand is MethodDef && (MethodDef)method.Body.Instructions[i].Operand == decryption) { //If method found, we just pop the 2 args and we decrypt the string //I also put the index of the instruction to nop it after System.Tuple <int, int> arg = (System.Tuple <int, int>)stack.Pop(); System.Tuple <string, int> arg2 = (System.Tuple <string, int>)stack.Pop(); string decrypted = a(arg2.Item1, arg.Item1); Console.ForegroundColor = ConsoleColor.Green; Print(string.Format(" {0} decrypted !", decrypted)); Console.ForegroundColor = ConsoleColor.White; method.Body.Instructions[arg.Item2].OpCode = OpCodes.Nop; method.Body.Instructions[arg2.Item2].OpCode = OpCodes.Nop; method.Body.Instructions[i] = Instruction.Create(OpCodes.Ldstr, decrypted); } } } } } }
public void TestConvertBindToSFValFinlandLocale() { Thread testThread = new Thread(() => { CultureInfo ci = new CultureInfo("en-FI"); Thread.CurrentThread.CurrentCulture = ci; System.Tuple <string, string> t = SFDataConverter.csharpTypeValToSfTypeVal(System.Data.DbType.Double, 1.2345); Assert.AreEqual("REAL", t.Item1); Assert.AreEqual("1.2345", t.Item2); }); testThread.Start(); testThread.Join(); }
protected internal virtual void VisitRuleStopState(ATNState p) { RuleStartState ruleStartState = _atn.ruleToStartState[p.ruleIndex]; if (ruleStartState.isPrecedenceRule) { System.Tuple <ParserRuleContext, int> parentContext = _parentContextStack.Pop(); UnrollRecursionContexts(parentContext.Item1); State = parentContext.Item2; } else { ExitRule(); } RuleTransition ruleTransition = (RuleTransition)_atn.states[State].Transition(0); State = ruleTransition.followState.stateNumber; }
private bool IsMissileCatched(IGoalkeeper goalkeeper) { System.Tuple <int, string> challenge = Challenge.GetChallenge(); try { int answer = goalkeeper.AcceptChallenge(challenge.Item2); bool catched = Chance.GetChance() && answer == challenge.Item1; return(catched); } catch (Exception ex) { return(false); } }
public static void Store(int location) { MelonPreferences_Entry <string> melonPref = Main.savedPrefs; try { var updated = new System.Tuple <float, float, float, float, float>(Main.flux_HDRClamp.Value, Main.flux_Hue.Value, Main.flux_Colorize.Value, Main.flux_Brightness.Value, Main.flux_Desat.Value); var Dict = GetSaved(); Dict[location] = updated; melonPref.Value = string.Join(";", Dict.Select(s => String.Format("{0},{1},{2},{3},{4},{5}", s.Key, s.Value.Item1.ToString("F5").TrimEnd('0'), s.Value.Item2.ToString("F5").TrimEnd('0'), s.Value.Item3.ToString("F5").TrimEnd('0'), s.Value.Item4.ToString("F5").TrimEnd('0'), s.Value.Item5.ToString("F5").TrimEnd('0') ))); Main.cat.SaveToFile(); } catch (System.Exception ex) { Main.Logger.Error($"Error storing new saved pref\n" + ex.ToString()); } }
public virtual CommonToken Create(System.Tuple <ITokenSource, ICharStream> source, int type, string text, int channel, int start, int stop, int line, int charPositionInLine) { CommonToken t = new CommonToken(source, type, channel, start, stop); t.Line = line; t.Column = charPositionInLine; if (text != null) { t.Text = text; } else { if (copyText && source.Item2 != null) { t.Text = source.Item2.GetText(Interval.Of(start, stop)); } } return(t); }
public void Should_Excute_Count_As_ToFutureValue() { var sessionFactory = CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { CreateItems(session); var query = session.Query<Item>(); var count = query.ToFutureValue(q => q.Count()); var items = query.ToFuture(); var results = new System.Tuple<int, IList<Item>>(count.Value, items.ToList()); Assert.AreEqual(4, results.Item1); Assert.IsNotNull(results.Item2); Assert.AreEqual(4, results.Item2.Count()); } } }
public void Should_Excute_Average_As_ToFutureValue() { var sessionFactory = CreateSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { var items = CreateItems(session); var query = session.Query<Item>(); var average = query.ToFutureValue(q => q.Average(x => x.Width)); var newItems = query.ToFuture(); var results = new System.Tuple<double, IList<Item>>(average.Value, newItems.ToList()); Assert.AreEqual(items.Average(x => x.Width), results.Item1); Assert.IsNotNull(results.Item2); Assert.AreEqual(4, results.Item2.Count()); } } }
public System.Tuple<Task, CancellationTokenSource> Execute(ScriptLanguage language, string scriptCode, TextWriter outputChannel) { // If there is an existing runner then nuke that one if (m_CurrentlyRunningScript != null) { throw new CannotInterruptRunningScriptException(); } if ((m_CurrentLanguageDomainPair != null) && (m_CurrentLanguageDomainPair.Item1 != language)) { // Different language requested so nuke the domain UnloadCurrentScriptDomain(); } if (m_CurrentLanguageDomainPair == null) { var scriptDomain = m_AppDomainBuilder("ScriptDomain", AppDomainPaths.Core); m_CurrentLanguageDomainPair = new System.Tuple<ScriptLanguage, AppDomain>(language, scriptDomain); } IExecuteScripts executor = LoadExecutor(language, m_CurrentLanguageDomainPair.Item2, outputChannel); var source = new CancellationTokenSource(); var token = new CancelScriptToken(source.Token); var result = Task.Factory.StartNew( () => { try { executor.Execute(scriptCode, token); } finally { m_CurrentlyRunningScript = null; if (m_CurrentToken != null) { m_CurrentToken.Dispose(); m_CurrentToken = null; } } }, source.Token, TaskCreationOptions.LongRunning, m_Scheduler); m_CurrentlyRunningScript = result; m_CurrentToken = source; return new System.Tuple<Task, CancellationTokenSource>(result, source); }
private void UnloadCurrentScriptDomain() { if (m_CurrentLanguageDomainPair != null) { AppDomain.Unload(m_CurrentLanguageDomainPair.Item2); m_CurrentLanguageDomainPair = null; } }
public static Guid GetDataType(string contentTypeAlias, string propertyTypeAlias) { //propertyTypeAlias needs to be invariant, so we will store uppercase var key = new System.Tuple<string, string>(contentTypeAlias, propertyTypeAlias.ToUpper()); return PropertyTypeCache.GetOrAdd( key, tuple => { // With 4.10 we can't do this via direct SQL as we have content type mixins var controlId = Guid.Empty; var ct = GetByAlias(contentTypeAlias); var pt = ct.getPropertyType(propertyTypeAlias); if (pt != null) { controlId = pt.DataTypeDefinition.DataType.Id; } return controlId; }); }