Ejemplo n.º 1
0
        private static async Task <bool> GetParamAsync(string key, XmlRpcValue resultValue, bool useCache)
        {
            string mappepKey = Names.Resolve(key);

            if (useCache)
            {
                lock (gate)
                {
                    if (cachedValues.TryGetValue(mappepKey, out var cachedValue) && !cachedValue.IsEmpty)
                    {
                        resultValue.Copy(cachedValue);
                        return(true);
                    }
                }
            }

            var parm   = new XmlRpcValue();
            var result = new XmlRpcValue();

            parm.Set(0, ThisNode.Name);
            parm.Set(1, mappepKey);
            resultValue.SetArray(0);

            bool ret = await Master.ExecuteAsync("getParam", parm, result, resultValue, false).ConfigureAwait(false);

            if (ret && useCache)
            {
                lock (gate)
                {
                    cachedValues[mappepKey] = resultValue.Clone();
                }
            }

            return(ret);
        }