示例#1
0
        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)
                    );
            }
        }
示例#3
0
 protected virtual IntersectCandidate <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField>[] GetIntersectCandidates(
     ViewIntersectionModel leftModel, EntityModel rightModel)
 => _candidateSources.SelectMany(source => source.GetIntersectCandidates(leftModel, rightModel)).ToArray();
示例#4
0
 public IntersectAnalysis(ViewIntersectionModel leftModel, EntityModel rightModel)
 {
     LeftModel  = leftModel;
     RightModel = rightModel;
 }