当前位置: 首页>>代码示例>>C#>>正文


C# List.ToList方法代码示例

本文整理汇总了C#中List.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToList方法的具体用法?C# List.ToList怎么用?C# List.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateListOfTimeSpan

 public static List<List<TimeSpan>> GenerateListOfTimeSpan(List<List<TimeSpan>> MyEncasingList)
 {
     //Trying To Spread out arrray
     List<List<TimeSpan>> ListOfList = new List<List<TimeSpan>>();
     List<List<TimeSpan>> ListOfListCopy = ListOfList.ToList();
     int i = 0;
     for (i = 0; i < MyEncasingList.Count; i++)
     {
         ListOfListCopy = ListOfList.ToList();
         List<List<TimeSpan>> UpdatedListOfList = new List<List<TimeSpan>>();
         foreach (TimeSpan MyTimeSpan in MyEncasingList[i])//ListOfList.CopyTo(MyOtherArray);
         {
             //Console.WriteLine("other {0}\n", MyNumber);
             if (ListOfListCopy.Count == 0)
             {
                 UpdatedListOfList.Add(CreateNewListAndAppend(MyTimeSpan, new List<TimeSpan>()));
             }
             foreach (List<TimeSpan> MyUpdatedSingleList in ListOfListCopy)
             {
                 UpdatedListOfList.Add(CreateNewListAndAppend(MyTimeSpan, MyUpdatedSingleList));
             }
         }
         ListOfList = UpdatedListOfList;
     }
     return ListOfList;
 }
开发者ID:jerbio,项目名称:My24HourTimerWPF,代码行数:26,代码来源:SpreadOutList.cs

示例2: GenerateListOfSubCalendarEvent

        public static List<List<SubCalendarEvent>> GenerateListOfSubCalendarEvent(List<List<SubCalendarEvent>> MyEncasingList)
        {
            //Trying To Spread out arrray
            List<List<SubCalendarEvent>> ListOfList = new List<List<SubCalendarEvent>>();
            List<List<SubCalendarEvent>> ListOfListCopy = ListOfList.ToList();
            int i = 0;
            for (i = 0; i < MyEncasingList.Count; i++)
            {
                ListOfListCopy = ListOfList.ToList();
                List<List<SubCalendarEvent>> UpdatedListOfList = new List<List<SubCalendarEvent>>();
                foreach (SubCalendarEvent MySubCalendarEvent in MyEncasingList[i])//ListOfList.CopyTo(MyOtherArray);
                {
                    //Console.WriteLine("other {0}\n", MyNumber);
                    if (ListOfListCopy.Count == 0)
                    {
                        UpdatedListOfList.Add(CreateNewListAndAppend(MySubCalendarEvent, new List<SubCalendarEvent>()));
                    }
                    foreach (List<SubCalendarEvent> MyUpdatedSingleList in ListOfListCopy)
                    {
                        if (!isSubCalendarEventAlreadyInList(MySubCalendarEvent, MyUpdatedSingleList))
                        {
                            UpdatedListOfList.Add(CreateNewListAndAppend(MySubCalendarEvent, MyUpdatedSingleList));
                        }

                    }
                }
                ListOfList = UpdatedListOfList;
            }
            return ListOfList;
        }
开发者ID:jerbio,项目名称:My24HourTimerWPF,代码行数:30,代码来源:SpreadOutList.cs

示例3: Test1

        static void Test1()
        {
            FleckLog.Level = LogLevel.Debug;
            var allSockets = new List<IWebSocketConnection>();
            var server = new WebSocketServer("ws://localhost:8181");
            server.Start(socket =>
                {
                    socket.OnOpen = () =>
                        {
                            Console.WriteLine("Open!");
                            allSockets.Add(socket);
                        };
                    socket.OnClose = () =>
                        {
                            Console.WriteLine("Close!");
                            allSockets.Remove(socket);
                        };
                    socket.OnMessage = message =>
                        {
                            Console.WriteLine(message);
                            allSockets.ToList().ForEach(s => s.Send("Echo: " + message));
                        };
                });

            var input = Console.ReadLine();
            while (input != "exit")
            {
                foreach (var socket in allSockets.ToList())
                {
                    socket.Send(input);
                }
                input = Console.ReadLine();
            }
        }
开发者ID:vbguyny,项目名称:Fleck,代码行数:34,代码来源:Server.cs

示例4: Start

        public void Start()
        {
            List<IWebSocketConnection> sockets = new List<IWebSocketConnection>();
            Fleck.WebSocketServer server = new Fleck.WebSocketServer("ws://127.0.0.1:8181");

            server.Start(socket =>
                {
                    socket.OnOpen = () =>
                        {
                            Console.WriteLine("Connection open.");
                            sockets.Add(socket);
                        };
                    socket.OnClose = () =>
                        {
                            Console.WriteLine("Connection closed.");
                            sockets.Remove(socket);
                        };
                    socket.OnMessage = message =>
                        {
                            Console.WriteLine("Client says: " + message);
                            sockets.ToList().ForEach(s => s.Send(" client says:" + message));
                        };

                });

            string input = Console.ReadLine();
            while (input != "exit")
            {
                sockets.ToList().ForEach(s => s.Send(input));
                input = Console.ReadLine();
            }
        }
开发者ID:bvelji,项目名称:70-480_Practice,代码行数:32,代码来源:HelloServer.cs

示例5: ParseFlights

        public IList<Flight> ParseFlights(HtmlNode documentNode)
        {
            var element = documentNode.SelectNodes("//table[@class='resultTable dealsResults']/tbody//tr[position()>1]");

            IEnumerable<Flight> flights = new List<Flight>();

            if (element == null)
                return flights.ToList();

            flights = from row in element
                      where row.HasChildNodes
                      let departureAirport = row.ChildNodes[1].InnerText
                      let destination = row.ChildNodes[3].InnerText
                      let departureDate = row.ChildNodes[5].SelectSingleNode("ul/li").InnerText
                      let returnDate = row.ChildNodes[5].SelectSingleNode("ul/li[position()>1]").InnerText
                      let departFlightTime = row.ChildNodes[7].SelectSingleNode("ul/li/ul/li").InnerText
                      let returnFlightTime = row.ChildNodes[7].SelectSingleNode("ul/li[position()>1]/ul/li").InnerText
                      let noOfNights = row.ChildNodes[9].InnerText
                      let departureAirportCode = row.ChildNodes[13].SelectSingleNode("fieldset/input[@id='depAP']").GetAttributeValue("value", "N/a")
                      let arrivalAirportCode = row.ChildNodes[13].SelectSingleNode("fieldset/input[@id='retAP']").GetAttributeValue("value", "N/a")
                      let seats = row.SelectSingleNode("td[@class='seatsLeft']").ChildNodes.Count > 2 ? row.SelectSingleNode("td[@class='seatsLeft']/div").InnerText : "0"
                      select new Flight
                          {
                              DepartureAirport = new Airport { Code = departureAirportCode, Name = departureAirport },
                              ArrivalAirport = new Airport { Code = arrivalAirportCode, Name = destination },
                              ArrivalDate = (departureDate + " " + departFlightTime + ":00").ToFormattedDateString(),
                              SeatsLeft = seats.ToInt32(),
                              DepartureDate =(returnDate + " " + returnFlightTime + ":00").ToFormattedDateString(),
                              NoOfNights = noOfNights.ToInt32()
                          };

            return flights.ToList();
        }
开发者ID:jonhunter1977,项目名称:HackDayScreenScraper,代码行数:33,代码来源:ThomsonHtmlParser.cs

示例6: CollectionQuerySimplification

        public CollectionQuerySimplification(List<object> coll)
        {
            var x = coll.Select(element => element as object).Any(element => element != null);  // Noncompliant use OfType
            x = coll.Select((element) => ((element as object))).Any(element => (element != null) && CheckCondition(element) && true);  // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object); // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object[]);
            y = coll.Where(element => element is object).Select(element => (object)element); // Noncompliant use OfType
            x = coll.Where(element => element == null).Any();  // Noncompliant use Any([expression])
            var z = coll.Where(element => element == null).Count();  // Noncompliant use Count([expression])
            z = Enumerable.Count(coll.Where(element => element == null));  // Noncompliant
            z = Enumerable.Count(Enumerable.Where(coll, element => element == null));  // Noncompliant
            y = coll.Select(element => element as object);
            y = coll.ToList().Select(element => element as object); // Noncompliant
            y = coll
                .ToList()  // Noncompliant
                .ToArray() // Noncompliant
                .Select(element => element as object);

            var z = coll
                .Select(element => element as object)
                .ToList();

            var c = coll.Count(); //Noncompliant
            c = coll.OfType<object>().Count();

            x = Enumerable.Select(coll, element => element as object).Any(element => element != null); //Noncompliant
            x = Enumerable.Any(Enumerable.Select(coll, element => element as object), element => element != null); //Noncompliant
        }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:28,代码来源:CollectionQuerySimplification.cs

示例7: gener

 private static void gener(int num, int len)
 {
     StringBuilder k1 = new StringBuilder();
     for (int a = 0; a < len; a++)
     {
         k1.Append(num.ToString());
     }
     List<int> lst1 = new List<int>();
     List<List<int>> depo = new List<List<int>>();
     for (int a = 0; a < num; a++)
     {
         lst1.Add(a);
     }
     long k = long.Parse(k1.ToString());
     for (int a = 0; a < k; a++)
     {
         List<int> lst = new List<int>();
         for (int z = 0; z < a.ToString().Length; z++)
         {
             lst.Add(int.Parse(a.ToString().ToCharArray()[z].ToString()));
         }
         lst.Sort();
         bool ok = true;
         if (lst.ToList().Distinct().Count() == lst.ToList().Count())
         {
             for (int b = 0; b < lst.Count; b++)
             {
                 if (!lst1.Contains(lst[b]))
                 {
                     ok = false;
                 }
             }
             if (ok)
             {
                 bool ko = true;
                 for (int c = 0; c < depo.Count; c++)
                 {
                     if (lst == (depo[c]))
                     {
                         ko = false;
                     }
                 }
                 if (ko)
                 {
                     depo.Add(lst);
                 }
             }
         }
     }
     List<List<int>> depo1 = new List<List<int>>(depo.Distinct().ToList());
     for (int a = 0; a < depo1.Count; a++)
     {
         for (int b = 0; b < depo1[a].Count; b++)
         {
             Console.Write("{0} ", depo1[a][b]);
         }
         Console.WriteLine();
     }
 }
开发者ID:Dar9586,项目名称:ita,代码行数:59,代码来源:Generatore.cs

示例8: WhenAddingParams_ThenAddsToList

	public void WhenAddingParams_ThenAddsToList()
	{
		ICollection<int> ints = new List<int>(new[] { 1, 2, 3 });

		ints.AddRange(4, 5);

		Assert.Equal(4, ints.ToList()[3]);
		Assert.Equal(5, ints.ToList()[4]);
	}
开发者ID:netfx,项目名称:extensions,代码行数:9,代码来源:CollectionAddRangeSpec.cs

示例9: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json; charset=utf-8";

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

            NFMT.User.BLL.CorporationBLL bll = new NFMT.User.BLL.CorporationBLL();
            result = bll.LoadAuthSelfCorp(user);

            List<NFMT.User.Model.Corporation> corps = new List<NFMT.User.Model.Corporation>();

            if (result.ResultStatus == 0)
            {
                corps = result.ReturnValue as List<NFMT.User.Model.Corporation>;
            }

            //合约过滤
            int contractId = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["ContractId"]))
                int.TryParse(context.Request.QueryString["ContractId"], out contractId);

            //合约抬头过滤
            IEnumerable<NFMT.User.Model.Corporation> ecs = new List<NFMT.User.Model.Corporation>();
            if (contractId > 0)
            {
                NFMT.Contract.BLL.ContractCorporationDetailBLL corpBLL = new NFMT.Contract.BLL.ContractCorporationDetailBLL();
                result = corpBLL.LoadCorpListByContractId(user, contractId,true);
                if (result.ResultStatus != 0)
                    context.Response.End();

                List<NFMT.Contract.Model.ContractCorporationDetail> contractCorps = result.ReturnValue as List<NFMT.Contract.Model.ContractCorporationDetail>;
                var corpIds = contractCorps.Select(c => c.CorpId).ToList();
                ecs = corps.Where(c => corpIds.Contains(c.CorpId));
                corps = ecs.ToList();
            }

            int subId = 0;
            if (!string.IsNullOrEmpty(context.Request.QueryString["SubId"]))
                int.TryParse(context.Request.QueryString["SubId"], out subId);
            if (subId > 0)
            {
                NFMT.Contract.BLL.SubCorporationDetailBLL subCorpBLL = new NFMT.Contract.BLL.SubCorporationDetailBLL();
                result = subCorpBLL.Load(user, subId, true);
                if (result.ResultStatus != 0)
                    context.Response.End();

                List<NFMT.Contract.Model.SubCorporationDetail> subCorps = result.ReturnValue as List<NFMT.Contract.Model.SubCorporationDetail>;
                var corpIds = subCorps.Select(c => c.CorpId).ToList();
                ecs = corps.Where(c => corpIds.Contains(c.CorpId));
                corps = ecs.ToList();
            }

            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(corps);
            context.Response.Write(jsonStr);
        }
开发者ID:weiliji,项目名称:NFMT,代码行数:56,代码来源:AuthSelfCorpHandler.ashx.cs

示例10: Main

        static void Main(string[] args)
        {
            FleckLog.Level = LogLevel.Info;
            var allsockets = new List<IWebSocketConnection>();
            var server = new WebSocketServer("ws://localhost:8181");

            server.Start(socket =>
            {
                socket.OnOpen = () =>
                    {   //See socket.ConnectionInfo.* for additional informations
                        Console.WriteLine(String.Empty);
                        Console.WriteLine("[NEW CLIENT CONNECTION]======================");
                        Console.WriteLine("GUID: " + socket.ConnectionInfo.Id);
                        Console.WriteLine("IP: " + socket.ConnectionInfo.ClientIpAddress);
                        Console.WriteLine("Port: " + socket.ConnectionInfo.ClientPort);
                        Console.WriteLine("=============================================");
                        Console.WriteLine(String.Empty);
                        allsockets.Add(socket);

                    };

                socket.OnClose = () =>
                {
                        Console.WriteLine(String.Empty);
                        Console.WriteLine("[DISCONNECTED CLIENT]=======================");
                        Console.WriteLine("GUID: " + socket.ConnectionInfo.Id);
                        Console.WriteLine("IP: " + socket.ConnectionInfo.ClientIpAddress);
                        Console.WriteLine("Port: " + socket.ConnectionInfo.ClientPort);
                        Console.WriteLine("=============================================");
                        Console.WriteLine(String.Empty);
                        allsockets.Remove(socket);
                    };

                socket.OnMessage = (message) =>
                {
                    //TODO: Json.Net Deserialize
                    Console.WriteLine("[JSON MESSAGE] " + message);
                    allsockets.ToList().ForEach(s => s.Send(message));
                };
            });

            var input = Console.ReadLine();
            while (input != "exit")
            {
                foreach (var socket in allsockets.ToList())
                {
                    socket.Send(input);
                }

                input = Console.ReadLine();
            }
        }
开发者ID:vegax87,项目名称:sharpchat,代码行数:52,代码来源:Program.cs

示例11: LoadFromCsv

        public int LoadFromCsv(string fileName, int tickerCode)
        {
            var storeThread = new DBStoreThread(true);
            var candles = new List<CandleData>();
            var totalStored = 0;

            using (var sr = new StreamReader(fileName, Encoding.GetEncoding(1252)))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();
                    if (string.IsNullOrEmpty(line)) continue;
                    var parts = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
                    // date - time - o-h-l-c
                    if (parts.Length < 6) continue;
                    DateTime time;
                    if (!DateTime.TryParseExact(parts[0] + " " + parts[1],
                                                "yyyy.MM.dd HH:mm", CultureProvider.Common, DateTimeStyles.AssumeLocal,
                                                out time))
                        continue;
                    var open = parts[2].ToFloatUniformSafe() ?? 0;
                    var high = parts[3].ToFloatUniformSafe() ?? 0;
                    var low = parts[4].ToFloatUniformSafe() ?? 0;
                    var close = parts[5].ToFloatUniformSafe() ?? 0;

                    if (open == 0 || high == 0 || low == 0 || close == 0) continue;
                    candles.Add(new CandleData(open, high, low, close, time, time.AddMinutes(1)));
                    if (candles.Count > BufferSize)
                    {
                        storeThread.PushQuotes(new Dictionary<int, List<CandleData>>
                            { { tickerCode, candles.ToList() } });
                        totalStored += candles.Count;
                        candles.Clear();
                    }
                }
                totalStored += candles.Count;
                if (candles.Count > 0)
                    storeThread.PushQuotes(new Dictionary<int, List<CandleData>>
                        { {tickerCode, candles.ToList()} });
            }

            while (storeThread.CandlesLeftInQueue > 0)
            {
                Thread.Sleep(200);
            }
            storeThread.Stop();

            return totalStored;
        }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:49,代码来源:CsvLoader.cs

示例12: Initialise

 public void Initialise(IEnumerable<IRiakNode> nodes)
 {
     _nodes = nodes.ToList();
     var list = _nodes.ToList();
     _generator = () => list;
     _roundRobin = new ConcurrentEnumerable<IRiakNode>(RoundRobin()).GetEnumerator();
 }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:7,代码来源:RoundRobinStrategy.cs

示例13: Main

        static void Main(string[] args)
        {
            Console.Write("Write a sequence of numbers, separated by spaces: ");
            string input = Console.ReadLine();
            List<int> listOfNums = new List<int>();

            try
            {
                listOfNums = (new List<string>(Regex.Split(input, @"\s+"))).Select(s => int.Parse(s)).ToList();
            }
            catch (FormatException)
            {
                Console.WriteLine("The input must contain at least 1 number.");
                return;
            }

            List<int> outputListOfNums = listOfNums.ToList();

            foreach (int num in listOfNums)
            {
                int count = listOfNums.Where(x => x.Equals(num)).Count();

                if (count % 2 != 0)
                {
                    outputListOfNums.RemoveAll(x => x == num);
                }
            }

            Console.WriteLine(string.Join(" ", outputListOfNums));
        }
开发者ID:nadiahristova,项目名称:Data-Structures-Algorithms-and-Complexity,代码行数:30,代码来源:RemoveOddOccurences.cs

示例14: navbarItems

        public IEnumerable<Navbar> navbarItems()
        {
            var menu = new List<Navbar>();
            //menu.Add(new Navbar { Id = 1, nameOption = "Home Page", controller = "Home", action = "Index", imageClass = "fa fa-institution", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 2, nameOption = "Analytic Tools", imageClass = "glyphicon glyphicon-leaf", status = true, isParent = true, parentId = 0 });
            //menu.Add(new Navbar { Id = 3, nameOption = "Biological Index", controller = "Home", action = "FlotCharts", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 4, nameOption = "Oceanographic Parameters", controller = "Home", action = "MorrisCharts", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 4, nameOption = "Upwelling Index", controller = "Home", action = "UpwellingIndex", status = true, isParent = false, parentId = 2 });
            //menu.Add(new Navbar { Id = 5, nameOption = "Elevation Profile Tool", controller = "Home", action = "Tables", imageClass = "fa fa-line-chart fa-1", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 6, nameOption = "Comparative Tool", controller = "Home", action = "Forms", imageClass = "glyphicon glyphicon-resize-horizontal", status = true, isParent = false, parentId = 0 });
            //menu.Add(new Navbar { Id = 7, nameOption = "UI Elements", imageClass = "fa fa-wrench fa-fw", status = true, isParent = true, parentId = 0 });
            //menu.Add(new Navbar { Id = 8, nameOption = "Panels and Wells", controller = "Home", action = "Panels", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 9, nameOption = "Buttons", controller = "Home", action = "Buttons", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 10, nameOption = "Notifications", controller = "Home", action = "Notifications", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 11, nameOption = "Typography", controller = "Home", action = "Typography", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 12, nameOption = "Icons", controller = "Home", action = "Icons", status = true, isParent = false, parentId = 7 });
            //menu.Add(new Navbar { Id = 13, nameOption = "Grid", controller = "Home", action = "Grid", status = true, isParent = false, parentId = 7 });

            menu.Add(new Navbar { Id = 1, nameOption = "Home Page", controller = "Home", action = "Index", imageClass = "fa fa-institution", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 2, nameOption = "Bathymetry  GIS mapping and transects", controller = "Home", action = "BathymetricTransects", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 3, nameOption = "CCLME Upwelling index", controller = "Home", action = "UpwellingIndex", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 4, nameOption = "Precipitation and river discharges", controller = "Home", action = "PrecipitationDischarges", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 5, nameOption = "Tide gauge graphs", controller = "Home", action = "TideGauge", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 6, nameOption = "Argo Profiles (3D)", controller = "Home", action = "Argo3D", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 7, nameOption = "GIS SST and Chl data and anomaly analysis", controller = "Home", action = "OceanographicAnomalies", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 8, nameOption = "Spatio-temporal data Viewer: SST, Chl, PSU", controller = "Home", action = "SpatioTemporalViewer", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 9, nameOption = "Oceanographic transects", controller = "Home", action = "OceanographicTransects", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 10, nameOption = "Biological data: abundance, distribution, species richness", controller = "Home", action = "BiologicalData", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 11, nameOption = "Using my own data", controller = "Home", action = "UsingOwnData", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 12, nameOption = "Interpolation tools for GIS", controller = "Home", action = "InterpolationTools", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 13, nameOption = "Time series analysis", controller = "Home", action = "TimeSeries", status = true, isParent = false, parentId = 0 });
            menu.Add(new Navbar { Id = 14, nameOption = "Reports", controller = "Home", action = "Tables", status = true, isParent = false, parentId = 0 });
            return menu.ToList();
        }
开发者ID:lmagudo,项目名称:IOC-UNESCO_WORKSHOP,代码行数:34,代码来源:Data.cs

示例15: Create

        internal static MethodInvoker Create(MethodInfo method, object target)
        {

            var args = new List<Type>(method.GetParameters().Select(p => p.ParameterType));
            Type delegateType;

            var returnMethodInvoker = new MethodInvoker
            {
                ParameterTypeList = args.ToList(),
                ParameterCount = args.Count,
                ReturnType = method.ReturnType,
                MethodName = method.Name
            };


            if (method.ReturnType == typeof(void))
            {
                delegateType = Expression.GetActionType(args.ToArray());
            }
            else
            {
                args.Add(method.ReturnType);
                delegateType = Expression.GetFuncType(args.ToArray());
            }

            returnMethodInvoker.MethodDelegate = method.CreateDelegate(delegateType, target);

            return returnMethodInvoker;

        }
开发者ID:Appverse,项目名称:appverse-mobile,代码行数:30,代码来源:MethodInvoker.cs


注:本文中的List.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。