コード例 #1
0
        private static IList CreateList(Type propertyType)
        {
            Type argumentType = ResolverHelper.GetArgumentType(propertyType);
            Type listType     = typeof(List <>).MakeGenericType(argumentType);

            return(Activator.CreateInstance(listType) as IList);
        }
コード例 #2
0
        public object ResolveItemFieldValue(object rawValue)
        {
            if (rawValue == null)
            {
                return(String.Empty);
            }

            var list = (IList)rawValue;

            if (list.Count == 0)
            {
                return(String.Empty);
            }

            Type argumentType = ResolverHelper.GetArgumentType(rawValue.GetType());

            IValueResolver resolver = GetInnerResolver(argumentType);

            var sb = new StringBuilder();

            foreach (object listItem in list)
            {
                sb.Append(resolver.ResolveItemFieldValue(listItem) + "|");
            }

            return(sb.ToString().Substring(0, sb.Length - 1));
        }
コード例 #3
0
        public bool CanResolve(Type type)
        {
            if (!IsNullableGenericType(type))
            {
                return(false);
            }

            Type argumentType = ResolverHelper.GetArgumentType(type);

            return(argumentType.IsValueType);
        }
コード例 #4
0
        public object ResolveEntityPropertyValue(string rawValue, Type propertyType)
        {
            Type argumentType = ResolverHelper.GetArgumentType(propertyType);
            Type nullableType = typeof(Nullable <>);

            if (!string.IsNullOrEmpty(rawValue))
            {
                object value = GetObjectValue(rawValue, argumentType);
                if (value != null)
                {
                    Type type = nullableType.MakeGenericType(argumentType);
                    return(Activator.CreateInstance(type, value));
                }
            }

            return(ResolverHelper.CreateGenericClassInstance(nullableType, argumentType));
        }
コード例 #5
0
        public object ResolveEntityPropertyValue(string rawValue, Type propertyType)
        {
            IList list = CreateList(propertyType);

            if (string.IsNullOrEmpty(rawValue))
            {
                return(list);
            }

            var delimiter = new [] { SitecoreDataAccess.Settings.ValueDelimiter };

            string[] items = rawValue.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

            Type           listArgumentType = ResolverHelper.GetArgumentType(propertyType);
            IValueResolver resolver         = GetInnerResolver(listArgumentType);

            foreach (string item in items)
            {
                list.Add(resolver.ResolveEntityPropertyValue(item, listArgumentType));
            }

            return(list);
        }
コード例 #6
0
        private static bool IsGenericParameterOfTypeNotAssignableToISitecoreDomainEnitity(Type propertyType)
        {
            Type argumentType = ResolverHelper.GetArgumentType(propertyType);

            return(!typeof(ISitecoreDomainEntity).IsAssignableFrom(argumentType));
        }