Пример #1
0
        public void Merge(WSValue src)
        {
            base.Merge(src);

            NAME        = string.IsNullOrEmpty(src.NAME) ? NAME : src.NAME;
            DESCRIPTION = string.IsNullOrEmpty(src.DESCRIPTION) ? DESCRIPTION : src.DESCRIPTION;
        }
Пример #2
0
 public static bool ReadValue(this Dictionary <string, string> dict, WSValue key, out string value)
 {
     lock (ReadDictionaryByVWSValueLock)
     {
         value = null;
         try
         {
             if (dict != null && key != null)
             {
                 if (dict.Any(d => key.Match(d.Key)))
                 {
                     value = dict.FirstOrDefault(d => key.Match(d.Key)).Value;
                     return(true);
                 }
             }
         }
         catch (Exception) { }
         return(false);
     }
 }
Пример #3
0
        public bool TryReadWSValue(Dictionary <string, string> dict, out WSValue value, WSValue DEFAULT = null)
        {
            WSValue v = null;

            if (dict != null && dict.Any())
            {
                try
                {
                    Func <KeyValuePair <string, string>, bool> expr = (i => Match(i.Key));
                    if (ALLOWED_VALUES != null && ALLOWED_VALUES.Any())
                    {
                        v = ALLOWED_VALUES.FirstOrDefault(x => x.Match(dict.FirstOrDefault(expr).Value));
                    }
                    else if (dict.Any(expr))
                    {
                        KeyValuePair <string, string> pair = dict.FirstOrDefault(expr);
                        v = new WSValue(pair.Key, pair.Value);
                    }
                }
                catch (Exception) { }
            }
            value = v == null ? DEFAULT : v;
            return(value != null);
        }
Пример #4
0
        public new void ReadXmlContent(System.Xml.XmlReader reader)
        {
            base.ReadXmlContent(reader);

            bool done = false;

            while (reader.MoveToContent() == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                case "readAccessMode":
                    READ_ACCESS_MODE.ReadXml(reader);
                    break;

                case "writeAccessMode":
                    WRITE_ACCESS_MODE.ReadXml(reader);
                    break;

                case "allowedValues":
                    if (reader.ReadToDescendant("allowedValue"))
                    {
                        List <WSValue> values = new List <WSValue>();
                        while (reader.MoveToContent() == XmlNodeType.Element)
                        {
                            if (!reader.IsEmptyElement)
                            {
                                string aName = reader.GetAttribute("name");
                                if (string.IsNullOrEmpty(aName))
                                {
                                    reader.Skip();
                                }
                                else
                                {
                                    WSValue value = new WSValue(aName);
                                    value.ReadXml(reader);
                                    values.Add(value);
                                }
                            }
                            reader.MoveToContent();
                            if (!reader.Read())
                            {
                                break;
                            }
                        }
                        ALLOWED_VALUES = values;
                    }
                    break;

                default:
                {
                    reader.Skip();
                    done = true;
                    break;
                }
                }
                reader.MoveToContent();
                if (done || !reader.Read())
                {
                    break;
                }
            }
        }
Пример #5
0
        public WSValue ReadWSValue(Dictionary <string, string> dict, WSValue DEFAULT = null)
        {
            WSValue v = null;

            return(TryReadWSValue(dict, out v, DEFAULT) ? v : DEFAULT);
        }
Пример #6
0
 public WSCommandKey(WSValue data) : base(data.NAME, data.ALIACES)
 {
 }
Пример #7
0
 public bool Match(WSValue value)
 {
     try {
         return(value != null && (ALIACES.Any(x => value.ALIACES.Any(v => x.Equals(v))) || value.NAME.ToLower().Equals(NAME.ToLower())));
     } catch (Exception) { } return(false);
 }
Пример #8
0
 public static bool IsValid(WSValue root)
 {
     try { return(root != null && root.isValid); } catch (Exception) { } return(false);
 }