private StructuralType CreateStructuralType(Type clrType) { var stb = new StructuralTypeBuilder(this); var st = stb.CreateStructuralType(clrType); return(st); }
private StructuralType GetStructuralTypeCore(String stName) { lock (_structuralTypes) { if (!TypeNameInfo.IsQualifiedTypeName(stName)) { String fullStName; if (_shortNameMap.TryGetValue(stName, out fullStName)) { stName = fullStName; } } var st = _structuralTypes[stName]; if (st == null) { var clrType = Configuration.Instance.GetClrType(stName); if (clrType == null) { return(null); } var stb = new StructuralTypeBuilder(this); st = stb.CreateStructuralType(clrType); _structuralTypes[stName] = st; } return(st); } }
private MetadataStore() { _clrTypeMap = new ClrTypeMap(this); RegisterTypeDiscoveryActionCore(typeof(IEntity), (t) => { StructuralTypeBuilder.GetEntityType(t); _clrTypeMap.GetStructuralType(t); }, false); RegisterTypeDiscoveryActionCore(typeof(IComplexObject), (t) => _clrTypeMap.GetStructuralType(t), false); RegisterTypeDiscoveryActionCore(typeof(Validator), (t) => RegisterValidator(t), true); }
/// <summary> /// Returns an StructuralType (EntityType or ComplexType) given its CLR type. /// </summary> /// <param name="clrType"></param> /// <returns></returns> public StructuralType GetStructuralType(Type clrType) { if (!IsStructuralType(clrType)) { throw new ArgumentOutOfRangeException("clrType", "This type does not implement either IEntity or IComplexObject"); } // not need for okIfNotFound because we will create a type if one isn't found. var stName = TypeNameInfo.FromClrType(clrType).StructuralTypeName; lock (_structuralTypes) { var st = _structuralTypes[stName]; if (st == null) { var stb = new StructuralTypeBuilder(this); st = stb.CreateStructuralType(clrType); _structuralTypes[stName] = st; } return(st); } }