Пример #1
0
    // Converts raw string data into a QRCode
    public static QRCode QRParse(string rawData)
    {
        QRTypes type   = QRTypes.Tokens;
        int     tokens = 0;


        bool   tagged     = false;
        string stringTag  = "";
        string tempString = "";

        for (int i = 0; i < rawData.Length; i++)
        {
            if (!tagged)
            {
                stringTag += rawData[i];
                if (rawData[i] == '>')
                {
                    tagged = true;
                }
            }
            else
            {
                if (rawData[i] != '<')
                {
                    tempString += rawData[i];
                }
                if (rawData[i] == '<' || i + 1 == rawData.Length)
                {
                    switch (stringTag)
                    {
                    case "<TYPE>":
                        type = (QRTypes)Enum.Parse(typeof(QRTypes), tempString);
                        break;

                    case "<TOKENS>":
                        tokens = int.Parse(tempString);
                        break;

                    default:
                        break;
                    }
                    stringTag  = "<";
                    tempString = "";
                    tagged     = false;
                }
            }
        }
        QRCode returnCode = new QRCode(type, tokens);

        returnCode.RawData = rawData;
        return(returnCode);
    }
Пример #2
0
 // Constructor
 public QRCode(QRTypes type, int tokens)
 {
     QRType     = type;
     TokenValue = tokens;
 }