dynamicobject

How to handle dynamic elements using Robot Framework

有些话、适合烂在心里 提交于 2019-12-06 15:53:49
问题 I am currently working on the Robot Framework and using Selenium2Libraries to work on a Web Application. I'm working on a Form and I'm dealing with a dynamic elements which is an editable text area and drop down list.. I really hope someone would be able to guide me on how I can do this. An example of what I am doing is, [Example element code] input id="textfield-1237-inputEl" class="x-form-field x-form-text x-form-text-default x-form-focus x-field-form-focus x-field-default-form-focus" data

Is there a way to create a DynamicObject that supports an Interface?

谁都会走 提交于 2019-12-05 14:27:32
问题 Can I define a class which derives from DynamicObject and supports an interface (ICanDoManyThings) without having to implement each method in the interface? I'm trying to make a dynamic proxy object, and want the method invocations on this class to be handled by the implementation of MyProxyClass.TryInvokeMember, which may or may not pass them on to a wrapped object. Is this possible? Thanks 回答1: ImpromptuInterface does exactly this and it works with ANY IDynamicMetaObjectProvider including

Convert type 'System.Dynamic.DynamicObject to System.Collections.IEnumerable

不羁岁月 提交于 2019-12-05 03:34:08
I'm successfully using the JavaScriptSerializer in MVC3 to de-serialize a json string in to a dynamic object. What I can't figure out is how to cast it to something I can enumerate over. The foreach line of code below is my latest attemt but it errors with: "Cannot implicitly convert type 'System.Dynamic.DynamicObject' to 'System.Collections.IEnumerable'. How can I convert or cast so that I can iterate through the dictionary? public dynamic GetEntities(string entityName, string entityField) { var serializer = new JavaScriptSerializer(); serializer.RegisterConverters(new[] { new MyProject

Determining the expected type of a DynamicObject member access

耗尽温柔 提交于 2019-12-05 01:05:13
Is it possible to determine what type a dynamic member access expects? I've tried dynamic foo = new MyDynamicObject(); int x = foo.IntValue; int y = (int)foo.IntValue; And in the TryGetMember intercept GetMemberBinder.ReturnType is object either way. I also implemented TryConvert wondering if it might get invoked to do the conversion, but it never is hit. Is there some other override I'm missing that lets me determine what Type the caller wants so that I can do the appropriate conversion? In C#, when using dynamic, the compiler always sets the binder to return type of object, and then does a

How to handle dynamic elements using Robot Framework

不羁的心 提交于 2019-12-04 22:26:08
I am currently working on the Robot Framework and using Selenium2Libraries to work on a Web Application. I'm working on a Form and I'm dealing with a dynamic elements which is an editable text area and drop down list.. I really hope someone would be able to guide me on how I can do this. An example of what I am doing is, [Example element code] input id="textfield-1237-inputEl" class="x-form-field x-form-text x-form-text-default x-form-focus x-field-form-focus x-field-default-form-focus" data-ref="inputEl" size="1" name="textfield-1237-inputEl" maxlength="200" role="textbox" aria-hidden="false"

Is there a way to create a DynamicObject that supports an Interface?

不想你离开。 提交于 2019-12-04 00:35:52
Can I define a class which derives from DynamicObject and supports an interface (ICanDoManyThings) without having to implement each method in the interface? I'm trying to make a dynamic proxy object, and want the method invocations on this class to be handled by the implementation of MyProxyClass.TryInvokeMember, which may or may not pass them on to a wrapped object. Is this possible? Thanks ImpromptuInterface does exactly this and it works with ANY IDynamicMetaObjectProvider including DynamicObject subclasses and ExpandoObject. using ImpromptuInterface; using ImpromptuInterface.Dynamic;

Get generic type of call to method in dynamic object

假如想象 提交于 2019-12-03 15:53:53
问题 I'm starting to work with dynamic objects in .Net and I can't figure out how to do something. I have a class that inherits from DynamicObject, and I override the TryInvokeMember method. e.g. class MyCustomDynamicClass : DynamicObject { public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { // I want to know here the type of the generic argument } } And inside that method I want to know the type (if any) of the generic arguments in the invocation. e

C# DynamicObject dynamic properties

徘徊边缘 提交于 2019-12-03 10:42:40
问题 Assuming I cannot use an ExpandoObject and have to roll my own like so :- class MyObject : DynamicObject { dictionary<string, object> _properties = dictionary<string, object>(); public override bool TryGetMember(GetMemberBinder binder, out object result) { string name = binder.Name.ToLower(); return _properties.TryGetValue(name, out result); } public override bool TrySetMember(SetMemberBinder binder, object value) { _properties[binder.Name.ToLower()] = value; return true; } } and further down

Get generic type of call to method in dynamic object

南楼画角 提交于 2019-12-03 05:17:20
I'm starting to work with dynamic objects in .Net and I can't figure out how to do something. I have a class that inherits from DynamicObject, and I override the TryInvokeMember method. e.g. class MyCustomDynamicClass : DynamicObject { public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { // I want to know here the type of the generic argument } } And inside that method I want to know the type (if any) of the generic arguments in the invocation. e.g. If I invoke the following code, I want to get the value of System.Boolean and System.Int32 inside

C# DynamicObject dynamic properties

笑着哭i 提交于 2019-12-03 00:19:56
Assuming I cannot use an ExpandoObject and have to roll my own like so :- class MyObject : DynamicObject { dictionary<string, object> _properties = dictionary<string, object>(); public override bool TryGetMember(GetMemberBinder binder, out object result) { string name = binder.Name.ToLower(); return _properties.TryGetValue(name, out result); } public override bool TrySetMember(SetMemberBinder binder, object value) { _properties[binder.Name.ToLower()] = value; return true; } } and further down the class hierarchy I have class MyNewObject : MyObject { public string Name { get { // do some funky