object-graph

How do I find cycles in my object hierarchy?

江枫思渺然 提交于 2019-12-06 05:38:50
问题 There is a class Company , which has reference to another instance of Company to represent the parent . Lets say there are four companies c1 , c2 , c3 & c4 and c2 , c3 , c4 has parent company set as c1 . For example: public class Company { public Company parent; public Company() { } public Company(Company parent) { this.parent = parent; } public static void main(String[] args) { Company c1 = new Company(); Company c2 = new Company(c1); Company c3 = new Company(c1); Company c4 = new Company(c1

How do I find cycles in my object hierarchy?

佐手、 提交于 2019-12-04 10:16:44
There is a class Company , which has reference to another instance of Company to represent the parent . Lets say there are four companies c1 , c2 , c3 & c4 and c2 , c3 , c4 has parent company set as c1 . For example: public class Company { public Company parent; public Company() { } public Company(Company parent) { this.parent = parent; } public static void main(String[] args) { Company c1 = new Company(); Company c2 = new Company(c1); Company c3 = new Company(c1); Company c4 = new Company(c1); } If we set c2 as parent company of the c1 : c1.parent = c2; then it will create a Cyclomatic

.NET Binary Serialize object with references to other objects . . . what happens?

六月ゝ 毕业季﹏ 提交于 2019-12-01 23:49:43
问题 If you have an object instance A that references other objects (for example instances B and C), and you binary serialize A to a file, what happens? Do you now have serialized data that includes A, B and C? How does it work exactly? What will I get if I deserialize the data? A, B, and C?? (Feel free to include internal workings explanations as well). 回答1: All of the references to other objects will be serialized as well. If you deserialize the data, you will end up with a complete, working set

StructureMap HowTo: Conditional Construction on Deep Object

。_饼干妹妹 提交于 2019-12-01 21:06:46
I'm having difficulty conditionally creating a dependency. Googling, I have yet to find a good example of using the BuildStack and Conditional Predicates. Here's what I'm doing in the Registry: //snip public SomeRegistry() { this.InstanceOf<IFoo>().Is.Conditional( c => { c.TheDefault.Is.ConstructedBy(() => new FooZ()); c.If( p => p.ParentType.IsAssignableFrom(typeof(IBar)) && p.BuildStack.Current.RequestedType.IsAssignableFrom(typeof(IDoStuffWithFooA))) .ThenIt.Is.ConstructedBy(() => new FooA()); c.If( p => p.ParentType.IsAssignableFrom(typeof(IBar)) && p.BuildStack.Current.RequestedType

Clone Whole Object Graph

懵懂的女人 提交于 2019-11-30 04:04:39
While using this code to serialize an object: public object Clone() { var serializer = new DataContractSerializer(GetType()); using (var ms = new System.IO.MemoryStream()) { serializer.WriteObject(ms, this); ms.Position = 0; return serializer.ReadObject(ms); } } I have noticed that it doesn't copy the relationships. Is there any way to make this happen? Simply use the constructor overload that accepts preserveObjectReferences , and set it to true: using System; using System.Runtime.Serialization; static class Program { public static T Clone<T>(T obj) where T : class { var serializer = new

What is an efficient way to Merge two iOS Core Data Persistent Stores?

孤街浪徒 提交于 2019-11-28 21:37:25
In our app under development we are using Core Data with a sqlite backing store to store our data. The object model for our app is complex. Also, the total amount of data served by our app is too large to fit into an iOS (iPhone/iPad/iPod Touch) app bundle. Because of the fact that our users are, typically, interested only in a subset of the data, we've partitioned our data in such a way that the app ships with a subset (albeit, ~100 MB) of the data objects in the app bundle. Our users have the option of downloading additional data objects (of size ~5 MB to 100 MB) from our server after they

What is an efficient way to Merge two iOS Core Data Persistent Stores?

不问归期 提交于 2019-11-27 14:03:08
问题 In our app under development we are using Core Data with a sqlite backing store to store our data. The object model for our app is complex. Also, the total amount of data served by our app is too large to fit into an iOS (iPhone/iPad/iPod Touch) app bundle. Because of the fact that our users are, typically, interested only in a subset of the data, we've partitioned our data in such a way that the app ships with a subset (albeit, ~100 MB) of the data objects in the app bundle. Our users have