Пример #1
0
 private CommandDefinition.CommandFormat ReplyCreate(CommandEnum command, BooleanValue isAck, ActionEnum action, byte subAction, byte[] data)
 {
     CommandDefinition.CommandAckStruct /*can't name it command*/ cmd = new CommandDefinition.CommandAckStruct(command, BooleanValue.False, isAck);
     CommandDefinition.ActionStruct /*can't name it action*/ act = new CommandDefinition.ActionStruct(ActionEnum.Response, subAction);
     CommandDefinition.CommandFormat packet = new CommandDefinition.CommandFormat(cmd, act, data);
     return packet;
 }
Пример #2
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            result = ArithmeticOperation.Arithmetic(flow, operation, leftOperand,
                                                    TypeConversion.ToFloat(value.Value));
            if (result != null)
            {
                return;
            }

            base.VisitBooleanValue(value);
        }
Пример #3
0
 public Task <SerializableValue> Execute(PluginExecuteContext context)
 {
     foreach (var(key, _) in context.Parameters)
     {
         return(Task.FromResult <SerializableValue>(new BooleanValue {
             value = BooleanValue.TryParse(key, context.Language)
         }));
     }
     return(Task.FromResult <SerializableValue>(new BooleanValue {
         value = false
     }));
 }
Пример #4
0
        public void BooleanValue()
        {
            var target = new BooleanValue(true);

            target.Value.Is(true);
            target.ValueAsObject.Is(true);
            target.Type.Is(ValueTypes.Boolean);

            target = new BooleanValue(false);
            target.Value.Is(false);
            target.ValueAsObject.Is(false);
        }
Пример #5
0
        public void TestOr()
        {
            // Arrange
            var boolTrue = new BooleanValue(true);
            var boolFalse = new BooleanValue(false);

            // Act & Assert
            Assert.IsFalse(((BooleanValue)boolFalse.Or(boolFalse)).Val);
            Assert.IsTrue(((BooleanValue)boolTrue.Or(boolFalse)).Val);
            Assert.IsTrue(((BooleanValue)boolFalse.Or(boolTrue)).Val);
            Assert.IsTrue(((BooleanValue)boolTrue.Or(boolTrue)).Val);
        }
        public void TestIsNotEqualTo()
        {
            // Arrange
            var boolTrue  = new BooleanValue(true);
            var boolFalse = new BooleanValue(false);

            // Act & Assert
            Assert.IsFalse(((BooleanValue)boolFalse.IsNotEqualTo(boolFalse)).Val);
            Assert.IsTrue(((BooleanValue)boolTrue.IsNotEqualTo(boolFalse)).Val);
            Assert.IsTrue(((BooleanValue)boolFalse.IsNotEqualTo(boolTrue)).Val);
            Assert.IsFalse(((BooleanValue)boolTrue.IsNotEqualTo(boolTrue)).Val);
        }
Пример #7
0
 private void SetFlagState(ScalarIntValue index, BooleanValue value)
 {
     if (!kPMCore.fetch.vessel_register.ContainsKey(shared.Vessel.id))
     {
         return;
     }
     if (kPMCore.fetch.GetVesselMonitors(shared.Vessel.id).monitors.Count == 0 || kPMCore.fetch.GetVesselMonitors(shared.Vessel.id).monitors.Count <= monitor)
     {
         return;
     }
     kPMCore.fetch.GetVesselMonitors(shared.Vessel.id).flagStates[monitor][index] = value;
 }
Пример #8
0
        public override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            var postedValue = postCollection[postDataKey];
            var boolValue   = !string.IsNullOrEmpty(postedValue);

            if (!BooleanValue.Equals(boolValue))
            {
                Value = boolValue;
                return(true);
            }
            return(false);
        }
Пример #9
0
        /// <summary>
        /// Evaluates the node, using the variables provided in the <paramref name="Variables"/> collection.
        /// </summary>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Result.</returns>
        public override IElement Evaluate(Variables Variables)
        {
            IElement     L  = this.left.Evaluate(Variables);
            BooleanValue BL = L as BooleanValue;
            BooleanValue BR;
            IElement     Result;
            IElement     R;

            if (this.bothBool.HasValue && this.bothBool.Value && BL != null)
            {
                bool LValue = BL.Value;
                Result = this.EvaluateOptimizedResult(LValue);
                if (Result != null)
                {
                    return(Result);
                }

                R  = this.right.Evaluate(Variables);
                BR = R as BooleanValue;

                if (BR != null)
                {
                    return(this.Evaluate(LValue, BR.Value));
                }
                else
                {
                    this.bothBool = false;
                }
            }
            else
            {
                R  = this.right.Evaluate(Variables);
                BR = R as BooleanValue;

                if (BL != null && BR != null)
                {
                    if (!this.bothBool.HasValue)
                    {
                        this.bothBool = true;
                    }

                    return(this.Evaluate(BL.Value, BR.Value));
                }
                else
                {
                    this.bothBool = false;
                    return(this.Evaluate(L, R, Variables));
                }
            }

            return(this.Evaluate(L, R, Variables));
        }
        static RequestLiquidTemplateEventHandler()
        {
            TemplateContext.GlobalMemberAccessStrategy.Register <HttpRequest, FluidValue>((request, name) =>
            {
                switch (name)
                {
                case "QueryString": return(new StringValue(request.QueryString.Value));

                case "ContentType": return(new StringValue(request.ContentType));

                case "ContentLength": return(NumberValue.Create(request.ContentLength ?? 0));

                case "Cookies": return(new ObjectValue(new CookieCollectionWrapper(request.Cookies)));

                case "Headers": return(new ObjectValue(new HeaderDictionaryWrapper(request.Headers)));

                case "Query": return(new ObjectValue(request.Query));

                case "Form": return(request.HasFormContentType ? (FluidValue) new ObjectValue(request.Form) : NilValue.Instance);

                case "Protocol": return(new StringValue(request.Protocol));

                case "Path": return(new StringValue(request.Path.Value));

                case "PathBase": return(new StringValue(request.PathBase.Value));

                case "Host": return(new StringValue(request.Host.Value));

                case "IsHttps": return(BooleanValue.Create(request.IsHttps));

                case "Scheme": return(new StringValue(request.Scheme));

                case "Method": return(new StringValue(request.Method));

                default: return(null);
                }
            });

            TemplateContext.GlobalMemberAccessStrategy.Register <FormCollection, FluidValue>((forms, name) =>
            {
                if (name == "Keys")
                {
                    return(new ArrayValue(forms.Keys.Select(x => new StringValue(x))));
                }

                return(new ArrayValue(forms[name].Select(x => new StringValue(x)).ToArray()));
            });

            TemplateContext.GlobalMemberAccessStrategy.Register <QueryCollection, string[]>((queries, name) => queries[name].ToArray());
            TemplateContext.GlobalMemberAccessStrategy.Register <CookieCollectionWrapper, string>((cookies, name) => cookies.RequestCookieCollection[name]);
            TemplateContext.GlobalMemberAccessStrategy.Register <HeaderDictionaryWrapper, string[]>((headers, name) => headers.HeaderDictionary[name].ToArray());
        }
Пример #11
0
        private static void SetCellTypeAndValue(Cell cell, ExcelColumnProperty property, object value, SharedStringTable sharedStrTbl)
        {
            if (property != null)
            {
                cell.DataType = GetCellDataType(property.PropertyInfo);
                if (property.CellFormatIndex > 0)
                {
                    cell.StyleIndex = (uint)property.CellFormatIndex;
                }
            }

            if (value == null)
            {
                return;
            }

            string strCellValue;
            int    sharedStrIndex;

            if (value is DateTime)
            {
                strCellValue = ((DateTime)value).ToOADate().ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
            else if (cell.DataType == null)
            {
                strCellValue = value.ToString();
            }
            else if (cell.DataType == CellValues.SharedString)
            {
                string theValue;
                if (value is bool)
                {
                    theValue = (bool)value ? "Yes" : "No";
                }
                else
                {
                    theValue = value.ToString();
                }
                sharedStrIndex = GetSharedStringIndex(sharedStrTbl, theValue);
                strCellValue   = sharedStrIndex.ToString();
            }
            else if (cell.DataType.Value == CellValues.Boolean)
            {
                strCellValue = BooleanValue.FromBoolean((bool)value).ToString();
            }
            else
            {
                strCellValue = value.ToString();
            }

            cell.CellValue = new CellValue(strCellValue);
        }
Пример #12
0
        /// <summary>
        /// Create cell format and add the cellformats collection
        /// </summary>
        private static CellFormat CreateCellFormat(CellFormats cfs, UInt32Value NumberFormatId)
        {
            CellFormat cf = new CellFormat();

            cf.NumberFormatId    = NumberFormatId;
            cf.FontId            = 0;
            cf.FillId            = 0;
            cf.BorderId          = 0;
            cf.FormatId          = 0;
            cf.ApplyNumberFormat = BooleanValue.FromBoolean(true);
            cfs.Append(cf);
            return(cf);
        }
Пример #13
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

            default:
                base.VisitBooleanValue(value);
                break;
            }
        }
Пример #14
0
 public void SetRunningPrimary(BooleanValue prim)
 {
     ThrowIfNotCPUVessel();
     if (!MultiMode)
     {
         throw new KOSException("Attempted to set the PRIMARYMODE suffix on a non-multi mode engine.");
     }
     // If runningPrimary does not match prim, call ToggleMode
     if (prim != Multi.runningPrimary)
     {
         ToggleMode();
     }
 }
Пример #15
0
 public override ValueTask <FluidValue> GetValueAsync(string name, TemplateContext context)
 {
     return(name switch
     {
         "length" => new ValueTask <FluidValue>(NumberValue.Create(Length)),
         "index" => new ValueTask <FluidValue>(NumberValue.Create(Index)),
         "index0" => new ValueTask <FluidValue>(NumberValue.Create(Index0)),
         "rindex" => new ValueTask <FluidValue>(NumberValue.Create(RIndex)),
         "rindex0" => new ValueTask <FluidValue>(NumberValue.Create(RIndex0)),
         "first" => new ValueTask <FluidValue>(BooleanValue.Create(First)),
         "last" => new ValueTask <FluidValue>(BooleanValue.Create(Last)),
         _ => new ValueTask <FluidValue>(NilValue.Instance),
     });
Пример #16
0
 private void ToggleRCS(BooleanValue state)
 {
     CheckEvaController();
     if (state.Value != rcs_state)
     {
         try
         {
             KerbalEVAUtility.RunEvent(kerbaleva, "Pack Toggle");
             rcs_state = state;
         }
         catch { }
     }
 }
Пример #17
0
 private void SetRetrograde(BooleanValue value)
 {
     if (shared.Vessel != FlightGlobals.ActiveVessel)
     {
         throw new KOSException("You may only call addons:tr:RETROGRADE from the active vessel.");
     }
     if (Available())
     {
         TRWrapper.RetrogradeEntry = value;
         return;
     }
     throw new KOSUnavailableAddonException("RETROGRADE", "Trajectories");
 }
Пример #18
0
        public void UpdateRecord(System.Collections.Generic.List <int> UpdList, DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (UpdList == null || UpdList.Count == 0)
            {
                return;
            }
            string        sql = "";
            StringBuilder sbd = new StringBuilder();

            foreach (var id in UpdList)
            {
                sbd.Append(id);
                sbd.Append(",");
            }

            sql = string.Format("select * from sys_Property where ID in({0})", sbd.ToString(0, sbd.Length - 1));


            BooleanValue <DataTable> bv = dao.GetDataTable(sql);

            if (bv.Success && bv.Value.Rows.Count > 0)
            {
                if (Default_sql != null)
                {
                    object busisData = null;
                    YueMES.Base.Dal.DTO.TryGetCache(Default_sql, DBNo, out busisData);
                    Sys_Propertys busis = (Sys_Propertys)busisData;
                    if (busis.Columns.Count != bv.Value.Columns.Count)
                    {
                        return;
                    }
                    lock (_lock)
                    {
                        foreach (var id in UpdList)
                        {
                            DataRow[] drs = busis.Select(string.Format("ID={0}", id));
                            if (drs.Length == 0)
                            {
                                continue;
                            }
                            busis.Rows.Remove(drs[0]);
                        }
                        foreach (DataRow row in bv.Value.Rows)
                        {
                            busis.LoadDataRow(row, true);
                        }
                        busis.AcceptChanges();
                    }
                }
            }
        }
Пример #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (valueTypeCase_ == ValueTypeOneofCase.NullValue)
            {
                hash ^= NullValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.BooleanValue)
            {
                hash ^= BooleanValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.IntegerValue)
            {
                hash ^= IntegerValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.DoubleValue)
            {
                hash ^= DoubleValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.TimestampValue)
            {
                hash ^= TimestampValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.StringValue)
            {
                hash ^= StringValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.BytesValue)
            {
                hash ^= BytesValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.ReferenceValue)
            {
                hash ^= ReferenceValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.GeoPointValue)
            {
                hash ^= GeoPointValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.ArrayValue)
            {
                hash ^= ArrayValue.GetHashCode();
            }
            if (valueTypeCase_ == ValueTypeOneofCase.MapValue)
            {
                hash ^= MapValue.GetHashCode();
            }
            hash ^= (int)valueTypeCase_;
            return(hash);
        }
Пример #20
0
        /// <summary>
        /// Evaluates the operator on scalar operands.
        /// </summary>
        /// <param name="Left">Left value.</param>
        /// <param name="Right">Right value.</param>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Result</returns>
        public override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
        {
            IElement     Result = base.EvaluateScalar(Left, Right, Variables);
            BooleanValue B      = (BooleanValue)Result;

            if (B.Value)
            {
                return(BooleanValue.False);
            }
            else
            {
                return(BooleanValue.True);
            }
        }
Пример #21
0
        /// <summary>
        /// 根据用户获取角色
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public static BooleanValue <DataTable> GetUserRoles(string UserNo)
        {
            string sql = $@"SELECT distinct sr.* from sys_Role_User sru
                        left join sys_Role sr on sr.ID=sru.MID
                        LEFT JOIN dbo.SYS_USER u ON u.id = sru.UserID
                        where u.no ='{UserNo}'";
            BooleanValue <DataTable> BV = DAO.Default.GetDataTable(sql);

            if (!BV.Success)
            {
                throw new Exception(BV.ErrorText);
            }
            return(BV);
        }
Пример #22
0
        /// <summary>
        /// Evaluates the operator on scalar operands.
        /// </summary>
        /// <param name="Left">Left value.</param>
        /// <param name="Right">Right value.</param>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Result</returns>
        public override IElement EvaluateScalar(IElement Left, IElement Right, Variables Variables)
        {
            BooleanValue BL = Left as BooleanValue;
            BooleanValue BR = Right as BooleanValue;

            if (BL != null && BR != null)
            {
                return(this.Evaluate(BL.Value, BR.Value));
            }
            else
            {
                throw new ScriptRuntimeException("Scalar operands must be boolean values.", this);
            }
        }
Пример #23
0
        public void WriteTo_PassFalseValue_ValueElementZeroIsWrittenToParamElement()
        {
            var writer = new BooleanValueWriter();

            var value      = new BooleanValue(false);
            var xmlElement = new XElement("param");

            writer.WriteTo(xmlElement, value);

            var valueElement = xmlElement.XPathSelectElement("value/boolean");

            Assert.NotNull(valueElement);
            Assert.Equal("0", valueElement.Value);
        }
Пример #24
0
        public void CanCompareToScalar()
        {
            BooleanValue bv = new BooleanValue(true);
            ScalarValue  sv = ScalarValue.Create(1);

            Assert.IsTrue(bv == sv);
            Assert.IsFalse(bv != sv);
            Assert.IsTrue(sv == bv);
            Assert.IsFalse(sv != bv);
            sv = ScalarValue.Create(0);
            Assert.IsTrue(bv != sv);
            Assert.IsFalse(bv == sv);
            Assert.IsTrue(sv != bv);
            Assert.IsFalse(sv == bv);
            sv = ScalarValue.Create(3.1415926535897932384626433832795);
            Assert.IsTrue(bv == sv);
            Assert.IsFalse(bv != sv);
            Assert.IsTrue(sv == bv);
            Assert.IsFalse(sv != bv);
            sv = ScalarValue.Create(0.0d);
            Assert.IsTrue(bv != sv);
            Assert.IsFalse(bv == sv);
            Assert.IsTrue(sv != bv);
            Assert.IsFalse(sv == bv);

            bv = new BooleanValue(false);
            sv = ScalarValue.Create(1);
            Assert.IsTrue(bv != sv);
            Assert.IsFalse(bv == sv);
            Assert.IsTrue(sv != bv);
            Assert.IsFalse(sv == bv);
            sv = ScalarValue.Create(0);
            Assert.IsTrue(bv == sv);
            Assert.IsFalse(bv != sv);
            Assert.IsTrue(sv == bv);
            Assert.IsFalse(sv != bv);
            sv = ScalarValue.Create(3.1415926535897932384626433832795);
            Assert.IsTrue(bv != sv);
            Assert.IsFalse(bv == sv);
            Assert.IsTrue(sv != bv);
            Assert.IsFalse(sv == bv);
            Assert.IsFalse(bv.Equals(sv));
            sv = ScalarValue.Create(0.0d);
            Assert.IsTrue(bv == sv);
            Assert.IsFalse(bv != sv);
            Assert.IsTrue(sv == bv);
            Assert.IsFalse(sv != bv);
            Assert.IsFalse(bv.Equals(sv));
        }
Пример #25
0
        public static void PageSetupUpdate(WorksheetPart worksheetPart, OrientationValues landscapeOrPortrait,
                                           DoubleValue marginLeft, DoubleValue marginRight, DoubleValue marginTop, DoubleValue marginBottom, DoubleValue marginHeader, DoubleValue marginFooter,
                                           Boolean isFitToPage, UInt32Value FitToHeight, UInt32Value FitToWidth, UInt32Value pageSize, string headerLeft, string headerCenter, string headerRight, string footerLeft, string footerRight)
        {
            Worksheet ws = worksheetPart.Worksheet;
            //page setup them moi pagesetup properties
            SheetProperties sp = new SheetProperties(new PageSetupProperties());

            ws.SheetProperties = sp;

            PrintOptions printOp = new PrintOptions();

            printOp.HorizontalCentered = true;
            ws.AppendChild(printOp);

            PageMargins pageMargins = new PageMargins();

            pageMargins.Left   = marginLeft;
            pageMargins.Right  = marginRight;
            pageMargins.Top    = marginTop;
            pageMargins.Bottom = marginBottom;
            pageMargins.Header = marginHeader;
            pageMargins.Footer = marginFooter;
            ws.AppendChild(pageMargins);

            // Set the FitToPage property to true
            ws.SheetProperties.PageSetupProperties.FitToPage = BooleanValue.FromBoolean(isFitToPage);

            DocumentFormat.OpenXml.Spreadsheet.PageSetup pgOr = new DocumentFormat.OpenXml.Spreadsheet.PageSetup();
            pgOr.Orientation = landscapeOrPortrait;
            pgOr.PaperSize   = pageSize;
            pgOr.FitToHeight = FitToHeight;
            pgOr.FitToWidth  = FitToWidth;
            ws.AppendChild(pgOr);

            HeaderFooter headerFooter1 = new HeaderFooter();
            OddHeader    oddHeader1    = new OddHeader();

            oddHeader1.Text = "&L&\"Times New Roman,Regular\"" + headerLeft + "&C&\"Times New Roman,Regular\"" + headerCenter + "&R&\"Times New Roman,Regular\"" + headerRight;
            OddFooter oddFooter1 = new OddFooter();

            oddFooter1.Text = "&L&\"Times New Roman,Regular\"" + footerLeft + "&C&P&R&\"Times New Roman,Regular\"" + footerRight;
            headerFooter1.Append(oddHeader1);
            headerFooter1.Append(oddFooter1);
            ws.AppendChild(headerFooter1);

            //save worksheet properties
            //worksheetPart.Worksheet.Save();
        }
Пример #26
0
        public int CompareTo(IndexValue other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (ReferenceEquals(null, other))
            {
                return(1);
            }
            var typeComparison = Type.CompareTo(other.Type);

            if (typeComparison != 0)
            {
                return(typeComparison);
            }
            switch (Type)
            {
            case IndexValueType.String:
                return(string.Compare(StringValue, other.StringValue, StringComparison.Ordinal));

            case IndexValueType.StringArray:
                return(string.Compare(ValueAsString, other.ValueAsString, StringComparison.Ordinal));

            case IndexValueType.Bool:
                return(BooleanValue.CompareTo(other.BooleanValue));

            case IndexValueType.Int:
                return(IntegerValue.CompareTo(other.IntegerValue));

            case IndexValueType.IntArray:
                return(string.Compare(ValueAsString, other.ValueAsString, StringComparison.Ordinal));

            case IndexValueType.Long:
                return(LongValue.CompareTo(other.LongValue));

            case IndexValueType.Float:
                return(SingleValue.CompareTo(other.SingleValue));

            case IndexValueType.Double:
                return(DoubleValue.CompareTo(other.DoubleValue));

            case IndexValueType.DateTime:
                return(DateTimeValue.CompareTo(other.DateTimeValue));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #27
0
 public FontData(
     Int32Value fontSize,
     A.LatinFont aLatinFont,
     BooleanValue isBold,
     BooleanValue isItalic,
     A.RgbColorModelHex aRgbColorModelHex,
     A.SchemeColor aSchemeColor) : this(fontSize)
 {
     FontSize          = fontSize;
     ALatinFont        = aLatinFont;
     IsBold            = isBold;
     IsItalic          = isItalic;
     ASchemeColor      = aSchemeColor;
     ARgbColorModelHex = aRgbColorModelHex;
 }
Пример #28
0
            public override IValue Execute(ActuatorBase state)
            {
                IValue value = null;

                if (mExpression != null)
                {
                    value = mExpression.Execute(state);
                }
                else
                {
                    value = new BooleanValue(false);
                }
                state.BreakProgram = true;
                return(value);
            }
Пример #29
0
 public object?VisitBoolean(BooleanValue booleanValue, Type expectedType)
 {
     if (expectedType == typeof(bool))
     {
         return(booleanValue.TokenValue);
     }
     else if (expectedType == typeof(bool?))
     {
         return((bool?)booleanValue.TokenValue);
     }
     else
     {
         return(Convert.ChangeType(booleanValue.TokenValue, expectedType, CultureInfo.InvariantCulture));
     }
 }
Пример #30
0
        public override string ToString()
        {
            switch (ValueType)
            {
            case (int)GatewayProperty.ValueTypes.ShortString:
                return(ShortTextValue);

            case (int)GatewayProperty.ValueTypes.Boolean:
                return(BooleanValue.ToString());

            case (int)GatewayProperty.ValueTypes.DictionaryKey:
                return(ShortTextValue);
            }
            return(base.ToString());
        }
Пример #31
0
 public ArrayValue(int row, int col, IValue fillValue = null)
 {
     if (ReferenceEquals(fillValue, null))
     {
         fillValue = new BooleanValue(false);
     }
     mValue = new IValue[row, col];
     for (var r = 0; r < row; ++r)
     {
         for (var c = 0; c < col; ++c)
         {
             mValue[r, c] = fillValue;
         }
     }
 }
Пример #32
0
        public override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            string postedValue = postCollection[postDataKey];
            bool   boolValue   = false;

            if (!(postedValue == null || postedValue == string.Empty))
            {
                boolValue = true;
            }
            if (!BooleanValue.Equals(boolValue))
            {
                Value = boolValue;
                return(true);
            }
            return(false);
        }
Пример #33
0
        public void BooleanValueTest()
        {
            // xsd:boolean is enum in W3C XSD 1.1 Part 2: Datatypes  - 'true' | 'false' | '1' | '0'

            BooleanValue target = new BooleanValue();
            Assert.False(target.HasValue); // default has no value.

            target.InnerText = "1";
            Assert.True(target.HasValue);
            Assert.True(target.Value);
            Assert.True((bool)target);

            target.InnerText = "0";
            Assert.False(target.Value);
            Assert.True(target.HasValue);
            Assert.False((bool)target);

            target.InnerText = "true";
            Assert.True(target.Value);
            Assert.True(target.HasValue);

            target.InnerText = "false";
            Assert.True(target.HasValue);
            Assert.False(target.Value);

            target.Value = true;
            Assert.Equal("1", target.InnerText);

            target.Value = false;
            Assert.Equal("0", target.ToString());

            target = true;
            Assert.True(target.Value);
            Assert.Equal("1", target.InnerText);

            target = false;
            Assert.False(target.Value);
            Assert.Equal("0", target.ToString());
        }
    public void TestAllStatementBuilderPartialFunctions() {
      StatementBuilder statementBuilder = new StatementBuilder()
          .Select("Name, Id")
          .From("Geo_Target")
          .Where("Targetable = :targetable")
          .OrderBy("Id DESC")
          .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .Offset(0)
          .AddValue("targetable", true)
          .IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT)
          .RemoveLimitAndOffset();
      Assert.AreEqual(null, statementBuilder.GetOffset());

      Statement expectedStatement = new Statement();
      expectedStatement.query = "SELECT Name, Id FROM Geo_Target"
          + " WHERE Targetable = :targetable ORDER BY Id DESC";
      String_ValueMapEntry targetableEntry = new String_ValueMapEntry();
      targetableEntry.key = "targetable";
      BooleanValue targetableValue = new BooleanValue();
      targetableValue.value = true;
      targetableEntry.value = targetableValue;
      expectedStatement.values = new String_ValueMapEntry[] {targetableEntry};
      Assert.True(StatementsAreEqual(expectedStatement, statementBuilder.ToStatement()));
    }
Пример #35
0
        /// <summary>
        /// Gets the values.
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ValueExpression> GetValues()
        {
            Dictionary<string, ValueExpression> values = new Dictionary<string, ValueExpression>();
            foreach (DataGridViewRow row in grdProperties.Rows)
            {
                string name = row.Cells[0].Value.ToString();
                PropertyDefinition propDef = row.Cells[0].Tag as PropertyDefinition;
                if (row.Cells[1].Value != null)
                {
                    string str = row.Cells[1].Value.ToString();
                    if (!string.IsNullOrEmpty(str))
                    {
                        ValueExpression expr = null;
                        if (propDef.PropertyType == PropertyType.PropertyType_DataProperty)
                        {
                            DataPropertyDefinition dp = propDef as DataPropertyDefinition;
                            switch (dp.DataType)
                            {
                                case DataType.DataType_Boolean:
                                    expr = new BooleanValue(Convert.ToBoolean(str));
                                    break;
                                case DataType.DataType_Byte:
                                    expr = new ByteValue(Convert.ToByte(str));
                                    break;
                                case DataType.DataType_DateTime:
                                    expr = new DateTimeValue(Convert.ToDateTime(str));
                                    break;
                                case DataType.DataType_Decimal:
                                    expr = new DecimalValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Double:
                                    expr = new DoubleValue(Convert.ToDouble(str));
                                    break;
                                case DataType.DataType_Int16:
                                    expr = new Int16Value(Convert.ToInt16(str));
                                    break;
                                case DataType.DataType_Int32:
                                    expr = new Int32Value(Convert.ToInt32(str));
                                    break;
                                case DataType.DataType_Int64:
                                    expr = new Int64Value(Convert.ToInt64(str));
                                    break;
                                case DataType.DataType_Single:
                                    expr = new SingleValue(Convert.ToSingle(str));
                                    break;
                                case DataType.DataType_String:
                                    expr = new StringValue(str);
                                    break;
                                default:
                                    throw new NotSupportedException("Unsupported data type: " + dp.DataType);
                            }
                        }
                        else if (propDef.PropertyType == PropertyType.PropertyType_GeometricProperty)
                        {
                            FdoGeometryFactory fact = FdoGeometryFactory.Instance;
                            OSGeo.FDO.Geometry.IGeometry geom = fact.CreateGeometry(str);
                            byte[] fgf = fact.GetFgf(geom);
                            expr = new GeometryValue(fgf);
                            geom.Dispose();
                        }

                        if (expr != null)
                            values.Add(name, expr);
                    }
                }
            }
            return values;
        }
Пример #36
0
 public CommandAckStruct(CommandEnum cmd, BooleanValue ackReq, BooleanValue isAck)
 {
     _commandWithAck = (byte)(((byte)cmd << 2) | ((byte)ackReq << 1) | (byte)isAck);
 }
Пример #37
0
 private CommandDefinition.CommandFormat CommandMake(CommandEnum commandCode, BooleanValue acknowledgeIsRequested, ActionEnum actionCode, byte subAction)
 {
     CommandDefinition.CommandAckStruct acknowledgement = new CommandDefinition.CommandAckStruct(commandCode, acknowledgeIsRequested, BooleanValue.False);
     CommandDefinition.ActionStruct action = new CommandDefinition.ActionStruct(actionCode, subAction);
     CommandDefinition.CommandFormat returnedCommand = new CommandDefinition.CommandFormat(acknowledgement.CommandWithAck, action.ActionAndSubAction);
     return returnedCommand;
 }
Пример #38
0
 internal override Value AndBool(BooleanValue value)
 {
     return new Undefined();
 }
Пример #39
0
        public XmlRecord(XmlProperty[] properties, FixedWKTReader wktReader, XmlNodeList propertyNodes, string nameElement, string valueElement)
        {
            for (int i = 0; i < properties.Length; i++)
            {
                string name = properties[i].Name;
                _ordinalMap[i] = name;

                switch (properties[i].Type)
                {
                    case PropertyValueType.Blob:
                        _values[name] = new BlobValue();
                        break;
                    case PropertyValueType.Boolean:
                        _values[name] = new BooleanValue();
                        break;
                    case PropertyValueType.Byte:
                        _values[name] = new ByteValue();
                        break;
                    case PropertyValueType.Clob:
                        _values[name] = new ClobValue();
                        break;
                    case PropertyValueType.DateTime:
                        _values[name] = new DateTimeValue();
                        break;
                    case PropertyValueType.Double:
                        _values[name] = new DoubleValue();
                        break;
                    case PropertyValueType.Feature:
                        _values[name] = new FeatureValue();
                        break;
                    case PropertyValueType.Geometry:
                        _values[name] = new GeometryValue();
                        break;
                    case PropertyValueType.Int16:
                        _values[name] = new Int16Value();
                        break;
                    case PropertyValueType.Int32:
                        _values[name] = new Int32Value();
                        break;
                    case PropertyValueType.Int64:
                        _values[name] = new Int64Value();
                        break;
                    case PropertyValueType.Raster:
                        _values[name] = new RasterValue();
                        break;
                    case PropertyValueType.Single:
                        _values[name] = new SingleValue();
                        break;
                    case PropertyValueType.String:
                        _values[name] = new StringValue();
                        break;
                }
            }

            foreach (XmlNode propNode in propertyNodes)
            {
                var name = propNode[nameElement].InnerText;
                var valueNode = propNode[valueElement];
                if (valueNode != null)
                {
                    var value = valueNode.InnerText;
                    switch (_values[name].Type)
                    {
                        case PropertyValueType.Blob:
                            ((BlobValue)_values[name]).Value = Encoding.UTF8.GetBytes(value);
                            break;
                        case PropertyValueType.Boolean:
                            ((BooleanValue)_values[name]).Value = XmlConvert.ToBoolean(value);
                            break;
                        case PropertyValueType.Byte:
                            ((ByteValue)_values[name]).Value = XmlConvert.ToByte(value);
                            break;
                        case PropertyValueType.Clob:
                            ((ClobValue)_values[name]).Value = value.ToCharArray();
                            break;
                        case PropertyValueType.DateTime:
                            var dt = ConvertToDateTime(value);
                            if (dt.HasValue)
                                ((DateTimeValue)_values[name]).Value = dt.Value;
                            break;
                        case PropertyValueType.Double:
                            ((DoubleValue)_values[name]).Value = XmlConvert.ToDouble(value);
                            break;
                        case PropertyValueType.Feature:
                            ((FeatureValue)_values[name]).Value = ConvertToFeatures(value);
                            break;
                        case PropertyValueType.Geometry:
                            ((GeometryValue)_values[name]).Value = wktReader.Read(value);
                            break;
                        case PropertyValueType.Int16:
                            ((Int16Value)_values[name]).Value = XmlConvert.ToInt16(value);
                            break;
                        case PropertyValueType.Int32:
                            ((Int32Value)_values[name]).Value = XmlConvert.ToInt32(value);
                            break;
                        case PropertyValueType.Int64:
                            ((Int64Value)_values[name]).Value = XmlConvert.ToInt64(value);
                            break;
                        case PropertyValueType.Raster:
                            ((RasterValue)_values[name]).Value = ConvertToRaster(value);
                            break;
                        case PropertyValueType.Single:
                            ((SingleValue)_values[name]).Value = XmlConvert.ToSingle(value);
                            break;
                        case PropertyValueType.String:
                            ((StringValue)_values[name]).Value = value;
                            break;
                    }
                }
            }
        }
Пример #40
0
        public void OpenXmlSimpleTypeConverterTest()
        {
            // 1. Base64BinaryValue
            Base64BinaryValue base64 = new Base64BinaryValue();
            base64 = "AA3322";
            Assert.True("AA3322" == base64);
            Assert.Equal("AA3322", base64.Value);
            base64 = Base64BinaryValue.FromString("1234");
            Assert.Equal("1234", base64.ToString());
            Assert.Equal("1234", Base64BinaryValue.ToString(base64));

            // 2. BooleanValue
            BooleanValue booleanValue = new BooleanValue();
            booleanValue = true;
            Assert.True(booleanValue);
            Assert.True(booleanValue.Value);
            booleanValue = BooleanValue.FromBoolean(false);
            Assert.False(booleanValue);
            Assert.Equal(false, BooleanValue.ToBoolean(booleanValue));

            // 3. ByteValue
            ByteValue byteValue = new ByteValue();
            Byte bt = 1;
            byteValue = bt;
            Assert.True(bt == byteValue);
            Assert.Equal(bt, byteValue.Value);
            bt = 2;
            byteValue = ByteValue.FromByte(bt);
            Assert.Equal(bt, ByteValue.ToByte(byteValue));

            // 4. DateTimeValue
            DateTimeValue dtValue = new DateTimeValue();
            DateTime dt = DateTime.Now;
            dtValue = dt;
            Assert.True(dt == dtValue);
            dt = DateTime.Now.AddDays(1);
            dtValue = DateTimeValue.FromDateTime(dt);
            Assert.Equal(dt, dtValue.Value);
            Assert.Equal(dt, DateTimeValue.ToDateTime(dt));

            // 5. DecimalValue
            DecimalValue decimalValue = new DecimalValue();
            decimal dcm = 10;
            decimalValue = dcm;
            Assert.True(dcm == decimalValue);
            decimalValue = DecimalValue.FromDecimal(20);
            Assert.Equal(20, decimalValue.Value);
            Assert.Equal(20, DecimalValue.ToDecimal(decimalValue));

            // 6. DoubleValue
            DoubleValue doubleValue = new DoubleValue();
            double dbl = 1.1;
            doubleValue = dbl;
            Assert.True(dbl == doubleValue);
            doubleValue = DoubleValue.FromDouble(2.2);
            Assert.Equal(2.2, doubleValue.Value);
            Assert.Equal(2.2, DoubleValue.ToDouble(doubleValue));

            // 7. HexBinaryValue
            HexBinaryValue hexBinaryValue = new HexBinaryValue();
            string hex = "0X99CCFF";
            hexBinaryValue = hex;
            Assert.True(hex == hexBinaryValue);
            hex = "111111";
            hexBinaryValue = HexBinaryValue.FromString(hex);
            Assert.Equal(hex, hexBinaryValue.Value);
            Assert.Equal(hex, HexBinaryValue.ToString(hexBinaryValue));

            // 8. Int16
            Int16Value int16Value = new Int16Value();
            Int16 int16 = 16;
            int16Value = int16;
            Assert.True(int16 == int16Value);
            int16 = 17;
            int16Value = Int16Value.FromInt16(int16);
            Assert.Equal(int16, int16Value.Value);
            Assert.Equal(int16, Int16Value.ToInt16(int16Value));

            // 9. Int32
            Int32Value int32Value = new Int32Value();
            Int32 int32 = 32;
            int32Value = int32;
            Assert.True(int32 == int32Value);
            int32 = 33;
            int32Value = Int32Value.FromInt32(int32);
            Assert.Equal(int32, int32Value.Value);
            Assert.Equal(int32, Int32Value.ToInt32(int32Value));

            // 10. Int64
            Int64Value int64Value = new Int64Value();
            Int64 int64 = 64;
            int64Value = int64;
            Assert.True(int64 == int64Value);
            int64 = 17;
            int64Value = Int64Value.FromInt64(int64);
            Assert.Equal(int64, int64Value.Value);
            Assert.Equal(int64, Int64Value.ToInt64(int64Value));

            // 11. IntegerValue
            IntegerValue integerValue = new IntegerValue();
            int integer = 64;
            integerValue = integer;
            Assert.True(integer == integerValue);
            integer = 17;
            integerValue = IntegerValue.FromInt64(integer);
            Assert.Equal(integer, integerValue.Value);
            Assert.Equal(integer, IntegerValue.ToInt64(integerValue));

            // 12. OnOffValue
            OnOffValue onOffValue = new OnOffValue();
            onOffValue = true;
            Assert.True(onOffValue);
            onOffValue = OnOffValue.FromBoolean(false);
            Assert.Equal(false, onOffValue.Value);
            Assert.Equal(false, OnOffValue.ToBoolean(onOffValue));

            // 13. SByteValue
            SByteValue sbyteValue = new SByteValue();
            SByte sbt = SByte.MaxValue;
            sbyteValue = sbt;
            Assert.True(sbt == sbyteValue);
            sbt = SByte.MinValue;
            sbyteValue = SByteValue.FromSByte(sbt);
            Assert.Equal(sbt, sbyteValue.Value);
            Assert.Equal(sbt, SByteValue.ToSByte(sbt));

            // 14. SingleValue
            SingleValue singleValue = new SingleValue();
            Single single = Single.MaxValue;
            singleValue = single;
            Assert.True(single == singleValue);
            single = Single.NaN;
            singleValue = SingleValue.FromSingle(single);
            Assert.Equal(single, singleValue.Value);
            Assert.Equal(single, SingleValue.ToSingle(singleValue));

            // 15. StringValue
            StringValue stringValue = new StringValue();
            String str = "Ethan";
            stringValue = str;
            Assert.True(str == stringValue);
            str = "Yin";
            stringValue = StringValue.FromString(str);
            Assert.Equal(str, stringValue.Value);
            Assert.Equal(str, stringValue.ToString());
            Assert.Equal(str, StringValue.ToString(stringValue));

            // 16. TrueFalseBlankValue
            TrueFalseBlankValue tfbValue = new TrueFalseBlankValue();
            tfbValue = true;
            Assert.True(tfbValue);
            tfbValue = TrueFalseBlankValue.FromBoolean(false);
            Assert.Equal(false, tfbValue.Value);
            Assert.Equal(false, TrueFalseBlankValue.ToBoolean(tfbValue));

            // 17. TrueFalseValue
            TrueFalseValue tfValue = new TrueFalseValue();
            tfValue = true;
            Assert.True(tfValue);
            tfValue = TrueFalseValue.FromBoolean(false);
            Assert.Equal(false, tfValue.Value);
            Assert.Equal(false, TrueFalseValue.ToBoolean(tfValue));

            // 18. UInt16Value
            UInt16Value uint16Value = new UInt16Value();
            UInt16 uint16 = UInt16.MaxValue;
            uint16Value = uint16;
            Assert.True(uint16 == uint16Value);
            uint16 = UInt16.MinValue;
            uint16Value = UInt16Value.FromUInt16(uint16);
            Assert.Equal(uint16, uint16Value.Value);
            Assert.Equal(uint16, UInt16Value.ToUInt16(uint16Value));

            // 19. UInt32Value
            UInt32Value uint32Value = new UInt32Value();
            UInt32 uint32 = UInt32.MaxValue;
            uint32Value = uint32;
            Assert.True(uint32 == uint32Value);
            uint32 = UInt32.MinValue;
            uint32Value = UInt32Value.FromUInt32(uint32);
            Assert.Equal(uint32, uint32Value.Value);
            Assert.Equal(uint32, UInt32Value.ToUInt32(uint32Value));

            // 20. UInt64Value
            UInt64Value uint64Value = new UInt64Value();
            UInt64 uint64 = UInt64.MaxValue;
            uint64Value = uint64;
            Assert.True(uint64 == uint64Value);
            uint64 = UInt64.MinValue;
            uint64Value = UInt64Value.FromUInt64(uint64);
            Assert.Equal(uint64, uint64Value.Value);
            Assert.Equal(uint64, UInt64Value.ToUInt64(uint64Value));
        }
Пример #41
0
			public GreaterThanOrEqualExpression(L20nObject a, L20nObject b)
			: base(a, b)
			{
				m_Output = new BooleanValue();
			}
Пример #42
0
			public LessThanExpression(L20nObject a, L20nObject b)
			: base(a, b)
			{
				m_Output = new BooleanValue();
			}
Пример #43
0
 public SCCBooleanValue(BooleanValue o, ITree antlr)
     : base(o, antlr)
 {
 }
Пример #44
0
 private CommandDefinition.CommandFormat ConstructCommand(CommandEnum command, BooleanValue ackReq, ActionEnum action, byte subAction)
 {
     CommandDefinition.CommandAckStruct cmdAck = new CommandDefinition.CommandAckStruct(command, ackReq, BooleanValue.False);
     CommandDefinition.ActionStruct a = new CommandDefinition.ActionStruct(action, subAction);
     CommandDefinition.CommandFormat cmd = new CommandDefinition.CommandFormat(cmdAck.CommandWithAck, a.ActionAndSubAction);
     return cmd;
 }
 /// <summary>
 /// Adds a new boolean value to the list of query parameters.
 /// </summary>
 /// <param name="key">The parameter name.</param>
 /// <param name="value">The parameter value.</param>
 /// <returns>The statement builder, for chaining method calls.</returns>
 public StatementBuilder AddValue(string key, bool value) {
   BooleanValue queryValue = new BooleanValue();
   queryValue.value = value;
   return AddValue(key, queryValue);
 }
Пример #46
0
 internal override Value IsNotEqualToBool(BooleanValue value)
 {
     return new Undefined();
 }
Пример #47
0
        internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction)
        {
            OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length];

            switch (unionValueRestriction.UnionId)
            {
                // ST_AnimationDgmBuildType
                case 25:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>();
                    break;

                // ST_AnimationChartBuildType
                case 27:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>();
                    break;

                // ST_AdjCoordinate
                case 45:
                    simpleValues[0] = new Int64Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_AdjAngle
                case 46:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_LayoutShapeType
                case 145:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.ShapeTypeValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>();
                    break;

                // ST_ParameterVal
                case 183:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>();
                    simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>();
                    simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>();
                    simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>();
                    simpleValues[10] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>();
                    simpleValues[11] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>();
                    simpleValues[12] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>();
                    simpleValues[13] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>();
                    simpleValues[14] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>();
                    simpleValues[15] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>();
                    simpleValues[16] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>();
                    simpleValues[17] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>();
                    simpleValues[18] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>();
                    simpleValues[19] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>();
                    simpleValues[20] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>();
                    simpleValues[21] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>();
                    simpleValues[22] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>();
                    simpleValues[23] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>();
                    simpleValues[24] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>();
                    simpleValues[25] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>();
                    simpleValues[26] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>();
                    simpleValues[27] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>();
                    simpleValues[28] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>();
                    simpleValues[29] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>();
                    simpleValues[30] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>();
                    simpleValues[31] = new Int32Value();
                    simpleValues[32] = new DoubleValue();
                    simpleValues[33] = new BooleanValue();
                    simpleValues[34] = new StringValue();
                    simpleValues[35] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>();
                    break;

                // ST_ModelId
                case 184:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_FunctionValue
                case 207:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new BooleanValue();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>();
                    break;

                // ST_FunctionArgument
                case 209:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>();
                    break;

                // ST_NonZeroDecimalNumber
                case 368:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_MarkupId
                case 375:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_HexColor
                case 404:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>();
                    simpleValues[1] = new HexBinaryValue();
                    break;

                // ST_DecimalNumberOrPercent
                case 507:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new Int32Value();
                    break;

                // ST_SignedHpsMeasure_O14
                case 525:
                    simpleValues[0] = new IntegerValue();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_HpsMeasure_O14
                case 528:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_SignedTwipsMeasure_O14
                case 531:
                    simpleValues[0] = new IntegerValue();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_TwipsMeasure_O14
                case 534:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_TransitionEightDirectionType
                case 544:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>();
                    break;

                // ST_TLTimeAnimateValueTime
                case 561:
                    simpleValues[0] = new Int32Value();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_TLTime_O12
                case 603:
                    simpleValues[0] = new UInt32Value();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_TLTime_O14
                case 604:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>();
                    break;

                // ST_PublishDate
                case 689:
                    simpleValues[0] = new DateTimeValue();
                    simpleValues[1] = new DateTimeValue();
                    simpleValues[2] = new StringValue();
                    break;

                // ST_ChannelDataPoint
                case 697:
                    simpleValues[0] = new DecimalValue();
                    simpleValues[1] = new BooleanValue();
                    break;

                // ST_ChannelPropertyName
                case 701:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_BrushPropertyName
                case 704:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_ChannelName
                case 707:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelNameValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_Units
                case 719:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>();
                    simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>();
                    simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>();
                    simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>();
                    simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>();
                    simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>();
                    simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>();
                    simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>();
                    simpleValues[10] = new StringValue();
                    break;

                // ST_BrushPropertyValue
                case 732:
                    simpleValues[0] = new DecimalValue();
                    simpleValues[1] = new BooleanValue();
                    simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.PenTipShapeValues>();
                    simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.RasterOperationValues>();
                    simpleValues[4] = new StringValue();
                    break;

                // ST_Ref
                case 746:
                    simpleValues[0] = new StringValue();
                    simpleValues[1] = new UInt32Value();
                    break;

                // ST_CtxNodeType
                case 747:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>();
                    simpleValues[1] = new StringValue();
                    break;

                // ST_SemanticType
                case 750:
                    simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>();
                    simpleValues[1] = new UInt32Value();
                    break;

                // ST_PointsOrInt
                case 753:
                    simpleValues[0] = new ListValue<StringValue>();
                    simpleValues[1] = new Int32Value();
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }

            Debug.Assert(simpleValues.Length > 0);

            return simpleValues;
        }
Пример #48
0
        public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw)
        {
            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                string name = reader.GetPropertyName(i);

                _ordinalMap[i] = name;

                var pt = (PropertyValueType)reader.GetPropertyType(name);
                switch (pt)
                {
                    case PropertyValueType.Blob:
                        _values[name] = new BlobValue();
                        break;
                    case PropertyValueType.Boolean:
                        _values[name] = new BooleanValue();
                        break;
                    case PropertyValueType.Byte:
                        _values[name] = new ByteValue();
                        break;
                    case PropertyValueType.Clob:
                        _values[name] = new ClobValue();
                        break;
                    case PropertyValueType.DateTime:
                        _values[name] = new DateTimeValue();
                        break;
                    case PropertyValueType.Double:
                        _values[name] = new DoubleValue();
                        break;
                    case PropertyValueType.Feature:
                        _values[name] = new FeatureValue();
                        break;
                    case PropertyValueType.Geometry:
                        _values[name] = new GeometryValue();
                        break;
                    case PropertyValueType.Int16:
                        _values[name] = new Int16Value();
                        break;
                    case PropertyValueType.Int32:
                        _values[name] = new Int32Value();
                        break;
                    case PropertyValueType.Int64:
                        _values[name] = new Int64Value();
                        break;
                    case PropertyValueType.Raster:
                        _values[name] = new RasterValue();
                        break;
                    case PropertyValueType.Single:
                        _values[name] = new SingleValue();
                        break;
                    case PropertyValueType.String:
                        _values[name] = new StringValue();
                        break;
                }
            }

            for (int i = 0; i < reader.GetPropertyCount(); i++)
            {
                string name = _ordinalMap[i];
                GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); };
                GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); };
                GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); };
                if (!reader.IsNull(name))
                {
                    var pt = (PropertyValueType)reader.GetPropertyType(name);
                    switch (pt)
                    {
                        case PropertyValueType.Blob:
                            ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob));
                            break;
                        case PropertyValueType.Boolean:
                            ((BooleanValue)_values[name]).Value = reader.GetBoolean(name);
                            break;
                        case PropertyValueType.Byte:
                            ((ByteValue)_values[name]).Value = reader.GetByte(name);
                            break;
                        case PropertyValueType.Clob:
                            byte [] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob));
                            ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b);
                            break;
                        case PropertyValueType.DateTime:
                            ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name));
                            break;
                        case PropertyValueType.Double:
                            ((DoubleValue)_values[name]).Value = reader.GetDouble(name);
                            break;
                        //case PropertyValueType.Feature:
                        case PropertyValueType.Geometry:
                            try
                            {
                                //TODO: See if SWIG issues come into play here
                                var geom = agfRw.Read(reader.GetGeometry(name));
                                var wkt = wktRw.Write(geom);
                                ((GeometryValue)_values[name]).Value = mgReader.Read(wkt);
                            }
                            catch //Invalid geometry fail!
                            {
                                ((GeometryValue)_values[name]).SetNull();
                            }
                            break;
                        case PropertyValueType.Int16:
                            ((Int16Value)_values[name]).Value = reader.GetInt16(name);
                            break;
                        case PropertyValueType.Int32:
                            ((Int32Value)_values[name]).Value = reader.GetInt32(name);
                            break;
                        case PropertyValueType.Int64:
                            ((Int64Value)_values[name]).Value = reader.GetInt64(name);
                            break;
                        case PropertyValueType.Single:
                            ((SingleValue)_values[name]).Value = reader.GetSingle(name);
                            break;
                        case PropertyValueType.String:
                            ((StringValue)_values[name]).Value = reader.GetString(name);
                            break;
                    }
                }
            }
        }
Пример #49
0
			/// <summary>
			/// Initializes a new instance of the <see cref="L20nCore.Objects.NegateExpression"/> class.
			/// </summary>
			public NegateExpression(L20nObject expression)
			{
				m_Expression = expression;
				m_Output = new BooleanValue();
			}
Пример #50
0
        private void Prepare(PropertyValueCollection propVals)
        {
            propVals.Clear();
            currentValues.Clear();

            // I do not trust the long-term stability of the PropertyValueCollection
            //
            // So what we do is load it up once with LiteralValue references and manipulate these
            // outside of the collection (via a cached dictionary). We cache everything from the wrapper API 
            // that can be cached in the managed world so that we only have minimal contact with it

            // Omit read-only properties
            using (FdoFeatureService service = _conn.CreateFeatureService())
            {
                ClassDefinition c = service.GetClassByName(this.ClassName);
                foreach (PropertyDefinition p in c.Properties)
                {
                    string name = p.Name;
                    PropertyValue pv = new PropertyValue(name, null);
                    if (p.PropertyType == PropertyType.PropertyType_DataProperty)
                    {
                        DataPropertyDefinition d = p as DataPropertyDefinition;
                        if (!d.ReadOnly && !d.IsAutoGenerated) 
                        {
                            DataValue dv = null;
                            switch (d.DataType)
                            {
                                case DataType.DataType_BLOB:
                                    dv = new BLOBValue();
                                    break;
                                case DataType.DataType_Boolean:
                                    dv = new BooleanValue();
                                    break;
                                case DataType.DataType_Byte:
                                    dv = new ByteValue();
                                    break;
                                case DataType.DataType_CLOB:
                                    dv = new CLOBValue();
                                    break;
                                case DataType.DataType_DateTime:
                                    dv = new DateTimeValue();
                                    break;
                                case DataType.DataType_Decimal:
                                    dv = new DecimalValue();
                                    break;
                                case DataType.DataType_Double:
                                    dv = new DoubleValue();
                                    break;
                                case DataType.DataType_Int16:
                                    dv = new Int16Value();
                                    break;
                                case DataType.DataType_Int32:
                                    dv = new Int32Value();
                                    break;
                                case DataType.DataType_Int64:
                                    dv = new Int64Value();
                                    break;
                                case DataType.DataType_Single:
                                    dv = new SingleValue();
                                    break;
                                case DataType.DataType_String:
                                    dv = new StringValue();
                                    break;
                            }
                            if (dv != null)
                            {
                                pv.Value = dv;
                                propVals.Add(pv);
                            }
                        }
                    }
                    else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty)
                    {
                        GeometricPropertyDefinition g = p as GeometricPropertyDefinition;
                        if (!g.ReadOnly)
                        {
                            GeometryValue gv = new GeometryValue();
                            pv.Value = gv;
                            propVals.Add(pv);
                        }
                    }
                }
                c.Dispose();
            }

            //Load property values into temp dictionary
            foreach (PropertyValue p in propVals)
            {
                currentValues[p.Name.Name] = p.Value as LiteralValue;
            }

            if (propertySnapshot == null)
            {
                propertySnapshot = new List<string>();
                foreach (PropertyValue p in propVals)
                {
                    propertySnapshot.Add(p.Name.Name);
                }
            }
        }
Пример #51
0
 internal virtual Value IsNotEqualToBool(BooleanValue value)
 {
     throw new InvalidOperationException(CreateMessage(Operation.NotEqualTo, value, this));
 }
Пример #52
0
 private static DataValue ConvertBoolean(BooleanValue src, DataType dataType)
 {
     switch (dataType)
     {
         case DataType.DataType_String:
             return new StringValue(src.Boolean.ToString());
         case DataType.DataType_Byte:
             return new ByteValue(Convert.ToByte(src.Boolean));
         case DataType.DataType_Int16:
             return new Int16Value(Convert.ToInt16(src.Boolean));
         case DataType.DataType_Int32:
             return new Int32Value(Convert.ToInt32(src.Boolean));
         case DataType.DataType_Int64:
             return new Int64Value(Convert.ToInt64(src.Boolean));
         default:
             return null;
     }
 }
Пример #53
0
			/// <summary>
			/// Initializes a new instance of the <see cref="L20nCore.Objects.BinaryExpression"/> class.
			/// </summary>
			public BinaryExpression(L20nObject first, L20nObject second)
			{
				m_First = first;
				m_Second = second;
				m_Output = new BooleanValue();
			}
Пример #54
0
 public BooleanValueOrExpression(BooleanValue booleanValue)
 {
     BooleanValue = booleanValue;
 }
Пример #55
0
        public void TestBooleanConversion()
        {
            BooleanValue b = new BooleanValue(true);
            DataValue dv = null;

            //To BLOB
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_BLOB, true, true);
            Assert.IsNull(dv);

            //To Boolean
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Boolean, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_Boolean);
            Assert.AreEqual(dv, b);

            dv = null;
            //To Byte
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Byte, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_Byte);
            
            //To CLOB
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_CLOB, true, true);
            Assert.IsNull(dv);

            //To DateTime
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_DateTime, true, true);
            Assert.IsNull(dv);

            //To Decimal
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Decimal, true, true);
            Assert.IsNull(dv);

            //To Double
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Double, true, true);
            Assert.IsNull(dv);

            dv = null;
            //To String
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_String, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_String);

            dv = null;
            //To Int16
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Int16, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_Int16);

            dv = null;
            //To Int32
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Int32, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_Int32);

            dv = null;
            //To Int64
            dv = ValueConverter.ConvertDataValue(b, DataType.DataType_Int64, true, true);
            Assert.IsNotNull(dv);
            Assert.AreEqual(dv.DataType, DataType.DataType_Int64);
        }
Пример #56
0
 internal virtual Value AndBool(BooleanValue value)
 {
     throw new InvalidOperationException();
 }
Пример #57
0
 public override BooleanValue CreateBooleanValue(BooleanValue o, Antlr.Runtime.Tree.ITree antlr)
 {
     return new SCCBooleanValue(o, antlr);
 }