用于VB的Wolfram Alpha API包装器不适用于C# [英] Wolfram Alpha API wrapper for VB not working for C#

查看:108
本文介绍了用于VB的Wolfram Alpha API包装器不适用于C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此位置使用了用于.NET的Wolfram Alpha API包装器

I'm using the Wolfram Alpha API wrapper for .NET at this location

http://products.wolframalpha.com/api/libraries.html

但是,它是用VB.NET编写的,并且是针对API的1.0版编写的.这是无法使用的.

However it's written in VB.NET and written for version 1.0 of the API. It's unusable.

有人知道更好的API包装器吗?

Does anyone know of a better API wrapper?

推荐答案

以下是可与新API一起使用的代码;我从Azure达拉斯那里得到的

Here is code that will work with the new API; I got it from Azure Dallas

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// Notice: Use of the service proxies that accompany this notice is subject to
//            the terms and conditions of the license agreement located at
//            http://go.microsoft.com/fwlink/?LinkID=202740&clcid=0x409
//            If you do not agree to these terms you may not use this content.
namespace WolframAlpha {
    using System;
    using System.Collections.Generic;
    using System.Data.Services.Client;
    using System.Net;
    using System.IO;


    public partial class DefaultPodEntity {

        private String _PlainText;

        private String _Img;

        private String _Title;

        private String _ParentTitle;

        private Int16 _ParentPosition;

        private String _ParentId;

        public String PlainText {
            get {
                return this._PlainText;
            }
            set {
                this._PlainText = value;
            }
        }

        public String Img {
            get {
                return this._Img;
            }
            set {
                this._Img = value;
            }
        }

        public String Title {
            get {
                return this._Title;
            }
            set {
                this._Title = value;
            }
        }

        public String ParentTitle {
            get {
                return this._ParentTitle;
            }
            set {
                this._ParentTitle = value;
            }
        }

        public Int16 ParentPosition {
            get {
                return this._ParentPosition;
            }
            set {
                this._ParentPosition = value;
            }
        }

        public String ParentId {
            get {
                return this._ParentId;
            }
            set {
                this._ParentId = value;
            }
        }
    }

    public partial class HtmlPodEntity {

        private String _Markup;

        private String _Title;

        private Int16 _Position;

        private String _Id;

        private String _Css;

        private String _Scripts;

        public String Markup {
            get {
                return this._Markup;
            }
            set {
                this._Markup = value;
            }
        }

        public String Title {
            get {
                return this._Title;
            }
            set {
                this._Title = value;
            }
        }

        public Int16 Position {
            get {
                return this._Position;
            }
            set {
                this._Position = value;
            }
        }

        public String Id {
            get {
                return this._Id;
            }
            set {
                this._Id = value;
            }
        }

        public String Css {
            get {
                return this._Css;
            }
            set {
                this._Css = value;
            }
        }

        public String Scripts {
            get {
                return this._Scripts;
            }
            set {
                this._Scripts = value;
            }
        }
    }

    public partial class PlainTextPodEntity {

        private String _PlainText;

        private String _Title;

        private String _ParentTitle;

        private Int16 _ParentPosition;

        private String _ParentId;

        public String PlainText {
            get {
                return this._PlainText;
            }
            set {
                this._PlainText = value;
            }
        }

        public String Title {
            get {
                return this._Title;
            }
            set {
                this._Title = value;
            }
        }

        public String ParentTitle {
            get {
                return this._ParentTitle;
            }
            set {
                this._ParentTitle = value;
            }
        }

        public Int16 ParentPosition {
            get {
                return this._ParentPosition;
            }
            set {
                this._ParentPosition = value;
            }
        }

        public String ParentId {
            get {
                return this._ParentId;
            }
            set {
                this._ParentId = value;
            }
        }
    }

    public partial class WolframAlphaFactsContainer : System.Data.Services.Client.DataServiceContext {

        public WolframAlphaFactsContainer(Uri serviceRoot) : 
                base(serviceRoot) {
        }

        /// <summary>
        /// </summary>
        /// <param name="Input">Query string Sample Values : weather|msft|derivative of x^4 sin x|SAT scores</param>
        /// <param name="Location">Location used for computation Sample Values : Madrid|Springfield, IL</param>
        /// <param name="LatitudeLongitude">Latitude/Longitude used for computation Sample Values : 40.42,-3.71|-22.54,-43.12</param>
        /// <param name="Width">Width in pixels for images returned Sample Values : 300|500</param>
        public DataServiceQuery<DefaultPodEntity> GetImageResults(String Input, String Location, String LatitudeLongitude, Int16? Width) {
            if ((Input == null)) {
                throw new System.ArgumentNullException("Input", "Input value cannot be null");
            }
            DataServiceQuery<DefaultPodEntity> query;
            query = base.CreateQuery<DefaultPodEntity>("GetImageResults");
            if ((Input != null)) {
                query = query.AddQueryOption("Input", string.Concat("\'", Input, "\'"));
            }
            if ((Location != null)) {
                query = query.AddQueryOption("Location", string.Concat("\'", Location, "\'"));
            }
            if ((LatitudeLongitude != null)) {
                query = query.AddQueryOption("LatitudeLongitude", string.Concat("\'", LatitudeLongitude, "\'"));
            }
            if (((Width != null) 
                        && (Width.HasValue == true))) {
                query = query.AddQueryOption("Width", Width.Value);
            }
            return query;
        }

        /// <summary>
        /// </summary>
        /// <param name="Input">Query string Sample Values : weather|msft|derivative of x^4 sin x|SAT scores</param>
        /// <param name="Location">Location used for computation Sample Values : Madrid|Springfield, IL</param>
        /// <param name="LatitudeLongitude">Latitude/Longitude used for computation Sample Values : 40.42,-3.71|-22.54,-43.12</param>
        /// <param name="Width">Width in pixels for images returned Sample Values : 300|500</param>
        public DataServiceQuery<HtmlPodEntity> GetHtmlResults(String Input, String Location, String LatitudeLongitude, Int16? Width) {
            if ((Input == null)) {
                throw new System.ArgumentNullException("Input", "Input value cannot be null");
            }
            DataServiceQuery<HtmlPodEntity> query;
            query = base.CreateQuery<HtmlPodEntity>("GetHtmlResults");
            if ((Input != null)) {
                query = query.AddQueryOption("Input", string.Concat("\'", Input, "\'"));
            }
            if ((Location != null)) {
                query = query.AddQueryOption("Location", string.Concat("\'", Location, "\'"));
            }
            if ((LatitudeLongitude != null)) {
                query = query.AddQueryOption("LatitudeLongitude", string.Concat("\'", LatitudeLongitude, "\'"));
            }
            if (((Width != null) 
                        && (Width.HasValue == true))) {
                query = query.AddQueryOption("Width", Width.Value);
            }
            return query;
        }

        /// <summary>
        /// </summary>
        /// <param name="Input">Query string Sample Values : weather|msft|derivative of x^4 sin x|SAT scores</param>
        /// <param name="Location">Location used for computation Sample Values : Madrid|Springfield, IL</param>
        /// <param name="LatitudeLongitude">Latitude/Longitude used for computation Sample Values : 40.42,-3.71|-22.54,-43.12</param>
        /// <param name="Width">Width in pixels for images returned Sample Values : 300|500</param>
        public DataServiceQuery<PlainTextPodEntity> GetPlainTextResults(String Input, String Location, String LatitudeLongitude, Int16? Width) {
            if ((Input == null)) {
                throw new System.ArgumentNullException("Input", "Input value cannot be null");
            }
            DataServiceQuery<PlainTextPodEntity> query;
            query = base.CreateQuery<PlainTextPodEntity>("GetPlainTextResults");
            if ((Input != null)) {
                query = query.AddQueryOption("Input", string.Concat("\'", Input, "\'"));
            }
            if ((Location != null)) {
                query = query.AddQueryOption("Location", string.Concat("\'", Location, "\'"));
            }
            if ((LatitudeLongitude != null)) {
                query = query.AddQueryOption("LatitudeLongitude", string.Concat("\'", LatitudeLongitude, "\'"));
            }
            if (((Width != null) 
                        && (Width.HasValue == true))) {
                query = query.AddQueryOption("Width", Width.Value);
            }
            return query;
        }
    }
}

这篇关于用于VB的Wolfram Alpha API包装器不适用于C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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