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


C# CodeDom.CodeLinePragma类代码示例

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


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

示例1: BuildExpressionSetup

        internal static void BuildExpressionSetup(ControlBuilder controlBuilder, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, bool isTwoWayBound, bool designerMode) {
            // {{controlType}} target;
            CodeVariableDeclarationStatement targetDecl = new CodeVariableDeclarationStatement(controlBuilder.ControlType, "dataBindingExpressionBuilderTarget");
            methodStatements.Add(targetDecl);

            CodeVariableReferenceExpression targetExp = new CodeVariableReferenceExpression(targetDecl.Name);

            // target = ({{controlType}}) sender;
            CodeAssignStatement setTarget = new CodeAssignStatement(targetExp,
                                                                    new CodeCastExpression(controlBuilder.ControlType,
                                                                                           new CodeArgumentReferenceExpression("sender")));
            setTarget.LinePragma = linePragma;
            statements.Add(setTarget);

            Type bindingContainerType = controlBuilder.BindingContainerType;
            CodeVariableDeclarationStatement containerDecl = new CodeVariableDeclarationStatement(bindingContainerType, "Container");
            methodStatements.Add(containerDecl);

            // {{containerType}} Container = ({{containerType}}) target.BindingContainer;
            CodeAssignStatement setContainer = new CodeAssignStatement(new CodeVariableReferenceExpression(containerDecl.Name),
                                                                       new CodeCastExpression(bindingContainerType,
                                                                                              new CodePropertyReferenceExpression(targetExp,
                                                                                                                                  "BindingContainer")));
            setContainer.LinePragma = linePragma;
            statements.Add(setContainer);
            string variableName = isTwoWayBound ? "BindItem" : "Item";
            GenerateItemTypeExpressions(controlBuilder, methodStatements, statements, linePragma, variableName);
            //Generate code for other variable as well at design time in addition to runtime variable for intellisense to work.
            if (designerMode) {
                GenerateItemTypeExpressions(controlBuilder, methodStatements, statements, linePragma, isTwoWayBound ?  "Item" : "BindItem");
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:DataBindingExpressionBuilder.cs

示例2: Constructor0

		public void Constructor0 ()
		{
			CodeSnippetStatement css = new CodeSnippetStatement ();
			Assert.IsNull (css.LinePragma, "#1");

			Assert.IsNotNull (css.Value, "#2");
			Assert.AreEqual (string.Empty, css.Value, "#3");

			Assert.IsNotNull (css.StartDirectives, "#4");
			Assert.AreEqual (0, css.StartDirectives.Count, "#5");

			Assert.IsNotNull (css.EndDirectives, "#6");
			Assert.AreEqual (0, css.EndDirectives.Count, "#7");

			Assert.IsNotNull (css.UserData, "#8");
			Assert.AreEqual (typeof(ListDictionary), css.UserData.GetType (), "#9");
			Assert.AreEqual (0, css.UserData.Count, "#10");
			
			css.Value = null;
			Assert.IsNotNull (css.Value, "#11");
			Assert.AreEqual (string.Empty, css.Value, "#12");

			CodeLinePragma clp = new CodeLinePragma ("mono", 10);
			css.LinePragma = clp;
			Assert.IsNotNull (css.LinePragma, "#13");
			Assert.AreSame (clp, css.LinePragma, "#14");

			css.LinePragma = null;
			Assert.IsNull (css.LinePragma, "#15");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:30,代码来源:CodeSnippetStatementTest.cs

示例3: FieldInfo

	    public FieldInfo (int idx, UserType type, string name, CodeLinePragma line)
	    {
		Idx = idx;
		Type = type;
		Name = name;
		Line = line;
	    }
开发者ID:emtees,项目名称:old-code,代码行数:7,代码来源:ResultBuilder.cs

示例4: Constructor0

		public void Constructor0 ()
		{
			CodeGotoStatement cgs = new CodeGotoStatement ();
			Assert.IsNull (cgs.Label, "#1");

			Assert.IsNotNull (cgs.StartDirectives, "#2");
			Assert.AreEqual (0, cgs.StartDirectives.Count, "#3");

			Assert.IsNotNull (cgs.EndDirectives, "#4");
			Assert.AreEqual (0, cgs.EndDirectives.Count, "#5");

			Assert.IsNotNull (cgs.UserData, "#6");
			Assert.AreEqual (typeof(ListDictionary), cgs.UserData.GetType (), "#7");
			Assert.AreEqual (0, cgs.UserData.Count, "#8");

			Assert.IsNull (cgs.LinePragma, "#9");

			CodeLinePragma clp = new CodeLinePragma ("mono", 10);
			cgs.LinePragma = clp;
			Assert.IsNotNull (cgs.LinePragma, "#10");
			Assert.AreSame (clp, cgs.LinePragma, "#11");

			cgs.LinePragma = null;
			Assert.IsNull (cgs.LinePragma, "#12");

			string label = "mono";
			cgs.Label = label;
			Assert.AreSame (label, cgs.Label, "#13");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:29,代码来源:CodeGotoStatementTest.cs

示例5: StructureBuilder

	public StructureBuilder (NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr) 
	    : base (BundleManagerBase.DefaultStructureClass, ns, loc, attr)
	{
	    BaseClass = new UserType (typeof (StructureTemplate));

	    ns.SetUserParams (this);
	}
开发者ID:emtees,项目名称:old-code,代码行数:7,代码来源:StructureBuilder.cs

示例6: BuildEvalExpression

        internal static void BuildEvalExpression(string field, string formatString, string propertyName,
            Type propertyType, ControlBuilder controlBuilder, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, bool isEncoded, ref bool hasTempObject) {

            // Altogether, this function will create a statement that looks like this:
            // if (this.Page.GetDataItem() != null) {
            //     target.{{propName}} = ({{propType}}) this.Eval(fieldName, formatString);
            // }

            //     this.Eval(fieldName, formatString)
            CodeMethodInvokeExpression evalExpr = new CodeMethodInvokeExpression();
            evalExpr.Method.TargetObject = new CodeThisReferenceExpression();
            evalExpr.Method.MethodName = EvalMethodName;
            evalExpr.Parameters.Add(new CodePrimitiveExpression(field));
            if (!String.IsNullOrEmpty(formatString)) {
                evalExpr.Parameters.Add(new CodePrimitiveExpression(formatString));
            }

            CodeStatementCollection evalStatements = new CodeStatementCollection();
            BuildPropertySetExpression(evalExpr, propertyName, propertyType, controlBuilder, methodStatements, evalStatements, linePragma, isEncoded, ref hasTempObject);

            // if (this.Page.GetDataItem() != null)
            CodeMethodInvokeExpression getDataItemExpr = new CodeMethodInvokeExpression();
            getDataItemExpr.Method.TargetObject = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Page");
            getDataItemExpr.Method.MethodName = GetDataItemMethodName;

            CodeConditionStatement ifStmt = new CodeConditionStatement();
            ifStmt.Condition = new CodeBinaryOperatorExpression(getDataItemExpr, 
                                                                CodeBinaryOperatorType.IdentityInequality, 
                                                                new CodePrimitiveExpression(null));
            ifStmt.TrueStatements.AddRange(evalStatements);
            statements.Add(ifStmt);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:32,代码来源:DataBindingExpressionBuilder.cs

示例7: EnumResultBuilder

	public EnumResultBuilder (string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
	{
	    if (name == null)
		throw new ArgumentNullException ();
	    
	    enumer = new TheEnum (name, ns, loc, attr);
	    result = new TheResult (name + "Result", ns, name, loc, attr);
	}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:EnumResultBuilder.cs

示例8: Constructor0_Deny_Unrestricted

		public void Constructor0_Deny_Unrestricted ()
		{
			CodeLinePragma clp = new CodeLinePragma ();
			Assert.AreEqual (String.Empty, clp.FileName, "FileName");
			clp.FileName = "filename";
			Assert.AreEqual (0, clp.LineNumber, "LineNumber");
			clp.LineNumber = Int32.MinValue;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:CodeLinePragmaCas.cs

示例9: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeLinePragma clp = new CodeLinePragma ("filename", Int32.MaxValue);
			Assert.AreEqual ("filename", clp.FileName, "FileName");
			clp.FileName = String.Empty;
			Assert.AreEqual (Int32.MaxValue, clp.LineNumber, "LineNumber");
			clp.LineNumber = 0;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:CodeLinePragmaCas.cs

示例10: MetaRuleBuilder

	public MetaRuleBuilder (string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
	{
	    rb = new RuleBuilder (name, ns, loc, attr);
	    tmpl = new RuleTemplateBuilder (name + "RTemplate", rb, ns, loc, attr);

	    ns.AddMetaRule (this);
	    BaseClass = RuleType;
	}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:MetaRuleBuilder.cs

示例11: TheResult

	    public TheResult (string name, NamespaceBuilder ns, string ename, CodeLinePragma loc, TypeAttributes attr)
		: base (name, ns, loc, attr)
	    {
		etype = new UserType (ename);

		BaseClass = new UserType (typeof (EnumResult<>));
		BaseClass.AddTypeArgument (etype);
	    }
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:EnumResultBuilder.cs

示例12: AddOutputWriteStatement

 private void AddOutputWriteStatement(CodeStatementCollection methodStatements, CodeExpression expr, CodeLinePragma linePragma)
 {
     CodeStatement outputWriteStatement = this.GetOutputWriteStatement(expr, false);
     if (linePragma != null)
     {
         outputWriteStatement.LinePragma = linePragma;
     }
     methodStatements.Add(outputWriteStatement);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:BaseTemplateCodeDomTreeGenerator.cs

示例13: WriteLinePragma

 public virtual void WriteLinePragma(CodeLinePragma pragma)
 {
     if (pragma == null)
     {
         WriteLinePragma(null, null);
     }
     else
     {
         WriteLinePragma(pragma.LineNumber, pragma.FileName);
     }
 }
开发者ID:KennyBu,项目名称:Razor,代码行数:11,代码来源:CodeWriter.cs

示例14: BuildExpression

        internal virtual void BuildExpression(BoundPropertyEntry bpe, ControlBuilder controlBuilder,
            CodeExpression controlReference, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, ref bool hasTempObject) {

            CodeExpression codeExpression = GetCodeExpression(bpe,
                bpe.ParsedExpressionData, new ExpressionBuilderContext(controlBuilder.VirtualPath));

            CodeDomUtility.CreatePropertySetStatements(methodStatements, statements,
                controlReference, bpe.Name, bpe.Type,
                codeExpression,
                linePragma);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:ExpressionBuilder.cs

示例15: TypeExpressedItem

	protected TypeExpressedItem (string namebase, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attrs)
	{
	    if (namebase == null)
		throw new ArgumentNullException ();

	    this.namebase = namebase;
	    location = loc;
	    this.attrs = attrs;

	    this.ns = ns;
	    ns.AddItem (this);
	}
开发者ID:emtees,项目名称:old-code,代码行数:12,代码来源:TypeExpressedItem.cs


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