private bool TryFindAndCreatePrimitiveProperties( Type type, StructuralType cspaceType, StructuralType ospaceType, IEnumerable <PropertyInfo> clrProperties) { foreach (EdmProperty edmProperty in cspaceType.GetDeclaredOnlyMembers <EdmProperty>().Where <EdmProperty>((Func <EdmProperty, bool>)(p => Helper.IsPrimitiveType(p.TypeUsage.EdmType)))) { EdmProperty cspaceProperty = edmProperty; PropertyInfo propertyInfo = clrProperties.FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(p => OSpaceTypeFactory.MemberMatchesByConvention(p, (EdmMember)cspaceProperty))); if (propertyInfo != (PropertyInfo)null) { PrimitiveType primitiveType; if (OSpaceTypeFactory.TryGetPrimitiveType(propertyInfo.PropertyType, out primitiveType)) { if (propertyInfo.CanRead && propertyInfo.CanWriteExtended()) { OSpaceTypeFactory.AddScalarMember(type, propertyInfo, ospaceType, cspaceProperty, (EdmType)primitiveType); } else { this.LogLoadMessage(Strings.Validator_OSpace_Convention_ScalarPropertyMissginGetterOrSetter((object)propertyInfo.Name, (object)type.FullName, (object)type.Assembly().FullName), (EdmType)cspaceType); return(false); } } else { this.LogLoadMessage(Strings.Validator_OSpace_Convention_NonPrimitiveTypeProperty((object)propertyInfo.Name, (object)type.FullName, (object)propertyInfo.PropertyType.FullName), (EdmType)cspaceType); return(false); } } else { this.LogLoadMessage(Strings.Validator_OSpace_Convention_MissingRequiredProperty((object)cspaceProperty.Name, (object)type.FullName), (EdmType)cspaceType); return(false); } } return(true); }
private bool TryFindComplexProperties( Type type, StructuralType cspaceType, StructuralType ospaceType, IEnumerable <PropertyInfo> clrProperties, List <Action> referenceResolutionListForCurrentType) { List <KeyValuePair <EdmProperty, PropertyInfo> > keyValuePairList = new List <KeyValuePair <EdmProperty, PropertyInfo> >(); foreach (EdmProperty edmProperty in cspaceType.GetDeclaredOnlyMembers <EdmProperty>().Where <EdmProperty>((Func <EdmProperty, bool>)(m => Helper.IsComplexType(m.TypeUsage.EdmType)))) { EdmProperty cspaceProperty = edmProperty; PropertyInfo propertyInfo = clrProperties.FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(p => OSpaceTypeFactory.MemberMatchesByConvention(p, (EdmMember)cspaceProperty))); if (propertyInfo != (PropertyInfo)null) { keyValuePairList.Add(new KeyValuePair <EdmProperty, PropertyInfo>(cspaceProperty, propertyInfo)); } else { this.LogLoadMessage(Strings.Validator_OSpace_Convention_MissingRequiredProperty((object)cspaceProperty.Name, (object)type.FullName), (EdmType)cspaceType); return(false); } } foreach (KeyValuePair <EdmProperty, PropertyInfo> keyValuePair in keyValuePairList) { this.TrackClosure(keyValuePair.Value.PropertyType); StructuralType ot = ospaceType; EdmProperty cp = keyValuePair.Key; PropertyInfo clrp = keyValuePair.Value; referenceResolutionListForCurrentType.Add((Action)(() => this.CreateAndAddComplexType(type, ot, cp, clrp))); } return(true); }