public void LoadTypes(
     EdmItemCollection edmItemCollection,
     ObjectItemCollection objectItemCollection)
 {
     foreach (EdmType edmType in edmItemCollection.OfType <EdmType>().Where <EdmType>((Func <EdmType, bool>)(t =>
     {
         if (t.BuiltInTypeKind != BuiltInTypeKind.EntityType && t.BuiltInTypeKind != BuiltInTypeKind.EnumType)
         {
             return(t.BuiltInTypeKind == BuiltInTypeKind.ComplexType);
         }
         return(true);
     })))
     {
         Type clrType = edmType.GetClrType();
         if (clrType != (Type)null)
         {
             EdmType type = this._typeFactory.TryCreateType(clrType, edmType);
             if (type != null)
             {
                 this._typeFactory.CspaceToOspace.Add(edmType, type);
             }
         }
     }
     this._typeFactory.CreateRelationships(edmItemCollection);
     foreach (Action referenceResolution in this._typeFactory.ReferenceResolutions)
     {
         referenceResolution();
     }
     foreach (MetadataItem metadataItem in this._typeFactory.LoadedTypes.Values)
     {
         metadataItem.SetReadOnly();
     }
     objectItemCollection.AddLoadedTypes(this._typeFactory.LoadedTypes);
     objectItemCollection.OSpaceTypesLoaded = true;
 }
        public void LoadTypes(EdmItemCollection edmItemCollection, ObjectItemCollection objectItemCollection)
        {
            DebugCheck.NotNull(edmItemCollection);
            DebugCheck.NotNull(objectItemCollection);

            foreach (var cSpaceType in edmItemCollection.OfType <EdmType>().Where(
                         t => t.BuiltInTypeKind == BuiltInTypeKind.EntityType ||
                         t.BuiltInTypeKind == BuiltInTypeKind.EnumType ||
                         t.BuiltInTypeKind == BuiltInTypeKind.ComplexType))
            {
                var clrType = cSpaceType.GetClrType();
                if (clrType != null)
                {
                    var oSpaceType = _typeFactory.TryCreateType(clrType, cSpaceType);
                    if (oSpaceType != null)
                    {
                        Debug.Assert(!_typeFactory.CspaceToOspace.ContainsKey(cSpaceType));
                        _typeFactory.CspaceToOspace.Add(cSpaceType, oSpaceType);
                    }
                }
                else
                {
                    Debug.Assert(!(cSpaceType is EntityType || cSpaceType is ComplexType || cSpaceType is EnumType));
                }
            }

            _typeFactory.CreateRelationships(edmItemCollection);

            foreach (var resolve in _typeFactory.ReferenceResolutions)
            {
                resolve();
            }

            foreach (var edmType in _typeFactory.LoadedTypes.Values)
            {
                edmType.SetReadOnly();
            }

            objectItemCollection.AddLoadedTypes(_typeFactory.LoadedTypes);
            objectItemCollection.OSpaceTypesLoaded = true;
        }