BExIS.Xml.Helpers.Mapping.XmlMapperManager.mapInternPathToExternPathWithIndex C# (CSharp) Method

mapInternPathToExternPathWithIndex() private method

private mapInternPathToExternPathWithIndex ( string source, string destination ) : string
source string
destination string
return string
        private string mapInternPathToExternPathWithIndex(string source, string destination)
        {
            //SOURCE
            // X[1]\XType[2]\Y[1]\yType[4]\F[1]\FType[2]\
            //DESTINATION
            // x[1]\y[2]\f[1]

            string[] sourceSplitWidthIndex = source.Split('/');

            // XFType[2]\F[1]\yType[4]\Y[1]\XType[2]\x[1]
            Array.Reverse(sourceSplitWidthIndex);

            string[] destinationSplit = destination.Split('/');

            // XFType\F\yType\Y\XType\x
            Array.Reverse(destinationSplit);
            int j = 0;
            for (int i = 0; i < sourceSplitWidthIndex.Length; i=i+2)
            {

                string tmp = sourceSplitWidthIndex[i];

                if (tmp.Contains("["))
                {
                    string tmpIndex = tmp.Split('[')[1];
                    string index = tmpIndex.Remove(tmpIndex.IndexOf(']'));

                    //set to destination array

                    //set j
                    if (i == 0) j = 0;
                    else if (i == 1) j = i + 1;
                    else j = i / 2;

                    if (destinationSplit.Length >= j)
                    {
                        string destinationTemp = destinationSplit[j];
                        destinationSplit[j] = destinationTemp + "[" + index + "]";
                        ////set parent
                        //string destinationTempParent = destinationSplit[j + 1];
                        //destinationSplit[j + 1] = destinationTempParent + "[" + 1 + "]";
                    }
                }
            }

            Array.Reverse(destinationSplit);

            // f[1]\y[2]\x[1]
            return String.Join("/", destinationSplit); ;
        }