コード例 #1
0
        protected virtual bool ResolveRedirects(FtMetaSequenceItem item, FtMetaSequenceList sequenceList, out string errorDescription)
        {
            RedirectSorter.Rec[]          sorterRecArray = new RedirectSorter.Rec[redirectList.Count];
            SequenceRedirectReadElement[] sortedElements;

            for (int i = 0; i < redirectList.Count; i++)
            {
                SequenceRedirectReadElement element = redirectList[i];

                sorterRecArray[i].Target   = element;
                sorterRecArray[i].Implicit = i;
                sorterRecArray[i].Explicit = element.ExplicitIndex;
            }

            int duplicateExplicitIndex;

            if (!RedirectSorter.TrySort(sorterRecArray, out sortedElements, out duplicateExplicitIndex))
            {
                errorDescription = string.Format(Properties.Resources.SequenceItemReadElement_ResolveRedirects_DuplicateExplicitIndex, duplicateExplicitIndex);
                return(false);
            }
            else
            {
                errorDescription = "";
                bool result = true;

                for (int i = 0; i < sortedElements.Length; i++)
                {
                    SequenceRedirectReadElement element = sortedElements[i];
                    int redirectType;
                    if (element.RedirectType == FtStandardSequenceRedirectType.Unknown)
                    {
                        redirectType = item.Field.DefaultSequenceRedirectType;
                    }
                    else
                    {
                        redirectType = element.RedirectType;
                    }
                    FtMetaSequenceRedirect redirect = item.RedirectList.New(redirectType);
                    if (!element.ResolveTo(redirect, sequenceList, out errorDescription))
                    {
                        result = false;
                        break;
                    }
                }

                return(result);
            }
        }
コード例 #2
0
        internal protected override bool TryCreate(MetaElementType elementType, out ReadElement element)
        {
            switch (elementType)
            {
            case MetaElementType.SequenceRedirect:
                SequenceRedirectReadElement redirectReadElement = new SequenceRedirectReadElement();
                redirectList.Add(redirectReadElement);
                element = redirectReadElement;
                return(true);

            default:
                element = null;
                return(false);
            }
        }