Building Module problem - ContentBaseMetadataSource construc

Posted by Community Admin on 04-Aug-2018 09:25

Building Module problem - ContentBaseMetadataSource constructor issue

All Replies

Posted by Community Admin on 01-Jul-2011 00:00

Hi,

I have been working through a tutorial in creating content based modules for an Email module, I have found myself stuck with the following code which is in the moduleFluentMetadataSources.cs file:

namespace Cinema.Model
    public class CinemaFluentMetadataSource : ContentBaseMetadataSource
    
        public CinemaFluentMetadataSource() : base()
         
        public CinemaFluentMetadataSource(IDatabaseMappingContext context) : base(context)
         
        protected override IList<IOpenAccessFluentMapping> BuildCustomMappings()
        
            var sitefinityMappings = base.BuildCustomMappings();
            sitefinityMappings.Add(new CinemaFluentMapping(this.Context));
            return sitefinityMappings;
        
    

I am receiving a build error with the line:

public CinemaFluentMetadataSource() : base()

The error is found in the "base()" constructor:

'Telerik.Sitefinity.Modules.GenericContent.Data.ContentBaseMetadataSource' does not contain a constructor that takes 0 arguments C:\VisualProjects\MyProject\EmailModule\Model\EmailFluentMetadataSource.cs

Now I have looked into the definition which is the ContentBaseMetadataSource class and noticed this is commented as using assembly Telerik.Sitefinity.dll, v4.0.30319, which is strange as all my projects are using v4.1.1395.0.

So my question is, was this ContentBaseMetadataSource constructor added in 4.1 and if so how can I refresh the class to use the correct dll which is in the project.

Thanks in advance of any help!


Posted by Community Admin on 05-Jul-2011 00:00

Hello Andrew,

Please, implement your MetaDataSource like in the Products sample, by providing parameterless constructor that calls the base constructor with null. The parameterless constructor is needed for the OA enhancer - it looks into the assembly using reflection for MetaDataSoruces with public parameterless constructors and than executes the mapping in order to get information which classes and properties to enhance. The ContentBaseMetadataSource doesn't have empty constructor since it shouldn't be considered during enhancing -> it is just a helper metadata source combining the necessary fluent mappings for Content based providers.  Another reason to change this is was not to forget to implement a constructor with a call to the base constructor with the context parameter - since this is very important for the correct functioning for different backend databases.

    public class ProductsFluentMetadataSource : ContentBaseMetadataSource
   
        #region Construction

        public ProductsFluentMetadataSource()
            : base(null)
       

        public ProductsFluentMetadataSource(IDatabaseMappingContext context)
            : base(context)
       

       



Regards,
Ivan Dimitrov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed