private static void EnsureTypesCache()
        {
            if (optionIdTypesCache == null)
            {
                var cache = new DhcpServerOptionIdTypes[256];

                foreach (var field in typeof(DhcpServerOptionIds).GetFields(BindingFlags.Public | BindingFlags.Static))
                {
                    var attributes = field
                                     .GetCustomAttributes(typeof(DhcpServerOptionIdTypeAttribute), false);
                    if (attributes.Length == 1 && attributes[0] is DhcpServerOptionIdTypeAttribute attribute)
                    {
                        var id = (byte)field.GetValue(null);
                        cache[id] = attribute.Type;
                    }
                }

                optionIdTypesCache = cache;
            }
        }
Esempio n. 2
0
 public DhcpServerOptionIdTypeAttribute(DhcpServerOptionIdTypes type)
 {
     Type = type;
 }