Ejemplo n.º 1
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto the stream
        /// </summary>
        public void Graph(XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph ANY
            QTYFormatter baseFormatter = new QTYFormatter();

            baseFormatter.Host = this.Host;

            // Null ?
            IAny anyInstance        = o as IAny;
            IPrimitiveDataValue pdv = o as IPrimitiveDataValue;
            IRealValue          rv  = o as IRealValue;

            // Format
            if (pdv.Value != null && anyInstance.NullFlavor == null)
            {
                if (rv == null || rv.Precision == 0)
                {
                    s.WriteAttributeString("value", Util.ToWireFormat(pdv.Value));
                }
                else if (rv != null)
                {
                    s.WriteAttributeString("value", String.Format(DatatypeR2Formatter.FormatterCulture, String.Format("{{0:0.{0}}}", new String('0', rv.Precision), DatatypeR2Formatter.FormatterCulture.NumberFormat.NumberDecimalSeparator), rv.Value));
                }
            }

            // Format the base
            baseFormatter.Graph(s, o, result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines if this instance of MO semantically equals <paramref name="other"/>
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public override BL SemanticEquals(IAny other)
        {
            var baseSem = base.SemanticEquals(other);

            if (!(bool)baseSem)
            {
                return(baseSem);
            }
            var otherMo = other as MO;

            if (otherMo == null)
            {
                return(false);
            }
            if ((this.Value == null && otherMo.Value == null || this.Value.Equals(otherMo.Value)) &&
                (this.Currency == null && otherMo.Currency == null || this.Currency.Equals(otherMo.Currency)))
            {
                return(true);
            }
            else if (this.UncertainRange != null && otherMo.UncertainRange != null &&
                     this.UncertainRange.Equals(otherMo.UncertainRange))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines if the current instance of BAG is semantically equal to <paramref name="other"/>
        /// </summary>
        /// <remarks>
        /// Two non-null, non null-flavored instances of BAG are semantically equal when they are empty or
        /// if they contain the same items (semantically) regardless of their order
        /// </remarks>
        public override BL SemanticEquals(IAny other)
        {
            var baseSem = base.SemanticEquals(other);

            if (!(bool)baseSem)
            {
                return(baseSem);
            }

            var otherBAG = other as BAG <T>;

            if (otherBAG.IsEmpty && this.IsEmpty)
            {
                return(true);
            }
            else
            {
                bool isEqual = this.Count == otherBAG.Count;
                foreach (ISemanticEquatable itm in this)
                {
                    isEqual &= otherBAG.FindAll(o => itm.SemanticEquals(o as IAny) == true).Count == this.FindAll(o => itm.SemanticEquals(o as IAny) == true).Count;
                }
                return(isEqual);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Determine semantic equality
        /// </summary>
        /// <remarks>Since this data-type is an adaptation of an R1 data type with no semantic equality statements,
        /// the value of this method will be that of the IVL type combined with the UVP type meaning that two
        /// URG instances are semantically equal when their <see cref="P:Low"/> and <see cref="P:High"/> bounds
        /// are specified and equal and their <see cref="P:Probability"/> properties are equal</remarks>
        public override BL SemanticEquals(IAny other)
        {
            // Based on set, first, is the other a DSET?
            if (other is URG <T> )
            {
                URG <T> ivlOther = other as URG <T>;
                // Parameters to semantic equality
                bool otherHighInfinite = (ivlOther.High == null || (NullFlavor)ivlOther.High.NullFlavor == DataTypes.NullFlavor.PositiveInfinity),
                     thisHighInfinite  = (this.High == null || (NullFlavor)this.High.NullFlavor == DataTypes.NullFlavor.PositiveInfinity),
                     otherLowInifinite = (ivlOther.Low == null || (NullFlavor)ivlOther.Low.NullFlavor == DataTypes.NullFlavor.NegativeInfinity),
                     thisLowInfinite   = (this.Low == null || (NullFlavor)this.Low.NullFlavor == DataTypes.NullFlavor.NegativeInfinity),
                     isOtherUnbound    = (ivlOther.High == null || ivlOther.High.IsNull) && !otherHighInfinite ||
                                         (ivlOther.Low == null || ivlOther.Low.IsNull) && !otherLowInifinite,
                     isThisUnbound = (this.High == null || this.High.IsNull) && !thisHighInfinite ||
                                     (this.Low == null || this.Low.IsNull) && !thisLowInfinite;

                // Case 1 : Both are bound
                if (!isOtherUnbound && !isThisUnbound)
                {
                    return(((otherHighInfinite && thisHighInfinite) || (bool)this.High.SemanticEquals(ivlOther.High)) &&
                           ((otherLowInifinite && thisLowInfinite) || (bool)this.Low.SemanticEquals(ivlOther.Low)) &&
                           (this.Probability == null ? ivlOther.Probability == null : this.Probability.Equals(ivlOther.Probability)));
                }
                return(false); // all others are not equal
            }
            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determine if this BL semantically equals another
        /// </summary>
        public override BL SemanticEquals(IAny other)
        {
            var baseEq = base.SemanticEquals(other);

            if (!(bool)baseEq)
            {
                return(baseEq);
            }

            // Null-flavored
            if (this.IsNull && other.IsNull)
            {
                return(true);
            }
            else if (this.IsNull ^ other.IsNull)
            {
                return(false);
            }

            // Values are equal?
            BL blOther = other as BL;

            if (blOther == null)
            {
                return(false);
            }
            else if (blOther.Value != null && this.Value != null)
            {
                return(this.Value.Equals(blOther.Value));
            }
            return(false);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determine semantic equality between this and <paramref name="other"/>
        /// </summary>
        public override BL SemanticEquals(IAny other)
        {
            var baseEq = base.SemanticEquals(other);

            if (!(bool)baseEq)
            {
                return(baseEq);
            }

            // Null-flavored
            if (this.IsNull && other.IsNull)
            {
                return(true);
            }
            else if (this.IsNull ^ other.IsNull)
            {
                return(false);
            }

            EIVL <T> eivlOther = (EIVL <T>)other;

            if (eivlOther == null)
            {
                return(false);
            }
            else
            {
                return
                    ((eivlOther.Event == null ? this.Event == null : (bool)eivlOther.Event.SemanticEquals(this.Event))
                     &&
                     (eivlOther.Offset == null ? this.Offset == null : (bool)eivlOther.Offset.SemanticEquals(this.Offset)));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Parse an object from <paramref name="s"/>
        /// </summary>
        /// <returns></returns>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            if (String.IsNullOrEmpty(s.GetAttribute("flavorId")))
            {
                return(Parse <CD <String> >(s, result));
            }
            else
            {
                IAny retVal = null;
                switch (s.GetAttribute("flavorId"))
                {
                case "CD.CE":
                    retVal        = Parse <CE <String> >(s, result);
                    retVal.Flavor = null;
                    break;

                case "CD.CV":
                    retVal        = Parse <CV <String> >(s, result);
                    retVal.Flavor = null;
                    break;

                default:
                    retVal = Parse <CD <String> >(s, result);
                    break;
                }
                return(retVal);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Executes the stored procedure or SQL batch.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="procOrBatch">Is a stored procedure identifier, SQL batch code, or inliner of a stored procedure.</param>
 /// <param name="returnValueToVariable">Is a name of the variable where the RETURN VALUE returned by the stored procedure will be stored.</param>
 public static ExecChainer Exec(this IAny prev, ExecArgument procOrBatch, string returnValueToVariable = null)
 {
     if (procOrBatch == null)
     {
         throw new QueryTalkException("Exec", QueryTalkExceptionType.ArgumentNull, "procOrBatch = null", Text.Method.Exec);
     }
     return(ExecChainer.Create((Chainer)prev, procOrBatch, returnValueToVariable, procOrBatch.Arguments));
 }
 public void GetDucketTypeClass(IAny anyDuckObject)
 {
     LifeConcreteProperty.GetterEvent += GetDucketType;
     ManaConcreteProperty.GetterEvent += GetDucketType;
     anyDuckObject.InvokeGetterEvent();
     // it will propagate to event and will invoke
     // best suitable overload method (GetDucketType)
     LifeConcreteProperty.GetterEvent -= GetDucketType;
     ManaConcreteProperty.GetterEvent -= GetDucketType;
 }
Ejemplo n.º 10
0
        public IEndsWith Has(int times, IAny input)
        {
            if (input is null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            _pattern = $"{_pattern}{input.Value}{{{times}}}";

            return(this);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Determines if this instance of CV is semantically equal to another
        /// </summary>
        public override BL SemanticEquals(IAny other)
        {
            var baseSem = base.SemanticEquals(other);

            if (!(bool)baseSem)
            {
                return(baseSem);
            }

            ICodedValue otherCv = other as ICodedValue;

            if (otherCv != null) // CS? If so call it's equality
            {
                return(otherCv.CodeSystem == null ? this.CodeSystem == null : otherCv.CodeSystem.Equals(this.CodeSystem));
            }
            return(baseSem);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Translate this QSET to an SXPR
        /// </summary>
        /// <exception cref="T:System.InvalidOperationException">When a member of the set cannot be translated to an SXCM expression</exception>
        public SXPR <T> TranslateToSXPR()
        {
            SXPR <T> retVal = new SXPR <T>();

            if (this.NullFlavor != null)
            {
                retVal.NullFlavor = this.NullFlavor.Clone() as CS <NullFlavor>;
            }
            else if (this is IEnumerable)
            {
                IEnumerator ienum = (this as IEnumerable).GetEnumerator();
                while (ienum.MoveNext())
                {
                    IAny current = ienum.Current as IAny;
                    if (current is QSET <T> )
                    {
                        var sxpr = (current as QSET <T>).TranslateToSXPR();
                        sxpr.Operator = this.GetEquivalentSetOperator();
                        retVal.Add(sxpr);
                    }
                    else if (current is SXCM <T> )
                    {
                        var sxcm = current.Clone() as SXCM <T>;
                        sxcm.Operator = this.GetEquivalentSetOperator(); // This is a shallow clone, but that is ok since we only want to modify the SetOperator which is immutable
                        retVal.Add(sxcm);
                    }
                    else if (current is T)
                    {
                        SXCM <T> sxcm = null;
                        if (current is IImplicitInterval <T> )
                        {
                            sxcm = (current as IImplicitInterval <T>).ToIVL();
                        }
                        else
                        {
                            throw new InvalidOperationException("Cannot interpret the member of the set with type '{0}' as it cannot be converted to a union of interval");
                        }
                        sxcm.Operator = this.GetEquivalentSetOperator();
                        retVal.Add(sxcm);
                    }
                }
            }

            return(retVal);
        }
Ejemplo n.º 13
0
        public override BL SemanticEquals(IAny other)
        {
            var baseSem = base.SemanticEquals(other);

            if (!(bool)baseSem)
            {
                return(baseSem);
            }

            GTS otherGts = other as GTS;

            if (other == null)
            {
                return(false);
            }

            // Return hull equality
            return(otherGts.Hull == null ? this.Hull == null : otherGts.Hull.SemanticEquals(this.Hull));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Determine semantic equality to a coded simple
        /// </summary>
        public override BL SemanticEquals(IAny other)
        {
            if (other == null)
            {
                return(null);
            }
            else if (this.IsNull && other.IsNull)
            {
                return new BL()
                       {
                           NullFlavor = NullFlavorUtil.GetCommonParent(this.NullFlavor, other.NullFlavor)
                       }
            }
            ;
            else if (this.IsNull ^ other.IsNull)
            {
                return new BL()
                       {
                           NullFlavor = DataTypes.NullFlavor.NotApplicable
                       }
            }
            ;
            else if (other is CO)
            {
                CO otherCo = other as CO;

                if (this.Code == null || otherCo.Code == null)
                {
                    return(false);
                }
                return(this.Code.SemanticEquals(otherCo.Code));
            }
            else if (other is ICodedSimple && this.Code != null)
            {
                return(this.Code.SemanticEquals(other));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Graphs object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

            // Graph
            baseFormatter.Graph(s, o, result);

            // Null ?
            IAny anyInstance        = o as IAny;
            IPrimitiveDataValue pdv = o as IPrimitiveDataValue;

            // Null flavor
            if (anyInstance.NullFlavor != null)
            {
                return;
            }

            // Format
            if (pdv.Value != null)
            {
                s.WriteAttributeString("value", Util.ToWireFormat(pdv.Value));
            }
        }