示例#1
0
        static void Main(string[] args)
        {
            var settings = new PluginSettings();

            settings.NetworkConnectionRules = new List <NetworkConnectionRule>()
            {
                new NetworkConnectionRule()
                {
                    LocalPort = "443"
                },
                new NetworkConnectionRule()
                {
                    RemotePort = "443"
                }
            };

            XmlSerializer xmlSerializer = new XmlSerializer(settings.GetType());

            using (var textWriter = new StringWriter())
            {
                xmlSerializer.Serialize(textWriter, settings);
                var serialized = textWriter.ToString();
                Debugger.Break();
            }

            var activeConnections = NetworkConnectionsHelper.GetActiveTCPConnections();

            var matchedConnections = new List <NetworkConnectionRule>();

            foreach (var activeConnection in activeConnections)
            {
                foreach (var rule in settings.NetworkConnectionRules)
                {
                    if (rule.Matches(activeConnection))
                    {
                        Debugger.Break();
                    }
                }
            }

            Debugger.Break();
        }
        public virtual void Add(TItem itemToAdd)
        {
            itemToAdd.IsSaved = true;
            Database.Add(itemToAdd);

            PropertyInfo propertyInfo = PluginSettings.GetType().GetProperty("EnableTag");

            if (propertyInfo != null)
            {
                bool EnableTag = (bool)propertyInfo.GetValue(PluginSettings);
                if (EnableTag)
                {
#if DEBUG
                    logger.Debug($"{PluginName} - RemoveTag & AddTag for {itemToAdd.Name} with {itemToAdd.Id}");
#endif
                    RemoveTag(itemToAdd.Id);
                    AddTag(itemToAdd.Id);
                }
            }
        }