tag:blogger.com,1999:blog-5184775962521127941.post5061157813816232291..comments2024-01-20T02:40:13.709+01:00Comments on Whizzo's Development Blog: Object Deep Cloning using IL in C# - version 1.1Unknownnoreply@blogger.comBlogger23125tag:blogger.com,1999:blog-5184775962521127941.post-85354142256108739292019-08-18T08:58:42.111+02:002019-08-18T08:58:42.111+02:00i am really happy to say it’s an interesting post ...i am really happy to say it’s an interesting post to read . I learn new information from your article , you are doing a great job . Keep it up and This paragraph gives clear idea for the new viewers of blogging.<br /><a href="http://www.onemachinelearning.com/" rel="nofollow">One Machine Learning</a><br /><a href="http://onedatasciences.com/" rel="nofollow">One data science </a><br /><a href="Bushraah88https://www.blogger.com/profile/06681642681061629300noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-8143684848737723352019-07-14T16:21:15.409+02:002019-07-14T16:21:15.409+02:00Nice information, valuable and excellent design, a...<br />Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.<br /><a href="http://www.onemachinelearning.com/" rel="nofollow">One Machine Learning</a><br /><a href="http://onedatasciences.com/" rel="nofollow">One data science </a><br />Bushraah88https://www.blogger.com/profile/06681642681061629300noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-80394177952727614052017-09-01T11:10:14.778+02:002017-09-01T11:10:14.778+02:00This comment has been removed by the author.harada57https://www.blogger.com/profile/06015023155124017905noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-57271570579553761722015-03-20T04:40:20.525+01:002015-03-20T04:40:20.525+01:00If you would like to summarize text, there are fre...If you would like to summarize text, there are free tools to use that will not require you to download any tool on your PC, but just use them while you are online. Here are some of their features and reasons to use them.<br /><br />Learn more about: <a href="http://www.summarizingtool.com/" rel="nofollow">summarize tool online</a><br />Saimon Rafihttp://www.summarizingtool.com/noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-52034664624157845182011-08-19T10:11:44.750+02:002011-08-19T10:11:44.750+02:00This looks like a really interesting way to carry ...This looks like a really interesting way to carry out cloning. Have you done any more work on this at all, as I notice this article is a few years old now.<br /><br />I'm interested in deep cloning an object graph (where some objects may be sub-classed in an external assembly). Would I be correct in thinking this will fail in a number of places? I've put these together from the list of Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-44727856331712110332011-05-29T12:41:30.445+02:002011-05-29T12:41:30.445+02:00i think there is a bug,try this
----------------
...i think there is a bug,try this<br /><br />----------------<br /><br />public class H<br /> {<br /> [Tools.CloneAttribute(CloneType=Tools.CloneType.DeepCloning)]<br /> private HashSet _set = new HashSet();<br /> <br /> public HashSet Set<br /> {<br /> get { return _set; }<br /> set { _set = value; }<br />namefreehttp://www.omeweb.comnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-16848672543434724722010-11-19T22:12:30.758+01:002010-11-19T22:12:30.758+01:00Hi.
Good job on the code. I'm running into the...Hi.<br />Good job on the code. I'm running into the same problem as selcux with NullReferenceException when cloning an object with more than one level of reference types. Took me a while to figure out the problem was multiple levels though. Do you have any updates which takes care of this?<br /><br />I also had to do some changes when it comes to getting the IEnumerator and Enumerators to bigfootnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-55310639079592551472010-05-07T12:15:34.610+02:002010-05-07T12:15:34.610+02:00Good job Whizzo,
I want to use this approach on ob...Good job Whizzo,<br />I want to use this approach on objects containing custom type fields. But when I tried I got null reference exception. Is there a way to make it recursively working?Anonymoushttps://www.blogger.com/profile/13534451078081668247noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-82598930867042174412010-05-01T00:29:44.505+02:002010-05-01T00:29:44.505+02:00Now i can use the code with IL, let's see what...Now i can use the code with IL, let's see what i had to change:<br /><br /><br /> public static class SwallowCloning<br /> {<br /> private static Dictionary _cachedIL = new Dictionary();<br /><br /><br /> public static T CloneObjectWithIL(this T objectToClone) where T : class<br /> {<br /> return CloneObjectWithIL(objectToClone: objectToClone, methodName:Eduardohttps://www.blogger.com/profile/10196431760748537752noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-43116841907365663612010-05-01T00:28:58.080+02:002010-05-01T00:28:58.080+02:00Thanks a lot, your code is being very useful in my...Thanks a lot, your code is being very useful in my projects. Though, i'm using your first code version due to the problems with arrays. But i would like to contribute with something very interesting. I've made the code able to DownCast Objects, imagine this scenario, in the past i had to create this DownCast method in the superclass:<br /><br /><br /> public class MyClass<br /> {<brEduardohttps://www.blogger.com/profile/10196431760748537752noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-35309080078848244522010-03-15T12:29:35.681+01:002010-03-15T12:29:35.681+01:00RegistratúrneZáznamyItem regZazn_najdeny = var_reg...RegistratúrneZáznamyItem regZazn_najdeny = var_regZazn.First();<br />RegistratúrneZáznamyItem regZazn_kopia = DSS_DeepClone_Linq.CloneHelper.CloneObjectWithILDeep(regZazn_najdeny);<br /><br />I can see, that kopia-instance object is clone with all properties as regZazn_najdeny, but when a I want to insert it to sharepoint by methods: <br />kontext_Aspreg.RegistratúrneZáznamy. <br />InsertOnSubmitUnknownhttps://www.blogger.com/profile/09856315887767270811noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-53741998941481714262010-03-15T12:27:39.809+01:002010-03-15T12:27:39.809+01:00This comment has been removed by the author.Unknownhttps://www.blogger.com/profile/09856315887767270811noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-12186984292390492602010-03-15T12:25:26.312+01:002010-03-15T12:25:26.312+01:00This comment has been removed by the author.Unknownhttps://www.blogger.com/profile/09856315887767270811noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-16441099441133494642009-04-01T12:57:00.000+02:002009-04-01T12:57:00.000+02:00Oh, thank you very much, of course, we can emit an...Oh, thank you very much, of course, we can emit an empty constructor in that case. I'll try that out.<BR/><BR/>Cheers, MichaelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-6743977817592758732009-03-29T16:32:00.000+02:002009-03-29T16:32:00.000+02:0027 maart, 2009 16:52 >>>Everywhere where ...27 maart, 2009 16:52 >>><BR/><BR/>Everywhere where objects are created based on there default constructor... These blocks looks like this:<BR/><BR/>ConstructorInfo cInfo = myObject.GetType().GetConstructor(Type.EmptyTypes);<BR/> generator.Emit(OpCodes.Newobj, cInfo);<BR/> generator.Emit(OpCodes.Stloc, cloneVariable);<BR/><BR/>Try this instead:<BR/><BR/>Jens Melgaaardhttp://www.dotjem.comnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-22454632116570999372009-03-27T16:52:00.000+01:002009-03-27T16:52:00.000+01:00Great thing that it's so performant.I have a probl...Great thing that it's so performant.<BR/><BR/>I have a problem tho, I need to clone "foreign" objects which often do not have any parameterless constructor, and that doesn't seem to work. :-/<BR/><BR/>As the state of an instance is completely determined by all of its instance fields, all we would need is just an instance.<BR/><BR/>It would be nice if there was an overload where I can hand in a Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-71761677055138007062009-02-15T02:00:00.000+01:002009-02-15T02:00:00.000+01:00First of all... Thanks for the post... very potent...First of all... Thanks for the post... very potential time saver...<BR/><BR/>I Ran into a cloning of arrays issue... meaning these are shallow by default, if i try to deepclone them it fails... I think you mentioned this some place so no biggie...<BR/><BR/>But i wanted to post what i ended up with so far...<BR/><BR/>Instead of keeping all things in IL, since a simple array would be pritty basic, Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-49754754291664193942008-09-18T20:27:00.000+02:002008-09-18T20:27:00.000+02:00Hi. Do you have a zip with your test program and t...Hi. Do you have a zip with your test program and the Clone code all in one. It seems as though as something's missing from the source posted online. <BR/><BR/>Thanks !Is this thing turned on ?https://www.blogger.com/profile/01879918472280171348noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-67291966785674825892008-08-08T04:16:00.000+02:002008-08-08T04:16:00.000+02:00Hi Whizzo,I have a limited knowledge of the IL as ...Hi Whizzo,<BR/><BR/>I have a limited knowledge of the IL as welll :). I used your code and it works for me however I tried to be able to change your code to clone a object with multimple other objects inside and with multiple object levels deep.<BR/><BR/>What I have done is if it reaches the isClass then I check the the field if it is a Property, if so I called your clone method inside the Unknownhttps://www.blogger.com/profile/07351334078278468117noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-56332051744203422242008-08-06T08:21:00.000+02:002008-08-06T08:21:00.000+02:00Sure, you may reference my post.Isn't reflection o...Sure, you may reference my post.<BR/><BR/>Isn't reflection only, a little slow?Whizzohttps://www.blogger.com/profile/05861307363609926139noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-2406139792198558672008-08-05T19:20:00.000+02:002008-08-05T19:20:00.000+02:00Well looks like that works, I have done it with re...Well looks like that works, I have done it with reflection and am now able to pass a large amount of entities over a WCF service connection without the errors you get for your object graph being to deep and message size. I have yet to do this with IL though.<BR/><BR/>I am currently writing an article about the method I used to share entity objects from a WCF server to a client without the client Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-71070951068540989192008-07-29T15:48:00.000+02:002008-07-29T15:48:00.000+02:00You could change the GetFields() by GetProperties(...You could change the GetFields() by GetProperties(), but normally the fields should work. Because all internal fields of the class you clone will be filled in.<BR/><BR/>Be aware to check the properties for a set method if you want to clone property-based.Whizzohttps://www.blogger.com/profile/05861307363609926139noreply@blogger.comtag:blogger.com,1999:blog-5184775962521127941.post-67321304330819447912008-07-11T19:58:00.000+02:002008-07-11T19:58:00.000+02:00How would one go about cloning a property with IL?...How would one go about cloning a property with IL? I've been working with your code with Entity Objects but I still lack some of the skill with IL to clone over a property, and a couple of properties in an Entity Object are needed to attach an object back into a Data Context.Anonymousnoreply@blogger.com