本文整理汇总了C#中System.CodeDom.CodeStatementCollection类的典型用法代码示例。如果您正苦于以下问题:C# CodeStatementCollection类的具体用法?C# CodeStatementCollection怎么用?C# CodeStatementCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeStatementCollection类属于System.CodeDom命名空间,在下文中一共展示了CodeStatementCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildDetectChangedMembers
public static CodeStatementCollection BuildDetectChangedMembers(TableViewTableTypeBase table)
{
CodeStatementCollection ValidationSetStatement = new CodeStatementCollection();
String PocoTypeName = "this";
ValidationSetStatement.Add(new CodeSnippetExpression("Boolean bResult = new Boolean()"));
ValidationSetStatement.Add(new CodeSnippetExpression("bResult = false"));
foreach (Column c in table.Columns)
{
MemberGraph mGraph = new MemberGraph(c);
CodeConditionStatement csTest1 = new CodeConditionStatement();
if (mGraph.IsNullable)
{
csTest1.Condition = new CodeSnippetExpression(PocoTypeName + "." + mGraph.PropertyName() + ".HasValue == true");
csTest1.TrueStatements.Add(new CodeSnippetExpression("bResult = true"));
}
else
{
csTest1.Condition = new CodeSnippetExpression(PocoTypeName + "." + mGraph.PropertyName() + " == null");
csTest1.TrueStatements.Add(new CodeSnippetExpression(""));
csTest1.FalseStatements.Add(new CodeSnippetExpression("bResult = true"));
}
}
return ValidationSetStatement;
}
示例2: GenerateCoreGroupMethod
private CodeStatementCollection GenerateCoreGroupMethod(GroupActivity groupActivity)
{
var invocationCodeCollection = new CodeStatementCollection();
invocationCodeCollection.AddRange(this.coreProcessBuilder.GenerateStartCodeStatement(groupActivity.Transitions, "start", null, this.activityNameToServiceNameDictionnary));
return invocationCodeCollection;
}
示例3: Serialize
public virtual object Serialize (IDesignerSerializationManager manager, object value)
{
if (value == null)
throw new ArgumentNullException ("value");
if (manager == null)
throw new ArgumentNullException ("manager");
object serialized = null;
bool isComplete = false;
CodeExpression createExpr = base.SerializeCreationExpression (manager, value, out isComplete);
if (isComplete) {
serialized = createExpr;
base.SetExpression (manager, value, createExpr);
} else {
ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
if (context != null && context.PresetValue == value) {
CodeStatementCollection statements = new CodeStatementCollection ();
statements.Add (new CodeAssignStatement (context.Expression, createExpr));
base.SerializeProperties (manager, statements, value, new Attribute[0]);
base.SerializeEvents (manager, statements, value, new Attribute[0]);
} else {
CodeExpression expression = base.GetExpression (manager, value);
if (expression == null) {
serialized = expression = createExpr;
base.SetExpression (manager, value, expression);
}
}
}
return serialized;
}
示例4: ToCodeDom
public override void ToCodeDom(CodeStatementCollection statements)
{
if (this.expression!=null)
statements.Add(new CodeExpressionStatement(this.expression.ToCodeDom()));
else
statements.Add(new CodeStatement());
}
示例5: AddRange
public void AddRange(CodeStatementCollection value)
{
foreach(CodeStatement e in value)
{
List.Add(e);
}
}
示例6: FillJSONArrayMembers
private void FillJSONArrayMembers(CodeStatementCollection statements)
{
if (IsComplexType())
{
statements.Add(
new CodeVariableDeclarationStatement(new CodeTypeReference("Org.Json.JSONObject"), "jsonObject", new CodeObjectCreateExpression("Org.Json.JSONObject")));
statements.Add(
new CodeMethodInvokeExpression(null, "AddToJsonArray", new CodeVariableReferenceExpression("jsonArray"), new CodeVariableReferenceExpression("jsonObject")));
statements.Add(
new CodeMethodInvokeExpression(null, methodName, new CodeVariableReferenceExpression("objs[i]"), new CodeVariableReferenceExpression("jsonObject")));
}
else
{
if (IsEnum())
{
statements.Add(
new CodeMethodInvokeExpression(null, "AddToJsonArray", new CodeVariableReferenceExpression("jsonArray"), new CodeCastExpression(type.Fields[0].FieldType.FullName, new CodeVariableReferenceExpression("objs[i]"))));
}
else
{
statements.Add(
new CodeMethodInvokeExpression(null, "AddToJsonArray", new CodeVariableReferenceExpression("jsonArray"), new CodeVariableReferenceExpression("objs[i]")));
}
}
}
示例7: BuildOperation
public override CodeStatementCollection BuildOperation(CodeGenerationContext ctx, ICodeGeneratorNode element, CodeVariableReferenceExpression value)
{
CodeStatementCollection statemets = new CodeStatementCollection();
statemets.Add(new CodeSnippetExpression(
string.Format("{0} = ({2})((int){0} >> {1})", value.VariableName, Value, GetValueType(element.MappedProperty).FullName)));
return statemets;
}
示例8: Serialize
public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
{
if (statements == null)
throw new ArgumentNullException ("statements");
if (manager == null)
throw new ArgumentNullException ("manager");
if (value == null)
throw new ArgumentNullException ("value");
if (descriptor == null)
throw new ArgumentNullException ("descriptor");
IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
if (service != null) {
// In the propertygrid the events are represented by PropertyDescriptors and the value is a string
// which contains the method name to bind to. The propertydescriptors are managed and created by the
// IEventBindingService
//
EventDescriptor ev = (EventDescriptor) descriptor;
string methodName = (string) service.GetEventProperty (ev).GetValue (value);
CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (ev.EventType), _thisReference, methodName);
CodeExpression targetObject = base.SerializeToExpression (manager, value);
CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, ev.Name);
statements.Add (new CodeAttachEventStatement (eventRef, listener));
}
}
示例9: DefaultInvocationMethod
public CodeStatementCollection DefaultInvocationMethod(Activity activity)
{
var invocationCodeCollection = new CodeStatementCollection();
invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(activity));
return invocationCodeCollection;
}
示例10: CreateConstructor
protected override void CreateConstructor (CodeStatementCollection localVars,
CodeStatementCollection trueStmt)
{
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));
}
#if NET_2_0
if (pageParser.MasterPageFile != null) {
CodeExpression prop;
prop = new CodePropertyReferenceExpression (thisRef, "MasterPageFile");
CodeExpression ct = new CodePrimitiveExpression (pageParser.MasterPageFile);
if (localVars == null)
localVars = new CodeStatementCollection ();
localVars.Add (new CodeAssignStatement (prop, ct));
}
#endif
base.CreateConstructor (localVars, trueStmt);
}
示例11: Serialize
public override object Serialize (IDesignerSerializationManager manager, object value)
{
if (value == null)
throw new ArgumentNullException ("value");
if (manager == null)
throw new ArgumentNullException ("manager");
object serialized = null;
string name = manager.GetName (value);
ExpressionContext exprContext = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
if (exprContext != null && exprContext.PresetValue == value) {
CodeStatementCollection statements = new CodeStatementCollection ();
bool isComplete = true;
statements.Add (new CodeCommentStatement (String.Empty));
statements.Add (new CodeCommentStatement (name));
statements.Add (new CodeCommentStatement (String.Empty));
statements.Add (new CodeAssignStatement (GetFieldReference (manager, name),
base.SerializeCreationExpression (manager, value, out isComplete)));
base.SerializeProperties (manager, statements, value, new Attribute[0]);
base.SerializeEvents (manager, statements, value);
serialized = statements;
} else {
serialized = base.Serialize (manager, value);
}
return serialized;
}
示例12: BuildControlSkins
private void BuildControlSkins(CodeStatementCollection statements) {
foreach (ControlSkinBuilderEntry entry in _controlSkinBuilderEntryList) {
string skinID = entry.SkinID;
ControlBuilder builder = entry.Builder;
statements.Add(BuildControlSkinAssignmentStatement(builder, skinID));
}
}
示例13: AddOwner
private void AddOwner(object statementOwner, CodeStatementCollection statements)
{
if (this._table == null)
{
this._table = new List<TableEntry>();
}
else
{
for (int i = 0; i < this._table.Count; i++)
{
if (object.ReferenceEquals(this._table[i].Owner, statementOwner))
{
if (this._table[i].Statements != null)
{
throw new InvalidOperationException();
}
if (statements != null)
{
this._table[i] = new TableEntry(statementOwner, statements);
}
return;
}
}
}
this._table.Add(new TableEntry(statementOwner, statements));
this._version++;
}
示例14: ToCodeDom
public override void ToCodeDom(CodeStatementCollection statements)
{
CodeStatement init = null;
CodeStatement increment = null;
if (this.initStatement!=null)
{
CodeStatementCollection col = new CodeStatementCollection();
this.initStatement.ToCodeDom(col);
init = col[0];
}
if (this.incrementStatement!=null)
{
CodeStatementCollection col = new CodeStatementCollection();
this.incrementStatement.ToCodeDom(col);
increment = col[0];
}
statements.Add(
new CodeIterationStatement(
init,
this.testExpression.ToCodeDom(),
increment,
this.statements.ToCodeDomArray()
)
);
}
示例15: Serialize
public override void Serialize (IDesignerSerializationManager manager, object value, MemberDescriptor descriptor,
CodeStatementCollection statements)
{
if (statements == null)
throw new ArgumentNullException ("statements");
if (manager == null)
throw new ArgumentNullException ("manager");
if (value == null)
throw new ArgumentNullException ("value");
if (descriptor == null)
throw new ArgumentNullException ("descriptor");
IEventBindingService service = manager.GetService (typeof (IEventBindingService)) as IEventBindingService;
if (service != null) {
EventDescriptor eventDescriptor = (EventDescriptor) descriptor;
string methodName = (string) service.GetEventProperty (eventDescriptor).GetValue (value);
if (methodName != null) {
CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression (new CodeTypeReference (eventDescriptor.EventType),
_thisReference, methodName);
CodeExpression targetObject = base.SerializeToExpression (manager, value);
CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression (targetObject, eventDescriptor.Name);
statements.Add (new CodeAttachEventStatement (eventRef, listener));
}
}
}