本文整理汇总了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");
}
}
示例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");
}
示例3: FieldInfo
public FieldInfo (int idx, UserType type, string name, CodeLinePragma line)
{
Idx = idx;
Type = type;
Name = name;
Line = line;
}
示例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");
}
示例5: StructureBuilder
public StructureBuilder (NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
: base (BundleManagerBase.DefaultStructureClass, ns, loc, attr)
{
BaseClass = new UserType (typeof (StructureTemplate));
ns.SetUserParams (this);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}