コード例 #1
0
        private static void CacheCallouts()
        {
            foreach (var Assem in Functions.GetAllUserPlugins())
            {
                var AssemName     = Assem.GetName();
                var AssemCallouts = (from Callout in Assem.GetTypes()
                                     where Callout.IsClass && Callout.BaseType == typeof(LSPD_First_Response.Mod.Callouts.Callout)
                                     select Callout).ToList();

                if (AssemCallouts.Count() < 1)
                {
                    Logger.Log(Assem.GetName().Name + " No callouts detected.");
                }

                else
                {
                    var AddCount = 0;
                    foreach (Type Callout in AssemCallouts)
                    {
                        var CalloutAttributes = Callout.GetCustomAttributes(typeof(CalloutInfoAttribute), true);

                        if (CalloutAttributes.Count() > 0)
                        {
                            var CalloutAttribute = (CalloutInfoAttribute)(from a in CalloutAttributes select a).FirstOrDefault();

                            if (CalloutAttribute != null)
                            {
                                if (Globals.Config.CalloutProbability == false)
                                {
                                    RandomCalloutCache.Add(CalloutAttribute.Name);
                                }

                                else
                                {
                                    for (var LoopCount = 0; LoopCount < CalloutProbabilityRegistrationCount[(int)CalloutAttribute.CalloutProbability] * Globals.Config.CalloutProbabilityModifier; LoopCount++)
                                    {
                                        RandomCalloutCache.Add(CalloutAttribute.Name);
                                    }
                                }
                                AddCount++;
                            }
                        }
                    }

                    Logger.Log(Assem.GetName().Name + $" detected {AddCount} callouts and added them to the ForceACallout cache.");
                }
            }

            if (Globals.Config.CalloutProbability == true)
            {
                Logger.Log($"{RandomCalloutCache.Count} total probabilities registered in ForceACallout.");
            }
        }
コード例 #2
0
 static Cmn()
 {
     Assem    = Assembly.GetExecutingAssembly();
     AppPath  = Assem.Location;
     AppVer   = Assem.GetName().Version;
     CurDir   = Environment.CurrentDirectory;
     PCName   = Environment.MachineName;
     UserName = Environment.UserName;
     HostName = Dns.GetHostName();
     Proc     = Process.GetCurrentProcess();
     ProcName = Proc.ProcessName;
     ProcId   = Proc.Id;
     IPAddress[] ipas = Dns.GetHostAddresses(HostName);
     foreach (IPAddress ipa in ipas)
     {
         if (ipa.AddressFamily == AddressFamily.InterNetwork)
         {
             IPv4 = ipa;
         }
         if (ipa.AddressFamily == AddressFamily.InterNetworkV6)
         {
             IPv6 = ipa;
         }
     }
     NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
     foreach (NetworkInterface adapter in adapters)
     {
         // ネットワーク接続状態が UP のアダプタのみ
         if (adapter.OperationalStatus == OperationalStatus.Up &&
             adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback &&
             adapter.NetworkInterfaceType != NetworkInterfaceType.Tunnel &&
             adapter.NetworkInterfaceType != NetworkInterfaceType.Unknown
             )
         {
             // 物理(MAC)アドレスの取得
             MacAddr = adapter.GetPhysicalAddress();
             break;
         }
     }
     Refresh();
 }
コード例 #3
0
        internal static void CacheCallouts()
        {
            foreach (Assembly Assem in Functions.GetAllUserPlugins())
            {
                AssemblyName AssemName     = Assem.GetName();
                List <Type>  AssemCallouts = (from Callout in Assem.GetTypes()
                                              where Callout.IsClass && Callout.BaseType == typeof(LSPD_First_Response.Mod.Callouts.Callout)
                                              select Callout).ToList();

                if (AssemCallouts.Count() < 1)
                {
                    Logger.Log(Assem.FullName + "No callouts detected.");
                }

                else
                {
                    int AddCount = 0;
                    foreach (Type Callout in AssemCallouts)
                    {
                        object[] CalloutAttributes = Callout.GetCustomAttributes(typeof(CalloutInfoAttribute), true);

                        if (CalloutAttributes.Count() > 0)
                        {
                            CalloutInfoAttribute CalloutAttribute = (CalloutInfoAttribute)(from a in CalloutAttributes select a).FirstOrDefault();

                            if (CalloutAttribute != null)
                            {
                                RandomCalloutCache.Add(CalloutAttribute.Name);
                                AddCount++;
                            }
                        }
                    }

                    Logger.Log(Assem.FullName + $" detected {AddCount} callouts and added them to the ForceACallout cache.");
                }
            }
        }