本文整理汇总了C#中System.CodeDom.CodeExpressionCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# CodeExpressionCollection.Insert方法的具体用法?C# CodeExpressionCollection.Insert怎么用?C# CodeExpressionCollection.Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.CodeExpressionCollection
的用法示例。
在下文中一共展示了CodeExpressionCollection.Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeExpressionCollection coll = new CodeExpressionCollection ();
Assert.AreEqual (0, coll.Add (ce), "Add");
Assert.AreSame (ce, coll[0], "this[int]");
coll.CopyTo (array, 0);
coll.AddRange (array);
coll.AddRange (coll);
Assert.IsTrue (coll.Contains (ce), "Contains");
Assert.AreEqual (0, coll.IndexOf (ce), "IndexOf");
coll.Insert (0, ce);
coll.Remove (ce);
}
示例2: Insert_Null
public void Insert_Null ()
{
CodeExpressionCollection coll = new CodeExpressionCollection ();
coll.Insert (0, (CodeExpression) null);
}
示例3: GenerateMethods
//.........这里部分代码省略.........
// Add parameter to interface method.
methodInterface.Parameters.Add(param);
} // Ends else in argument
} // Ends loop over method arguments
methodAsync.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "userState"));
// Add method body, then sort out arguments code...
CodeFieldReferenceExpression thisRaiser = new CodeFieldReferenceExpression(
new CodeThisReferenceExpression(), raiserName
);
CodeTypeReference typerefResult = null;
if (idlMethod.Return != null) // If method has return type
{
// Add result to Result type.
// TODO replace typeof(string) with actual return type.
typerefResult = new CodeTypeReference("???");
}
CodeTypeReference typerefResults = null;
CodeTypeReference typerefParams = null;
CodeExpression exprAsyncParamValue = null;
string asyncMethodName = "AsyncFuncImpl"; // Default is assuming that function returns something.
if (paramsHolder.QuType()) // If got params type
{
typerefParams = new CodeTypeReference(paramsHolder.CodeType.Name);
// Add proxy field to params struct.
CodeMemberField memberParamsProxy = new CodeMemberField(new CodeTypeReference("readonly " + genInterfaceName), proxyName);
memberParamsProxy.Attributes = MemberAttributes.Public;
paramsHolder.CodeType.Members.Insert(0, memberParamsProxy); // TODO: Going to need a using or a fully qualified name.
// Add initialisation to constructor
constructorParams.Parameters.Insert(0, paramProxy);
// Constructor will take proxy as first argument.
constructorParams.Statements.Insert(0, assignProxy);
paramsHolder.CodeType.TypeAttributes = TypeAttributes.NestedPrivate;
paramsHolder.CodeType.IsStruct = true;
constructorParams.Attributes = MemberAttributes.Public;
paramsHolder.CodeType.Members.Add(constructorParams);
typeProxy.Members.Add(paramsHolder.CodeType);
asyncArgs.Insert(0, thisProxyFieldRef);
exprAsyncParamValue = new CodeObjectCreateExpression(typerefParams, asyncArgs.Cast<CodeExpression>().ToArray());
} // Ends if got params type
if (resultHolder.QuType()) // If got results type
{
typerefResults = new CodeTypeReference(resultHolder.CodeType.Name);
methodCall.ReturnType = typerefResults;
// Setup call method parameters.
if (idlMethod.Return != null)
{
// Add result field to EventArgs.
CodeMemberField fieldResult = new CodeMemberField(typerefResult, resultName);
fieldResult.Attributes = MemberAttributes.Private;
typeEvent.Members.Insert(0, fieldResult);
// Add result property to EventArgs.
CodeMemberProperty propResult = new CodeMemberProperty();
示例4: Insert
public void Insert ()
{
CodeExpression exp1 = new CodeExpression ();
CodeExpression exp2 = new CodeExpression ();
CodeExpressionCollection coll = new CodeExpressionCollection ();
coll.Add (exp1);
Assert.AreEqual (1, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (exp1), "#2");
coll.Insert (0, exp2);
Assert.AreEqual (2, coll.Count, "#3");
Assert.AreEqual (1, coll.IndexOf (exp1), "#4");
Assert.AreEqual (0, coll.IndexOf (exp2), "#5");
}