Beispiel #1
0
        public object ResolveReference(object context, string reference)
        {
            var id = new Guid(reference);

            lock (((IDictionary)_knownDtos).SyncRoot)
            {
                if (_knownDtos.TryGetValue(id, out var value))
                {
                    if (!value.TryGetTarget(out var target))
                    {
                        Logger.Debug("Could not get target {0}", id);
                        ProxyObjectBase.TryResurect(id, out _);
                    }
                    Logger.Trace("Resolved reference {0} with {1}", reference, value);

                    if (target == null)
                    {
                        Logger.Debug("NULL ON TARGET! {0}", reference);
                    }

                    return(target);
                }
                else if (ProxyObjectBase.TryResurect(id, out var target))
                {
                    return(target);
                }
                else
                {
                    Logger.Warn("Unknown reference: {0}", reference);
                    return(null);
                }
            }
        }
Beispiel #2
0
 internal static bool TryResurect(Guid dtoGuid, out ProxyObjectBase finalizeRequested)
 {
     if (FinalizeRequested.TryGetValue(dtoGuid, out finalizeRequested))
     {
         finalizeRequested.Resurrect();
         return(true);
     }
     return(false);
 }
Beispiel #3
0
 public void DeleteReference(Guid reference)
 {
     if (ProxyObjectBase.TryGetFinalizeRequested(reference, out var proxy))
     {
         proxy.Finalized   -= Proxy_Finalized;
         proxy.Resurrected -= Proxy_Resurrected;
         proxy.FinalizeProxy();
         return;
     }
     Logger.Debug("Could not finalize resurrected proxy {0}", reference);
 }
Beispiel #4
0
 public void Set(ProxyObjectBase dto, object value, string propertyName)
 {
     try
     {
         var queryMessage = SocketMessage.Create(
             SocketMessage.SocketMessageType.Set,
             dto,
             propertyName,
             1,
             value);
         SendAndGetResponse <object>(queryMessage);
     }
     catch (Exception e)
     {
         Logger.Error("From Set {0}: {1}", dto, e);
         throw;
     }
 }
Beispiel #5
0
 public void EventRemove(ProxyObjectBase dto, string eventName)
 {
     try
     {
         var queryMessage = SocketMessage.Create(
             SocketMessage.SocketMessageType.EventRemove,
             dto,
             eventName,
             0,
             null);
         SendAndGetResponse <object>(queryMessage);
     }
     catch (Exception e)
     {
         Logger.Error("From Invoke {0}: {1}", dto, e);
         throw;
     }
 }
Beispiel #6
0
 public T Get <T>(ProxyObjectBase dto, string propertyName)
 {
     try
     {
         var queryMessage = SocketMessage.Create(
             SocketMessage.SocketMessageType.Get,
             dto,
             propertyName,
             0,
             null
             );
         return(SendAndGetResponse <T>(queryMessage));
     }
     catch (Exception e)
     {
         Logger.Error("From Get {0}: {1}", dto, e);
         throw;
     }
 }
Beispiel #7
0
 public void Invoke(ProxyObjectBase dto, string methodName, params object[] parameters)
 {
     try
     {
         var queryMessage = SocketMessage.Create(
             SocketMessage.SocketMessageType.Query,
             dto,
             methodName,
             parameters.Length,
             new SocketMessageArrayValue {
             Value = parameters
         });
         SendAndGetResponse <object>(queryMessage);
     }
     catch (Exception e)
     {
         Logger.Error("From Invoke {0}: {1}", dto, e);
         throw;
     }
 }
Beispiel #8
0
 internal static bool TryGetFinalizeRequested(Guid dtoGuid, out ProxyObjectBase finalizeRequested)
 {
     return(FinalizeRequested.TryGetValue(dtoGuid, out finalizeRequested));
 }
Beispiel #9
0
 public ProxyObjectBaseEventArgs(ProxyObjectBase proxy)
 {
     Proxy = proxy;
 }