Пример #1
0
        public static KnownServiceTypeEntry[] GetRegisteredServiceTypes()
        {
            Dictionary <Type, KnownServiceTypeEntry> dictionary = LocalServicesConfiguration._services;

            Dictionary <Type, KnownServiceTypeEntry> .ValueCollection valueCollection = dictionary.Values; // .get_Values();
            KnownServiceTypeEntry[] knownServiceTypeEntryArr = new KnownServiceTypeEntry[valueCollection.Count];
            valueCollection.CopyTo(knownServiceTypeEntryArr, 0);
            return(knownServiceTypeEntryArr);
        }
Пример #2
0
 public static void RegisterKnownServiceType(KnownServiceTypeEntry entry)
 {
     lock (LocalServicesConfiguration._servicesMonitor)
     {
         Dictionary <Type, KnownServiceTypeEntry> dictionary = new Dictionary <Type, KnownServiceTypeEntry>(LocalServicesConfiguration._services);
         dictionary.Add(entry.Type, entry);
         LocalServicesConfiguration._services = dictionary;
     }
 }
Пример #3
0
        public static T CreateInstance <T>()
        {
            KnownServiceTypeEntry knownServiceTypeEntry = LocalServicesConfiguration.IsKnownServiceType(typeof(T));

            if (knownServiceTypeEntry == null)
            {
                throw new LocalServicesException(String.Format("Unknown service {0}", typeof(T).FullName));
            }
            return((T)Activator.CreateInstance(knownServiceTypeEntry.Service));
        }