What is an elegant way to create and initialise instances of a class that has several readonly properties? Passing all values in a constructor would not be very convenient.
The purpose is that instances are immutable after initialisation. However if the constructor is not used for initialising all the property values, then how can the readonly properties be changed from another class?
This is another one of my "I think it's not possible but I need confirmation" questions.I have a base class for a bunch of child classes. Right now, this base class has a few common properties the children use, like Name. The base is an abstract class (MustInherit)Technically, this means that everytime a child class is instantiated, it lugs around, in memory, its own copy of Name. The thing is, Name is going to be a fixed value for all instances of a given child. I.e., Child1.Name will return "child_object1", and Child2.Name will return "child_object2".
I have a class in which some of the fields are also classes.I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"But the code compiles fine.
dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition dados_Defenicao.arCode = "123" dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error
I have a class in which some of the fields are also classes.
I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"
But the code compiles fine.
dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition dados_Defenicao.arCode = "123" dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error
I wrote a function that copies the properties of one class to another so make a copy of an object.So something like
MyObject myObject = myOtherObject.MyCustomCopy(myObject) where myObject and myOtherObject are of the same type. I do it by bascually doing myObject.prop1 = myOtherObject.prop1
[code]....
I am pretty sure in the past I used a .NET object that automaticaly did this, by reflection I guess, but can't remember it ... or an I imagining that such a method exists?
I am sort of new to MVC so pardon my ignorance. I am using IoC ( StructureMap ) and I have a need to pass in an instance of what I consider to be a set of Controls to each view, so I have created ViewModels in order to accomodate this. The view model is populated with an instance of the Controls and the View is then rendered. When a user performs a POST, the Controls are not being passed back to the Action.
Im trying to bulk update. I want to use viewmodel pattern. I read this article and create program. Program show Database value and html looks ok. But After submit, Controller couldn't get values. Every values are 'Nothing' please point me where I missunderstanding.
Public Class users Public id As String Public username As String
I have been getting up to speed with the MVVM pattern in Silverlight and was wondering how to implement binding from the View to the ViewModel when the ViewModel constructor has a parameter if an interface type.If I bind the viewmodel to the view in XAML then you can not use a parameterised constructor. Given that I was creating a default constructor passing an instance to the parameterised constructor but this breaks the abstraction.
I'm attempting to improve my MVVM abilities in my next WP7 App (which is written in Vb.NET). I have a textbox that has been given focus and has a WP7 keyboard displayed. I am using command binding and a xyzzer's bindable Application bar (which is excellent).[URL] I want to be able to cancel the focus of the TextBox from the ViewModel, by setting focus on the form. Normally (Non MVVM) I would do this from within the form by calling:
I am trying to create a Public Sub / Function that will allow me to pass certain variables into it and this will affect the output. e.g. DIV ID = InfoDiv CSS Class = "Warning" LBInfoMsg.Text = "An Error has occured" DIV Visibility = True or False
I would like to type something similar in the code behind page: InfoMsg(InfoDiv, "warning", "An Error has Occurred", True)
Public Sub InfMsg(ByRef MyDIV As System.Web.UI.HtmlControls.HtmlGenericControl, ByRef CSS As System.Web.UI.WebControls.Style, ByVal strMessage As String) strMessage = strMessage.Replace("'", "''") MyDIV.Attributes.Add("Style", "warning") MyDIV.Visible = "True" End Sub
I've createda vb.net class library where I've defined a number of small classes... nothing complicated, just working with strings, sending emails, etc.In another project, I reference the class library and I'm seemingly able to create an instance ofone of tclasses - intellisense shows me all of the plic properties, methods, etc... all looks perfect. No compile errors at all, nothing b gumdropsand lollipops.When I run the app I'm working on that references the class library, it fails at the point where I'm creating an instance of the class and gives me a vague exception, "System.TypeLoadException".
I'm trying to elaberate on some basic examples of .Net programming in using VB. The basic example of creating a new instance of Form1 is: Dim x as New Form1 x.Show I've added some OptionButtons to set the StartPosition of the Next Instance of Form1 as well as some Labels that display the Top, Left, Width and Height properties when the new instance of Form1 is Shown.
This is the code I'm using. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As New Form1 If Me.RadioButton1.Checked = True Then x.Top = 0 x.Left = 0 [Code] ......
Something that has been confusing me for a while now with WPF MVVM is for example, when I have a base model containing nothing but a few properties and some validation code and I then build a view model around this base model, how should the view model be structured.
For Example:
Base Model -> Imports ModellingHelper Imports FTNHelper
[Code]....
What I am wondering is, if there is a better way to structure the view model to improve data binding, so I don't have to bind to Source.Name etc. How should I handle the base model in the view model?
I was wondering if there is a way of making a picture have the properties of a checkbox. I want to have clickable stars that change color (from white to yellow) everytime the user clicks on them to represent the rating they put on certain foods.
as you might guess from the variable names I'm making a game (but this problem isn't game related!) which involves multiple "bullets" moving along straight trajectories. This is my attempt at changing my code for firing one bullet into one for firing many bullets at once. It works perfectly except for one thing.The class I made (BulletClass) to contain all the things needed to move the bullet isn't setting all of its properties correctly. I apologise for the walls of code however I wasn't entirely sure whether I should chop bits out. I wanted to colour code my code so that you could scroll through and see the subs where things have gone wrong, but apparently I can't even code a new thread. Let alone a video game. Instead I'll just list them, you can search for them if you like or just scroll through at your leisure.
[Code]...
In a nutshell: the properties TargetPosY, TargetPosX, ShipPosX and ShipPoseY are not working properly. As a result the calculations involving them are skewed and the bullets always travel directly downward.
I've got a Dictionary collection of a certain class with dozens of string properties.i'd like to create a datatable from this info and map these properties into Datatable columns, and for each member of the dictionary maps it to a row...
i could type out column names based on the class properties, but thats a bit specific and hard coded.
What I want to do is something like
Dim mytable as datatable For each string_property as property of myclass Dim column as new datacolumn(string_property.name) 'column add to table etc Next I'm unfamiliar with how to do this, maybe the Reflection classes are useful - perhaps the guru's can point out an efficient solution?
Is there a way to clear all the properties in a class, because i have a class where all my properties were stored, can i clear all those in just a short code?
I've tried searching... a lot for the answer, but as I'm not too sure what exactly I'm trying to do I can't seem to find anything. I'm trying to write a dll in order to handle errors thrown from a vb.net app. In the dll I need several forms (I'm not totally sure if they can have forms - I'm a bit of a newbie when it comes to dll's) for which the user can type in their message about the error and submit it.
I have dynamic class with varied numbers of property. At one time I need to save all data from this class. So, to do the For/Next or Do/Loop, I need to know, how many properties in class for now? Is it possible to findout the property numbers and after - property names list?
For example. I have a class INI, were was .Path as preexisted property. Then the few properties has been added and INI start consist of .Path, .Size, .Color and something else.
I dont want to keep in mind all properties has been added. All I want to get some simple loop to read all properties names and values to dump it to the file. Some sort of this[code]...
I am filling a form with values from a class, which is working fine. But now I want to take the changed values in the text box and modify the class. For some reason I have not been able to get the syntax.
I have created a class named CustomerType - CustomerTyp, which includes 4 properties - ID, Name, Number, Selected. I need to make a code, which determines how many properties has the class.
How can I get all the properties of a class that implement a specific base class or interface? I have a properties class that contains several other property classes. Some, not all, of these classes implement an interface. I would like to know if it's possible to iterate over all properties of parent class for child-classes that implement the target interface. It sounds like a job for reflection? I'm just not sure how. Can it be done via the "PropertyInfo" object?
I have an app with my own class "something".So, Im going to one of the my modules and declare public var as a class. After fillup this class by date, I would to get this date from the other module of my app. But there this var is unavailavle (its mean I have to redeclare it again. Its mean I'll lost
Whats the best way to iteract through a class to get all the properties names? So far i have this code
Dim classInstance As New ServiceReference1.draftClaimEntryDefinition For Each PropertyItem As PropertyInfo In classInstance.GetType().GetProperties() Dim strPropName As String = String.Empty[code]....
My problem is: I will receive a xml file, and have to get the data in a class, but as mentioned before the class has a lot of classes as properties, and i want do do it without hardcode, I want to loop the class properties names and compare them to the xml tags (it haves the same name as the class properties), and put the values from the xml file in an instance object of the class.
Code: Public Class Customer Public Property AccountNumber() As String Public Property AccountCreationDate() As String
[code].....
This works but I tried to loop thru the properties of the class with a For Each/Next loop. It does not work as the intellisense won't co-operate with Items I think i need like "PropertyInfo" . After reading, I see that only thru Reflection can I do this. Well, Reflection has me baffled at the moment.