无法实现IClonable或ISerializable的C#克隆对象 [英] C# Cloning Objects that implement neither IClonable or ISerializable

查看:194
本文介绍了无法实现IClonable或ISerializable的C#克隆对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经尝试了所有我能想到的并且无法解决的问题.基本上,我正在制作一个Outlook 2010加载项,它对传入的HTML格式的电子邮件进行了调整,目的是使视障用户(尤其是视障用户)更容易访问它们.

一切正常,除了运行我的加载项时,无论我尝试什么,它实际上都尝试修改原始电子邮件,哪个与Exchange连接的Outlook根本不喜欢并拒绝.我想要做的是显示修改后的电子邮件,其中包含所有好东西(答复,全部答复,密件抄送等),就像您通常使用Outlook一样,而无需修改原始消息……也就是说,我只想要显示我修改过的消息,而不修改存储的消息或添加新消息.

如:

Hi all,

I''ve tried everything I can think of and cannot figure this out. Basically, I''m making an Outlook 2010 Add-In that makes adjustments to incoming HTML formatted emails for the purposes of making them more Accessible to visually-impaired users (visually impaired users in particular.)

Everything works fine, except that when my Add-In runs, it actually attempts to modify the original email no matter what I try, which Exchange connected Outlook doesn''t like at all and rejects. What I want to do is display my modified email message with all of the goodies (reply, reply-all, BCC, etc., just like you would normally use Outlook) without modifying the original message...that is, I only want to display my modified message, not modify the stored message or add a new message.

Such as:

if (selObject is Outlook.MailItem)
  {
      Outlook.MailItem mailItem = (selObject as Outlook.MailItem);
      Outlook.MailItem accessible_mail_item = mailItem;
      ...rest of my code...
      accessible_mail_item.Display(false);
  }


我的问题是,"accessible_mail_item"不是"mailItem"的副本...它是指向它的指针.如何制作此不可序列化/可克隆对象的副本/克隆?我已经尝试了各种深度克隆"功能,但是它们都给了我关于不可序列化"或类似错误的信息.

任何帮助将不胜感激!!!!!!!!

谢谢!
Kendell


The problem I have is, "accessible_mail_item" is not a copy of "mailItem"...it''s a pointer to it. How can I make a copy/clone of this non-Serializable/Clonable Object? I''ve tried various "Deep Clone" functions out there, but they all give me the same errors about "not being serializable" or whatever.

Any help will be much appreciated!!!!!!!!

Thanks!
Kendell

推荐答案

尝试 fastJSON 中的DeepCopy() [ ^ ]或fastBinaryJSON [ ^ ],因为它们不需要对象可序列化或克隆.
Try DeepCopy() in fastJSON[^] or fastBinaryJSON[^] as they don''t require the object to be serializable or clonable.


这篇关于无法实现IClonable或ISerializable的C#克隆对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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