.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

IEditableObject on classes with collection properties?

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :WPF
 
I have a question about the IEditableObject interface. In general it makes great sense. But what happens if you have complex classes that have nested objects or collections properties? What level of property changes are you supposed to be able to cancel?For discussion, let's say you have an "Order" class with a "Name" property and a "OrderLineItems" property that's a collection of "OrderLineItem". Each "OrderLineItem" has a "Quantity", "Description", and "Amount" property. Both classes implement IEditableObject.It's straightforward that if you call Order.BeginEdit, change Order.Name, and call Order.CancelEdit, then Order.Name will have it's original value. This is the normal case and why IEditableObject exists.But what if you call Order.BeginEdit, remove Order.OrderLineItems[0], and call Order.CancelEdit? Should the removed OrderLineItem be restored to the collection?What if you modify Order.OrderLineItems[0].Quantity? Should Order.CancelEdit restore that value? Perhaps Order.BeginEdit() should be calling BeginEdit() on each of it's children?I guess I'm wondering just how deep IEditableObject is expected to go? The MSDN documentation doesn't cover any of this. Any thoughts?SBussinger


View Complete Post


More Related Resource Links

Public properties of collection derived classes are not deserialized in REST wcf service

  

I have Restful wcf service that returns the following class, but the Total and Count fields become 0 when it reaches the client side. But they have the correct values on the server side.

 public class Groups : List<Group>
{
   
private int total;
   
private int start;

   
/// <summary>
   
/// Total number of Groups in the result set irrespective of the paging
   
/// </summary>

Trouble assigning properties for multiple CSS classes

  
Hi Can anyone tell me why the first block of CSS below works, but the second one doesn't? Thanks Block 1: (works) <style type="text/css">  .FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style> Block 2: (Doesn't work - all I get for FB is color: Black)<style type="text/css">  .SomeOtherClass, FB  {      margin-bottom: 0.5in;      margin-left: 0.5in;      text-align: left;      float: left  }  .FB  {      color: Black;  }</style>

Update all Properties in the User Information List after restoring a site collection to a new domain

  

hi All

I moved a site collection (content db) from one domain to another. After the site collection was restored i ran the stsadm -o migrateuser -oldlogin -newlogin. The result was that the login id of the user in the source domain was replaced with the login in the destination domain.

However the rest of the properties in the User Information List (paricularly interested in the Email) was not updated.

How can i get all the properties in the User Information List with values in the new domain

Thanks in Advance


pv

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit

  

Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.

 

My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error

 

" Only public classes can be used in markup. 'BitmapFrameDecode' type is not public.  "

I have no idea how to fix this..can anyone help me? Thank you very much!


Catalin Toma

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit

  

Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.

 

My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error

 

This is my simplified control:

 

 

public partial class MultiFrameImage : UserControl
  {
    public MultiFrameImage()
    {
      ImageSources = new ObservableCollection<ImageSource>();

      InitializeComponent();
    }

    public ObservableCollection<ImageSource> ImageSources
    {
      get
      {
        return base.GetValue(ImageSourcesProperty) as ObservableCollection<ImageSource>;
      }
      set
      {
        base.SetValue(ImageSourcesProperty,value);
      }
    }
    public DependencyProperty ImageSourcesProperty = DependencyProperty.Register("ImageSources",typeof(ObservableCollection<ImageSource>),typeof(MultiFrameImage));
  }

 

Now,if I initialize the control like this everything works fine:

 

  <Grid>
    <me:MultiFrameImage>
      <me:MultiFrameImage.ImageSources>
        <ImageSource>/Resources/flow1.png</ImageSource>
        <ImageSource>/Reso

Parsing C# Classes, Methods, and Method Properties Using Regex's

  

I have a web project that allows multiple developers to contribute to a .cs file in the App_Code folder. I need to dynamically report on which classes exist in the file, which methods are in those classes, which properties are expected by those methods, and what the method returns. I can't seem to get my curly brace matching to work using regex's.

I went down the road of trying to dynamically build the code and then use reflection to enumerate the objects, but I don't think that's going to work.

Any help would be appreciated.


WCF Tip: Using Properties in Service Contracts

  
you'll notice all of the Service Contracts are implemented with interfaces containing only methods. For the longest time I thought that's all that was supported, until I thought about it a little more. In C# land, properties are simply wrappers around a get method and set method, so why wouldn't we be able to use properties in a service contract? Well the answer is we can.

Learning C# and OOP, Classes

  
This is the second lesson in a miniseries designed to teach you how to write object-oriented programs using C#. This miniseries will describe and discuss the necessary and significant aspects of object-oriented programming (OOP) using C#.

Automatic vs Explicit Properties

  
If the reason that motivated the change from automatically implemented property to explicitly implemented property was to change the semantics of the property then you should evaluate whether the desired semantics when accessing the property from within the class are identical to or different from the desired semantics when accessing the property from outside the class.

Dependency Properties

  
When you begin to develop appliations with WPF, you will soon stumble across DependencyProperties. They look quite similar to normal .NET properties, but the concept behind is much more complex and powerful

InterFaces and Abstract Classes

  
Link Describes About Abstraction and Interfaces In Breif

MSDN Abstract Classes Link

  
MSDN Reference For Abstract Clases

Xml File Methods and Properties

  
Method and Properties of XmlTextWriter class:
The XmlWriter class is a base class that outputs an XML data structure. It has methods to sequentially write XML elements in a proper hierarchy to create an XML file or other types of output streams. The System.Xml namespace provides support for the XmlWriter. It must be imported to the ASP.NET page with the directive

<%@ Import Namespace="System.Xml" %>

The XmlTextWriter

XmlWriter is an abstract class that is implemented as an extended XMLTextWriter class. The XmlTextWriter writes a sequence of XML nodes one element at a time. Output can be written to an XML file, although other streams of output data can be produced. It can create a new file or overwrite an existing file. Its non-cached writing techniques provides very fast generation of an output stream.

C# conversion to VB and properties

  

I am trying to implement image caching for a web application and I found some code on the Internet that implements an HttpHandler that does this. The code was in C# and since my web app is written in VB, I decided to convert the code to VB. I managed to convert everything except the following code (in bold):

public class FileExtensionCollection : ConfigurationElementCollection
    {
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.AddRemoveClearMap;
            }
        }

        public FileExtension this[int index]
        {
            get { return (FileExtension)BaseGet(index); }
            set
            {
               &nb

using reflection to emit properties to the top of the entity graph

  

I've got a class

  public class Criminal
    {

public HouseholdMember[] LiedAboutFSHousehold { get; set; }

      public HouseholdMember[] FoodstampTrafficingHousehold { get; set; }
        ...
   }
HouseholdMember inherits Person, as do many other classes.  

  public class HouseholdMember: Person
    {
           ....
     }

 

What I&#

Relation between classes in c# with class diagrams

  

Hi

Can anyone provide me an example of one to one and one two many relationship between classes in c# with class diagram and explationation.


The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

  

Hey guys


I came across this bug using while trying to implement a sitemap




Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);


[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend