コード例 #1
0
        /// <summary>
        /// Distinct-values operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:distinct-values operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence distinct_values(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence distinct_values(ICollection args, DynamicContext context)
        {
            ResultBuffer rs = new ResultBuffer();

            // get args
            IEnumerator citer = args.GetEnumerator();

            citer.MoveNext();
            ResultSequence arg1 = (ResultSequence)citer.Current;
            ResultSequence arg2 = ResultBuffer.EMPTY;

            if (citer.MoveNext())
            {
                arg2 = (ResultSequence)citer.Current;
            }

            string collationURI = context.CollationProvider.DefaultCollation;

            if (!(arg2 == null || arg2.empty()))
            {
                XSString collation = (XSString)arg2.item(0);
                collationURI = collation.StringValue;
            }

            for (var iter = arg1.iterator(); iter.MoveNext();)
            {
                AnyAtomicType atomizedItem = (AnyAtomicType)FnData.atomize((Item)iter.Current);
                if (!contains(rs, atomizedItem, context, collationURI))
                {
                    rs.add(atomizedItem);
                }
            }

            return(rs.Sequence);
        }
コード例 #2
0
ファイル: FnMin.cs プロジェクト: kaby76/AntlrTreeEditing
        /// <summary>
        /// Min operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dynamic">
        ///            Dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:min operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence min(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence min(ICollection args, DynamicContext context)
        {
            ResultSequence arg = FnMax.get_arg(args, typeof(CmpLt));

            if (arg.empty())
            {
                return(ResultSequenceFactory.create_new());
            }

            CmpLt max = null;

            TypePromoter tp = new ComparableTypePromoter();

            tp.considerSequence(arg);

            for (var i = arg.iterator(); i.MoveNext();)
            {
                AnyAtomicType conv = tp.promote((AnyType)i.Current);

                if (conv != null)
                {
                    if (conv is XSDouble && ((XSDouble)conv).nan() || conv is XSFloat && ((XSFloat)conv).nan())
                    {
                        return(ResultSequenceFactory.create_new(tp.promote(new XSFloat(float.NaN))));
                    }
                    if (max == null || ((CmpLt)conv).lt((AnyType)max, context))
                    {
                        max = (CmpLt)conv;
                    }
                }
            }
            return(ResultSequenceFactory.create_new((AnyType)max));
        }
コード例 #3
0
        public void Load1()
        {
            var assembly       = typeof(AssemblyLoadingTest).Assembly;
            var dynamicContext = new DynamicContext(assembly.Location, new NETCoreAssemblyLoader());

            Assert.IsNotNull(dynamicContext.Assembly);
        }
コード例 #4
0
        /// <summary>
        /// Prefix-from-QName operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:prefix-from-QName operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence inScopePrefixes(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence inScopePrefixes(ICollection args, DynamicContext dc)
        {
            //		Collection cargs = Function.convert_arguments(args, expected_args());
            ICollection cargs = args;
            var         i     = cargs.GetEnumerator();

            i.MoveNext();
            ResultSequence arg1 = (ResultSequence)i.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            ResultBuffer rs = new ResultBuffer();

            Item anytype = arg1.item(0);

            if (!(anytype is ElementType))
            {
                throw new DynamicError(TypeError.invalid_type(null));
            }

            ElementType element    = (ElementType)anytype;
            IList       prefixList = lookupPrefixes(element);

            createPrefixResultSet(rs, prefixList);
            return(rs.Sequence);
        }
コード例 #5
0
        /// <summary>
        /// Compare the arguments as codepoints
        /// </summary>
        /// <param name="args">
        ///            are compared. </param>
        /// <param name="dynamicContext">
        ///            The current dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the comparison of the arguments. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence codepoint_equals(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence codepoint_equals(ICollection args, DynamicContext dynamicContext)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            ResultBuffer rs = new ResultBuffer();

            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1  = (ResultSequence)argiter.Current;
            XSString       xstr1 = arg1 == null || arg1.empty() ? null : (XSString)arg1.first();

            argiter.MoveNext();
            ResultSequence arg2  = (ResultSequence)argiter.Current;
            XSString       xstr2 = arg2 == null || arg2.empty() ? null : (XSString)arg2.first();

            // This delegates to FnCompare
            System.Numerics.BigInteger result = FnCompare.compare_string(org.eclipse.wst.xml.xpath2.api.CollationProvider_Fields.CODEPOINT_COLLATION, xstr1, xstr2, dynamicContext);
            if (result != null)
            {
                rs.add(new XSBoolean(System.Numerics.BigInteger.Zero.Equals(result)));
            }

            return(rs.Sequence);
        }
コード例 #6
0
        /// <summary>
        /// Equality comparison between this and the supplied representation which
        /// must be of type hexBinary
        /// </summary>
        /// <param name="arg">
        ///            The representation to compare with </param>
        /// <returns> True if the two representation are same. False otherwise.
        /// </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean eq(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual bool eq(AnyType arg, DynamicContext dynamicContext)
        {
            throw new Exception();
            //string valToCompare = arg.StringValue;

            // sbyte[] value1 = HexBin.decode(_value);
            // sbyte[] value2 = HexBin.decode(valToCompare);
            // if (value2 == null)
            // {
            //return false;
            // }

            // int len = value1.Length;
            // if (len != value2.Length)
            // {
            //return false;
            // }

            // for (int i = 0; i < len; i++)
            // {
            //if (value1[i] != value2[i])
            //{
            //  return false;
            //}
            // }

            // return true;
        }
コード例 #7
0
ファイル: XSDecimal.cs プロジェクト: kaby76/AntlrTreeEditing
        /// <summary>
        /// Comparison between this number and the supplied representation.
        /// </summary>
        /// <param name="arg">
        ///            Representation to be compared with (must currently be of type
        ///            XSDecimal) </param>
        /// <returns> True if the supplied type represents a number greater than this
        ///         one stored. False otherwise </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean lt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override bool lt(AnyType arg, DynamicContext context)
        {
            Item      carg = convertArg(arg);
            XSDecimal val  = (XSDecimal)get_single_type(carg, typeof(XSDecimal));

            return(_value.CompareTo(val.Value) == -1);
        }
コード例 #8
0
        public void Cast_BottomContextExplicitDynamic_IsCastableToTopContext()
        {
            dynamic    context = new DynamicContext(new BottomContext(), new JObject());
            TopContext casted  = (TopContext)context;

            Assert.That(casted, Is.Not.Null);
        }
コード例 #9
0
        public void Cast_NotContextImplicitDynamic_IsNotCastableToTopContext()
        {
            dynamic    context = new DynamicContext(new NotContext(), new JObject());
            TopContext casted  = context;

            Assert.That(casted, Is.Null);
        }
コード例 #10
0
        /// <summary>
        /// Doc operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:doc operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence doc(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence doc(ICollection args, EvaluationContext ec)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultSequenceFactory.create_new());
            }

            string uri = ((XSString)arg1.item(0)).value();

            DynamicContext dc       = ec.DynamicContext;
            var            resolved = dc.resolveUri(uri);

            if (resolved == null)
            {
                throw DynamicError.invalid_doc(null);
            }

            Document doc = dc.getDocument(resolved);

            if (doc == null)
            {
                throw DynamicError.doc_not_found(null);
            }

            return(new DocType(doc, ec.StaticContext.TypeModel));
        }
コード例 #11
0
 /// <summary>
 /// Constructor for FunctionLibrary.
 /// </summary>
 /// <param name="ns">
 ///            namespace. </param>
 public FunctionLibrary(string ns)
 {
     _namespace = ns;
     _functions = new Hashtable();
     _sc        = null;
     _dc        = null;
 }
コード例 #12
0
ファイル: FnCompare.cs プロジェクト: kaby76/AntlrTreeEditing
        /// <summary>
        /// Compare the arguments.
        /// </summary>
        /// <param name="args">
        ///            are compared (optional 3rd argument is the collation) </param>
        /// <param name="dynamicContext">
        ///            Current dynamic context </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> The result of the comparison of the arguments. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence compare(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence compare(ICollection args, DynamicContext context)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;

            argiter.MoveNext();
            ResultSequence arg2 = (ResultSequence)argiter.Current;

            string collationUri = context.CollationProvider.DefaultCollation;

            if (argiter.MoveNext())
            {
                ResultSequence collArg = (ResultSequence)argiter.Current;
                collationUri = collArg.first().StringValue;
            }

            XSString xstr1 = arg1.empty() ? null : (XSString)arg1.first();
            XSString xstr2 = arg2.empty() ? null : (XSString)arg2.first();

            System.Numerics.BigInteger result = compare_string(collationUri, xstr1, xstr2, context);
            if (result != null)
            {
                return(ResultSequenceFactory.create_new(new XSInteger(result)));
            }
            else
            {
                return(ResultSequenceFactory.create_new());
            }
        }
コード例 #13
0
    /// <summary>
    ///     Selects a node set, using the specified XPath expression.
    /// </summary>
    /// <param name="navigator">A source XPathNavigator.</param>
    /// <param name="expression">An XPath expression.</param>
    /// <param name="variables">A set of XPathVariables.</param>
    /// <returns>An iterator over the nodes matching the specified expression.</returns>
    public static XPathNodeIterator Select(this XPathNavigator navigator, string expression, params XPathVariable[] variables)
    {
        if (variables == null || variables.Length == 0 || variables[0] == null)
        {
            return(navigator.Select(expression));
        }

        // Reflector shows that the standard XPathNavigator.Compile method just does
        //   return XPathExpression.Compile(xpath);
        // only difference is, XPathNavigator.Compile is virtual so it could be overridden
        // by a class inheriting from XPathNavigator... there does not seem to be any
        // doing it in the Framework, though... so we'll assume it's much cleaner to use
        // the static compile:
        var compiled = XPathExpression.Compile(expression);

        var context = new DynamicContext();

        foreach (XPathVariable variable in variables)
        {
            context.AddVariable(variable.Name, variable.Value);
        }

        compiled.SetContext(context);
        return(navigator.Select(compiled));
    }
コード例 #14
0
        /// <summary>
        /// Comparison between this number and the supplied representation.
        /// </summary>
        /// <param name="arg">
        ///            The datatype to compare with </param>
        /// <returns> True if the supplied representation is a greater number than the
        ///         one stored. False otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean lt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override bool lt(AnyType arg, DynamicContext context)
        {
            Item    carg = convertArg(arg);
            XSFloat val  = (XSFloat)get_single_type(carg, typeof(XSFloat));

            return(float_value() < val.float_value());
        }
コード例 #15
0
ファイル: XSDate.cs プロジェクト: kaby76/AntlrTreeEditing
        /// <summary>
        /// Comparison on this and the supplied dates (taking timezones into account)
        /// </summary>
        /// <param name="arg">
        ///            XSDate representation of the date to compare to </param>
        /// <exception cref="DynamicError"> </exception>
        /// <returns> True if in time, this date lies after the date supplied. False
        ///         otherwise. </returns>
        public virtual bool gt(AnyType arg, DynamicContext context)
        {
            XSDate   val     = (XSDate)NumericType.get_single_type((Item)arg, typeof(XSDate));
            Calendar thiscal = normalizeCalendar(calendar(), tz());
            Calendar thatcal = normalizeCalendar(val.calendar(), val.tz());

            return(thiscal.CompareTo(thatcal) > 0);
        }
コード例 #16
0
        public void Load2()
        {
            var assembly       = typeof(AssemblyLoadingTest).Assembly;
            var dynamicContext = new DynamicContext(assembly.Location, new NETCoreAssemblyLoader(), true);

            Assert.IsNotNull(dynamicContext.Assembly);
            Assert.IsTrue(dynamicContext.AllowInvocation);
        }
コード例 #17
0
        /// <summary>
        /// Comparison between this and the supplied XSTime representation
        /// </summary>
        /// <param name="arg">
        ///            The XSTime to compare with </param>
        /// <returns> True if the supplied time represnts a point in time before that
        ///         represented by the time stored. False otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean gt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual bool gt(AnyType arg, DynamicContext context)
        {
            XSTime   val     = (XSTime)NumericType.get_single_type(arg, typeof(XSTime));
            Calendar thiscal = normalizeCalendar(calendar(), tz());
            Calendar thatcal = normalizeCalendar(val.calendar(), val.tz());

            return(thiscal.IsGreaterThan(thatcal));
        }
コード例 #18
0
        /// <summary>
        /// Implicit-Timezone operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:implicit-timezone operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence implicit_timezone(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence implicit_timezone(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            AnyType res = new XSDayTimeDuration(dc.TimezoneOffset);

            return(ResultSequenceFactory.create_new(res));
        }
コード例 #19
0
 /// <summary>
 /// 注册EntityFramework实体配置
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public static CFConfig RegisterEFRepository(this CFConfig config)
 {
     foreach (ConnectionStringSettings cnStr in ConfigurationManager.ConnectionStrings)
     {
         DynamicContext.GetCompiledModel(cnStr.Name);
     }
     return(config);
 }
コード例 #20
0
        /// <summary>
        /// Equality comparison between this and the supplied representation. This
        /// representation must be of type XSGDay
        /// </summary>
        /// <param name="arg">
        ///            The XSGDay to compare with </param>
        /// <returns> True if the two representations are of the same day. False
        ///         otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean eq(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual bool eq(AnyType arg, DynamicContext dynamicContext)
        {
            XSGDay   val     = (XSGDay)NumericType.get_single_type(arg, typeof(XSGDay));
            Calendar thiscal = normalizeCalendar(calendar(), tz());
            Calendar thatcal = normalizeCalendar(val.calendar(), val.tz());

            return(thiscal.Equals(thatcal));
        }
コード例 #21
0
        /// <summary>
        /// Comparison between this and the supplied representation which must be of
        /// type String
        /// </summary>
        /// <param name="arg">
        ///            The representation to compare with </param>
        /// <returns> True if this String is lexographically less than that supplied.
        ///         False otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean lt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual bool lt(AnyType arg, DynamicContext context)
        {
            int cmp = do_compare(arg, context);

            Debug.Assert(cmp != 666);

            return(cmp < 0);
        }
コード例 #22
0
        /// <summary>
        /// Comparison between this number and the supplied representation. Currently
        /// no numeric type promotion exists so the supplied representation must be
        /// of type XSDouble.
        /// </summary>
        /// <param name="arg">
        ///            Representation to be compared with (must currently be of type
        ///            XSDouble) </param>
        /// <returns> True if the supplied type represents a number greater than this
        ///         one stored. False otherwise </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean lt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override bool lt(AnyType arg, DynamicContext context)
        {
            Item carg = convertArg(arg);

            XSDouble val = (XSDouble)get_single_type(carg, typeof(XSDouble));

            return(double_value() < val.double_value());
        }
コード例 #23
0
ファイル: PacketConfiguration.cs プロジェクト: sumonb/dynaxml
        //public  PacketConfiguration(IDynamicContext dynamicContext)
        //{
        //}
        public List <PacketConfigurationInfo> GetConfiguration()
        {
            IDynamicContext con = new DynamicContext("data source=##;initial catalog=##;persist security info=True;user id=##;password=##;");


            var dto = con.FetchData("root", CommandType.Text, "select * from FRListing", null);



            var dtclient = con.FetchData("listing", CommandType.Text, "select * from FRListingPayment", null);



            List <PacketConfigurationInfo> dd = new List <PacketConfigurationInfo>()
            {
                new PacketConfigurationInfo()
                {
                    Dt = dto,
                    MainElementName = "Listings",
                    ItemElementName = "Listing",
                    RowId           = 1,
                    ParentId        = 0,
                    PrimaryKey      = "FRListingID",
                    RelationKey     = "FRListingID",
                    XmlNodeMetaInfo = new List <XmlElementMetaInfo>()
                    {
                        new XmlElementMetaInfo()
                        {
                            AttributeType = true, Name = "FRListingID"
                        }
                    }
                }
                ,
                new PacketConfigurationInfo()
                {
                    Dt = dtclient,
                    MainElementName = "Payments",
                    ItemElementName = "Payment",
                    RowId           = 2,
                    ParentId        = 1,
                    PrimaryKey      = "FRListingPaymentID",
                    RelationKey     = "FRListingID",
                    XmlNodeMetaInfo = new List <XmlElementMetaInfo>()
                    {
                        new XmlElementMetaInfo()
                        {
                            AttributeType = true, Name = "FRListingID"
                        },
                        new XmlElementMetaInfo()
                        {
                            AttributeType = true, Name = "OfficeId"
                        }
                    }
                }
            };

            return(dd);
        }
コード例 #24
0
        /// <summary>
        /// Current-Date operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:current-date operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence current_date(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence current_date(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            XSDayTimeDuration tz  = new XSDayTimeDuration(dc.TimezoneOffset);
            AnyType           res = new XSDate(dc.CurrentDateTime, tz);

            return(ResultSequenceFactory.create_new(res));
        }
コード例 #25
0
        /// <summary>
        /// Support for Contains interface.
        /// </summary>
        /// <param name="rs">
        ///            input1 expression sequence. </param>
        /// <param name="item">
        ///            input2 expression of any atomic type. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of operation. </returns>
        protected internal static bool contains(ResultBuffer rs, AnyAtomicType item, DynamicContext context, string collationURI)
        {
            if (!(item is CmpEq))
            {
                return(false);
            }

            return(hasValue(rs, item, context, collationURI));
        }
コード例 #26
0
        /*
         * (non-Javadoc)
         * @see org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal#lt(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean lt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public override bool lt(AnyType arg, DynamicContext context)
        {
            Item      carg = convertArg(arg);
            XSInteger val  = (XSInteger)get_single_type(carg, typeof(XSInteger));

            int compareResult = int_value().CompareTo(val.int_value());

            return(compareResult < 0);
        }
コード例 #27
0
        /// <summary>
        /// @since 2.0
        /// </summary>
        public virtual ResultSequence evaluate(DynamicContext dynamicContext, object[] contextItems)
        {
            if (_staticContext == null)
            {
                throw new System.InvalidOperationException("Static Context not set yet!");
            }

            return((new DefaultEvaluator(_staticContext, dynamicContext, contextItems)).evaluate2(this));
        }
コード例 #28
0
ファイル: Index.cs プロジェクト: ruo2012/myxsl
            public override IXdmEnumerator Call(IXdmEnumerator[] arguments, DynamicContext context)
            {
                XdmAtomicValue p1 = arguments[0].AsAtomicValues().SingleOrDefault();

                if (p1 == null)
                {
                    return(EmptyEnumerator.INSTANCE);
                }

                return(Math.Acos((double)p1.Value).ToXdmAtomicValue().GetXdmEnumerator());
            }
コード例 #29
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        public void SaveState()
        {
            var objectToSave = new DynamicContext();

            SaveState(objectToSave);

            if (!objectToSave.IsEmpty)
            {
                DynamicContext.Save <TViewModel>(objectToSave);
            }
        }
コード例 #30
0
        /// <summary>
        /// Current-Time operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:current-time operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence current_time(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence current_time(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            var d = dc.TimezoneOffset;
            XSDayTimeDuration tz = new XSDayTimeDuration(0, d.Hours, d.Minutes, 0.0, d.Sign == -1);

            AnyType res = new XSTime(dc.CurrentDateTime, tz);

            return(ResultSequenceFactory.create_new(res));
        }
コード例 #31
0
            public OpenFileResult InputFileOpenWrite(IInFileDef fileDef, DynamicContext ctx)
            {
                string tmpFilePath = Path.GetTempFileName();
                _tmpFilesToDel.Add(tmpFilePath);

                _filesToCopyFromTmp.Add(Tuple.Create(
                    new TaskFileDescription
                    {
                        FileName = GetFileName(fileDef),
                        SlotName = GetSlotName(fileDef)
                    },
                    tmpFilePath
                ));

                var res = new OpenFileResult()
                {
                    FilePath = tmpFilePath, // note: or fileName
                    Stream = File.OpenWrite(tmpFilePath)
                };

                return res;
            }
コード例 #32
0
            public OpenFileResult InputFileOpenRead(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                OpenFileResult result;

                string storageId = externalFileDefinition.Locator;
                if (String.IsNullOrEmpty(storageId))
                {
                    result = new OpenFileResult
                    {
                        FilePath = "", // note: or fileName
                        Stream = null,
                    };
                }
                else
                {
                    string tmpFileName = Path.GetTempFileName();
                    _tmpFilesToDel.Add(tmpFileName);

                    Log.Debug("Loading input file from storage for PB: " + storageId);
                    IOProxy.Storage.Download(storageId, tmpFileName);
                    Log.Debug("Loading done for file: " + storageId);

                    result = new OpenFileResult
                    {
                        FilePath = tmpFileName, // note: or fileName
                        Stream = File.OpenRead(tmpFileName),
                    };
                }

                return result;
            }
コード例 #33
0
            public long InputFileCopy(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                long fileSize = 0;

                string storageId = externalFileDefinition.Locator;
                if (!String.IsNullOrEmpty(storageId))
                {
                    _filesToCopyFromStorage.Add(new TaskFileDescription
                    {
                        FileName = GetFileName(fileDef, externalFileDefinition),
                        SlotName = GetSlotName(fileDef),
                        StorageId = storageId,
                    });

                    fileSize = IOProxy.Storage.GetFileSize(storageId); // todo : 0?
                }

                return fileSize;
            }
コード例 #34
0
            public OpenFileResult OutputFileOpenRead(IOutFileDef fileDef, string filePath, DynamicContext ctx)
            {
                string ftpPath = _ftpRoot + filePath.TrimStart(new[] { '/', '\\' });
                string tmpFilePath = Path.GetTempFileName();

                Log.Debug("Downloading file for PB: " + ftpPath);
                IOProxy.Ftp.DownloadFile(ftpPath, tmpFilePath);
                Log.Debug("Downloading file done: " + ftpPath);
                _tmpFilesToDel.Add(tmpFilePath);

                var res = new OpenFileResult()
                {
                    FilePath = filePath,
                    Stream = File.OpenRead(tmpFilePath)
                };

                return res;
            }
コード例 #35
0
            public long OutputFileCopy(IOutFileDef fileDef, string filePath, DynamicContext ctx)
            {
                _filesToCopyFromFTP.Add(Tuple.Create(
                    new TaskFileDescription {
                        FileName = GetFileName(filePath, fileDef),
                        SlotName = GetSlotName(fileDef)
                    },
                    filePath
                ));

                string ftpPath = _ftpRoot + filePath.TrimStart(new[] { '/', '\\' });
                return IOProxy.Ftp.GetFileSize(ftpPath);
            }