Example #1
0
    private ContentBase(string?name, IContentTypeComposition?contentType, IPropertyCollection properties, string?culture = null)
    {
        ContentType = contentType?.ToSimple() ?? throw new ArgumentNullException(nameof(contentType));

        // initially, all new instances have
        Id        = 0; // no identity
        VersionId = 0; // no versions

        SetCultureName(name, culture);

        _contentTypeId = contentType.Id;
        _properties    = properties ?? throw new ArgumentNullException(nameof(properties));
        _properties.EnsurePropertyTypes(contentType.CompositionPropertyTypes);

        // track all property types on this content type, these can never change during the lifetime of this single instance
        // there is no real extra memory overhead of doing this since these property types are already cached on this object via the
        // properties already.
        AllPropertyTypes = new List <IPropertyType>(contentType.CompositionPropertyTypes);
    }