Пример #1
0
        /// <summary>
        /// Toes the string.
        /// </summary>
        /// <remarks>Format specified: P - plugin token A - absolutepath with session id F - file name</remarks>
        /// <param name="format">The format.</param>
        /// <returns></returns>
        public string ToString(string format)
        {
            StringBuilder retVal = new StringBuilder();

            foreach (char patternChar in format.ToCharArray())
            {
                switch (patternChar)
                {
                case 'P':
                    retVal.Append(PluginToken.ToString());
                    break;

                case 'A':
                    List <byte> token = new List <byte>();
                    token.AddRange(BitConverter.GetBytes(SessionIdDelimiter));
                    //If SessionId is empty then no save him
                    if (SessionId != Guid.Empty)
                    {
                        token.AddRange(SessionId.ToByteArray());
                    }
                    token.AddRange(BitConverter.GetBytes(SessionIdDelimiter));
                    //absolute path
                    token.AddRange(AbsolutePath.GetByteArray());
                    retVal.Append(CryptToken(token.ToArray()));
                    break;

                case 'F':
                    retVal.Append(FileNameReplaceInvalidChars(AbsolutePath.FileName));
                    break;

                default:
                    retVal.Append(patternChar);
                    break;
                }
            }

            return(retVal.ToString());
        }