當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.ToTaskResult方法代碼示例

本文整理匯總了C#中System.Data.DataTable.ToTaskResult方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.ToTaskResult方法的具體用法?C# DataTable.ToTaskResult怎麽用?C# DataTable.ToTaskResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.ToTaskResult方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DoEnterData

            //async 
            Task<DataTable> DoEnterData(

            [CallerFilePathAttribute] string CallerFilePath = null,
            [CallerLineNumberAttribute] int CallerLineNumber = 0,
            [CallerMemberNameAttribute] string CallerMemberName = null

            )
        {
            // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationWebService.cs

            var table = new DataTable { TableName = "DoEnterData " + new { reason }.ToString() };

            var column = new DataColumn();
            column.ColumnName = "Column 1";

            var column2 = new DataColumn();
            column2.ColumnName = "Column 2";

            table.Columns.Add(column);
            table.Columns.Add(column2);

            for (int i = 0; i < 32; i++)
            {
                var row = table.NewRow();

                row[column] = "#" + i;
                //row[column2] = new { reason, CallerMemberName, CallerLineNumber, CallerFilePath }.ToString();
                row[column2] = "John Doe, Canada | 600 USD";
                table.Rows.Add(row);
            }


            return table.ToTaskResult();
        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:35,代碼來源:ApplicationControl.cs

示例2: DoEnterData

            //async 
            Task<DataTable> DoEnterData(

            [CallerFilePathAttribute] string CallerFilePath = null,
            [CallerLineNumberAttribute] int CallerLineNumber = 0,
            [CallerMemberNameAttribute] string CallerMemberName = null

            )
        {
            // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationWebService.cs

            var table = new DataTable { TableName = "DoEnterData " + new { reason }.ToString() };

            var z = new Random().NextByte();

            var column = new DataColumn();
            column.ColumnName = "Column " + z;

            // An exception of type 'System.Data.DuplicateNameException' occurred in System.Data.dll but was not handled in user code
            //Additional information: A column named 'Column 2' already belongs to this DataTable.

            var column2 = new DataColumn();
            column2.ColumnName = "Column x2";

            table.Columns.Add(column);
            table.Columns.Add(column2);

            for (int i = 0; i < 32; i++)
            {
                var row = table.NewRow();

                row[column] = "#" + (i + z);
                //row[column2] = new { reason, CallerMemberName, CallerLineNumber, CallerFilePath }.ToString();
                row[column2] = "John Doe, Canada | 600 USD" + " | z " + z;
                table.Rows.Add(row);
            }


            return table.ToTaskResult();
        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:40,代碼來源:ApplicationWebService.cs

示例3: DoEnterData

            //async 
            Task<DataTable> DoEnterData(

            [CallerFilePathAttribute] string CallerFilePath = null,
            [CallerLineNumberAttribute] int CallerLineNumber = 0,
            [CallerMemberNameAttribute] string CallerMemberName = null

            )
        {
            // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationWebService.cs

            var table = new DataTable { TableName = "DoEnterData " + new { reason }.ToString() };

            var column = new DataColumn();
            column.ColumnName = "Column 1";

            // X:\jsc.svn\core\ScriptCoreLib.Ultra.Library\ScriptCoreLib.Ultra.Library\Library\StringConversions.StringArray.cs
            column.ReadOnly = true;

            var column2 = new DataColumn();
            column2.ColumnName = "Column 2";

            table.Columns.Add(column);
            table.Columns.Add(column2);

            for (int i = 0; i < 32; i++)
            {
                var row = table.NewRow();

                row[column] = "#" + i;
                //row[column2] = new { reason, CallerMemberName, CallerLineNumber, CallerFilePath }.ToString();
                row[column2] = "John Doe, Canada | 600 USD";
                table.Rows.Add(row);
            }



            table.ColumnChanged +=
           (s, a) =>
           {
               Console.WriteLine("Server ColumnChanged " + new { a.Row, a.Column, a.ProposedValue });
           };

            table.TableNewRow +=
                (s, a) =>
                {
                    Console.WriteLine("Server TableNewRow " + new { a.Row });

                };

            return table.ToTaskResult();
        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:52,代碼來源:ApplicationWebService.cs

示例4: GetInterfaces


//.........這裏部分代碼省略.........


            var g = from x in data

                    let get_key = new Func<bool>(
                        delegate
                        {
                            Console.WriteLine("get_key " + new { x.IsPrivate, x.IsLoopback, x.SupportsMulticast, x.IPv4 });



                            return x.IsPrivate && !x.IsLoopback && x.SupportsMulticast && x.IPv4;
                        }
                    )

                    let key = get_key()

                    // group by missing from scriptcorelib?

                    let gkey = new { x.u, x.n.Description, x.SupportsMulticast, key }
                    //let gvalue = new { key }

                    // Caused by: java.lang.RuntimeException: Implement IComparable for __AnonymousTypes__JVMCLRPrivateAddress__i__d_jvm.__f__AnonymousType_115__82__110_d_1 vs __AnonymousTypes__JVMCLRPrivateAddress__i__d_jvm.__f__AnonymousType_115__82__110_d_1

                    group gkey by key;



            // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationWebService.cs

            var table = new DataTable
            {

                TableName = "GetInterfaces"
            };




            var cAddress = new DataColumn
            {
                ColumnName = "Address",
                ReadOnly = true

            };

            table.Columns.Add(cAddress);

            var cComment = new DataColumn
            {
                ColumnName = "Comment",
                ReadOnly = true

            };

            table.Columns.Add(cComment);

            g.OrderByDescending(k => k.Key).WithEachIndex(
                (gx, gi) =>
                {

                    if (gi > 0)
                    {
                        var row = table.NewRow();

                        row[cAddress] = "";
                        row[cComment] = "";

                        table.Rows.Add(row);
                    }

                    gx.WithEach(
                          x =>
                          {
                              var row = table.NewRow();

                              row[cAddress] = x.u.Address.ToString();
                              row[cComment] = new
                              {

                                  x.key,
                                  x.SupportsMulticast,
                                  x.Description
                              }.ToString();

                              table.Rows.Add(row);
                          }
                      );

                }
            );






            return table.ToTaskResult();

        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:101,代碼來源:ApplicationWebService.cs

示例5: GetInterfaces


//.........這裏部分代碼省略.........
            // X:\jsc.svn\examples\javascript\forms\Test\TestDataTableToJavascript\TestDataTableToJavascript\ApplicationWebService.cs

            var table = new DataTable
            {

                TableName = "GetInterfaces"
            };


            var column = new DataColumn();
            column.ColumnName = "Name";
            column.ReadOnly = true;

            // An exception of type 'System.Data.DuplicateNameException' occurred in System.Data.dll but was not handled in user code
            //Additional information: A column named 'Column 2' already belongs to this DataTable.


            table.Columns.Add(column);


            var cSupportsMulticast = new DataColumn
            {
                ColumnName = "SupportsMulticast",
                ReadOnly = true

            };

            table.Columns.Add(cSupportsMulticast);

            var cGatewayAddresses = new DataColumn
            {
                ColumnName = "GatewayAddresses",
                ReadOnly = true

            };

            table.Columns.Add(cGatewayAddresses);



            NetworkInterface.GetAllNetworkInterfaces()

                .OrderByDescending(
                    k => k.GetIPProperties().UnicastAddresses.Count > 0
                )
            .WithEach(
                n =>
                {
                    var row = table.NewRow();

                    //row[column] = n.Id + " | " + n.Name;
                    row[column] = n.Name
                        + " | " + n.Description
                        //+ " | " + n.GetPhysicalAddress().GetAddressBytes().ToHexString()
                        ;

                    //Caused by: java.lang.NullPointerException
                    //        at ScriptCoreLib.Extensions.StringExtensions.ToHexString(StringExtensions.java:34)
                    //        at FormsNIC.ApplicationWebService___c__DisplayClass5._GetInterfaces_b__3(ApplicationWebService___c__DisplayClass5.java:45)
                    //        ... 54 more


                    //     //{ NetworkInterfaceName = net4, supportsMulticast = true, isUp = true, isVirtual = false, 
                    // DisplayName = Atheros AR9485WB-EG Wireless Network Adapter, 
                    // InetAddressesString = , /192.168.43.252, /fe80:0:0:0:55cc:63eb:5b4:60b4%11 }

                    row[cSupportsMulticast] = Convert.ToString(n.SupportsMulticast);

                    var IPProperties = n.GetIPProperties();
                    //var PhysicalAddress = n.GetPhysicalAddress();

                    var InetAddressesString = "";

                    // Address = {192.168.43.1}



                    IPProperties.UnicastAddresses.WithEach(
                        g =>
                        {
                            // IPv4 private addresses
                            // http://en.wikipedia.org/wiki/IP_address

                            InetAddressesString += "; " + g.Address;
                        }
                    );


                    row[cGatewayAddresses] = InetAddressesString;

                    Console.WriteLine(new { n.Description, InetAddressesString });
                    table.Rows.Add(row);

                }
            );


            return table.ToTaskResult();

        }
開發者ID:exaphaser,項目名稱:JSC-Cross-Compiler,代碼行數:101,代碼來源:ApplicationWebService.cs


注:本文中的System.Data.DataTable.ToTaskResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。