Represents the configuration for a property on a .Net type
コード例 #1
0
 protected override void Copy(AbstractPropertyConfiguration copy)
 {
     var config = copy as SitecoreInfoConfiguration;
     config.Type = Type;
     config.UrlOptions = UrlOptions;
     config.MediaUrlOptions = MediaUrlOptions;
     base.Copy(copy);
 }
コード例 #2
0
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as IdConfiguration;

            config.Type = Type;

            base.Copy(copy);
        }
コード例 #3
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if(_properties.Any(x=>x.PropertyInfo.Name == property.PropertyInfo.Name))
                throw new MapperException("You can not have duplicate mappings for properties. Property Name: {0}  Type: {0}".Formatted(property.PropertyInfo.Name, this.Type.Name));

            if(property != null)
                _properties.Add(property);
        }
コード例 #4
0
        protected override void Copy(AbstractPropertyConfiguration copy)
        {
            var config = copy as SitecoreDelegateConfiguration;

            config.MapToCmsAction = MapToCmsAction;
            config.MapToPropertyAction = MapToPropertyAction;

            base.Copy(copy);
        }
コード例 #5
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;
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (_properties.Any(x => x.PropertyInfo.Name == property.PropertyInfo.Name))
            {
                throw new MapperException("You can not have duplicate mappings for properties. Property Name: {0}  Type: {0}".Formatted(property.PropertyInfo.Name, Type.Name));
            }

            if (property != null)
            {
                _properties.Add(property);
            }
        }
コード例 #8
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property != null)
            {
                var currentProperty = _properties.FirstOrDefault(x => x.PropertyInfo.Name == property.PropertyInfo.Name);
                if (currentProperty != null)
                {
                    _properties.Remove(currentProperty);
                }


                _properties.Add(property);
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property != null)
            {
                if (_properties.Any(x => x.PropertyInfo.Name == property.PropertyInfo.Name))
                {
                    throw new MapperException(
                              "You cannot have duplicate mappings for properties. Property Name: {0}  Type: {0}".Formatted(
                                  property.PropertyInfo.Name, Type.Name));
                }


                _properties = _properties.Concat(new[] { property }).ToArray();
                _propertMappingExpression = CreatePropertyExpression(property);
            }
        }
コード例 #10
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 && infoProperty.Type == SitecoreInfoType.Language)
                LanguageConfig = infoProperty;
            else if (infoProperty != null && infoProperty.Type == SitecoreInfoType.Version)
                VersionConfig = infoProperty;



            base.AddProperty(property);
        }
コード例 #11
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property != null)
            {
                var key = property.PropertyInfo.Name;

                if (property.PropertyInfo.GetMethod != null && property.PropertyInfo.GetMethod.IsPrivate)
                {
                    _privateProperties[key] = property;
                }
                else
                {
                    _properties[key] = property;
                }
            }
        }
コード例 #12
0
        protected virtual Action <object, AbstractDataMappingContext> CreatePropertyExpression(
            AbstractPropertyConfiguration property)
        {
            var next = _propertMappingExpression;

            return((obj, context) =>
            {
                try
                {
                    property.Mapper.MapCmsToProperty(context);
                }
                catch (Exception e)
                {
                    throw new MapperException(
                        "Failed to map property {0} on {1}".Formatted(property.PropertyInfo.Name,
                                                                      property.PropertyInfo.DeclaringType.FullName), e);
                }
                next(obj, context);
            });
        }
コード例 #13
0
        /// <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<,>)));
        }
コード例 #14
0
 protected override void Copy(AbstractPropertyConfiguration copy)
 {
     var config = copy as SitecoreNodeConfiguration;
    
     base.Copy(copy);
 }
コード例 #15
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property != null)
            {

                var currentProperty = _properties.FirstOrDefault(x => x.PropertyInfo.Name == property.PropertyInfo.Name);
                if (currentProperty != null)
                {
                    _properties.Remove(currentProperty);
                }


                _properties.Add(property);

            }
        }
コード例 #16
0
 protected virtual void Copy(AbstractPropertyConfiguration copy)
 {
     copy.PropertyInfo = PropertyInfo;
 }
コード例 #17
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
 protected override void Copy(AbstractPropertyConfiguration copy)
 {
     var config = copy as UmbracoIdConfiguration;
     base.Copy(copy);
 }
コード例 #19
0
        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;
            }
        }
コード例 #20
0
 protected virtual void Copy(AbstractPropertyConfiguration copy)
 {
     copy.PropertyInfo = PropertyInfo;
 }
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return false;
 }
コード例 #22
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)
            {
                switch (infoProperty.Type)
                {
                    case SitecoreInfoType.Language:
                        LanguageConfig = infoProperty;
                        break;
                    case SitecoreInfoType.Version:
                        VersionConfig = infoProperty;
                        break;
                    case SitecoreInfoType.ItemUri:
                        ItemUriConfig = infoProperty;
                        break;
                }
            }

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

            base.AddProperty(property);
        }
コード例 #23
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);
コード例 #24
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return configuration is SitecoreItemConfiguration && configuration.PropertyInfo.PropertyType == typeof (Item);
 }
コード例 #25
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)
        {
            if (!(configuration is SitecoreQueryConfiguration)) return false;

            if (configuration.PropertyInfo.PropertyType.IsGenericType)
            {

                Type outerType = Utilities.GetGenericOuter(configuration.PropertyInfo.PropertyType);
                Type innerType = 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);
            }
        }
コード例 #26
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 SitecoreNodeConfiguration;// && context.TypeConfigurations.ContainsKey(configuration.PropertyInfo.PropertyType);
 }
コード例 #27
0
 protected override void Copy(AbstractPropertyConfiguration copy)
 {
     var config = copy as SitecoreLinkedConfiguration;
     config.Option = Option;
     base.Copy(copy);
 }
コード例 #28
0
 protected override void Copy(AbstractPropertyConfiguration copy)
 {
     var config = copy as SitecoreQueryConfiguration;
     config.UseQueryContext = UseQueryContext;
     base.Copy(copy);
 }
コード例 #29
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return configuration is UmbracoDelegateConfiguration;
 }
コード例 #30
0
 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);
 }
コード例 #31
0
 public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
 {
     return configuration is SitecoreSelfConfiguration;
 }
コード例 #32
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;
 }
コード例 #33
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)
        {
            if (!(configuration is SitecoreLinkedConfiguration))
                return false;

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

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

            return typeof (IEnumerable<>) == outerType;// && context.TypeConfigurations.ContainsKey(innerType);
        }
コード例 #34
0
        protected virtual Action<object, AbstractDataMappingContext> CreatePropertyExpression(
            AbstractPropertyConfiguration property)
        {
            var next = _propertMappingExpression;

            return (obj, context) =>
                {
                    try
                    {
                        property.Mapper.MapCmsToProperty(context);
                    }
                    catch (Exception e)
                    {
                        throw new MapperException(
                            "Failed to map property {0} on {1}".Formatted(property.PropertyInfo.Name,
                                property.PropertyInfo.DeclaringType.FullName), e);
                    }
                    next(obj, context);
                };
        }
コード例 #35
0
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            var underlyingType = Nullable.GetUnderlyingType(configuration.PropertyInfo.PropertyType);

            return underlyingType != null && underlyingType.IsEnum;
        }
コード例 #36
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public virtual void AddProperty(AbstractPropertyConfiguration property)
        {
            if (property != null)
            {
                if (_properties.Any(x => x.PropertyInfo.Name == property.PropertyInfo.Name))
                {
                    throw new MapperException(
                        "You cannot have duplicate mappings for properties. Property Name: {0}  Type: {1}".Formatted(
                            property.PropertyInfo.Name, Type.Name));
                }


                _properties = _properties.Concat(new[] {property}).ToArray();
                _propertMappingExpression = CreatePropertyExpression(property);
            }
        }