public IIntersection <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField> CreateIntersection( TypeModel leftModel, EntityModel rightModel ) { var fieldBuilder = new FieldBuilder(); var viewIntersectionModel = ViewIntersectionModel.FromTypeModel(leftModel); while (true) { var intersectCandidates = GetIntersectCandidates(viewIntersectionModel, rightModel); var analysisCtx = new IntersectAnalysis(viewIntersectionModel, rightModel); ApplyValidIntersectionCandidates(analysisCtx, intersectCandidates); var invalidFields = GetInvalidFields(analysisCtx).ToArray(); if (invalidFields.Length == 0) { // remove any unbound fields return(new Intersection(viewIntersectionModel, rightModel, analysisCtx.IntersectedFields.ToArray())); } foreach (var invalidField in invalidFields) { invalidField.LeftField.Replace(BuildReplacement(invalidField, fieldBuilder)); } } }
protected ViewIntersectionField( string fieldName, bool canRead, bool canWrite, Type fieldDataType, TypeModel declaringTypeModel, PropertyInfoField originPropertyField ) { FieldName = fieldName; CanRead = canRead; CanWrite = canWrite; FieldDataType = fieldDataType; DeclaringTypeModel = declaringTypeModel; OriginPropertyField = originPropertyField; if (SqlTypeHelper.GetDataType(fieldDataType) == null) { SelfModel = ViewIntersectionModel.FromTypeModel( TypeModel.GetModelOf(fieldDataType) ); } }
protected virtual IntersectCandidate <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField>[] GetIntersectCandidates( ViewIntersectionModel leftModel, EntityModel rightModel) => _candidateSources.SelectMany(source => source.GetIntersectCandidates(leftModel, rightModel)).ToArray();
public IntersectAnalysis(ViewIntersectionModel leftModel, EntityModel rightModel) { LeftModel = leftModel; RightModel = rightModel; }