protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as FieldConfiguration;

            config.ReadOnly = ReadOnly;

            base.Copy(copy);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as LinkedConfiguration;

            config.IsLazy = IsLazy;
            config.InferType = InferType;

            base.Copy(copy);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as QueryConfiguration;

            config.Query = Query;
            config.IsLazy = IsLazy;
            config.IsRelative = IsRelative;
            config.InferType = InferType;

            base.Copy(copy);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as NodeConfiguration;

            config.Id = Id;
            config.IsLazy = IsLazy;
            config.Path = Path;
            config.InferType = InferType;

            base.Copy(copy);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as NodeConfiguration;

            config.Id        = Id;
            config.IsLazy    = IsLazy;
            config.Path      = Path;
            config.InferType = InferType;

            base.Copy(copy);
        }
        /// <summary>
        /// Determines whether this instance can handle the specified configuration.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            var fieldConfiguration = configuration as SitecoreFieldConfiguration;

            if (fieldConfiguration == null)
            {
                return(false);
            }

            Type propertyType = fieldConfiguration.PropertyInfo.PropertyType;

            return(propertyType.IsGenericType && (!(propertyType.GetGenericTypeDefinition() != typeof(IDictionary <,>))));
        }
示例#7
0
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            var scConfig = configuration as SitecoreInfoConfiguration;

            if (scConfig == null)
            {
                return(false);
            }

            Type type = scConfig.PropertyInfo.PropertyType;

            return(typeof(IEnumerable) == type);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as UmbracoPropertyConfiguration;

            config.CodeFirst           = this.CodeFirst;
            config.PropertyAlias       = this.PropertyAlias;
            config.PropertyDescription = this.PropertyDescription;
            config.ContentTab          = this.ContentTab;
            config.PropertyIsMandatory = this.PropertyIsMandatory;
            config.PropertyName        = this.PropertyName;
            config.PropertyValidation  = this.PropertyValidation;
            config.PropertyType        = this.PropertyType;
            config.Setting             = this.Setting;
            base.Copy(copy);
        }
        private void LoadValue(AbstractPropertyConfiguration propertyConfiguration)
        {
            if (_mapRequested == false)
            {
                _mapRequested = true;
                _args.Counters.ModelsMapped++;
            }

            if (!Values.ContainsKey(propertyConfiguration.PropertyInfo.Name))
            {
                var result = propertyConfiguration.Mapper.MapToProperty(_mappingContext) ??
                             Utilities.GetDefault(propertyConfiguration.PropertyInfo.PropertyType);
                Values[propertyConfiguration.PropertyInfo.Name] = result;
            }
        }
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public override void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property is UmbracoIdConfiguration)
            {
                IdConfig = property as UmbracoIdConfiguration;
            }

            var infoProperty = property as UmbracoInfoConfiguration;

            if (infoProperty != null && infoProperty.Type == UmbracoInfoType.Version)
            {
                VersionConfig = infoProperty;
            }

            base.AddProperty(property);
        }
        /// <summary>
        /// Indicates that the data mapper will mapper to and from the property
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            if (!(configuration is SitecoreLinkedConfiguration))
            {
                return(false);
            }

            if (!configuration.PropertyInfo.PropertyType.IsGenericType)
            {
                return(false);
            }

            Type outerType = Utilities.GetGenericOuter(configuration.PropertyInfo.PropertyType);

            return(typeof(IEnumerable <>) == outerType);// && context.TypeConfigurations.ContainsKey(innerType);
        }
示例#12
0
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            Type type = configuration.PropertyInfo.PropertyType;

            if (!type.IsGenericType)
            {
                return(false);
            }

            if (type.GetGenericTypeDefinition() != typeof(GlassLazy <>))
            {
                return(false);
            }

            return(true);
        }
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as SitecoreFieldConfiguration;

            config.CodeFirst       = this.CodeFirst;
            config.FieldId         = this.FieldId;
            config.FieldName       = this.FieldName;
            config.FieldSource     = this.FieldSource;
            config.FieldTitle      = this.FieldTitle;
            config.FieldType       = this.FieldType;
            config.IsShared        = this.IsShared;
            config.IsUnversioned   = this.IsUnversioned;
            config.SectionName     = this.SectionName;
            config.Setting         = this.Setting;
            config.CustomFieldType = this.CustomFieldType;
            base.Copy(copy);
        }
示例#14
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public override void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property is SitecoreIdConfiguration)
            {
                IdConfig = property as SitecoreIdConfiguration;
            }

            var infoProperty = property as SitecoreInfoConfiguration;

            if (infoProperty != null)
            {
                AssignInfoToKnownProperty(this, infoProperty);
            }

            if (property is SitecoreItemConfiguration)
            {
                ItemConfig = property as SitecoreItemConfiguration;
            }

            base.AddProperty(property);
        }
        /// <summary>
        /// Indicates that the data mapper will mapper to and from the property
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            if (!(configuration is SitecoreQueryConfiguration))
            {
                return(false);
            }

            if (configuration.PropertyInfo.PropertyType.IsGenericType)
            {
                Type outerType = Utilities.GetGenericOuter(configuration.PropertyInfo.PropertyType);
                Type innerType = Mapper.Utilities.GetGenericArgument(configuration.PropertyInfo.PropertyType);

                return(typeof(IEnumerable <>) == outerType);// && context.TypeConfigurations.ContainsKey(innerType);
            }
            else
            {
                //We are now assuming auto-mapping works
                return(true);
                //return context.TypeConfigurations.ContainsKey(configuration.PropertyInfo.PropertyType);
            }
        }
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public override void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property is SitecoreIdConfiguration)
            {
                IdConfig = property as SitecoreIdConfiguration;
            }

            var infoProperty = property as SitecoreInfoConfiguration;

            if (infoProperty != null && infoProperty.Type == SitecoreInfoType.Language)
            {
                LanguageConfig = infoProperty;
            }
            else if (infoProperty != null && infoProperty.Type == SitecoreInfoType.Version)
            {
                VersionConfig = infoProperty;
            }



            base.AddProperty(property);
        }
        public void AutoMapProperties_InterfaceSomeStaticallyMapped_AutoMapsAllProperties()
        {
            //Assign
            _configuration.Type    = typeof(IStubInterface);
            _configuration.AutoMap = true;

            Assert.AreEqual(0, _configuration.Properties.Count());

            AbstractPropertyConfiguration property1 = Substitute.For <AbstractPropertyConfiguration>();

            property1.PropertyInfo = _configuration.Type.GetProperty("Prop1");
            AbstractPropertyConfiguration property2 = Substitute.For <AbstractPropertyConfiguration>();

            property2.PropertyInfo = _configuration.Type.GetProperty("Prop2");

            _configuration.AddProperty(property1);
            _configuration.AddProperty(property2);

            //Act
            _configuration.PerformAutoMap();

            //Assert
            Assert.AreEqual(5, _configuration.Properties.Count());
        }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <param name="config">The config.</param>
 public void Configure(PropertyInfo propertyInfo, AbstractPropertyConfiguration config)
 {
     config.PropertyInfo = propertyInfo;
 }
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(configuration is SitecoreChildrenConfiguration &&
            configuration.PropertyInfo.PropertyType == typeof(ChildrenCast));
 }
示例#20
0
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as UmbracoDelegateConfiguration;

            base.Copy(copy);
        }
示例#21
0
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            var underlyingType = Nullable.GetUnderlyingType(configuration.PropertyInfo.PropertyType);

            return(underlyingType != null && underlyingType.IsEnum);
        }
示例#22
0
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as SitecoreIdConfiguration;

            base.Copy(copy);
        }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <param name="config">The config.</param>
 public void Configure(PropertyInfo propertyInfo, AbstractPropertyConfiguration config)
 {
     config.PropertyInfo = propertyInfo;
 }
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     throw new NotImplementedException();
 }
示例#25
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(false);
 }
 /// <summary>
 /// Indicates that the data mapper will mapper to and from the property
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="context">The context.</param>
 /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(configuration is SitecoreNodeConfiguration);// && context.TypeConfigurations.ContainsKey(configuration.PropertyInfo.PropertyType);
 }
示例#27
0
 /// <summary>
 /// Sets up the data mapper for a particular property
 /// </summary>
 /// <param name="args">The args.</param>
 public virtual void Setup(DataMapperResolverArgs args)
 {
     Configuration = args.PropertyConfiguration;
 }
示例#28
0
 /// <summary>
 /// Indicates that the data mapper will mapper to and from the property
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="context">The context.</param>
 /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
 public abstract bool CanHandle(AbstractPropertyConfiguration configuration, Context context);
 protected virtual bool ValidProperty(AbstractPropertyConfiguration property)
 {
     return(property != null && property.Ignore == false && property.PropertyInfo.CanWrite);
 }
示例#30
0
 /// <summary>
 /// Indicates that the data mapper will mapper to and from the property
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="context">The context.</param>
 /// <returns><c>true</c> if this instance can handle the specified configuration; otherwise, <c>false</c>.</returns>
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(configuration is SitecoreInfoConfiguration);
 }
示例#31
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(CanHandleFunction(configuration));
 }
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return(configuration is UmbracoDelegateConfiguration);
 }