public void SetObjectOwner(object oObj, object oParent) { EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oObj.GetType()); ReflectionUtil.SetFieldValue(oObj, oEntityTypeInfo.OwnerParent, oParent); }
public TisEntityTypeInfoExternal( EntityTypeInfo oTypeInfo, ITisEntityReflection oReflectionExternal) { m_oTypeInfo = oTypeInfo; m_oReflectionExternal = oReflectionExternal; }
// Avoids reallocation of returned children ArrayList private void GetChildren( object oObj, ChildrenListFilter pfChildrenListFilter, object oChildrenListFilterCriteria, ObjectFilter pfObjectFilter, object oObjectFilterCriteria, EntityRelation enRelation, bool bRecursive, ICollection <object> oOutChildren) { // Get TypeInfo of specified object EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oObj); // Get the ChildrenLists according to EntityRelation filter EntityChildrenListInfo[] ChildrenLists = GetChildrenListsInfo( oEntityTypeInfo, enRelation); // Iterate ChildrenLists foreach (EntityChildrenListInfo oChildrenList in ChildrenLists) { // Obtain list object INamedObjectList oContainer = oChildrenList.GetValue(oObj) as INamedObjectList; if (oContainer != null) { // Check if container passes filter bool bContainerPassedFilter = (pfChildrenListFilter == null) || pfChildrenListFilter(oChildrenList, oChildrenListFilterCriteria); object oEl; for (int i = 0; i < oContainer.Count; i++) { oEl = oContainer[oContainer.NameByIndex(i)]; if (bContainerPassedFilter && (pfObjectFilter == null || pfObjectFilter(oEl, oObjectFilterCriteria))) { // If elements filter passed oOutChildren.Add(oEl); } if (bRecursive) { // Recursive call for each children GetChildren( oEl, pfChildrenListFilter, oChildrenListFilterCriteria, pfObjectFilter, oObjectFilterCriteria, enRelation, bRecursive, oOutChildren); } } } } }
public object GetObjectOwner(object oObj) { EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oObj.GetType()); return(ReflectionUtil.GetFieldValue(oObj, oEntityTypeInfo.OwnerParent)); }
internal EntityChildrenListInfo[] GetChildrenListsInfo( EntityTypeInfo oEntityTypeInfo, EntityRelation enRelation) { EntityChildrenListInfo[] ChildrenLists = null; switch (enRelation) { case EntityRelation.Link: ChildrenLists = oEntityTypeInfo.LinkedChildren; break; case EntityRelation.Owner: ChildrenLists = oEntityTypeInfo.OwnedChildren; break; case EntityRelation.All: ChildrenLists = oEntityTypeInfo.AllChildren; break; default: throw new TisException("Unknown EntityRelation [{0}]", enRelation); } return(ChildrenLists); }
private FieldInfo GetUniqueParentLinkField(object oVal) { // Get TypeInfo of the value EntityTypeInfo oTypeInfo = Reflection.GetEntityTypeInfo(oVal); // Get a field that is a unique link to us FieldInfo oField = oTypeInfo.GetUniqueParentLinkField(this.GetType()); return(oField); }
private static bool ObjectFilter_WithObsoleteMember( object oObj, object oCriteria) { EntityReflectionServices oThis = new EntityReflectionServices(); EntityTypeInfo oEntityTypeInfo = oThis.GetEntityTypeInfo(oObj); FieldInfo[] ObsoleteMembers = oEntityTypeInfo.ObsoleteMembers; return(ObsoleteMembers.Length > 0); }
public EntityTypeInfo Get(Type oType) { EntityTypeInfo oVal = null; if (!m_oTypeToInfoTable.TryGetValue(oType, out oVal)) { oVal = new EntityTypeInfo(oType); m_oTypeToInfoTable[oType] = oVal; } return(oVal); }
public FieldInfo[] GetEntityTypeObsoleteMembers(Type oType) { EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oType); if (oEntityTypeInfo != null) { return(oEntityTypeInfo.ObsoleteMembers); } else { return(new FieldInfo[0]); } }
private void SetObjectOwnerParent(object oObj, object oParent) { EntityTypeInfo oChildTypeInfo = Reflection.GetEntityTypeInfo(oObj); FieldInfo oOwnerParentField = oChildTypeInfo.OwnerParent; if (oOwnerParentField != null) { object oTarget = oObj; // Set child "OwnerParent" field ReflectionUtil.SetFieldValue(oTarget, oOwnerParentField, oParent); } }
public EntityParameterInfo GetEntityParameterInfo( Type oType, string sParamName) { EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oType); EntityParameterInfo oParamData = oEntityTypeInfo.GetEntityParameterInfo(sParamName); if (oParamData == null) { throw new TisException( "Parameter [{0}] not exists in type [{1}]", sParamName, oType); } return(oParamData); }
public object CreateChild( object oObj, Type oChildType, string sChildName) { EntityTypeInfo oTypeInfo = GetEntityTypeInfo(oObj); EntityChildrenListInfo[] OwnedChildrenInfo = oTypeInfo.OwnedChildren; INamedObjectOwnerList oChildList = null; // Find the ChildList of specified type - must be one // and only one foreach (EntityChildrenListInfo oChildInfo in OwnedChildrenInfo) { if (oChildInfo.ChildType == oChildType) { if (oChildList != null) { throw new TisException( "More than 1 child list contains entities of type [{0}] " + "under entity of type [{1}]. " + "The child can't be created", oChildType, oObj.GetType()); } oChildList = oChildInfo.GetValue(oObj) as INamedObjectOwnerList; } } if (oChildList == null) { throw new TisException( "The child of type [{0}] can't be created under node of type [{1}]", oChildType, oObj.GetType()); } // Create a child return(oChildList.CreateNew(sChildName)); }
public ICollection GetParents(object oObj, bool bMandatoryOnly) { EntityTypeInfo oEntityTypeInfo = GetEntityTypeInfo(oObj.GetType()); ArrayList oParents = new ArrayList(); foreach (EntityParentInfo oParentInfo in oEntityTypeInfo.AllDirectParents) { if (bMandatoryOnly && !oParentInfo.Mandatory) { continue; } object oParent = ReflectionUtil.GetFieldValue(oObj, oParentInfo.Parent); if (oParent != null) { oParents.Add(oParent); } } return(oParents); }