Exemple #1
0
        private static bool DeserializeReportType(string serialized, ref int cc, out SharedVariableReportType rType, out Exception ex)
        {
            int bcc;

            ex    = null;
            rType = SharedVariableReportType.Unknown;
            if (!Scanner.ReadString(", rType=", serialized, ref cc))
            {
                ex = new Exception("Invalid subscriptions segment (subscription report type), expected ','");
                return(false);
            }
            bcc = cc;
            if (!Scanner.AdvanceToChar(new char[] { ',', '}' }, serialized, ref cc))
            {
                ex = new Exception("Invalid subscriptions segment (subscription report type), expected '}'");
                return(false);
            }

            try
            {
                rType = (SharedVariableReportType)Enum.Parse(typeof(SharedVariableReportType), serialized.Substring(bcc, cc - bcc));
            }
            catch
            {
                ex = new Exception("Invalid value for subscription report type");
                return(false);
            }
            return(true);
        }
Exemple #2
0
        private static bool DeserializeSubscriptionWriter(string serialized, ref int cc, out string subscriber, out Exception ex)
        {
            int bcc;

            ex         = null;
            subscriber = null;
            if (!Scanner.ReadString("writer=", serialized, ref cc))
            {
                ex = new Exception("Invalid subscriptions segment, expected 'writer='");
                return(false);
            }
            bcc = cc;
            if (!Scanner.AdvanceToChar('}', serialized, ref cc))
            {
                ex = new Exception("Invalid subscriptions segment, expected ','");
                return(false);
            }
            subscriber = serialized.Substring(bcc, cc - bcc);
            return(true);
        }