internal bool ActivationSwitchMatch(MemberInfo objectToCheck,AppConfigProvider provider) { var attrs = objectToCheck.GetCustomAttributes(typeof (ActivationSwitchAttribute), true).Cast <ActivationSwitchAttribute>(); return ActivationSwitchMatch(attrs, provider); }
internal bool AppConfigMatchMatch(IEnumerable<KeyValuePair<string,string>> presentFlags,AppConfigProvider provider) { var result = presentFlags.Where(k => provider.ContainsKey(k.Key)) .All(k => k.Value.Equals(provider.GetValue(k.Key))); return result; }
internal bool ActivationSwitchMatch(IEnumerable<ActivationSwitchAttribute> attributes, AppConfigProvider provider) { var enums = attributes.Where(k => k.Switch != null).Select(k => k.Switch).OfType<Enum>().ToArray(); var keys = attributes.Where(k => k.Name != null) .Zip(attributes.Where(k=>k.Value!=null), (a,b)=> new KeyValuePair<string,string>(a.Name,b.Value)).ToArray(); return FlagsMatch(enums) & AppConfigMatchMatch(keys,provider); }
public SerialPoster([ImportMany] IEnumerable <IPacketResourcePoster> packetResourcePosters, IStatChannel statChannel, SettingsHolder settings, AppConfigProvider appConfigProvider ) { _packetResourcePosters = packetResourcePosters .Where(k => settings.Settings .ActivationSwitchMatch(k.GetType(), appConfigProvider)); _statChannel = statChannel; _statChannel.Register("Universal"); }
public SerialPoster([ImportMany]IEnumerable<IPacketResourcePoster> packetResourcePosters, IStatChannel statChannel, SettingsHolder settings, AppConfigProvider appConfigProvider ) { _packetResourcePosters = packetResourcePosters .Where(k => settings.Settings .ActivationSwitchMatch(k.GetType(), appConfigProvider)); _statChannel = statChannel; _statChannel.Register("Universal"); }
internal bool ActivationSwitchMatch(ActivationSwitchAttribute attribute, AppConfigProvider provider) { return FlagsMatch(attribute.CombinedEnums) && AppConfigMatchMatch(attribute.Configs,provider); }