Beispiel #1
0
        public virtual bool Get(string id, object sender, AssetRetrieved callBack)
        {
            AssetBase asset = null;

            if (m_Cache != null)
            {
                if (!m_Cache.GetFromMemory(id, out asset))
                {
                    callBack(id, sender, null);
                    return(false);
                }
            }

            if (asset == null)
            {
                if (id.Equals(Util.UUIDZeroString))
                {
                    callBack(id, sender, null);
                    return(false);
                }

                lock (m_AssetHandlers)
                {
                    SimpleAssetRetrieved handlerEx = new SimpleAssetRetrieved(delegate(AssetBase _asset) { callBack(id, sender, _asset); _asset = null; });

                    List <SimpleAssetRetrieved> handlers;
                    if (m_AssetHandlers.TryGetValue(id, out handlers))
                    {
                        // Someone else is already loading this asset. It will notify our handler when done.
                        handlers.Add(handlerEx);
                        return(true);
                    }

                    handlers = new List <SimpleAssetRetrieved>();
                    handlers.Add(handlerEx);

                    m_AssetHandlers.Add(id, handlers);
                    m_localRequestsQueue.Enqueue(id);
                }
            }
            else
            {
                if (asset != null && (asset.Data == null || asset.Data.Length == 0))
                {
                    asset = null;
                }
                callBack(id, sender, asset);
            }
            return(true);
        }
Beispiel #2
0
 public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)
 {
 }
Beispiel #3
0
        public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)
        {
            m_assetConnector.Get(id, null, (i, s, asset) =>
            {
                if (asset != null)
                {
                    if (!m_AssetPerms.AllowedExport(asset.Type))
                    {
                        asset = null;
                    }
                    else
                    {
                        if (asset.Metadata.Type == (sbyte)AssetType.Object)
                        {
                            asset.Data = AdjustIdentifiers(asset.Data);
                        }

                        AdjustIdentifiers(asset.Metadata);
                    }
                }

                callBack(asset);
            });
        }
        public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)
        {
            if (m_Cache != null)
            {
                AssetBase asset;
                if (!m_Cache.GetFromMemory(id, out asset))
                {
                    callBack(null);
                    return;
                }

                if (asset != null)
                {
                    callBack(asset);
                    return;
                }
            }

            if (id.Equals(Util.UUIDZeroString))
            {
                callBack(null);
                return;
            }

            m_AssetService.Get(id, null, delegate(string assetID, object s, AssetBase a)
            {
                if (m_Cache != null)
                {
                    if (a == null)
                    {
                        m_Cache.CacheNegative(assetID);
                    }
                    else
                    {
                        m_Cache.Cache(a);
                    }
                }
                //if (null == a)
                //.   m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id);

                Util.FireAndForget(o => callBack(a), null, "LocalAssetServiceConnector.GotFromServiceCallback");
            });
        }
Beispiel #5
0
        public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)
        {
            AssetBase asset = null;

            if (m_Cache != null)
            {
                if (!m_Cache.GetFromMemory(id, out asset))
                {
                    callBack(null);
                    return;
                }
            }

            if (asset == null)
            {
                if (id.Equals(Util.UUIDZeroString))
                {
                    callBack(null);
                    return;
                }

                lock (m_AssetHandlers)
                {
                    SimpleAssetRetrieved handlerEx = new SimpleAssetRetrieved(delegate(AssetBase _asset) { callBack(_asset); _asset = null; });

                    List <SimpleAssetRetrieved> handlers;
                    if (m_AssetHandlers.TryGetValue(id, out handlers))
                    {
                        // Someone else is already loading this asset. It will notify our handler when done.
                        handlers.Add(handlerEx);
                        return;
                    }

                    handlers = new List <SimpleAssetRetrieved>();
                    handlers.Add(handlerEx);

                    m_AssetHandlers.Add(id, handlers);
                    if (string.IsNullOrEmpty(ForeignAssetService))
                    {
                        m_localRequestsQueue.Enqueue(id);
                    }
                    else
                    {
                        ForeignAssetServiceGetData fasgd = new ForeignAssetServiceGetData
                        {
                            id = id,
                            ForeignAssetService = ForeignAssetService,
                            StoreOnLocalGrid    = StoreOnLocalGrid
                        };
                        m_remoteRequestsQueue.Enqueue(fasgd);
                    }
                }
            }
            else
            {
                if (asset != null && (asset.Data == null || asset.Data.Length == 0))
                {
                    asset = null;
                }
                callBack(asset);
            }
        }
        public void Get(string id, string ForeignAssetService, bool StoreOnLocalGrid, SimpleAssetRetrieved callBack)
        {
            AssetBase a = Get(id, ForeignAssetService, StoreOnLocalGrid);

            if (a != null)
            {
                Util.FireAndForget(o => callBack(a), null, "LocalAssetServiceConnector.GotFromServiceCallback");
            }
        }