コード例 #1
0
ファイル: ProcedureRegistry.cs プロジェクト: Neo4Net/Neo4Net
        /// <summary>
        /// Register a new procedure.
        /// </summary>
        /// <param name="proc"> the procedure. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void register(org.neo4j.kernel.api.proc.CallableProcedure proc, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableProcedure proc, bool overrideCurrentImplementation)
        {
            ProcedureSignature signature = proc.Signature();
            QualifiedName      name      = signature.Name();

            string descriptiveName = signature.ToString();

            ValidateSignature(descriptiveName, signature.InputSignature(), "input");
            ValidateSignature(descriptiveName, signature.OutputSignature(), "output");

            if (!signature.Void && signature.OutputSignature().Count == 0)
            {
                throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureRegistrationFailed, "Procedures with zero output fields must be declared as VOID");
            }

            CallableProcedure oldImplementation = _procedures.get(name);

            if (oldImplementation == null)
            {
                _procedures.put(name, proc, signature.CaseInsensitive());
            }
            else
            {
                if (overrideCurrentImplementation)
                {
                    _procedures.put(name, proc, signature.CaseInsensitive());
                }
                else
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureRegistrationFailed, "Unable to register procedure, because the name `%s` is already in use.", name);
                }
            }
        }
コード例 #2
0
ファイル: ProcedureRegistry.cs プロジェクト: Neo4Net/Neo4Net
        /// <summary>
        /// Register a new function.
        /// </summary>
        /// <param name="function"> the function. </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void register(org.neo4j.kernel.api.proc.CallableUserFunction function, boolean overrideCurrentImplementation) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        public virtual void Register(CallableUserFunction function, bool overrideCurrentImplementation)
        {
            UserFunctionSignature signature = function.Signature();
            QualifiedName         name      = signature.Name();

            CallableUserFunction oldImplementation = _functions.get(name);

            if (oldImplementation == null)
            {
                _functions.put(name, function, signature.CaseInsensitive());
            }
            else
            {
                if (overrideCurrentImplementation)
                {
                    _functions.put(name, function, signature.CaseInsensitive());
                }
                else
                {
                    throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Procedure.ProcedureRegistrationFailed, "Unable to register function, because the name `%s` is already in use.", name);
                }
            }
        }