Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Programmatically read the type of a property in a datatype

$
0
0
Thx napernik for your reply!

I now have the following code in my razor function file:
@using CompositeC1Contrib.RazorFunctions;
@using CompositeC1Contrib.RazorFunctions.FunctionProvider;
@using CompositeC1Contrib.RazorFunctions.Html;
@using Composite.Data;
@using Composite.Data.Types;
@using System.Linq;

@inherits CompositeC1WebPage

@{
    
            var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(typeof (IPage));
            foreach( var field in dataTypeDescriptor.Fields)
            {
                if (!field.Inherited)
                {
                    OutPut(field.Name + " " + field.InstanceType);

                    if(field.InstanceType == typeof(string))
                    {
                        OutPut("Max length " + field.StoreType.MaximumLength);
                    }
                }
            }   
    
}
But, I get the error " error CS0103: The name 'DynamicTypeManager' does not exist in the current context". Am i missing a reference in the using section?

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>