当前位置: 首页>>代码示例>>C#>>正文


C# CodeDom.CodeParameterDeclarationExpression类代码示例

本文整理汇总了C#中System.CodeDom.CodeParameterDeclarationExpression的典型用法代码示例。如果您正苦于以下问题:C# CodeParameterDeclarationExpression类的具体用法?C# CodeParameterDeclarationExpression怎么用?C# CodeParameterDeclarationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CodeParameterDeclarationExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeParameterDeclarationExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindingElementExtensionSectionGenerator

        internal BindingElementExtensionSectionGenerator(Type bindingElementType, Assembly userAssembly, CodeDomProvider provider)
        {
            this.bindingElementType = bindingElementType;
            this.userAssembly = userAssembly;
            this.provider = provider;

            string typePrefix = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement));
            this.generatedClassName = typePrefix + Constants.ElementSuffix;
            this.constantsClassName = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement)) + Constants.ConfigurationStrings;
            this.defaultValuesClassName = bindingElementType.Name.Substring(0, bindingElementType.Name.IndexOf(TypeNameConstants.BindingElement)) + Constants.Defaults;

            this.customBEVarInstance = Helpers.TurnFirstCharLower(bindingElementType.Name);
            customBEArgRef = new CodeArgumentReferenceExpression(customBEVarInstance);

            this.customBETypeRef = new CodeTypeReference(bindingElementType.Name);
            this.customBETypeOfRef = new CodeTypeOfExpression(customBETypeRef);
            this.customBENewVarAssignRef = new CodeVariableDeclarationStatement(
                                                customBETypeRef,
                                                customBEVarInstance,
                                                new CodeObjectCreateExpression(customBETypeRef));
            this.bindingElementMethodParamRef = new CodeParameterDeclarationExpression(
                                                    CodeDomHelperObjects.bindingElementTypeRef,
                                                    Constants.bindingElementParamName);

        }
开发者ID:ssickles,项目名称:archive,代码行数:25,代码来源:BindingElementExtensionSectionGenerator.cs

示例2: DeclareCodeType

        public override void DeclareCodeType(IDLInterface idlIntf)
        {
            // Proxy class.
            typeProxy = new CodeTypeDeclaration(name + "Proxy");
            typeProxy.IsClass = true;
            typeProxy.TypeAttributes = TypeAttributes.Public;
            eventsDeclarationHolder = new CodeTypeDeferredNamespaceDeclarationHolderEvents(idlIntf);
            typeProxy.BaseTypes.Add(genInterfaceName);

            // Interface field.
            CodeMemberField memberProxy = new CodeMemberField(genInterfaceName, proxyName);
            memberProxy.Attributes = MemberAttributes.Private;
            typeProxy.Members.Add(memberProxy); // TODO: Going to need a using or a fully qualified name.

            // Constructor.
            CodeConstructor constructor = new CodeConstructor();
            constructor.Attributes = MemberAttributes.Public;
            // TODO - use the actual interface type rather than a string.
            paramProxy = new CodeParameterDeclarationExpression(genInterfaceName, proxyName);
            constructor.Parameters.Add(paramProxy);
            thisProxyFieldRef = new CodeFieldReferenceExpression(
                new CodeThisReferenceExpression(), proxyName
            );
            assignProxy = new CodeAssignStatement(thisProxyFieldRef,
                new CodeArgumentReferenceExpression(proxyName));
            constructor.Statements.Add(assignProxy);
            typeProxy.Members.Add(constructor);

            declarationHolder = new CodeTypeIgnoredNamespaceDeclarationHolderParams(idlIntf);
            contextDeclarationHolder = declarationHolder;

            bAddNamespace = false;
        }
开发者ID:jean-edouard,项目名称:win-tools,代码行数:33,代码来源:ProxyBuilder.cs

示例3: Constructor0

		public void Constructor0 ()
		{
			CodeParameterDeclarationExpression cpde = new CodeParameterDeclarationExpression ();
			Assert.IsNotNull (cpde.CustomAttributes, "#1");
			Assert.AreEqual (0, cpde.CustomAttributes.Count, "#2");
			Assert.AreEqual (FieldDirection.In, cpde.Direction, "#3");
			Assert.IsNotNull (cpde.Name, "#4");
			Assert.AreEqual (string.Empty, cpde.Name, "#5");
			Assert.IsNotNull (cpde.Type, "#6");
			Assert.AreEqual (typeof (void).FullName, cpde.Type.BaseType, "#7");

			cpde.Direction = FieldDirection.Out;
			Assert.AreEqual (FieldDirection.Out, cpde.Direction, "#8");

			string name = "mono";
			cpde.Name = name;
			Assert.AreSame (name, cpde.Name, "#9");

			cpde.Name = null;
			Assert.IsNotNull (cpde.Name, "#10");
			Assert.AreEqual (string.Empty, cpde.Name, "#11");

			CodeTypeReference type = new CodeTypeReference ("mono");
			cpde.Type = type;
			Assert.AreSame (type, cpde.Type, "#12");

			cpde.Type = null;
			Assert.IsNotNull (cpde.Type, "#13");
			Assert.AreEqual (typeof (void).FullName, cpde.Type.BaseType, "#14");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:CodeParameterDeclarationExpressionTest.cs

示例4: CreateRequiredConstructor

        internal CodeConstructor CreateRequiredConstructor(CodeTypeDeclaration resourceClass,
                                                           IMethod request,
                                                           bool addOptionalParameters)
        {
            var constructor = new CodeConstructor();
            constructor.Attributes = MemberAttributes.Public;

            // IRequestProvider service
            var serviceArg = new CodeParameterDeclarationExpression(typeof(IRequestProvider), ServiceName);
            constructor.Parameters.Add(serviceArg);

            // : base(service, "path", "HTTPMETHOD")
            constructor.BaseConstructorArgs.Add(
                new CodePropertyReferenceExpression(
                    new CodeVariableReferenceExpression(ServiceName), BaseUriName));
            constructor.BaseConstructorArgs.Add(new CodePrimitiveExpression(request.MediaUpload.Simple.Path));
            constructor.BaseConstructorArgs.Add(new CodePrimitiveExpression(request.HttpMethod));

            // Add all required arguments to the constructor.
            AddBodyParameter(constructor, request);

            // Add common upload arguements.
            constructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(StreamParameterName));
            constructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression(ContentTypeParameterName));

            AddAuthorizationAssignment(constructor);
            AddRequestParameters(resourceClass, request, constructor, addOptionalParameters);

            constructor.Parameters.Add(new CodeParameterDeclarationExpression(
                new CodeTypeReference(typeof(System.IO.Stream)), StreamParameterName));
            constructor.Parameters.Add(new CodeParameterDeclarationExpression(
                new CodeTypeReference(typeof(System.String)), ContentTypeParameterName));

            return constructor;
        }
开发者ID:JANCARLO123,项目名称:google-apis,代码行数:35,代码来源:UploadConstructorDecorator.cs

示例5: Visit

        public void Visit(ProcedureDefinition statement)
        {
            var argList = new List<CodeParameterDeclarationExpression>();
            foreach (var arg in statement.Args)
            {
                var variableType = TablePrimitive.FromString(arg.Type).Type;
                var codeParam = new CodeParameterDeclarationExpression(variableType, arg.Variable);
                Scope.Current.RegisterPrimitive(codeParam.Name, variableType, codeParam.Type);
                Scope.Current.Type.Type.Members.Add(new CodeMemberField() { Name = codeParam.Name, Type = codeParam.Type, Attributes = MemberAttributes.Public | MemberAttributes.Final });

                var assignment = new CodeAssignStatement(new CodeVariableReferenceExpression("_" + Scope.Current.ScopeIdentifier + "." + codeParam.Name), new CodeVariableReferenceExpression(codeParam.Name));
                _mainType.Constructor.Statements.Add(assignment);

                argList.Add(codeParam);
            }

            _mainType.Type.Name = statement.Name;
            _mainType.Constructor.Parameters.Clear();
            _mainType.Constructor.BaseConstructorArgs.Clear();
            _mainType.Constructor.Parameters.AddRange(argList.ToArray());
            _mainType.Constructor.BaseConstructorArgs.Add(new CodeArrayCreateExpression(new CodeTypeReference(typeof(string[])), 0));

            //visit block
            var blockArgs = VisitChild(statement.Block);
            _codeStack.Peek().ParentStatements.AddRange(blockArgs.ParentStatements);
        }
开发者ID:bitsummation,项目名称:pickaxe,代码行数:26,代码来源:Visitor.ProcedureDefinition.cs

示例6: Emit

        // Builds a codedom delegate expression and attaches it to the given codedom namespace.
        public static void Emit(CodeNamespace codeNamespace, DelegateDeclaration del)
        {
            // Create the codedom delegate and attach it to the namespace.
            var codeDelegate = new CodeTypeDelegate();
            codeNamespace.Types.Add(codeDelegate);

            // Assign the name of the delegate
            codeDelegate.Name = del.Name;

            // Set the type of the delegate: make sure to check for null
            if (del.ReturnTypeName == "void")
                codeDelegate.ReturnType = null;
            else
                codeDelegate.ReturnType = new CodeTypeReference(del.ReturnTypeName);

            // Translate the accessibililty of the delegate
            MemberAttributes attributes = MemberAttributes.Public;
            switch(del.Accessibility)
            {
                case Accessibility.Public:
                    attributes = MemberAttributes.Public;
                    break;
                case Accessibility.Protected:
                    attributes = MemberAttributes.Family;
                    break;
                case Accessibility.Private:
                    attributes = MemberAttributes.Private;
                    break;
                case Accessibility.Internal:
                    attributes = MemberAttributes.FamilyAndAssembly;
                    break;
            }

            // Shared = static
            if (del.IsShared)
                attributes |= MemberAttributes.Static;

            codeDelegate.Attributes = attributes;

            // Translate the parameters of the delegate.
            foreach (Expression p in del.Parameters)
            {
                if (p is SimpleParameter) // ex "int i"
                    codeDelegate.Parameters.Add(new CodeParameterDeclarationExpression((p as SimpleParameter).TypeName, (p as SimpleParameter).Name));
                if (p is DirectionedParameter) // ex "ref int t"
                {
                    var codeParameter = new CodeParameterDeclarationExpression((p as DirectionedParameter).TypeName, (p as DirectionedParameter).Name);
                    switch ((p as DirectionedParameter).Direction)
                    {
                        case ParameterDirection.Out:
                            codeParameter.Direction = FieldDirection.Out;
                            break;
                        case ParameterDirection.Ref:
                            codeParameter.Direction = FieldDirection.Ref;
                            break;
                    }
                    codeDelegate.Parameters.Add(codeParameter);
                }
            }
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:61,代码来源:DelegateEmitter.cs

示例7: Emit

        // Generates a codedom constructor expression and attaches it to the given type.
        public static void Emit(CodeTypeDeclaration codeTypeDeclaration, Constructor ctor)
        {
            // Create the codedom constructor
            var codeCtor = new CodeConstructor();
            codeTypeDeclaration.Members.Add(codeCtor);

            // Translate accessibility of the constructor
            MemberAttributes memberAttributes = MemberAttributes.Public;
            switch (ctor.Accessibility)
            {
                case Accessibility.Internal:
                    memberAttributes |= MemberAttributes.FamilyAndAssembly;
                    break;
                case Accessibility.Private:
                    memberAttributes |= MemberAttributes.Private;
                    break;
                case Accessibility.Protected:
                    memberAttributes |= MemberAttributes.Family;
                    break;
                case Accessibility.Public:
                    memberAttributes |= MemberAttributes.Public;
                    break;
            }
            codeCtor.Attributes = memberAttributes;

            // Translate the parameters of the constructor
            foreach (Expression p in ctor.Parameters)
            {
                if (p is SimpleParameter) // ex "int i"
                    codeCtor.Parameters.Add(new CodeParameterDeclarationExpression((p as SimpleParameter).TypeName, (p as SimpleParameter).Name));
                if (p is DirectionedParameter) // ex "ref int i"
                {
                    var codeParameter = new CodeParameterDeclarationExpression((p as DirectionedParameter).TypeName, (p as DirectionedParameter).Name);
                    switch ((p as DirectionedParameter).Direction)
                    {
                        case ParameterDirection.Out:
                            codeParameter.Direction = FieldDirection.Out;
                            break;
                        case ParameterDirection.Ref:
                            codeParameter.Direction = FieldDirection.Ref;
                            break;
                    }
                    codeCtor.Parameters.Add(codeParameter);
                }
            }

            // Add call to a constructor of the base class or another in the same class.
            foreach (var a in ctor.SubParameters.ChildExpressions)
            {
                if (ctor.Sub)
                    codeCtor.ChainedConstructorArgs.Add(CodeDomEmitter.EmitCodeExpression(a));
                else
                    codeCtor.BaseConstructorArgs.Add(CodeDomEmitter.EmitCodeExpression(a));
            }

            // Add all the statements in the body of the constructor
            foreach (var e in ctor.ChildExpressions)
                codeCtor.Statements.Add(CodeDomEmitter.EmitCodeStatement(e));
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:60,代码来源:ConstructorEmitter.cs

示例8: AddRange

 /// <devdoc>
 /// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.CodeParameterDeclarationExpressionCollection'/>.</para>
 /// </devdoc>
 public void AddRange(CodeParameterDeclarationExpression[] value) {
     if (value == null) {
         throw new ArgumentNullException("value");
     }
     for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
         this.Add(value[i]);
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:11,代码来源:CodeParameterDeclarationExpressionCollection.cs

示例9: GetParameterExpression

        private static CodeParameterDeclarationExpression GetParameterExpression(ParameterInfo parameter)
        {
            var p = new CodeParameterDeclarationExpression();
            p.Name = parameter.Name;
            p.Type = new CodeTypeReference(parameter.ParameterType);

            return p;
        }
开发者ID:mbrit,项目名称:MoqRTPOC,代码行数:8,代码来源:Program.cs

示例10: Constructor1_NullItem

		public void Constructor1_NullItem ()
		{
			CodeParameterDeclarationExpression[] parameters = new CodeParameterDeclarationExpression[] { 
				new CodeParameterDeclarationExpression (), null };

			CodeParameterDeclarationExpressionCollection coll = new CodeParameterDeclarationExpressionCollection (
				parameters);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeParameterDeclarationExpressionCollectionTest.cs

示例11: LocalMethod

 CodeMemberMethod LocalMethod(string name)
 {
     var method = new CodeMemberMethod { Name = name, ReturnType = new CodeTypeReference(typeof(object)) };
     var param = new CodeParameterDeclarationExpression(typeof(object[]), args);
     param.UserData.Add(Parser.RawData, typeof(object[]));
     method.Parameters.Add(param);
     return method;
 }
开发者ID:lnsoso,项目名称:IronAHK,代码行数:8,代码来源:Invokes.cs

示例12: DesignTimeParameterInfo

 internal DesignTimeParameterInfo(CodeParameterDeclarationExpression codeParameter, int position, MemberInfo member)
 {
     this.MemberImpl = member;
     this.NameImpl = Helper.EnsureTypeName(codeParameter.Name);
     this.codeParameterType = codeParameter.Type;
     this.AttrsImpl = Helper.ConvertToParameterAttributes(codeParameter.Direction);
     this.isRef = (codeParameter.Direction == FieldDirection.Ref);
     this.PositionImpl = position;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:9,代码来源:ParameterInfo.cs

示例13: Visit

        public void Visit(CaseVariableStatement statement)
        {
            var domArg = new CodeDomArg();

            CodeMemberMethod method = new CodeMemberMethod();
            method.Name = "Case_" + domArg.MethodIdentifier;
            method.Attributes = MemberAttributes.Private;
            method.ReturnType = new CodeTypeReference(typeof(object));
            GenerateCallStatement(method.Statements, statement.Line.Line);

            var caseArgs = VisitChild(statement.Case, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
            if (caseArgs.Tag != null)
                _codeStack.Peek().Tag = caseArgs.Tag;

            method.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference(typeof(object)), "var", caseArgs.CodeExpression));

            foreach (var childArg in statement.BooleanStatements)
            {
                domArg = VisitChild(childArg, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
                if (domArg.Tag != null)
                    _codeStack.Peek().Tag = domArg.Tag;

                method.Statements.AddRange(domArg.ParentStatements);
            }

            if (statement.ElseStatement == null)
                method.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null)));
            else
            {
                domArg = VisitChild(statement.ElseStatement, new CodeDomArg() { Scope = _codeStack.Peek().Scope });
                if (domArg.Tag != null)
                    _codeStack.Peek().Tag = domArg.Tag;

                method.Statements.Add(new CodeMethodReturnStatement(domArg.CodeExpression));
            }

            _mainType.Type.Members.Add(method);

            var methodcall = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(null, method.Name));
            var rowParam = new CodeParameterDeclarationExpression(_codeStack.Peek().Scope.CodeDomReference.TypeArguments[0], "row");
            method.Parameters.Add(rowParam);
            methodcall.Parameters.Add(new CodeVariableReferenceExpression("row"));

            if(_codeStack.Peek().Tag != null) //pick statement
            {
                var htmlNodeParam = new CodeParameterDeclarationExpression(new CodeTypeReference("HtmlNode"), "node");
                methodcall.Parameters.Add(new CodeVariableReferenceExpression("node"));
                method.Parameters.Add(htmlNodeParam);
            }

            _codeStack.Peek()
                  .ParentStatements.Add(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("result"),
                      "AddColumn",
                      new CodePrimitiveExpression("(No column name)")));

            _codeStack.Peek().CodeExpression = methodcall;
        }
开发者ID:bitsummation,项目名称:pickaxe,代码行数:57,代码来源:Visitor.CaseVariableStatement.cs

示例14: AddRange

		public void AddRange (CodeParameterDeclarationExpression [] value )
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}

			for (int i = 0; i < value.Length; i++) {
				Add (value[i]);
			}
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:10,代码来源:CodeParameterDeclarationExpressionCollection.cs

示例15: CodeMemberOperatorOverride

 public CodeMemberOperatorOverride(OperatorType type,
     CodeParameterDeclarationExpression[] parameters,
     CodeTypeReference returnType,
     params CodeStatement[] statements)
 {
     m_operator = type;
     m_parameters = parameters;
     m_returnType = returnType;
     m_statements = statements;
 }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:10,代码来源:CodeMemberOperatorOverride.cs


注:本文中的System.CodeDom.CodeParameterDeclarationExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。