Search Results

Search found 16162 results on 647 pages for 'property attribute'.

Page 5/647 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • change a frame's attribute by pressing a button

    - by asavu
    Hi. Suppose we have a JFrame named frame1 with a String attribute named credentials set inittially to null. I have a jButton named button1 attached to the frame and I want to change the frame1 String credentials attribute by pressing button1. I need some piece of advice regarding the ActionListener code especially. Could you guys pls help me? Thank you.

    Read the article

  • MVC 3 AdditionalMetadata Attribute with ViewBag to Render Dynamic UI

    - by Steve Michelotti
    A few months ago I blogged about using Model metadata to render a dynamic UI in MVC 2. The scenario in the post was that we might have a view model where the questions are conditionally displayed and therefore a dynamic UI is needed. To recap the previous post, the solution was to use a custom attribute called [QuestionId] in conjunction with an “ApplicableQuestions” collection to identify whether each question should be displayed. This allowed me to have a view model that looked like this: 1: [UIHint("ScalarQuestion")] 2: [DisplayName("First Name")] 3: [QuestionId("NB0021")] 4: public string FirstName { get; set; } 5: 6: [UIHint("ScalarQuestion")] 7: [DisplayName("Last Name")] 8: [QuestionId("NB0022")] 9: public string LastName { get; set; } 10: 11: [UIHint("ScalarQuestion")] 12: [QuestionId("NB0023")] 13: public int Age { get; set; } 14: 15: public IEnumerable<string> ApplicableQuestions { get; set; } At the same time, I was able to avoid repetitive IF statements for every single question in my view: 1: <%: Html.EditorFor(m => m.FirstName, new { applicableQuestions = Model.ApplicableQuestions })%> 2: <%: Html.EditorFor(m => m.LastName, new { applicableQuestions = Model.ApplicableQuestions })%> 3: <%: Html.EditorFor(m => m.Age, new { applicableQuestions = Model.ApplicableQuestions })%> by creating an Editor Template called “ScalarQuestion” that encapsulated the IF statement: 1: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2: <%@ Import Namespace="DynamicQuestions.Models" %> 3: <%@ Import Namespace="System.Linq" %> 4: <% 5: var applicableQuestions = this.ViewData["applicableQuestions"] as IEnumerable<string>; 6: var questionAttr = this.ViewData.ModelMetadata.ContainerType.GetProperty(this.ViewData.ModelMetadata.PropertyName).GetCustomAttributes(typeof(QuestionIdAttribute), true) as QuestionIdAttribute[]; 7: string questionId = null; 8: if (questionAttr.Length > 0) 9: { 10: questionId = questionAttr[0].Id; 11: } 12: if (questionId != null && applicableQuestions.Contains(questionId)) { %> 13: <div> 14: <%: Html.Label("") %> 15: <%: Html.TextBox("", this.Model)%> 16: </div> 17: <% } %> You might want to go back and read the full post in order to get the full context. MVC 3 offers a couple of new features that make this scenario more elegant to implement. The first step is to use the new [AdditionalMetadata] attribute which, so far, appears to be an under appreciated new feature of MVC 3. With this attribute, I don’t need my custom [QuestionId] attribute anymore - now I can just write my view model like this: 1: [UIHint("ScalarQuestion")] 2: [DisplayName("First Name")] 3: [AdditionalMetadata("QuestionId", "NB0021")] 4: public string FirstName { get; set; } 5:   6: [UIHint("ScalarQuestion")] 7: [DisplayName("Last Name")] 8: [AdditionalMetadata("QuestionId", "NB0022")] 9: public string LastName { get; set; } 10:   11: [UIHint("ScalarQuestion")] 12: [AdditionalMetadata("QuestionId", "NB0023")] 13: public int Age { get; set; } Thus far, the documentation seems to be pretty sparse on the AdditionalMetadata attribute. It’s buried in the Other New Features section of the MVC 3 home page and, after showing the attribute on a view model property, it just says, “This metadata is made available to any display or editor template when a product view model is rendered. It is up to you to interpret the metadata information.” But what exactly does it look like for me to “interpret the metadata information”? Well, it turns out it makes the view much easier to work with. Here is the re-implemented ScalarQuestion template updated for MVC 3 and Razor: 1: @{ 2: object questionId; 3: ViewData.ModelMetadata.AdditionalValues.TryGetValue("QuestionId", out questionId); 4: if (ViewBag.applicableQuestions.Contains((string)questionId)) { 5: <div> 6: @Html.LabelFor(m => m) 7: @Html.TextBoxFor(m => m) 8: </div> 9: } 10: } So we’ve gone from 17 lines of code (in the MVC 2 version) to about 7-8 lines of code here. The first thing to notice is that in MVC 3 we now have a property called “AdditionalValues” that hangs off of the ModelMetadata property. This is automatically populated by any [AdditionalMetadata] attributes on the property. There is no more need for me to explicitly write Reflection code to GetCustomAttributes() and then check to see if those attributes were present. I can just call TryGetValue() on the dictionary to see if they were present. Secondly, the “applicableQuestions” anonymous type that I passed in from the calling view – in MVC 3 I now have a dynamic ViewBag property where I can just “dot into” the applicableQuestions with a nicer syntax than dictionary square bracket syntax. And there’s no problems calling the Contains() method on this dynamic object because at runtime the DLR has resolved that it is a generic List<string>. At this point you might be saying that, yes the view got much nicer than the MVC 2 version, but my view model got slightly worse.  In the previous version I had a nice [QuestionId] attribute but now, with the [AdditionalMetadata] attribute, I have to type the string “QuestionId” for every single property and hope that I don’t make a typo. Well, the good news is that it’s easy to create your own attributes that can participate in the metadata’s additional values. The key is that the attribute must implement that IMetadataAware interface and populate the AdditionalValues dictionary in the OnMetadataCreated() method: 1: public class QuestionIdAttribute : Attribute, IMetadataAware 2: { 3: public string Id { get; set; } 4:   5: public QuestionIdAttribute(string id) 6: { 7: this.Id = id; 8: } 9:   10: public void OnMetadataCreated(ModelMetadata metadata) 11: { 12: metadata.AdditionalValues["QuestionId"] = this.Id; 13: } 14: } This now allows me to encapuslate my “QuestionId” string in just one place and get back to my original attribute which can be used like this: [QuestionId(“NB0021”)]. The [AdditionalMetadata] attribute is a powerful and under-appreciated new feature of MVC 3. Combined with the dynamic ViewBag property, you can do some really interesting things with your applications with less code and ceremony.

    Read the article

  • C#: Cached Property: Easier way?

    - by Peterdk
    I have a object with properties that are expensive to compute, so they are only calculated on first access and then cached. private List<Note> notes; public List<Note> Notes { get { if (this.notes == null) { this.notes = CalcNotes(); } return this.notes; } } I wonder, is there a better way to do this? Is it somehow possible to create a Cached Property or something like that in C#?

    Read the article

  • Grails Date Property Editor

    - by Jan
    Hey folks, i'm using the jQuery UI datepicker instead of the <g:datePicker>, which is changing the selected date in a textbox. Now I want to save this neatly back into my database, and came across custom property editors. click me hard to see the topic on StackOverflow However, adding this custom PropertyEditor didn't change anything, dates are still displayed like '2010-01-01 00:00:00.0' and if I try to save a date it crashes with Cannot cast object '05.05.2010' with class 'java.lang.String' to class 'java.util.Date'. Is there any additional magic needed, like a special naming of the textbox or something like that? Thanks for your help, Jan

    Read the article

  • Binding a dependency property to another dependency property

    - by Rire1979
    Take this scenario where I am working with a grid like control: <RadGrid DataContext={Binding someDataContextObject, Mode=OneWay}> <RadGrid.columns> <RadGrid.Column Header="Column Header" DataMember="{Binding dataContextObjectProperty, Mode=OneWay}"> [...] <DataTemplate> <MyCustomControl Data="{Binding ???}" /> </DataTemplate> <\RadGrid.Column> </RadGrid.columns> </RadGrid> I would like to bind the Data dependency property of MyCustomControl to the DataMember dependency property of the column to avoid multiple bindings to the same data. How do I do it?

    Read the article

  • Ontology - Conflict of same individuals property and datatype property

    - by blueomega
    I am having a problem with "same individuals property" in protege, when i run a reasoner (pellet 1.5 or fact++) Lets take ontology example thing has class sons A and B, A has sons C and D. B, C and D have individuals of the same class. Cant i say a individual C is "same individual" as individual B, and then add also individual D is "same individual" as individual B. Wich is true, they have diferent names, but they are same individual.. Why does it only work when i set individual B has "same individual" of type C or D? The protege error is "InconsistentOntologyException:Fact++.Kernel: inconsistent Ontology" and pellet says ontology is inconsistent. EDIT: Seems its a more deep rooted problem, this example works :(, gonna keep checking. EDIT2: After some more experimenting, seems its a conflict with DataType properties. They all share a DataType properties with same name. In the example domain of property would be A and range string. Any idea how to solve?

    Read the article

  • how to create property of type generic class?

    - by Anish
    public class SelectionList<T> : ObservableCollection<SelectionItem<T>> where T : IComparable<T> { // Code } public class SelectionItem<T> : INotifyPropertyChanged { // Code } I need to create a property which is of the type SelectionList...as follows: public SelectionList<string> Sports { get; set; }. But when I replace string with DataRowView, as public SelectionList<DataRowView> Sports { get; set; }. I am getting error. Please help

    Read the article

  • Elegantly Handle Repetitive Property Code in C#

    - by Eric J.
    The language shortcut public string Code { get; set; } saves a bit of typing when defining trivial properties in C#. However, I find myself writing highly repetitive, not-quite-as-trivial property code that still follows a clear pattern e.g. public string Code { get { return code; } set { if (code != value) { code = value; NotifyPropertyChanged("Code"); } } } I can certainly define a Visual Studio snippet to reduce typing. However, if I need to add something to my pattern, I have to go back and change quite a bit of existing code. Is there a more elegant approach? Is a snippet the best way to go?

    Read the article

  • iphone @property(retain), init(), and standards

    - by inyourcorner
    I'm new to the memory management of the iphone and had a question about standards/correctness. My header file declares: IBOutlet UITabBarController *tabBarController; @property (nonatomic, retain) UITabBarController *tabBarController; In my init() code I was doing something like the following: self.tabBarController = [[UITabBarController alloc] init]; [tabBarController release]; NSLog(@"Retain count of tbc: %d",[tabBarController retainCount]); to get the retain count back to one. Is this correct from a standardization point of view? It just looked a bit different to me, but again I'm new to this. Thanks

    Read the article

  • Pointer to another classs as a property

    - by arjacsoh
    Why I receive an error when I try to create a property to another class through a pointer like that: #ifndef SQUARE_H #define SQUARE_H #include <string> //using namespace std; #include "Player.h" class Square { public: Square(int); void process(); protected: int ID; Player* PlayerOn; <--- }; #endif and the Player class is : #ifndef PLAYER_H #define PLAYER_H #include <string> //using namespace std; #include "Square.h" class Player { public: Player(int,int); // ~Player(void); int playDice(); private: int ID; int money; }; #endif I receive: syntax error missing ; before * (on the declaration of Player* PlayerOn;) and missing type specifier (on the same line...)

    Read the article

  • CSS Attribute selector - Match attribute values that begin with

    - by LuckyShot
    I am trying to identify all the <UL> that contain a menu list by defining the ID like this: <ul id="menutop"> <li><a href="#">item1</a></li> <li><a href="#">item2</a></li> <li><a href="#">item3</a></li> </ul> <ul id="menumain"> <li><a href="#">item1</a></li> <li><a href="#">item2</a></li> <li><a href="#">item3</a></li> </ul> As per what I understand, I could use: ul[id|='menu']>li>a {color:#f00;} (<a> direct child of a <li> direct child of an <ul> that has its id starting with menu) But it doesn't work. Searching a bit brought me this [question][1] which suggests that ID is an attribute and not a property so I don't get why it isn't working. What am I doing wrong? Here's a link to the CSS2 Matching attributes and attribute values as per the W3 standards ( http://www.w3.org/TR/CSS2/selector.html#matching-attrs ).

    Read the article

  • Entity Framework - adding new items via a navigation property

    - by Robert
    I have come across what appears to be very peculiar behaviour using entity framework 4.0. I have a User entity, which has a Company (A Company has many Users). If I do this, everything works as expected and I get a nice shiny new user in the database: var company = _model.Companies.First(); company.Users.Add(new User(1, "John", "Smith")); _model.SaveChanges(); However, if I do this, then I get nothing new in the database, and no exceptions thrown: var existingUser = _model.Users.First(); var company = existingUser.Company; company.Users.Add(new User(1, "John", "Smith")); _model.SaveChanges(); So it appears that if I add a User to the Company that is pulled directly from the model, then everything works fine. However if the User is added to a Company that is pulled as a navigation property of another object, then it doesn't work. Can someone tell me if this is expected behaviour, or if there is something I can do to make it so that it is? Thanks!

    Read the article

  • How to access/use custom attribute in spring security based CAS client

    - by Bill Li
    I need send certain attributes(say, human readable user name) from server to client after a successful authentication. Server part was done. Now attribute was sent to client. From log, I can see: 2010-03-28 23:48:56,669 DEBUG Cas20ServiceTicketValidator:185 - Server response: [email protected] <cas:proxyGrantingTicket>PGTIOU-1-QZgcN61oAZcunsC9aKxj-cas</cas:proxyGrantingTicket> <cas:attributes> <cas:FullName>Test account 1</cas:FullName> </cas:attributes> </cas:authenticationSuccess> </cas:serviceResponse> Yet, I don't know how to access the attribute in client(I am using Spring security 2.0.5). In authenticationProvider, a userDetailsService is configured to read db for authenticated principal. <bean id="casAuthenticationProvider" class="org.springframework.security.providers.cas.CasAuthenticationProvider"> <sec:custom-authentication-provider /> <property name="userDetailsService" ref="clerkManager"/> <!-- other stuff goes here --> </bean> Now in my controller, I can easily do this: Clerk currentClerk = (Clerk)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); Ideally, I can fill the attribute to this Clerk object as another property in some way. How to do this? Or what is recommended approach to share attributes across all apps under CAS's centralized nature?

    Read the article

  • IE: Undocumented "cache" attribute defined for input elements?

    - by aefxx
    Hi everybody. I've stumpled upon a strange behavior in IE(6/7/8) that drives me nuts. Given the following markup: <input type="text" value="foo" class="bar" cache="yes" send="no" /> Please note that the cache attribute is set to yes. However IE somehow manages to change the attributes value to cache="cache" when rendering the DOM. So, I wonder, is there an undocumented feature that I'm not aware of? I've googled about an hour now but couldn't find any info on this (not even on MSDN). NOTE I'm aware that adding custom attributes is non-standard compliant and that boolean attributes should be noted as attribute="attribute. Nevertheless I have to cope with these as they were introduced long before I joined the team. These custom attributes are used in conjunction with javascript to provide a more user friendly approach to form handling (and it works out quite well with Firefox/Safari/Opera/Chrome). I know that I could simply convert these custom attributes to x-data attributes that will be introduced with HTML5 but that would take me several hours of extra work - sigh. Hope, I made myself clear. Thanks in advance.

    Read the article

  • why is the <img> alt attribute not always properly displayed

    - by Piero
    So I have this php script that output an html table with data about some files (like filename, filesize, etc...) I have this javascript function that displays the picture when you hover a tag belonging to the class "preview". For example, if a filename is: somePic.jpg, when you hover somePic.jpg in the table, the picture will appear next to your mouse. Now not all these files are pictures, some are .mp3, so of course when you hover them, the javascript cannot display the picture. To deal with this case, I added in the tag (generated by the javascript function), an alt attribute: alt='Preview not available for this type of content.' And here is my problem, sometimes it works, but sometimes it doesn't! Sometimes you start hovering .mp3 links, and the alt attribute is displayed, then you hover a picture, the picture is displayed, then you hover an .mp3 again, and the alt isn't displayed anymore, but the "broken image" image (the little red cross) is displayed instead... Sure I could parse the filenames and detect when it's an mp3 and then deal with the case, but I thought the alt attribute was suppose to achieve this... but it's buggy... Any idea? Does anyone already faced this problem?

    Read the article

  • property names are different from original Object in the silverlight

    - by kwon
    Following is part of service layer which is provided by WCF service : [Serializable] public class WaitInfo { private string roomName; private string pName; private string tagNo; public string RoomName { get { return roomName; } set { this.roomName = value; } } public string PName { get { return pName; } set { this.pName = value; } } public string TagNo { get { return tagNo; } set { this.tagNo = value; } } } public class Service1 : IService1 { public List<WaitInfo> GetWaitingList() { MyDBDataContext db = new MyDBDataContext(); var query = from w in db.WAIT_INFOs select new WaitInfo { TagNo = w.PATIENT_INFO.TAG_NO, RoomName= w.ROOM_INFO.ROOM_NAME, PName= w.PATIENT_INFO.P_NAME }; List<WaitInfo> result = query.ToList(); return result; } And following is codebehind part of UI layer which is provided by Silverlight public MainPage() { InitializeComponent(); Service1Client s = new Service1Client(); s.GetWaitingListCompleted += new EventHandler<GetWaitingListByCompletedEventArgs>( s_GetWaitingListCompleted); s.GetWaitingListAsync(); } void s_GetWaitingListCompleted(object sender, RadControlsSilverlightApplication1.ServiceReference2.GetWaitingListByCompletedEventArgs e) { GridDataGrid.ItemsSource = e.Result; } And following is xaml code in Silverlight page <Grid x:Name="LayoutRoot"> <data:DataGrid x:Name="GridDataGrid"></data:DataGrid> </Grid> Is is very simple code, however what I am thinking weird is property name of object at "e.Result" in the code behind page. In the service layer, although properties' names are surely "RoomName, PName, TagNo", in the silverlight properties' names are "roomName, pName, tagNo" which are private variable name of the WaitingList Object. Did I something wrong? Thanks in advance.

    Read the article

  • Creating Property Set Expression Trees In A Developer Friendly Way

    - by Paulo Morgado
    In a previous post I showed how to create expression trees to set properties on an object. The way I did it was not very developer friendly. It involved explicitly creating the necessary expressions because the compiler won’t generate expression trees with property or field set expressions. Recently someone contacted me the help develop some kind of command pattern framework that used developer friendly lambdas to generate property set expression trees. Simply putting, given this entity class: public class Person { public string Name { get; set; } } The person in question wanted to write code like this: var et = Set((Person p) => p.Name = "me"); Where et is the expression tree that represents the property assignment. So, if we can’t do this, let’s try the next best thing that is splitting retrieving the property information from the retrieving the value to assign o the property: var et = Set((Person p) => p.Name, () => "me"); And this is something that the compiler can handle. The implementation of Set receives an expression to retrieve the property information from and another expression the retrieve the value to assign to the property: public static Expression<Action<TEntity>> Set<TEntity, TValue>( Expression<Func<TEntity, TValue>> propertyGetExpression, Expression<Func<TValue>> valueExpression) The implementation of this method gets the property information form the body of the property get expression (propertyGetExpression) and the value expression (valueExpression) to build an assign expression and builds a lambda expression using the same parameter of the property get expression as its parameter: public static Expression<Action<TEntity>> Set<TEntity, TValue>( Expression<Func<TEntity, TValue>> propertyGetExpression, Expression<Func<TValue>> valueExpression) { var entityParameterExpression = (ParameterExpression)(((MemberExpression)(propertyGetExpression.Body)).Expression); return Expression.Lambda<Action<TEntity>>( Expression.Assign(propertyGetExpression.Body, valueExpression.Body), entityParameterExpression); } And now we can use the expression to translate to another context or just compile and use it: var et = Set((Person p) => p.Name, () => name); Console.WriteLine(person.Name); // Prints: p => (p.Name = “me”) var d = et.Compile(); d(person); Console.WriteLine(person.Name); // Prints: me It can even support closures: var et = Set((Person p) => p.Name, () => name); Console.WriteLine(person.Name); // Prints: p => (p.Name = value(<>c__DisplayClass0).name) var d = et.Compile(); name = "me"; d(person); Console.WriteLine(person.Name); // Prints: me name = "you"; d(person); Console.WriteLine(person.Name); // Prints: you Not so useful in the intended scenario (but still possible) is building an expression tree that receives the value to assign to the property as a parameter: public static Expression<Action<TEntity, TValue>> Set<TEntity, TValue>(Expression<Func<TEntity, TValue>> propertyGetExpression) { var entityParameterExpression = (ParameterExpression)(((MemberExpression)(propertyGetExpression.Body)).Expression); var valueParameterExpression = Expression.Parameter(typeof(TValue)); return Expression.Lambda<Action<TEntity, TValue>>( Expression.Assign(propertyGetExpression.Body, valueParameterExpression), entityParameterExpression, valueParameterExpression); } This new expression can be used like this: var et = Set((Person p) => p.Name); Console.WriteLine(person.Name); // Prints: (p, Param_0) => (p.Name = Param_0) var d = et.Compile(); d(person, "me"); Console.WriteLine(person.Name); // Prints: me d(person, "you"); Console.WriteLine(person.Name); // Prints: you The only caveat is that we need to be able to write code to read the property in order to write to it.

    Read the article

  • Calling "Base-Getter" in Overriding Getter of Property

    - by scherand
    I have a base class "Parent" like this: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Parent { private int parentVirtualInt = -1; public virtual int VirtualProperty { get { return parentVirtualInt; } set { if(parentVirtualInt != value) { parentVirtualInt = value; } } } } } and a child class like this: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Child : Parent { public override int VirtualProperty { get { if(base.VirtualProperty > 0) { throw new ApplicationException("Dummy Ex"); } return base.VirtualProperty; } set { if(base.VirtualProperty != value) { base.VirtualProperty = value; } } } } } Note that the getter in Child is calling the getter of Parent (or at least this is what I intend). I now use the "Child" class by instantiating it, assigning a value (let's say 4) to its VirtualProperty and then reading the property again. Child c = new Child(); c.VirtualProperty = 4; Console.Out.WriteLine("Child.VirtualProperty: " + c.VirtualProperty); When I run this, I obviously get an ApplicationException saying "Dummy Ex". But if I set a breakpoint on the line if(base.VirtualProperty > 0) in Child and check the value of base.VirtualProperty (by hovering the mouse over it) before the exception can be thrown (I assume(d)), I already get the Exception. From this I convey that the statement base.VirtualProperty in the "Child-Getter calls itself"; kind of. What I would like to achieve is the same behavior I get when I change the definition of parentVirutalInt (in Parent) to protected and use base.parentVirtualInt in the Getter of Child instead of base.VirtualProperty. And I don't yet see why this is not working. Can anybody shed some light on this? I feel that overridden properties behave differently than overridden methods? By the way: I am doing something very similar with subclassing a class I do not have any control over (this is the main reason why my "workaround" is not an option). Kind regards

    Read the article

  • Silverlight: Binding a child controls property to a property in a user control

    - by Jeremy
    If I have a user control defined: public partial class MainFooter : UserControl { public System.Windows.Media.Color BkColor; } and it's xaml: <UserControl x:Class="Test.MainFooter"> <Grid x:Name="LayoutRoot"> <Rectangle x:Name="rctBottom_Background2" HorizontalAlignment="Stretch" Grid.Row="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0.82,0.895" StartPoint="0.911,-0.442"> <GradientStop Color="{**How can I bind this to the BkColor property?}"/**> <GradientStop Color="#00FFFFFF" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> </Grid> </UserControl> and used: <MyControls:MainFooter x:Name="rcrMainFooter" BkColor="#FFE2B42A"> </MyControls:MainFooter> How would I go about binding the GradientStop Color in the Rectangle to the value of the it's user controls BkColor property?

    Read the article

  • .NET asmx web services: serialize object property as string property to support versioning

    - by mcliedtk
    I am in the process of upgrading our web services to support versioning. We will be publishing our versioned web services like so: http://localhost/project/services/1.0/service.asmx http://localhost/project/services/1.1/service.asmx One requirement of this versioning is that I am not allowed to break the original wsdl (the 1.0 wsdl). The challenge lies in how to shepherd the newly versioned classes through the logic that lies behind the web services (this logic includes a number of command and adapter classes). Note that upgrading to WCF is not an option at the moment. To illustrate this, let's consider an example with Blogs and Posts. Prior to the introduction of versions, we were passing concrete objects around instead of interfaces. So an AddPostToBlog command would take in a Post object instead of an IPost. // Old AddPostToBlog constructor. public AddPostToBlog(Blog blog, Post post) { // constructor body } With the introduction of versioning, I would like to maintain the original Post while adding a PostOnePointOne. Both Post and PostOnePointOne will implement the IPost interface (they are not extending an abstract class because that inheritance breaks the wsdl, though I suppose there may be a way around that via some fancy xml serialization tricks). // New AddPostToBlog constructor. public AddPostToBlog(Blog blog, IPost post) { // constructor body } This brings us to my question regarding serialization. The original Post class has an enum property named Type. For various cross-platform compatibility issues, we are changing our enums in our web services to strings. So I would like to do the following: // New IPost interface. public interface IPost { object Type { get; set; } } // Original Post object. public Post { // The purpose of this attribute would be to maintain how // the enum currently is serialized even though now the // type is an object instead of an enum (internally the // object actually is an enum here, but it is exposed as // an object to implement the interface). [XmlMagic(SerializeAsEnum)] object Type { get; set; } } // New version of Post object public PostOnePointOne { // The purpose of this attribute would be to force // serialization as a string even though it is an object. [XmlMagic(SerializeAsString)] object Type { get; set; } } The XmlMagic refers to an XmlAttribute or some other part of the System.Xml namespace that would allow me to control the type of the object property being serialized (depending on which version of the object I am serializaing). Does anyone know how to accomplish this?

    Read the article

  • How to get attribute value using SelectSingleNode?

    - by Nano HE
    I am parsing a xml document, I need find out the gid (an attribute) value (3810). Based on SelectSingleNode(). I found it is not easy to find the attribute name and it's value. Can I use this method or I must switch to other way. Attached my code. How can I use book obj to get the attribute value3810 for gid. Thank you. My test.xml file as below <?xml version="1.0" ?> <root> <VersionInfo date="2007-11-28" version="1.0.0.2" /> <Attributes> <AttrDir name="EFEM" DirID="1"> <AttrDir name="Aligner" DirID="2"> <AttrDir name="SequenceID" DirID="3"> <AttrObj text="Slot01" gid="3810" unit="" scale="1" /> <AttrObjCount value="1" /> </AttrDir> </AttrDir> </AttrDir> </Attributes> </root> I wrote the test.cs as below public class Sample { public static void Main() { XmlDocument doc = new XmlDocument(); doc.Load("test.xml"); XmlNode book; XmlNode root = doc.DocumentElement; book = root.SelectSingleNode("Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]"); Console.WriteLine("Display the modified XML document...."); doc.Save(Console.Out); } } [Update 06/10/2010] The xml file is a complex file. Included thousands of gids. But for each of Xpath, the gid is unique. I load the xml file to a TreeView control. this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);. When treeView1_AfterSelect event occurred, the e.Node.FullPath will return as a String Value. I parse the string Value e.Node.FullPath. Then I got the member of XPath Above. Then I tried to find which gid item was selected. I need find the gid value as a return value indeed.

    Read the article

  • Calling Property Methods from the e.PropertyName property

    - by user275561
    void TheSettings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var settings = IsolatedStorageSettings.ApplicationSettings[StorageSettings] as Dictionary<string, string>; settings[e.PropertyName]= //call the method that has the same property name to get what the value is LoadData(); } Here is What I am trying to do. This is for a Windows Phone 7 series App. I am trying to determine what values got changed when the user changes the settings on the settings page and just save that.

    Read the article

  • get xml attribute named xlink:href using xsl

    - by awe
    How can I get the value of an attribute called xlink:href of an xml node in xsl template? I have this xml node: <DCPType> <HTTP> <Get> <OnlineResource test="hello" xlink:href="http://localhost/wms/default.aspx" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" /> </Get> </HTTP> </DCPType> When I try the following xsl, I get an error saying "Prefix 'xlink' is not defined." : <xsl:value-of select="DCPType/HTTP/Get/OnlineResource/@xlink:href" /> When I try this simple attribute, it works: <xsl:value-of select="DCPType/HTTP/Get/OnlineResource/@test" />

    Read the article

  • Using Linq to SQL change events with attribute-based mapping

    - by R Mene
    I'm writing a new ASP.NET MVC2 application using Linq to SQL. This application depends on an existing SQL database. I am using attribute-based mapping to map my database fields to my Linq to SQL entities. I also need to make use of Linq to SQL's On[Property]Changed methods so I can perform change-auditing of database tables within my application. Whereas the documentation explains how to do this when using Linq to SQL's ORM and dbml files (i.e. by writing partial classes), it is not clear how to do with when using attribute-based mapping or when using XML-based mapping. It would be very helpful if someone could describe how to do this.

    Read the article

  • remove json attribute where attribute is a variable

    - by pedalpete
    I have a news feed where items in the feed are created from JSON returned from a server. When the user takes an action on an item, I want to remove it from the object via javascript. The feed looks like this: {"newsFeed":[{"feedId":"1", "title":"item1 title", "desc":"description of the item"}, {"feedId":"2", "title":"item2 title", "desc":"description of the item"}]} I'm trying to remove a JSON attribute or entry where the feedId is passed in via a variable using jQuery. I'm not sure exactly where I'm going wrong here, but when I alert the feed before and after the removal of the object, I'm getting the same response: function removeFromFeed(feedId){ var newsFeed=jQuery('div#newsFeed').data('newsFeed'); alert(newsFeed.toSource()); delete newsFeed.feedId[feedId] jQuery('div#newsFeed').data('newsFeed',newsFeed); alert(newsFeed.toSource()); }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >