예제 #1
0
 //Constructor
 public Image(PyramidPanic game, string imageName, Vector2 position, Char? identifier)
 {
     this.game= game;
     this.texture = this.game.Content.Load<Texture2D>(imageName);
     this.position = position;
     this.identifier = identifier;
     this.rectangle = new Rectangle((int)this.position.X,
                                    (int)this.position.Y,
                                    this.texture.Width,
                                    this.texture.Height);
 }
예제 #2
0
 public Base64Encoding(String alphabet, Char?paddingSymbol = null)
     : this(alphabet, BuildLookupTable(alphabet), paddingSymbol)
 {
 }
 /// <inheritdoc />
 public override void WriteValue(Char?value) => CheckValue(_writer.WriteValue, value);
예제 #4
0
 public override void SetNullableChar(object o, int index, Char?value)
 {
     this[index].SetNullableChar(o, value);
 }
예제 #5
0
        public void Set(Wrapper w)
        {
            if ((_tcode & VType.Numeric) != VType.Numeric)
            {
                if (w._tcode != _tcode)
                {
                    throw new VariantException(w._tcode, _tcode);
                }
                switch (_tcode)
                {
                case VType.Boolean:
                    _boolean = w._boolean;
                    break;

                case VType.nBoolean:
                    _nboolean = w._nboolean;
                    break;

                case VType.Char:
                    _char = w._char;
                    break;

                case VType.nChar:
                    _nchar = w._nchar;
                    break;

                case VType.DateTime:
                    _datetime = w._datetime;
                    break;

                case VType.nDateTime:
                    _ndatetime = w._ndatetime;
                    break;

                case VType.String:
                    _string = w._string;
                    break;
                }
            }
            else
            {
                //bool done = false;
                Decimal vv;
                bool    castok = w.TryCast(out vv);

                switch (_tcode)
                {
                case VType.Byte:
                    _byte = (Byte)vv;
                    break;

                case VType.nByte:
                    if (castok)
                    {
                        _nbyte = (Byte?)vv;
                    }
                    else
                    {
                        _nbyte = null;
                    }
                    break;

                case VType.SByte:
                    _sbyte = (SByte)vv;
                    break;

                case VType.nSByte:
                    if (castok)
                    {
                        _nsbyte = (SByte?)vv;
                    }
                    else
                    {
                        _nsbyte = null;
                    }
                    break;

                case VType.Int64:
                    _int64 = (Int64)vv;
                    break;

                case VType.nInt64:
                    if (castok)
                    {
                        _nint64 = (Int64?)vv;
                    }
                    else
                    {
                        _nint64 = null;
                    }
                    break;

                case VType.Double:
                    _double = (Double)vv;
                    break;

                case VType.nDouble:
                    if (castok)
                    {
                        _ndouble = (Double?)vv;
                    }
                    else
                    {
                        _ndouble = null;
                    }
                    break;

                case VType.Decimal:
                    _decimal = vv;
                    break;

                case VType.nDecimal:
                    if (castok)
                    {
                        _ndecimal = (Decimal?)vv;
                    }
                    else
                    {
                        _ndecimal = null;
                    }
                    break;
                }
            }
            //} set
        }
예제 #6
0
 public override void  SetNullableChar(object obj, Char?value)
 {
     Setter(obj, value);
 }
예제 #7
0
 public Base32Encoding(String alphabet, Byte[] lookupTable, Char?paddingSymbol = null)
     : base(32, alphabet, lookupTable)
 {
     PaddingSymbol = paddingSymbol;
 }
예제 #8
0
        //private static object ConvertToT<T>(object Source)
        //{
        //    object theRet = Source;
        //    if (Source is string)
        //    {
        //        return (Source as string).ConvertToTargetType(typeof(T), Source);
        //    }
        //    return theRet;
        //}
        /// <summary>
        /// 将值转换成指定类型的值.
        /// </summary>
        /// <param name="Source">源</param>
        /// <param name="type">指定类型</param>
        /// <param name="DefaultValue">没转换成功返回的值</param>
        /// <returns>指定类型的值,转换不成功返回default值.</returns>
        public static object ConvertToTargetType(this string Source, Type type, object DefaultValue)
        {
            if (type == typeof(string))
            {
                return(Source);
            }
            if (type == typeof(Boolean))
            {
                Boolean theRet = Boolean.Parse(Source);
                return(theRet);
            }
            if (type == typeof(byte))
            {
                Byte theRet = Byte.Parse(Source);
                return(theRet);
            }
            if (type == typeof(Char))
            {
                Char theRet = Char.Parse(Source);
                return(theRet);
            }
            if (type == typeof(DateTime))
            {
                DateTime theRet = DateTime.Parse(Source);
                return(theRet);
            }
            if (type == typeof(Decimal))
            {
                Decimal theRet = Decimal.Parse(Source);
                return(theRet);
            }
            if (type == typeof(Double))
            {
                Double theRet = Double.Parse(Source);
                return(theRet);
            }
            if (type == typeof(Int16))
            {
                Int16 theRet = Int16.Parse(Source);
                return(theRet);
            }

            if (type == typeof(Int32))
            {
                Int32 theRet = Int32.Parse(Source);
                return(theRet);
            }
            if (type == typeof(SByte))
            {
                SByte theRet = SByte.Parse(Source);
                return(theRet);
            }
            if (type == typeof(int))
            {
                int theRet = int.Parse(Source);
                return(theRet);
            }
            if (type == typeof(Single))
            {
                Single theRet = Single.Parse(Source);
                return(theRet);
            }

            if (type == typeof(String))
            {
                String theRet = Source;
                return(theRet);
            }
            if (type == typeof(UInt16))
            {
                UInt16 theRet = UInt16.Parse(Source);
                return(theRet);
            }

            if (type == typeof(UInt32))
            {
                UInt32 theRet = UInt32.Parse(Source);
                return(theRet);
            }
            if (type == typeof(UInt64))
            {
                UInt64 theRet = UInt64.Parse(Source);
                return(theRet);
            }
            //可空基本类型处理.
            if (type == typeof(Boolean?))
            {
                Boolean?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Boolean?)bool.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(byte?))
            {
                Byte?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Byte?)Byte.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Char?))
            {
                Char?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Char?)Char.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(DateTime?))
            {
                DateTime?theRet = (Source != null && Source != "" && Source != string.Empty) ? (DateTime?)DateTime.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Decimal?))
            {
                Decimal?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Decimal?)Decimal.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Double?))
            {
                Double?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Double?)Double.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Int16?))
            {
                Int16?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Int16?)Int16.Parse(Source) : null;
                return(theRet);
            }

            if (type == typeof(Int32?))
            {
                Int32?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Int32?)Int32.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Int64?))
            {
                Int64?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Int64?)Int64.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(SByte?))
            {
                SByte?theRet = (Source != null && Source != "" && Source != string.Empty) ? (SByte?)SByte.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(int?))
            {
                int?theRet = (Source != null && Source != "" && Source != string.Empty) ? (int?)int.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(Single?))
            {
                Single?theRet = (Source != null && Source != "" && Source != string.Empty) ? (Single?)Single.Parse(Source) : null;
                return(theRet);
            }


            if (type == typeof(UInt16?))
            {
                UInt16?theRet = (Source != null && Source != "" && Source != string.Empty) ? (UInt16?)UInt16.Parse(Source) : null;
                return(theRet);
            }

            if (type == typeof(UInt32?))
            {
                UInt32?theRet = (Source != null && Source != "" && Source != string.Empty) ? (UInt32?)UInt32.Parse(Source) : null;
                return(theRet);
            }
            if (type == typeof(UInt64?))
            {
                UInt64?theRet = (Source != null && Source != "" && Source != string.Empty) ? (UInt64?)UInt64.Parse(Source) : null;
                return(theRet);
            }
            return(DefaultValue);
        }
예제 #9
0
        public static Dictionary <string, string> ParseParameters(string toParse)
        {
            Dictionary <string, string> Parameters = new Dictionary <string, string>();

            bool   IsInsideString           = false;
            int    SlashCounterInsideString = 0;
            bool   ParsingVariableName      = true;
            bool   ParsingVariableValue     = !ParsingVariableName;
            string VariableName             = "";
            string VariableValue            = "";

            for (int aux = 0; aux < toParse.Length; aux++)
            {
                Char C        = toParse[aux];
                Char?NextChar = null;
                if (aux < toParse.Length - 1)
                {
                    NextChar = toParse[aux + 1];
                }

                Char?PreviousChar = null;
                if (aux != 0)
                {
                    PreviousChar = toParse[aux - 1];
                }

                #region Inside string detection
                if (C == '\'' && IsInsideString)
                {
                    SlashCounterInsideString++;
                }

                if (!IsInsideString && C == '\'')
                {
                    IsInsideString = true;
                    SlashCounterInsideString++;
                }
                else if (IsInsideString && C == '\'' && NextChar != '\'' && ((SlashCounterInsideString % 2) == 0))
                {
                    IsInsideString           = false;
                    SlashCounterInsideString = 0;
                }
                #endregion

                if (C == '=' && !IsInsideString)
                {
                    if (ParsingVariableName)
                    {
                        ParsingVariableName  = false;
                        ParsingVariableValue = true;
                        continue;
                    }
                }

                if ((C == '\t' || C == '\n' || C == '\r') && !IsInsideString)
                {
                    continue;
                }

                if ((C == ';') && !IsInsideString)
                {
                    Parameters.Add(VariableName.Trim(), VariableValue.Trim());
                    VariableName         = "";
                    VariableValue        = "";
                    ParsingVariableName  = true;
                    ParsingVariableValue = !ParsingVariableName;
                    continue;
                }

                if (ParsingVariableName)
                {
                    VariableName += C;
                }

                if (ParsingVariableValue)
                {
                    VariableValue += C;
                }
            }

            if (!string.IsNullOrEmpty(VariableName.Trim()))
            {
                if (string.IsNullOrEmpty(VariableValue.Trim()))
                {
                    throw new Exception("Variable '" + VariableName + "' must be set a value.");
                }

                Parameters.Add(VariableName.Trim(), VariableValue.Trim());
            }

            return(Parameters);
        }
예제 #10
0
 public override void SetNullableChar(object o, int index, Char?value)
 {
     _list.Add(ConvertTo <T> .From(value));
 }
예제 #11
0
        /// <summary>
        /// Expecting a string with format: (..,..,..)  example: ('mytext',test','test3')
        /// </summary>
        /// <returns></returns>
        public List <string> GetValues(string valuesString)
        {
            var Values = new List <string>();

            bool   IsInsideString = false;
            string Value          = "";

            bool Started = false;
            int  SlashCounterInsideString = 0;

            for (int aux = 0; aux < valuesString.Length; aux++)
            {
                Char C        = valuesString[aux];
                Char?NextChar = null;
                if (aux < valuesString.Length - 1)
                {
                    NextChar = valuesString[aux + 1];
                }

                Char?PreviousChar = null;
                if (aux != 0)
                {
                    PreviousChar = valuesString[aux - 1];
                }

                #region Inside string detection
                if (C == '\'' && IsInsideString)
                {
                    SlashCounterInsideString++;
                }

                if (!IsInsideString && C == '\'')
                {
                    IsInsideString = true;
                    SlashCounterInsideString++;
                }
                else if (IsInsideString && C == '\'' && NextChar != '\'' && ((SlashCounterInsideString % 2) == 0))
                {
                    IsInsideString           = false;
                    SlashCounterInsideString = 0;
                }
                #endregion

                if (C == '(' && !Started && !IsInsideString)
                {
                    Started = true;
                    continue;
                }

                if (C != ' ' && !Started)
                {
                    Started = true;
                }

                if (C == ' ' && !IsInsideString)
                {
                    continue;
                }

                if (C == ',' && !IsInsideString)
                {
                    if (!Value.IsNumber() && !Value.IsString())
                    {
                        throw new Exception("Invalid value inside 'in' clause");
                    }
                    Values.Add(Value);
                    Value = "";
                    continue;
                }
                else
                {
                    Value += C;
                }
            }

            #region Last Value
            if (Value != "")
            {
                if (Value.EndsWith(")"))
                {
                    Value = Value.Substring(0, Value.Length - 1);
                }

                if (!Value.IsNumber() && !Value.IsString())
                {
                    throw new Exception("Invalid value inside 'in' clause");
                }
                Values.Add(Value);
                Value = "";
            }
            #endregion

            if (Values.Count == 0)
            {
                throw new Exception("No values inside 'in' clause");
            }
            return(Values);
        }
예제 #12
0
 public static string ToSqlQuotedString(this Char?c) => c == null ? "NULL" : ToSqlQuotedString(c.ToString());
예제 #13
0
        public virtual void Parse(
            String stringList, out List <String> strings, out Dictionary <String, String> namedStrings
            )
        {
            // Parse position definitions.
            //      (MyParameter1, MyParameter2, MyNamedParameter=MyValue)
            // ^ to ^
            const Int32 PP_Prefix = 1;

            // ( MyParameter1 , MyParameter2,MyParameter3,MyNamedParameter = MyValue)
            //  ^                    to                  ^
            const Int32 PP_String = 2;

            // (MyParameter1,MyParameter2,MyParameter3,MyNamedParameter=MyValue)
            //                                         ^               ^
            const Int32 PP_NamedString = 3;

            // (MyParameter1,MyParameter2,MyParameter3,MyNamedParameter=MyValue)
            //                                                          ^      ^
            const Int32 PP_NamedStringValue = 4;
            // (MyParameter1,MyParameter2,MyParameter3,MyNamedParameter=MyValue)
            //                                                                  ^   to    ^
            const Int32 PP_End = 5;

            Int32   parsePosition       = PP_Prefix;
            Char?   maskingWith         = null;
            Char?   lastStringMaskChar  = null;
            Boolean lastStringWasMasked = false;
            String  lastNamedStringName = null;

            // The first part will be the command's name.
            StringBuilder currentString = new StringBuilder();

            strings      = new List <String>();
            namedStrings = new Dictionary <String, String>();

            for (Int32 i = 0; ((i < stringList.Length) && (parsePosition != PP_End)); i++)
            {
                Char    currentChar = stringList[i];
                Boolean isLastChar  = (i == stringList.Length - 1);

                switch (parsePosition)
                {
                case PP_Prefix:
                    // e.g.     #<parameters>)
                    //          <parameters>
                    //      (<parameters>)
                    //      <parameters>
                    if (currentChar != ' ')
                    {
                        if (currentChar != this.ParseSettings.ListPrefix)
                        {
                            if (!this.ParseSettings.ExplicitPrefixSuffix)
                            {
                                // Let PP_String reparse this character.
                                i--;
                            }
                            else
                            {
                                this.ThrowParseException(
                                    String.Format("List-prefix {0} not found.", this.ParseSettings.ListPrefix)
                                    );
                            }
                        }

                        parsePosition = PP_String;
                        continue;
                    }

                    break;

                case PP_String:
                case PP_NamedString:
                case PP_NamedStringValue:
                    // e.g. MyParameter1,MyParameter2)
                    //         MyParameter  )
                    //      "MyPar"a"meter"
                    //      MyParameter)
                    //      MyParameter,"",,  ,   MyParameter3 ,A= , Muh
                    //      )
                    if (maskingWith != null)
                    {
                        if (currentChar != maskingWith)
                        {
                            if (isLastChar)
                            {
                                this.ThrowParseException(String.Format("Value mask {0} is never closed.", maskingWith));
                            }

                            currentString.Append(currentChar);
                            continue;
                        }
                        else
                        {
                            lastStringMaskChar  = maskingWith;
                            maskingWith         = null;
                            lastStringWasMasked = true;

                            if (!isLastChar)
                            {
                                continue;
                            }
                        }
                    }

                    if (
                        (isLastChar) &&
                        (this.ParseSettings.ExplicitPrefixSuffix) &&
                        (currentChar != this.ParseSettings.ListSuffix)
                        )
                    {
                        this.ThrowParseException("List-suffix not found.");
                    }

                    if (
                        (this.ParseSettings.NamedStringPrefix != null) &&
                        (currentChar == this.ParseSettings.NamedStringPrefix)
                        )
                    {
                        for (Int32 n = 0; n < currentString.Length; n++)
                        {
                            if (currentString[n] != ' ')
                            {
                                this.ThrowParseException(String.Format(
                                                             "Only whitespaces are allowed before {0}", this.ParseSettings.NamedStringPrefix
                                                             ));
                            }
                        }

                        parsePosition = PP_NamedString;
                        currentString = new StringBuilder();
                        continue;
                    }

                    if (
                        (isLastChar) ||
                        (currentChar == this.ParseSettings.ListSuffix) ||
                        (currentChar == this.ParseSettings.StringSeparator) || (
                            (currentChar == this.ParseSettings.NamedStringValueSeparator) &&
                            (parsePosition != PP_NamedStringValue) && (
                                (parsePosition == PP_NamedString) || (
                                    (parsePosition == PP_String) &&
                                    (this.ParseSettings.NamedStringValueSeparator != ' ')
                                    )
                                )
                            )
                        )
                    {
                        if (
                            (isLastChar) &&
                            (currentChar != this.ParseSettings.ListSuffix) &&
                            (currentChar != this.ParseSettings.StringSeparator) &&
                            (currentChar != this.ParseSettings.NamedStringValueSeparator) &&
                            (currentChar != lastStringMaskChar)
                            )
                        {
                            currentString.Append(currentChar);
                        }

                        if (!lastStringWasMasked)
                        {
                            if ((currentChar == this.ParseSettings.ListSuffix) && (strings.Count == 0))
                            {
                                // This muste be a stringlist prefix, suffix string, so ignore this possible parameter.
                                continue;
                            }

                            if (currentString.Length == 0)
                            {
                                if (this.ParseSettings.StringSeparator != ' ')
                                {
                                    this.ThrowParseException("A string value can not be empty.");
                                }
                                else
                                {
                                    // If the string separator is a whitespace, then simply ignore this possible parameter.

                                    if (currentChar == this.ParseSettings.ListSuffix)
                                    {
                                        parsePosition = PP_End;
                                    }

                                    continue;
                                }
                            }

                            Boolean onlyWhitespaces = true;
                            for (Int32 n = 0; n < currentString.Length; n++)
                            {
                                if (currentString[n] != ' ')
                                {
                                    onlyWhitespaces = false;
                                }
                            }

                            if (onlyWhitespaces)
                            {
                                this.ThrowParseException("A string value can not contain whitespaces only.");
                            }
                        }

                        String finalizedString = currentString.ToString();
                        currentString = new StringBuilder();

                        if (!lastStringWasMasked)
                        {
                            finalizedString = finalizedString.Trim();
                        }

                        if (parsePosition == PP_String)
                        {
                            if (
                                (currentChar != this.ParseSettings.NamedStringValueSeparator) ||
                                (this.ParseSettings.NamedStringValueSeparator == this.ParseSettings.StringSeparator)
                                )
                            {
                                strings.Add(finalizedString);
                            }
                            else
                            {
                                if (this.ParseSettings.NamedStringPrefix == null)
                                {
                                    parsePosition = PP_NamedString;
                                }
                                else
                                {
                                    this.ThrowParseException(String.Format(
                                                                 "Invalid {0} after string, if the string should be a named string put a {1} before it.",
                                                                 this.ParseSettings.NamedStringValueSeparator, this.ParseSettings.NamedStringPrefix
                                                                 ));
                                }
                            }
                        }

                        if (parsePosition == PP_NamedStringValue)
                        {
                            namedStrings.Add(lastNamedStringName, finalizedString);
                            parsePosition = PP_String;
                        }

                        if (parsePosition == PP_NamedString)
                        {
                            if (currentChar == this.ParseSettings.NamedStringValueSeparator)
                            {
                                if (!isLastChar)
                                {
                                    lastNamedStringName = finalizedString;

                                    parsePosition = PP_NamedStringValue;
                                }
                                else
                                {
                                    this.ThrowParseException(
                                        String.Format("No value for named string \"{0}\" defined.", finalizedString)
                                        );
                                }
                            }
                            else
                            {
                                // This must be an empty named string.
                                namedStrings.Add(finalizedString, String.Empty);

                                parsePosition = PP_String;
                            }
                        }

                        if (currentChar == this.ParseSettings.ListSuffix)
                        {
                            parsePosition = PP_End;
                        }

                        lastStringWasMasked = false;
                        lastStringMaskChar  = null;
                        continue;
                    }

                    if (
                        (currentChar == this.ParseSettings.MaskingChar) ||
                        (currentChar == this.ParseSettings.AltMaskingChar)
                        )
                    {
                        maskingWith   = currentChar;
                        currentString = new StringBuilder();
                        continue;
                    }

                    if (!lastStringWasMasked)
                    {
                        currentString.Append(currentChar);
                    }

                    break;
                }
            }
        }
예제 #14
0
 private RegexParser(ICodeReader reader, Char?delimitator)
 {
     this._reader      = reader ?? throw new ArgumentNullException(nameof(reader));
     this._delimitator = delimitator;
 }
예제 #15
0
        /// <summary>
        /// Zwraca kolejny token
        /// </summary>
        public static ExpressionToken GetNextToken(IList <Char> Chars, Int32 StartIndex, ExpressionToken PrevToken)
        {
            // szukanie operatórw porównania
            Char[] foundCompareOperator = StringHelper.StartsWith(Chars, DynLanuageSymbols.CompareOperators, StartIndex, false);
            if (foundCompareOperator != null)
            {
                return(new ExpressionToken(foundCompareOperator, TokenType.OPERATOR)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundCompareOperator.Length - 1
                });
            }

            // szukanie nawiasu START
            Char[] foundBracketBegin = StringHelper.StartsWith(Chars, DynLanuageSymbols.BracketBegin, StartIndex, false);
            if (foundBracketBegin != null)
            {
                return(new ExpressionToken(foundBracketBegin, TokenType.BRACKET_BEGIN)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundBracketBegin.Length - 1
                });
            }

            // szukanie nawiasu END
            Char[] foundBracketEnd = StringHelper.StartsWith(Chars, DynLanuageSymbols.BracketEnd, StartIndex, false);
            if (foundBracketEnd != null)
            {
                return(new ExpressionToken(foundBracketEnd, TokenType.BRACKET_END)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundBracketEnd.Length - 1
                });
            }

            // szukanie indexera START
            Char[] foundIndexerBegin = StringHelper.StartsWith(Chars, DynLanuageSymbols.IndexerBegin, StartIndex, false);
            if (foundIndexerBegin != null)
            {
                return(new ExpressionToken(foundIndexerBegin, TokenType.INDEXER_BEGIN)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundIndexerBegin.Length - 1
                });
            }

            // szukanie indexera END
            Char[] foundIndexerEnd = StringHelper.StartsWith(Chars, DynLanuageSymbols.IndexerEnd, StartIndex, false);
            if (foundIndexerEnd != null)
            {
                return(new ExpressionToken(foundIndexerEnd, TokenType.INDEXER_END)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundIndexerEnd.Length - 1
                });
            }

            // szukanie operatora równości
            Char[] foundEqualOperator = StringHelper.StartsWith(Chars, DynLanuageSymbols.EqualOperator, StartIndex, false);
            if (foundEqualOperator != null)
            {
                return(new ExpressionToken(foundEqualOperator, TokenType.EQUAL_OPERATOR)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundEqualOperator.Length - 1
                });
            }

            // szukanie operatora
            Char[] foundOperator = StringHelper.StartsWith(Chars, DynLanuageSymbols.Operators, StartIndex, false);
            if (foundOperator != null)
            {
                return(new ExpressionToken(foundOperator, TokenType.OPERATOR)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundOperator.Length - 1
                });
            }

            // szukanie operatorów logicznych
            Char[] foundLogicalOperator = StringHelper.StartsWith(Chars, DynLanuageSymbols.LogicalOperators, StartIndex, true);
            if (foundLogicalOperator != null)
            {
                Char?prevChar = StartIndex > 0 ? (Char?)Chars[StartIndex - 1] : null;
                Char?nextChar = StartIndex + foundLogicalOperator.Length < Chars.Count ? (Char?)Chars[StartIndex + foundLogicalOperator.Length] : null;

                if (!(prevChar != null && Char.IsLetterOrDigit(prevChar.Value) && Char.IsLetterOrDigit(foundLogicalOperator[0])) &&
                    !(nextChar != null && Char.IsLetterOrDigit(nextChar.Value) && Char.IsLetterOrDigit(foundLogicalOperator[foundLogicalOperator.Length - 1])))
                {
                    return(new ExpressionToken(foundLogicalOperator, TokenType.OPERATOR)
                    {
                        StartIndex = StartIndex,
                        EndIndex = StartIndex + foundLogicalOperator.Length - 1
                    });
                }
                else
                {
                    prevChar = prevChar;
                }
            }

            // szukanie białych znaków
            Char[] foundWhitespaces = StringHelper.StartsWith(Chars, DynLanuageSymbols.Whitespaces, StartIndex, false);
            if (foundWhitespaces != null)
            {
                return(new ExpressionToken(foundWhitespaces, TokenType.WHITESPACE)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundWhitespaces.Length - 1
                });
            }

            // szukanie przecinka
            Char[] foundSeparator = StringHelper.StartsWith(Chars, DynLanuageSymbols.Separators, StartIndex, false);
            if (foundSeparator != null)
            {
                return(new ExpressionToken(foundSeparator, TokenType.SEPARATOR)
                {
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + foundSeparator.Length - 1
                });
            }

            TokenType   tokenType = TokenType.VARIABLE;
            Int32       nextIndex = -1;
            List <Char> chars     = new List <Char>();

            OnpOnpStringFindResult firstNext = StringHelper.FirstNextIndex(
                Chars, StartIndex,
                new[] { DynLanuageSymbols.IndexerBegin, DynLanuageSymbols.IndexerEnd, DynLanuageSymbols.BracketBegin, DynLanuageSymbols.BracketEnd, DynLanuageSymbols.OperatorsAndPropertyAndBrackets, DynLanuageSymbols.Separators },
                true);

            if (firstNext == null || firstNext.Index < 0)
            {
                for (Int32 j = StartIndex; j < Chars.Count; j++)
                {
                    chars.Add(Chars[j]);
                }
            }
            else
            {
                int len = firstNext.Index;
                for (Int32 j = StartIndex; j < len; j++)
                {
                    chars.Add(Chars[j]);
                }
                nextIndex = firstNext.Index;
            }
            if (nextIndex < 0)
            {
                nextIndex = Chars.Count;
            }

            StringHelper.Trim(chars);

            if (chars.Count != 0)
            {
                if (StringHelper.IsValue(chars))
                {
                    tokenType = TokenType.VALUE;
                }

                //if (tokenType == TokenType.VARIABLE)
                //    for (var i = 0; i < chars.Count; i++)
                //        chars[i] = Char.ToUpper(chars[i]);

                return
                    (new ExpressionToken(chars, tokenType)
                {
                    TokenLength = (nextIndex - StartIndex),
                    StartIndex = StartIndex,
                    EndIndex = StartIndex + chars.Count - 1
                });
            }

            return(null);
        }
예제 #16
0
        public static void Write(this JsonWriter writer, JsonPropertyName propertyName, Char?value)
        {
            if (!value.HasValue && !writer.Settings.SerializeNulls)
            {
                return;
            }

            writer.WritePropertyName(propertyName);
            writer.WriteValue(value);
        }
예제 #17
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            Char? Keypressed=null;
            switch (e.Key)
            {
                case Key.NumPad0:
                case Key.D0:
                    Keypressed = '0';
                    break;
                case Key.NumPad1:
                case Key.D1:
                    Keypressed = '1';
                    break;
                case Key.NumPad2:
                case Key.D2:
                    Keypressed = '2';
                    break;
                case Key.NumPad3:
                case Key.D3:
                    Keypressed = '3';
                    break;
                case Key.NumPad4:
                case Key.D4:
                    Keypressed = '4';
                    break;
                case Key.NumPad5:
                case Key.D5:
                    Keypressed = '5';
                    break;
                case Key.NumPad6:
                case Key.D6:
                    Keypressed = '6';
                    break;
                case Key.NumPad7:
                case Key.D7:
                    Keypressed = '7';
                    break;
                case Key.NumPad8:
                case Key.D8:
                    Keypressed = '8';
                    break;
                case Key.NumPad9:
                case Key.D9:
                    Keypressed = '9';
                    break;
                case Key.Delete:
                case Key.Back:
                    Keypressed='C';
                    break;
                case Key.Return :
                    Keypressed = 'ü';
                    break;

            }
            if (Keypressed != null)
            {
                Button forcepressed = null;
                switch (OperatingMode)
                {
                    case OperatingModeConstants.OpMode_PinEntry:
                        forcepressed = findKeybutton(Keypressed.ToString(), new Button[]{EntryButton0,EntryButton1,EntryButton2,EntryButton3,
                                                                            EntryButton4,EntryButton5,EntryButton6,EntryButton7,
                                                                            EntryButton8,EntryButton9,EntryButtonOK,EntryButtonC}, EntryButtonClick);
                        break;
                    case OperatingModeConstants.OpMode_ScanOrder:
                        forcepressed = findKeybutton(Keypressed.ToString(), new Button[] { WOButton0,WOButton1,WOButton2,WOButton3,
                                                                                        WOButton4,WOButton5,WOButton6,WOButton7,
                                                                                        WOButton8,WOButton9,WOButton0,WOButtonC,WOButtonOK}, WorkOrderButtonEntryClick); 
                        break;
                        
                }

            }

        }
예제 #18
0
 public void Set(Char?b)
 {
     checkType(VType.nChar);
     _nchar = b;
 }
예제 #19
0
 public Analysis(Boolean successfull, Char?symbol)
 {
     IsSuccessfully  = successfull;
     UncorrectSymbol = symbol;
 }
예제 #20
0
 public Wrapper(Char?b, Mask mask)
 {
     _mask  = mask;
     _tcode = VType.nChar;
     _nchar = b;
 }
예제 #21
0
        private void TestParam(Char?x)
        {
            _Char column = _Char.Param(x);

            column.VerifyParam(x);
        }
예제 #22
0
        Populate(
            int stringSize,
            int binarySize)
        {
            PartitionKey = typeof(AllDataExplicit).Name;
            RowKey       = Guid.NewGuid().ToString();

            // Fields + Nullable. 8 + 8 + 6 = 22
            StringField     = DataGenerator.GetStringSizeFixed(stringSize);
            StringFieldNull = null;

            BoolField        = DataGenerator.Rnd.Next(2) == 1;
            BoolFieldNull    = null;
            BoolFieldNullNot = DataGenerator.Rnd.Next(2) == 1;

            IntField        = DataGenerator.Rnd.Next(Int32.MaxValue);
            IntFieldNull    = null;
            IntFieldNullNot = DataGenerator.Rnd.Next(int.MaxValue);

            Int64Field        = (Int64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));
            Int64FieldNull    = null;
            Int64FieldNullNot = (Int64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));

            DoubleField        = DataGenerator.Rnd.NextDouble() * Double.MaxValue;
            DoubleFieldNull    = null;
            DoubleFieldNullNot = DataGenerator.Rnd.NextDouble() * Double.MaxValue;

            DateTimeField        = DateTime.UtcNow;
            DateTimeFieldNull    = null;
            DateTimeFieldNullNot = DateTime.UtcNow;

            GuidField        = Guid.NewGuid();
            GuidFieldNull    = null;
            GuidFieldNullNot = Guid.NewGuid();

            BinaryField     = DataGenerator.GetBytesSizeFixed(binarySize);
            BinaryFieldNull = null;

            // intrinsic morphs + Nullable. 7 * 4 = 28
            ByteFieldMin     = Byte.MinValue;
            ByteFieldMax     = Byte.MaxValue;
            ByteFieldNull    = null;
            ByteFieldNullNot = (byte)DataGenerator.Rnd.Next(byte.MaxValue);

            SByteFieldMin     = SByte.MinValue;
            SByteFieldMax     = SByte.MaxValue;
            SByteFieldNull    = null;
            SByteFieldNullNot = (sbyte)DataGenerator.Rnd.Next(sbyte.MaxValue);

            Int16FieldMin     = Int16.MinValue;
            Int16FieldMax     = Int16.MaxValue;
            Int16FieldNull    = null;
            Int16FieldNullNot = (Int16)DataGenerator.Rnd.Next(Int16.MaxValue);

            UInt16FieldMin     = UInt16.MinValue;
            UInt16FieldMax     = UInt16.MaxValue;
            UInt16FieldNull    = null;
            UInt16FieldNullNot = (UInt16)DataGenerator.Rnd.Next(UInt16.MaxValue);

            UInt32FieldMin     = UInt32.MinValue;
            UInt32FieldMax     = UInt32.MaxValue;
            UInt32FieldNull    = null;
            UInt32FieldNullNot = (UInt32)DataGenerator.Rnd.Next(UInt16.MaxValue);

            UInt64FieldMin     = UInt64.MinValue;
            UInt64FieldMax     = UInt64.MaxValue;
            UInt64FieldNull    = null;
            UInt64FieldNullNot = (UInt64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));

            CharFieldMin     = Char.MinValue;
            CharFieldMax     = Char.MaxValue;
            CharFieldNull    = null;
            CharFieldNullNot = (Char)DataGenerator.Rnd.Next(Char.MaxValue);

            // Enums - 8
            ByteEnumField        = ByteEnum.Value2;
            ByteEnumFieldNull    = null;
            ByteEnumFieldNullNot = ByteEnum.Value1;

            SByteEnumField        = SByteEnum.Value2;
            SByteEnumFieldNull    = null;
            SByteEnumFieldNullNot = SByteEnum.Value1;

            Int16EnumField        = Int16Enum.Value2;
            Int16EnumFieldNull    = null;
            Int16EnumFieldNullNot = Int16Enum.Value1;

            UInt16EnumField        = UInt16Enum.Value2;
            UInt16EnumFieldNull    = null;
            UInt16EnumFieldNullNot = UInt16Enum.Value1;

            Int32EnumField        = Int32Enum.Value2;
            Int32EnumFieldNull    = null;
            Int32EnumFieldNullNot = Int32Enum.Value1;

            UInt32EnumField        = UInt32Enum.Value2;
            UInt32EnumFieldNull    = null;
            UInt32EnumFieldNullNot = UInt32Enum.Value1;

            Int64EnumField        = Int64Enum.Value2;
            Int64EnumFieldNull    = null;
            Int64EnumFieldNullNot = Int64Enum.Value1;

            UInt64EnumField        = UInt64Enum.Value2;
            UInt64EnumFieldNull    = null;
            UInt64EnumFieldNullNot = UInt64Enum.Value1;

            // Object
            // Create a derived generic object type to validate correct de-serialization
            var employeeInfo = EmployeeInfo <int> .CreateNew();

            employeeInfo.Dummy = 101;

            PersonInfo = employeeInfo;
        }
예제 #23
0
        private void TestImplicit(Char?x)
        {
            _Char column = x;

            column.VerifyParam(x);
        }
예제 #24
0
        // strive for O(n) command parsing
        internal static IEnumerable <TextCommandWord> Parse(String text)
        {
            Contract.Assert(!String.IsNullOrWhiteSpace(text), "Calling to parse empty text.");

            var  current     = new List <Char>();
            var  isParameter = false;
            Char?context     = null;

            for (int i = 0; i < text.Length; i++)
            {
                var c = text[i];

                var escaped = DetectEscapedChar(text, ref c, ref i);

                if (!escaped && (c == SingleQuoteChar || c == DoubleQuoteChar))
                {
                    if (context.HasValue && context.Value == c)
                    {
                        context = null;
                        continue;
                    }
                    else if (!context.HasValue)
                    {
                        context = c;
                        continue;
                    }
                }

                if (context.HasValue)
                {
                    current.Add(c);
                    continue;
                }

                if (c == ArrobaChar && !current.Any() && (text[i - 1] == ArrobaChar || isDelimiter(text[i - 1])))
                {
                    isParameter = true;
                    continue;
                }

                if (isDelimiter(c))
                {
                    // move till new word, end of line or break is found
                    // to ensure that in 'hello  \t\nworld', 'hello' is
                    // considered end of a line as well.
                    var nextBreak = c;
                    if (isCommandPartDelimiter(c))
                    {
                        for (var j = i + 1; j <= text.Length; j++)
                        {
                            if (j == text.Length)
                            {
                                nextBreak = LFChar;
                                break;
                            }
                            nextBreak = text[j];
                            DetectEscapedChar(text, ref nextBreak, ref j);
                            if (!isCommandPartDelimiter(nextBreak))
                            {
                                break;
                            }
                            i++;
                        }
                    }

                    if (!current.Any())
                    {
                        continue;
                    }

                    yield return(new TextCommandWord(new String(current.ToArray()), isParameter, isCommandLineDelimiter(nextBreak)));

                    current.Clear();
                    isParameter = false;
                    continue;
                }

                current.Add(c);
            }

            if (current.Any())
            {
                yield return(new TextCommandWord(new String(current.ToArray()), isParameter, true));
            }
        }
예제 #25
0
 /// <summary>
 /// Creates a shingle filter using default settings.
 ///
 /// See IgnoringSinglePrefixOrSuffixShingleByDefault, and DefaultSettingsCodec
 /// </summary>
 /// <param name="input">stream from which to construct the matrix</param>
 /// <param name="minimumShingleSize">minimum number of tokens in any shingle.</param>
 /// <param name="maximumShingleSize">maximum number of tokens in any shingle.</param>
 /// <param name="spacerCharacter">character to use between texts of the token parts in a shingle. null for none. </param>
 public ShingleMatrixFilter(TokenStream input, int minimumShingleSize, int maximumShingleSize, Char?spacerCharacter)
     : this(input, minimumShingleSize, maximumShingleSize, spacerCharacter, IgnoringSinglePrefixOrSuffixShingleByDefault)
 {
 }
예제 #26
0
 public Char?EchoNullableChar(Char?arg0)
 {
     return(arg0);
 }
예제 #27
0
 /// <summary>
 /// Creates a shingle filter using the default <see cref="TokenSettingsCodec"/>.
 ///
 /// See DefaultSettingsCodec
 /// </summary>
 /// <param name="input">stream from which to construct the matrix</param>
 /// <param name="minimumShingleSize">minimum number of tokens in any shingle.</param>
 /// <param name="maximumShingleSize">maximum number of tokens in any shingle.</param>
 /// <param name="spacerCharacter">character to use between texts of the token parts in a shingle. null for none.</param>
 /// <param name="ignoringSinglePrefixOrSuffixShingle">if true, shingles that only contains permutation of the first of the last column will not be produced as shingles. Useful when adding boundary marker tokens such as '^' and '$'.</param>
 public ShingleMatrixFilter(TokenStream input, int minimumShingleSize, int maximumShingleSize, Char?spacerCharacter, bool ignoringSinglePrefixOrSuffixShingle)
     : this(input, minimumShingleSize, maximumShingleSize, spacerCharacter, ignoringSinglePrefixOrSuffixShingle, DefaultSettingsCodec)
 {
 }
예제 #28
0
 public virtual void    SetNullableChar(object o, Char?value)
 {
     SetValue(o, value);
 }
예제 #29
0
        /// <summary>
        /// Creates a shingle filter with ad hoc parameter settings.
        /// </summary>
        /// <param name="input">stream from which to construct the matrix</param>
        /// <param name="minimumShingleSize">minimum number of tokens in any shingle.</param>
        /// <param name="maximumShingleSize">maximum number of tokens in any shingle.</param>
        /// <param name="spacerCharacter">character to use between texts of the token parts in a shingle. null for none.</param>
        /// <param name="ignoringSinglePrefixOrSuffixShingle">if true, shingles that only contains permutation of the first of the last column will not be produced as shingles. Useful when adding boundary marker tokens such as '^' and '$'.</param>
        /// <param name="settingsCodec">codec used to read input token weight and matrix positioning.</param>
        public ShingleMatrixFilter(TokenStream input, int minimumShingleSize, int maximumShingleSize, Char?spacerCharacter, bool ignoringSinglePrefixOrSuffixShingle, TokenSettingsCodec settingsCodec)
        {
            _input             = input;
            MinimumShingleSize = minimumShingleSize;
            MaximumShingleSize = maximumShingleSize;
            SpacerCharacter    = spacerCharacter;
            IsIgnoringSinglePrefixOrSuffixShingle = ignoringSinglePrefixOrSuffixShingle;
            _settingsCodec = settingsCodec;

            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            _termAtt    = AddAttribute <ITermAttribute>();
            _posIncrAtt = AddAttribute <IPositionIncrementAttribute>();
            _payloadAtt = AddAttribute <IPayloadAttribute>();
            _offsetAtt  = AddAttribute <IOffsetAttribute>();
            _typeAtt    = AddAttribute <ITypeAttribute>();
            _flagsAtt   = AddAttribute <IFlagsAttribute>();
            // ReSharper restore DoNotCallOverridableMethodsInConstructor

            _inTermAtt    = input.AddAttribute <ITermAttribute>();
            _inPosIncrAtt = input.AddAttribute <IPositionIncrementAttribute>();
            _inPayloadAtt = input.AddAttribute <IPayloadAttribute>();
            _inOffsetAtt  = input.AddAttribute <IOffsetAttribute>();
            _inTypeAtt    = input.AddAttribute <ITypeAttribute>();
            _inFlagsAtt   = input.AddAttribute <IFlagsAttribute>();
        }
예제 #30
0
 public Base64Encoding(String alphabet, Byte[] lookupTable, Char?paddingSymbol)
     : base(64, alphabet, lookupTable)
 {
     PaddingSymbol = paddingSymbol;
 }
예제 #31
0
 /// <summary>
 /// Parses a regex expression from a reader.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="delimitator">The regex expression delimitator (if any).</param>
 /// <returns></returns>
 public static GrammarNode <Char> Parse(ICodeReader reader, Char?delimitator = null) =>
 new RegexParser(reader, delimitator).MainParse();