Example #1
0
 /// <summary>
 /// Revokes a published object. ArgumentException is thrown if the object has not been published by means of this provider.
 /// </summary>
 /// <param name="obj">The object has to be the one published through this provider class.</param>
 /// <param name="force">Suppresses WMI exceptions (but not ArgumentException) and forcefully clears internal list.</param>
 public void Revoke(IWmiHardwareEntity obj, bool force = false)
 {
     if (!Contains(obj))
     {
         throw new ArgumentException("IHardware object with specified HWID has not been published through this provider.");
     }
     try
     {
         if (obj.GetType().GetCustomAttributes(typeof(ManagementEntityAttribute), false).Any())
         {
             InstrumentationManager.Revoke(obj);
         }
         else
         {
             Instrumentation.Revoke(obj);
         }
     }
     catch (Exception ex)
     {
         if (!force)
         {
             throw ex;
         }
     }
     _pub.Remove(obj.Hwid);
 }
Example #2
0
 public void RevokeInformer(WmiReadynessInformer obj, bool force = false)
 {
     if (!ContainsInformer(obj))
     {
         throw new ArgumentException("Informer with specified ApplicationName has not been published through this provider.");
     }
     try
     {
         if (obj.GetType().GetCustomAttributes(typeof(ManagementEntityAttribute), false).Any())
         {
             InstrumentationManager.Revoke(obj);
         }
         else
         {
             Instrumentation.Revoke(obj);
         }
     }
     catch (Exception ex)
     {
         if (!force)
         {
             throw ex;
         }
     }
     _pub.Remove(obj.ApplicationName);
 }
Example #3
0
 public void Dispose()
 {
     foreach (IWmiObject instance in activeInstances)
     {
         Instrumentation.Revoke(instance);
     }
     Logger.LogInformation("Deregistered all instances from WMI provider");
     activeInstances = null;
 }
Example #4
0
 public void Dispose()
 {
     foreach (IWmiObject instance in activeInstances)
     {
         try {
             Instrumentation.Revoke(instance);
         } catch (Exception) { }
     }
     activeInstances = null;
 }
        public static void Main(string[] args)
        {
            MyManagedElement el = new MyManagedElement();

            el.Description = "SAMPLE INSTANCE";
            el.Count       = 256;
            Instrumentation.Publish(el);
            Console.ReadLine();
            Instrumentation.Revoke(el);
        }
        private void RevokeInstance(string identifier)
        {
            int instanceIndex = activeInstances.FindIndex(
                item => item.Identifier == identifier.ToString()
                );

            try {
                Instrumentation.Revoke(activeInstances[instanceIndex]);
            } catch (Exception) { }

            activeInstances.RemoveAt(instanceIndex);
        }
        public static void Main(string[] args)
        {
            MyManagedElement el = new MyManagedElement();

            el.Description = "SAMPLE INSTANCE";
            el.Count       = 256;
            Instrumentation.Publish(el);
            Console.WriteLine("Instance published (true/false): {0}", el.Published);
            Console.ReadLine();
            Instrumentation.Revoke(el);
            Console.WriteLine("Instance published (true/false): {0}", el.Published);
        }
Example #8
0
        private void RevokeInstance(string identifier)
        {
            int instanceIndex = activeInstances.FindIndex(
                item => item.Identifier == identifier.ToString()
                );

            if (instanceIndex == -1)
            {
                return;
            }

            Instrumentation.Revoke(activeInstances[instanceIndex]);
            Logger.LogInformation($"Deregistered {activeInstances[instanceIndex].Name} from WMI provider");

            activeInstances.RemoveAt(instanceIndex);
        }
        private void RevokeInstance(string identifier)
        {
            int instanceIndex = _activeInstances.FindIndex(
                item => item.Identifier == identifier.ToString()
                );

            if (instanceIndex == -1)
            {
                return;
            }

            try
            {
                Instrumentation.Revoke(_activeInstances[instanceIndex]);
            }
            catch { }

            _activeInstances.RemoveAt(instanceIndex);
        }
Example #10
0
 public void Refresh()
 {
     _isLock = true;
     while (_lock.TryEnter())
     {
     }
     try
     {
         if (_cache == null)
         {
             _cache = _dic.Values.OrderByDescending(v => v.SearchCount).ToPerfectList();
         }
         else
         {
             var list = new List <InstrumentNode>(SettingCache.LuceneHotWord);
             foreach (var v in _cache)
             {
                 Instrumentation.Revoke(v);
                 if (_dic.ContainsKey(v.Key))
                 {
                     v.SearchCount += _dic[v.Key].SearchCount;
                     _dic.Remove(v.Key);
                 }
             }
             _cache = _dic.Values.Union(_cache).OrderByDescending(v => v.SearchCount).Distinct().Take(SettingCache.LuceneHotWord).ToPerfectList();
         }
         PublishCache();
         _dic.Clear();
         SerizlizerUtils <List <InstrumentNode> > .SerializeLastCache(_cache, _bufferName);
     }
     finally
     {
         _isLock = false;
         _lock.Exit();
     }
 }
Example #11
0
    static void Maina()
    {
        Instrumentation.RegisterAssembly(typeof(Appo).Assembly);

        BadProp2 inst2 = new BadProp2();

        Instrumentation.Publish(inst2);
        Instrumentation.Publish(inst2);
        Instrumentation.Revoke(inst2);
        Instrumentation.Revoke(inst2);

        BadProp inst = new BadProp();

        Instrumentation.Publish(inst);
        Console.WriteLine(inst.Published);
        Instrumentation.Publish(inst);
        Console.WriteLine(inst.Published);

        Instrumentation.Revoke(inst);
        Console.WriteLine(inst.Published);

        inst.Published = true;
        Console.WriteLine(inst.Published);
    }
 /// <summary>
 /// revoke a previously published message from the WMI repository
 /// </summary>
 /// <param name="Message">the message to revoke</param>
 public static void Revoke(MyWMIInterface pInterface)
 {
     Instrumentation.Revoke(pInterface);
 }
Example #13
0
 public void CleanUp()
 {
     Instrumentation.Revoke(this);
 }
Example #14
0
 public void CleanUp()
 {
     GXLogging.Debug(log, "Revoke");
     Instrumentation.Revoke(this);
 }