private RawDataSourceInfoBase ConvertDataTemplateContextToCollectionItem(DataBindingProcessingContext context, RawDataSourceInfoBase dataSource)
        {
            RawDataSourceInfo normalizedDataSource = context.RootContext.DataContext.NormalizedDataSource;

            if (dataSource.SourceNode != normalizedDataSource.SourceNode)
            {
                return((RawDataSourceInfoBase)null);
            }
            string inheritedPath = normalizedDataSource.NormalizedClrPath ?? string.Empty;
            string str           = dataSource.NormalizedClrPath ?? string.Empty;

            if (!str.StartsWith(inheritedPath, StringComparison.Ordinal))
            {
                return((RawDataSourceInfoBase)null);
            }
            string localPath = string.Empty;

            if (str.Length > inheritedPath.Length)
            {
                switch (str[inheritedPath.Length])
                {
                case '[':
                    localPath = str.Substring(inheritedPath.Length);
                    break;

                case '.':
                case '/':
                    localPath = str.Substring(inheritedPath.Length + 1);
                    break;

                default:
                    return((RawDataSourceInfoBase)null);
                }
            }
            string clrPath = ClrPropertyPathHelper.CombinePaths(ClrPropertyPathHelper.CombinePaths(inheritedPath, DataSchemaNode.IndexNodePath), localPath);

            return((RawDataSourceInfoBase) new RawDataSourceInfo(dataSource.SourceNode, clrPath));
        }
        private PathChangeInfo GetPathChange(IType sourceType, string normalizedClrPath, string clrPath, bool preservePropertyName)
        {
            if (string.IsNullOrEmpty(clrPath))
            {
                return((PathChangeInfo)null);
            }
            PathChangeInfo pathChangeInfo = new PathChangeInfo();

            pathChangeInfo.TargetType = sourceType;
            pathChangeInfo.OldPath    = clrPath;
            pathChangeInfo.NewPath    = string.Empty;
            IList <ClrPathPart> parts = ClrPropertyPathHelper.SplitPath(normalizedClrPath);

            if (parts == null)
            {
                return((PathChangeInfo)null);
            }
            bool flag = false;

            for (int index = 0; index < parts.Count; ++index)
            {
                ClrPathPart clrPathPart = parts[index];
                IType       targetType  = pathChangeInfo.TargetType;
                IType       type;
                if (clrPathPart.Category == ClrPathPartCategory.CurrentItem || clrPathPart.Category == ClrPathPartCategory.IndexStep)
                {
                    type = targetType.ItemType;
                }
                else
                {
                    IProperty property = this.VerifyPropertyName(clrPathPart.Path, targetType);
                    if (property == null)
                    {
                        type = (IType)null;
                    }
                    else
                    {
                        type = property.PropertyType;
                        if (property.Name != clrPathPart.Path)
                        {
                            flag = true;
                            clrPathPart.NewPath = property.Name;
                        }
                    }
                }
                pathChangeInfo.TargetType = type;
                if (type == null)
                {
                    pathChangeInfo.BreakingChange = true;
                    break;
                }
            }
            if (pathChangeInfo.BreakingChange)
            {
                return(pathChangeInfo);
            }
            if (!flag)
            {
                return((PathChangeInfo)null);
            }
            if (preservePropertyName)
            {
                string[] strArray      = ClrPropertyPathHelper.SplitAtFirstProperty(clrPath);
                string   inheritedPath = strArray[0];
                int      pathPartCount = ClrPropertyPathHelper.GetPathPartCount(strArray[1]);
                string   localPath     = ClrPropertyPathHelper.CombinePathParts(parts, parts.Count - pathPartCount);
                pathChangeInfo.NewPath = ClrPropertyPathHelper.CombinePaths(inheritedPath, localPath);
            }
            else
            {
                int pathPartCount = ClrPropertyPathHelper.GetPathPartCount(clrPath);
                pathChangeInfo.NewPath = ClrPropertyPathHelper.CombinePathParts(parts, parts.Count - pathPartCount);
            }
            return(pathChangeInfo);
        }