Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectExtension"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        public ObjectExtensionPropertyInfo(
            ObjectExtensionInfo objectExtension,
            Type type,
            string name)
        {
            ObjectExtension = Check.NotNull(objectExtension, nameof(objectExtension));
            Type            = Check.NotNull(type, nameof(type));
            Name            = Check.NotNull(name, nameof(name));

            Configuration = new Dictionary <object, object>();
            Attributes    = new List <Attribute>();

            Attributes.AddRange(ExtensionPropertyHelper.GetDefaultAttributes(Type));
            DefaultValue = TypeHelper.GetDefaultValue(Type);
        }
Exemple #2
0
        private static bool CanMapProperty(
            string propertyName,
            ObjectExtensionInfo sourceObjectExtension,
            ObjectExtensionInfo destinationObjectExtension,
            MappingPropertyDefinitionChecks?definitionChecks = null,
            string[] ignoredProperties = null)
        {
            Check.NotNull(propertyName, nameof(propertyName));

            if (ignoredProperties != null &&
                ignoredProperties.Contains(propertyName))
            {
                return(false);
            }

            if (definitionChecks != null)
            {
                if (definitionChecks.Value.HasFlag(MappingPropertyDefinitionChecks.Source))
                {
                    if (sourceObjectExtension == null)
                    {
                        return(false);
                    }

                    if (!sourceObjectExtension.HasProperty(propertyName))
                    {
                        return(false);
                    }
                }

                if (definitionChecks.Value.HasFlag(MappingPropertyDefinitionChecks.Destination))
                {
                    if (destinationObjectExtension == null)
                    {
                        return(false);
                    }

                    if (!destinationObjectExtension.HasProperty(propertyName))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            else
            {
                var sourcePropertyDefinition      = sourceObjectExtension?.GetPropertyOrNull(propertyName);
                var destinationPropertyDefinition = destinationObjectExtension?.GetPropertyOrNull(propertyName);

                if (sourcePropertyDefinition != null)
                {
                    if (destinationPropertyDefinition != null)
                    {
                        return(true);
                    }

                    if (sourcePropertyDefinition.CheckPairDefinitionOnMapping == false)
                    {
                        return(true);
                    }
                }
                else if (destinationPropertyDefinition != null)
                {
                    if (destinationPropertyDefinition.CheckPairDefinitionOnMapping == false)
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }