Exemple #1
0
        /// <summary>
        ///     Determines whether [is match implementation] [the specified tokenizer].
        /// </summary>
        protected override Token IsMatchImpl(Tokenizer tokenizer)
        {
            foreach (var character in Match)
            {
                if (tokenizer.Current == character.ToString(CultureInfo.InvariantCulture))
                {
                    tokenizer.Consume();
                }
                else
                {
                    return(null);
                }
            }

            bool found;

            if (!AllowAsSubString)
            {
                var next = tokenizer.Current;

                found = string.IsNullOrWhiteSpace(next) || SpecialCharacters.Any(character => character.Match == next);
            }
            else
            {
                found = true;
            }

            if (found)
            {
                return(new Token(TokenType, Match));
            }

            return(null);
        }
        /// <summary>
        /// Builds a new <see cref="StringValueExpression"/> instance that can wrap a string value
        /// </summary>
        /// <param name="value">value of the expression.</param>
        /// <remarks>
        /// The <see cref="EscapedParseableString"/> property automatically escapes <see cref="SpecialCharacters"/> from <paramref name="value"/>.
        /// </remarks>
        public StringValueExpression(string value) : base(value)
        {
            _lazyParseableString = new(() =>
            {
                // The length of the final parseable string in worst cases scenario will double (1 backlash + the escaped character)
                // Also we need an extra position for the final '*' that will be append in all cases
                bool requireEscapingCharacters = value.AtLeastOnce(chr => SpecialCharacters.Contains(chr));
                StringBuilder parseableString;

                if (requireEscapingCharacters)
                {
                    parseableString = new((value.Length * 2) + 1);
                    foreach (char chr in value)
                    {
                        if (SpecialCharacters.Contains(chr))
                        {
                            parseableString = parseableString.Append('\\');
                        }
                        parseableString = parseableString.Append(chr);
                    }
                }
                else
                {
                    parseableString = new(value);
                }

                return(parseableString.ToString());
            });
        }
        /// <summary>
        /// Gets the word in a switch from the current argument or parses a file.
        /// For example -foo, /foo, or --foo would return 'foo'.
        /// </summary>
        /// <param name="args">
        /// The command line parameters to be processed.
        /// </param>
        /// <param name="argIndex">
        /// The index in args to the argument to process.
        /// </param>
        /// <param name="parser">
        /// Used to parse files in the args.  If not supplied, Files will not be parsed.
        /// </param>
        /// <param name="noexitSeen">
        /// Used during parsing files.
        /// </param>
        /// <returns>
        /// Returns a Tuple:
        /// The first value is a String called SwitchKey with the word in a switch from the current argument or null.
        /// The second value is a bool called ShouldBreak, indicating if the parsing look should break.
        /// </returns>
        private static (string SwitchKey, bool ShouldBreak) GetSwitchKey(string[] args, ref int argIndex, CommandLineParameterParser parser, ref bool noexitSeen)
        {
            string switchKey = args[argIndex].Trim().ToLowerInvariant();

            if (string.IsNullOrEmpty(switchKey))
            {
                return(SwitchKey : null, ShouldBreak : false);
            }

            if (!SpecialCharacters.IsDash(switchKey[0]) && switchKey[0] != '/')
            {
                // then its a file
                if (parser != null)
                {
                    --argIndex;
                    parser.ParseFile(args, ref argIndex, noexitSeen);
                }

                return(SwitchKey : null, ShouldBreak : true);
            }

            // chop off the first character so that we're agnostic wrt specifying / or -
            // in front of the switch name.
            switchKey = switchKey.Substring(1);

            // chop off the second dash so we're agnostic wrt specifying - or --
            if (!string.IsNullOrEmpty(switchKey) && SpecialCharacters.IsDash(switchKey[0]))
            {
                switchKey = switchKey.Substring(1);
            }

            return(SwitchKey : switchKey, ShouldBreak : false);
        }
 internal static string SerializeValueAssignmentDeclaration(string keyString, int indentation, int objectDepth, EFormatOption keyFormatOption)
 {
     return(new string('\t', indentation)
            + new string(SpecialCharacters.objectDepth, objectDepth) + " "
            + SpecialCharacters.FormatStringValue(keyString, keyFormatOption)
            + $" {SpecialCharacters.valueAssignment} ");
 }
Exemple #5
0
 /// <summary>
 ///     Clears all the global
 /// </summary>
 public static void ClearValues()
 {
     AccountingGroups.Clear();
     CostProfileGroups.Clear();
     CountriesOfOrigin.Clear();
     CustomerIdConversions.Clear();
     ExternalIdTypes.Clear();
     ItemCategories.Clear();
     ItemGroups.Clear();
     ItemIds.Clear();
     ItemIdSuffixes.Clear();
     ItemRecords.Clear();
     Languages.Clear();
     Licenses.Clear();
     LocalItemIds.Clear();
     MetaDescriptions.Clear();
     PricingGroups.Clear();
     ProductCategories.Clear();
     ProductFormats.Clear();
     ProductGoups.Clear();
     ProductLines.Clear();
     Properties.Clear();
     PsStatuses.Clear();
     RequestStatus.Clear();
     SpecialCharacters.Clear();
     TariffCodes.Clear();
     Territories.Clear();
     ToolTips.Clear();
     UpcProductFormatExceptions.Clear();
     Upcs.Clear();
     UserNames.Clear();
     UserRoles.Clear();
     WebCategoryList.Clear();
 }
Exemple #6
0
        }         // DoVisitImage

        // ----------------------------------------------------------------------
        protected override void DoVisitSpecial(IRtfVisualSpecialChar visualSpecialChar)
        {
            if (!EnterVisual(visualSpecialChar))
            {
                return;
            }

            switch (visualSpecialChar.CharKind)
            {
            case RtfVisualSpecialCharKind.ParagraphNumberBegin:
                isInParagraphNumber = true;
                break;

            case RtfVisualSpecialCharKind.ParagraphNumberEnd:
                isInParagraphNumber = false;
                break;

            default:
                if (SpecialCharacters.ContainsKey(visualSpecialChar.CharKind))
                {
                    Writer.Write(SpecialCharacters[visualSpecialChar.CharKind]);
                }
                break;
            }

            LeaveVisual(visualSpecialChar);
        }         // DoVisitSpecial
        private void LogInterestingPropertyValues(COWContactLogging.ContactChangeLogEvent loggingEvent, COWTriggerAction operation, CoreItem item, IEnumerable <StorePropertyDefinition> allUniqueInterestingProperties)
        {
            StringBuilder stringBuilder = new StringBuilder(200);

            foreach (StorePropertyDefinition storePropertyDefinition in allUniqueInterestingProperties)
            {
                stringBuilder.Clear();
                object obj = this.GetPropertyValueForLogging(item, storePropertyDefinition);
                obj = this.SanitizePropertyValueForLogging(obj);
                stringBuilder.Append("[New=");
                stringBuilder.Append(obj);
                bool flag = item.PropertyBag.IsPropertyDirty(storePropertyDefinition);
                if (flag && operation != COWTriggerAction.Create)
                {
                    object obj2 = this.GetOriginalPropertyValueForLogging(item, storePropertyDefinition);
                    obj2 = this.SanitizePropertyValueForLogging(obj2);
                    if (obj2 != obj)
                    {
                        stringBuilder.Append(",Old=");
                        stringBuilder.Append(obj2);
                    }
                }
                stringBuilder.Append("]");
                string key = SpecialCharacters.SanitizeForLogging(storePropertyDefinition.Name);
                loggingEvent.Add(key, stringBuilder.ToString());
            }
        }
Exemple #8
0
 public static char AsQuote(char c)
 {
     if (SpecialCharacters.IsSingleQuote(c))
     {
         return('\'');
     }
     return(SpecialCharacters.IsDoubleQuote(c) ? '"' : c);
 }
Exemple #9
0
 public static bool IsDelimiter(char c, char delimiter)
 {
     if (delimiter == '"')
     {
         return(SpecialCharacters.IsDoubleQuote(c));
     }
     return(delimiter == '\'' ? SpecialCharacters.IsSingleQuote(c) : (int)c == (int)delimiter);
 }
Exemple #10
0
 /// <summary>
 /// Initialises a new instance of the <see cref="CommandLineOptionValidator"/> class.
 /// </summary>
 public CommandLineOptionValidator(ICommandLineOptionContainer container, SpecialCharacters specialCharacters)
 {
     _rules = new List <ICommandLineOptionValidator>
     {
         new OptionNameValidator(specialCharacters),
         new NoDuplicateOptionValidator(container)
     };
 }
Exemple #11
0
            private int GetMatchLength(Match match)
            {
                if (SpecialCharacters.Contains(match.Value[match.Value.Length - 1]))
                {
                    return(match.Length - 1);
                }

                return(match.Length);
            }
Exemple #12
0
 public Parser()
 {
     CompilerDefValues.LoadAllValues();
     VeriableList           = new List <string>();
     KeyWordList            = new Dictionary <int, string>();
     SpecSymbolList         = new Dictionary <int, string>();
     FunctionList           = new List <string>();
     _acceptableKeyWordList = CompilerDefValues.AcceptableKeyWordList;
     _acceptableSpecSymbols = CompilerDefValues.AcceptableSpecSymbols;
 }
 public void specialCharacter(SpecialCharacters c)
 {
     switch(c)
     {
         case SpecialCharacters.Backspace:
             if (editingString.Length == 0)
                 break;
             editingString.Remove(editingString.Length - 1, 1);
             break;
     }
 }
Exemple #14
0
        /// <summary>
        /// Validates special characters in string
        /// </summary>
        /// <param name="string">Value to be validated</param>
        /// <param name="error">Error message if fails, contains string format which interpolates character which failed at {0} format.</param>
        private static void ValidateSpecialCharacters(string @string, string error)
        {
            const string SpecialCharacters = "~`!@#$%^&*()_+={}[]:;'<>,.?/|";

            foreach (var @char in @string)
            {
                if (SpecialCharacters.Contains(@char))
                {
                    throw new Exception(string.Format(error, @char));
                }
            }
        }
Exemple #15
0
        public static void LoadAllValues()
        {
            var xmldoc = new XmlDocument();

            xmldoc.Load("keyWordList.xml");
            AcceptableKeyWordList = KeyWords.Deserialize(xmldoc.InnerXml);

            var xmldoc2 = new XmlDocument();

            xmldoc2.Load("SpecialCharacters.xml");
            AcceptableSpecSymbols = SpecialCharacters.Deserialize(xmldoc2.InnerXml);
        }
        private string GetExceptionInfo(Exception ex)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(ex.GetType().Name + " ExceptionMessage " + SpecialCharacters.SanitizeForLogging(ex.Message));
            string stackTrace = ex.StackTrace;

            if (!string.IsNullOrEmpty(stackTrace))
            {
                stringBuilder.Append(" StackTrace - ");
                stringBuilder.Append(SpecialCharacters.SanitizeForLogging(stackTrace));
            }
            return(stringBuilder.ToString());
        }
        internal static string SerializeSingleValueType(SerializationInfo serializationInfo, EFormatOption valueFormatOption)
        {
            if (serializationInfo.dataInstance == null)
            {
                return(SpecialCharacters.FormatStringValue(null, valueFormatOption));
            }
            if (!serializationInfo.eDataType.IsSingleValueType())
            {
                throw new ArgumentOutOfRangeException("eDataType: " + serializationInfo.eDataType + " is not a single-value Type!");
            }
            string result = TypeDescriptor.GetConverter(serializationInfo.dataType).ConvertToInvariantString(serializationInfo.dataInstance);

            return(SpecialCharacters.FormatStringValue(result, valueFormatOption));
        }
Exemple #18
0
 protected void AppendValidChars(StringBuilder dest, string src)
 {
     foreach (char c in src)
     {
         if (SpecialCharacters.IsValidKeyChar(c))
         {
             dest.Append(c);
         }
         else
         {
             dest.Append('-');
         }
     }
 }
 public static string AsString(this SpecialCharacters specialCharacters)
 {
     return(specialCharacters switch
     {
         SpecialCharacters.DialogueEnd => kDialogueEnd,
         SpecialCharacters.ChangeColour => kChangeColourP,
         SpecialCharacters.ChangeColourExtended => kChangeColourS,
         SpecialCharacters.ClearWindow => kClearWindow,
         SpecialCharacters.NewLine => kNewLine,
         SpecialCharacters.Pause => kPause,
         SpecialCharacters.KanjiStart => kKanjiStart,
         SpecialCharacters.FuriganaStart => kFuriganaStart,
         SpecialCharacters.FuriganaEnd => kFuriganaEnd,
         SpecialCharacters.Player13 => kBattlePlayer,
         SpecialCharacters.PlayerInField => kFieldPlayer,
         SpecialCharacters.Speaker => kSpeaker,
         SpecialCharacters.SetSpeaker => kSetSpeaker,
         SpecialCharacters.FoeTrainerClass => kFoeTrainerClass,
         SpecialCharacters.FoeTrainerName => kFoeTrainerName,
         SpecialCharacters.WaitKeyPress => kWaitKeyPress,
         SpecialCharacters.PokemonSpeciesCry => kSpeciesCry,
         SpecialCharacters.SpecialMSG => kspecialMSG,
         SpecialCharacters.VarPokemon4E => kvarPokemon4E,
         SpecialCharacters.VarItem2D => kvarItem2D,
         SpecialCharacters.VarItem2E => kvarItem2E,
         SpecialCharacters.VarQuantity => kvarQuantity,
         SpecialCharacters.VarMove28 => kvarMove28,
         SpecialCharacters.VarItem29 => kvarItem29,
         SpecialCharacters.VarPokemon20 => kvarPokemon20,
         SpecialCharacters.VarPokemon21 => kvarPokemon21,
         SpecialCharacters.VarPokemon0F => kvarPokemon0F,
         SpecialCharacters.VarPokemon10 => kvarPokemon10,
         SpecialCharacters.VarPokemon11 => kvarPokemon11,
         SpecialCharacters.VarPokemon12 => kvarPokemon12,
         SpecialCharacters.SentOutPokemon1 => ksentOutPokemon1,
         SpecialCharacters.SentOutPokemon2 => ksentOutPokemon2,
         SpecialCharacters.VarPokemon16 => kvarPokemon16,
         SpecialCharacters.VarPokemon17 => kvarPokemon17,
         SpecialCharacters.VarPokemon18 => kvarPokemon18,
         SpecialCharacters.VarPokemon19 => kvarPokemon19,
         SpecialCharacters.VarAbility1A => kvarAbility1A,
         SpecialCharacters.VarAbility1B => kvarAbility1B,
         SpecialCharacters.VarAbility1C => kvarAbility1C,
         SpecialCharacters.VarAbility1D => kvarAbility1D,
         SpecialCharacters.VarPokemon1E => kvarPokemon1E,
         SpecialCharacters.ChangeFont => kBold,
         _ => string.Format("{0:X}", (byte)specialCharacters)
     });
Exemple #20
0
        public async Task <JsonResult> CreateAcronymAsync(string acronym, char specialCharacter)
        {
            try
            {
                var spc = new SpecialCharacters {
                    Acronym = acronym, SpecialCharacter = (int)specialCharacter
                };
                _db.SpecialCharacters.Add(spc);
                await _db.SaveChangesAsync();

                return(Json(new { success = true, spc = new { acronym = spc.Acronym, specialCharacter = char.ConvertFromUtf32(specialCharacter) } }));
            }
            catch (Exception ex) {
                return(Json(new { success = false, exception = ex }));
            }
        }
 private static void AddKeyValuePair(Dictionary <string, string> keyValuePairs, string key, string value)
 {
     if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
     {
         if (!SpecialCharacters.IsValidKey(key))
         {
             return;
         }
         if (keyValuePairs.ContainsKey(key))
         {
             keyValuePairs["DupKey"] = key;
             return;
         }
         keyValuePairs[key] = Plt1WebHandler.EncodeValidValueString(value);
     }
 }
Exemple #22
0
        public override void Draw(GameTime gameTime, GraphicsDevice device, SpriteBatch spriteBatch, SpriteFont font)
        {
            if (Selected)
            {
                spriteBatch.DrawString(font, SpecialCharacters.RightArrow, new Vector2(X, Y + Height - SpriteManager.CharHeight - 20), SpriteManager.ForegroundColor);
            }

            decimal hpPercent = ((decimal)monster.CurrentHP) / monster.Stats.HP;

            bool onFrame2 = false;

            if (hpPercent > 0.5m)
            {
                onFrame2 = frameCounter % 10 > 5;
            }
            else if (hpPercent > 0.2m)
            {
                onFrame2 = frameCounter % 30 > 15;
            }
            else
            {
                onFrame2 = frameCounter % 60 > 30;
            }

            Rectangle iconSource;

            if (Selected && onFrame2)
            {
                iconSource = new Rectangle(SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight * (int)monster.Species.BodyType, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight);
            }
            else
            {
                iconSource = new Rectangle(0, SpriteManager.PartyIconHeight * (int)monster.Species.BodyType, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight);
            }

            spriteBatch.Draw(SpriteManager.PartyIcons, new Rectangle(X + SpriteManager.CharWidth, Y, SpriteManager.PartyIconWidth, SpriteManager.PartyIconHeight), iconSource, Color.White);

            spriteBatch.DrawString(font, SpecialCharacters.ReplaceChars(monster.Name).PadRight(10, ' ') + string.Format("{0}{1}", SpecialCharacters.ColonL, monster.Level).PadRight(4, ' ') + monster.StatusText, new Vector2(X + 100, Y), SpriteManager.ForegroundColor);
            spriteBatch.DrawString(font, string.Format("{0,3}/{1,3}", monster.CurrentHP, monster.Stats.HP).PadLeft(17, ' '), new Vector2(X + 100, Y + SpriteManager.CharHeight), SpriteManager.ForegroundColor);

            spriteBatch.Draw(SpriteManager.HPBar, new Rectangle(X + 136, Y + SpriteManager.CharHeight + 8, SpriteManager.HPBar.Width, SpriteManager.HPBar.Height), SpriteManager.ForegroundColor);

            Color color = hpPercent > 0.5m ? SpriteManager.HPBarHighColor : hpPercent > 0.2m ? SpriteManager.HPBarMediumColor : SpriteManager.HPBarLowColor;

            spriteBatch.Draw(SpriteManager.White, new Rectangle(X + 196, Y + SpriteManager.CharHeight + 12, (int)(192 * hpPercent), 8), color);
        }
Exemple #23
0
        public void CreateFinalProduct()
        {
            CryptoController crypto = new CryptoController();

            try
            {
                if (SpecialCharacterSet == "specific")
                {
                    string sCharPool = SpecialCharacters.Replace(" ", String.Empty);

                    if (GenerationType == "random")
                    {
                        FinalProduct = crypto.generateRandom(AnsweredQuestion1, AnsweredQuestion2, sCharPool, SelectedLength);
                    }
                    else if (GenerationType == "familiar")
                    {
                        string mixedBag = crypto.familiarCharMix(SpecialCharacterSet, sCharPool);

                        FinalProduct = crypto.generateFamiliar(AnsweredQuestion1, AnsweredQuestion2, mixedBag, SelectedLength);
                    }
                }
                else if (SpecialCharacterSet == "default")
                {
                    string answer1   = AnsweredQuestion1;
                    string answer2   = AnsweredQuestion2;
                    string sCharPool = "!@#$%^&*()_+-=,./";
                    int    length    = SelectedLength;

                    if (GenerationType == "random")
                    {
                        FinalProduct = crypto.generateRandom(AnsweredQuestion1, AnsweredQuestion2, sCharPool, SelectedLength);
                    }
                    else if (GenerationType == "familiar")
                    {
                        string mixedBag = crypto.familiarCharMix(SpecialCharacterSet, sCharPool);

                        FinalProduct = crypto.generateFamiliar(AnsweredQuestion1, AnsweredQuestion2, mixedBag, SelectedLength);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
            private static string SanitizeKey(string key)
            {
                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.EnsureCapacity(key.Length);
                foreach (char c in key)
                {
                    if (SpecialCharacters.IsValidKeyChar(c))
                    {
                        stringBuilder.Append(c);
                    }
                    else
                    {
                        stringBuilder.Append('.');
                    }
                }
                return(stringBuilder.ToString());
            }
        // Token: 0x06000871 RID: 2161 RVA: 0x0003AFDC File Offset: 0x000391DC
        private void AddExtendedProperty(string extendedTypeLabel, string folderType, string folderId, bool isSuccess)
        {
            string key;

            if (folderId != null)
            {
                key = string.Format("{0}.{1}[{2}]", extendedTypeLabel, folderType, SpecialCharacters.SanitizeForLogging(folderId));
            }
            else
            {
                key       = string.Format("{0}.{1}[{2}]", extendedTypeLabel, "UnknownFolderId", SpecialCharacters.SanitizeForLogging(Guid.NewGuid().ToString()));
                isSuccess = false;
            }
            if (!this.extendedPropertiesMap.ContainsKey(key))
            {
                this.extendedPropertiesMap.Add(key, isSuccess.ToString());
            }
        }
Exemple #26
0
        /// <summary>
        /// Escapes content so that it is safe for inclusion in a string that will later be used as a
        /// format string. If this is to be embedded inside of a single-quoted string, be sure to also
        /// call EscapeSingleQuotedStringContent.
        /// For example: "'" + EscapeSingleQuotedStringContent(EscapeFormatStringContent(userContent)) + "'" -f $args
        /// </summary>
        /// <param name="value">The content to be included in a format string.</param>
        /// <returns>Content with all curly braces escaped.</returns>
        public static string EscapeFormatStringContent(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }
            StringBuilder sb = new StringBuilder(value.Length);

            foreach (char c in value)
            {
                sb.Append(c);
                if (SpecialCharacters.IsCurlyBracket(c))
                {
                    // double-up curly brackets to escape them
                    sb.Append(c);
                }
            }
            return(sb.ToString());
        }
Exemple #27
0
        /// <summary>
        /// Escapes content so that it is safe for inclusion in a single-quoted string.
        /// For example: "'" + EscapeSingleQuotedStringContent(userContent) + "'"
        /// </summary>
        /// <param name="value">The content to be included in a single-quoted string.</param>
        /// <returns>Content with all single-quotes escaped.</returns>
        public static string EscapeSingleQuotedStringContent(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }
            StringBuilder sb = new StringBuilder(value.Length);

            foreach (char c in value)
            {
                sb.Append(c);
                if (SpecialCharacters.IsSingleQuote(c))
                {
                    // double-up quotes to escape them
                    sb.Append(c);
                }
            }
            return(sb.ToString());
        }
        public SpecialUnicodeCharacters(SpecialCharacters specialChars, params byte[] unicodeBytes)
        {
            var bs = new List <byte>
            {
                0xFF,
                0xFF,
                (byte)specialChars
            };

            ExtraBytes = unicodeBytes.Length;

            foreach (var uByte in unicodeBytes)
            {
                bs.Add(uByte);
            }

            ByteStream = bs.ToArray();
            Unicode    = 0xFF;
            chars      = specialChars;
        }
        /// <summary>
        /// Builds a new <see cref="ContainsExpression"/> that holds the specified <paramref name="value"/>.
        /// </summary>
        /// <param name="value"></param>
        /// <exception cref="ArgumentNullException">if <paramref name="value"/> is <c>null</c></exception>
        /// <exception cref="ArgumentOutOfRangeException">if <paramref name="value"/> is <c>empty</c></exception>
        public ContainsExpression(string value)
        {
            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (value.Length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(value)} cannot be empty");
            }

            Value = value;

            _lazyEscapedParseableString = new(() =>
            {
                // The length of the final parseable string in worst cases scenario will double (1 backlash + the escaped character)
                // Also we need an extra position for the final '*' that will be append in all cases
                bool requireEscapingCharacters = Value.AtLeastOnce(chr => SpecialCharacters.Contains(chr));
                StringBuilder parseableString;

                if (requireEscapingCharacters)
                {
                    parseableString = new((Value.Length * 2) + 2);
                    foreach (char chr in Value)
                    {
                        if (SpecialCharacters.Contains(chr))
                        {
                            parseableString = parseableString.Append('\\');
                        }
                        parseableString = parseableString.Append(chr);
                    }
                }
                else
                {
                    parseableString = new(Value, Value.Length + 2);
                }

                return(parseableString.Insert(0, "*").Append('*').ToString());
            });
        }
        // Token: 0x0600009D RID: 157 RVA: 0x00004CB4 File Offset: 0x00002EB4
        protected string FormatExceptionListToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (AssistantLogEntryBase.ExceptionInfo exceptionInfo in this.exceptions)
            {
                stringBuilder.Append(string.Format("{0}_{1}_{2}_{3}_{4}_{5}|", new object[]
                {
                    exceptionInfo.Name,
                    exceptionInfo.InnerException,
                    exceptionInfo.Count,
                    SpecialCharacters.SanitizeForLogging(exceptionInfo.Message),
                    SpecialCharacters.SanitizeForLogging(exceptionInfo.StackTrace),
                    exceptionInfo.DiagnosticContext
                }));
            }
            return(stringBuilder.ToString().TrimEnd(new char[]
            {
                '|'
            }));
        }
    static void Main(string[] args)
    {
        SpecialCharacters specialCharacters = new SpecialCharacters {
            Umlaute = "äüö"
        };

        // serialize object to xml

        MemoryStream  memoryStreamSerialize  = new MemoryStream();
        XmlSerializer xmlSerializerSerialize = new XmlSerializer(typeof(SpecialCharacters));
        XmlTextWriter xmlTextWriterSerialize = new XmlTextWriter(memoryStreamSerialize, Encoding.UTF8);

        xmlSerializerSerialize.Serialize(xmlTextWriterSerialize, specialCharacters);
        memoryStreamSerialize = (MemoryStream)xmlTextWriterSerialize.BaseStream;

        // converts a byte array of unicode values (UTF-8 enabled) to a string
        UTF8Encoding encodingSerialize = new UTF8Encoding();
        string       serializedXml     = encodingSerialize.GetString(memoryStreamSerialize.ToArray());

        xmlTextWriterSerialize.Close();
        memoryStreamSerialize.Close();
        memoryStreamSerialize.Dispose();

        // deserialize xml to object

        // converts a string to a UTF-8 byte array.
        UTF8Encoding encodingDeserialize = new UTF8Encoding();

        byte[] byteArray = encodingDeserialize.GetBytes(serializedXml);

        using (MemoryStream memoryStreamDeserialize = new MemoryStream(byteArray))
        {
            XmlSerializer xmlSerializerDeserialize = new XmlSerializer(typeof(SpecialCharacters));
            XmlTextWriter xmlTextWriterDeserialize = new XmlTextWriter(memoryStreamDeserialize, Encoding.UTF8);

            SpecialCharacters deserializedObject = (SpecialCharacters)xmlSerializerDeserialize.Deserialize(xmlTextWriterDeserialize.BaseStream);
        }
    }
Exemple #32
0
 static CronField()
 {
     SpecialCharacters = SpecialCharacters.All();
 }
Exemple #33
0
 static CronValueExpression()
 {
     SpecialCharacters = SpecialCharacters.ValueExpression();
 }