init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
82
Framework/Collections/Generic/AssociatedEntityCollection.cs
Normal file
82
Framework/Collections/Generic/AssociatedEntityCollection.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
|
||||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
public class AssociatedEntityCollection<OwnerEntityType, CollectionEntityType> : EntityCollection<CollectionEntityType>, IAssociatedEntityCollection<CollectionEntityType>, IAssociatedEntityCollection
|
||||
where OwnerEntityType : Kreta.Framework.Entities.Entity
|
||||
where CollectionEntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
private IEntityCollectionDA<CollectionEntityType> m_DA = null;
|
||||
|
||||
public AssociatedEntityCollection(IEntityCollectionDA<CollectionEntityType> collectionDA)
|
||||
{
|
||||
m_DA = collectionDA;
|
||||
}
|
||||
|
||||
protected override void DoAdd(CollectionEntityType entity)
|
||||
{
|
||||
m_DA.AddItem(entity);
|
||||
base.DoAdd(entity);
|
||||
}
|
||||
|
||||
protected override void DoRemove(CollectionEntityType entity)
|
||||
{
|
||||
m_DA.DeleteItem(entity);
|
||||
base.DoRemove(entity);
|
||||
}
|
||||
|
||||
protected override void DoClear()
|
||||
{
|
||||
throw new NotSupportedException("AssociatedEntityCollection<OwnerEntityType, CollectionEntityType>.DoClear()");
|
||||
}
|
||||
|
||||
public void Remove(CollectionEntityType entity)
|
||||
{
|
||||
DoRemove(entity);
|
||||
}
|
||||
|
||||
public void Delete(CollectionEntityType entity)
|
||||
{
|
||||
DoRemove(entity);
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
CollectionEntityType[] tmp = new CollectionEntityType[m_Entities.Count];
|
||||
m_Entities.CopyTo(tmp);
|
||||
foreach (CollectionEntityType entity in tmp)
|
||||
{
|
||||
DoRemove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
m_DA.LoadCollection(this);
|
||||
}
|
||||
|
||||
#region IAssociatedEntityCollection Members
|
||||
|
||||
void IAssociatedEntityCollection.Remove(Kreta.Framework.Entities.Entity entity)
|
||||
{
|
||||
Remove((CollectionEntityType)entity);
|
||||
}
|
||||
|
||||
void IAssociatedEntityCollection.Delete(Kreta.Framework.Entities.Entity entity)
|
||||
{
|
||||
Delete((CollectionEntityType)entity);
|
||||
}
|
||||
|
||||
void IAssociatedEntityCollection.RemoveAll()
|
||||
{
|
||||
RemoveAll();
|
||||
}
|
||||
|
||||
void IAssociatedEntityCollection.Load()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
400
Framework/Collections/Generic/EntityCollection.cs
Normal file
400
Framework/Collections/Generic/EntityCollection.cs
Normal file
|
@ -0,0 +1,400 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
/// <summary>
|
||||
/// Entitás lista felülete.
|
||||
/// </summary>
|
||||
public class EntityCollection<EntityType> : IEntityCollection<EntityType>, IEntityCollection, IList
|
||||
where EntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
protected List<EntityType> m_Entities = new List<EntityType>();
|
||||
|
||||
public EntityCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Külön bejárat a DA számára
|
||||
/// </summary>
|
||||
/// <param name="entity">Entitás példány</param>
|
||||
protected internal void InternalAdd(EntityType entity)
|
||||
{
|
||||
m_Entities.Add(entity);
|
||||
}
|
||||
|
||||
#region Internal operations
|
||||
protected virtual void DoRemove(EntityType entity)
|
||||
{
|
||||
if (entity.ID == -1)
|
||||
{
|
||||
m_Entities.Remove(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Entities.RemoveAll(e => e.ID == entity.ID);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DoAdd(EntityType entity)
|
||||
{
|
||||
if (!Contains(entity))
|
||||
{
|
||||
m_Entities.Add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DoClear()
|
||||
{
|
||||
m_Entities.Clear();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList<EntityType> Members
|
||||
|
||||
int IList<EntityType>.IndexOf(EntityType item)
|
||||
{
|
||||
return IndexOf(item);
|
||||
}
|
||||
|
||||
void IList<EntityType>.Insert(int index, EntityType item)
|
||||
{
|
||||
throw new NotSupportedException("IList<EntityType>.Insert");
|
||||
}
|
||||
|
||||
void IList<EntityType>.RemoveAt(int index)
|
||||
{
|
||||
DoRemove(m_Entities[index]);
|
||||
}
|
||||
|
||||
EntityType IList<EntityType>.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Entities[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException("EntityType IList<EntityType>.this[int index] setter");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICollection<EntityType> Members
|
||||
|
||||
void ICollection<EntityType>.Add(EntityType item)
|
||||
{
|
||||
DoAdd(item);
|
||||
}
|
||||
|
||||
void ICollection<EntityType>.Clear()
|
||||
{
|
||||
DoClear();
|
||||
}
|
||||
|
||||
bool ICollection<EntityType>.Contains(EntityType item)
|
||||
{
|
||||
return Contains(item);
|
||||
}
|
||||
|
||||
void ICollection<EntityType>.CopyTo(EntityType[] array, int arrayIndex)
|
||||
{
|
||||
m_Entities.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
int ICollection<EntityType>.Count
|
||||
{
|
||||
get { return m_Entities.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<EntityType>.IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
bool ICollection<EntityType>.Remove(EntityType item)
|
||||
{
|
||||
if (Contains(item))
|
||||
{
|
||||
DoRemove(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerable<EntityType> Members
|
||||
|
||||
IEnumerator<EntityType> IEnumerable<EntityType>.GetEnumerator()
|
||||
{
|
||||
return m_Entities.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Members
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return m_Entities.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
|
||||
int IList.Add(object value)
|
||||
{
|
||||
DoAdd((EntityType)value);
|
||||
return IndexOf((EntityType)value);
|
||||
}
|
||||
|
||||
void IList.Clear()
|
||||
{
|
||||
DoClear();
|
||||
}
|
||||
|
||||
bool IList.Contains(object value)
|
||||
{
|
||||
return Contains((EntityType)value);
|
||||
}
|
||||
|
||||
int IList.IndexOf(object value)
|
||||
{
|
||||
return IndexOf((EntityType)value);
|
||||
}
|
||||
|
||||
void IList.Insert(int index, object value)
|
||||
{
|
||||
throw new NotSupportedException("void IList.Insert(int index, object value)");
|
||||
}
|
||||
|
||||
bool IList.IsFixedSize
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
bool IList.IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
void IList.Remove(object value)
|
||||
{
|
||||
DoRemove((EntityType)value);
|
||||
}
|
||||
|
||||
void IList.RemoveAt(int index)
|
||||
{
|
||||
DoRemove(m_Entities[index]);
|
||||
}
|
||||
|
||||
object IList.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Entities[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException("object IList.this[int index] setter");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
|
||||
void ICollection.CopyTo(Array array, int index)
|
||||
{
|
||||
((ICollection)m_Entities).CopyTo(array, index);
|
||||
}
|
||||
|
||||
int ICollection.Count
|
||||
{
|
||||
get { return m_Entities.Count; }
|
||||
}
|
||||
|
||||
bool ICollection.IsSynchronized
|
||||
{
|
||||
get { return ((ICollection)m_Entities).IsSynchronized; }
|
||||
}
|
||||
|
||||
object ICollection.SyncRoot
|
||||
{
|
||||
get { return ((ICollection)m_Entities).SyncRoot; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEntityCollection<EntityType> Members
|
||||
public int Count
|
||||
{
|
||||
get { return m_Entities.Count; }
|
||||
}
|
||||
|
||||
public EntityType this[int index] => m_Entities[index];
|
||||
|
||||
public int Add(EntityType entity)
|
||||
{
|
||||
DoAdd(entity);
|
||||
return IndexOf(entity);
|
||||
}
|
||||
|
||||
public bool Contains(EntityType entity)
|
||||
{
|
||||
if (entity.ID == -1)
|
||||
{
|
||||
return m_Entities.Contains(entity);
|
||||
}
|
||||
|
||||
return m_Entities.Any(e => e.ID == entity.ID);
|
||||
}
|
||||
|
||||
public void DeleteAll(bool logikai = true)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
entity.Delete(false, logikai);
|
||||
}
|
||||
|
||||
m_Entities.Clear();
|
||||
}
|
||||
|
||||
public void DeleteMany(IList<int> ids, bool logikai = true)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
if (!ids.Contains(entity.ID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.Delete(false, logikai);
|
||||
}
|
||||
m_Entities.Clear();
|
||||
}
|
||||
|
||||
public void DeleteAll(bool runHandler, bool logikai = true)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
entity.Delete(runHandler, logikai);
|
||||
}
|
||||
|
||||
m_Entities.Clear();
|
||||
}
|
||||
|
||||
public void CascadeDeleteAll(bool logikai = true)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
entity.CascadeDelete(logikai);
|
||||
}
|
||||
|
||||
m_Entities.Clear();
|
||||
}
|
||||
|
||||
public void CascadeDeleteAll(bool runHandler, bool logikai = true)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
entity.CascadeDelete(runHandler, logikai);
|
||||
}
|
||||
|
||||
m_Entities.Clear();
|
||||
}
|
||||
|
||||
public EntityType FindEntityById(int entityId)
|
||||
{
|
||||
foreach (EntityType entity in m_Entities)
|
||||
{
|
||||
if (entity.ID == entityId)
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
DoClear();
|
||||
}
|
||||
|
||||
public int IndexOf(EntityType entity)
|
||||
{
|
||||
if (entity.ID == -1)
|
||||
{
|
||||
return m_Entities.IndexOf(entity);
|
||||
}
|
||||
|
||||
var found = m_Entities.Find(e => e.ID == entity.ID);
|
||||
return found == null ? -1 : m_Entities.IndexOf(found);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEntityCollection Members
|
||||
|
||||
int IEntityCollection.Count
|
||||
{
|
||||
get { return Count; }
|
||||
}
|
||||
|
||||
Kreta.Framework.Entities.Entity IEntityCollection.this[int index]
|
||||
{
|
||||
get { return this[index]; }
|
||||
}
|
||||
|
||||
int IEntityCollection.Add(Kreta.Framework.Entities.Entity entity) => Add((EntityType)entity);
|
||||
|
||||
bool IEntityCollection.Contains(Kreta.Framework.Entities.Entity entity)
|
||||
{
|
||||
return Contains((EntityType)entity);
|
||||
}
|
||||
|
||||
void IEntityCollection.DeleteAll()
|
||||
{
|
||||
DeleteAll();
|
||||
}
|
||||
|
||||
void IEntityCollection.DeleteAll(bool runHandler)
|
||||
{
|
||||
DeleteAll(runHandler);
|
||||
}
|
||||
|
||||
void IEntityCollection.CascadeDeleteAll()
|
||||
{
|
||||
CascadeDeleteAll();
|
||||
}
|
||||
|
||||
void IEntityCollection.CascadeDeleteAll(bool runHandler)
|
||||
{
|
||||
CascadeDeleteAll(runHandler);
|
||||
}
|
||||
|
||||
Kreta.Framework.Entities.Entity IEntityCollection.FindEntityById(int entityId)
|
||||
{
|
||||
return FindEntityById(entityId);
|
||||
}
|
||||
|
||||
void IEntityCollection.Clear()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
int IEntityCollection.IndexOf(Kreta.Framework.Entities.Entity entity)
|
||||
{
|
||||
return IndexOf((EntityType)entity);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
32
Framework/Collections/Generic/EntityCollectionDA.cs
Normal file
32
Framework/Collections/Generic/EntityCollectionDA.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
public abstract class EntityCollectionDA<OwnerEntityType, CollectionEntityType> : IEntityCollectionDA<CollectionEntityType>
|
||||
where OwnerEntityType : Kreta.Framework.Entities.Entity
|
||||
where CollectionEntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
private OwnerEntityType m_Owner = null;
|
||||
|
||||
protected internal EntityCollectionDA(OwnerEntityType owner)
|
||||
{
|
||||
m_Owner = owner;
|
||||
}
|
||||
|
||||
private EntityCollectionDA()
|
||||
{
|
||||
}
|
||||
|
||||
protected OwnerEntityType Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Owner;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void LoadCollection(IAssociatedEntityCollection<CollectionEntityType> collection);
|
||||
|
||||
public abstract void AddItem(CollectionEntityType entity);
|
||||
|
||||
public abstract void DeleteItem(CollectionEntityType entity);
|
||||
}
|
||||
}
|
12
Framework/Collections/Generic/IAssociatedEntityCollection.cs
Normal file
12
Framework/Collections/Generic/IAssociatedEntityCollection.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
public interface IAssociatedEntityCollection<EntityType> : IEntityCollection<EntityType>
|
||||
where EntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
void Delete(EntityType entity);
|
||||
|
||||
void RemoveAll();
|
||||
|
||||
void Load();
|
||||
}
|
||||
}
|
21
Framework/Collections/Generic/IEntityCollection.cs
Normal file
21
Framework/Collections/Generic/IEntityCollection.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
public interface IEntityCollection<EntityType> : IList<EntityType>
|
||||
where EntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
void DeleteAll(bool logikai = true);
|
||||
|
||||
void DeleteAll(bool runHandler, bool logikai = true);
|
||||
|
||||
void DeleteMany(IList<int> ids, bool logikai = true);
|
||||
|
||||
void CascadeDeleteAll(bool logikai = true);
|
||||
|
||||
void CascadeDeleteAll(bool runHandler, bool logikai = true);
|
||||
|
||||
EntityType FindEntityById(int entityId);
|
||||
|
||||
}
|
||||
}
|
12
Framework/Collections/Generic/IEntityCollectionDA.cs
Normal file
12
Framework/Collections/Generic/IEntityCollectionDA.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace Kreta.Framework.Collections.Generic
|
||||
{
|
||||
public interface IEntityCollectionDA<CollectionEntityType>
|
||||
where CollectionEntityType : Kreta.Framework.Entities.Entity
|
||||
{
|
||||
void LoadCollection(IAssociatedEntityCollection<CollectionEntityType> collection);
|
||||
|
||||
void AddItem(CollectionEntityType entity);
|
||||
|
||||
void DeleteItem(CollectionEntityType entity);
|
||||
}
|
||||
}
|
16
Framework/Collections/IAssociatedEntityCollection.cs
Normal file
16
Framework/Collections/IAssociatedEntityCollection.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using Kreta.Framework.Entities;
|
||||
|
||||
namespace Kreta.Framework.Collections
|
||||
{
|
||||
public interface IAssociatedEntityCollection : IEntityCollection, IEnumerable
|
||||
{
|
||||
void Remove(Entity entity);
|
||||
|
||||
void Delete(Entity entity);
|
||||
|
||||
void RemoveAll();
|
||||
|
||||
void Load();
|
||||
}
|
||||
}
|
36
Framework/Collections/IEntityCollection.cs
Normal file
36
Framework/Collections/IEntityCollection.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Collections;
|
||||
using Kreta.Framework.Entities;
|
||||
|
||||
namespace Kreta.Framework.Collections
|
||||
{
|
||||
public interface IEntityCollection : IEnumerable
|
||||
{
|
||||
int Count
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
Entity this[int index]
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
int Add(Entity entity);
|
||||
|
||||
bool Contains(Entity entity);
|
||||
|
||||
void DeleteAll();
|
||||
|
||||
void DeleteAll(bool runHandler);
|
||||
|
||||
void CascadeDeleteAll();
|
||||
|
||||
void CascadeDeleteAll(bool runHandler);
|
||||
|
||||
Entity FindEntityById(int entityId);
|
||||
|
||||
void Clear();
|
||||
|
||||
int IndexOf(Entity entity);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue