当前位置: 首页>>代码示例>>C#>>正文


C# QilNode.DeepClone方法代码示例

本文整理汇总了C#中QilNode.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# QilNode.DeepClone方法的具体用法?C# QilNode.DeepClone怎么用?C# QilNode.DeepClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QilNode的用法示例。


在下文中一共展示了QilNode.DeepClone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PlaceMarker

        private QilNode PlaceMarker(QilNode countPattern, QilNode fromPattern, bool multiple)
        {
            /*
                Quotation from XSLT 2.0 spec:
                * Let $A be the node sequence selected by the expression
                    ancestor-or-self::node()[matches-count(.)]          (level = "multiple")
                    ancestor-or-self::node()[matches-count(.)][1]       (level = "single")
                * Let $F be the node sequence selected by the expression
                    ancestor-or-self::node()[matches-from(.)][1]
                * Let $AF be the value of
                    $A intersect ($F/descendant-or-self::node())
                * Return the result of the expression
                    for $af in $AF return 1+count($af/preceding-sibling::node()[matches-count(.)])

                NOTE: There are some distinctions between XSLT 1.0 and XSLT 2.0 specs. In our 1.0 implementation we:
                1) Assume that the 'matches-from()' function does not match root nodes by default.
                2) Instead of '$A intersect ($F/descendant-or-self::node())' (which, by the way,
                   would filter out attribute and namespace nodes from $A) we calculate
                     '$A'           if the 'from' attribute is omitted,
                     '$A[. >> $F]'  if the 'from' attribute is present.
            */

            QilNode countPattern2, countMatches, fromMatches, A, F, AF;
            QilIterator i, j;

            countPattern2 = (countPattern != null) ? countPattern.DeepClone(_f.BaseFactory) : null;
            countMatches = _f.Filter(i = _f.For(_f.AncestorOrSelf(GetCurrentNode())), MatchCountPattern(countPattern, i));
            if (multiple)
            {
                A = _f.DocOrderDistinct(countMatches);
            }
            else
            {
                A = _f.Filter(i = _f.For(countMatches), _f.Eq(_f.PositionOf(i), _f.Int32(1)));
            }

            if (fromPattern == null)
            {
                AF = A;
            }
            else
            {
                fromMatches = _f.Filter(i = _f.For(_f.AncestorOrSelf(GetCurrentNode())), MatchPattern(fromPattern, i));
                F = _f.Filter(i = _f.For(fromMatches), _f.Eq(_f.PositionOf(i), _f.Int32(1)));
                AF = _f.Loop(i = _f.For(F), _f.Filter(j = _f.For(A), _f.Before(i, j)));
            }

            return _f.Loop(j = _f.For(AF),
                _f.Add(_f.Int32(1), _f.Length(_f.Filter(i = _f.For(_f.PrecedingSibling(j)), MatchCountPattern(countPattern2, i))))
            );
        }
开发者ID:Corillian,项目名称:corefx,代码行数:51,代码来源:QilGenerator.cs

示例2: CompileDataTypeAttribute

        private void CompileDataTypeAttribute(string attValue, bool fwdCompat, ref QilNode select, out QilNode select2)
        {
            const string DtText = "text";
            const string DtNumber = "number";
            QilNode result = CompileStringAvt(attValue);
            if (result != null)
            {
                if (result.NodeType == QilNodeType.LiteralString)
                {
                    string dataType = (string)(QilLiteral)result;
                    if (dataType == DtNumber)
                    {
                        select = _f.ConvertToNumber(select);
                        select2 = null;
                        return;
                    }
                    else if (dataType == DtText)
                    {
                        // fall through to default case
                    }
                    else
                    {
                        if (!fwdCompat)
                        {
                            // check for qname-but-not-ncname
                            string prefix, local, nsUri;
                            bool isValid = _compiler.ParseQName(dataType, out prefix, out local, (IErrorHelper)this);
                            nsUri = isValid ? ResolvePrefix(/*ignoreDefaultNs:*/true, prefix) : _compiler.CreatePhantomNamespace();

                            if (nsUri.Length == 0)
                            {
                                // this is a ncname; we might report SR.Xslt_InvalidAttrValue,
                                // but the following error message is more user friendly
                            }
                            ReportError(/*[XT_034]*/SR.Xslt_BistateAttribute, "data-type", DtText, DtNumber);
                        }
                        // fall through to default case
                    }
                }
                else
                {
                    // Precalculate its value outside of for-each loop
                    QilIterator dt, qname;

                    result = _f.Loop(dt = _f.Let(result),
                        _f.Conditional(_f.Eq(dt, _f.String(DtNumber)), _f.False(),
                        _f.Conditional(_f.Eq(dt, _f.String(DtText)), _f.True(),
                        fwdCompat ? _f.True() :
                        _f.Loop(qname = _f.Let(ResolveQNameDynamic(/*ignoreDefaultNs:*/true, dt)),
                            _f.Error(_lastScope.SourceLine,
                                SR.Xslt_BistateAttribute, "data-type", DtText, DtNumber
                            )
                        )
                    )));

                    QilIterator text = _f.Let(result);
                    _varHelper.AddVariable(text);

                    // Make two sort keys since heterogenous sort keys are not allowed
                    select2 = select.DeepClone(_f.BaseFactory);
                    select = _f.Conditional(text, _f.ConvertToString(select), _f.String(string.Empty));
                    select2 = _f.Conditional(text, _f.Double(0), _f.ConvertToNumber(select2));
                    return;
                }
            }

            // Default case
            select = _f.ConvertToString(select);
            select2 = null;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:70,代码来源:QilGenerator.cs


注:本文中的QilNode.DeepClone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。