Beispiel #1
0
        internal Boolean TryGetByAlias(String alias, out ProcedureDefinition procedure)
        {
            Contract.Assert(!String.IsNullOrWhiteSpace(alias), "Using an empty alias for finding a procedure.");

            return(_proceduresByName.TryGetValue(alias, out procedure));
        }
        internal static IEnumerable <ProcedureDefinition> Parse(TextReader reader)
        {
            String line = String.Empty;
            ProcedureDefinition       current           = null;
            StringBuilder             current_body      = new StringBuilder(1024);
            Boolean                   parsingParameters = false;
            List <ProcedureParameter> parameters        = new List <ProcedureParameter>();

            while (line != null)
            {
                line = reader.ReadLine();
                if (line == null)
                {
                    continue;
                }

                var index = 0;
                if (IsProcStart(line, ref index))
                {
                    if (current != null)
                    {
                        throw new RedisClientProcedureParsingException("Procedure start found in the context of other procedure.");
                    }

                    current      = new ProcedureDefinition();
                    current.Name = GetName(line, ref index);
                    GetParameters(line, ref index, ref parsingParameters, parameters);
                }
                else if (parsingParameters)
                {
                    GetParameters(line, ref index, ref parsingParameters, parameters);
                }
                else if (IsProcEnd(line))
                {
                    if (current == null)
                    {
                        throw new RedisClientProcedureParsingException("Procedure end found without beginning.");
                    }

                    current.Parameters = parameters.ToArray();
                    AppendParameterInitialization(current_body, current.Parameters);
                    current.Body   = current_body.ToString();
                    current.Digest = Hash(current.Body);

                    yield return(current);

                    current = null;
                    current_body.Clear();
                    parameters.Clear();
                }
                else if (current != null)
                {
                    current_body.AppendLine(line);
                }
            }

            if (current != null)
            {
                throw new RedisClientProcedureParsingException("Procedure end missing.");
            }
        }
Beispiel #3
0
        internal bool TryGetByDigest(String digest, out ProcedureDefinition procedure)
        {
            Contract.Assert(!String.IsNullOrWhiteSpace(digest), "Using an empty digest for finding a procedure.");

            return(_proceduresByDigest.TryGetValue(digest, out procedure));
        }
 public ProcedureCommandBinder(ProcedureDefinition procedure)
     : base(_evalsha, false)
 {
     _procedure = procedure;
     base.Add(new RESPCommandLiteral(procedure.Digest));
 }