Print Page | Close Window

ISampleDataProvider internal construtor

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3643
Printed Date: 02-May-2024 at 5:50pm


Topic: ISampleDataProvider internal construtor
Posted By: halloweenx8
Subject: ISampleDataProvider internal construtor
Date Posted: 20-Sep-2012 at 10:48pm
For the life of me I can't find why TempHire works and my app which is similar does not.
 
This code is located in TempHireSampleDataProvider
 
        private StaffingResource NewResource(string first, string middle, string last, string summary)
        {
            return new StaffingResource
                     {
                           Id = CreateGuid(_resId++),
                           FirstName = first,
                           MiddleName = middle,
                           LastName = last,
                           Summary = summary,
                           Created = SystemTime.Now,
                           CreatedUser = "SampleData",
                           Modified = SystemTime.Now,
                           ModifyUser = "SampleData"
                       };
        }
 
 
But the class is defined this way
 internal StaffingResource()
        {
        }

      /// <summary>Gets or sets the Id. </summary>
        [DataMember]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Required]
        public Guid Id { get; internal set; }
 
there suppose to be 2 errors in here, first the constructor is internal and second Id is should not be settable?
 
Now that must be me missing basic stuff.
 
Thanks anyway.
 


-------------
Jean

"If You are Not Making Mistakes, then You are Not Doing Anything.”



Replies:
Posted By: mgood
Date Posted: 22-Sep-2012 at 1:03am
The trick is to make the types visible to the other assembly. In TempHire, DomainModel makes it's internal types visible to DomainServices.

Look at AssemblyInfo.cs and you'll find the following:

[assembly: InternalsVisibleTo("DomainServices.SL")]

or

[assembly: InternalsVisibleTo("DomainServices")]

More info on InternalsVisibleTo can be found there:

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx


Posted By: halloweenx8
Date Posted: 22-Sep-2012 at 8:33am
I thought it was basic, but it is a neat trick, thanks

-------------
Jean

"If You are Not Making Mistakes, then You are Not Doing Anything.”



Print Page | Close Window