コード例 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (ddlParamType.Text.Length == 0 && canEditType)
            {
                MessageBox.Show(this, "No type selected for the parameter", "Missing type", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            Type parameterType = null;

            try
            {
                parameterType = Project.Instance.GetTypeFromReferencedAssemblies(ddlParamType.Text, false);
            }
            catch
            {
                // Do nothing, because we check for null below
            }
            if (parameterType == null && canEditType)
            {
                MessageBox.Show(this, "The data-type cannot be found in the referenced assemblies. Try using a fully qualified type-name.", "Unknown Type", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (CurrentParameter == null)
            {
                CurrentParameter = new ParamInfo(txtParamName.Text, parameterType);
            }
            else
            {
                CurrentParameter.Name = txtParamName.Text;
                if(canEditType) CurrentParameter.DataType = parameterType;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #2
0
 public frmParameterEdit(ParamInfo parameter, bool canEditType)
 {
     InitializeComponent();
     Controller.ShadeMainForm();
     CurrentParameter = parameter;
     this.canEditType = canEditType;
     Populate();
 }
コード例 #3
0
ファイル: FunctionInfo.cs プロジェクト: uQr/Visual-NHibernate
        public void AddParameter(ParamInfo parm)
        {
            bool found = false;

            for (int i = 0; i < Parameters.Count; i++)
            {
                if (Parameters[i].Name == parm.Name)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                Parameters.Add(parm);
            }
        }
コード例 #4
0
ファイル: ucFunctions.cs プロジェクト: uQr/Visual-NHibernate
        public ucFunction GetFunctionScreen(string functionName, ParamInfo[] parameters)
        {
            foreach (TabItem tab in tabStrip1.Tabs)
            {
                ucFunction functionScreen = (ucFunction)tab.AttachedControl.Controls["ucFunction"];
                FunctionInfo func = functionScreen.CurrentFunction;

                if (func.Name == functionName && func.Parameters.Count == parameters.Length)
                {
                    bool found = true;

                    for (int i = 0; i < func.Parameters.Count; i++)
                    {
                        if (func.Parameters[i].DataType.FullName != parameters[i].DataType.FullName)
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        return functionScreen;
                    }
                }
            }
            return null;
        }
コード例 #5
0
        private static string FormatParameter(ParamInfo paramInfo)
        {
            string param = "";

            string modifierText = "";
            if (paramInfo.Modifiers.Length > 0)
            {
                modifierText = paramInfo.Modifiers + " ";
            }

            param += string.Format("{2}{0} {1}", Utility.GetDemangledGenericTypeName(paramInfo.DataType), paramInfo.Name, modifierText);

            return param;
        }
コード例 #6
0
        protected virtual void ProcessFunctionParameters(FunctionInfo info, XmlNode functionNode)
        {
            var parametersNode = functionNode["Parameters"];
            if (parametersNode == null) throw new DeserialisationException("Could not find Parameters node");

            var parameterNodes = parametersNode.SelectNodes("Parameter");
            if (parameterNodes == null) return;

            foreach (XmlNode paramNode in parameterNodes)
            {
                var name = paramNode.Attributes["name"].Value;
                var typeName = paramNode.Attributes["type"].Value;
                var modifiers = paramNode.Attributes["modifiers"].Value;
                var paramType = GetTypeNamed(typeName);

                ParamInfo pi = new ParamInfo(name, paramType) { Modifiers = modifiers };
                info.AddParameter(pi);
            }
        }
コード例 #7
0
        private static void ReadXmlFunctionNode(Project project, ICollection<string> missingTypesMessages, XPathNavigator funcNode)
        {
            string funcName = funcNode.SelectSingleNode("@name").Value;
            SyntaxEditorHelper.ScriptLanguageTypes scriptLanguage = funcNode.SelectSingleNode("@scriptlanguage") == null ? SyntaxEditorHelper.ScriptLanguageTypes.CSharp : (SyntaxEditorHelper.ScriptLanguageTypes)Enum.Parse(typeof(SyntaxEditorHelper.ScriptLanguageTypes), funcNode.SelectSingleNode("@scriptlanguage").Value, true);
            string description = funcNode.SelectSingleNode("@description") == null ? "" : funcNode.SelectSingleNode("@description").Value;
            string category = funcNode.SelectSingleNode("@category") == null ? "" : funcNode.SelectSingleNode("@category").Value;
            bool isTemplateFunction = false;

            if (funcNode.SelectSingleNode("@istemplatefunction") != null)
            {
                isTemplateFunction = Boolean.Parse(funcNode.SelectSingleNode("@istemplatefunction").Value);
            }
            string templateReturnLanguage = isTemplateFunction ? funcNode.SelectSingleNode("@returntype").Value : "";

            XPathNavigator tempnode = funcNode.SelectSingleNode("@isextensionmethod");
            bool isExtensionMethod = tempnode == null ? false : Boolean.Parse(tempnode.Value);
            string extendedtype = isExtensionMethod ? funcNode.SelectSingleNode("@extendedtype").Value : "";

            Type dataType;

            if (isTemplateFunction)
            {
                dataType = typeof(string);
            }
            else
            {
                if (funcNode.SelectSingleNode("@returntype").Value != "void")
                {
                    dataType = Project.Instance.GetTypeFromReferencedAssemblies(funcNode.SelectSingleNode("@returntype").Value, false);

                    if (dataType == null)
                    {
                        missingTypesMessages.Add(String.Format("Function ({0}): The return-type ({1}) cannot be found in the referenced files. The return-type will be changed to 'void'.", funcName, funcNode.SelectSingleNode("@returntype").Value));
                    }
                }
                else
                {
                    dataType = null;
                }
            }
            project.Functions.Add(new FunctionInfo(funcName, dataType, funcNode.Value, isTemplateFunction, scriptLanguage, description, templateReturnLanguage, category, isExtensionMethod, extendedtype));
            XPathNodeIterator paramNodes = funcNode.Select("parameter");
            project.Functions[project.Functions.Count - 1].Parameters.Clear();

            if (paramNodes.Count > 0)
            {
                foreach (XPathNavigator paramNode in paramNodes)
                {
                    Type paramType = Project.Instance.GetTypeFromReferencedAssemblies(paramNode.SelectSingleNode("@type").Value, false);

                    if (paramType == null)
                    {
                        missingTypesMessages.Add(String.Format("Function ({0}): The parameter named '{1}' of type ({2}) cannot be found in the referenced files. It will be changed to type 'object'.", funcName, paramNode.SelectSingleNode("@name").Value, paramNode.SelectSingleNode("@type").Value));
                        paramType = typeof(object);
                    }
                    ParamInfo param = new ParamInfo(paramNode.SelectSingleNode("@name").Value, paramType);
                    param.Modifiers = paramNode.SelectSingleNode("@modifiers") != null ? paramNode.SelectSingleNode("@modifiers").Value : "";
                    project.Functions[project.Functions.Count - 1].Parameters.Add(param);
                }
            }
        }
コード例 #8
0
ファイル: Project.cs プロジェクト: uQr/Visual-NHibernate
        public void Clear()
        {
            if (Directory.Exists(Controller.TempPath))
            {
                try
                {
                    Directory.Delete(Controller.TempPath, true);
                }
                catch
                {
                    // Do nothing - usually some dev process is accessing the directory
                }
            }
            SharedData.ClearAssemblySearchPaths();
            DefaultValueFunctions.Clear();
            Settings.Default.CodeFile = "";
            CompileFolderName = "";
            Functions.Clear();
            ClearIncludedFiles();
            IsDirty = false;
            Namespaces.Clear();
            Parameters = new ParamInfo[0];
            ProjectFileName = "";
            ProjectXmlConfig = "";
            m_references.Clear();
            ScriptFunctionsFile = "";
            TargetFile = "";
            TemplateFile = "";
            TemplateNamespace = "";
            OutputNames.Clear();
            RootOutput = new OutputFolder("ROOT");
            Constants = new Constant[0];
            m_userOptions.Clear();
            DebugProjectFile = "";
            Actions = new BaseAction[0];
            m_referencedAssemblies.Clear();
            ApiExtensionMethods.Clear();

            TriggerProjectChangedEvent(true);
        }