/// <exception cref="System.IO.IOException"></exception>
        private IClassDefinition CreateNestedClassDef(IPortable portable, ClassDefinitionBuilder
                                                      nestedBuilder)
        {
            var writer = new ClassDefinitionWriter(_context, nestedBuilder);

            portable.WritePortable(writer);
            return(_context.RegisterClassDefinition(nestedBuilder.Build()));
        }
        /// <exception cref="System.IO.IOException" />
        public IClassDefinition LookupOrRegisterClassDefinition(IPortable p)
        {
            var portableVersion = PortableVersionHelper.GetVersion(p, _version);
            var cd = LookupClassDefinition(p.FactoryId, p.ClassId, portableVersion);

            if (cd == null)
            {
                var writer = new ClassDefinitionWriter(this, p.FactoryId, p.ClassId, portableVersion);
                p.WritePortable(writer);
                cd = writer.RegisterAndGet();
            }
            return(cd);
        }