示例#1
0
        /// <summary>
        /// This method finds a 'Method' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Method' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindMethod(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Method method = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Find StoredProcedure
                FindMethodStoredProcedure findMethodProc = null;

                // verify the first parameters is a 'Method'.
                if (parameters[0].ObjectValue as Method != null)
                {
                    // Get MethodParameter
                    Method paramMethod = (Method)parameters[0].ObjectValue;

                    // verify paramMethod exists
                    if (paramMethod != null)
                    {
                        // Now create findMethodProc from MethodWriter
                        // The DataWriter converts the 'Method'
                        // to the SqlParameter[] array needed to find a 'Method'.
                        findMethodProc = MethodWriter.CreateFindMethodStoredProcedure(paramMethod);
                    }

                    // Verify findMethodProc exists
                    if (findMethodProc != null)
                    {
                        // Execute Find Stored Procedure
                        method = this.DataManager.MethodManager.FindMethod(findMethodProc, dataConnector);

                        // if dataObject exists
                        if (method != null)
                        {
                            // set returnObject.ObjectValue
                            returnObject.ObjectValue = method;
                        }
                    }
                }
                else
                {
                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }

            // return value
            return(returnObject);
        }