Esempio n. 1
0
        //==============================================================================================================================
        // Helper for the GetCustomAttributes() methods that take a specific attribute type. For desktop compatibility,
        // we return an array of the specific attribute type even though the api's return type promises only an IEnumerable<Attribute>.
        // There are known store apps that cast the results of apis and expect the cast to work.
        //==============================================================================================================================
        private static IEnumerable <Attribute> Instantiate(this IEnumerable <CustomAttributeData> cads, Type actualElementType)
        {
            List <Attribute> attributes = new List <Attribute> ();

            foreach (CustomAttributeData cad in cads)
            {
                Attribute instantiatedAttribute = /*cad.Instantiate ()*/ (Attribute)Activator.CreateInstance(cad.GetType());
                attributes.Add(instantiatedAttribute);
            }
            int count = attributes.Count;

            Attribute[] result;
            result = (Attribute[])Array.CreateInstance(actualElementType, count);
            attributes.CopyTo(result, 0);
            return(result);
        }
        private void LoadElements()
        {
            _elements.Clear();
            var interfaces  = NetworkInterface.GetAllNetworkInterfaces();
            var columnTypes = new[]
            {
                typeof(IfIndex), typeof(IfDescr), typeof(IfType), typeof(IfMtu), typeof(IfSpeed), typeof(IfPhysAddress), typeof(IfAdminStatus), typeof(IfOperStatus),
                typeof(IfLastChange), typeof(IfInOctets), typeof(IfInUcastPkts), typeof(IfInNUcastPkts), typeof(IfInDiscards), typeof(IfInErrors), typeof(IfInUnknownProtos),
                typeof(IfOutOctets), typeof(IfOutUcastPkts), typeof(IfOutNUcastPkts), typeof(IfOutDiscards), typeof(IfOutErrors), typeof(IfOutQLen), typeof(IfSpecific)
            };

            foreach (var type in columnTypes)
            {
                for (int i = 0; i < interfaces.Length; i++)
                {
                    _elements.Add((ScalarObject)Activator.CreateInstance(type, new object[] { i + 1, interfaces[i] }));
                }
            }
        }
Esempio n. 3
0
        internal static void AddPrefix(string prefix, Type type)
        {
            object o = Activator.CreateInstance(type, true);

            prefixes[prefix] = o;
        }
Esempio n. 4
0
 private static Attribute Instantiate(this CustomAttributeData cad)
 {
     return /*cad.Instantiate ()*/ ((Attribute)Activator.CreateInstance(cad.GetType()));
 }