Ejemplo n.º 1
0
 public static BubbleLink AddBubleLink(Participant participant, Bubble bubble)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         try
         {
             entities.Attach(participant);
             entities.Attach(bubble);
             if (bubble.Participant != participant)
             {
                 throw new UnauthorizedAccessException("You are not owner of this bubble.");
             }
             BubbleLink bubbleLink = new BubbleLink
             {
                 BubbleLinkId   = Guid.NewGuid(),
                 RemoteBubbleId = Guid.Empty,
                 Bubble         = bubble,
                 Name           = "New Bubble Link",
                 Address        = "127.0.0.1",
                 Port           = MxpConstants.DefaultHubPort,
                 X       = 50,
                 Y       = 50,
                 Z       = 0,
                 Enabled = false
             };
             entities.AddToBubbleLink(bubbleLink);
             entities.SaveChanges();
             entities.Detach(bubbleLink);
             return(bubbleLink);
         }
         finally
         {
             entities.Detach(bubble);
             entities.Detach(participant);
         }
     }
 }