Collections
Collection classes are derived from a subclass of various classes in the JadeSoftware.Joob namespace listed in the following table, to inherit the required behavior.
Collection | Description |
---|---|
JadeSoftware.Joob.ObjectArray | Array of JADE objects |
JadeSoftware.Joob.ObjectSet | Set of JADE objects |
JadeSoftware.Joob.MemberKeyDictionary | Dictionary of JADE objects with one or more keys that are in the member class |
JadeSoftware.Joob.ExtKeyDictionary | Dictionary of JADE objects with one or more keys that are externally supplied |
JadeSoftware.Joob.DynamicDictionary | Dictionary of objects that encapsulates the behavior of the JADE |
The following example shows an exposed JADE
public partial class AgentDictByName: MemberKeyDictionary<AgentDictByNameKey, Agent> { private static AgentDictByNameMetadata _metaModel; partial void Initialize(); static AgentDictByName() { _metaModel = MetadataCache<AgentDictByNameMetadata>.GetData(null); } private AgentDictByName(): this(JadeSoftware.Joob.ClassPersistence.Transient) { } public AgentDictByName(JadeSoftware.Joob.ClassPersistence lifetime): base(lifetime, typeof(AgentDictByName), _metaModel.metaClass) { this.Initialize(); } protected AgentDictByName(JadeSoftware.Joob.ClassPersistence lifetime, System.Type type, JadeSoftware.Joob.ClassMetadata metaClass): base(lifetime, type, metaClass) { this.Initialize(); } public virtual Agent this[String name, DateTime dob] { get { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base[key]; } set { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); base[key] = value; } } public virtual bool TryGetValue(String name, DateTime dob, out Agent value) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base.TryGetValue(key, out value); } public virtual bool TryGetValue(String name, DateTime dob, JadeSoftware.Joob.SearchStrategy strategy, out Agent value) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base.TryGetValue(key, strategy, out value); } public virtual IJoobDictionaryEnumerable<AgentDictByNameKey, Agent> StartingAtKey(String name, DateTime dob) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base.StartingAtKey(key); } public virtual IJoobDictionaryEnumerable<AgentDictByNameKey, Agent>
StartingAtKey(String name, DateTime dob, JadeSoftware.Joob.SearchStrategy strategy) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base.StartingAtKey(key, strategy); } public virtual void Remove(String name, DateTime dob) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); base.Remove(key); } public virtual void Remove(String name, DateTime dob, Agent member) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); base.Remove(key, member); } public virtual bool ContainsKey(String name, DateTime dob) { AgentDictByNameKey key = new AgentDictByNameKey(name, dob); return base.ContainsKey(key); } }
In the following example, root contains a reference AllAgents of type AgentDictByName.
foreach (Agent agent in root.AllAgents) { agent.DoSomething(); }
When indexing a JADE array in .NET, the .NET convention of zero-based arrays is used; that is, the element at position zero (0) is the first element in the array. In the following example, a C# class called SomeClass has an
SomeClass obj = joobContext.FirstInstance<SomeClass>(); Int32 i = obj.MyIntegerArray[0]; // returns first element of array Int32 j = obj.MyIntegerArray.At(0); // also returns first element of array
In the following example, root contains a reference AllAgents of type AgentDictByName.
foreach (Agent agent in root.AllAgents) { agent.DoSomething(); }
When indexing a JADE array in .NET, the .NET convention of zero-based arrays is used; that is, the element at position zero (0) is the first element in the array. In the following example, a C# class called SomeClass has an
SomeClass obj = joobContext.FirstInstance<SomeClass>(); Int32 i = obj.MyIntegerArray[0]; // returns first element of array Int32 j = obj.MyIntegerArray.At(0); // also returns first element of array