public FluentMetadataFixture()
        {
            FluentMetadataBuilder.Reset();

            try { FluentMetadataBuilder.ForAssemblyOfType<FluentMetadataFixture>(); }
            catch (Exception ex) { Exception = ex; }

            ModelMetadataProviders.Current = new FluentMetadataProvider();
        }
        private string GetPropertyDisplayName(string propertyName)
        {
            var metaData = FluentMetadataBuilder.GetTypeBuilder(currentType).MetaDataFor(propertyName);

            if (metaData != null)
            {
                propertyName = string.IsNullOrEmpty(metaData.DisplayName) ? propertyName : metaData.DisplayName;
            }
            return(propertyName);
        }
Exemple #3
0
        static string GetPropertyDisplayName(string propertyName)
        {
            var metaData = FluentMetadataBuilder.GetTypeBuilder <T>().MetaDataFor(propertyName);

            if (metaData != null)
            {
                var metaDataDisplayName = metaData.GetDisplayName();
                propertyName = string.IsNullOrEmpty(metaDataDisplayName) ?
                               propertyName :
                               metaDataDisplayName;
            }
            return(propertyName);
        }
Exemple #4
0
        private void InitPropertyMetadata()
        {
            string a;
            var    builder = FluentMetadataBuilder.GetTypeBuilder(typeof(T));

            foreach (var propertyInfo in typeof(T).GetProperties())
            {
                if (propertyInfo.GetIndexParameters().Length == 0)
                {
                    var propertyMetadata = builder.MapProperty(typeof(T), propertyInfo.Name, propertyInfo.PropertyType);
                    metadata.Properties.Add(propertyMetadata);
                }
            }
        }
Exemple #5
0
        public When_FluentMetadataBuilder_builds_metadata_copying_from_non_existing_metadata()
        {
            FluentMetadataBuilder.Reset();

            try
            {
                FluentMetadataBuilder.BuildMetadataDefinitions(
                    GetUnbuildableMetadataDefinitions());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
        }
        public When_FluentMetadataBuilder_builds_copying_metadata_with_circular_references()
        {
            FluentMetadataBuilder.Reset();

            try
            {
                FluentMetadataBuilder.BuildMetadataDefinitions(
                    GetUnbuildableMetadataDefinitions());
            }
            catch (Exception ex)
            {
                exception = ex;
            }
        }
        public When_FluentMetadataBuilder_builds_metadata_copying_from_other_metadata_that_does_not_apply()
        {
            FluentMetadataBuilder.Reset();

            try
            {
                FluentMetadataBuilder.BuildMetadataDefinitions(GetUnbuildableMetadataDefinitions());
                someViewModelRules           = QueryFluentMetadata.GetMetadataFor(typeof(SomeViewModel)).Rules;
                someViewModelMyPropertyRules = QueryFluentMetadata.GetMetadataFor(typeof(SomeViewModel), "MyProperty").Rules;
            }
            catch (Exception ex)
            {
                exception = ex;
            }
        }
Exemple #8
0
        private void InitPropertyMetadata()
        {
            var builder = FluentMetadataBuilder.GetTypeBuilder(typeof(T));

            foreach (var propertyInfo in typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                if (propertyInfo.GetIndexParameters().Length == 0)
                {
                    Metadata.Properties.Add(
                        builder.MapProperty(
                            typeof(T),
                            propertyInfo.Name,
                            propertyInfo.PropertyType));
                }
            }
        }
Exemple #9
0
 public MetadataSetup()
 {
     FluentMetadataBuilder.Reset();
     try
     {
         FluentMetadataBuilder.BuildMetadataDefinitions(
             typeof(Person).Assembly.GetTypes()
             .Where(t => t.Is <IClassMetadata>())
             .Except(When_FluentMetadataBuilder_builds_metadata_copying_from_other_metadata.GetUnbuildableMetadataDefinitions())
             .Except(When_FluentMetadataBuilder_builds_metadata_copying_from_other_metadata_that_does_not_apply.GetUnbuildableMetadataDefinitions())
             .Except(When_FluentMetadataBuilder_builds_copying_metadata_with_circular_references.GetUnbuildableMetadataDefinitions())
             .Except(When_FluentMetadataBuilder_builds_metadata_copying_from_non_existing_metadata.GetUnbuildableMetadataDefinitions()));
     }
     catch (Exception ex)
     {
         Exception = ex;
     }
 }
Exemple #10
0
        public When_copying_metadata_from_an_AutoMapped_Type()
        {
            FluentMetadataBuilder.Reset();
            Mapper.Reset();

            Mapper.Initialize(cfg =>
            {
                cfg.ShouldMapProperty = pi => true; //in order to test NonPublic member mapping as well

                cfg.CreateMap <Source, Destination>()
                .ForMember(d => d.Renamed, o => o.MapFrom(s => s.Named))
                .ForMember(d => d.IntProperty, o => o.ResolveUsing <FakeResolver, string>(s => s.StringField));
            });

            Mapper.AssertConfigurationIsValid();
            FluentMetadataBuilder.ForAssemblyOfType <Source>();

            destinationMetadata = QueryFluentMetadata.GetMetadataFor(typeof(Destination));
        }
        public When_FluentMetadataBuilder_builds_metadata_copying_from_other_metadata()
        {
            FluentMetadataBuilder.Reset();
            var typesToBuildInLaterBatch = new[] { typeof(SomeTypeInAnotherAssemblyMetadata) };

            try
            {
                FluentMetadataBuilder.BuildMetadataDefinitions(
                    GetUnbuildableMetadataDefinitions()
                    .Except(typesToBuildInLaterBatch));
                FluentMetadataBuilder.BuildMetadataDefinitions(typesToBuildInLaterBatch);
                someViewModelRules                 = QueryFluentMetadata.GetMetadataFor(typeof(SomeViewModel)).Rules;
                someViewModelMyPropertyRules       = QueryFluentMetadata.GetMetadataFor(typeof(SomeViewModel), "MyProperty").Rules;
                someViewModelMyStringPropertyRules = QueryFluentMetadata.GetMetadataFor(typeof(SomeViewModel), "MyStringProperty").Rules;
            }
            catch (Exception ex)
            {
                exception = ex;
            }
        }
Exemple #12
0
 public FluentMetadataFixture()
 {
     FluentMetadataBuilder.Reset();
     FluentMetadataBuilder.ForAssemblyOfType <FluentMetadataFixture>();
     ModelMetadataProviders.Current = Metadata;
 }
Exemple #13
0
 public FluentMetaDataConventionSpecs()
 {
     FluentMetadataBuilder.Reset();
     FluentMetadataBuilder.ForAssemblyOfType <TestClassMetadata>();
     sut = new FluentMetadataConvention();
 }
Exemple #14
0
 public MetadataSetup()
 {
     FluentMetadataBuilder.Reset();
     FluentMetadataBuilder.ForAssemblyOfType <WebUser>();
 }
Exemple #15
0
 public MetadataSetup()
 {
     FluentMetadataBuilder.Reset();
     FluentMetadataBuilder.ForAssemblyOfType <Person>();
     MetadataHelper.CopyMetadata(typeof(WebUser), typeof(WebUserIndexModel));
 }