Esempio n. 1
0
 public DataTypeSerializer(IEntityService entityService, ILogger <DataTypeSerializer> logger,
                           IDataTypeService dataTypeService,
                           DataEditorCollection dataEditors,
                           ConfigurationSerializerCollection configurationSerializers,
                           PropertyEditorCollection propertyEditors,
                           IConfigurationEditorJsonSerializer jsonSerializer)
     : base(entityService, logger, UmbracoObjectTypes.DataTypeContainer)
 {
     this.dataTypeService          = dataTypeService;
     this.dataEditors              = dataEditors;
     this.configurationSerializers = configurationSerializers;
     this.propertyEditors          = propertyEditors;
     this.jsonSerializer           = jsonSerializer;
 }
Esempio n. 2
0
 public ParameterEditorCollection(DataEditorCollection dataEditors, IManifestParser manifestParser)
     : base(() => dataEditors
            .Where(x => (x.Type & EditorType.MacroParameter) > 0)
            .Union(manifestParser.CombinedManifest.PropertyEditors))
 {
 }
Esempio n. 3
0
 public PropertyEditorCollection(DataEditorCollection dataEditors)
     : base(() => dataEditors
            .Where(x => (x.Type & EditorType.PropertyValue) > 0))
 {
 }
Esempio n. 4
0
        public void SetUp()
        {
            // annoying, but content type wants short string helper ;(
            SettingsForTests.Reset();

            // well, this is also annoying, but...
            // validating a value is performed by its data editor,
            // based upon the configuration in the data type, so we
            // need to be able to retrieve them all...

            Current.Reset();

            var configs = new Configs();

            configs.Add(SettingsForTests.GetDefaultGlobalSettings);
            configs.Add(SettingsForTests.GetDefaultUmbracoSettings);

            var factory = Mock.Of <IFactory>();

            Current.Factory = factory;

            var dataEditors = new DataEditorCollection(new IDataEditor[]
            {
                new DataEditor(Mock.Of <ILogger>())
                {
                    Alias = "editor", ExplicitValueEditor = new DataValueEditor("view")
                }
            });
            var propertyEditors = new PropertyEditorCollection(dataEditors);

            var dataType = Mock.Of <IDataType>();

            Mock.Get(dataType)
            .Setup(x => x.Configuration)
            .Returns(null);

            var dataTypeService = Mock.Of <IDataTypeService>();

            Mock.Get(dataTypeService)
            .Setup(x => x.GetDataType(It.IsAny <int>()))
            .Returns <int>(x => dataType);

            var serviceContext = ServiceContext.CreatePartial(
                dataTypeService: dataTypeService,
                localizedTextService: Mock.Of <ILocalizedTextService>());

            Mock.Get(factory)
            .Setup(x => x.GetInstance(It.IsAny <Type>()))
            .Returns <Type>(x =>
            {
                if (x == typeof(Configs))
                {
                    return(configs);
                }
                if (x == typeof(PropertyEditorCollection))
                {
                    return(propertyEditors);
                }
                if (x == typeof(ServiceContext))
                {
                    return(serviceContext);
                }
                if (x == typeof(ILocalizedTextService))
                {
                    return(serviceContext.LocalizationService);
                }
                throw new NotSupportedException(x.FullName);
            });
        }