Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Thu, 3 Jul 2008 02:27:01 -0700,    group: microsoft.public.vstudio.extensibility        back       


DSL and Collection Editors????   
Hi all,
I have come across an interesting feature when serializing lists of 
objects....It seems my DSL can only load the list when I Clean and Build and 
not when I just Build...... Please find steps below to reproduce the issue... 

It's VS2008 but not sure what level of patching/service packing has taken 
place.

Create a new DSL Project using Component Models as a template

Add a User Class to the Dsl Project. Make sure this is in the default 
namespace for the project

    [Serializable]
    public class User
    {
        public User()
        {
        }

        private string _username;

        public string Username
        {
            get { return _username; }
            set { _username = value; }
        }
    }

Add a reference to System.Design in the Dsl and DslPackage projects

Add a UsersEditor Class to the DSL project.

    public class UsersEditor : System.ComponentModel.Design.CollectionEditor
    {
        public UsersEditor(Type t)
            : base(t)
        {
        }

        public override object 
EditValue(System.ComponentModel.ITypeDescriptorContext context, 
IServiceProvider provider, object value)
        {
            return base.EditValue(context, provider, value);
        }
    }

Add an ExternalType to the DSL Domain Types
	Name: List<User>
	Namespace: System.Collections.Generic

Add a new Domain Property to the Component Class on the DSL designer surface
	Name: Users
	Type: List<Users>
	Kind: CustomStorage
	Custom Attributes: 
		System.ComponentModel.Editor
		{ typeof(UsersEditor)
		, typeof(System.Drawing.Design.UITypeEditor)
		}

Add a partial class for Component

    public partial class Component
    {
        List<User> _userList = new List<User>();

        public List<User> GetUsersValue()
        {
            return _userList;
        }

        public void SetUsersValue(List<User> value)
        {
            if (null != value)
                _userList = value;
        }
    }

Validate, transform templates, build and run.

In the Experimental Hive add a component to the Test dsl and see that you 
can add Users using the Users Collection Editor. You can add and remove users 
and set usernames. Save the test dsl, close the file and open the test dsl 
again (note, do not shut the experiential hive yet). See that your users 
should still be there.

Ok, now shut the experimental hive and immediately restart it (F5). Try 
looking for your users.... It seems they have disappeared!

Shut the experiential hive again and this time clean the solution then 
restart the hive. Now look for your users, they should be back again!

Anyone care to explain why I can only see my users after I do a clean and 
build rather than just a build? I initially thought it was something to do 
with the way I initialized my List<user>, but then why do I see the different 
functionality when I clean and build rather than just build?

TIA and sorry if i've made any typos in the code
Andy
date: Thu, 3 Jul 2008 02:27:01 -0700   author:   Andy

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us