什么是API使用? [英] What is API Usage?

查看:127
本文介绍了什么是API使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我得到了什么API使用的是正确的定义。我有code,它是从C#应用程序用于BulkInsert到SQL片段。它说,片段展示了API的使用。我该如何翻译呢?

 私人无效WriteToDatabase()
{
    //获取连接字符串
    字符串CONNSTRING =;
    //连接到SQL
    使用(SqlConnection的连接=
            新的SqlConnection(CONNSTRING))
    {
        //确保使触发器
        //更多的触发下一篇文章中
        SqlBulkCopy的bulkCopy =
            新SqlBulkCopy的
            (
            连接,
            SqlBulkCopyOptions.TableLock |
            SqlBulkCopyOptions.FireTriggers |
            SqlBulkCopyOptions.UseInternalTransaction,
            空值
            );

        //设置目标表名
        bulkCopy.DestinationTableName = this.tableName;
        connection.Open();

        //写在dataTable的数据
        bulkCopy.WriteToServer(dataTable的);
        的Connection.close();
    }
    //复位
    this.dataTable.Clear();
    this.recordCount = 0;
}
 

解决方案

应用程序编程接口(API)是为了提供图书馆和/或操作系统服务一组例程,数据结构,对象类和/或协议,以支持应用程序的构建

在简单来说,一个API包括可以看到,用来自外部的交互的组件的位。该Microsoft.NET框架具有的东西,你不能使用,因为它们不是框架的API的一部分地段。这些类,方法,接口等被标记为内部或私有的,由MS供使用。

你看什么是使用这种code,从有人在图书馆看在外部的角度来看的只是一个例子。换句话说,你可以写这$ ​​C C $自己作为该API的消费者。它使用API​​没有详细说明所有可能的方式,但它给你一个提示。

I am not sure I am getting the correct definition for what API Usage is. I have a snippet of code that is used for a BulkInsert into SQL from c# application. It said the snippet shows the API usage. How do I translate that?

private void WriteToDatabase()
{
    // get your connection string
    string connString = "";
    // connect to SQL
    using (SqlConnection connection = 
            new SqlConnection(connString))
    {
        // make sure to enable triggers
        // more on triggers in next post
        SqlBulkCopy bulkCopy = 
            new SqlBulkCopy
            (
            connection, 
            SqlBulkCopyOptions.TableLock | 
            SqlBulkCopyOptions.FireTriggers | 
            SqlBulkCopyOptions.UseInternalTransaction,
            null
            );

        // set the destination table name
        bulkCopy.DestinationTableName = this.tableName;
        connection.Open();

        // write the data in the "dataTable"
        bulkCopy.WriteToServer(dataTable);
        connection.Close();
    }
    // reset
    this.dataTable.Clear();
    this.recordCount = 0;
}

解决方案

An application programming interface (API) is a set of routines, data structures, object classes and/or protocols provided by libraries and/or operating system services in order to support the building of applications

In simpler terms, an API consists of the bits of an assembly you can see and interact with from the outside. The Microsoft.NET framework has LOTS of stuff that you can't use because they are not part of the framework's API. These classes, methods, interfaces, etc are marked internal or private, and are intended for use by MS.

What you're looking at is just an example of using this code from the perspective of someone on the outside of the library looking in. In other words, you could have written this code yourself, as a consumer of the API. It doesn't detail all the possible ways to use the API, but it gives you a hint.

这篇关于什么是API使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆