C#GetType for FIleType [英] C# GetType for FIleType

查看:97
本文介绍了C#GetType for FIleType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表与LT; billingfileformatter> formatters = BillingFileManager.GetFormatterByIdWithChilden((Guid)QueueInfo.BillingFileFormatterId);

foreach(格式化程序中的BillingFileFormatter格式化程序)

{

List< string> LineItemList = new List< string>();

ACH testobject = new ACH();

// string typeName =Billing.Ach。 + formatter.ClassName +,Billing.Ach,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null;

string typeName = formatter.ClassName;

类型filetype = Type.GetType(typeName);

IBillingFile billingFile =(IBillingFile)Activator.CreateInstance(filetype);

LineItemList = billingFile.ProcessBillingQueue(QueueInfo,new List< order> ;(OrdersToProcess.Values.ToList()));

List<billingfileformatter> formatters = BillingFileManager.GetFormatterByIdWithChilden((Guid)QueueInfo.BillingFileFormatterId);
foreach (BillingFileFormatter formatter in formatters)
{
List<string> LineItemList = new List<string>();
ACH testobject = new ACH();
//string typeName = "Billing.Ach." + formatter.ClassName + ", Billing.Ach, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
string typeName = formatter.ClassName;
Type filetype = Type.GetType(typeName);
IBillingFile billingFile = (IBillingFile)Activator.CreateInstance(filetype);
LineItemList = billingFile.ProcessBillingQueue(QueueInfo, new List<order>(OrdersToProcess.Values.ToList()));








上面是我失败的代码,GetType返回null,我不知道为什么。任何帮助将不胜感激。




Above is the code that is failing for me, the GetType is coming back null and I dont know why. Any help would be appreciated.

推荐答案

请参阅我对该问题的评论。你真的需要解释你想要实现什么。



您正在使用静态方法 System.Type.GetType(System.String) http://msdn.microsoft.com/en-us/library/ w3f99sx1.aspx [ ^ ]。



阅读此帮助页面。这个方法真的不应该给你非空值。如果字符串不代表任何现有类型,它将为null。



我怀疑你真的需要它。



-SA
Please see my comment to the question. You really need to explain what do you want to achieve.

You are using the static method System.Type.GetType(System.String): http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx[^].

Read this help page. This method really should not give you non-null value. It will be null if the string does not represent any existing type.

I doubt you really need it.

—SA


谢谢你们,我错误地引用了命名空间,直到我在Billing.Ach类库中创建其他iBillingFile引用,我刚做了IBillingFile billingFile = new ACH();.我试图为ACH类库中的所有不同类型的对象创建一个通用包装器。我非常感谢所有的帮助!
thank you guys, I had the namespace incorrectly referenced and until I create the other iBillingFile References in the Billing.Ach class library, I just did IBillingFile billingFile = new ACH();. I was trying to make a generic wrapper for all the different types of Objects inside the ACH class library. I really appreciate all the help!!!


这篇关于C#GetType for FIleType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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