Пример #1
0
        }         // func GetLogPropertyInfo

        public static async Task GetLogPropertiesAsync(DEHttpClient http, string path, Action <string, LogProperty> process = null)
        {
            var xProperties = await http.GetXmlAsync(Program.MakeUri(path,
                                                                     new PropertyValue("action", "listget"),
                                                                     new PropertyValue("id", "tw_properties")
                                                                     ), rootName : "list");

            var properties = xProperties.Element("items")?.Elements("property");

            if (properties != null)
            {
                foreach (var x in properties)
                {
                    var name = x.GetAttribute("name", null);
                    if (name == null)
                    {
                        continue;
                    }

                    // parse info
                    var propertyInfo = new LogPropertyInfo(name,
                                                           x.GetAttribute("displayname", name),
                                                           LuaType.GetType(x.GetAttribute("type", "string"), lateAllowed: true).Type,
                                                           x.GetAttribute("description", name),
                                                           x.GetAttribute("format", null)
                                                           );
                    UpdatePropertyInfo(propertyInfo);

                    // process value
                    process?.Invoke(path, new LogProperty(propertyInfo, x.Value));
                }
            }
        } // func GetLogProperties
Пример #2
0
            }             // ctor

            public bool SetResult(LogPropertyInfo propertyInfo)
            {
                if (propertyInfo.Name == name)
                {
                    task.TrySetResult(propertyInfo);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }             // func SetResult
Пример #3
0
        private static void UpdatePropertyInfo(LogPropertyInfo propertyInfo)
        {
            // update store
            propertyStore[propertyInfo.Name] = propertyInfo;

            // invoke events
            for (var i = waits.Count - 1; i >= 0; i--)
            {
                if (waits[i].SetResult(propertyInfo))
                {
                    waits.RemoveAt(i);
                }
            }
        }         // proc UpdatePropertyInfo
Пример #4
0
 private LogProperty(LogPropertyInfo info, string value = null)
 {
     this.info  = info ?? throw new ArgumentNullException(nameof(info));
     this.value = value;
 }         // ctor