Esempio n. 1
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         StartValue = ValueParser.ParseWordValue(valueStrings[0]);
     }
     catch (ValueParseException exception)
     {
         StartValue = WordValue.Null;
     }
 }
Esempio n. 2
0
#pragma warning restore 612,618

        #endregion BEGIN ADDED BY MPAUL42: monoGIS team

        /// <summary>
        /// Method to parse an envelope from its <see cref="Envelope.ToString"/> value
        /// </summary>
        /// <param name="envelope">The envelope string</param>
        /// <returns>The envelope</returns>
        public static Envelope Parse(string envelope)
        {
            if (string.IsNullOrEmpty(envelope))
            {
                throw new ArgumentNullException("envelope");
            }
            if (!(envelope.StartsWith("Env[") && envelope.EndsWith("]")))
            {
                throw new ArgumentException("Not a valid envelope string", "envelope");
            }

            // test for null
            envelope = envelope.Substring(4, envelope.Length - 5);
            if (envelope == "Null")
            {
                return(new Envelope());
            }

            // Parse values
            var ordinatesValues = new double[4];
            var ordinateLabel   = new[] { "x", "y" };
            var j = 0;

            // split into ranges
            var parts = envelope.Split(',');

            if (parts.Length != 2)
            {
                throw new ArgumentException("Does not provide two ranges", "envelope");
            }

            foreach (var part in parts)
            {
                // Split int min/max
                var ordinates = part.Split(':');
                if (ordinates.Length != 2)
                {
                    throw new ArgumentException("Does not provide just min and max values", "envelope");
                }

                if (!ValueParser.TryParse(ordinates[0].Trim(), NumberStyles.Number, NumberFormatInfo.InvariantInfo, out ordinatesValues[2 * j]))
                {
                    throw new ArgumentException(string.Format("Could not parse min {0}-Ordinate", ordinateLabel[j]), "envelope");
                }
                if (!ValueParser.TryParse(ordinates[1].Trim(), NumberStyles.Number, NumberFormatInfo.InvariantInfo, out ordinatesValues[2 * j + 1]))
                {
                    throw new ArgumentException(string.Format("Could not parse max {0}-Ordinate", ordinateLabel[j]), "envelope");
                }
                j++;
            }

            return(new Envelope(ordinatesValues[0], ordinatesValues[1],
                                ordinatesValues[2], ordinatesValues[3]));
        }
Esempio n. 3
0
 public void ParseValue(ValueParser parser)
 {
     if (!string.IsNullOrEmpty(Value))
     {
         Parsed = parser.Parse(Parameter.Type, Value);
     }
     else if (Parameter != null)
     {
         Parsed = Parameter.DefaultValue;
     }
 }
Esempio n. 4
0
        public void ShouldParseSimpleDynamicTypeWithFormatting()
        {
            var termValue = ValueParser.Parse("My birthday is {birthday:dd/MM/yyyy#DateTime}");

            termValue.CSharpStringFormatValue.ShouldEqual("My birthday is {0:dd/MM/yyyy}");
            termValue.Parameters.Count.ShouldEqual(1);
            termValue.Parameters[0].Name.ShouldEqual("birthday");
            termValue.Parameters[0].Type.ShouldEqual("DateTime");
            termValue.Parameters[0].Index.ShouldEqual(0);
            termValue.Parameters[0].Format.ShouldEqual("dd/MM/yyyy");
        }
Esempio n. 5
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         OutputValue = ValueParser.ParseBitValue(valueStrings[0]);
     }
     catch (ValueParseException)
     {
         OutputValue = BitValue.Null;
     }
 }
Esempio n. 6
0
        public void ShouldParseSimpleDynamicWithType()
        {
            var termValue = ValueParser.Parse("I am {age#int}");

            termValue.CSharpStringFormatValue.ShouldEqual("I am {0}");
            termValue.Parameters.Count.ShouldEqual(1);
            termValue.Parameters[0].Name.ShouldEqual("age");
            termValue.Parameters[0].Type.ShouldEqual("int");
            termValue.Parameters[0].Index.ShouldEqual(0);
            termValue.Parameters[0].Format.ShouldBeNull();
        }
Esempio n. 7
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         Value = ValueParser.ParseBitValue(valueStrings[0]);
     }
     catch
     {
         Value = BitValue.Null;
     }
 }
Esempio n. 8
0
 private void ValueTextBox6_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (ValueParser.IsVariablePattern(ValueString6))
     {
         CommentString6 = ValueCommentManager.GetComment(ValueString6);
     }
     else
     {
         CommentString6 = ValueCommentManager.GetComment(ValueString6.ToUpper());
     }
 }
Esempio n. 9
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         IDValue = ValueParser.ParseWordValue(valueStrings[0]);
     }
     catch (ValueParseException)
     {
         IDValue = WordValue.Null;
     }
     FuncName = valueStrings[2];
 }
Esempio n. 10
0
            public void Should_Return_True_For_Correct_Element()
            {
                // Given
                var parser = new ValueParser();
                var node   = "<value>Hello World</value>".CreateXmlNode();

                // When
                var result = parser.CanParse(node);

                // Then
                Assert.True(result);
            }
Esempio n. 11
0
 public static void RegisterValueParser(CommandLineApplication app, IConsole console)
 {
     app.ValueParsers.Add(ValueParser.Create((name, value, culture) =>
     {
         if (string.IsNullOrWhiteSpace(value) && console.IsInputRedirected)
         {
             value = console.In.ReadLine();
         }
         return(new Password {
             Value = value
         });
     }));
 }
Esempio n. 12
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         CountValue  = ValueParser.ParseDoubleWordValue(valueStrings[0]);
         DefineValue = ValueParser.ParseDoubleWordValue(valueStrings[1]);
     }
     catch (ValueParseException)
     {
         CountValue  = DoubleWordValue.Null;
         DefineValue = DoubleWordValue.Null;
     }
 }
Esempio n. 13
0
            public void Should_Parse_Content_Recursivly()
            {
                // Given
                var commentParser = Substitute.For <ICommentParser>();
                var nodeParser    = new ValueParser();
                var node          = "<value>Hello World</value>".CreateXmlNode();

                // When
                nodeParser.Parse(commentParser, node);

                // Then
                commentParser.Received(1).Parse(Arg.Any <XmlNode>());
            }
Esempio n. 14
0
        private async Task OnValueChanged(ChangeEventArgs e)
        {
            _value = e.Value?.ToString();

            var parseResult = ValueParser.TryParse <TValue>(_value);

            if (parseResult.Item2)
            {
                await ValueChanged.InvokeAsync(parseResult.Item1);

                await Changed.InvokeAsync(parseResult.Item1);
            }
        }
Esempio n. 15
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(4);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine1("IN1:", InputValue1);
         *  dialog.ShowLine3("IN2:", InputValue2);
         *  dialog.ShowLine5("IN3:", InputValue3);
         *  dialog.ShowLine7("OUT:", OutputValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = InputValue1.ValueString;
            var  oldvaluestring2 = InputValue2.ValueString;
            var  oldvaluestring3 = InputValue3.ValueString;
            var  oldvaluestring4 = OutputValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex
            });
            bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] {
                ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex
            });
            bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] {
                ValueParser.VerifyBitRegex3
            });

            if (check1 && check2 && check3 && check4)
            {
                InputValue1 = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice);
                InputValue2 = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice);
                InputValue3 = ValueParser.ParseDoubleWordValue(valueStrings[4], contextDevice);
                OutputValue = ValueParser.ParseBitValue(valueStrings[6], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, InputValue1.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, InputValue2.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, InputValue3.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring4, OutputValue.ValueString);
                ValueCommentManager.UpdateComment(InputValue1, valueStrings[1]);
                ValueCommentManager.UpdateComment(InputValue2, valueStrings[3]);
                ValueCommentManager.UpdateComment(InputValue3, valueStrings[5]);
                ValueCommentManager.UpdateComment(OutputValue, valueStrings[7]);
            }
            else if (!check1)
            {
                throw new ValueParseException("IN1格式错误!");
            }
            else if (!check2)
            {
                throw new ValueParseException("IN2格式错误!");
            }
            else if (!check3)
            {
                throw new ValueParseException("IN3格式错误!");
            }
            else if (!check4)
            {
                throw new ValueParseException("OUT格式错误!");
            }
        }
Esempio n. 16
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(4);
         *  dialog.ShowLine1("D:", ArgumentValue);
         *  dialog.ShowLine3("V:", VelocityValue);
         *  dialog.ShowLine5("OUT1:", OutputValue1);
         *  dialog.ShowLine7("OUT2:", OutputValue2);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = ArgumentValue.ValueString;
            var  oldvaluestring2 = VelocityValue.ValueString;
            var  oldvaluestring3 = OutputValue1.ValueString;
            var  oldvaluestring4 = OutputValue2.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyWordRegex3
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex
            });
            bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] {
                ValueParser.VerifyBitRegex4
            });
            bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] {
                ValueParser.VerifyBitRegex4
            });

            if (check1 && check2 && check3)
            {
                ArgumentValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                VelocityValue = ValueParser.ParseWordValue(valueStrings[2], contextDevice);
                OutputValue1  = ValueParser.ParseBitValue(valueStrings[4], contextDevice);
                OutputValue2  = ValueParser.ParseBitValue(valueStrings[6], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, ArgumentValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, VelocityValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue1.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue2.ValueString);
                ValueCommentManager.UpdateComment(ArgumentValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(VelocityValue, valueStrings[3]);
                ValueCommentManager.UpdateComment(OutputValue1, valueStrings[5]);
                ValueCommentManager.UpdateComment(OutputValue2, valueStrings[7]);
            }
            else if (!check1)
            {
                throw new ValueParseException("D格式非法!");
            }
            else if (!check2)
            {
                throw new ValueParseException("V格式非法");
            }
            else if (!check3)
            {
                throw new ValueParseException("OUT1格式非法!");
            }
            else if (!check4)
            {
                throw new ValueParseException("OUT2格式非法!");
            }
        }
Esempio n. 17
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(4);
         *  dialog.ShowLine1("BV:", BackValue);
         *  dialog.ShowLine3("CV:", CrawValue);
         *  dialog.ShowLine5("SIGN:", SignalValue);
         *  dialog.ShowLine7("OUT:", OutputValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = BackValue.ValueString;
            var  oldvaluestring2 = CrawValue.ValueString;
            var  oldvaluestring3 = SignalValue.ValueString;
            var  oldvaluestring4 = OutputValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyWordRegex3
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex
            });
            bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] {
                ValueParser.VerifyBitRegex5
            });
            bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] {
                ValueParser.VerifyBitRegex4
            });

            if (check1 && check2 && check3 && check4)
            {
                BackValue   = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                CrawValue   = ValueParser.ParseWordValue(valueStrings[2], contextDevice);
                SignalValue = ValueParser.ParseBitValue(valueStrings[4], contextDevice);
                OutputValue = ValueParser.ParseBitValue(valueStrings[6], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, BackValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, CrawValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, SignalValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue.ValueString);
                ValueCommentManager.UpdateComment(BackValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(CrawValue, valueStrings[3]);
                ValueCommentManager.UpdateComment(SignalValue, valueStrings[5]);
                ValueCommentManager.UpdateComment(OutputValue, valueStrings[7]);
            }
            else if (!check1)
            {
                throw new ValueParseException("BV格式非法!");
            }
            else if (!check2)
            {
                throw new ValueParseException("CV格式非法");
            }
            else if (!check3)
            {
                throw new ValueParseException("SIGN格式非法!");
            }
            else if (!check4)
            {
                throw new ValueParseException("OUT格式非法!");
            }
        }
Esempio n. 18
0
        public void TryParse_FloatStringIntWithGroupSeparatorAndCustomDecimalSeparator_ReturnFloat()
        {
            var nfi = new NumberFormatInfo
            {
                NumberGroupSeparator   = " ",
                NumberDecimalSeparator = ",",
                NumberDecimalDigits    = 3
            };

            var parseResult = ValueParser.TryParse <float>("1 000,234", nfi);

            Assert.IsTrue(parseResult.IsParsed);
            Assert.AreEqual(1000.234F, parseResult.Value);
        }
Esempio n. 19
0
 // Rates are in units of |value| per real-time second.
 public DifferentialSlider(string label,
                           string unit,
                           double log10_lower_rate,
                           double log10_upper_rate,
                           double zero_value             = 0,
                           double min_value              = double.NegativeInfinity,
                           double max_value              = double.PositiveInfinity,
                           ValueFormatter formatter      = null,
                           ValueParser parser            = null,
                           UnityEngine.Color?text_colour = null,
                           int label_width = 3,
                           int field_width = 5)
 {
     label_       = label;
     label_width_ = label_width;
     field_width_ = field_width;
     unit_        = unit;
     if (formatter == null)
     {
         // TODO(egg): Is this just "N3"?
         formatter_ = v => v.ToString("#,0.000", Culture.culture);
     }
     else
     {
         formatter_ = formatter;
     }
     if (parser == null)
     {
         // As a special exemption we allow a comma as the decimal separator.
         parser_ = (string s, out double value) =>
                   double.TryParse(s.Replace(',', '.'),
                                   NumberStyles.AllowDecimalPoint |
                                   NumberStyles.AllowLeadingSign |
                                   NumberStyles.AllowLeadingWhite |
                                   NumberStyles.AllowThousands |
                                   NumberStyles.AllowTrailingWhite,
                                   Culture.culture.NumberFormat,
                                   out value);
     }
     else
     {
         parser_ = parser;
     }
     log10_lower_rate_ = log10_lower_rate;
     log10_upper_rate_ = log10_upper_rate;
     zero_value_       = zero_value;
     min_value_        = min_value;
     max_value_        = max_value;
     text_colour_      = text_colour;
 }
Esempio n. 20
0
 // Rates are in units of |value| per real-time second.
 public DifferentialSlider(string label,
                           string unit,
                           double log10_lower_rate,
                           double log10_upper_rate,
                           ValueFormatter formatter,
                           UnityEngine.TextAnchor alignment =
                           UnityEngine.TextAnchor.MiddleRight,
                           ValueParser parser            = null,
                           double zero_value             = 0,
                           double min_value              = double.NegativeInfinity,
                           double max_value              = double.PositiveInfinity,
                           UnityEngine.Color?text_colour = null,
                           int label_width = 3,
                           int field_width = 5)
 {
     label_       = label;
     label_width_ = label_width;
     field_width_ = field_width;
     unit_        = unit;
     alignment_   = alignment;
     formatter_   = formatter;
     if (parser == null)
     {
         // As a special exemption we allow a comma as the decimal separator and
         // the hyphen-minus instead of the minus sign.
         // We also turn figure spaces back into leading 0s, and remove grouping
         // marks, since .NET does not like those in the fractional part.
         parser_ = (string s, out double value) => double.TryParse(
             s.Replace(',', '.').Replace('-', '−')
             .Replace(figure_space, '0').Replace("'", ""),
             NumberStyles.AllowDecimalPoint |
             NumberStyles.AllowLeadingSign |
             NumberStyles.AllowLeadingWhite |
             NumberStyles.AllowThousands |
             NumberStyles.AllowTrailingWhite,
             Culture.culture.NumberFormat,
             out value);
     }
     else
     {
         parser_ = parser;
     }
     log10_lower_rate_ = log10_lower_rate;
     log10_upper_rate_ = log10_upper_rate;
     zero_value_       = zero_value;
     min_value_        = min_value;
     max_value_        = max_value;
     text_colour_      = text_colour;
 }
Esempio n. 21
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(1);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine4("LBL",LBLIndex);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring = LBLIndex.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyIntKHValueRegex }))
            {
                LBLIndex = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring, LBLIndex.ValueString);
                ValueCommentManager.UpdateComment(LBLIndex, valueStrings[1]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }
Esempio n. 22
0
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring = Value.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyBitRegex3 }))
            {
                Value = ValueParser.ParseBitValue(valueStrings[0], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring, Value.ValueString);
                ValueCommentManager.UpdateComment(Value, valueStrings[1]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }
Esempio n. 23
0
        private protected static T ParseHeader <THeaders, T>(string headerName, HeadersReader <THeaders> reader,
                                                             ValueParser <T> parser)
            where THeaders : IEnumerable <string>
        {
            if (reader(headerName, out var headers))
            {
                foreach (var header in headers)
                {
                    if (parser(header, out var result))
                    {
                        return(result);
                    }
                }
            }

            throw new RaftProtocolException(ExceptionMessages.MissingHeader(headerName));
        }
Esempio n. 24
0
        public static Specification <TFact, TProjection> Match <TProjection>(Expression <Func <TFact, TProjection> > spec)
        {
            var    parameter       = spec.Parameters[0];
            var    initialFactName = parameter.Name;
            var    initialFactType = parameter.Type.FactTypeName();
            object proxy           = SpecificationParser.InstanceOfFact(typeof(TFact));
            var    label           = new Label(initialFactName, initialFactType);
            var    context         = SpecificationContext.Empty.With(label, proxy, parameter.Type);
            var    startingSet     = new SetDefinitionInitial(label, parameter.Type);
            var    symbolTable     = SymbolTable.Empty.With(initialFactName, new SymbolValueSetDefinition(startingSet));

            var symbolValue   = ValueParser.ParseValue(symbolTable, context, spec.Body).symbolValue;
            var result        = SpecificationParser.ParseValue(symbolValue);
            var specification = SpecificationGenerator.CreateSpecification(context, result);

            return(new Specification <TFact, TProjection>(specification.Pipeline, specification.Projection));
        }
Esempio n. 25
0
        /// <summary>
        /// Removes an item from the enumeration
        /// </summary>
        /// <typeparam name="T">Enumeration type</typeparam>
        /// <param name="item">enumeration item</param>
        /// <param name="itemToRemove">item to remove from enumeration</param>
        /// <returns>Removed result</returns>
        public static T Remove <T>(this Enum item, T itemToRemove)
        {
            Type        myType     = item.GetType();
            object      result     = item;
            ValueParser itemParsed = new ValueParser(itemToRemove, myType);

            if (itemParsed.Signed is long)
            {
                result = Convert.ToInt64(item) & ~(long)itemParsed.Signed;
            }
            else if (itemParsed.Unsigned is ulong)
            {
                result = Convert.ToUInt64(item) & ~(ulong)itemParsed.Unsigned;
            }

            return((T)Enum.Parse(myType, result.ToString()));
        }
Esempio n. 26
0
        public MessageData(
            IDictionary<string, string> specialPropsBindings,
            IDictionary<string, string> distinctIdPropsBindings,
            MessagePropetiesRules messagePropetiesRules,
            SuperPropertiesRules superPropertiesRules,
            MixpanelConfig config = null)
        {
            _specialPropsBindings = specialPropsBindings ?? new Dictionary<string, string>();
            _distinctIdPropsBindings = distinctIdPropsBindings ?? new Dictionary<string, string>();
            _messagePropetiesRules = messagePropetiesRules;
            _superPropertiesRules = superPropertiesRules;
            _valueParser = new ValueParser();
            _nameFormatter = new PropertyNameFormatter(config);
            _propertiesDigger = new PropertiesDigger();

            SpecialProps = new Dictionary<string, object>();
            Props = new Dictionary<string, object>();
        }
Esempio n. 27
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(1);
         *  dialog.ShowLine4("OUT:", OutputValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = OutputValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyBitRegex4
            });

            if (check1)
            {
                OutputValue = ValueParser.ParseBitValue(valueStrings[0], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, OutputValue.ValueString);
                ValueCommentManager.UpdateComment(OutputValue, valueStrings[1]);
            }
            else
            {
                throw new ValueParseException("OUT格式非法!");
            }
        }
Esempio n. 28
0
        public MessageData(
            IDictionary <string, string> specialPropsBindings,
            IDictionary <string, string> distinctIdPropsBindings,
            MessagePropetiesRules messagePropetiesRules,
            SuperPropertiesRules superPropertiesRules,
            MixpanelConfig config = null)
        {
            _specialPropsBindings    = specialPropsBindings ?? new Dictionary <string, string>();
            _distinctIdPropsBindings = distinctIdPropsBindings ?? new Dictionary <string, string>();
            _messagePropetiesRules   = messagePropetiesRules;
            _superPropertiesRules    = superPropertiesRules;
            _valueParser             = new ValueParser();
            _nameFormatter           = new PropertyNameFormatter(config);
            _propertiesDigger        = new PropertiesDigger();

            SpecialProps = new Dictionary <string, object>();
            Props        = new Dictionary <string, object>();
        }
Esempio n. 29
0
        private static Expression ConcatenateAndOrExpressions(
            IEnumerable <Filter> filters,
            ParameterExpression itemParameter,
            Type filterableClassType)
        {
            Expression where = null;
            MemberExpression property;
            Expression       filterExpression;

            if (filters != null)
            {
                foreach (var filter in filters)
                {
                    property = RecursivelyPropertyInfoGetter.CreatePropertyExpression(itemParameter, filter.PropertyName);

                    filter.Value = ValueParser.ParseValueToPropertyType(property, filter.Value);

                    filterExpression = CompareExpressionByOperator(
                        filter.Operator,
                        property,
                        Expression.Constant(filter.Value));

                    if (filter.OrFilters != null && filter.OrFilters.Count > 0)
                    {
                        Expression filtersExpressions = ConcatenateAndOrExpressions(filter.OrFilters, itemParameter, filterableClassType);
                        if (filtersExpressions != null)
                        {
                            filterExpression = Expression.OrElse(filterExpression, filtersExpressions);
                        }
                    }

                    if (where != null)
                    {
                        where = Expression.AndAlso(where, filterExpression);
                    }
                    else
                    {
                        where = filterExpression;
                    }
                }
            }

            return(where);
        }
Esempio n. 30
0
 public override void ParseValue(IList <string> valueStrings)
 {
     try
     {
         Value1 = ValueParser.ParseDoubleWordValue(valueStrings[0]);
     }
     catch (ValueParseException exception)
     {
         Value1 = DoubleWordValue.Null;
     }
     try
     {
         Value2 = ValueParser.ParseDoubleWordValue(valueStrings[1]);
     }
     catch (ValueParseException exception)
     {
         Value2 = DoubleWordValue.Null;
     }
 }
Esempio n. 31
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(2);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine3("DW1",Value1);
         *  dialog.ShowLine5("DW2",Value2);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring1 = Value1.ValueString;
            var oldvaluestring2 = Value2.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }))
            {
                Value1 = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice);
                Value2 = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, Value1.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, Value2.ValueString);
                ValueCommentManager.UpdateComment(Value1, valueStrings[1]);
                ValueCommentManager.UpdateComment(Value2, valueStrings[3]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }
 protected MessageBuilderBase(MixpanelConfig config = null)
 {
     Config = config;
     ValueParser = new ValueParser();
     PropertyNameFormatter = new PropertyNameFormatter(config);
 }
Esempio n. 33
0
 public void ParseValue(string value, CardValue expected)
 {
     ValueParser p = new ValueParser();
     Assert.AreEqual(expected, p.Parse(value) );
 }
 public ValueParseTests()
 {
     _parser = new ValueParser(null);
 }