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


C# CodeDom.CodeArrayIndexerExpression类代码示例

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


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

示例1: Constructor0_Deny_Unrestricted

		public void Constructor0_Deny_Unrestricted ()
		{
			CodeArrayIndexerExpression caie = new CodeArrayIndexerExpression ();
			Assert.AreEqual (0, caie.Indices.Count, "Indices");
			Assert.IsNull (caie.TargetObject, "TargetObject");
			caie.TargetObject = new CodeExpression ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeArrayIndexerExpressionCas.cs

示例2: EmitArrayIndexer

        void EmitArrayIndexer(CodeArrayIndexerExpression array)
        {
            if (array.TargetObject is CodePropertyReferenceExpression &&
                ((CodePropertyReferenceExpression)array.TargetObject).PropertyName == Parser.VarProperty &&
                array.Indices.Count == 1 && array.Indices[0] is CodePrimitiveExpression)
            {
                var name = ((CodePrimitiveExpression)array.Indices[0]).Value as string;

                if (name != null)
                {
                    var sep = name.IndexOf(Parser.ScopeVar);

                    if (sep != -1)
                        name = name.Substring(sep + 1);

                    writer.Write(name);
                    return;
                }
            }

            EmitExpression(array.TargetObject);

            foreach (CodeExpression index in array.Indices)
            {
                writer.Write(Parser.ArrayOpen);
                EmitExpression(index);
                writer.Write(Parser.ArrayClose);
            }
        }
开发者ID:pschuegr,项目名称:IronAHK,代码行数:29,代码来源:Expression.cs

示例3: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeExpression target = new CodeExpression ();
			CodeExpression[] parameters = new CodeExpression[1] { target };
			CodeArrayIndexerExpression caie = new CodeArrayIndexerExpression (target, parameters);
			Assert.AreEqual (1, caie.Indices.Count, "Indices");
			Assert.AreSame (target, caie.TargetObject, "TargetObject");
			caie.TargetObject = new CodeExpression ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeArrayIndexerExpressionCas.cs

示例4: Clone

 public static CodeArrayIndexerExpression Clone(this CodeArrayIndexerExpression expression)
 {
     if (expression == null) return null;
     CodeArrayIndexerExpression e = new CodeArrayIndexerExpression();
     e.Indices.AddRange(expression.Indices.Clone());
     e.TargetObject = expression.TargetObject.Clone();
     e.UserData.AddRange(expression.UserData);
     return e;
 }
开发者ID:svejdo1,项目名称:CodeDomExtensions,代码行数:9,代码来源:CodeArrayIndexerExpressionExtensions.cs

示例5: EmitArrayIndexerExpression

        private void EmitArrayIndexerExpression(CodeArrayIndexerExpression Indexer)
        {
            var index = (CodeArrayIndexerExpression) Indexer;

            Generator.Emit(OpCodes.Ldloc, VarsProperty);
            EmitExpression(index.Indices[0]);

            Generator.Emit(OpCodes.Callvirt, GetVariable);
        }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:9,代码来源:EmitExpr.cs

示例6: VisitCodeArrayIndexerExpression

        /// <summary>
        /// Visits a <see cref="CodeArrayIndexerExpression"/>.
        /// </summary>
        /// <param name="codeArrayIndexerExpression">The <see cref="CodeArrayIndexerExpression"/> to visit.</param>
        protected virtual void VisitCodeArrayIndexerExpression(CodeArrayIndexerExpression codeArrayIndexerExpression)
        {
            if (codeArrayIndexerExpression == null)
            {
                return;
            }

            this.VisitCodeExpression(codeArrayIndexerExpression.TargetObject);
            this.VisitCodeExpressionCollection(codeArrayIndexerExpression.Indices);
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:14,代码来源:CodeDomVisitor.cs

示例7: BuildArray

 private CodeExpression BuildArray(CodeStatementCollection statements, string name, object value)
 {
     Array array = (Array) value;
     Type type = value.GetType();
     string uniqueVariableName = GetUniqueVariableName(name, statements);
     CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement(type.FullName, uniqueVariableName);
     statement.InitExpression = new CodeArrayCreateExpression(type.GetElementType(), array.Length);
     statements.Add(statement);
     CodeVariableReferenceExpression targetObject = new CodeVariableReferenceExpression(uniqueVariableName);
     string str2 = name + "_";
     for (int i = 0; i < array.Length; i++)
     {
         CodeArrayIndexerExpression left = new CodeArrayIndexerExpression(targetObject, new CodeExpression[0]);
         left.Indices.Add(new CodePrimitiveExpression(i));
         CodeExpression right = this.BuildObject(statements, str2 + i.ToString(), array.GetValue(i));
         statements.Add(new CodeAssignStatement(left, right));
     }
     return targetObject;
 }
开发者ID:hdougie,项目名称:webservicestudio2,代码行数:19,代码来源:Script.cs

示例8: CreateProperty

        static CodeMemberProperty CreateProperty(PropertyNameType nameType, string constantsClassName, string defaultValuesClassName)
        {
            CodeMemberProperty publicProp = new CodeMemberProperty();
            publicProp.Name = nameType.propertyName;
            publicProp.Attributes = CodeDomHelperObjects.PublicFinal;
            publicProp.HasGet = true;
            publicProp.HasSet = true;
            publicProp.Type = new CodeTypeReference(nameType.propertyType);

            CodeAttributeDeclarationCollection attributes = new CodeAttributeDeclarationCollection();
            CodeAttributeArgument arg1 = new CodeAttributeArgument(
                                            new CodeFieldReferenceExpression(
                                                new CodeTypeReferenceExpression(constantsClassName),
                                                nameType.propertyName));
            CodeAttributeArgument arg2 = new CodeAttributeArgument(
                                            PropertyNameConstants.DefaultValueProperty,
                                            new CodeFieldReferenceExpression(
                                                new CodeTypeReferenceExpression(defaultValuesClassName),
                                                Constants.DefaultPrefix + nameType.propertyName));
            // Future TODO: Provide a library with attributes that custom channel writes 
            // can use to adorn their properties with default values and validators, we can
            // then add it here.
            attributes.Add(new CodeAttributeDeclaration(
                            new CodeTypeReference(TypeNameConstants.ConfigurationProperty),
                            arg1, arg2));
            publicProp.CustomAttributes = new CodeAttributeDeclarationCollection(attributes);
            string nameInConfig = constantsClassName + "." + nameType.propertyName;
            CodeArrayIndexerExpression baseIndexedProperty
                                        = new CodeArrayIndexerExpression(
                                            CodeDomHelperObjects.BaseRef,
                                            new CodeFieldReferenceExpression(
                                                new CodeTypeReferenceExpression(constantsClassName),
                                                nameType.propertyName));
            publicProp.GetStatements.Add(new CodeMethodReturnStatement(
                                                new CodeCastExpression(
                                                    nameType.propertyType,
                                                    baseIndexedProperty)));
            publicProp.SetStatements.Add(new CodeAssignStatement(
                                                baseIndexedProperty,
                                                new CodePropertySetValueReferenceExpression()));
            return publicProp;
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:42,代码来源:CodeDomCommon.cs

示例9: CreateConstructor

		protected override void CreateConstructor (CodeStatementCollection localVars,
							   CodeStatementCollection trueStmt)
		{
#if NET_2_0
			if (!String.IsNullOrEmpty (pageParser.MasterPageFile))
				// This is here just to trigger master page build, so that its type
				// is available when compiling the page itself.
				BuildManager.GetCompiledType (pageParser.MasterPageFile);
#endif
			if (pageParser.ClientTarget != null) {
				CodeExpression prop;
				prop = new CodePropertyReferenceExpression (thisRef, "ClientTarget");
				CodeExpression ct = new CodePrimitiveExpression (pageParser.ClientTarget);
				if (localVars == null)
					localVars = new CodeStatementCollection ();
				localVars.Add (new CodeAssignStatement (prop, ct));
			}

			ArrayList deps = pageParser.Dependencies;
			int depsCount = deps != null ? deps.Count : 0;
			
			if (depsCount > 0) {
				if (localVars == null)
					localVars = new CodeStatementCollection ();
				if (trueStmt == null)
					trueStmt = new CodeStatementCollection ();

				CodeAssignStatement assign;
#if NET_2_0
				localVars.Add (
					new CodeVariableDeclarationStatement (
						typeof (string[]),
						"dependencies")
				);

				CodeVariableReferenceExpression dependencies = new CodeVariableReferenceExpression ("dependencies");
				trueStmt.Add (
					new CodeAssignStatement (dependencies, new CodeArrayCreateExpression (typeof (string), depsCount))
				);
				
				CodeArrayIndexerExpression arrayIndex;
				object o;
				
				for (int i = 0; i < depsCount; i++) {
					o = deps [i];
					arrayIndex = new CodeArrayIndexerExpression (dependencies, new CodeExpression[] {new CodePrimitiveExpression (i)});
					assign = new CodeAssignStatement (arrayIndex, new CodePrimitiveExpression (o));
					trueStmt.Add (assign);
				}
				
				CodeMethodInvokeExpression getDepsCall = new CodeMethodInvokeExpression (
					thisRef,
					"GetWrappedFileDependencies",
					new CodeExpression[] {dependencies}
				);
				assign = new CodeAssignStatement (GetMainClassFieldReferenceExpression ("__fileDependencies"), getDepsCall);
#else
				localVars.Add (new CodeVariableDeclarationStatement (
						typeof (ArrayList),
						"dependencies")
				);

				CodeVariableReferenceExpression dependencies = new CodeVariableReferenceExpression ("dependencies");
				trueStmt.Add (
					new CodeAssignStatement (dependencies, new CodeObjectCreateExpression (typeof (ArrayList), new CodeExpression[] {new CodePrimitiveExpression (depsCount)}))
				);

				CodeMethodInvokeExpression invoke;
				for (int i = 0; i < depsCount; i++) {
					invoke = new CodeMethodInvokeExpression (dependencies, "Add", new CodeExpression[] {new CodePrimitiveExpression (deps [i])});
					trueStmt.Add (invoke);
				}
				assign = new CodeAssignStatement (GetMainClassFieldReferenceExpression ("__fileDependencies"), dependencies);
#endif

				trueStmt.Add (assign);
			}

			base.CreateConstructor (localVars, trueStmt);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:80,代码来源:PageCompiler.cs

示例10: CreateVertexInputMethods

		private void CreateVertexInputMethods()
		{
			AsmListing asmVS = this.source.GetAsmTechnique(this.techniqueName, this.platform).VertexShader;

			//create the GetVertexInputCount() and GetVertexInput() methods

			CodeMemberMethod count = new CodeMemberMethod();
			count.Name = "GetVertexInputCountImpl";
			count.Attributes = MemberAttributes.Family | MemberAttributes.Override;
			count.ReturnType = new CodeTypeReference(typeof(int));

			Comment(count, "Returns the number of vertex inputs used by this shader");
			count.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(asmVS.InputCount)));
			classDom.Members.Add(count);

			//inputs are stored in a static array

			//create it...

			int[] arrayValues = new int[asmVS.InputCount * 2];
			for (int i = 0; i < asmVS.InputCount; i++)
			{
				arrayValues[i] = (int)asmVS.GetInput(i).Usage;
				arrayValues[i + asmVS.InputCount] = (int)asmVS.GetInput(i).Index;
			}

			this.vsInputField = new CodeMemberField(typeof(int[]), "vin");
			this.vsInputField.Attributes = MemberAttributes.Private | MemberAttributes.Static | MemberAttributes.Final;
			this.vsInputField.InitExpression = ShaderBytes.ToArray(arrayValues, this.directives);

			CodeFieldReferenceExpression vsInputRef = new CodeFieldReferenceExpression(ShaderClassEx, vsInputField.Name);

			//protected internal abstract void GetVertexInput(int index, out VertexElementUsage elementUsage, out int elementIndex);

			CodeMemberMethod getInput = new CodeMemberMethod();
			getInput.Name = "GetVertexInputImpl";
			getInput.Attributes = MemberAttributes.Family | MemberAttributes.Override;

			CodeParameterDeclarationExpression indexParam = new CodeParameterDeclarationExpression(typeof(int),"i");
			getInput.Parameters.Add(indexParam);

			CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(typeof(VertexElementUsage), "usage");
			param.Direction = FieldDirection.Out;
			getInput.Parameters.Add(param);

			param = new CodeParameterDeclarationExpression(typeof(int), "index");
			param.Direction = FieldDirection.Out;
			getInput.Parameters.Add(param);

			CodeArgumentReferenceExpression indexRef = new CodeArgumentReferenceExpression(indexParam.Name);

			//the element index is stored at 'i + asmVS.InputCount'
			CodeExpression indexArray = new CodeArrayIndexerExpression(vsInputRef,
				new CodeBinaryOperatorExpression(indexRef, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(asmVS.InputCount)));

			//and the usage must be cast
			CodeExpression usageCast = new CodeCastExpression(typeof(VertexElementUsage), new CodeArrayIndexerExpression(vsInputRef,indexRef));

			getInput.Statements.Add(new CodeAssignStatement(new CodeArgumentReferenceExpression("usage"), usageCast));
			getInput.Statements.Add(new CodeAssignStatement(new CodeArgumentReferenceExpression("index"), indexArray));

			Comment(getInput, "Returns a vertex input used by this shader");

			classDom.Members.Add(getInput);
		}
开发者ID:shadarath,项目名称:Wirtualna-rzeczywistosc,代码行数:65,代码来源:ShaderDom.cs

示例11: GenerateArrayIndexerExpression

		protected override void GenerateArrayIndexerExpression (CodeArrayIndexerExpression e)
		{
		}
开发者ID:Profit0004,项目名称:mono,代码行数:3,代码来源:CodeGeneratorCas.cs

示例12: GenerateArrayIndexerExpression

		protected abstract void GenerateArrayIndexerExpression (CodeArrayIndexerExpression e);
开发者ID:carrie901,项目名称:mono,代码行数:1,代码来源:CodeGenerator.cs

示例13: GenerateArrayIndexerExpression

		protected override void GenerateArrayIndexerExpression (CodeArrayIndexerExpression expression)
		{
			TextWriter output = Output;

			GenerateExpression (expression.TargetObject);
			output.Write ("(");
			OutputExpressionList (expression.Indices);
			output.Write (')');
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:VBCodeGenerator.cs

示例14: GenerateArrayIndexerExpression

		protected override void GenerateArrayIndexerExpression(CodeArrayIndexerExpression e)
		{
			Output.Write("[CodeArrayIndexerExpression: {0}]", e.ToString());
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:4,代码来源:CodeDOMVerboseOutputGenerator.cs

示例15: GenerateArrayIndexerExpression

 /// <summary>
 /// Generates code for the specified array indexer expression.
 /// </summary>
 /// <remarks><c>TARGET[INDEX1][INDEX2]...</c></remarks>
 protected override void GenerateArrayIndexerExpression(CodeArrayIndexerExpression e)
 {
     OutputArrayIndexerExpression(e.TargetObject, e.Indices);
 }
开发者ID:jdluzen,项目名称:Phalanger,代码行数:8,代码来源:PhpGenerator.CLR.cs


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