本文整理汇总了C#中System.CodeDom.CodeEventReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# CodeEventReferenceExpression类的具体用法?C# CodeEventReferenceExpression怎么用?C# CodeEventReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeEventReferenceExpression类属于System.CodeDom命名空间,在下文中一共展示了CodeEventReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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));
}
}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:25,代码来源:EventCodeDomSerializer.cs
示例2: Constructor1
public void Constructor1 ()
{
CodeEventReferenceExpression eventref = new CodeEventReferenceExpression ();
CodeExpression listener = new CodeExpression ();
CodeRemoveEventStatement caes = new CodeRemoveEventStatement (eventref, listener);
Assert.AreSame (eventref, caes.Event, "#1");
Assert.AreEqual (string.Empty, caes.Event.EventName, "#2");
Assert.IsNull (caes.Event.TargetObject, "#3");
Assert.AreSame (listener, caes.Listener, "#4");
caes.Event = null;
Assert.IsNotNull (caes.Event, "#5");
Assert.AreEqual (string.Empty, caes.Event.EventName, "#6");
Assert.IsNull (caes.Event.TargetObject, "#7");
Assert.AreSame (listener, caes.Listener, "#8");
caes.Listener = null;
Assert.IsNull (caes.Listener, "#9");
caes.Event = eventref;
Assert.AreSame (eventref, caes.Event, "#10");
caes.Listener = listener;
Assert.AreSame (listener, caes.Listener, "#11");
caes = new CodeRemoveEventStatement ((CodeEventReferenceExpression) null, (CodeExpression) null);
Assert.IsNotNull (caes.Event, "#12");
Assert.IsNull (caes.Listener, "#13");
Assert.AreEqual (string.Empty, caes.Event.EventName, "#14");
Assert.IsNull (caes.Event.TargetObject, "#15");
}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:CodeRemoveEventStatementTest.cs
示例3: AddCallbackImplementation
internal static void AddCallbackImplementation(CodeTypeDeclaration codeClass, string callbackName, string handlerName, string handlerArgs, bool methodHasOutParameters)
{
CodeFlags[] parameterFlags = new CodeFlags[1];
CodeMemberMethod method = AddMethod(codeClass, callbackName, parameterFlags, new string[] { typeof(object).FullName }, new string[] { "arg" }, typeof(void).FullName, null, (CodeFlags) 0);
CodeEventReferenceExpression left = new CodeEventReferenceExpression(new CodeThisReferenceExpression(), handlerName);
CodeBinaryOperatorExpression condition = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
CodeStatement[] trueStatements = new CodeStatement[2];
trueStatements[0] = new CodeVariableDeclarationStatement(typeof(InvokeCompletedEventArgs), "invokeArgs", new CodeCastExpression(typeof(InvokeCompletedEventArgs), new CodeArgumentReferenceExpression("arg")));
CodeVariableReferenceExpression targetObject = new CodeVariableReferenceExpression("invokeArgs");
CodeObjectCreateExpression expression4 = new CodeObjectCreateExpression();
if (methodHasOutParameters)
{
expression4.CreateType = new CodeTypeReference(handlerArgs);
expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Results"));
}
else
{
expression4.CreateType = new CodeTypeReference(typeof(AsyncCompletedEventArgs));
}
expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Error"));
expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "Cancelled"));
expression4.Parameters.Add(new CodePropertyReferenceExpression(targetObject, "UserState"));
trueStatements[1] = new CodeExpressionStatement(new CodeDelegateInvokeExpression(new CodeEventReferenceExpression(new CodeThisReferenceExpression(), handlerName), new CodeExpression[] { new CodeThisReferenceExpression(), expression4 }));
method.Statements.Add(new CodeConditionStatement(condition, trueStatements, new CodeStatement[0]));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:WebCodeGenerator.cs
示例4: 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));
}
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:26,代码来源:EventCodeDomSerializer.cs
示例5: CodeAttachEventStatement
public CodeAttachEventStatement (CodeExpression targetObject,
string eventName,
CodeExpression listener)
{
this.eventRef = new CodeEventReferenceExpression (targetObject,
eventName);
this.listener = listener;
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:8,代码来源:CodeAttachEventStatement.cs
示例6: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeEventReferenceExpression cere = new CodeEventReferenceExpression ();
Assert.AreEqual (String.Empty, cere.EventName, "EventName");
cere.EventName = "mono";
Assert.IsNull (cere.TargetObject, "TargetObject");
cere.TargetObject = new CodeExpression ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeEventReferenceExpressionCas.cs
示例7: Clone
public static CodeEventReferenceExpression Clone(this CodeEventReferenceExpression expression)
{
if (expression == null) return null;
CodeEventReferenceExpression e = new CodeEventReferenceExpression();
e.EventName = expression.EventName;
e.TargetObject = expression.TargetObject.Clone();
e.UserData.AddRange(expression.UserData);
return e;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:9,代码来源:CodeEventReferenceExpressionExtensions.cs
示例8: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeExpression target = new CodeExpression ();
CodeEventReferenceExpression cere = new CodeEventReferenceExpression (target, "mono");
Assert.AreEqual ("mono", cere.EventName, "EventName");
cere.EventName = String.Empty;
Assert.AreSame (target, cere.TargetObject, "TargetObject");
cere.TargetObject = new CodeExpression ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeEventReferenceExpressionCas.cs
示例9: Constructor1_Deny_Unrestricted
public void Constructor1_Deny_Unrestricted ()
{
CodeEventReferenceExpression eventref = new CodeEventReferenceExpression ();
CodeExpression listener = new CodeExpression ();
CodeAttachEventStatement caes = new CodeAttachEventStatement (eventref, listener);
Assert.AreSame (eventref, caes.Event, "Event");
caes.Event = new CodeEventReferenceExpression ();
Assert.AreSame (listener, caes.Listener, "Listener");
caes.Listener = new CodeExpression ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:CodeAttachEventStatementCas.cs
示例10: Serialize
public override void Serialize(IDesignerSerializationManager manager, object value, MemberDescriptor descriptor, CodeStatementCollection statements)
{
EventDescriptor e = descriptor as EventDescriptor;
if (manager == null)
{
throw new ArgumentNullException("manager");
}
if (value == null)
{
throw new ArgumentNullException("value");
}
if (e == null)
{
throw new ArgumentNullException("descriptor");
}
if (statements == null)
{
throw new ArgumentNullException("statements");
}
try
{
IEventBindingService service = (IEventBindingService) manager.GetService(typeof(IEventBindingService));
if (service != null)
{
string methodName = (string) service.GetEventProperty(e).GetValue(value);
if (methodName != null)
{
CodeExpression targetObject = base.SerializeToExpression(manager, value);
if (targetObject != null)
{
CodeTypeReference delegateType = new CodeTypeReference(e.EventType);
CodeDelegateCreateExpression listener = new CodeDelegateCreateExpression(delegateType, _thisRef, methodName);
CodeEventReferenceExpression eventRef = new CodeEventReferenceExpression(targetObject, e.Name);
CodeAttachEventStatement statement = new CodeAttachEventStatement(eventRef, listener);
statement.UserData[typeof(Delegate)] = e.EventType;
statements.Add(statement);
}
}
}
}
catch (Exception innerException)
{
if (innerException is TargetInvocationException)
{
innerException = innerException.InnerException;
}
manager.ReportError(System.Design.SR.GetString("SerializerPropertyGenFailed", new object[] { e.Name, innerException.Message }));
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:EventMemberCodeDomSerializer.cs
示例11: Constructor1
public void Constructor1 ()
{
CodeSnippetExpression expression = new CodeSnippetExpression("exp");
CodeEventReferenceExpression cere = new CodeEventReferenceExpression (
expression, "mono");
Assert.AreEqual ("mono", cere.EventName, "#1");
Assert.IsNotNull (cere.TargetObject, "#2");
Assert.AreSame (expression, cere.TargetObject, "#3");
cere.EventName = null;
Assert.IsNotNull (cere.EventName, "#4");
Assert.AreEqual (string.Empty, cere.EventName, "#5");
cere.TargetObject = null;
Assert.IsNull (cere.TargetObject, "#6");
cere = new CodeEventReferenceExpression ((CodeExpression) null,
(string) null);
Assert.IsNotNull (cere.EventName, "#7");
Assert.AreEqual (string.Empty, cere.EventName, "#8");
Assert.IsNull (cere.TargetObject, "#9");
}
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:CodeEventReferenceExpressionTest.cs
示例12: Constructor0
public void Constructor0 ()
{
CodeEventReferenceExpression cere = new CodeEventReferenceExpression ();
Assert.IsNotNull (cere.EventName, "#1");
Assert.AreEqual (string.Empty, cere.EventName, "#2");
Assert.IsNull (cere.TargetObject, "#3");
string eventName = "mono";
cere.EventName = eventName;
Assert.IsNotNull (cere.EventName, "#4");
Assert.AreSame (eventName, cere.EventName, "#5");
cere.EventName = null;
Assert.IsNotNull (cere.EventName, "#6");
Assert.AreEqual (string.Empty, cere.EventName, "#7");
CodeExpression expression = new CodeExpression ();
cere.TargetObject = expression;
Assert.IsNotNull (cere.TargetObject, "#8");
Assert.AreSame (expression, cere.TargetObject, "#9");
cere.TargetObject = null;
Assert.IsNull (cere.TargetObject, "#10");
}
开发者ID:nlhepler,项目名称:mono,代码行数:24,代码来源:CodeEventReferenceExpressionTest.cs
示例13: GenerateFormalEventReferenceExpression
private void GenerateFormalEventReferenceExpression(CodeEventReferenceExpression e)
{
if ((e.TargetObject != null) && !(e.TargetObject is CodeThisReferenceExpression))
{
base.GenerateExpression(e.TargetObject);
base.Output.Write(".");
}
this.OutputIdentifier(e.EventName);
}
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:9,代码来源:VBCodeGenerator.cs
示例14: GenerateEventReferenceExpression
protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression e)
{
}
开发者ID:Profit0004,项目名称:mono,代码行数:3,代码来源:CodeGeneratorCas.cs
示例15: ImplementINotifyPropertyChanged
/// <summary>
/// Adds an implementation of the INotifyPropertyChanged interface to the given type.
/// </summary>
/// <param name="type">The type declaration</param>
/// <returns>Type with INotifyPropertyChanged implemented.</returns>
protected CodeTypeDeclaration ImplementINotifyPropertyChanged(CodeTypeDeclaration type)
{
//// This method will implement the INotifyPropertyChanged interface
//// Here's an example :
//// public class Customer :INotifyPropertyChanged {
//// public PropertyChangedEventHandler PropertyChanged;
//// public void RaisePropertyChanged(string propertyName) {
//// if( this.PropertyChanged !=null ) {
//// this.PropertyChanged (this, new PropertyChangedEventArgs( propertyName ) );
//// }
//// }
//// }
CodeThisReferenceExpression thisReference = new CodeThisReferenceExpression();
CodeTypeReference notifyPropertyChanged = Code.TypeRef(typeof(INotifyPropertyChanged));
// Add the implements INotifyPropertyChanged statement
// public class Customer :INotifyPropertyChanged {
type.BaseTypes.Add(notifyPropertyChanged);
// Add the PropertyChanged event as a field to the type
// public PropertyChangedEventHandler PropertyChanged;
CodeMemberEvent propertyChangedEvent = type.AddEvent(Code.TypeRef(typeof(PropertyChangedEventHandler)), "PropertyChanged");
propertyChangedEvent.ImplementationTypes.Add(notifyPropertyChanged);
// this.PropertyChanged
CodeEventReferenceExpression eventFieldReference = new CodeEventReferenceExpression(thisReference, "PropertyChanged");
// Add the RaisePropertyChanged Method which will invoke the PropertyChanged handler whenever a property value changes
// if( this.PropertyChanged !=null )
CodeConditionStatement invokeEventHandlersIfAny = new CodeConditionStatement(new CodeBinaryOperatorExpression(eventFieldReference, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)));
// this.PropertyChanged (this, new PropertyChangedEventArgs( propertyName ) );
invokeEventHandlersIfAny.TrueStatements.Add(
new CodeDelegateInvokeExpression(eventFieldReference, new CodeExpression[] { thisReference, new CodeObjectCreateExpression("PropertyChangedEventArgs", new CodeArgumentReferenceExpression("propertyName")) }));
// public void RaisePropertyChanged
CodeMemberMethod method = type.AddMethod("RaisePropertyChanged", MemberAttributes.Public);
method.Parameters.Add(new CodeParameterDeclarationExpression("System.String", "propertyName"));
//// public void RaisePropertyChanged(string propertyName) {
//// if( this.PropertyChanged !=null ) {
//// this.PropertyChanged (this, new PropertyChangedEventArgs( propertyName ) );
//// }
//// }
method.Statements.Add(invokeEventHandlersIfAny);
return type;
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:53,代码来源:PocoDataBindingClientCodeLayerGenerator.cs
示例16: GenerateEventReferenceExpression
protected abstract void GenerateEventReferenceExpression (CodeEventReferenceExpression e);
开发者ID:carrie901,项目名称:mono,代码行数:1,代码来源:CodeGenerator.cs
示例17: GenerateEventReferenceExpression
protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression expression)
{
if (expression.TargetObject != null) {
GenerateExpression (expression.TargetObject);
Output.Write ('.');
if (expression.TargetObject is CodeThisReferenceExpression) {
// We're actually creating a reference to a compiler-generated field here...
Output.Write (expression.EventName + "Event");
} else {
Output.Write (CreateEscapedIdentifier (expression.EventName));
}
} else {
Output.Write (CreateEscapedIdentifier (expression.EventName + "Event"));
}
}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:VBCodeGenerator.cs
示例18: GenerateEventReferenceExpression
protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression expression)
{
if (expression.TargetObject != null) {
GenerateExpression (expression.TargetObject);
Output.Write ('.');
}
Output.Write (GetSafeName (expression.EventName));
}
开发者ID:runefs,项目名称:Marvin,代码行数:8,代码来源:CSharpCodeGenerator.cs
示例19: Visit
public void Visit (CodeEventReferenceExpression o)
{
g.GenerateEventReferenceExpression (o);
}
开发者ID:carrie901,项目名称:mono,代码行数:4,代码来源:CodeGenerator.cs
示例20: GenerateEventReferenceExpression
/// <summary>
/// Generates code for the specified event reference expression.
/// </summary>
/// <remarks><c>TARGETOBJECT->EVENTNAME</c> or <c>TARGETOBJECT::EVENTNAME</c></remarks>
protected override void GenerateEventReferenceExpression(CodeEventReferenceExpression e)
{
OutputMemberReference(e.TargetObject, e.EventName, true, null);
}
开发者ID:jdluzen,项目名称:Phalanger,代码行数:8,代码来源:PhpGenerator.CLR.cs
注:本文中的System.CodeDom.CodeEventReferenceExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论