所以,我使用CookComputings XMLRPC
庫,能夠去跟InfusionSoft
(它是一個在線CRM這是相當流行的)。主要方法是:轉換CookComputing XMLRpcStruct(IEnumerable的<Object>)和實際的C#類
[XmlRpcMethod("DataService.query")]
IEnumerable<object> QuerySubscriptionStatus(string apiKey,
string table, int limit, int page,
IDictionary queryData, string[] selectedFields);
我需要使用一個IEnumerable<object>
可悲的是,作爲InfusionSoft XML/RPC API需要它。我希望情況並非如此,但可悲的是。
由於我使用.NET 4.5,我想我可以做一個dyanmic投:
var subStatus = proxy.QuerySubscriptionStatus(
_key, "RecurringOrder", 500, 0, dict, sarray);
var result = subStatus.Cast<SubscriptionStatus>();
不幸的是,這是不行的,我給從C#一個很不好受錯誤:
無法轉換類型'CookComputing.XmlRpc.XmlRpcStruct爲鍵入「WBI.Model.SubscriptionStatus'.`的對象
我已經試過指定我的類作爲一個struct
;嘿,我甚至試圖用XMLRpcMember()
標籤指定它,但不是,它只是不會轉換。
如何與IEnumerable
中的數據交互?
類/結構類型我試過
public struct SubStatus
{
public int AffiliateId;
public int AutoCharge;
public double BillingAmt;
public string BillingCycle;
public int CC1;
public int CC2;
public int ContactId;
public DateTime EndDate;
public int Frequency;
public int Id;
public DateTime LastBillDate;
public int LeadAffiliateId;
public int MaxRetry;
public int MerchantAccountId;
public DateTime NextBillDate;
public int NumDaysBetweenRetry;
public int OriginatingOrderId;
public DateTime PaidThruDate;
public int PaymentGatewayId;
public int ProductId;
public int ProgramId;
public string PromoCode;
public int Qty;
public string ReasonStopped;
public int ShippingOptionId;
public DateTime StartDate;
public string Status;
public int SubscriptionPlanId;
}
我也只是嘗試一個簡單的類與XMLRpcMember
標籤:
public class SubscriptionStatus
{
[XmlRpcMember("AffiliateId")]
public int AffiliateId { get; set; }
[XmlRpcMember("AutoCharge")]
public int AutoCharge { get; set; }
[XmlRpcMember("BillingAmt")]
public double BillingAmt { get; set; }
[XmlRpcMember("BillingCycle")]
public string BillingCycle { get; set; }
[XmlRpcMember("CC1")]
public int CC1 { get; set; }
[XmlRpcMember("CC2")]
public int CC2 { get; set; }
[XmlRpcMember("ContactId")]
public int ContactId { get; set; }
[XmlRpcMember("EndDate")]
public DateTime EndDate { get; set; }
[XmlRpcMember("Frequency")]
public int Frequency { get; set; }
[XmlRpcMember("Id")]
public int Id { get; set; }
[XmlRpcMember("LastBillDate")]
public DateTime LastBillDate { get; set; }
[XmlRpcMember("LeadAffiliateId")]
public int LeadAffiliateId { get; set; }
[XmlRpcMember("MaxRetry")]
public int MaxRetry { get; set; }
[XmlRpcMember("MerchantAccountId")]
public int MerchantAccountId { get; set; }
[XmlRpcMember("NextBillDate")]
public DateTime NextBillDate { get; set; }
[XmlRpcMember("NumDaysBetweenRetry")]
public int NumDaysBetweenRetry { get; set; }
[XmlRpcMember("OriginatingOrderId")]
public int OriginatingOrderId { get; set; }
[XmlRpcMember("PaidThruDate")]
public DateTime PaidThruDate { get; set; }
[XmlRpcMember("PaymentGatewayId")]
public int PaymentGatewayId { get; set; }
[XmlRpcMember("ProductId")]
public int ProductId { get; set; }
[XmlRpcMember("ProgramId")]
public int ProgramId { get; set; }
[XmlRpcMember("PromoCode")]
public string PromoCode { get; set; }
[XmlRpcMember("Qty")]
public int Qty { get; set; }
[XmlRpcMember("ReasonStopped")]
public string ReasonStopped { get; set; }
[XmlRpcMember("ShippingOptionId")]
public int ShippingOptionId { get; set; }
[XmlRpcMember("StartDate")]
public DateTime StartDate { get; set; }
[XmlRpcMember("Status")]
public string Status { get; set; }
[XmlRpcMember("SubscriptionPlanId")]
public int SubscriptionPlanId { get; set; }
}
不幸的是,將它轉換爲列表是不可能的,因爲IEnumerable