dynamic

DataGridColumn Binding with Dynamically Generated Data

佐手、 提交于 2019-12-10 22:57:30
问题 I have a large set of data that is generated from a web service in my program. I need to display this data in a DataGrid, but the returned collections of data all have different formats (One may be 3 columns and the next 7) so I cannot create a specific object to hold this data. I am having trouble getting this information to display. Right now I am trying to use this method. I put the data into a two-dimensional list of KeyValuePairs. The Key being the Column this data would belong to, the

DynamicObject binding WRT private types

江枫思渺然 提交于 2019-12-10 22:45:37
问题 Consider the following: using System; using System.Dynamic; namespace DynamicTest { class Program { static void Main(string[] args) { dynamic d = new DynamicTest(); var v = d.foo(); Console.WriteLine(v.Value); Console.ReadKey(); } } public interface IValueProvider<T> { T Value { get; } } public class DynamicTest : DynamicObject { public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { result = new ValueProvider<int>(32); return true; } private class

Why does Delphi call incorrect constructor during dynamic object creation?

纵饮孤独 提交于 2019-12-10 22:38:48
问题 I am having trouble with the incorrect virtual Create() method being called during dynamic object creation. The parent method is called rather than the decendant method. I have reviewed these posts, but can't figure it out: Delphi - Create class from a string Exploring TRTTIType and Descendants Can I pass a Class type as a procedure parameter and here Class_References I have the following classes: TCellObj = class(TPhysicsObj) ... public constructor Create(RgnMgr : TObject); virtual; //RgnMgr

RuntimeBinderException - C# .NET 4 Dynamic Keyword - Help Me Understand Why Method Isn't Matching

风流意气都作罢 提交于 2019-12-10 22:02:06
问题 I've built a generic config system for an HttpModule that allows pluggable HTTP header inspectors. For reference, here is the basic layout of the code -- this should be enough to get a feel for what I'm doing: public interface IHttpHeaderInspectingAuthenticatorFactory<T> where T: HttpHeaderInspectingAuthenticatorConfigurationElement { IHttpHeaderInspectingAuthenticator<T> Construct(T config); } public class BasicAuthenticationInspectingAuthenticatorFactory : IHttpHeaderInspectingAuthenticator

Dynamic class loading with Java

﹥>﹥吖頭↗ 提交于 2019-12-10 21:47:46
问题 I want to dynamically load a concrete class which implements an interface. Input: concrete class name. I need to call a method in this concrete class, that is, I'll need to set: MyInterface myclass = new concreteClassName(); myclass.function(); How can I achieve this? 回答1: have a look at Class.forName(String) String str = "Test$B"; //your full class name here instead of Test$B A clazz = null; //change A to be your interface try { clazz = (A)Class.forName(str).newInstance(); //change A to be

Hiding implementation files in a package

人盡茶涼 提交于 2019-12-10 21:27:27
问题 I have a module called spellnum . It can be used as a command-line utility (it has the if __name__ == '__main__': block) or it can be imported like a standard Python module. The module defines a class named Speller which looks like this: class Speller(object): def __init__(self, lang="en"): module = __import__("spelling_" + lang) # use module's contents... As you can see, the class constructor loads other modules at runtime. Those modules ( spelling_en.py , spelling_es.py , etc.) are located

Using Dynamic Column Names in a Linq Query

為{幸葍}努か 提交于 2019-12-10 21:19:08
问题 foreach (Dimension dimensions in Enum.GetValues(typeof(Dimension))) { var r = new ReferenceTable(dimensions).referenceItems; List<TVRawDataRecord> qry = TVRawDataList.Where(p => !r.Any(d => d.Value == p.BrandVariant)) .ToList(); DimensionItem di = new DimensionItem(qry, dimensions); newDimensions.Add(di); } I am trying to create a Linq query that compares a list of TVRawDataRecords to those in an enum of Dimensions and where there is no match then add them to a new DimensionIem list. This all

Dynamic Wavy Path/Border

二次信任 提交于 2019-12-10 21:11:00
问题 There is something I need to build, but my math ability is not up to par. What I am looking to build is something like this demo, but I need it to be a hybrid of a circle and polygon instead of a line, so to speak. The black line should be dynamic and randomly generated that basically acts as a border on the page. Currently, I am dissecting this answer with the aim of hopefully being able to transpose it into this, but I am having massive doubts that I will be able to figure this out. Any

Using Automapper to Copy Properties from a Dynamic

谁都会走 提交于 2019-12-10 20:58:42
问题 I have a dynamic object (actually, a JObject, from JSON.NET) being built dynamically from JSON. I want to have its properties copied to an existing object. The properties from the dynamic object should exist in the target object's type, if not, it's ok to have an error. I am looking at Automapper, latest version, for this. I tried to create a map from JObject to the proper type, but I don't think it'll work because the properties in the JObject are stored in an internal dictionary. Is this

vb.net deleting lots of dynamically created buttons

别等时光非礼了梦想. 提交于 2019-12-10 20:48:51
问题 I'm a new programmer to vb.net, so apologise for what is likely to be ignorance. I’m building a simple gui for a database interface, with many parent and child items within it. Upon a form I create buttons depending on how many items (parents/children). I've got the creation of the buttons thus: For RowNumber As Integer = 0 To NoOfRows Dim Buttoni As New Button Buttoni.Location = New Point(LocationX, LocationY) Buttoni.Width = 100 Buttoni.Height = 40 Buttoni.Visible = True Buttoni.Text =