示例#1
0
 public PollingEventArgs(EventType type, PollResult result, Exception exception)
 {
     Type = type;
     Result = result;
     Exception = exception;
 }
 /// <summary>
 /// Apply the polled result to the configuration.
 /// If the polled result is full result from source, each property in the result is either added to set 
 /// to the configuration, and any property that is in the configuration but not in the result is deleted if IgnoreDeletesFromSource
 /// is false. If the polled result is incremental, properties added and changed in the partial result 
 /// are set with the configuration, and deleted properties are deleted form configuration if ignoreDeletesFromSource
 /// is false.
 /// </summary>
 /// <param name="result"></param>
 /// <param name="config"></param>
 protected void PopulateProperties(PollResult result, IConfiguration config)
 {
     if (result == null || !result.HasChanges)
     {
         return;
     }
     if (!result.Incremental)
     {
         var props = result.Complete;
         if (props == null)
         {
             return;
         }
         foreach (var prop in props)
         {
             m_PropertyUpdater.AddOrChangeProperty(prop.Key, prop.Value, config);
         }
         var existingKeys = new HashSet<string>(config.Keys);
         if (!IgnoreDeletesFromSource)
         {
             foreach (string key in existingKeys.Where(k => !props.ContainsKey(k)))
             {
                 m_PropertyUpdater.DeleteProperty(key, config);
             }
         }
     }
     else
     {
         var props = result.Added;
         if (props != null)
         {
             foreach (var prop in props)
             {
                 m_PropertyUpdater.AddOrChangeProperty(prop.Key, prop.Value, config);
             }
         }
         props = result.Changed;
         if (props != null)
         {
             foreach (var prop in props)
             {
                 m_PropertyUpdater.AddOrChangeProperty(prop.Key, prop.Value, config);
             }
         }
         if (!IgnoreDeletesFromSource)
         {
             props = result.Deleted;
             if (props != null)
             {
                 foreach (var key in props.Keys)
                 {
                     m_PropertyUpdater.DeleteProperty(key, config);
                 }
             }
         }
     }
 }
示例#3
0
 public PollingEventArgs(EventType type, PollResult result, Exception exception)
 {
     Type      = type;
     Result    = result;
     Exception = exception;
 }