System.Collections.Generic.List.Reverse()

Here are the examples of the csharp api System.Collections.Generic.List.Reverse() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1050 Examples 7

19 View Source File : SortWay.cs
License : MIT License
Project Creator : alen-smajic

void SortList(List<List<Vector3>> WaysToBeSorted, int index)
    {
        if(WaysToBeSorted.Count <= 0)
        {
            return;
        }

        List<List<Vector3>> Lefreplacedems = WaysToBeSorted; 
        bool found_something = false;

        for(int i = 0; i < WaysToBeSorted.Count; i++)
        {
            if(WaysToBeSorted[i][0] == SortedPathAndWays[index][SortedPathAndWays[index].Count - 1][SortedPathAndWays[index][SortedPathAndWays[index].Count - 1].Count - 1])
            {
                SortedPathAndWays[index].Add(WaysToBeSorted[i]);
                Lefreplacedems.RemoveAt(i);
                found_something = true;
            }
            else if (SortedPathAndWays[index][0][0] == WaysToBeSorted[i][WaysToBeSorted[i].Count - 1])
            {
               SortedPathAndWays[index].Insert(0, WaysToBeSorted[i]);
                Lefreplacedems.RemoveAt(i);
                found_something = true;
            }
            else if(WaysToBeSorted[i][0] == SortedPathAndWays[index][0][0])
            {
                WaysToBeSorted[i].Reverse();
                SortedPathAndWays[index].Insert(0, WaysToBeSorted[i]);
                Lefreplacedems.RemoveAt(i);
                found_something = true;
            }
            else if (WaysToBeSorted[i][WaysToBeSorted[i].Count - 1] == SortedPathAndWays[index][SortedPathAndWays[index].Count - 1][SortedPathAndWays[index][SortedPathAndWays[index].Count - 1].Count - 1])
            {
                WaysToBeSorted[i].Reverse();
                SortedPathAndWays[index].Add(WaysToBeSorted[i]);
                Lefreplacedems.RemoveAt(i);
                found_something = true;
            }
            else
            {
                continue;
            }
        }

        if(found_something == false)
        {
            List<List<Vector3>> localList = new List<List<Vector3>>();
            localList.Add(WaysToBeSorted[0]);
            SortedPathAndWays.Add(localList);
            Lefreplacedems.RemoveAt(0);
            SortList(Lefreplacedems, index + 1);
        }
        else
        {
            SortList(Lefreplacedems, index);
        }
    }

19 View Source File : ThriftFooter.cs
License : MIT License
Project Creator : aloneguid

public List<string> GetPath(Thrift.SchemaElement schemaElement)
      {
         var path = new List<string>();

         ThriftSchemaTree.Node wrapped = _tree.Find(schemaElement);
         while(wrapped.parent != null)
         {
            path.Add(wrapped.element.Name);
            wrapped = wrapped.parent;
         }

         path.Reverse();
         return path;
      }

19 View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

private Texture2D CreateCustomCharacter(RNPC npc, string type)
        {
            Texture2D sprite = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.bodyType + "_" + type + ".png", ContentSource.ModFolder);
            Texture2D hairT = this.Helper.Content.Load<Texture2D>("replacedets/hair/" + npc.hairStyle + "_" + type + ".png", ContentSource.ModFolder);
            Texture2D eyeT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_eyes_" + type + ".png", ContentSource.ModFolder);

            Texture2D eyeBackT = null;
            Texture2D noseT = null;
            Texture2D mouthT = null;
            if (type == "portrait")
            {
                eyeBackT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_eyes_back.png", ContentSource.ModFolder);
                noseT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_nose.png", ContentSource.ModFolder);
                mouthT = this.Helper.Content.Load<Texture2D>("replacedets/body/" + npc.gender + "_mouth.png", ContentSource.ModFolder);
            }
            Texture2D topT = this.Helper.Content.Load<Texture2D>("replacedets/transparent_" + type + ".png", ContentSource.ModFolder);
            Texture2D bottomT = topT;
            Texture2D shoesT = topT;

            // clothes

            // try and share with other type (char/portrait)
            string[] clothes;
            if (npc.clothes != null)
            {
                clothes = npc.clothes;
            }
            else
            {
                string npcString = string.Join("/", npc.npcString.Split('/').Take(7)) + "/" + npc.bodyType;
                List<string> potentialClothes = GetHighestRankedStrings(npcString, RNPCclothes.data, 8);

                clothes = potentialClothes[Game1.random.Next(0, potentialClothes.Count)].Split('^');
                //base.Monitor.Log(string.Join(" | ", clothes), LogLevel.Debug);
                npc.clothes = clothes;
                npc.topRandomColour = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
            }

            if (clothes[0] != "")
            {
                topT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[0] + "_" + type + ".png", ContentSource.ModFolder);
            }
            if (clothes[1] != "" && type == "character")
            {
                bottomT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[1] + ".png", ContentSource.ModFolder);
            }
            if (clothes[2] != "" && type == "character")
            {
                shoesT = this.Helper.Content.Load<Texture2D>("replacedets/clothes/" + clothes[2] + ".png", ContentSource.ModFolder);
            }

            Color[] data = new Color[sprite.Width * sprite.Height];
            Color[] dataH = new Color[hairT.Width * hairT.Height];
            Color[] dataE = new Color[eyeT.Width * eyeT.Height];
            Color[] dataEB = null;
            Color[] dataN = null;
            Color[] dataM = null;
            if (type == "portrait")
            {
                dataEB = new Color[eyeBackT.Width * eyeBackT.Height];
                dataN = new Color[noseT.Width * noseT.Height];
                dataM = new Color[mouthT.Width * mouthT.Height];
            }
            Color[] dataT = new Color[topT.Width * topT.Height];
            Color[] dataB = new Color[bottomT.Width * bottomT.Height];
            Color[] dataS = new Color[shoesT.Width * shoesT.Height];
            sprite.GetData(data);
            hairT.GetData(dataH);
            eyeT.GetData(dataE);
            if (type == "portrait")
            {
                eyeBackT.GetData(dataEB);
                noseT.GetData(dataN);
                mouthT.GetData(dataM);
            }
            topT.GetData(dataT);
            bottomT.GetData(dataB);
            shoesT.GetData(dataS);

            string[] skinRBG = npc.skinColour.Split(' ');
            string[] eyeRBG = npc.eyeColour.Split(' ');
            List<string> hairRBGs = npc.hairColour.Split('^').ToList();

            string[] baseColourT = clothes[3] == "any" ? npc.topRandomColour : null;

            string[] baseColourB;
            switch (clothes[4])
            {
                case "any":
                    baseColourB = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
                    break;
                case "top":
                    baseColourB = baseColourT;
                    break;
                default:
                    baseColourB = null;
                    break;
            }
            string[] baseColourS;
            switch (clothes[5])
            {
                case "any":
                    baseColourS = new string[] { Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString(), Game1.random.Next(0, 255).ToString() };
                    break;
                case "top":
                    baseColourS = baseColourT;
                    break;
                case "bottom":
                    baseColourS = baseColourB;
                    break;
                default:
                    baseColourS = null;
                    break;
            }

            // make hair gradient

            List<string> hairGreyStrings = new List<string>();
            for (int i = 0; i < dataH.Length; i++)
            {
                if (dataH[i].R == dataH[i].G && dataH[i].R == dataH[i].B && dataH[i].G == dataH[i].B) // greyscale
                {
                    if (!hairGreyStrings.Contains(dataH[i].R.ToString()))
                    { // only add one of each grey
                        hairGreyStrings.Add(dataH[i].R.ToString());
                    }
                }
            }

            // make same number of greys as colours in gradient

            if (hairRBGs.Count > hairGreyStrings.Count) // ex 9 and 6
            {
                hairGreyStrings = LengthenToMatch(hairGreyStrings, hairRBGs);
            }
            else if (hairRBGs.Count < hairGreyStrings.Count)
            {
                hairRBGs = LengthenToMatch(hairRBGs, hairGreyStrings);

            }
            List<byte> hairGreys = new List<byte>();
            foreach (string str in hairGreyStrings)
            {
                hairGreys.Add(byte.Parse(str));
            }
            hairGreys.Sort();
            hairGreys.Reverse(); // lightest to darkest
            //Alert(hairGreys.Count+ " " +hairRBGs.Count);
            
            // start putting it together

            for (int i = 0; i < data.Length; i++)
            {
                if (dataH.Length > i && dataH[i] != Color.Transparent)
                {
                    if (dataH[i].R == dataH[i].G && dataH[i].R == dataH[i].B && dataH[i].G == dataH[i].B) // greyscale
                    {
                        // hair gradient

                        // for cases where fewer greys than colours (multiple of same grey)
                        List<int> greyMatches = new List<int>();
                        for (int j = 0; j < hairGreys.Count; j++)
                        {
                            if (hairGreys[j] == dataH[i].R)
                            {
                                greyMatches.Add(j);
                            }
                        }

                        string[] hairRBG;
                        int rnd = Game1.random.Next(0, greyMatches.Count);
                        int match = greyMatches[rnd];
                        hairRBG = hairRBGs[match].Split(' '); // turns single grey into set of colours

                        data[i] = new Color(byte.Parse(hairRBG[0]), byte.Parse(hairRBG[1]), byte.Parse(hairRBG[2]), dataH[i].A);
                    }
                    else // ignore already coloured parts
                    {
                        data[i] = dataH[i];
                    }
                }
                else if (dataT.Length > i && dataT[i] != Color.Transparent)
                {
                    data[i] = baseColourT != null ? ColorizeGrey(baseColourT, dataT[i]) : dataT[i];
                }
                else if (dataB.Length > i && dataB[i] != Color.Transparent)
                {
                    data[i] = baseColourB != null ? ColorizeGrey(baseColourB, dataB[i]) : dataB[i];
                }
                else if (dataS.Length > i && dataS[i] != Color.Transparent)
                {
                    data[i] = baseColourS != null ? ColorizeGrey(baseColourS, dataS[i]) : dataS[i];
                }
                else if (dataE.Length > i && dataE[i] != Color.Transparent)
                {
                    if (dataE[i] != Color.White)
                    {
                        data[i] = ColorizeGrey(eyeRBG, dataE[i]);
                    }
                    else
                    {
                        data[i] = Color.White;
                    }
                }
                else if (type == "portrait" && dataEB.Length > i && dataEB[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, dataEB[i]);
                }
                else if (type == "portrait" && dataN.Length > i && dataN[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, dataN[i]);
                }
                else if (type == "portrait" && dataM.Length > i && dataM[i] != Color.Transparent)
                {
                    if (dataM[i] != Color.White)
                    {
                        data[i] = ColorizeGrey(skinRBG, dataM[i]);
                    }
                    else
                    {
                        data[i] = Color.White;
                    }
                }
                else if (data[i] != Color.Transparent)
                {
                    data[i] = ColorizeGrey(skinRBG, data[i]);
                }
            }
            sprite.SetData<Color>(data);
            return sprite;
        }

19 View Source File : GUIScaleUtility.cs
License : MIT License
Project Creator : alelievr

public static void BeginNoClip () 
		{
			// Record and close all clips one by one, from bottom to top, until we hit the 'origin'
			List<Rect> rectStackGroup = new List<Rect> ();
			Rect topMostClip = getTopRect;
			while (topMostClip != new Rect (-10000, -10000, 40000, 40000)) 
			{
				rectStackGroup.Add (topMostClip);
				GUI.EndClip ();
				topMostClip = getTopRect;
			}
			// Store the clips appropriately
			rectStackGroup.Reverse ();
			rectStackGroups.Add (rectStackGroup);
			currentRectStack.AddRange (rectStackGroup);
		}

19 View Source File : DirectoryEntry.cs
License : MIT License
Project Creator : aerosoul94

public string GetPath()
        {
            List<string> ancestry = new List<string>();

            for (DirectoryEntry parent = _parent; parent != null; parent = parent._parent)
            {
                ancestry.Add(parent.FileName);
            }

            ancestry.Reverse();
            return String.Join("/", ancestry.ToArray());
        }

19 View Source File : _Host.cshtml.cs
License : Apache License 2.0
Project Creator : acblog

public async Task<string> Getreplacedle()
        {
            string path = HttpContext.Request.Path.ToString().Trim('/');
            {
                int indFrag = path.IndexOf('#');
                if (indFrag != -1)
                    path = path.Remove(indFrag);
            }
            string[] pathSegs = path.Split('/');

            List<string> result = new List<string>
            {
                "AcBlog"
            };

            if (pathSegs.Length > 0)
            {
                switch (pathSegs[0])
                {
                    case "posts":
                        await GeneratePostreplacedle(pathSegs[1..], result, "Posts");
                        break;
                    case "articles":
                        await GeneratePostreplacedle(pathSegs[1..], result, "Articles");
                        break;
                    case "slides":
                        await GeneratePostreplacedle(pathSegs[1..], result, "Slides");
                        break;
                    case "notes":
                        await GeneratePostreplacedle(pathSegs[1..], result, "Notes");
                        break;
                    case "categories":
                        // await GenerateCategoryreplacedle(pathSegs[1..], result);
                        break;
                    case "keywords":
                        // await GenerateKeywordreplacedle(pathSegs[1..], result);
                        break;
                }
            }

            result.Reverse();

            return string.Join(" - ", result);
        }

19 View Source File : CandleManager.cs
License : Apache License 2.0
Project Creator : AlexWan

private async void CandleStarter()
        {
            try
            {
                while (true)
                {

                   await Task.Delay(50);

                    if (_isDisposed == true)
                    {
                        return;
                    }

                    if (MainWindow.ProccesIsWorked == false)
                    {
                        return;
                    }

                    if (_candleSeriesNeadToStart.Count != 0)
                    {
                        CandleSeries series = _candleSeriesNeadToStart.Dequeue();

                        if (series == null || series.IsStarted)
                        {
                            continue;
                        }

                        ServerType serverType = _server.ServerType;

                        if (serverType == ServerType.Tester)
                        {
                            series.IsStarted = true;
                        }

                        else if (serverType == ServerType.Plaza ||
                                 serverType == ServerType.QuikDde ||
                                 serverType == ServerType.AstsBridge ||
                                 serverType == ServerType.NinjaTrader ||
                                 serverType == ServerType.Lmax)
                        {
                            series.CandlesAll = null;
                            // further, we try to load candles with ticks
                            // далее, пытаемся пробуем прогрузить свечи при помощи тиков
                            List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);

                            series.PreLoad(allTrades);
                            // if there is a preloading of candles on the server and something is downloaded
                            // если на сервере есть предзагрузка свечек и что-то скачалось 
                            series.UpdateAllCandles();

                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.SmartCom)
                        {
                            SmartComServer smart = (SmartComServer) _server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);

                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = smart.GetSmartComCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan, 170);
                                if (candles != null)
                                {
                                    candles.Reverse();
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Tinkoff)
                        {
                            TinkoffServer smart = (TinkoffServer)_server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1 ||
                                series.TimeFrame == TimeFrame.Hour2 ||
                                series.TimeFrame == TimeFrame.Hour4 ||
                                series.TimeFrame == TimeFrame.Min20 ||
                                series.TimeFrame == TimeFrame.Min45)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);

                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = smart.GetCandleHistory(series.Security.NameId,
                                    series.TimeFrame);

                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Tester ||
                                 serverType == ServerType.Optimizer ||
                                 serverType == ServerType.Oanda||
                                 serverType == ServerType.BitStamp
                            )
                        {
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.QuikLua)
                        {
                            QuikLuaServer luaServ = (QuikLuaServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple || 
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = luaServ.GetQuikLuaTickHistory(series.Security);
                                if (allTrades != null && allTrades.Count != 0)
                                {
                                    series.PreLoad(allTrades);
                                }
                            }
                            else
                            {
                                List<Candle> candles = luaServ.GetQuikLuaCandleHistory(series.Security,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    //candles.Reverse();
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.BitMex)
                        {
                            BitMexServer bitMex = (BitMexServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple || 
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = bitMex.GetBitMexCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Kraken)
                        {
                            KrakenServer kraken = (KrakenServer)_server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = kraken.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Binance)
                        {
                            BinanceServer binance = (BinanceServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple || 
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = binance.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.InteractivBrokers)
                        {
                            InteractiveBrokersServer server = (InteractiveBrokersServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = server.GetCandleHistory(series.Security.Name,
                                    series.TimeFrame);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.BinanceFutures)
                        {

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                BinanceServerFutures binance = (BinanceServerFutures)_server;
                                List<Candle> candles = binance.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.BitMax)
                        {
                            BitMaxProServer bitMax = (BitMaxProServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = bitMax.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Bitfinex)
                        {
                            BitfinexServer bitfinex = (BitfinexServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple || 
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = bitfinex.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Transaq)
                        {
                            TransaqServer transaq = (TransaqServer)_server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);

                                series.PreLoad(allTrades);
                                series.UpdateAllCandles();
                                series.IsStarted = true;
                            }
                            else
                            {
                                transaq.GetCandleHistory(series);
                            }
                        }
                        else if (serverType == ServerType.Livecoin ||
                                 serverType == ServerType.Exmo)
                        {
                            List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);

                            series.PreLoad(allTrades);
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Zb)
                        {
                            ZbServer zbServer = (ZbServer)_server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = zbServer.GetCandleHistory(series.Security.Name, series.TimeFrameSpan);

                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.GateIo)
                        {
                            GateIoServer gateIoServer = (GateIoServer)_server;

                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = gateIoServer.GetCandleHistory(series.Security.Name, series.TimeFrameSpan);

                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.GateIoFutures)
                        {
                            GateIoFuturesServer gateIoFutures = (GateIoFuturesServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = gateIoFutures.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.Hitbtc)
                        {
                            HitbtcServer hitbtc = (HitbtcServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = hitbtc.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.HuobiSpot)
                        {
                            HuobiSpotServer huobiSpot = (HuobiSpotServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = huobiSpot.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.HuobiFutures)
                        {
                            HuobiFuturesServer huobi = (HuobiFuturesServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = huobi.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.HuobiFuturesSwap)
                        {
                            HuobiFuturesSwapServer huobi = (HuobiFuturesSwapServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = huobi.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                        else if (serverType == ServerType.FTX)
                        {
                            FTXServer ftxServer = (FTXServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = ftxServer.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }

                        else if (serverType == ServerType.Bybit)
                        {
                            BybitServer bybit = (BybitServer)_server;
                            if (series.CandleCreateMethodType != CandleCreateMethodType.Simple ||
                                series.TimeFrameSpan.TotalMinutes < 1)
                            {
                                List<Trade> allTrades = _server.GetAllTradesToSecurity(series.Security);
                                series.PreLoad(allTrades);
                            }
                            else
                            {
                                List<Candle> candles = bybit.GetCandleHistory(series.Security.Name,
                                    series.TimeFrameSpan);
                                if (candles != null)
                                {
                                    series.CandlesAll = candles;
                                }
                            }
                            series.UpdateAllCandles();
                            series.IsStarted = true;
                        }
                    }
                }
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }
        }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static List<Formula> CreateFormulaInvocationFormulaForLblIndexes(ushort rw, ushort col, string var1Lblname, string var2Lblname, int var1Lblindex, int var2Lblindex)
        {
            // =ARGUMENT("var1",2)
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.ARGUMENT, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(2));
            ptgList.Add(new PtgStr(var1Lblname, true, AbstractPtg.PtgDataType.VALUE));
            ptgList.Reverse();
            Stack<AbstractPtg> ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formFuncArg1Formula = new Formula(new Cell(rw, col), FormulaValue.GetEmptyStringFormulaValue(), true,
                new CellParsedFormula(ptgStack));
            
            // =ARGUMENT("var2",8)
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.ARGUMENT, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(8));
            ptgList.Add(new PtgStr(var2Lblname, true, AbstractPtg.PtgDataType.VALUE));
            ptgList.Reverse();
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formFuncArg2Formula = new Formula(new Cell(rw+1, col), FormulaValue.GetEmptyStringFormulaValue(), true,
                new CellParsedFormula(ptgStack));

            // =FORMULA(var1,var2)
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(CetabValues.FORMULA, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgName(var2Lblindex));
            ptgList.Add(new PtgName(var1Lblindex));
            ptgList.Reverse();     
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formulaInvocationFunction = new Formula(new Cell(rw+2, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));
            
            // =RETURN()
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.RETURN, 0, AbstractPtg.PtgDataType.VALUE));
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula returnFormula = new Formula(new Cell(rw+3, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));

            return new List<Formula>() {formFuncArg1Formula, formFuncArg2Formula, formulaInvocationFunction, returnFormula};
        }

19 View Source File : Util.cs
License : MIT License
Project Creator : anastasios-stamoulis

public static List<string> detailed_summary(C.Function root, bool print = true) {
      // This is based on the C.logging.graph.plot, but without the actual plotting part
      // Walks through every node of the graph starting at ``root``, creates a network graph, and returns a network description
      var model = new List<string>();
      root = root.RootFunction;
      var root_uid = root.Uid;
      var stack = new Stack<object>();
      stack.Push(root);
      var visited_uids = new HashSet<string>();
      while (stack.Count > 0) {
        var popped = stack.Pop();
        if (popped is C.Variable) {
          var v = (C.Variable)popped;
          if (v.IsOutput) {
            stack.Push(v.Owner);
          }
          else if (v.IsInput) {
            model.Add(v.replacedtring());
          }
          continue;
        }
        if (popped is IList<C.Variable>) {
          foreach (var pv in (IList<C.Variable>)popped) {
            stack.Push(pv);
          }
          continue;
        }
        var node = (C.Function)popped;
        if (visited_uids.Contains(node.Uid)) { continue; }
        node = node.RootFunction;
        stack.Push(node.RootFunction.Inputs);
        var line = new System.Text.StringBuilder($"{node.Name} : {node.OpName} ({node.Uid}) :");
        line.Append("(");
        for (int i = 0; i < node.Inputs.Count; i++) {
          var input = node.Inputs[i];
          if (node.IsBlock && input.IsConstant) { continue; }
          line.Append(input.Uid);
          if (i != (node.Inputs.Count - 1)) {
            line.Append(", ");
          }
        }
        line.Append(") -> ");
        foreach (var v in node.Outputs) {
          model.Add(line.ToString() + "\t" + shape_desc(v));
        }
        visited_uids.Add(node.Uid);
      }
      model.Reverse();

      if (print) {
        for (int i = 0; i < model.Count; i++) {
          Console.WriteLine(model[i]);
        }
      }
      return model;
    }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static List<Formula> CreateCharFunctionWithArgsForLbl(ushort rw, ushort col, int var1Lblindex, string var1Lblname)
        {
            // =ARGUMENT("var1",1)
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.ARGUMENT, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(1));
            ptgList.Add(new PtgStr(var1Lblname, true, AbstractPtg.PtgDataType.VALUE));
            ptgList.Reverse();
            Stack<AbstractPtg> ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula charFuncArgFormula = new Formula(new Cell(rw, col), FormulaValue.GetEmptyStringFormulaValue(), true,
                new CellParsedFormula(ptgStack));

            // =RETURN(CHAR(var1))
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.RETURN, 1, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgFunc(FtabValues.CHAR, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgName(var1Lblindex));
            ptgList.Reverse();     
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula charInvocationReturnFormula = new Formula(new Cell(rw+1, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));
            return new List<Formula>() {charFuncArgFormula, charInvocationReturnFormula};
        }

19 View Source File : NodeEditorAction.cs
License : MIT License
Project Creator : aksyr

public void DrawDraggedConnection() {
            if (IsDraggingPort) {
                Color col = NodeEditorPreferences.GetTypeColor(draggedPort.ValueType);
                col.a = draggedPortTarget != null ? 1.0f : 0.6f;

                Rect fromRect;
                if (!_portConnectionPoints.TryGetValue(draggedPort, out fromRect)) return;
                List<Vector2> gridPoints = new List<Vector2>();
                gridPoints.Add(fromRect.center);
                for (int i = 0; i < draggedOutputReroutes.Count; i++) {
                    gridPoints.Add(draggedOutputReroutes[i]);
                }
                if (draggedPortTarget != null) gridPoints.Add(portConnectionPoints[draggedPortTarget].center);
                else gridPoints.Add(WindowToGridPosition(Event.current.mousePosition));

                if(draggedPort.IsInput)
                {
                    gridPoints.Reverse();
                }
                DrawNoodle(col, gridPoints);

                Color bgcol = Color.black;
                Color frcol = col;
                bgcol.a = 0.6f;
                frcol.a = 0.6f;

                // Loop through reroute points again and draw the points
                for (int i = 0; i < draggedOutputReroutes.Count; i++) {
                    // Draw reroute point at position
                    Rect rect = new Rect(draggedOutputReroutes[i], new Vector2(16, 16));
                    rect.position = new Vector2(rect.position.x - 8, rect.position.y - 8);
                    rect = GridToWindowRect(rect);

                    NodeEditorGUILayout.DrawPortHandle(rect, bgcol, frcol);
                }
            }
        }

19 View Source File : JsonFsCheck.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : agocke

public static IReadOnlyList<MemberDeclarationSyntax> ToMembers(TestTypeDef typeDef)
        {
            // Types have generated unique names, counting from a depth-first traversal
            var types = new List<MemberDeclarationSyntax>();
            _ = VisitType(typeDef, typeIndex: 0, types);
            // Reverse types, as they're added depth-first
            types.Reverse();
            return types;

            // Generate syntax for the given typedef, and the type definition for the generated
            // types of any fields. Returns the type index of the last type generated.
            static int VisitType(TestType type, int typeIndex, List<MemberDeclarationSyntax> types)
            {
                switch (type)
                {
                    case TestListLike arr:
                        return VisitType(arr.ElementType, typeIndex, types);
                    case TestTypeDef typeDef:
                        var fieldsSyntax = new List<MemberDeclarationSyntax>();
                        // nextIndex tracks the number of types we're generating. Every type
                        // will get a new index, which will be used to create a unique name
                        int nextIndex = typeIndex + 1;
                        for (int fieldIndex = 0; fieldIndex < typeDef.FieldTypes.Length; fieldIndex++)
                        {
                            var field = typeDef.FieldTypes[fieldIndex];
                            var fieldTypeName = field.TypeSyntax(nextIndex);
                            ExpressionSyntax initializer = field.Value(nextIndex);
                            fieldsSyntax.Add(FieldDeclaration(
                                attributeLists: default,
                                modifiers: TokenList(Token(SyntaxKind.PublicKeyword)),
                                VariableDeclaration(
                                    fieldTypeName,
                                    SeparatedList(new[] { VariableDeclarator(
                                Identifier("Field" + fieldIndex),
                                argumentList: null,
                                initializer: EqualsValueClause(initializer)) }))
                            ));
                            nextIndex = VisitType(field, nextIndex, types);
                        }

                        // Add the first type
                        types.Add(ClreplacedDeclaration(
                            attributeLists: List(new[] { AttributeList(SeparatedList(new[] { Attribute(IdentifierName("GenerateSerialize")) })) }),
                            modifiers: TokenList(new[] { Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.PartialKeyword) }),
                            identifier: Identifier(typeDef.TypeName(typeIndex)),
                            typeParameterList: null,
                            baseList: null,
                            constraintClauses: default,
                            List(fieldsSyntax)
                        ));
                        return nextIndex;

                    default:
                        return typeIndex;
                }
            }
        }

19 View Source File : BaseObjectCollection.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

protected void SortNodes()
        {
            switch (SortType)
            {
                case CollationOrder.ChildOrder:
                    NodeList.Sort((c1, c2) => (c1.Transform.GetSiblingIndex().CompareTo(c2.Transform.GetSiblingIndex())));
                    break;

                case CollationOrder.Alphabetical:
                    NodeList.Sort((c1, c2) => (string.CompareOrdinal(c1.Name, c2.Name)));
                    break;

                case CollationOrder.AlphabeticalReversed:
                    NodeList.Sort((c1, c2) => (string.CompareOrdinal(c1.Name, c2.Name)));
                    NodeList.Reverse();
                    break;

                case CollationOrder.ChildOrderReversed:
                    NodeList.Sort((c1, c2) => (c1.Transform.GetSiblingIndex().CompareTo(c2.Transform.GetSiblingIndex())));
                    NodeList.Reverse();
                    break;
            }
        }

19 View Source File : BiomeSwitchGraph.cs
License : MIT License
Project Creator : alelievr

List< BiomeSwitchData > GetPrecedentSwitchDatas(BaseNode currentNode, BaseNode rootNode)
		{
			var precedentSwitchDatas = new List< BiomeSwitchData >();

			BaseNode n = currentNode;
			while (n != rootNode)
			{
				BaseNode prevNode = n;
				n = n.GetInputNodes().First();
				if (n.GetType() != typeof(NodeBiomeSwitch))
					break ;
				
				var switches = (n as NodeBiomeSwitch).switchList;
				
				int index = n.outputAnchors.ToList().FindIndex(a => a.links.Any(l => l.toNode == prevNode));

				if (index == -1)
					throw new InvalidOperationException("[PWBiomeSwitchGraph] IMPOSSIBRU !!!!! check your node API !");
				
				precedentSwitchDatas.Add(switches[index]);
			}

			precedentSwitchDatas.Reverse();

			return precedentSwitchDatas;
		}

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

private static Stack<AbstractPtg> GetAntireplacedysisCharSubroutineForInt(ushort charInt, string varName, string decoyVarName,
            int functionLabelOffset)
        {
            int numAndArgs = 2;

            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.IF, 3, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgMissArg());
            ptgList.Add(new PtgFuncVar(FtabValues.USERDEFINEDFUNCTION, 1, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgName(functionLabelOffset));
            ptgList.Add(new PtgFuncVar(FtabValues.AND, numAndArgs, AbstractPtg.PtgDataType.VALUE));

            Random r = new Random();
            int correctArg = r.Next(0, numAndArgs);

            for (int i = 0; i < numAndArgs; i += 1)
            {
                ptgList.Add(new PtgFuncVar(FtabValues.SET_NAME, 2, AbstractPtg.PtgDataType.VALUE));

                if (i == correctArg)
                {
                    ptgList.Add(new PtgInt(charInt));
                    ptgList.Add(new PtgStr(varName, true));
                }
                else
                {
                    ptgList.Add(new PtgInt((ushort)r.Next(1,255)));
                    ptgList.Add(new PtgStr(decoyVarName, true));
                }


            }
            ptgList.Reverse();
            return new Stack<AbstractPtg>(ptgList);
        }

19 View Source File : Connection.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj

protected void Reverse()
		{
			Shape shape = startShape;
			startShape = endShape;
			endShape = shape;

			LineOrientation orientation = startOrientation;
			startOrientation = endOrientation;
			endOrientation = orientation;

			bendPoints.Reverse();
			RouteCache.Reverse();
			foreach (BendPoint point in BendPoints)
			{
				point.RelativeToStartShape = !point.RelativeToStartShape;
			}

			NeedsRedraw = true;
		}

19 View Source File : SiteMapNodeDrop.cs
License : MIT License
Project Creator : Adoxio

private SiteMapNodeDrop[] GetBreadcrumbs()
		{
			var breadcrumbs = new List<SiteMapNodeDrop>();

			var parent = Parent;

			while (parent != null)
			{
				breadcrumbs.Add(parent);

				parent = parent.Parent;
			}

			breadcrumbs.Reverse();

			return breadcrumbs.ToArray();
		}

19 View Source File : GateIoFuturesServer.cs
License : Apache License 2.0
Project Creator : AlexWan

public override List<Trade> GetTickDataToSecurity(Security security, DateTime startTime, DateTime endTime, DateTime actualTime)
        {
            List<Trade> trades = new List<Trade>();

            DateTime endOver = endTime;

            while (true)
            {
                if (endOver <= startTime)
                {
                    break;
                }

                List<Trade> newTrades = GetTrades(security.Name, endOver);

                if (newTrades != null && newTrades.Count != 0)
                    trades.AddRange(newTrades);
                else
                    break;

                endOver = trades[trades.Count - 1].Time.AddSeconds(-1);
                Thread.Sleep(100);
            }

            if (trades.Count == 0)
            {
                return null;
            }


            while (trades.Last().Time < startTime)
            {
                trades.Remove(trades.Last());
            }

            trades.Reverse();

            return trades;
        }

19 View Source File : AStarManager.cs
License : MIT License
Project Creator : 404Lcc

public List<AStarNodeData> GeneratePath(AStarNodeData startAStarNodeData, AStarNodeData endAStarNodeData)
        {
            List<AStarNodeData> pathList = new List<AStarNodeData>();
            if (endAStarNodeData != null)
            {
                AStarNodeData temp = endAStarNodeData;
                while (temp != startAStarNodeData)
                {
                    pathList.Add(temp);
                    temp = temp.parent;
                }
                pathList.Reverse();
            }
            UpdatePath(pathList.ToArray());
            return pathList;
        }

19 View Source File : TreeNode.cs
License : MIT License
Project Creator : amidos2006

public List<int[]> getPath(){
            List<int[]> result = new List<int[]>();
            TreeNode current = this;
            while(current != null){
                result.Add(new int[]{current.x, current.y});
                current = current.parent;
            }
            result.Reverse();
            return result;
        }

19 View Source File : IBlockchainService.cs
License : MIT License
Project Creator : AElfProject

public async Task<List<Hash>> GetBlockHashesAsync(Chain chain, Hash firstHash, int count,
            Hash chainBranchBlockHash)
        {
            var first = await _blockManager.GetBlockHeaderAsync(firstHash);

            if (first == null)
                return new List<Hash>();

            var height = first.Height + count;

            var chainBranchBlockHashKey = chainBranchBlockHash.ToStorageKey();

            ChainBlockLink chainBlockLink = null;

            if (chain.Branches.ContainsKey(chainBranchBlockHashKey))
            {
                if (height > chain.Branches[chainBranchBlockHashKey])
                {
                    height = chain.Branches[chainBranchBlockHashKey];
                    count = (int) (height - first.Height);
                }
            }
            else
            {
                var branchChainBlockLink = await _chainManager.GetChainBlockLinkAsync(chainBranchBlockHash);
                if (height > branchChainBlockLink.Height)
                {
                    height = branchChainBlockLink.Height;
                    chainBlockLink = branchChainBlockLink;
                    count = (int) (height - first.Height);
                }
            }

            var hashes = new List<Hash>();

            if (count <= 0)
                return hashes;


            if (chainBlockLink == null)
            {
                var last = await GetBlockHashByHeightAsync(chain, height, chainBranchBlockHash);

                if (last == null)
                    throw new InvalidOperationException("not support");

                chainBlockLink = await _chainManager.GetChainBlockLinkAsync(last);
            }


            hashes.Add(chainBlockLink.BlockHash);
            for (var i = 0; i < count - 1; i++)
            {
                chainBlockLink = await _chainManager.GetChainBlockLinkAsync(chainBlockLink.PreviousBlockHash);
                hashes.Add(chainBlockLink.BlockHash);
            }

            if (chainBlockLink.PreviousBlockHash != firstHash)
            {
                throw new Exception("wrong branch");
            }

            hashes.Reverse();

            return hashes;
        }

19 View Source File : IChainManager.cs
License : MIT License
Project Creator : AElfProject

public async Task<List<ChainBlockLink>> GetNotExecutedBlocks(Hash blockHash)
        {
            var output = new List<ChainBlockLink>();
            while (true)
            {
                var chainBlockLink = await GetChainBlockLinkAsync(blockHash);
                if (chainBlockLink != null)
                {
                    if (chainBlockLink.ExecutionStatus == ChainBlockLinkExecutionStatus.ExecutionNone)
                    {
                        output.Add(chainBlockLink);
                        if (chainBlockLink.PreviousBlockHash != null)
                            blockHash = chainBlockLink.PreviousBlockHash;
                        continue;
                    }
                    else if (chainBlockLink.ExecutionStatus == ChainBlockLinkExecutionStatus.ExecutionFailed)
                    {
                        output.Clear();
                    }
                }

                break;
            }

            output.Reverse();
            return output;
        }

19 View Source File : HolidayUtil.cs
License : MIT License
Project Creator : 6tail

private static List<Holiday> findHolidaysBackward(string key)
        {
            List<Holiday> l = new List<Holiday>();
            string s = findBackward(key);
            if (null == s)
            {
                return l;
            }
            while (s.EndsWith(key))
            {
                l.Add(buildHolidayBackward(s));
                s = s.Substring(0, s.Length - SIZE);
            }
            l.Reverse();
            return l;
        }

19 View Source File : SourceMasterRepository.cs
License : MIT License
Project Creator : afaniuolo

public string GereplacedemPath(Guid itemId)
		{
			var scItem = _sourceMasterDb.Items.FirstOrDefault(item => item.ID == itemId);
			if (scItem == null)
			{
				return string.Empty;
			}

			List<string> itemNames = new List<string>();
			itemNames.Add(scItem.Name);
			var isRootSitecoreItem = false;
			while (!isRootSitecoreItem)
			{
				scItem = _sourceMasterDb.Items.FirstOrDefault(item => item.ID == scItem.ParentID);
				if (scItem == null) break;
				itemNames.Add(scItem.Name);
				isRootSitecoreItem = scItem.ID == new Guid("{11111111-1111-1111-1111-111111111111}");		
			}

			itemNames.Reverse();
			return "/" + String.Join("/", itemNames);
		}

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

private static Stack<AbstractPtg> GetCharSubroutineForInt(ushort charInt, string varName,
            int functionLabelOffset)
        {
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.IF, 3, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgMissArg());
            ptgList.Add(new PtgFuncVar(FtabValues.USERDEFINEDFUNCTION, 1, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgName(functionLabelOffset));
            ptgList.Add(new PtgFuncVar(FtabValues.SET_NAME, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(charInt));
            ptgList.Add(new PtgStr(varName, true));
            ptgList.Reverse();
            return new Stack<AbstractPtg>(ptgList);
        }

19 View Source File : DefaultContractResolver.cs
License : MIT License
Project Creator : akaskela

private List<Type> GetClreplacedHierarchyForType(Type type)
        {
            List<Type> ret = new List<Type>();

            Type current = type;
            while (current != null && current != typeof(object))
            {
                ret.Add(current);
                current = current.BaseType();
            }

            // Return the clreplaced list in order of simple => complex
            ret.Reverse();
            return ret;
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AhmedOS

private void DeleteSelectedButton_Click(object sender, EventArgs e)
        {
            List<int> list = new List<int>();
            foreach (int index in filesListBox.SelectedIndices)
                list.Add(index);
            list.Reverse();
            foreach (int index in list)
                filesListBox.Items.RemoveAt(index);
        }

19 View Source File : AwaiterExtensions.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private static List<Type> GenerateObjectTrace(IEnumerable<IEnumerator> enumerators)
            {
                var objTrace = new List<Type>();

                foreach (var enumerator in enumerators)
                {
                    // NOTE: This only works with scripting engine 4.6
                    // And could easily stop working with unity updates
                    var field = enumerator.GetType().GetField("$this", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                    if (field == null)
                    {
                        continue;
                    }

                    var obj = field.GetValue(enumerator);

                    if (obj == null)
                    {
                        continue;
                    }

                    var objType = obj.GetType();

                    if (!objTrace.Any() || objType != objTrace.Last())
                    {
                        objTrace.Add(objType);
                    }
                }

                objTrace.Reverse();
                return objTrace;
            }

19 View Source File : Vertices.cs
License : MIT License
Project Creator : Alan-FGR

public void ForceCounterClockWise()
        {
            //The simplest polygon which can exist in the Euclidean plane has 3 sides.
            if (Count < 3)
                return;

            if (!IsCounterClockWise())
                Reverse();
        }

19 View Source File : KissMangaHelper.cs
License : GNU General Public License v3.0
Project Creator : 9vult

public static string[] GetChapterUrls(string mUrl)
        {
            var doreplacedent = new HtmlWeb().Load(mUrl);
            string[] urls = doreplacedent.DoreplacedentNode.Descendants("a")
                            .Select(e => e.GetAttributeValue("href", null))
                            .Where(s => !string.IsNullOrEmpty(s)).ToArray<string>();

            List<string> chapterUrls = new List<string>();

            foreach (string url in urls)
            {
                if (url.StartsWith("/chapter/"))
                {
                    chapterUrls.Add(url);
                }
            }

            chapterUrls.Reverse(); // Switch to increasing (1->2)

            return chapterUrls.ToArray();
        }

19 View Source File : GUIScaleUtility.cs
License : MIT License
Project Creator : alelievr

public static void MoveClipsUp (int count) 
		{
			// Record and close all clips one by one, from bottom to top, until reached the count or hit the 'origin'
			List<Rect> rectStackGroup = new List<Rect> ();
			Rect topMostClip = getTopRect;
			while (topMostClip != new Rect (-10000, -10000, 40000, 40000) && count > 0)
			{
				rectStackGroup.Add (topMostClip);
				GUI.EndClip ();
				topMostClip = getTopRect;
				count--;
			}
			// Store the clips appropriately
			rectStackGroup.Reverse ();
			rectStackGroups.Add (rectStackGroup);
			currentRectStack.AddRange (rectStackGroup);
		}

19 View Source File : TextFormattingConverterBase.cs
License : MIT License
Project Creator : ABTSoftware

public string HighlightTermsBase(string text, string[] terms)
        {
            var set = new HashSet<int>();
            foreach (var term in terms)
            {
                var indexes = text.ToLower().AllIndexesOf(term).Reverse().ToList();
                foreach (var index in indexes)
                {
                    for (int j = 0; j < term.Length; j++)
                    {
                        set.Add(j + index);
                    }
                }
            }

            if (set.Count > 0)
            {
                var list = set.ToList();
                list.Sort();

                var ranges = GetRanges(list.ToArray());
                ranges.Reverse();

                var color = HighlightColor ?? Colors.Black;
                string colorString = string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", color.A, color.R, color.G, color.B);

                foreach (var range in ranges)
                {
                    text = text.Insert(range.Item1 + range.Item2, "</Run>");
                    text = text.Insert(range.Item1, string.Format("<Run Foreground=\"{0}\">", colorString));
                }
            }

            return text;
        }

19 View Source File : SortWay.cs
License : MIT License
Project Creator : alen-smajic

private void Start()
    {
        allWayCoordinates = new List<List<Vector3>>();
        SortedPathAndWays = new List<List<List<Vector3>>>();
        SplittedinPaths = new List<List<Vector3>>();
        PathsInRightOrder = new List<List<Vector3>>();

        MoveToTarget = new List<Vector3>();
        PathLastNode = new List<Vector3>();

        List<GameObject> allObjects = new List<GameObject>();
        Scene scene = SceneManager.GetActiveScene();
        scene.GetRootGameObjects(allObjects);

        // This for loop returns a list "allWayCoordinates" which contains more lists. Every list of these are way objects
        // which contain the node coordinates
        for (int i = 0; i < TranSportWayMarker.SelectedWays.Count; i++)
        {
            string ObjectName = allObjects[TranSportWayMarker.SelectedWays[i]].name;
            string ObjectID = ObjectName.Substring(15); // The ID of the way is being determined in order to search for it in the MapReader clreplaced.

            List<Vector3> WayNodes = new List<Vector3>();
            for (int j = 0; j < MapReader.ways[Convert.ToUInt64(ObjectID)].UnityCoordinates.Count; j++)
            {
                WayNodes.Add(MapReader.ways[Convert.ToUInt64(ObjectID)].UnityCoordinates[j]);
            }
            allWayCoordinates.Add(WayNodes); 
            // allWayCoordinates contains lists which represent the way objects. Every single one of these lists contains the node coordinates as values.
        }

        // Next we create a new list (SortedPathAndWays). This list merges the ways that belong to a common path.
        // E.g. if a bus line ends on one edge of the map and continues at another edge of the map, the corresponding ways will be stored in different lists.
        List<List<Vector3>> localList = new List<List<Vector3>>();
        localList.Add(allWayCoordinates[0]);
        SortedPathAndWays.Add(localList);
        allWayCoordinates.RemoveAt(0);

        // Is being called to sort the SortedPathAndWays with  respect to allWayCoordinates.
        SortList(allWayCoordinates, 0);

        // Here we transform the three-dimensional SortedPathAndWays list into a two-dimensional list. We do this by concatenating the inner lists
        // because these are already sorted.
        List<Vector3> temporaryList = new List<Vector3>();
        for(int i = 0; i < SortedPathAndWays.Count; i++) 
        {
            temporaryList = SortedPathAndWays[i].SelectMany(x => x).ToList();
            SplittedinPaths.Add(temporaryList);
        }

        for(int i = 0; i < TranSportWayMarker.StationOrder.Count; i++)
        {
            for(int j = 0; j < SplittedinPaths.Count; j++)
            {
                for(int k = 0; k < SplittedinPaths[j].Count; k++)
                {
                    if(TranSportWayMarker.StationOrder[i] == SplittedinPaths[j][k])
                    {
                        if (PathsInRightOrder.Contains(SplittedinPaths[j]))
                        {
                            break;
                        }
                        else
                        {
                            PathsInRightOrder.Add(SplittedinPaths[j]);
                        }
                    }
                }
            }
        }

        // Append paths which dont contain any station at the end.
        for(int i = 0; i < SplittedinPaths.Count; i++)
        {
            if (!PathsInRightOrder.Contains(SplittedinPaths[i]))
            {
                PathsInRightOrder.Add(SplittedinPaths[i]);
            }
        }

        // Switch the direction of the values within the paths using the stations.
        int firstIndex = -1;
        int secondIndex = -1;
        for(int i = 0; i < TranSportWayMarker.StationOrder.Count; i++)
        {
            for(int k = 0; k < PathsInRightOrder.Count; k++)
            {
                for(int j = 0; j < PathsInRightOrder[k].Count; j++)
                {
                    if(TranSportWayMarker.StationOrder[i] == PathsInRightOrder[k][j])
                    {
                        if(firstIndex == -1)
                        {
                            firstIndex = j;
                            break;
                        }
                        else
                        {
                            secondIndex = j;
                            break;
                        }
                    }
                }
                if(firstIndex != -1 && secondIndex != -1)
                {
                    if(firstIndex > secondIndex)
                    {
                        PathsInRightOrder[k].Reverse();
                        break;
                    }
                }
            }
        }

        for(int i = 0; i < PathsInRightOrder.Count; i++)
        {
            for(int j = 0; j < SortWay.PathsInRightOrder[i].Count; j++)
            {
                MoveToTarget.Add(SortWay.PathsInRightOrder[i][j]);
            }
        }

        if(SortWay.PathsInRightOrder.Count > 1)
        {
            for(int i = 0; i < PathsInRightOrder.Count; i++)
            {
                PathLastNode.Add(PathsInRightOrder[i][PathsInRightOrder[i].Count - 1]);
            }
        }

        IdentifyVehicle();
    }

19 View Source File : Utils.cs
License : GNU General Public License v3.0
Project Creator : 2dust

public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
        {
            List<Mode.VmessItem> list = new List<Mode.VmessItem>();
            if (!keepOlder) source.Reverse(); // Remove the early items first

            bool _isAdded(Mode.VmessItem o, Mode.VmessItem n)
            {
                return o.configVersion == n.configVersion &&
                    o.configType == n.configType &&
                    o.address == n.address &&
                    o.port == n.port &&
                    o.id == n.id &&
                    o.alterId == n.alterId &&
                    o.security == n.security &&
                    o.network == n.network &&
                    o.headerType == n.headerType &&
                    o.requestHost == n.requestHost &&
                    o.path == n.path &&
                    o.streamSecurity == n.streamSecurity;
                // skip (will remove) different remarks
            }
            foreach (Mode.VmessItem item in source)
            {
                if (!list.Exists(i => _isAdded(i, item)))
                {
                    list.Add(item);
                }
            }
            if (!keepOlder) list.Reverse();
            result = list;
        }

19 View Source File : PaginatedMessagesControlViewModel.cs
License : GNU General Public License v3.0
Project Creator : alexdillon

private async Task<IEnumerable<Message>> GetFromGroupMeAsync(Message startAt, Message endAt)
        {
            var result = new List<Message>(this.MessagesPerPage);
            long.TryParse(startAt.Id, out var startId);
            long.TryParse(endAt.Id, out var endId);

            // GroupMe only allows before_id searches on Chat's (not after_id), so we have to go backwards...
            // Add 1 to include the endAt message in the returned data.
            long currentId = endId + 1;
            while (currentId > startId)
            {
                var msgs = await this.replacedociateWith.GetMessagesAsync(GroupMeClientApi.MessageRetreiveMode.BeforeId, currentId.ToString());
                result.AddRange(msgs);

                currentId = long.Parse(msgs.Last().Id);
            }

            // Since we went backwards, reverse the list.
            result.Reverse();

            // GroupMe block sizes might not align with the pagination page-sizes.
            // Cut to match the expected page size.
            int startIndex = result.FindIndex(m => m.Id == startAt.Id);
            return result.Skip(startIndex);
        }

19 View Source File : ExpressionParser.cs
License : MIT License
Project Creator : actions

private static List<ExpressionNode> PopOperands(
            ParseContext context,
            Int32 count)
        {
            var result = new List<ExpressionNode>();
            while (count-- > 0)
            {
                result.Add(context.Operands.Pop());
            }

            result.Reverse();
            return result;
        }

19 View Source File : PieSeries.cs
License : MIT License
Project Creator : AlexGyver

public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.Slices.Count == 0)
            {
                return;
            }

            double total = this.slices.Sum(slice => slice.Value);
            if (Math.Abs(total) < double.Epsilon)
            {
                return;
            }

            // todo: reduce available size due to the labels
            double radius = Math.Min(model.PlotArea.Width, model.PlotArea.Height) / 2;

            double outerRadius = radius * (this.Diameter - this.ExplodedDistance);
            double innerRadius = radius * this.InnerDiameter;

            double angle = this.StartAngle;
            var midPoint = new ScreenPoint(
                (model.PlotArea.Left + model.PlotArea.Right) * 0.5, (model.PlotArea.Top + model.PlotArea.Bottom) * 0.5);

            foreach (var slice in this.slices)
            {
                var outerPoints = new List<ScreenPoint>();
                var innerPoints = new List<ScreenPoint>();

                double sliceAngle = slice.Value / total * this.AngleSpan;
                double endAngle = angle + sliceAngle;
                double explodedRadius = slice.IsExploded ? this.ExplodedDistance * radius : 0.0;

                double midAngle = angle + (sliceAngle / 2);
                double midAngleRadians = midAngle * Math.PI / 180;
                var mp = new ScreenPoint(
                    midPoint.X + (explodedRadius * Math.Cos(midAngleRadians)),
                    midPoint.Y + (explodedRadius * Math.Sin(midAngleRadians)));

                // Create the pie sector points for both outside and inside arcs
                while (true)
                {
                    bool stop = false;
                    if (angle >= endAngle)
                    {
                        angle = endAngle;
                        stop = true;
                    }

                    double a = angle * Math.PI / 180;
                    var op = new ScreenPoint(mp.X + (outerRadius * Math.Cos(a)), mp.Y + (outerRadius * Math.Sin(a)));
                    outerPoints.Add(op);
                    var ip = new ScreenPoint(mp.X + (innerRadius * Math.Cos(a)), mp.Y + (innerRadius * Math.Sin(a)));
                    if (innerRadius + explodedRadius > 0)
                    {
                        innerPoints.Add(ip);
                    }

                    if (stop)
                    {
                        break;
                    }

                    angle += this.AngleIncrement;
                }

                innerPoints.Reverse();
                if (innerPoints.Count == 0)
                {
                    innerPoints.Add(mp);
                }

                innerPoints.Add(outerPoints[0]);

                var points = outerPoints;
                points.AddRange(innerPoints);

                rc.DrawPolygon(points, slice.ActualFillColor, this.Stroke, this.StrokeThickness, null, OxyPenLineJoin.Bevel);

                // Render label outside the slice
                if (this.OutsideLabelFormat != null)
                {
                    string label = string.Format(
                        this.OutsideLabelFormat, slice.Value, slice.Label, slice.Value / total * 100);
                    int sign = Math.Sign(Math.Cos(midAngleRadians));

                    // tick points
                    var tp0 = new ScreenPoint(
                        mp.X + ((outerRadius + this.TickDistance) * Math.Cos(midAngleRadians)),
                        mp.Y + ((outerRadius + this.TickDistance) * Math.Sin(midAngleRadians)));
                    var tp1 = new ScreenPoint(
                        tp0.X + (this.TickRadialLength * Math.Cos(midAngleRadians)),
                        tp0.Y + (this.TickRadialLength * Math.Sin(midAngleRadians)));
                    var tp2 = new ScreenPoint(tp1.X + (this.TickHorizontalLength * sign), tp1.Y);
                    rc.DrawLine(new[] { tp0, tp1, tp2 }, this.Stroke, this.StrokeThickness, null, OxyPenLineJoin.Bevel);

                    // label
                    var labelPosition = new ScreenPoint(tp2.X + (this.TickLabelDistance * sign), tp2.Y);
                    rc.DrawText(
                        labelPosition,
                        label,
                        this.ActualTextColor,
                        this.ActualFont,
                        this.ActualFontSize,
                        this.ActualFontWeight,
                        0,
                        sign > 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right,
                        VerticalAlignment.Middle);
                }

                // Render label inside the slice
                if (this.InsideLabelFormat != null)
                {
                    string label = string.Format(
                        this.InsideLabelFormat, slice.Value, slice.Label, slice.Value / total * 100);
                    double r = (innerRadius * (1 - this.InsideLabelPosition)) + (outerRadius * this.InsideLabelPosition);
                    var labelPosition = new ScreenPoint(
                        mp.X + (r * Math.Cos(midAngleRadians)), mp.Y + (r * Math.Sin(midAngleRadians)));
                    double textAngle = 0;
                    if (this.AreInsideLabelsAngled)
                    {
                        textAngle = midAngle;
                        if (Math.Cos(midAngleRadians) < 0)
                        {
                            textAngle += 180;
                        }
                    }

                    rc.DrawText(
                        labelPosition,
                        label,
                        this.ActualTextColor,
                        this.ActualFont,
                        this.ActualFontSize,
                        this.ActualFontWeight,
                        textAngle,
                        HorizontalAlignment.Center,
                        VerticalAlignment.Middle);
                }
            }
        }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static Formula CreateCharInvocationFormulaForLblIndex(ushort rw, ushort col, int lblIndex)
        {
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.RETURN, 1, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgFunc(FtabValues.CHAR, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgName(lblIndex));
            ptgList.Reverse();
            Stack<AbstractPtg> ptgStack = new Stack<AbstractPtg>(ptgList);

            Formula charInvocationFormula = new Formula(new Cell(rw, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));
            return charInvocationFormula;
        }

19 View Source File : BybitServer.cs
License : Apache License 2.0
Project Creator : AlexWan

private List<Trade> GetTrades(string security, DateTime start_time, DateTime end_time)
        {
            lock (locker_candles)
            {
                List<Trade> result_trades = new List<Trade>();
                DateTime end_over = end_time;

                List<Trade> point_trades = BybitTradesCreator.GetTradesCollection(client, security, 1, -1);
                int last_trade_id = Convert.ToInt32(point_trades.Last().Id);

                while (true)
                {
                    List<Trade> new_trades = BybitTradesCreator.GetTradesCollection(client, security, 1000, last_trade_id - 1000);

                    if (new_trades != null && new_trades.Count != 0)
                    {
                        last_trade_id = Convert.ToInt32(new_trades.First().Id);

                        new_trades.AddRange(result_trades);
                        result_trades = new_trades;

                        if (result_trades.First().Time <= start_time)
                            break;
                    }
                    else
                        break;

                    Thread.Sleep(20);
                }

                for (int i = result_trades.Count - 1; i > 0; i--)
                {
                    if (result_trades[i].Time > end_time)
                        result_trades.Remove(result_trades[i]);
                }

                result_trades.Reverse();

                for (int i = result_trades.Count - 1; i > 0; i--)
                {
                    if (result_trades[i].Time < start_time)
                        result_trades.Remove(result_trades[i]);
                }

                result_trades.Reverse();

                return result_trades;
            }
        }

19 View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

private void LogColors()
        {
            for (int j = 1; j < 13; j++)
            {
                Texture2D sprite = this.Helper.Content.Load<Texture2D>("replacedets/work/hairs/" + j + ".png");
                Color[] data = new Color[sprite.Width * sprite.Height];
                sprite.GetData(data);
                Dictionary<int,string> tempList = new Dictionary<int,string>();
                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i] != Color.Transparent)
                    {
                        int total = (int)data[i].R + (int)data[i].G + (int)data[i].B;
                        string c = string.Join(" ", new string[] { data[i].R.ToString(), data[i].G.ToString(), data[i].B.ToString() });
                        if (!tempList.ContainsKey(total))
                        {
                            tempList.Add(total,c);
                        }
                        else if(tempList[total] != c)
                        {
                            while (tempList.ContainsKey(total))
                            {
                                total++;
                                if (!tempList.ContainsKey(total))
                                {
                                    tempList.Add(total, c);
                                }
                                else if (tempList[total] == c)
                                    break;
                            }
                        }
                    }

                }
                var keys = tempList.Keys.ToList();
                keys.Sort();
                keys.Reverse();

                var outList = new List<string>();
                foreach(var key in keys)
                {
                    outList.Add(tempList[key]);
                }
                Alert(string.Join("^", outList));
            }
        }

19 View Source File : AntCertificationUtil.cs
License : Apache License 2.0
Project Creator : alipay

public static String GetCertSN(X509Certificate cert)
        {
            string issuerDN = cert.IssuerDN.ToString();
            //提取出的证书的issuerDN本身是以CN开头的,则无需逆序,直接返回
            if (issuerDN.StartsWith("CN", StringComparison.Ordinal))
            {
                return CalculateMd5(issuerDN + cert.SerialNumber);
            }
            List<String> attributes = issuerDN.Split(',').ToList();
            attributes.Reverse();
            return CalculateMd5(String.Join(",", attributes.ToArray()) + cert.SerialNumber);
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public static List<int> OrderPaiLord(List<int> paiarr)
        {
            List<int> _tempList = new List<int>(paiarr);
            for (int i = 0; i < _tempList.Count; i++)
            {
                if (_tempList[i] > 100) _tempList[i] %= 100;
            }
            int[] temparr = _tempList.ToArray<int>();
            Array.Sort<int>(temparr);
            List<int> _ASCList = temparr.ToList<int>();
            _ASCList.Reverse();//默认是升序反转一下就降序了
            return _ASCList;
        }

19 View Source File : ModSorter.cs
License : MIT License
Project Creator : amazingalek

public IList<IModData> SortMods(IList<IModData> mods)
		{
			var modDict = new Dictionary<string, IModData>();
			var set = new HashSet<Edge>();
			var modList = mods.Select(mod => mod.Manifest.UniqueName).ToList();

			foreach (var mod in mods)
			{
				if (modDict.ContainsKey(mod.Manifest.UniqueName))
				{
					_console.WriteLine($"Error - {mod.Manifest.UniqueName} already exists in the mod sorter - ignoring duplicate.", MessageType.Error);
					continue;
				}
				modDict.Add(mod.Manifest.UniqueName, mod);

				foreach (var dependency in mod.Manifest.Dependencies)
				{
					if (mod.Manifest.PriorityLoad && !modList.Contains(dependency))
					{
						_console.WriteLine($"Error - {mod.Manifest.UniqueName} (priority load) depends on a normal mod! Removing from load...", MessageType.Error);
						modDict.Remove(mod.Manifest.UniqueName);
						modList.Remove(mod.Manifest.UniqueName);
					}
					else
					{
						set.Add(new Edge(mod.Manifest.UniqueName, dependency));
					}
				}
			}

			var sortedList = TopologicalSort(
				new HashSet<string>(modList),
				new HashSet<Edge>(set)
			);

			if (sortedList == null)
			{
				// Sorting has failed, return the original mod list
				_console.WriteLine("Error - Cyclic dependency found. Returning original load order...", MessageType.Error);
				return mods;
			}

			sortedList.Reverse();
			return sortedList.Where(modDict.ContainsKey).Select(mod => modDict[mod]).ToList();
		}

19 View Source File : Ldftn.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a

public void Load(DarksVMContext ctx, out ExecutionState state)
        {
            var sp = ctx.Registers[DarksVMConstants.REG_SP].U4;
            var methodSlot = ctx.Stack[sp--];
            var objectSlot = ctx.Stack[sp];

            if(objectSlot.O != null)
            {
                var method = (MethodInfo) ctx.Instance.Data.LookupReference(methodSlot.U4);
                var type = objectSlot.O.GetType();

                var baseTypes = new List<Type>();
                do
                {
                    baseTypes.Add(type);
                    type = type.BaseType;
                } while(type != null && type != method.DeclaringType);
                baseTypes.Reverse();

                var found = method;
                const BindingFlags fl = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                foreach(var baseType in baseTypes)
                foreach(var m in baseType.GetMethods(fl))
                    if(m.GetBaseDefinition() == found)
                    {
                        found = m;
                        break;
                    }

                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) found.MethodHandle.GetFunctionPointer()};
            }
            if(objectSlot.U8 != 0)
            {
                // intra linking
                var entryKey = ctx.Stack[--sp].U4;
                var codeAdr = methodSlot.U8;
                var sig = ctx.Instance.Data.LookupExport(objectSlot.U4).Signature;
                var ptr = DarksVMTrampoline.CreateTrampoline(ctx.Instance.Data.Module, codeAdr, entryKey, sig, objectSlot.U4);
                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) ptr};
            }
            else
            {
                var method = (MethodBase) ctx.Instance.Data.LookupReference(methodSlot.U4);
                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) method.MethodHandle.GetFunctionPointer()};
            }

            ctx.Stack.SetTopPosition(sp);
            ctx.Registers[DarksVMConstants.REG_SP].U4 = sp;
            state = ExecutionState.Next;
        }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

public static List<Formula> CreateFormulaEvalInvocationFormulaForLblIndexes(ushort rw, ushort col, string var1Lblname, int var1Lblindex)
        {
            // =ARGUMENT("var1",2)
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.ARGUMENT, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(2));
            ptgList.Add(new PtgStr(var1Lblname, true, AbstractPtg.PtgDataType.VALUE));
            ptgList.Reverse();
            Stack<AbstractPtg> ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formFuncArg1Formula = new Formula(new Cell(rw, col), FormulaValue.GetEmptyStringFormulaValue(), true,
                new CellParsedFormula(ptgStack));
            
            // =FORMULA(var1,nextRow)
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(CetabValues.FORMULA, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgRef(rw+2,col,false,false));
            ptgList.Add(new PtgName(var1Lblindex));
            ptgList.Reverse();     
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formulaInvocationFunction = new Formula(new Cell(rw+1, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));

            // Formula Written by Previous Line
            
            // =FORMULA("",prevRow)
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(CetabValues.FORMULA, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgRef(rw+2,col,false,false));
            ptgList.Add(new PtgStr(""));
            ptgList.Reverse();     
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula formulaRemovalFunction = new Formula(new Cell(rw+3, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));

            
            // =RETURN()
            ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.RETURN, 0, AbstractPtg.PtgDataType.VALUE));
            ptgStack = new Stack<AbstractPtg>(ptgList);
            Formula returnFormula = new Formula(new Cell(rw+4, col), FormulaValue.GetEmptyStringFormulaValue(), true, new CellParsedFormula(ptgStack));

            return new List<Formula>() {formFuncArg1Formula, formulaInvocationFunction, formulaRemovalFunction, returnFormula};
        }

19 View Source File : ServiceBuilder.cs
License : MIT License
Project Creator : 1100100

public async Task StartAsync(CancellationToken cancellationToken)
        {
            UraganoSettings.ClientGlobalInterceptors.Reverse();
            UraganoSettings.ServerGlobalInterceptors.Reverse();

            var enableClient = ServiceProvider.GetService<ILoadBalancing>() != null;
            var enableServer = UraganoSettings.ServerSettings != null;

            var types = ReflectHelper.GetDependencyTypes();
            var services = types.Where(t => t.IsInterface && typeof(IService).IsreplacedignableFrom(t)).Select(@interface => new
            {
                Interface = @interface,
                Implementation = types.FirstOrDefault(p => p.IsClreplaced && p.IsPublic && !p.IsAbstract && !p.Name.EndsWith("_____UraganoClientProxy") && @interface.IsreplacedignableFrom(p))
            }).ToList();

            foreach (var service in services)
            {
                var imp = service.Implementation;

                var routeAttr = service.Interface.GetCustomAttribute<ServiceRouteAttribute>();
                var routePrefix = routeAttr == null ? $"{service.Interface.Namespace}/{service.Interface.Name}" : routeAttr.Route;


                var interfaceMethods = service.Interface.GetMethods();

                List<MethodInfo> implementationMethods = null;
                if (enableServer && imp != null)
                    implementationMethods = imp.GetMethods().ToList();

                var disableClientIntercept = service.Interface.GetCustomAttribute<NonInterceptAttribute>(true) != null;
                var clientClreplacedInterceptors = new List<Type>();
                if (!disableClientIntercept)
                    clientClreplacedInterceptors = service.Interface.GetCustomAttributes(true).Where(p => p is IInterceptor)
                    .Select(p => p.GetType()).ToList();

                var serverClreplacedInterceptors = new List<Type>();
                var disableServerIntercept = false;
                if (enableServer && imp != null)
                {
                    disableServerIntercept = imp.GetCustomAttribute<NonInterceptAttribute>(true) != null;
                    if (!disableServerIntercept)
                        serverClreplacedInterceptors = imp.GetCustomAttributes(true).Where(p => p is IInterceptor)
                            .Select(p => p.GetType()).ToList();
                }

                foreach (var interfaceMethod in interfaceMethods)
                {
                    MethodInfo serverMethod = null;
                    var idAttr = interfaceMethod.GetCustomAttribute<ServiceRouteAttribute>();
                    var route = idAttr == null ? $"{routePrefix}/{interfaceMethod.Name}" : $"{routePrefix}/{idAttr.Route}";

                    var clientInterceptors = new List<Type>();
                    if (enableClient && !disableClientIntercept && interfaceMethod.GetCustomAttribute<NonInterceptAttribute>(true) == null)
                    {
                        clientInterceptors.AddRange(UraganoSettings.ClientGlobalInterceptors);
                        clientInterceptors.AddRange(clientClreplacedInterceptors);
                        clientInterceptors.AddRange(interfaceMethod.GetCustomAttributes(true)
                            .Where(p => p is IInterceptor).Select(p => p.GetType()).ToList());
                        clientInterceptors.Reverse();
                    }


                    var serverInterceptors = new List<Type>();
                    if (enableServer && imp != null)
                    {
                        serverMethod = implementationMethods.First(p => IsImplementationMethod(interfaceMethod, p));
                        if (!disableServerIntercept && serverMethod?.GetCustomAttribute<NonInterceptAttribute>(true) == null)
                        {
                            serverInterceptors.AddRange(UraganoSettings.ServerGlobalInterceptors);
                            serverInterceptors.AddRange(serverClreplacedInterceptors.ToList());
                            if (serverMethod != null)
                                serverInterceptors.AddRange(serverMethod.GetCustomAttributes(true)
                                    .Where(p => p is IInterceptor).Select(p => p.GetType()).ToList());
                            serverInterceptors.Reverse();
                        }
                    }

                    ServiceFactory.Create(route, serverMethod, interfaceMethod, serverInterceptors, clientInterceptors);
                }
            }

            await Task.CompletedTask;
        }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public static List<int> OrderPaiLordWithColor(List<int> paiarr)
        {
            List<int> _tempList = new List<int>(paiarr);
            for (int i = 0; i < _tempList.Count; i++)
            {
                if (_tempList[i] > 100) _tempList[i] %= 100;
            }
            int[] temparr = _tempList.ToArray<int>();
            Array.Sort<int>(temparr);
            List<int> _ASCList = temparr.ToList<int>();
            _ASCList.Reverse();//默认是升序反转一下就降序了

            //带上花色,有点小复杂 
            Dictionary<int, int> _dicPoker2Count = GetPoker_Count(_ASCList);
            Dictionary<int, int> _dicPoker2CountUsed = new Dictionary<int, int>();
            for (int j = 0; j < _ASCList.Count; j++)
            {
                if (!_dicPoker2CountUsed.ContainsKey(_ASCList[j])) _dicPoker2CountUsed.Add(_ASCList[j], 1);

                for (int c = _dicPoker2CountUsed[_ASCList[j]]; c <= 4; c++)
                {
                    _dicPoker2CountUsed[_ASCList[j]]++;
                    if (paiarr.Contains(_ASCList[j] + 100 * c))
                    {
                        _ASCList[j] = _ASCList[j] + 100 * c;
                        break;
                    }
                }
            }
            return _ASCList;
        }

19 View Source File : AINavMeshGenerator.cs
License : MIT License
Project Creator : 7ark

private Node[] GetAStar(Vector2 currentPosition, Vector2 destination, GameObject obj = null)
    {
        Node start = generator.FindClosestNode(currentPosition, false, obj);
        Node end = generator.FindClosestNode(destination, true, obj);
        if (start == null || end == null)
        {
            return null;
        }

        openSet.Clear();
        closedSet.Clear();
        openSet.Add(start);
        while (openSet.Count > 0)
        {
            Node current = openSet[0];

            //Evaluate costs
            for (int i = 1; i < openSet.Count; i++)
            {
                if (openSet[i].fCost < current.fCost || openSet[i].fCost == current.fCost)
                {
                    if (openSet[i].hCost < current.hCost)
                    {
                        current = openSet[i];
                    }
                }
            }

            openSet.Remove(current);
            closedSet.Add(current);

            if (current.Equals(end))
            {
                break;
            }

            //Go through neighbors
            foreach (Node neighbor in current.connections.Where(x => x != null))
            {
                //The replacedociated object check is so the enemy ignores pathing through it's own bad sector
                if ((!neighbor.valid && neighbor.replacedociatedObject != obj) || closedSet.Contains(neighbor))
                {
                    continue;
                }

                float newCost = current.gCost + Heuristic(current, neighbor);
                if (newCost < neighbor.gCost || !openSet.Contains(neighbor))
                {
                    neighbor.gCost = newCost;
                    neighbor.hCost = Heuristic(neighbor, end);
                    neighbor.parent = current;

                    if (!openSet.Contains(neighbor))
                    {
                        openSet.Add(neighbor);
                    }
                }
            }
        }

        if(end.parent == null)
        {
            return null;
        }

        //Calculate path
        path.Clear();
        Node currentCheck = end;
        while (!path.Contains(currentCheck) && currentCheck != null)
        {
            path.Add(currentCheck);
            currentCheck = currentCheck.parent;
        }
        path.Reverse();
        if(path[0] != start)
        {
            return null;
        }
        return path.ToArray();
    }

19 View Source File : FormulaHelper.cs
License : Apache License 2.0
Project Creator : aaaddress1

private static Stack<AbstractPtg> GetCharSubroutineWithArgsForInt(ushort charInt, int functionLabelOffset)
        {
            List<AbstractPtg> ptgList = new List<AbstractPtg>();
            ptgList.Add(new PtgFuncVar(FtabValues.USERDEFINEDFUNCTION, 2, AbstractPtg.PtgDataType.VALUE));
            ptgList.Add(new PtgInt(charInt));
            ptgList.Add(new PtgName(functionLabelOffset));
            ptgList.Reverse();
            return new Stack<AbstractPtg>(ptgList);
        }

19 View Source File : XmlNodeConverter.cs
License : MIT License
Project Creator : akaskela

private void PushParentNamespaces(IXmlNode node, XmlNamespaceManager manager)
        {
            List<IXmlNode> parentElements = null;

            IXmlNode parent = node;
            while ((parent = parent.ParentNode) != null)
            {
                if (parent.NodeType == XmlNodeType.Element)
                {
                    if (parentElements == null)
                    {
                        parentElements = new List<IXmlNode>();
                    }

                    parentElements.Add(parent);
                }
            }

            if (parentElements != null)
            {
                parentElements.Reverse();

                foreach (IXmlNode parentElement in parentElements)
                {
                    manager.PushScope();
                    foreach (IXmlNode attribute in parentElement.Attributes)
                    {
                        if (attribute.NamespaceUri == "http://www.w3.org/2000/xmlns/" && attribute.LocalName != "xmlns")
                        {
                            manager.AddNamespace(attribute.LocalName, attribute.Value);
                        }
                    }
                }
            }
        }

See More Examples