public TemplateCommand(JsonNode jsonNode, Template template) { m_jsonNode = jsonNode; m_template = template; m_type = jsonNode.GetObjectOrDefault("type", TemplateCommandType.Undefined); m_pathSeperator = jsonNode.GetObjectOrDefault<char?>("pathSeparator", null); }
// Reads a char, allows peeking and checks for end of stream char ReadChar() { if (prevChar != null) { var c = prevChar.Value; prevChar = null; return c; } if (stream.Read(singleChar, 0, 1) < 1) { endStream = true; return '\0'; } var ch = (char)singleChar[0]; // Handle line and column numbers here; // This isn't terribly accurate, but good enough for diagnostics if (ch == '\r') { wasCr = true; line++; column = 0; } else { if (ch == '\n' && !wasCr) { line++; column = 0; } wasCr = false; } column++; return ch; }
public void Setup() { //Instance Fields Setup BooleanField = null; ByteField = null; SByteField = null; IntField = null; LongField = null; Int16Field = null; UInt16Field = null; Int32Field = null; UInt32Field = null; Int64Field = null; UInt64Field = null; CharField = null; DoubleField = null; FloatField = null; //Static Fields Setup BooleanFieldStatic = null; ByteFieldStatic = null; SByteFieldStatic = null; IntFieldStatic = null; LongFieldStatic = null; Int16FieldStatic = null; UInt16FieldStatic = null; Int32FieldStatic = null; UInt32FieldStatic = null; Int64FieldStatic = null; UInt64FieldStatic = null; CharFieldStatic = null; DoubleFieldStatic = null; FloatFieldStatic = null; }
public void Clear() { _operand1 = null; _operator = null; _operand2 = null; _result = null; _display = "0"; }
/// <summary> /// Creates a new KeyboardEventArgs, given a time for the event, the key that was pressed, and /// the modifiers that were applied at the time of the press, as well as the keyboard state at /// the time the event occurred. /// </summary> public KeyboardEventArgs(TimeSpan time, Keys key, Modifiers modifiers, KeyboardState state) : base(time) { Character = KeyboardUtil.ToChar(key, modifiers); State = state; Modifiers = modifiers; Key = key; }
public static void CheckUnaryArithmeticNegateCheckedNullableCharTest() { char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < values.Length; i++) { VerifyArithmeticNegateCheckedNullableChar(values[i]); } }
public static void CheckLiftedAddNullableCharTest() { char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < values.Length; i++) { for (int j = 0; j < values.Length; j++) { VerifyAddNullableChar(values[i], values[j]); } } }
public static void CheckNonLiftedComparisonEqualNullableCharTest(bool useInterpreter) { char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < values.Length; i++) { for (int j = 0; j < values.Length; j++) { VerifyComparisonEqualNullableChar(values[i], values[j], useInterpreter); } } }
public static void CheckNullableCharLessThanOrEqualTest(bool useInterpreter) { char?[] array = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array.Length; j++) { VerifyNullableCharLessThanOrEqual(array[i], array[j], useInterpreter); } } }
public static void CheckLiftedSubtractCheckedNullableCharTest(bool useInterpreter) { char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < values.Length; i++) { for (int j = 0; j < values.Length; j++) { VerifySubtractCheckedNullableChar(values[i], values[j], useInterpreter); } } }
public static void CheckNullableCharEqualTest() { char?[] array = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array.Length; j++) { VerifyNullableCharEqual(array[i], array[j]); } } }
public static void CheckNonLiftedComparisonGreaterThanOrEqualNullableCharTest() { char?[] values = new char?[] { null, '\0', '\b', 'A', '\uffff' }; for (int i = 0; i < values.Length; i++) { for (int j = 0; j < values.Length; j++) { VerifyComparisonGreaterThanOrEqualNullableChar(values[i], values[j]); } } }
public char? Read() { char? result; if (this.peeked.HasValue) { result = this.peeked; this.peeked = null; } else result = this.RawRead(); return result; }
public void AdvancePos() { _pos++; if(_pos >= _source.Length) { _currentChar = null; } else { _currentChar = _source[_pos]; } }
public void AdvanceChar() { _pos++; if(_pos >= this.SourceText.Length) { _currentChar = null; } else { _currentChar = SourceText[_pos]; } }
public CsvParser(TextReader reader) { Debug.Assert(reader != null, "Reader must never be null."); this.reader = reader; this.buffer = new char[BufferSize]; this.values = new ValueList(); this.valueBuilder = new ValueBuilder(this); this.valueSeparator = Constants.DefaultValueSeparator; this.valueDelimiter = Constants.DefaultValueDelimiter; this.UpdateSpecialCharacterMask(); }
public Move(Position originalPosition, Position newPosition, Player player, char? promotion) { OriginalPosition = originalPosition; NewPosition = newPosition; Player = player; if (promotion.HasValue) { Promotion = char.ToUpper(promotion.Value); } else { Promotion = null; } }
public Move(string originalPosition, string newPosition, Player player, char? promotion) { OriginalPosition = new Position(originalPosition); NewPosition = new Position(newPosition); Player = player; if (promotion.HasValue) { Promotion = char.ToUpper(promotion.Value); } else { Promotion = null; } }
/// <summary> /// Constructor vacio: id = 0; centroGasto, comprador, proveedor = new; clave, carta, observaciones = ""; fechas = new Date, estado = null /// </summary> public Requisicion () { id = 0; centroGasto = new CentroGasto(); comprador = new Comprador(); proveedor = new Proveedor(); clave = ""; fechaElaboracion = new DateTime(); fechaEntrega = new DateTime(); estado = '\0'; cartaCompromiso = ""; fechaPromesaEntrega = new DateTime(); observaciones = ""; }
public void HighlightLetter(string letterTofind) { this.letter = letterTofind.First().ToString().ToLower(); int totalLocations = this.textView.TextSnapshot.GetText() .Count(c => c.ToString().ToLower() == this.letter); this.letterLocationSpans = new LetterReferenceDictionary(totalLocations); this.OffsetKey = this.letterLocationSpans.OffsetKey; foreach (var line in this.textView.TextViewLines) { this.CreateVisualsForLetter(line); } }
private OptionAttribute(string shortName, string longName) { if (shortName == null) throw new ArgumentNullException("shortName"); if (longName == null) throw new ArgumentNullException("longName"); this.shortName = shortName; this.longName = longName; this.setName = string.Empty; this.min = -1; this.max = -1; this.separator = '\0'; this.helpText = string.Empty; this.metaValue = string.Empty; }
public void Equals() { we_need_two_operands(); deal_with_repeated_equals(); if (_operator != null) { show((int) _operands.Inject(_operator)); _lastOperator = _operator; _operator = null; _operands[0] = Display; } _lastFunctionWasEquals = true; }
public EdiGrammar() { _ComponentDataElementSeparator = ':'; _SegmentNameDelimiter = _DataElementSeparator = '+'; _DecimalMark = '.'; _ReleaseCharacter = '?'; _Reserved = new[] { ' ' }; _SegmentTerminator = '\''; _ServiceStringAdviceTag = "UNA"; _InterchangeHeaderTag = "UNB"; _FunctionalGroupHeaderTag = "UNG"; _MessageHeaderTag = "UNH"; _MessageTrailerTag = "UNT"; _FunctionalGroupTrailerTag = "UNE"; _InterchangeTrailerTag = "UNZ"; }
public EdiGrammar(IEdiGrammar grammar) { _ComponentDataElementSeparator = grammar.ComponentDataElementSeparator; _DataElementSeparator = grammar.DataElementSeparator; _DecimalMark = grammar.DecimalMark; _ReleaseCharacter = grammar.ReleaseCharacter; _Reserved = grammar.Reserved.Clone() as char[]; _SegmentTerminator = grammar.SegmentTerminator; _ServiceStringAdviceTag = grammar.ServiceStringAdviceTag; _InterchangeHeaderTag = grammar.InterchangeHeaderTag; _FunctionalGroupHeaderTag = grammar.FunctionalGroupHeaderTag; _MessageHeaderTag = grammar.MessageHeaderTag; _MessageTrailerTag = grammar.MessageTrailerTag; _FunctionalGroupTrailerTag = grammar.FunctionalGroupTrailerTag; _InterchangeTrailerTag = grammar.InterchangeTrailerTag; }
public void ApplyUnitSolution(string solution) { if (state != State.UnitInGame) throw new InvalidOperationException(string.Format("Invalid game state: {0}", state)); if (nextMove.HasValue) throw new InvalidOperationException(string.Format("Next move is not null: {0}", nextMove)); for (int i = 0; i < solution.Length; i++) { nextMove = solution[i]; Step(); if (i < solution.Length - 1 && state != State.UnitInGame) throw new InvalidOperationException(string.Format("Invalid game state: {0}", state)); } nextMove = null; if (state != State.End && state != State.WaitUnit) throw new InvalidOperationException(string.Format("Invalid game state: {0}", state)); }
public TokenizerState() { currentToken = null; previousChar = null; previousToken = null; previousChar = null; currentString = string.Empty; foreach (string s in operators) specialWords.Add(s); foreach (string s in keywords) specialWords.Add(s); foreach (string s in specialWords) foreach (char c in s.ToCharArray()) if (!specialWordChars.Contains(c)) specialWordChars.Add(c); }
private void UpdateState() { if (_position < _buffer.Length) { LineTrackingStringBuffer.CharacterReference chr = _buffer.CharAt(_position); _current = chr.Character; _location = chr.Location; } else if (_buffer.Length == 0) { _current = null; _location = SourceLocation.Zero; } else { _current = null; _location = _buffer.EndLocation; } }
public PIDSensor(int mode, int PID, int bytes, PIDSensor parent, string description, string formula = "") { this.mode = mode; this.PID = PID; this.bytes = bytes; this.description = description; this.formula = formula.ToUpper(); this.parent = parent; // The 'formula' field in the XML file can be filled with characters and calculation symbols // To determine the number of arguments needed, the highest used character in the formula will be stored. this.highestFormulaCharacter = GetHighestFormulaCharacterFrom(formula); if (this.highestFormulaCharacter == null) this.highestFormulaCharacterNumber = -1; // because A = 0 else if (this.highestFormulaCharacter != null) { char character = (char)highestFormulaCharacter; this.highestFormulaCharacterNumber = Array.IndexOf(alphabet, character, 0, 26); } }
public OptionInfo(BaseOptionAttribute attribute, PropertyInfo property) { if (attribute == null) { throw new ArgumentNullException("attribute", SR.ArgumentNullException_AttributeCannotBeNull); } if (property == null) { throw new ArgumentNullException("property", SR.ArgumentNullException_PropertyCannotBeNull); } _required = attribute.Required; _shortName = attribute.ShortName; _longName = attribute.LongName; _mutuallyExclusiveSet = attribute.MutuallyExclusiveSet; _defaultValue = attribute.DefaultValue; _hasDefaultValue = attribute.HasDefaultValue; _attribute = attribute; _property = property; _propertyWriter = new PropertyWriter(_property); }
public OptionInfo(OptionAttribute attribute, PropertyInfo property) { if (attribute == null) { throw new ArgumentNullException("attribute", "The attribute is mandatory"); } if (property == null) { throw new ArgumentNullException("property", "The property is mandatory"); } _required = attribute.Required; _helpText = attribute.HelpText; _shortName = attribute.ShortName; _longName = attribute.LongName; _mutuallyExclusiveSet = attribute.MutuallyExclusiveSet; _defaultValue = attribute.DefaultValue; _hasDefaultValue = attribute.HasDefaultValue; _attribute = attribute; _property = property; }
internal static string ReadLine(this Stream stream, ref int maxLength, Encoding encoding, char?termChar, int ReadTimeout = 10000) { if (stream.CanTimeout) { stream.ReadTimeout = ReadTimeout; } var maxLengthSpecified = maxLength > 0; int i; byte b = 0, b0; var read = false; using (var mem = new MemoryStream()) { while (true) { b0 = b; i = stream.ReadByte(); if (i == -1) { break; } else { read = true; } b = (byte)i; if (maxLengthSpecified) { maxLength--; } if (maxLengthSpecified && mem.Length == 1 && b == termChar && b0 == termChar) { maxLength++; continue; } if (b == 10 || b == 13) { if (mem.Length == 0 && b == 10) { continue; } else { break; } } mem.WriteByte(b); if (maxLengthSpecified && maxLength == 0) { break; } } if (mem.Length == 0 && !read) { return(null); } return(encoding.GetString(mem.ToArray())); } }
protected override Task <TextChange?> GetTextChangeAsync(CompletionItem selectedItem, char?ch, CancellationToken cancellationToken) { return(Task.FromResult <TextChange?>(new TextChange( selectedItem.Span, // Do not insert colon on <Tab> so that user can complete out a variable name that does not currently exist. // ch == null is to support the old completion only. // Do not insert an extra colon if colon has been explicitly typed. (ch == null || ch == '\t' || ch == ':') ? selectedItem.DisplayText : selectedItem.GetEntireDisplayText()))); }
public LikeFilter(MediaItemAspectMetadata.AttributeSpecification attributeType, string expression, char?escapeChar) : this(attributeType, expression, escapeChar, true) { }
private char GetFillChar(char?fillChar, Type fieldType) { return(fillChar == null ? ' ' : fillChar.Value); }
protected override Task <TextChange?> GetTextChangeAsync(CompletionItem selectedItem, char?ch, CancellationToken cancellationToken) { return(Task.FromResult <TextChange?>(new TextChange( selectedItem.Span, selectedItem.DisplayText.Substring(0, selectedItem.DisplayText.Length - ColonString.Length)))); }
public static string ToEdiString(this double?value, Picture?picture, char?decimalMark) => ToEdiString((decimal?)value, picture, decimalMark);
internal static JsonString Create(char?value) => value is char c ? new JsonString(c.ToString()) : null;
public override Task <TextChange?> GetTextChangeAsync(Document document, CompletionItem selectedItem, char?ch, CancellationToken cancellationToken) { var insertionText = SymbolCompletionItem.GetInsertionText(selectedItem); return(Task.FromResult <TextChange?>(new TextChange(selectedItem.Span, insertionText))); }
public LikeFilter(MediaItemAspectMetadata.AttributeSpecification attributeType, string expression, char?escapeChar, bool caseSensitive) : base(attributeType, expression, escapeChar) { _caseSensitive = caseSensitive; }
private List <ExecutionCommand> GetExecutionCommands(Guid cmdGroup, uint nCmdID, IntPtr pvaIn, out char?typedChar) { typedChar = null; List <ExecutionCommand> ret = new List <ExecutionCommand>(); /* If there's automation, or we can't recognize cmdGroup, just pass on. */ if (VsShellUtilities.IsInAutomationFunction(provider.ServiceProvider) || (cmdGroup != VSConstants.VSStd2K)) { ret.Add(ExecutionCommand.CMD_PassToNextHandler); return(ret); } bool sessionActive = (session != null && !session.IsDismissed); bool sessionSelectionActive = (sessionActive && session.SelectedCompletionSet.SelectionStatus.IsSelected); switch ((VSConstants.VSStd2KCmdID)nCmdID) { case VSConstants.VSStd2KCmdID.AUTOCOMPLETE: case VSConstants.VSStd2KCmdID.COMPLETEWORD: ret.Add(sessionActive ? ExecutionCommand.CMD_PassToNextHandler : ExecutionCommand.CMD_StartSession); break; case VSConstants.VSStd2KCmdID.TYPECHAR: typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn); bool commitChr = TypedCharLeadsToCommit(typedChar.Value); bool triggerChr = TypedCharLeadsToTrigger(typedChar.Value); if (commitChr && sessionActive) { /* Ready to commit the completion. * We first check if we can commit something meaningful. * If so, we then check if this commit will lead to another * completion trigger. * */ if (sessionSelectionActive) { ret.Add(ExecutionCommand.CMD_Commit); ret.Add(ExecutionCommand.CMD_PassToNextHandler); if (triggerChr) { ret.Add(ExecutionCommand.CMD_StartSession); } } else { ret.Add(ExecutionCommand.CMD_Dismiss); ret.Add(ExecutionCommand.CMD_PassToNextHandler); } } else if (sessionActive) { /* Typed char doesn't lead to a commit. It leads to filter of completion results. */ ret.Add(ExecutionCommand.CMD_PassToNextHandler); ret.Add(ExecutionCommand.CMD_Filter); } else { ret.Add(ExecutionCommand.CMD_PassToNextHandler); /* Session not active, check if we have a trigger*/ if (triggerChr) { ret.Add(ExecutionCommand.CMD_StartSession); } } /* At last, we issue a CheckInputChar command to see if we * could do something about auto brackets completion, indention. */ ret.Add(ExecutionCommand.CMD_CheckInputChar); break; case VSConstants.VSStd2KCmdID.RETURN: case VSConstants.VSStd2KCmdID.TAB: if (sessionActive) { if (!sessionSelectionActive) { session.SelectedCompletionSet.SelectBestMatch(); } ret.Add(ExecutionCommand.CMD_Commit); } else { ret.Add(ExecutionCommand.CMD_PassToNextHandler); if (nCmdID == (uint)(VSConstants.VSStd2KCmdID.RETURN)) { typedChar = '\n'; ret.Add(ExecutionCommand.CMD_CheckInputChar); } } break; case VSConstants.VSStd2KCmdID.BACKSPACE: case VSConstants.VSStd2KCmdID.DELETE: ret.Add(ExecutionCommand.CMD_PassToNextHandler); if (sessionActive) { ret.Add(ExecutionCommand.CMD_Filter); } break; case VSConstants.VSStd2KCmdID.CANCEL: ret.Add(sessionActive ? ExecutionCommand.CMD_Dismiss : ExecutionCommand.CMD_PassToNextHandler); break; default: ret.Add(ExecutionCommand.CMD_PassToNextHandler); break; } return(ret); }
public override void WriteValue(char?value) => _writer.WriteValue(value);
public static string[] Split(this string text, string value, ChoStringSplitOptions stringSplitOptions, char?quoteChar = '\0', char?quoteEscape = ChoCharEx.Backslash) { return(Split(text, (object)value, stringSplitOptions, (quoteChar == null ? '\0' : quoteChar.Value), (quoteEscape == null ? ChoCharEx.Backslash : quoteEscape.Value))); }
//#if !NETSTANDARD2_0 // /// <summary> // /// Split the string into multiple strings by the Separators. // /// </summary> // /// <param name="text">A string value to be split.</param> // /// <param name="Separators">List of Separators used to split the string.</param> // /// <param name="ignoreEmptyWord">true, to ignore the empry words in the output list</param> // /// <returns>A string array contains splitted values, if the input text is null/empty, an empty array will be returned.</returns> // //public static string[] Split(this string text, char[] Separators, ChoStringSplitOptions stringSplitOptions, char quoteChar = '\0') // //{ // // return Split(text, (object)Separators, stringSplitOptions, quoteChar); // //} // public static string[] FastSplit(this string sText, char? cSeparator = ',', char? cQuotes = '"') // { // string[] oTokens; // unsafe // { // fixed (char* lpText = sText) // { // #region Fast array estimatation // char* lpCurrent = lpText; // int nEstimatedSize = 0; // while (0 != *lpCurrent) // { // if (cSeparator == *lpCurrent) // { // nEstimatedSize++; // } // lpCurrent++; // } // nEstimatedSize++; // Add EOL char(s) // string[] oEstimatedTokens = new string[nEstimatedSize]; // #endregion // #region Parsing // char[] oBuffer = new char[sText.Length]; // int nIndex = 0; // int nTokens = 0; // lpCurrent = lpText; // while (0 != *lpCurrent) // { // if (cQuotes == *lpCurrent) // { // // Quotes parsing // lpCurrent++; // Skip quote // nIndex = 0; // Reset buffer // while ( // (0 != *lpCurrent) // && (cQuotes != *lpCurrent) // ) // { // oBuffer[nIndex] = *lpCurrent; // Store char // lpCurrent++; // Move source cursor // nIndex++; // Move target cursor // } // } // else if (cSeparator == *lpCurrent) // { // // Separator char parsing // oEstimatedTokens[nTokens++] = new string(oBuffer, 0, nIndex); // Store token // nIndex = 0; // Skip separator and Reset buffer // } // else // { // // Content parsing // oBuffer[nIndex] = *lpCurrent; // Store char // nIndex++; // Move target cursor // } // lpCurrent++; // Move source cursor // } // // Recover pending buffer // if (nIndex > 0) // { // // Store token // oEstimatedTokens[nTokens++] = new string(oBuffer, 0, nIndex); // } // // Build final tokens list // if (nTokens == nEstimatedSize) // { // oTokens = oEstimatedTokens; // } // else // { // oTokens = new string[nTokens]; // Array.Copy(oEstimatedTokens, 0, oTokens, 0, nTokens); // } // #endregion // } // } // // Epilogue // return oTokens; // } //#else // public static string[] FastSplit(this string stringToSplit, char? cSeparator = ',', char? cQuotes = '"') // { // char[] characters = stringToSplit.ToCharArray(); // List<string> returnValueList = new List<string>(); // string tempString = ""; // bool blockUntilEndQuote = false; // int characterCount = 0; // foreach (char character in characters) // { // characterCount = characterCount + 1; // if (character == cQuotes) // { // if (blockUntilEndQuote == false) // { // blockUntilEndQuote = true; // } // else if (blockUntilEndQuote == true) // { // blockUntilEndQuote = false; // } // } // if (character != cSeparator) // { // tempString = tempString + character; // } // else if (character == cSeparator && blockUntilEndQuote == true) // { // tempString = tempString + character; // } // else // { // returnValueList.Add(tempString); // tempString = ""; // } // if (characterCount == characters.Length) // { // returnValueList.Add(tempString); // tempString = ""; // } // } // string[] returnValue = returnValueList.ToArray(); // return returnValue; // } //#endif public static string[] FastSplit(this string line, char?cSeparator = ',', char?cQuotes = '"', char?cQuoteEscape = ChoCharEx.Backslash) { char escapeChar = cQuoteEscape == null ? ChoCharEx.Backslash : cQuoteEscape.Value; List <string> result = new List <string>(); StringBuilder currentStr = new StringBuilder(""); bool inQuotes = false; int length = line.Length; bool lineEnded = false; for (int i = 0; i < line.Length; i++) // For each character { if (!inQuotes && line[i] == escapeChar && i + 1 < length && line[i + 1] == escapeChar) { currentStr.Append(line[i + 1]); i++; } else if (!inQuotes && line[i] == escapeChar && i + 1 < length && line[i + 1] == cQuotes) { currentStr.Append(line[i + 1]); i++; } else if (!inQuotes && line[i] == cQuotes) { if (i == length - 1) { currentStr.Append(line[i]); } inQuotes = !inQuotes; } else if (inQuotes && ( ((i + 1 < length && line[i + 1] == cSeparator) || (i + 1 == length)) ) ) // Comma { if (line[i] == cQuotes) // If not in quotes, end of current string, add it to result { inQuotes = false; lineEnded = i + 1 == length; result.Add(currentStr.ToString()); currentStr.Clear(); i++; } else { currentStr.Append(line[i]); // If in quotes, just add it } } else if (inQuotes && line[i] == escapeChar && i + 1 < length && line[i + 1] == escapeChar) { currentStr.Append(line[i + 1]); i++; } else if (inQuotes && ((line[i] == escapeChar && i + 1 < length && line[i + 1] == cQuotes)) ) // Comma { i++; //inQuotes = false; currentStr.Append(line[i]); } else if (inQuotes && line[i] == cQuotes) { if (i + 1 < length && line[i + 1] == cQuotes) { currentStr.Append(line[i]); i++; } else { inQuotes = false; } } else if (line[i] == cSeparator) // Comma { if (!inQuotes) // If not in quotes, end of current string, add it to result { var value = currentStr.ToString(); if (value.Length == 1 && value[0] == cQuoteEscape) { result.Add(String.Empty); } else { result.Add(value); } currentStr.Clear(); } else { currentStr.Append(line[i]); // If in quotes, just add it } } else // Add any other character to current string { currentStr.Append(line[i]); } } if (!lineEnded) { result.Add(currentStr.ToString()); } return(result.ToArray()); // Return array of all strings }
// parse a component of the expanded set. // At this point, no pattern may contain "/" in it // so we're going to return a 2d array, where each entry is the full // pattern, split on '/', and then turned into a regular expression. // A regexp is made at the end which joins each array with an // escaped /, and another full one which joins each regexp with |. // // Following the lead of Bash 4.1, note that "**" only has special meaning // when it is the *only* thing in a path portion. Otherwise, any series // of * is equivalent to a single *. Globstar behavior is enabled by // default, and can be disabled by setting options.noglobstar. private Tuple <ParseItem, bool> Parse(string pattern, bool isSub) { // shortcuts if (!options.NoGlobStar && pattern == "**") { return(Tuple.Create(GlobStar.Instance, false)); } if (pattern == "") { return(Tuple.Create(ParseItem.Empty, false)); } string re = ""; bool hasMagic = options.NoCase, escaping = false, inClass = false; // ? => one single character var patternListStack = new Stack <PatternListEntry>(); char plType; char?stateChar = null; int reClassStart = -1, classStart = -1; // . and .. never match anything that doesn't start with ., // even when options.dot is set. string patternStart = pattern[0] == '.' ? "" // anything // not (start or / followed by . or .. followed by / or end) : options.Dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)"; Action clearStateChar = () => { if (stateChar != null) { // we had some state-tracking character // that wasn't consumed by this pass. switch (stateChar) { case '*': re += star; hasMagic = true; break; case '?': re += qmark; hasMagic = true; break; default: re += "\\" + stateChar; break; } stateChar = null; } }; for (var i = 0; i < pattern.Length; i++) { var c = pattern[i]; //if (options.debug) { // console.error("%s\t%s %s %j", pattern, i, re, c) //} // skip over any that are escaped. if (escaping && reSpecials.Contains(c)) { re += "\\" + c; escaping = false; continue; } switch (c) { case '/': // completely not allowed, even escaped. // Should already be path-split by now. return(null); case '\\': clearStateChar(); escaping = true; continue; // the various stateChar values // for the 'extglob' stuff. case '?': case '*': case '+': case '@': case '!': //if (options.debug) { // console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c) //} // all of those are literals inside a class, except that // the glob [!a] means [^a] in regexp if (inClass) { if (c == '!' && i == classStart + 1) { c = '^'; } re += c; continue; } // if we already have a stateChar, then it means // that there was something like ** or +? in there. // Handle the stateChar, then proceed with this one. clearStateChar(); stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing. // just clear the statechar *now*, rather than even diving into // the patternList stuff. if (options.NoExt) { clearStateChar(); } continue; case '(': if (inClass) { re += "("; continue; } if (stateChar == null) { re += "\\("; continue; } plType = stateChar.Value; patternListStack.Push(new PatternListEntry { Type = plType, Start = i - 1, ReStart = re.Length }); // negation is (?:(?!js)[^/]*) re += stateChar == '!' ? "(?:(?!" : "(?:"; stateChar = null; continue; case ')': if (inClass || !patternListStack.Any()) { re += "\\)"; continue; } hasMagic = true; re += ')'; plType = patternListStack.Pop().Type; // negation is (?:(?!js)[^/]*) // The others are (?:<pattern>)<type> switch (plType) { case '!': re += "[^/]*?)"; break; case '?': case '+': case '*': re += plType; break; case '@': break; // the default anyway } continue; case '|': if (inClass || !patternListStack.Any() || escaping) { re += "\\|"; escaping = false; continue; } re += "|"; continue; // these are mostly the same in regexp and glob case '[': // swallow any state-tracking char before the [ clearStateChar(); if (inClass) { re += "\\" + c; continue; } inClass = true; classStart = i; reClassStart = re.Length; re += c; continue; case ']': // a right bracket shall lose its special // meaning and represent itself in // a bracket expression if it occurs // first in the list. -- POSIX.2 2.8.3.2 if (i == classStart + 1 || !inClass) { re += "\\" + c; escaping = false; continue; } // finish up the class. hasMagic = true; inClass = false; re += c; continue; default: // swallow any state char that wasn't consumed clearStateChar(); if (escaping) { // no need escaping = false; } else if (reSpecials.Contains(c) && !(c == '^' && inClass)) { re += "\\"; } re += c; break; } // switch } // for // handle the case where we left a class open. // "[abc" is valid, equivalent to "\[abc" if (inClass) { // split where the last [ was, and escape it // this is a huge pita. We now have to re-walk // the contents of the would-be class to re-translate // any characters that were passed through as-is string cs = pattern.Substring(classStart + 1); var sp = this.Parse(cs, true); re = re.Substring(0, reClassStart) + "\\[" + sp.Item1.Source; hasMagic = hasMagic || sp.Item2; } // handle the case where we had a +( thing at the *end* // of the pattern. // each pattern list stack adds 3 chars, and we need to go through // and escape any | chars that were passed through as-is for the regexp. // Go through and escape them, taking care not to double-escape any // | chars that were already escaped. while (patternListStack.Any()) { var pl = patternListStack.Pop(); var tail = re.Substring(pl.ReStart + 3); // maybe some even number of \, then maybe 1 \, followed by a | tail = escapeCheck.Replace(tail, m => { string escape = m.Groups[2].Value; // the | isn't already escaped, so escape it. if (String.IsNullOrEmpty(escape)) { escape = "\\"; } // need to escape all those slashes *again*, without escaping the // one that we need for escaping the | character. As it works out, // escaping an even number of slashes can be done by simply repeating // it exactly after itself. That's why this trick works. // // I am sorry that you have to see this. return(m.Groups[1].Value + m.Groups[1].Value + escape + "|"); }); // console.error("tail=%j\n %s", tail, tail) var t = pl.Type == '*' ? star : pl.Type == '?' ? qmark : "\\" + pl.Type; hasMagic = true; re = re.Remove(pl.ReStart) + t + "\\(" + tail; } // handle trailing things that only matter at the very end. clearStateChar(); if (escaping) { // trailing \\ re += "\\\\"; } // only need to apply the nodot start if the re starts with // something that could conceivably capture a dot var addPatternStart = false; switch (re[0]) { case '.': case '[': case '(': addPatternStart = true; break; } // if the re is not "" at this point, then we need to make sure // it doesn't match against an empty path part. // Otherwise a/* will match a/, which it should not. if (re != "" && hasMagic) { re = "(?=.)" + re; } if (addPatternStart) { re = patternStart + re; } // parsing just a piece of a larger pattern. if (isSub) { return(Tuple.Create(ParseItem.Literal(re), hasMagic)); } // skip the regexp for non-magical patterns // unescape anything in it, though, so that it'll be // an exact match against a file etc. if (!hasMagic) { return(Tuple.Create(ParseItem.Literal(GlobUnescape(pattern)), false)); } return(new Tuple <ParseItem, bool>(new MagicItem(re, options), false)); }
public extern SpriteFont(Texture2D texture, List <Rectangle> glyphBounds, List <Rectangle> cropping, List <char> characters, int lineSpacing, float spacing, List <Vector3> kerning, char?defaultCharacter);
protected WinRelativePath(string path, char? separator) : base(path, separator) { }
static void Main(string[] args) { while (true) { Console.Write("Enter number of generated generic MethodState files: "); string input = Console.ReadLine(); if (!byte.TryParse(input, out byte maxGenerics) || maxGenerics == byte.MinValue || maxGenerics == byte.MaxValue) { Console.WriteLine("Invalid max number of generics"); continue; } for (byte i = 0; i < maxGenerics; i++) { byte currentCountOfGenerics = (byte)(i + 1); string fileName = $@"..\..\..\..\NilDev.MethodState\MethodState{currentCountOfGenerics}.generated.cs"; if (File.Exists(fileName)) { try { Console.WriteLine($@"File ""{fileName}"" already exists. Deleting it..."); File.Delete(fileName); Console.WriteLine($@"File ""{fileName}"" deleted."); } catch (Exception ex) { Console.WriteLine("Could not delete the file:"); Console.WriteLine(ex); continue; } } char? argumentSeparator = null; string stateSwitchDefinitionSB = @" switch (_selectedTypeIndex) {"; var genericDefinitionSB = new StringBuilder(); var actionDefinitionSB = new StringBuilder(); var voidObserveCasesSB = new StringBuilder(stateSwitchDefinitionSB); var resultObserverCaseSB = new StringBuilder(stateSwitchDefinitionSB); var genericsDocumentationSB = new StringBuilder(); var synchronousObserverDocumentationSB = new StringBuilder(); var asynchronousObserverDocumentationSB = new StringBuilder(); var asyncObserversDefinitionSB = new StringBuilder(); var transformerObserversDefinitionSB = new StringBuilder(); var asyncTransformerObserversDefinitionSB = new StringBuilder(); var observMethodCallSB = new StringBuilder(@" return Observe("); var ctorSB = new StringBuilder(); var implicitCastSB = new StringBuilder(); genericDefinitionSB.Append('<'); actionDefinitionSB.Append('('); asyncObserversDefinitionSB.Append('('); transformerObserversDefinitionSB.Append('('); asyncTransformerObserversDefinitionSB.Append('('); for (byte j = 0; j < currentCountOfGenerics; j++) { if (!(argumentSeparator is null)) { genericDefinitionSB.Append(argumentSeparator); genericDefinitionSB.Append(' '); } byte currentGenericNumber = (byte)(j + 1); string genericType = $"T{currentGenericNumber}"; genericDefinitionSB.Append(genericType); argumentSeparator = ','; } genericDefinitionSB.Append('>'); argumentSeparator = null; for (byte j = 0; j < currentCountOfGenerics; j++) { byte currentGenericNumber = (byte)(j + 1); string ordinalGenericNumber = GetOrdinalNumber(currentGenericNumber); string genericType = $"T{currentGenericNumber}"; string stateName = "_state"; string currentStateName = $"state{currentGenericNumber}"; string observerName = $"observer{currentGenericNumber}"; string funcTypeDefinition = $"Func<{genericType}, "; genericsDocumentationSB.Append(@" /// <typeparam name="""); genericsDocumentationSB.Append(genericType); genericsDocumentationSB.Append(@""">Type of a "); genericsDocumentationSB.Append(ordinalGenericNumber); genericsDocumentationSB.Append(" possible state.</typeparam>"); synchronousObserverDocumentationSB.Append(@" /// <param name="""); synchronousObserverDocumentationSB.Append(observerName); synchronousObserverDocumentationSB.Append(@""">Observer for the "); synchronousObserverDocumentationSB.Append(ordinalGenericNumber); synchronousObserverDocumentationSB.Append(" state.</param>"); asynchronousObserverDocumentationSB.Append(@" /// <param name="""); asynchronousObserverDocumentationSB.Append(observerName); asynchronousObserverDocumentationSB.Append(@""">Asynchronous observer for the "); asynchronousObserverDocumentationSB.Append(ordinalGenericNumber); asynchronousObserverDocumentationSB.Append(" state.</param>"); var caseSB = new StringBuilder(@" case "); caseSB.Append(currentGenericNumber); caseSB.Append(':'); var stateCastSB = new StringBuilder(@" var "); stateCastSB.Append(currentStateName); stateCastSB.Append(" = ("); stateCastSB.Append(genericType); stateCastSB.Append(')'); stateCastSB.Append(stateName); stateCastSB.Append(@"; "); var observerCallSB = new StringBuilder(observerName); observerCallSB.Append('('); observerCallSB.Append(currentStateName); observerCallSB.Append(')'); observerCallSB.Append(';'); voidObserveCasesSB.Append(caseSB); voidObserveCasesSB.Append(stateCastSB); voidObserveCasesSB.Append(observerCallSB); voidObserveCasesSB.Append(@" break;"); resultObserverCaseSB.Append(caseSB); resultObserverCaseSB.Append(stateCastSB); resultObserverCaseSB.Append("return "); resultObserverCaseSB.Append(observerCallSB); if (!(argumentSeparator is null)) { actionDefinitionSB.Append(argumentSeparator); actionDefinitionSB.Append(' '); asyncObserversDefinitionSB.Append(argumentSeparator); asyncObserversDefinitionSB.Append(' '); transformerObserversDefinitionSB.Append(argumentSeparator); transformerObserversDefinitionSB.Append(' '); asyncTransformerObserversDefinitionSB.Append(argumentSeparator); asyncTransformerObserversDefinitionSB.Append(' '); observMethodCallSB.Append(argumentSeparator); observMethodCallSB.Append(' '); } actionDefinitionSB.Append("Action<"); actionDefinitionSB.Append(genericType); actionDefinitionSB.Append('>'); actionDefinitionSB.Append(' '); actionDefinitionSB.Append(observerName); asyncObserversDefinitionSB.Append(funcTypeDefinition); asyncObserversDefinitionSB.Append("Task>"); asyncObserversDefinitionSB.Append(' '); asyncObserversDefinitionSB.Append(observerName); transformerObserversDefinitionSB.Append(funcTypeDefinition); transformerObserversDefinitionSB.Append("TResult>"); transformerObserversDefinitionSB.Append(' '); transformerObserversDefinitionSB.Append(observerName); asyncTransformerObserversDefinitionSB.Append(funcTypeDefinition); asyncTransformerObserversDefinitionSB.Append("Task<TResult>>"); asyncTransformerObserversDefinitionSB.Append(' '); asyncTransformerObserversDefinitionSB.Append(observerName); observMethodCallSB.Append(observerName); ctorSB.Append(@" /// <summary> /// Constructs the "); ctorSB.Append(ordinalGenericNumber); ctorSB.Append(@" state. /// </summary> /// <param name=""state"">Current state.</param> private MethodState("); ctorSB.Append(genericType); ctorSB.Append(@" state) { _state = state; _selectedTypeIndex = "); ctorSB.Append(currentGenericNumber); ctorSB.Append(@"; }"); implicitCastSB.Append(@" /// <summary> /// Implicit cast for the "); implicitCastSB.Append(ordinalGenericNumber); implicitCastSB.Append(@" state. /// </summary> /// <param name=""state"">Current state.</param> public static implicit operator MethodState"); implicitCastSB.Append(genericDefinitionSB); implicitCastSB.Append("("); implicitCastSB.Append(genericType); implicitCastSB.Append(@" state) { if (state is null) { return new MethodState"); implicitCastSB.Append(genericDefinitionSB); implicitCastSB.Append(@"(); } return new MethodState"); implicitCastSB.Append(genericDefinitionSB); implicitCastSB.Append(@"(state); }"); argumentSeparator = ','; } actionDefinitionSB.Append(", Action nullObserver)"); asyncObserversDefinitionSB.Append(", Func<Task> nullObserver)"); transformerObserversDefinitionSB.Append(", Func<TResult> nullObserver)"); asyncTransformerObserversDefinitionSB.Append(", Func<Task<TResult>> nullObserver)"); observMethodCallSB.Append(", nullObserver);"); voidObserveCasesSB.Append(@" case 0: nullObserver(); break; default: throw new InvalidOperationException(""Cannot determine the method state.""); }"); resultObserverCaseSB.Append(@" case 0: return nullObserver(); default: throw new InvalidOperationException(""Cannot determine the method state.""); }"); StringBuilder sb = new StringBuilder(@"using System; using System.Threading.Tasks; namespace NilDev.MethodState { /// <summary> /// Describes the possible states which can be returned by a method and gives the possibility to observe it when required. /// </summary>"); sb.Append(genericsDocumentationSB); sb.Append(@" public struct MethodState"); sb.Append(genericDefinitionSB); sb.Append(@" { private readonly object _state; private readonly byte _selectedTypeIndex;"); sb.AppendLine(); sb.Append(@" /// <summary> /// This method lets the caller observe the current state by calling respective state observer. /// </summary>"); sb.Append(synchronousObserverDocumentationSB); sb.Append(@" /// <param name=""nullObserver"">Observer when the current state is null</param> public void Observe"); sb.Append(actionDefinitionSB); sb.AppendLine(@" {"); sb.Append(voidObserveCasesSB); sb.Append(@" } /// <summary> /// This method lets the caller observe the current state asynchronously by calling respective state observer. /// </summary>"); sb.Append(asynchronousObserverDocumentationSB); sb.Append(@" /// <param name=""nullObserver"">Asynchronous observer when the current state is null</param> /// <returns>Task</returns> public Task ObserveAsync"); sb.Append(asyncObserversDefinitionSB); sb.Append(@" {"); sb.Append(observMethodCallSB); sb.Append(@" } /// <summary> /// This method lets the caller observe the current state by calling respective state observer and returns an observation result. /// </summary> /// <typeparam name=""TResult"">Type of observation result.</typeparam>"); sb.Append(synchronousObserverDocumentationSB); sb.Append(@" /// <param name=""nullObserver"">Observer when the current state is null</param> /// <returns>Observation result.</returns> public TResult Observe<TResult>"); sb.Append(transformerObserversDefinitionSB); sb.Append(@" {"); sb.Append(resultObserverCaseSB); sb.Append(@" } /// <summary> /// This method lets the caller observe the current state by calling respective state observer and returns an observation result asynchronously. /// </summary> /// <typeparam name=""TResult"">Type of observation result.</typeparam>"); sb.Append(asynchronousObserverDocumentationSB); sb.Append(@" /// <param name=""nullObserver"">Asynchronous observer when the current state is null</param> /// <returns>Task</returns> public Task<TResult> ObserveAsync<TResult>"); sb.Append(asyncTransformerObserversDefinitionSB); sb.Append(@" {"); sb.Append(observMethodCallSB); sb.Append(@" }"); sb.Append(ctorSB); sb.Append(implicitCastSB); sb.Append(@" } }"); File.WriteAllText(fileName, sb.ToString()); } break; } }
/// <summary> /// Writes this XML to string while allowing invalid XML chars to either be /// simply removed during the write process, or else encoded into entities, /// instead of having an exception occur, as the standard XmlWriter.Create /// XmlWriter does (which is the default writer used by XElement). /// </summary> /// <param name="xml">XElement.</param> /// <param name="deleteInvalidChars">True to have any invalid chars deleted, else they will be entity encoded.</param> /// <param name="indent">Indent setting.</param> /// <param name="indentChar">Indent char (leave null to use default)</param> public static string ToStringIgnoreInvalidChars(this XElement xml, bool deleteInvalidChars = true, bool indent = true, char?indentChar = null) { if (xml == null) { return(null); } StringWriter swriter = new StringWriter(); using (XmlTextWriterIgnoreInvalidChars writer = new XmlTextWriterIgnoreInvalidChars(swriter, deleteInvalidChars)) { // -- settings -- // unfortunately writer.Settings cannot be set, is null, so we can't specify: bool newLineOnAttributes, bool omitXmlDeclaration writer.Formatting = indent ? Formatting.Indented : Formatting.None; if (indentChar != null) { writer.IndentChar = (char)indentChar; } // -- write -- xml.WriteTo(writer); } return(swriter.ToString()); }
public override Task WriteValueAsync(char?value, CancellationToken cancellationToken = new CancellationToken()) => _writer.WriteValueAsync(value, cancellationToken);
public ClickHouseConnectionSettings(string connectionString) { var varName = new StringBuilder(); var varValue = new StringBuilder(); char?valueEscape = null; var inEscape = false; var inValue = false; foreach (var c in connectionString) { if (inEscape) { if (inValue) { varValue.Append(c); } else { varName.Append(c); } inEscape = false; } else if (valueEscape.HasValue) { if (valueEscape.Value == c) { valueEscape = null; } else { if (inValue) { varValue.Append(c); } else { varName.Append(c); } } } else { switch (c) { case '\\': inEscape = true; break; case '"': case '\'': valueEscape = c; break; default: { if (char.IsWhiteSpace(c)) { } else { switch (c) { case '=' when inValue: throw new FormatException($"Value for parameter {varName} in the connection string contains unescaped '='."); case '=': inValue = true; break; case ';' when !inValue: throw new FormatException($"No value for parameter {varName} in the connection string."); case ';': SetValue(varName.ToString(), varValue.ToString()); inValue = false; varName.Clear(); varValue.Clear(); break; default: { if (inValue) { varValue.Append(c); } else { varName.Append(c); } break; } } } break; } } } } if (inValue) { SetValue(varName.ToString(), varValue.ToString()); } }
static void FromChar() { Console.WriteLine("--- FromChar"); char?[] a = new char?[] { new char?(), new char?('b'), new char?('c') }; TestCore(a); }
public static string TrimRight(string str, char?ch) { return(str == null || ch == null ? null : str.TrimEnd(ch.Value)); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); ArraySamples arraySamples = new ArraySamples(); int[] arrayMostFrequent = { 1, 2, 3, 1 }; int result = arraySamples.MostFrequentOccurring(arrayMostFrequent); Console.WriteLine($"{result} occurred most in the given array"); int[] array1 = { 1, 2, 3, 4 }; int[] array2 = { 1, 3, 9 }; List <int> commonValues = arraySamples.CommonElements(array1, array2); foreach (int value in commonValues) { Console.WriteLine($"{value} occurred in both the given arrays using contains"); } List <int> commonValuesWithLoops = arraySamples.CommonElementsWithLoops(array1, array2); foreach (int value in commonValuesWithLoops) { Console.WriteLine($"{value} occurred in both the given arrays when using loops"); } int[] array3 = { 1, 2, 3, 4, 5, 6, 7 }; int[] array4 = { 4, 5, 6, 7, 1, 2, 3 }; bool isRotation = arraySamples.IsRotation(array3, array4); string message = isRotation ? "TRUE: The two arrays are rotations of one another" : "FALSE: These two arrays are NOT rotations of one anoter"; Console.WriteLine($"{message}"); //test string StringSamples stringSamples = new StringSamples(); string testStr = "bbaccdds"; char?nonRepeater = stringSamples.NonRepeating(testStr); Console.WriteLine($"The value that did not repeat is: {nonRepeater}"); //One Edit away string testStr1 = "a"; string testStr2 = "a"; bool isOneEdit = stringSamples.IsOneEditAway(testStr1, testStr2); Console.WriteLine($"The two strings are one edit away: {isOneEdit}"); //test multi MultiDimArraySamples multiDimArraySamples = new MultiDimArraySamples(); //minesweeper count bombs int[][] bombs = new int[][] { new int[] { 0, 0 }, new int[] { 0, 1 } }; int[,] minesweeper = multiDimArraySamples.Minesweeper(bombs, 3, 4); Console.WriteLine($"mine field returmed"); int[,] startMineField = { { -1, 1, 0, 0 }, { 1, 1, 0, 0 }, { 0, 0, 1, 1 }, { 0, 0, 1, -1 } }; multiDimArraySamples.expandMinesweeper(startMineField, 4, 4, 1, 2); Console.WriteLine($"mine field returmed"); //ArrayDemo(); Console.ReadLine(); }
/// <summary> /// Performs the calculation of the current stacks /// </summary> /// <param name="operands">Current stack of operators.</param> /// <param name="values">Current stack of values.</param> /// <param name="precedence">Optional; Sets the precedence value which is used in Part 2.</param> /// <returns>Both operands and values stacks.</returns> private static (Stack <char> operands, Stack <double> values) Calculate(Stack <char> operands, Stack <double> values, char?precedence = Token.Multiply) { while (operands.Peek() != Token.LeftBracket && (precedence == Token.Multiply || operands.Peek() != Token.Multiply)) { switch (operands.Pop()) { case Token.Addition: values.Push(values.Pop() + values.Pop()); break; case Token.Multiply: values.Push(values.Pop() * values.Pop()); break; } } return(operands, values); }
protected RelativePath(string path, char?separator = null) { _path = path; _separator = separator; }
public PlayerIIMove(string originalPosition, string newPosition, char?promotion) { OriginalPosition = originalPosition; NewPosition = newPosition; Promotion = promotion; }
public void pve() { int player = 0; if (PLAYERS[0] == ai.symbol) { // Console.WriteLine("Komputer gra jako: " + PLAYERS[0]); // Console.WriteLine("Człowiek gra jako: " + PLAYERS[1]); } else { // Console.WriteLine("Komputer gra jako: " + PLAYERS[1]); // Console.WriteLine("Człowiek gra jako: " + PLAYERS[0]); } do { bool full = false; // Console.WriteLine("0123456"); // Console.WriteLine(toString()); player %= 2; // Console.WriteLine(player); if (PLAYERS[player] == ai.symbol) { int col = ai.selectedColumn(); dropOne(ai.symbol, col); // Console.WriteLine("Tura Komputera: " + col); player++; } else { // Console.Write("Tura Gracza: "); int col = Convert.ToInt32(Console.ReadLine()); if (col < 0 || col > width - 1) { // Console.WriteLine("Kolumna musi być między 0 a 6 "); } else { if (!dropOne(ai.theOtherSymbol(), col)) { // Console.WriteLine("Kolumna pełna, wybierz inną!"); } else { player++; } } } winner = checkWin(); if (winner != null) { // Console.WriteLine("Brawo wygrywają: " + winner); // Console.WriteLine(toString()); break; } isFull(); if (isF) { // Console.WriteLine("Remis!"); // Console.WriteLine(toString()); break; } } while (true); }
/// <summary> /// Creates a printable key (alpha-numeric or special character). /// </summary> /// <param name="rawCode">Char code of the key.</param> public Key(char rawCode) { _rawCode = rawCode; _name = rawCode.ToString(); }
public Task <char?> EchoNullableCharFromBody([FromBody] char?input) { return(Task.Factory.StartNew(() => input)); }
public async void eve() { int player = 0; if (PLAYERS[0] == ai.symbol) { // Console.WriteLine("Komputer gra jako: " + PLAYERS[0]); //Console.WriteLine("Człowiek gra jako: " + PLAYERS[1]); } else { // Console.WriteLine("Komputer gra jako: " + PLAYERS[1]); // Console.WriteLine("Człowiek gra jako: " + PLAYERS[0]); } do { bool full = false; //Console.WriteLine("0123456"); //Console.WriteLine(toString()); player %= 2; //Console.WriteLine(player); if (PLAYERS[player] == ai.symbol) { if (!aif) { int col = ai.selectedColumn(); dropOne(ai.symbol, col); // Console.WriteLine("Tura Komputera: "+ col); player++; og.updateGrid2(); } else { int col = rand.Next(0, 7); dropOne(ai.symbol, col); player++; aif = false; og.updateGrid2(); } } else { /* Console.Write("Tura Gracza: "); * int col = Convert.ToInt32(Console.ReadLine()); * * if (col < 0 || col > width-1) * { * Console.WriteLine("Kolumna musi być między 0 a 6 "); * * } * else * { * if(!dropOne(ai.theOtherSymbol(),col)) * { * Console.WriteLine("Kolumna pełna, wybierz inną!"); * } * else * { * player++; * } * } */ if (!ai2f) { int col = ai2.selectedColumn(); dropOne(ai2.symbol, col); // Console.WriteLine("Tura Komputera: " + col); player++; og.updateGrid2(); } else { int col = rand.Next(0, 7); dropOne(ai2.symbol, col); player++; ai2f = false; og.updateGrid2(); } } winner = checkWin(); if (winner != null) { //Console.WriteLine("Brawo wygrywają: " + winner); //Console.WriteLine(toString()); ; og.showWinner(); break; } isFull(); if (isF) { //Console.WriteLine("Remis!"); //Console.WriteLine(toString()); break; } } while (true); }