コード例 #1
0
        public Method CreateSetResultSetMethod(StoredProcedureResultSetColumn resultSet, MethodPolymophism polymophism)
        {
            var    sp = this.StoredProcedure;
            Method md = new Method(MethodAccessModifier.Protected, "SetResultSet");

            md.Modifier.Polymophism = polymophism;

            md.AddParameter(String.Format("{0}.{1}", sp.Name, resultSet.Name), "resultSet");
            md.AddParameter("IDataReader", "reader");

            md.Body.AddRange(CreateSetResultSetMethodBody(resultSet));
            return(md);
        }
コード例 #2
0
        public void MethodGenericParameters()
        {
            var md = new Method(MethodAccessModifier.Public, "GetDisplayName");

            md.AddParameter("String", "name");
            md.AddParameter("Int32", "age");
            md.GenericParameters.Add("T1");
            md.GenericParameters.Add("T2");
            md.Body.Add(SourceCodeLanguage.CSharp, "return name + \":\" + age.ToString();");

            Assert.AreEqual("public void GetDisplayName<T1, T2>(String name, Int32 age)" + SourceCodeGenerator.NewLine
                            + "{" + SourceCodeGenerator.NewLine
                            + SourceCodeGenerator.Default.Indent + "return name + \":\" + age.ToString();" + SourceCodeGenerator.NewLine
                            + "}" + SourceCodeGenerator.NewLine
                            , SourceCodeGenerator.Write(SourceCodeLanguage.CSharp, md));
        }
コード例 #3
0
        public override void EnterMethodDeclaration([NotNull] JavaParser.MethodDeclarationContext context)
        {
            Logger.Debug("parsing method");

            var inputStream = context.Start.InputStream;

            var interval = new Interval(context.Start.StartIndex, context.Stop.StopIndex);

            var parameters = context.formalParameters()?.formalParameterList()?.formalParameter();

            Method methodModel = new Method(_currentClass, context.Identifier()?.GetText(), inputStream.GetText(interval));

            if (parameters != null)
            {
                foreach (var param in parameters)
                {
                    methodModel.AddParameter(param.GetText());
                }
            }

            if (_currentClass != null)
            {
                _currentClass.AddMethod(methodModel);
            }

            _statementListener.setCurrentMethod(methodModel);

            InvokeParseInfoUpdate("Parsing method: " + methodModel.Name);
        }
コード例 #4
0
ファイル: MethodGenerator.cs プロジェクト: J4S0Nc/docu
        public void Add(List <Namespace> namespaces, DocumentedMethod association)
        {
            if (association.Method == null)
            {
                return;
            }

            DeclaredType type = FindType(association, namespaces);

            DeclaredType methodReturnType = null;

            if (association.Method.MemberType == MemberTypes.Method)
            {
                methodReturnType = DeclaredType.Unresolved(
                    IdentifierFor.Type(((MethodInfo)association.Method).ReturnType),
                    ((MethodInfo)association.Method).ReturnType,
                    Namespace.Unresolved(IdentifierFor.Namespace(((MethodInfo)association.Method).ReturnType.Namespace)));
            }

            Method doc = Method.Unresolved(
                IdentifierFor.Method(association.Method, association.TargetType),
                type,
                association.Method,
                methodReturnType);

            ParseSummary(association, doc);
            ParseRemarks(association, doc);
            ParseValue(association, doc);
            ParseReturns(association, doc);
            ParseExample(association, doc);

            foreach (ParameterInfo parameter in association.Method.GetParameters())
            {
                DeclaredType reference = DeclaredType.Unresolved(
                    IdentifierFor.Type(parameter.ParameterType),
                    parameter.ParameterType,
                    Namespace.Unresolved(IdentifierFor.Namespace(parameter.ParameterType.Namespace)));
                var docParam = new MethodParameter(parameter.Name, parameter.IsOptional, parameter.DefaultValue, reference);


                ParseParamSummary(association, docParam);

                doc.AddParameter(docParam);
            }

            if (_matchedAssociations.ContainsKey(association.Name))
            {
                return; // weird case when a type has the same method declared twice
            }

            _matchedAssociations.Add(association.Name, doc);

            if (type == null)
            {
                return;
            }

            type.AddMethod(doc);
        }
コード例 #5
0
 public FAMIX.Parameter EnsureParameterInMethod(IParameterSymbol parameterSymbol, Method CurrentMethod)
 {
     if (CurrentMethod.Parameters.Any(p => p.name == parameterSymbol.Name))
     {
         return(CurrentMethod.Parameters.Find(p => p.name == parameterSymbol.Name));
     }
     FAMIX.Parameter parameter = this.CreateParameter(parameterSymbol);
     CurrentMethod.AddParameter(parameter);
     return(parameter);
 }
コード例 #6
0
        private void HandleParameter(EA.Parameter param, Method method)
        {
            Parameter p = new Parameter();

            p.SetName(param.Name);
            Int32 id = Int32.Parse(param.ClassifierID);

            EA.Element datatype = m_InterfaceOfInterest.GetElementByID(id);
            p.SetDatatype(FetchNamespace(datatype));
            p.SetIsConst(param.IsConst);
            p.SetPositionInArgList(param.Position);

            method.AddParameter(p);
        }
コード例 #7
0
        public Method CreateSetOutputParameterValueMethod()
        {
            var    sp = this.StoredProcedure;
            Method md = new Method(MethodAccessModifier.Protected, "SetOutputParameterValue");

            md.Modifier.Polymophism = MethodPolymophism.Override;
            md.ReturnTypeName       = new TypeName("void");

            md.AddParameter("DbCommand", "command");

            md.Body.AddRange(CreateSetOutputParameterValueMethodBody());

            return(md);
        }
コード例 #8
0
 private void Add_Clicked(object sender, RoutedEventArgs e)
 {
     try {
         //建立視窗
         var paraWind = new ParameterWindow();
         //如果使用者有點下儲存,進行判斷
         if (paraWind.ShowDialog() ?? false)
         {
             if (paraWind.Parameter.IsValid)
             {
                 //確認名稱和註解有打
                 Method.AddParameter(paraWind.Parameter);
             }
         }
     } catch (Exception ex) {
         MessageBox.Show(
             ex.ToString(),
             "Exception",
             MessageBoxButton.OK,
             MessageBoxImage.Error
             );
     }
 }