New Posts New Posts RSS Feed: ISampleDataProvider internal construtor
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ISampleDataProvider internal construtor

 Post Reply Post Reply
Author
halloweenx8 View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Sep-2012
Location: Longueuil, QC
Posts: 36
Post Options Post Options   Quote halloweenx8 Quote  Post ReplyReply Direct Link To This Post Topic: ISampleDataProvider internal construtor
    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.”
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
halloweenx8 View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Sep-2012
Location: Longueuil, QC
Posts: 36
Post Options Post Options   Quote halloweenx8 Quote  Post ReplyReply Direct Link To This Post 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.”
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down