本文整理汇总了C#中System.CodeDom.CodeMethodReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeMethodReferenceExpression类的具体用法?C# CodeMethodReferenceExpression怎么用?C# CodeMethodReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeMethodReferenceExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeMethodReferenceExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor0
public void Constructor0 ()
{
CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression ();
Assert.IsNotNull (cmre.MethodName, "#1");
Assert.AreEqual (string.Empty, cmre.MethodName, "#2");
Assert.IsNull (cmre.TargetObject, "#3");
#if NET_2_0
Assert.IsNotNull (cmre.TypeArguments, "#4");
Assert.AreEqual (0, cmre.TypeArguments.Count, "#5");
#endif
string methodName = "mono";
cmre.MethodName = methodName;
Assert.IsNotNull (cmre.MethodName, "#6");
Assert.AreSame (methodName, cmre.MethodName, "#7");
cmre.MethodName = null;
Assert.IsNotNull (cmre.MethodName, "#8");
Assert.AreEqual (string.Empty, cmre.MethodName, "#9");
CodeExpression expression = new CodeExpression ();
cmre.TargetObject = expression;
Assert.IsNotNull (cmre.TargetObject, "#10");
Assert.AreSame (expression, cmre.TargetObject, "#11");
cmre.TargetObject = null;
Assert.IsNull (cmre.TargetObject, "#12");
}
示例2: CreateService
protected override CodeMemberMethod CreateService(CodeTypeReference typerefWCFService, CodeTypeReference typerefService)
{
CodeTypeReferenceExpression typerefexprService = new CodeTypeReferenceExpression(typerefService);
CodeMethodReferenceExpression methodrefDbusServiceCreate = new CodeMethodReferenceExpression(typerefexprService, "Create");
CodeMemberMethod methodCreateService = new CodeMemberMethod();
methodCreateService.Name = CreateServiceName;
methodCreateService.ReturnType = typerefWCFService;
methodCreateService.Attributes = MemberAttributes.Static;
methodCreateService.Parameters.Add(new CodeParameterDeclarationExpression(CodeBuilderCommon.typerefWCFServiceParams, nameWCFServiceParamsArg));
CodeMethodReferenceExpression methodrefCreateDbusService = new CodeMethodReferenceExpression(CodeBuilderCommon.typerefexprLookupTargetFunctions, CodeBuilderCommon.CreateDbusService);
methodrefCreateDbusService.TypeArguments.Add(typerefService);
methodCreateService.Statements.Add(new CodeVariableDeclarationStatement(typerefService, dbusService, // * <dbus_service> dbusService =
new CodeMethodInvokeExpression(methodrefCreateDbusService // * Udbus.WCF.Dbus.Service.LookupTargetFunctions.CreateDbusService(
, argrefWCFServiceParams // * wcfserviceparams
, methodrefDbusServiceCreate // * , <dbus_service>.Create // createService1
, methodrefDbusServiceCreate // * , <dbus_service>.Create // createService2
, new CodePropertyReferenceExpression(typerefexprService, CodeBuilderCommon.DefaultConnectionParameters) // * <dbus_service>.DefaultConnectionParameters);
)
));
// * <wcfservice> wcfService = new <wcfservice>(dbusservice);
methodCreateService.Statements.Add(new CodeVariableDeclarationStatement(typerefWCFService, wcfService
, new CodeObjectCreateExpression(typerefWCFService, varrefDbusService)
));
// return wcfService;
methodCreateService.Statements.Add(new CodeMethodReturnStatement(varrefWcfService));
return methodCreateService;
}
示例3: CodeMethodInvokeExpression
public CodeMethodInvokeExpression (CodeExpression targetObject,
string methodName,
params CodeExpression [] parameters)
{
this.method = new CodeMethodReferenceExpression( targetObject, methodName );
this.Parameters.AddRange (parameters);
}
示例4: CreateMethod
CodeMemberMethod CreateMethod()
{
CodeMemberMethod method = new CodeMemberMethod();
// BeginInit method call.
CodeExpressionStatement statement = new CodeExpressionStatement();
CodeMethodInvokeExpression methodInvoke = new CodeMethodInvokeExpression();
statement.Expression = methodInvoke;
CodeMethodReferenceExpression methodRef = new CodeMethodReferenceExpression();
methodRef.MethodName = "BeginInit";
CodeCastExpression cast = new CodeCastExpression();
cast.TargetType = new CodeTypeReference();
cast.TargetType.BaseType = "System.ComponentModel.ISupportInitialize";
CodeFieldReferenceExpression fieldRef = new CodeFieldReferenceExpression();
fieldRef.FieldName = "pictureBox1";
fieldRef.TargetObject = new CodeThisReferenceExpression();
cast.Expression = fieldRef;
methodRef.TargetObject = cast;
methodInvoke.Method = methodRef;
method.Statements.Add(statement);
return method;
}
示例5: Constructor0
public void Constructor0 ()
{
CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression ();
Assert.IsNotNull (cmie.Method, "#1");
Assert.AreEqual (string.Empty, cmie.Method.MethodName, "#2");
Assert.IsNull (cmie.Method.TargetObject, "#3");
#if NET_2_0
Assert.AreEqual (0, cmie.Method.TypeArguments.Count, "#4");
#endif
Assert.IsNotNull (cmie.Parameters, "#5");
Assert.AreEqual (0, cmie.Parameters.Count, "#6");
CodeMethodReferenceExpression method = new CodeMethodReferenceExpression ();
cmie.Method = method;
Assert.IsNotNull (cmie.Method, "#7");
Assert.AreSame (method, cmie.Method, "#8");
cmie.Method = null;
Assert.IsNotNull (cmie.Method, "#9");
Assert.AreEqual (string.Empty, cmie.Method.MethodName, "#10");
Assert.IsNull (cmie.Method.TargetObject, "#11");
#if NET_2_0
Assert.AreEqual (0, cmie.Method.TypeArguments.Count, "#12");
#endif
}
示例6: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeMethodReferenceExpression method = new CodeMethodReferenceExpression ();
CodeExpression[] parameters = new CodeExpression[1] { new CodeExpression () };
CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression (method, parameters);
Assert.AreSame (method, cmie.Method, "Method");
cmie.Method = new CodeMethodReferenceExpression ();
Assert.AreEqual (1, cmie.Parameters.Count, "Parameters");
}
示例7: Generate
public override void Generate(object codeObject, Entity entity)
{
var propNode = (CodeMemberProperty) codeObject;
var property = (GenericProperty) entity;
var getPropertyValueMethod = new CodeMethodReferenceExpression(null, "GetValue", propNode.Type);
var getPropertyValueCall = new CodeMethodInvokeExpression(getPropertyValueMethod, new CodePrimitiveExpression(property.Alias));
propNode.GetStatements.Add(new CodeMethodReturnStatement(getPropertyValueCall));
}
示例8: Serialize
public override object Serialize(IDesignerSerializationManager manager, object value)
{
PropertyDescriptor descriptor = (PropertyDescriptor) manager.Context[typeof(PropertyDescriptor)];
ExpressionContext context = (ExpressionContext) manager.Context[typeof(ExpressionContext)];
bool flag = (value != null) ? CodeDomSerializerBase.GetReflectionTypeHelper(manager, value).IsSerializable : true;
bool flag2 = !flag;
bool flag3 = (descriptor != null) && descriptor.Attributes.Contains(DesignerSerializationVisibilityAttribute.Content);
if (!flag2)
{
flag2 = ((context != null) && (context.PresetValue != null)) && (context.PresetValue == value);
}
if (((this._model == CodeDomLocalizationModel.PropertyReflection) && !flag3) && !flag2)
{
CodeStatementCollection statements = (CodeStatementCollection) manager.Context[typeof(CodeStatementCollection)];
bool flag4 = false;
ExtenderProvidedPropertyAttribute attribute = null;
if (descriptor != null)
{
attribute = descriptor.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute;
if ((attribute != null) && (attribute.ExtenderProperty != null))
{
flag4 = true;
}
}
if ((!flag4 && (context != null)) && (statements != null))
{
string name = manager.GetName(context.Owner);
CodeExpression expression = base.SerializeToExpression(manager, context.Owner);
if ((name != null) && (expression != null))
{
RootContext context2 = manager.Context[typeof(RootContext)] as RootContext;
if ((context2 != null) && (context2.Value == context.Owner))
{
name = "$this";
}
base.SerializeToResourceExpression(manager, value, false);
if (this.EmitApplyMethod(manager, context.Owner))
{
ResourceManager manager2 = manager.Context[typeof(ResourceManager)] as ResourceManager;
CodeMethodReferenceExpression expression3 = new CodeMethodReferenceExpression(base.GetExpression(manager, manager2), "ApplyResources");
CodeMethodInvokeExpression expression4 = new CodeMethodInvokeExpression {
Method = expression3
};
expression4.Parameters.Add(expression);
expression4.Parameters.Add(new CodePrimitiveExpression(name));
statements.Add(expression4);
}
return null;
}
}
}
if (flag2)
{
return this._currentSerializer.Serialize(manager, value);
}
return base.SerializeToResourceExpression(manager, value);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:LocalizationCodeDomSerializer.cs
示例9: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression ();
Assert.AreEqual (String.Empty, cmre.MethodName, "MethodName");
cmre.MethodName = "mono";
Assert.IsNull (cmre.TargetObject, "TargetObject");
cmre.TargetObject = new CodeExpression ();
Assert.AreEqual (0, cmre.TypeArguments.Count, "TypeArguments");
}
示例10: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeExpression target = new CodeExpression ();
CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression (target, "mono");
Assert.AreEqual ("mono", cmre.MethodName, "MethodName");
cmre.MethodName = String.Empty;
Assert.AreSame (target, cmre.TargetObject, "TargetObject");
cmre.TargetObject = new CodeExpression ();
Assert.AreEqual (0, cmre.TypeArguments.Count, "TypeArguments");
}
示例11: Clone
public static CodeMethodReferenceExpression Clone(this CodeMethodReferenceExpression expression)
{
if (expression == null) return null;
CodeMethodReferenceExpression e = new CodeMethodReferenceExpression();
e.MethodName = expression.MethodName;
e.TargetObject = expression.TargetObject.Clone();
e.TypeArguments.AddRange(expression.TypeArguments.Clone());
e.UserData.AddRange(expression.UserData);
return e;
}
示例12: TypescriptMethodReferenceExpression
public TypescriptMethodReferenceExpression(
IExpressionFactory expressionFactory,
CodeMethodReferenceExpression codeExpression,
CodeGeneratorOptions options)
{
_expressionFactory = expressionFactory;
_codeExpression = codeExpression;
_options = options;
System.Diagnostics.Debug.WriteLine("TypescriptMethodReferenceExpression Created");
}
示例13: CloneMethodReference
private static CodeMethodReferenceExpression CloneMethodReference(CodeMethodReferenceExpression oldReference)
{
CodeMethodReferenceExpression result = new CodeMethodReferenceExpression {
MethodName = oldReference.MethodName,
TargetObject = RuleExpressionWalker.Clone(oldReference.TargetObject)
};
foreach (CodeTypeReference reference in oldReference.TypeArguments)
{
result.TypeArguments.Add(TypeReferenceExpression.CloneType(reference));
}
ConditionHelper.CloneUserData(oldReference, result);
return result;
}
示例14: GenerateExceptionStatement
private CodeThrowExceptionStatement GenerateExceptionStatement(GenerateErrorActivity activity)
{
var parameters = DefaultActivityBuilder.GenerateParameters(new List<string> {
@"""Message : {0}\nMessage code : {1} """
}, activity);
CodeMethodInvokeExpression stringFormatCall = new CodeMethodInvokeExpression();
stringFormatCall.Parameters.AddRange(parameters);
CodeMethodReferenceExpression formatMethod = new CodeMethodReferenceExpression();
formatMethod.MethodName = "Format";
CodeVariableReferenceExpression stringObject = new CodeVariableReferenceExpression();
stringObject.VariableName = "String";
formatMethod.TargetObject = stringObject;
stringFormatCall.Method = formatMethod;
CodeThrowExceptionStatement throwException = new CodeThrowExceptionStatement(new CodeObjectCreateExpression(new CodeTypeReference(typeof(System.Exception)), stringFormatCall));
return throwException;
}
示例15: Constructor1
public void Constructor1 ()
{
CodeMethodReferenceExpression method1 = new CodeMethodReferenceExpression ();
CodeExpression param1 = new CodeExpression ();
CodeExpression param2 = new CodeExpression ();
CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression (
method1, param1, param2);
Assert.IsNotNull (cmie.Method, "#1");
Assert.AreSame (method1, cmie.Method, "#2");
cmie.Method = null;
Assert.IsNotNull (cmie.Method, "#3");
Assert.AreEqual (string.Empty, cmie.Method.MethodName, "#4");
Assert.IsNull (cmie.Method.TargetObject, "#5");
#if NET_2_0
Assert.AreEqual (0, cmie.Method.TypeArguments.Count, "#6");
#endif
CodeMethodReferenceExpression method2 = new CodeMethodReferenceExpression ();
cmie.Method = method2;
Assert.IsNotNull (cmie.Method, "#7");
Assert.AreSame (method2, cmie.Method, "#8");
Assert.IsNotNull (cmie.Parameters, "#9");
Assert.AreEqual (2, cmie.Parameters.Count, "#10");
Assert.AreEqual (0, cmie.Parameters.IndexOf (param1), "#11");
Assert.AreEqual (1, cmie.Parameters.IndexOf (param2), "#12");
cmie = new CodeMethodInvokeExpression ((CodeMethodReferenceExpression) null,
param2);
Assert.IsNotNull (cmie.Method, "#13");
Assert.AreEqual (string.Empty, cmie.Method.MethodName, "#14");
Assert.IsNull (cmie.Method.TargetObject, "#15");
#if NET_2_0
Assert.AreEqual (0, cmie.Method.TypeArguments.Count, "#16");
#endif
Assert.IsNotNull (cmie.Parameters, "#17");
Assert.AreEqual (1, cmie.Parameters.Count, "#18");
Assert.AreEqual (0, cmie.Parameters.IndexOf (param2), "#19");
}