Exemplo n.º 1
0
 internal static void DecreaseReferenceCount(int dotnetObjectId)
 {
     lock (DotNetObject.Locker)
     {
         DotNetObjectReferenceCounter dotnetObjectReference = DotNetObject.DotnetObjectReferences[dotnetObjectId];
         --dotnetObjectReference.ReferenceCount;
         if (dotnetObjectReference.ReferenceCount == 0)
         {
             DotNetObject.DotnetObjectReferences.Remove(dotnetObjectId);
         }
         else
         {
             DotNetObject.DotnetObjectReferences[dotnetObjectId] = dotnetObjectReference;
         }
     }
 }
Exemplo n.º 2
0
 internal static void IncreaseReferenceCount(int dotnetObjectId)
 {
     lock (DotNetObject.Locker)
     {
         if (DotNetObject.DotnetObjectReferences.ContainsKey(dotnetObjectId))
         {
             DotNetObjectReferenceCounter dotnetObjectReference = DotNetObject.DotnetObjectReferences[dotnetObjectId];
             ++dotnetObjectReference.ReferenceCount;
             DotNetObject.DotnetObjectReferences[dotnetObjectId] = dotnetObjectReference;
         }
         else
         {
             DotNetObject fromFirstReferences = DotNetObject.GetDotNetObjectFromFirstReferences(dotnetObjectId);
             DotNetObject.DotnetObjectReferences.Add(dotnetObjectId, new DotNetObjectReferenceCounter()
             {
                 ReferenceCount = 1,
                 DotNetObject   = fromFirstReferences
             });
         }
     }
 }