private void ConnectionManagement() { Receive <Tcp.ConnectionClosed>(_ => { _requesterDictionary.Clear(); _listener.Tell(new Disconnected(_host.ToString(), _port)); _heartbeatTimer.Cancel(); Become(EstablishConnect); }); Receive <Tcp.CommandFailed>(p => p.Cmd is Tcp.Write, c => _currentConnection.Socket.Tell(c.Cmd)); Receive <Tcp.CommandFailed>(p => p.Cmd is Tcp.Connect, c => _listener.Tell(new ConnectionFailed(_host.ToString(), _port))); Receive <CommandAck>(s => { _requesterDictionary.Add(s.Sync, s.Sender); }); Receive <Heartbeat>(h => { var idle = DateTime.Now - _lastDataReceived; var result = Tuple.Create(idle > (h.Delay + h.Delay), idle > h.Delay); if (result.Item1 && result.Item2) { _currentConnection.Socket.Tell(Tcp.Close.Instance); } else if (!result.Item1 && result.Item2) { Self.Tell(Request.Ping().Build()); } }); ReceiveRequests(); }
private static void GetElementDependencies(ICustomAttributeProvider annotatedElement, IList <System.Tuple <RuleDependencyAttribute, ICustomAttributeProvider> > result) { foreach (RuleDependencyAttribute dependency in annotatedElement.GetCustomAttributes(typeof(RuleDependencyAttribute), true)) { result.Add(Tuple.Create(dependency, annotatedElement)); } }
/// <summary><inheritDoc/></summary> public virtual IToken NextToken() { if (i >= tokens.Count) { if (eofToken == null) { int start = -1; if (tokens.Count > 0) { int previousStop = tokens[tokens.Count - 1].StopIndex; if (previousStop != -1) { start = previousStop + 1; } } int stop = Math.Max(-1, start - 1); eofToken = _factory.Create(Tuple.Create((ITokenSource)this, InputStream), TokenConstants.EOF, "EOF", TokenConstants.DefaultChannel, start, stop, Line, Column); } return(eofToken); } IToken t = tokens[i]; if (i == tokens.Count - 1 && t.Type == TokenConstants.EOF) { eofToken = t; } i++; return(t); }
public Lexer(ICharStream input, TextWriter output, TextWriter errorOutput) { this._input = input; this.Output = output; this.ErrorOutput = errorOutput; this._tokenFactorySourcePair = Tuple.Create((ITokenSource)this, input); }
private void AddUnlimitWithoutChargeCourses(SimplePageVM model, bool isEng) { var courseTCs = PriceService.CourseWithUnlimite().Except(PriceService.CourseWithUnlimitePrice().Keys); var courses = courseTCs.Select(x => Tuple.Create( CourseService.GetAllCourseNames().GetValueOrDefault(x), 0M)).Where(x => x.Item1 != null).ToList(); AddCourseTable(model, courses, false, isEng); }
/// <summary>Set the char stream and reset the lexer</summary> public virtual void SetInputStream(ICharStream input) { this._input = null; this._tokenFactorySourcePair = Tuple.Create((ITokenSource)this, _input); Reset(); this._input = input; this._tokenFactorySourcePair = Tuple.Create((ITokenSource)this, _input); }
public void AddControlForUnlimitWithCharge(SimplePageVM model) { var courseTCs = PriceService.CourseWithUnlimitePrice(); var courses = courseTCs.Select(x => Tuple.Create( CourseService.GetAllCourseNames().GetValueOrDefault(x.Key), x.Value)) .Where(x => x.Item1 != null).ToList(); AddCourseTable(model, courses, true); }
public static void WriteStatus(string text, string examType, int step, int count) { if (count == 0) { count = 1; step = -1; } examType = examType == null ? "" : "[{0}] ".FormatWith(examType); Status = Tuple.Create(examType + text, (int)100.0 * (step + 1) / count); }
public void AddControlForIntramuralExtramural(SimplePageVM model) { var openClasses = GroupService.GetPlannedAndNotBegin() .Where(x => x.IsIntraExtramural).Take(30).ToList(); var groups = GroupVMService.GetSectionGroups(openClasses) .Select(x => Tuple.Create(x.Key, new NearestGroupsVM(x.ToList()))).ToList(); model.Controls.Add( new SimplePageVM.Control(Views.Shared.Education.NearestGroupListWithSections, groups)); }
private void InitData() { _properties1 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Dato", "OrderDate") }, new List <Tuple <string, string> > { Tuple.Create("Kundenr", "CustomerNumber") }, new List <Tuple <string, string> > { Tuple.Create("OWebbordrenr", "") }, new List <Tuple <string, string> > { Tuple.Create("Ordrenr", "OrderNumber") } }; _properties2 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Vår ref.", "VendorReference"), Tuple.Create("Leveringsadresse", "DeliveryAddress"), Tuple.Create("Lev.betingelser", "DeliveryConditions"), Tuple.Create("Bet.betingelser", "PaymentConditions") }, new List <Tuple <string, string> > { Tuple.Create("Deres ref. / Deres ordrenr.", "Tag"), Tuple.Create("Køpere", "InvoiceAddress"), Tuple.Create("Leveringsform", "DeliveryMethod"), Tuple.Create("Anmerkning", "") } }; _properties4 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> >(), new List <Tuple <string, string> > { Tuple.Create("Telefon", "Vendor.PhoneNumber"), Tuple.Create("Faks", "Vendor.FaxNumber"), }, new List <Tuple <string, string> > { Tuple.Create("Org.nr", "Vendor.OrganizationNumber") } }; }
private void InitData() { _properties1 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Vårt momsreg nr", "Vendor.OrganizationNumber"), Tuple.Create("Leveringsadresse", "DeliveryAddress"), Tuple.Create("Betaler", "CustomerNumber"), Tuple.Create("Deres referanse", "CustomerReference"), Tuple.Create("Godsmerke", "") }, new List <Tuple <string, string> > { Tuple.Create("Vår referanse", "VendorReference"), Tuple.Create("Selger", "") } }; _properties2 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Kunde", "InvoiceAddress"), Tuple.Create("Betalingsvilkår", "PaymentConditions"), Tuple.Create("Leveringsbetingelse", "DeliveryConditions"), Tuple.Create("Leveringsmåte", "DeliveryMethod") }, new List <Tuple <string, string> > { Tuple.Create("Valuta", "Currency"), Tuple.Create("Kontantrabatt", ""), } }; _properties3 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Dato", ""), Tuple.Create("Kundenr", "") }, new List <Tuple <string, string> > { Tuple.Create("Ordrenr", "OrderNumber"), Tuple.Create("Deres ordrenr", "Tag") }, new List <Tuple <string, string> > { Tuple.Create("Ordre dato", "OrderDate"), Tuple.Create("Deres d", "") } }; }
private void InitData() { _properties2 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Kundenr", "CustomerNumber"), } }; _properties3 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Org. nr:", "Vendor.OrganizationNumber"), Tuple.Create("Tel:", "Vendor.PhoneNumber"), Tuple.Create("Email:", "Vendor.Email") }, new List <Tuple <string, string> > { Tuple.Create("Internet:", "Vendor.Link") }, new List <Tuple <string, string> > { Tuple.Create("konto nr", "Vendor.AccountNumber") } }; _properties5 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Transport måte", "DeliveryMethod"), Tuple.Create("Leveringsbet", "DeliveryConditions") } }; _properties6 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Your order n", "Tag") }, new List <Tuple <string, string> > { Tuple.Create("Order date", "OrderDate") }, new List <Tuple <string, string> > { Tuple.Create("Acknowledgement n", "OrderNumber") } }; }
public virtual IList <System.Tuple <K, V> > GetPairs() { IList <System.Tuple <K, V> > pairs = new ArrayList <System.Tuple <K, V> >(); foreach (KeyValuePair <K, IList <V> > pair in this) { foreach (V value in pair.Value) { pairs.Add(Tuple.Create(pair.Key, value)); } } return(pairs); }
public void AddControlForAboutDiplom(SimplePageVM model) { var diploms = CourseService.DiplomTracks().ToList(); var sections = UniqCourseInSection(GroupVMService.GetSectionCourseTCs(diploms)); var data = sections.Select(x => Tuple.Create(x.Key, CourseListVMService.GetAll(new TrackListVM { IsDiplomPage = true, Courses = x.ToList() }).FluentUpdate(y => y.EntityName = x.Key.Name))).ToList(); var list = new DiplomProgramListVM { List = data }; model.Controls.Add(new SimplePageVM.Control(Views.Page.DiplomProgramList, list)); }
public void CreateGraphConfigForDfs() { NodeFamily nodes = new NodeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("v", "0", "n") }); var dfsNode = System.Tuple.Create( new Condition("\"__CURRENT_FUNCTION__\" == \"dfs\" && __ARG1__ == __v__"), (INodeProperty) new FillColorNodeProperty(Color.Red)); nodes.Properties.Add(dfsNode); EdgeFamily edges = new EdgeFamily( new List <IdentifierPartTemplate> { new IdentifierPartTemplate("a", "0", "n"), new IdentifierPartTemplate("b", "0", "n"), new IdentifierPartTemplate("x", "0", "g[__a__].size()") }, new EdgeFamily.EdgeEnd(nodes, new List <string> { "__a__" }), new EdgeFamily.EdgeEnd(nodes, new List <string> { "__b__" })) { ValidationTemplate = "__a__ < __b__ && g[__a__][__x__] == __b__" }; var dfsEdges = Tuple.Create(new Condition("p[__a__] == __b__ || p[__b__] == __a__"), (IEdgeProperty) new LineColorEdgeProperty(Color.Red)); edges.Properties.Add(dfsEdges); GraphConfig config = new GraphConfig { Edges = new HashSet <EdgeFamily> { edges }, Nodes = new HashSet <NodeFamily> { nodes } }; }
/// <summary> /// Constructs a new /// <see cref="CommonToken"/> /// as a copy of another /// <see cref="IToken"/> /// . /// <p> /// If /// <paramref name="oldToken"/> /// is also a /// <see cref="CommonToken"/> /// instance, the newly /// constructed token will share a reference to the /// <see cref="Text()"/> /// field and /// the /// <see cref="Tuple{T1, T2}"/> /// stored in /// <see cref="source"/> /// . Otherwise, /// <see cref="Text()"/> /// will /// be assigned the result of calling /// <see cref="Text()"/> /// , and /// <see cref="source"/> /// will be constructed from the result of /// <see cref="IToken.TokenSource()"/> /// and /// <see cref="IToken.InputStream()"/> /// .</p> /// </summary> /// <param name="oldToken">The token to copy.</param> public CommonToken(IToken oldToken) { _type = oldToken.Type; _line = oldToken.Line; index = oldToken.TokenIndex; charPositionInLine = oldToken.Column; _channel = oldToken.Channel; start = oldToken.StartIndex; stop = oldToken.StopIndex; if (oldToken is Antlr4.Runtime.CommonToken) { _text = ((Antlr4.Runtime.CommonToken)oldToken)._text; source = ((Antlr4.Runtime.CommonToken)oldToken).source; } else { _text = oldToken.Text; source = Tuple.Create(oldToken.TokenSource, oldToken.InputStream); } }
private void InitData() { _properties1 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Ordrenr.", "OrderNumber"), Tuple.Create("Dato", "OrderDate"), Tuple.Create("Kundenr.", "CustomerNumber") } }; _properties6 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Deres bestillingsnr.:", "Tag"), Tuple.Create("Deres bestillingsdato", "") }, new List <Tuple <string, string> > { Tuple.Create("Deres ref:", "CustomerReference") } }; _properties7 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Betaling", "PaymentConditions"), Tuple.Create("Leveringsbetingelser", "DeliveryConditions"), Tuple.Create("Godsavsender", ""), Tuple.Create("Forsendelsesinfo", "DeliveryMethod"), Tuple.Create("Sendes til", "DeliveryAddress"), }, new List <Tuple <string, string> > { Tuple.Create("Deres ref:", "CustomerReference") } }; }
private DiplomProgramListVM GetTrainingPrograms(PageController page) { return(MethodBase.GetCurrentMethod().CacheDay(() => { var programs = CourseService.GetAllHitTracks() .Select(x => x.Course_TC).Except(CourseTC.HalfTracks.Keys).ToList(); var sectionCourseTCs = GroupVMService.GetSectionCourseTCs(programs); var sections = UniqCourseInSection(sectionCourseTCs); var data = sections.Select(x => Tuple.Create(x.Key, CourseListVMService.GetAll(new TrackListVM { IsTrainingProgramsPage = true, Courses = x.ToList() }).FluentUpdate(y => { y.EntityName = x.Key.Name; y.EntityUrl = page.Html.Url().Section().Urls.Details(x.Key.UrlName); }))).ToList(); var list = new DiplomProgramListVM { List = data }; return list; })); }
private void _epasaRegexButton_Click(object sender, EventArgs e) { try { //var unescapedSafeAnsiCharPattern = // RegexPattern.With.Set(RegexPattern.With.Literal(SafeUnescapedAnsiCharSet)); var unescapedSafeAnsiCharPatterns = SafeUnescapedAnsiCharSet .Select(c => RegexPattern.With.Literal(c.ToString())); var escapedSafeAnsiCharPatterns = SafeEscapedAnsiCharSet .Select(c => RegexPattern.With.Literal("\\").Literal(c.ToString())); var safeAnsiCharPattern = RegexPattern.With.Choice.EitherAny( unescapedSafeAnsiCharPatterns.Concat(escapedSafeAnsiCharPatterns).ToArray() ); var safeAnsiStringPattern = new RegexPattern(safeAnsiCharPattern) .Repeat.OneOrMore; var pascal64StartPattern = RegexPattern.With .Set(RegexPattern.With.Literal(Pascal64StartCharSet, true)); // account name needs to omit brackets! var pascal64StringPattern = new RegexPattern(pascal64StartPattern) .Set(RegexPattern.With.Literal(Pascal64CharSet, true)).Repeat.InRange(2, 63); var hexNibblePattern = RegexPattern.With .Set(RegexRange.OfMany(Tuple.Create('0', '9'), Tuple.Create('a', 'f'))); var hexBytePattern = RegexPattern.With .Group( new RegexPattern(hexNibblePattern).Repeat.Exactly(2) ); var hexStringPattern = new RegexPattern(hexBytePattern).Repeat.OneOrMore; var base58CharPattern = RegexPattern.With .Set(RegexPattern.With.Literal(Base58CharSet)); var base58StringPattern = new RegexPattern(base58CharPattern).Repeat.OneOrMore; var integerPattern = RegexPattern .With.Digit.Repeat.OneOrMore; var accountNamePattern = RegexPattern .With.NamedGroup("AccountName", pascal64StringPattern); var accountNumberPattern = RegexPattern .With.NamedGroup("AccountNumber", integerPattern) .Literal("-") .NamedGroup("Checksum", RegexPattern.With.Digit.Repeat.Exactly(2)); var pasaPattern = RegexPattern .With.Choice.Either(accountNamePattern, accountNumberPattern); var payloadPattern = RegexPattern.With .Choice.EitherAny( RegexPattern.With.NamedGroup("ASCIIPayload", RegexPattern.With.Literal("\"").Group(safeAnsiStringPattern).Literal("\"")).Repeat.Optional, RegexPattern.With.NamedGroup("HexPayload", RegexPattern.With.Literal("0x").Group(hexStringPattern)).Repeat.Optional, RegexPattern.With.NamedGroup("Base58Payload", base58StringPattern).Repeat.Optional ); var publicPayloadPattern = RegexPattern.With .Literal("[") .NamedGroup("NoEncryption", payloadPattern).Repeat.Optional .Literal("]", true); var receiverPayloadPattern = RegexPattern.With .Literal("(") .NamedGroup("ReceiverEncrypted", payloadPattern).Repeat.Optional .Literal(")"); var senderPayloadPattern = RegexPattern.With .Literal("<") .NamedGroup("SenderEncrypted", payloadPattern).Repeat.Optional .Literal(">"); var aesPayloadPattern = RegexPattern.With .Literal("<") .NamedGroup("AESEncrypted", payloadPattern).Repeat.Optional .Literal(">") .Literal(":") .NamedGroup("Password", safeAnsiStringPattern); var extendedAddressPattern = RegexPattern.With .Choice.EitherAny( publicPayloadPattern, receiverPayloadPattern, senderPayloadPattern, aesPayloadPattern ); var epasaChecksumPattern = new RegexPattern(hexBytePattern) .Repeat.Exactly(2); var epasaPattern = RegexPattern .With.AtBeginning .NamedGroup("PASA", pasaPattern) .RegEx(new RegexPattern(extendedAddressPattern)).Repeat.Optional .Group( RegexPattern.With .Literal(":") .NamedGroup("EPASAChecksum", epasaChecksumPattern) .AtEnd ).Repeat.Optional; _standardTextBox.Clear(); _standardTextBox.AppendText(epasaPattern.ToString()); Match subregex; { //subregex = new Regex(unescapedSafeAnsiCharPattern, RegexOptions.None).Match("77-44[0x1234]:121f"); _standardTextBox.AppendLine("const string safeAnsiCharPattern = \"" + safeAnsiCharPattern + "\""); _standardTextBox.AppendLine("const string safeAnsiStringPattern = \"" + safeAnsiStringPattern + "\""); _standardTextBox.AppendLine("const string pascal64StartPattern = \"" + pascal64StartPattern + "\""); _standardTextBox.AppendLine("const string pascal64StringPattern = \"" + pascal64StringPattern + "\""); _standardTextBox.AppendLine("const string hexNibblePattern = \"" + hexNibblePattern + "\""); _standardTextBox.AppendLine("const string hexBytePattern = \"" + hexBytePattern + "\""); _standardTextBox.AppendLine("const string hexStringPattern = \"" + hexStringPattern + "\""); _standardTextBox.AppendLine("const string base58CharPattern = \"" + base58CharPattern + "\""); _standardTextBox.AppendLine("const string base58StringPattern = \"" + base58StringPattern + "\""); _standardTextBox.AppendLine("const string integerPattern = \"" + integerPattern + "\""); _standardTextBox.AppendLine("const string accountNamePattern = \"" + accountNamePattern + "\""); _standardTextBox.AppendLine("const string accountNumberPattern = \"" + accountNumberPattern + "\""); _standardTextBox.AppendLine("const string pasaPattern = \"" + pasaPattern + "\""); _standardTextBox.AppendLine("const string payloadPattern = \"" + payloadPattern + "\""); _standardTextBox.AppendLine("const string publicPayloadPattern = \"" + publicPayloadPattern + "\""); _standardTextBox.AppendLine("const string receiverPayloadPattern = \"" + receiverPayloadPattern + "\""); _standardTextBox.AppendLine("const string senderPayloadPattern = \"" + senderPayloadPattern + "\""); _standardTextBox.AppendLine("const string aesPayloadPattern = \"" + aesPayloadPattern + "\""); _standardTextBox.AppendLine("const string extendedAddressPattern = \"" + extendedAddressPattern + "\""); _standardTextBox.AppendLine("const string epasaChecksumPattern = \"" + epasaChecksumPattern + "\""); _standardTextBox.AppendLine("const string epasaPattern = \"" + epasaPattern + "\""); } _standardTextBox.AppendLine(""); var regex = new Regex(epasaPattern, RegexOptions.None); var result = regex.Match("77-44[0x123]:121f"); result = regex.Match("77-44[0x123]"); result = regex.Match("77-44[B58xdf]:121f"); result = regex.Match("77-44"); result = regex.Match("account-name"); result = regex.Match("account-name:abcd"); _standardTextBox.AppendLine(result.ToString()); } catch (Exception error) { ExceptionDialog.Show(this, error); } }
public void SetMinMaxWaitTime(float min, float max) { _minMaxWaitTime = new System.Tuple <float, float>(min, max); }
public override void _PhysicsProcess(float Delta) { if (!Possessed) { return; } if (ForwardAxis == 0 && IsOnFloor()) { if (Momentum.z > 0) { Momentum.z = Mathf.Clamp(Momentum.z - Friction * Delta, 0f, MaxMovementSpeed); } else if (Momentum.z < 0) { Momentum.z = Mathf.Clamp(Momentum.z + Friction * Delta, -MaxMovementSpeed, 0f); } } if (RightAxis == 0 && IsOnFloor()) { if (Momentum.x > 0) { Momentum.x = Mathf.Clamp(Momentum.x - Friction * Delta, 0f, MaxMovementSpeed); } else if (Momentum.x < 0) { Momentum.x = Mathf.Clamp(Momentum.x + Friction * Delta, -MaxMovementSpeed, 0f); } } if (IsJumping && JumpTimer <= MaxJumpLength) { JumpTimer += Delta; Momentum.y = Mathf.Clamp(Momentum.y + JumpContinueForce * Delta, -MaxMovementSpeed, MaxMovementSpeed); } else { JumpTimer = 0f; IsJumping = false; Momentum.y = Mathf.Clamp(Momentum.y - Gravity * Delta, -MaxMovementSpeed, MaxMovementSpeed); } Vector3 OldPos = Translation; MoveAndSlide(Momentum.Rotated(new Vector3(0, 1, 0), Mathf.Deg2Rad(LookHorizontal)), new Vector3(0, 1, 0), true, 4, Mathf.Deg2Rad(60)); //MoveAndSlide multiplies by *physics* delta internally Vector3 NewPos = Translation; Translation = OldPos; if (NewPos != OldPos) { if (ShouldDo.LocalPlayerMove(NewPos)) { Translation = NewPos; } } if (IsOnFloor() && Momentum.y <= 0f) { Momentum.y = -1f; } RpcUnreliable(nameof(Update), Translation, RotationDegrees); if (!Building.GetChunkTuple(Translation).Equals(CurrentChunk)) { CurrentChunk = Building.GetChunkTuple(Translation); UnloadAndRequestChunks(); } }
protected internal virtual IToken ConstructToken(ITokenSource tokenSource, int expectedTokenType, string tokenText, IToken current) { ITokenFactory factory = tokenSource.TokenFactory; return(factory.Create(Tuple.Create(tokenSource, current.TokenSource.InputStream), expectedTokenType, tokenText, TokenConstants.DefaultChannel, -1, -1, current.Line, current.Column)); }
protected internal virtual void ReadStates(ATN atn) { // // STATES // IList <System.Tuple <LoopEndState, int> > loopBackStateNumbers = new List <System.Tuple <LoopEndState, int> >(); IList <System.Tuple <BlockStartState, int> > endStateNumbers = new List <System.Tuple <BlockStartState, int> >(); int nstates = ReadInt(); for (int i_1 = 0; i_1 < nstates; i_1++) { StateType stype = (StateType)ReadInt(); // ignore bad type of states if (stype == StateType.InvalidType) { atn.AddState(null); continue; } int ruleIndex = ReadInt(); if (ruleIndex == char.MaxValue) { ruleIndex = -1; } ATNState s = StateFactory(stype, ruleIndex); if (stype == StateType.LoopEnd) { // special case int loopBackStateNumber = ReadInt(); loopBackStateNumbers.Add(Tuple.Create((LoopEndState)s, loopBackStateNumber)); } else { if (s is BlockStartState) { int endStateNumber = ReadInt(); endStateNumbers.Add(Tuple.Create((BlockStartState)s, endStateNumber)); } } atn.AddState(s); } // delay the assignment of loop back and end states until we know all the state instances have been initialized foreach (System.Tuple <LoopEndState, int> pair in loopBackStateNumbers) { pair.Item1.loopBackState = atn.states[pair.Item2]; } foreach (System.Tuple <BlockStartState, int> pair_1 in endStateNumbers) { pair_1.Item1.endState = (BlockEndState)atn.states[pair_1.Item2]; } int numNonGreedyStates = ReadInt(); for (int i_2 = 0; i_2 < numNonGreedyStates; i_2++) { int stateNumber = ReadInt(); ((DecisionState)atn.states[stateNumber]).nonGreedy = true; } int numPrecedenceStates = ReadInt(); for (int i_4 = 0; i_4 < numPrecedenceStates; i_4++) { int stateNumber = ReadInt(); ((RuleStartState)atn.states[stateNumber]).isPrecedenceRule = true; } }
/// <summary> /// Given a CSV File containing items in the order [ROLE],[IDX],[PRODUCTNAME] /// This method will take in the csv file and process through in order to generate a final dictionary value /// </summary> /// <param name="path">Path to CSV</param> private static void GenerateMasterBundleList(string path) { // List of the csvData. Gets cleared after finding a ",," List <string[]> csvData = new List <string[]>(); int lineNum = 0; try { using (StreamReader readFile = new StreamReader(path)) { string line; string[] row; // Go until we reach end of line while ((line = readFile.ReadLine()) != null) { // Keep track of what line to check IN CASE lineNum++; if (line != ",,") { // Add these items to our csvdata row = line.Split(','); // TO DO: ENSURE THAT EVERY LINE CONTAINS 3 ELEMENTS if (row.Length != 3) { possibleErr.AppendLine("Line " + lineNum + " is missing a value. Fix this!"); } else { csvData.Add(row); } } else { Console.WriteLine("End of File Dependency"); // Check if all products are labeled Bundle // This is our dictionary of all the items that share files Dictionary <ProductInfo, List <ProductInfo> > miniProduct = new Dictionary <ProductInfo, List <ProductInfo> >(); foreach (string[] product in csvData) { string role = product[0]; if (role == "Bundle") { // We found a bundle, so go through every other product in the lsit and find dependencies ProductInfo itsABundle = Product.Create(Int32.Parse(product[1]), product[2]); miniProduct.Add(itsABundle, new List <ProductInfo>()); //Search through list for all dependencies foreach (string[] otherProd in csvData) { if (product == otherProd) { continue; } else if (otherProd[0] == "Unique") { ProductInfo partOfBundle = Product.Create(Int32.Parse(otherProd[1]), otherProd[2]); miniProduct[itsABundle].Add(partOfBundle); } else if (otherProd[0] == "Compound") { // COMPOUNDS ARE A PART OF A BUNDLE ProductInfo partOfBundle = Product.Create(Int32.Parse(otherProd[1]), otherProd[2]); miniProduct[itsABundle].Add(partOfBundle); } } } // TO DO: COMPOUND ITEMS else if (role == "Compound") { //Search through list of all dependencies // We found a bundle, so go through every other product in the lsit and find dependencies ProductInfo itsACompound = Product.Create(Int32.Parse(product[1]), product[2]); miniProduct.Add(itsACompound, new List <ProductInfo>()); //Search through list for all dependencies foreach (string[] otherProd in csvData) { if (product == otherProd) { continue; } else if (otherProd[0] == "Unique") { ProductInfo partOfBundle = Product.Create(Int32.Parse(otherProd[1]), otherProd[2]); miniProduct[itsACompound].Add(partOfBundle); } } } // Put all the sharedIDX items in a list else if (role == "Shared IDX") { ProductInfo sharedIDX = Product.Create(Int32.Parse(product[1]), product[2]); if (!SharedIDXProducts.Contains(sharedIDX)) { SharedIDXProducts.Add(sharedIDX); } } else if (role == "Unique") { // DONT REALLY NEED TO DO ANYTHING BUT THESE ARE ALL THE CASES } else { // CAN CAPTURE MISSPELLINGS AND SUCH possibleErr.AppendLine("Line " + lineNum + " has an unidentified role: " + role); } } // We have finished sorting through everything with a file dependency, add them back to our MASTER dictionary foreach (var key in miniProduct.Keys) { if (FinalBundleList.Keys.Contains(key)) { List <ProductInfo> newList = FinalBundleList[key].Union(miniProduct[key]).ToList(); FinalBundleList[key] = newList; } else { FinalBundleList.Add(key, miniProduct[key]); } } // May not need to clear the dictionary but why not be safe miniProduct.Clear(); csvData.Clear(); } } } } catch (Exception e) { Console.WriteLine(e.Message); } List <ProductInfo> keysWith0Val = new List <ProductInfo>(); // REMOVE DUPLICATES VALUES FROM DICTIONARY foreach (ProductInfo checks in FinalBundleList.Keys) { if (FinalBundleList[checks].Count == 0) { keysWith0Val.Add(checks); } } foreach (ProductInfo toRemove in keysWith0Val) { FinalBundleList.Remove(toRemove); } }
public void onSelect(MathBlock mb) { // select first block if(!this.selectedBlock) { this.selectedBlock = mb; return; } // unselect block if(this.selectedBlock == mb) { this.selectedBlock = null; return; } // select right block if(this.selectedBlock.value == mb.value) { Debug.Log("Correct!"); // attack opponent Container opponent = GameManager.instance.queryTeam(1 - this.teamNumber); System.Tuple<MathBlock, MathBlock> targets = opponent.getTargets(); // attack first block GameObject bullet1 = Instantiate(ResourceManager.instance.bulletPrefab, this.selectedBlock.self.position, Quaternion.identity); bullet1.transform .DOMove(targets.Item1.self.position, this.attackDuration) .OnComplete( () => { targets.Item1.calculate(this.getBlockRandomValue()); targets.Item1.anim.SetBool(MathBlock.IS_AIMED, false); Destroy(bullet1); // camera shake cameraShake.addForce(Util.unitVec2() * this.forceScale); // add score this.score++; this.textScore.addScore(); this.textScore.setText($"Score: {this.score}"); // play audio } ); // attack second one GameObject bullet2 = Instantiate(ResourceManager.instance.bulletPrefab, mb.self.position, Quaternion.identity); bullet2.transform .DOMove(targets.Item2.self.position, this.attackDuration) .OnComplete( () => { targets.Item2.calculate(this.getBlockRandomValue()); targets.Item2.anim.SetBool(MathBlock.IS_AIMED, false); Destroy(bullet2); } ); // re-generate blocks this.selectedBlock.calculate(this.getBlockRandomValue()); mb.calculate(this.getBlockRandomValue()); this.selectedBlock = null; } // wrong selection else { Debug.Log("Bu~Bu~~desuwa"); // punishment this.selectedBlock.calculate(this.selectedBlock.value); mb.calculate(mb.value); this.selectedBlock = null; } }
public override void EnterRecursionRule(ParserRuleContext localctx, int state, int ruleIndex, int precedence) { _parentContextStack.Push(Tuple.Create(RuleContext, localctx.invokingState)); base.EnterRecursionRule(localctx, state, ruleIndex, precedence); }
public void SetCheckpoint(int index, System.Tuple <Vector3, Quaternion> info) { this.checkpoints[index] = info; }
private void InitData() { _properties1 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Vårt ordrenr.", "OrderNumber") }, new List <Tuple <string, string> > { Tuple.Create("Kundenummer", "CustomerNumber") }, new List <Tuple <string, string> > { Tuple.Create("Ordredato", "OrderDate") } }; _properties2 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Leveringsadresse", "DeliveryAddress") }, new List <Tuple <string, string> > { Tuple.Create("Kundeadresse", "InvoiceAddress") } }; _properties3 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Deres referanse", "CustomerReference"), Tuple.Create("Deres ordrenummer", "Tag"), Tuple.Create("Leveringsvillkår", "DeliveryConditions"), Tuple.Create("Leveringsmåte", "DeliveryMethod") }, new List <Tuple <string, string> > { Tuple.Create("Vår referense", "VendorReference"), Tuple.Create("Forsendelsesdato", ""), Tuple.Create("Betalingsbetingelser", "PaymentConditions") } }; _properties5 = new List <List <Tuple <string, string> > > { new List <Tuple <string, string> > { Tuple.Create("Adresse", "Vendor.PostalAddress"), Tuple.Create("Organisasjonsnummer", "") }, new List <Tuple <string, string> > { Tuple.Create("Telefon", "Vendor.PhoneNumber"), Tuple.Create("Fax", "Vendor.FaxNumber") }, new List <Tuple <string, string> > { Tuple.Create("Momsreg.nr.", "Vendor.OrganizationNumber"), Tuple.Create("Bankkonto", "Vendor.AccountNumber") }, new List <Tuple <string, string> > { Tuple.Create("Internet", "Vendor.Link"), Tuple.Create("e-post", "Vendor.Email") } }; }
private static IDictionary <int, string> GetSharedStrings(SpreadsheetDocument document) { return(document.WorkbookPart.SharedStringTablePart.SharedStringTable .Select((x, i) => Tuple.Create(i, x.InnerText)) .ToDictionary(x => x.Item1, x => x.Item2)); }
void Update() { if (point_queue.Count > 0 && Time.time - last_push_time >= wait_interval) { System.Tuple <Vector3[], Vector3[], Color[]> currItem = point_queue.Peek(); Vector3[] positions = currItem.Item1; Vector3[] scales = currItem.Item2; Color[] colors = currItem.Item3; int end = Mathf.Min(curr_index + SystemInfo.maxTextureSize - 1, positions.Length); if (end - curr_index != new_point_positions.width) { new_point_positions = new Texture2D(end - curr_index, 1, TextureFormat.RGBAFloat, false); new_point_colors = new Texture2D(end - curr_index, 1, TextureFormat.RGBAFloat, false); if (colors == null) { NativeArray <Color> .Copy(default_point_colors, new_point_colors.GetRawTextureData <Color>(), end - curr_index); new_point_colors.Apply(); } new_point_scales = new Texture2D(end - curr_index, 1, TextureFormat.RGBAFloat, false); if (scales == null) { NativeArray <Color> .Copy(default_point_scales, new_point_scales.GetRawTextureData <Color>(), end - curr_index); new_point_scales.Apply(); } } NativeArray <Color> rawData = new_point_positions.GetRawTextureData <Color>(); for (int j = curr_index, k = 0; j < end; j++, k++) { rawData[k] = new Color(positions[j].x, positions[j].y, positions[j].z); } new_point_positions.Apply(); if (colors != null) { NativeArray <Color> .Copy(colors, curr_index, new_point_colors.GetRawTextureData <Color>(), 0, end - curr_index); new_point_colors.Apply(); } if (scales != null) { NativeArray <Color> scaleData = new_point_scales.GetRawTextureData <Color>(); for (int j = curr_index, k = 0; j < end; j++, k++) { scaleData[k] = new Color(scales[j].x, scales[j].y, scales[j].z); } new_point_scales.Apply(); } visualEffect.SetInt("num_new_particles", end - curr_index); visualEffect.SetTexture("new_particle_positions", new_point_positions); visualEffect.SetTexture("new_particle_colors", new_point_colors); visualEffect.SetTexture("new_particle_scales", new_point_scales); visualEffect.SendEvent("AddParticles"); curr_index = end; if (curr_index >= positions.Length) { point_queue.Dequeue(); curr_index = 0; } last_push_time = Time.time; } }