Ejemplo n.º 1
0
 private void RegisterStructuralType(Type clrType)
 {
     lock (_clrTypeMap) {
         var stName = TypeNameInfo.FromClrType(clrType).StructuralTypeName;
         _clrTypeMap[stName] = clrType;
     }
 }
Ejemplo n.º 2
0
        /// <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);
            }
        }