GetVertexDomainPropertyMaps(IVertexSchema pVertex, bool pCreateMode) { Type pmt = typeof(PropertyMapping); IEnumerable <PropertyMapping> propMaps = pVertex .GetType() .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) .Where(x => x.PropertyType.IsSubclassOf(pmt)) .Select(x => (PropertyMapping)x.GetValue(pVertex, null)) .Where(x => (!pCreateMode || x.Api.CreateAccess != Access.None)); var map = new Dictionary <DomainProperty, IList <PropertyMapping> >(); foreach (PropertyMapping pm in propMaps) { if (!map.ContainsKey(pm.Domain)) { map.Add(pm.Domain, new List <PropertyMapping>()); } map[pm.Domain].Add(pm); } return(map); }
/*--------------------------------------------------------------------------------------------*/ public static IList <DomainProperty> GetVertexDomainProperties(IVertexSchema pVertex) { Type dpt = typeof(DomainProperty); return(pVertex .GetType() .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) .Where(x => x.PropertyType.IsSubclassOf(dpt)) .Select(x => (DomainProperty)x.GetValue(pVertex, null)) .ToList()); }
/*--------------------------------------------------------------------------------------------*/ public static IList <IEdgeSchema> GetEdgeSchemasForVertex( IVertexSchema pVertex, bool pCreateMode = false) { Type vt = pVertex.GetType(); return(GetEdgeSchemas() .Where(x => x.FromVertexType == vt) .Where(x => (!pCreateMode || (x.FabToVertexId.CreateAccess != Access.None && x.CreateFromOtherDirection == null))) .ToList()); }
GetVertexApiPropertyMaps(IVertexSchema pVertex) { Type pmt = typeof(PropertyMapping); return(pVertex .GetType() .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) .Where(x => x.PropertyType.IsSubclassOf(pmt)) .Select(x => (PropertyMapping)x.GetValue(pVertex, null)) .ToDictionary(x => x.Api, x => x)); }
/*--------------------------------------------------------------------------------------------*/ public static IEdgeSchema GetReverseEdgeSchema(IVertexSchema pVertex, IEdgeSchema pEdge) { Type vt = pVertex.GetType(); Type et = pEdge.GetType(); return(GetEdgeSchemas() .Where(x => x.ToVertexType == vt) .Where(x => (x.FabToVertexId.CreateAccess != Access.None && x.CreateFromOtherDirection == et)) .Take(1) .SingleOrDefault()); }
/*--------------------------------------------------------------------------------------------*/ public static IList <ApiProperty> GetVertexApiProperties(IVertexSchema pVertex, bool pSkipSubObjects = false, bool pCreateMode = false) { Type apt = typeof(ApiProperty); return(pVertex .GetType() .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) .Where(x => x.PropertyType.IsSubclassOf(apt)) .Select(x => (ApiProperty)x.GetValue(pVertex, null)) .Where(x => (!pSkipSubObjects || x.SubObjectOf == null)) .Where(x => (!pCreateMode || x.CreateAccess != Access.None)) .ToList()); }
GetVertexApiPropertySubMap(IVertexSchema pVertex) { IList <ApiProperty> props = GetVertexApiProperties(pVertex); var subMap = new Dictionary <string, IList <ApiProperty> >(); foreach (ApiProperty ap in props) { if (ap.SubObjectOf == null) { continue; } if (!subMap.ContainsKey(ap.SubObjectOf)) { subMap.Add(ap.SubObjectOf, new List <ApiProperty>()); } subMap[ap.SubObjectOf].Add(ap); } return(subMap); }
/*--------------------------------------------------------------------------------------------*/ public static IVertexSchema GetVertexParent(IVertexSchema pVertex) { Type type = pVertex.GetType().BaseType; return(type == typeof(Object) ? null : GetVertex(type)); }