public static T Build <T>(IPage source) where T : new()
        {
            if (source == null)
            {
                throw new ArgumentNullException();
            }

            var dest = new T();

            return((T)FieldSetMapper.Build(null, source.MetadataFields, dest, null));
        }
Exemplo n.º 2
0
        public static T Build <T>(IComponent source, IPage page = null) where T : new()
        {
            var destinationModel = new T();
            var obj = (T)FieldSetMapper.Build(source.Fields, source.MetadataFields, destinationModel, source, page);

            if (obj is IComponentBase)
            {
                obj.GetType().GetProperty("ComponentId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("Schema").SetValue(obj, source.Schema.Title, null);
            }
            return(obj);
        }
Exemplo n.º 3
0
        public static object Build(IComponent source, Type targetType, IPage page = null)
        {
            var destinationModel = Activator.CreateInstance(targetType);
            var obj = FieldSetMapper.Build(source.Fields, source.MetadataFields, destinationModel, source, page);

            if (obj is IComponentBase)
            {
                obj.GetType().GetProperty("ComponentId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("Schema").SetValue(obj, source.Schema.Title, null);
            }
            return(obj);
        }
        public static T Build <T>(IKeyword source) where T : new()
        {
            var destinationModel = new T();
            var obj = (T)FieldSetMapper.Build(source.MetadataFields, destinationModel, source);

            if (obj is IKeywordBase)
            {
                obj.GetType().GetProperty("KeywordId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("KeywordValue").SetValue(obj, source.Title, null);
                obj.GetType().GetProperty("KeywordKey").SetValue(obj, source.Key, null);
            }
            return(obj);
        }
        public static object Build(IKeyword source, Type targetType)
        {
            var destinationModel = Activator.CreateInstance(targetType);
            var obj = FieldSetMapper.Build(source.MetadataFields, destinationModel, source);

            if (obj is IKeywordBase)
            {
                obj.GetType().GetProperty("KeywordId").SetValue(obj, source.Id, null);
                obj.GetType().GetProperty("KeywordValue").SetValue(obj, source.Title, null);
                obj.GetType().GetProperty("KeywordKey").SetValue(obj, source.Key, null);
            }
            return(obj);
        }
Exemplo n.º 6
0
        internal static object Build(IFieldSet source, Type targetType, IPage page = null)
        {
            var destinationModel = Activator.CreateInstance(targetType);

            return(FieldSetMapper.Build(source, null, destinationModel, null, page));
        }