Ejemplo n.º 1
0
        public ModEntry Import(string modDir, ModSource source = ModSource.Unknown)
        {
            if (FindByPath(modDir) != null)
            {
                // Mod already loaded
                return(null);
            }

            // look for .XComMod file
            string infoFile;

            try
            {
                infoFile = Directory.GetFiles(modDir, "*.XComMod", SearchOption.TopDirectoryOnly).SingleOrDefault();
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(
                    $"A mod could not be loaded since it contains multiple .xcommod files\r\nPlease notify the mod creator.\r\n\r\nPath: {modDir}");
                return(null);
            }

            if (infoFile == null)
            {
                return(null);
            }

            var modID  = Path.GetFileNameWithoutExtension(infoFile);
            var isDupe = All.Any(m => m.ID == modID && string.Compare(m.Path, modDir, StringComparison.OrdinalIgnoreCase) == 0);

            // Parse .XComMod file
            var modinfo = new ModInfo(infoFile);

            var mod = new ModEntry
            {
                ID        = modID,
                Name      = modinfo.Title ?? "Unnamed Mod",
                Path      = modDir,
                Source    = source,
                isActive  = false,
                DateAdded = DateTime.Now,
                State     = ModState.New
            };

            AddMod(modinfo.Category, mod);

            // mark dupes
            if (isDupe)
            {
                foreach (var m in All.Where(m => m.ID == modID))
                {
                    m.State |= ModState.DuplicateID;
                }
            }

            return(mod);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a hidden CVar object to the variable list.
 /// </summary>
 /// <param name="name">The name of the variable to add</param>
 /// <param name="value">The value of the variable to add</param>
 public void SetHidden(string name, dynamic value)
 {
     if (All.Any(v => v.Name == name && v.Hidden))
     {
         All.FirstOrDefault(v => v.Name == name && v.Hidden).Value = value;
     }
     else
     {
         All.Add(new CVar(name, value, false, true));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes static members of the SequenceParsers class.
        /// </summary>
        static SequenceParsers()
        {
            // get the registered parsers
            IList <ISequenceParser> registeredParsers = GetSequenceParsers();

            if (null != registeredParsers)
            {
                foreach (ISequenceParser parser in registeredParsers.Where(
                             parser => parser != null && !All.Any(sp =>
                                                                  string.Compare(sp.Name, parser.Name, StringComparison.OrdinalIgnoreCase) == 0)))
                {
                    all.Add(parser);
                }
            }
        }
Ejemplo n.º 4
0
        public static void FindAll(IEnumerable <Type> baseType, Assembly assemblyObj)
        {
            AssemblyObj = assemblyObj;

            All = baseType
                  .ExceptNull()
                  .Distinct()
                  .Select(x => GetDefinableType(x))
                  .ExceptNull()
                  .Distinct()
                  .ToList();


            DomainEntities = All.Where(x => IsEntity(x)).ToList();
            All            = All.Except(DomainEntities).ToList();
            Enums          = All.Where(x => x.IsEnum).ToList();
            All            = All.Except(Enums).ToList();

            while (All.Any(t => Crawl(t)))
            {
                continue;
            }
        }
Ejemplo n.º 5
0
        protected override Assembly Load(AssemblyName assemblyName)
        {
            // If this is SRTPluginBase, just pull it from the Default context.
            if (assemblyName.FullName == typeof(IPlugin).Assembly.FullName)
            {
                return(Default.LoadFromAssemblyName(assemblyName));
            }

            // If the requested assembly is a provider and the assembly name does not match our folder name, do not load it from our folder. Load it from the other load contexts. This fixes issue #26 (ref: https://github.com/Squirrelies/SRTHost/issues/26).
            if (assemblyName.Name.StartsWith("SRTPluginProvider", StringComparison.InvariantCultureIgnoreCase) && !thisPluginDirectory.Name.StartsWith("SRTPluginProvider", StringComparison.InvariantCultureIgnoreCase))
            {
                return(All.First(a => a.Name == assemblyName.Name).LoadFromAssemblyName(assemblyName));
            }

            // Attempt to let let the AssemblyDependencyResolver handle it first.
            string assemblyPath = _thisPluginResolver.ResolveAssemblyToPath(assemblyName);

            // If that failed, no problem. Check our folder.
            if (assemblyPath == null)
            {
                assemblyPath = DetectAssemblyLocation(assemblyName.Name);
            }

            if (assemblyPath != null) // Return the assembly we found.
            {
                return(LoadFromAssemblyPath(assemblyPath));
            }
            else if (All.Any(a => a.Name == assemblyName.Name))                                         // Are there any LoadContexts that match this AssemblyName? If so, maybe we can enlist their help!
            {
                return(All.First(a => a.Name == assemblyName.Name).LoadFromAssemblyName(assemblyName)); // TODO: Is this needed anymore with the new provider diversion above?
            }
            else // If we made it this far, hopefully the default AssemblyLoadContext can help because we have no idea.
            {
                return(Default.LoadFromAssemblyName(assemblyName));
            }
        }
Ejemplo n.º 6
0
 private bool Exists(PropertyAccessor accessor)
 {
     return(All.Any(p => p.Property.Name.Equals(accessor.Name, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 7
0
        public ModEntry Import(string modDir, ModSource source = ModSource.Unknown)
        {
            if (FindByPath(modDir) != null)
            {
                // Mod already loaded
                return(null);
            }

            // look for .XComMod file
            string infoFile = FindModInfo(modDir);

            if (infoFile == null)
            {
                return(null);
            }

            var modID  = Path.GetFileNameWithoutExtension(infoFile);
            var isDupe = All.Any(m => m.ID == modID && string.Compare(m.Path, modDir, StringComparison.OrdinalIgnoreCase) == 0);

            // Parse .XComMod file
            var modinfo = new ModInfo(infoFile);

            var mod = new ModEntry
            {
                ID           = modID,
                Name         = modinfo.Title ?? "Unnamed Mod",
                Path         = modDir,
                Source       = source,
                isActive     = false,
                DateAdded    = DateTime.Now,
                BuiltForWOTC = modinfo.RequiresXPACK,
                State        = ModState.New
            };

            if (source == ModSource.SteamWorkshop)
            {
                var s = modDir.Split(Path.DirectorySeparatorChar).Last();
                try
                {
                    mod.WorkshopID = Convert.ToInt64(s);
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        $"A mod could not be loaded because the workshop ID failed to parse.\r\nPlease check that the following directory conforms to valid workshop numbering.\r\n\r\nPath: {modDir}");
                    return(null);
                }
            }

            AddMod(modinfo.Category, mod);

            // mark dupes
            if (isDupe)
            {
                foreach (var m in All.Where(m => m.ID == modID))
                {
                    m.State |= ModState.DuplicateID;
                }
            }

            return(mod);
        }
 public bool Any() => All.Any(p => p != null);
Ejemplo n.º 9
0
 /// <summary>
 /// Helper method that checks if a variable exists given its name and type.
 /// </summary>
 /// <param name="name">The name of the variable</param>
 /// <param name="type">The type of the variable</param>
 /// <returns>True if the variable exists and matches the given type</returns>
 public bool VariableExists(string name, CVar.VarType type)
 {
     return(All.Any(v => v.Name == name && v.Type == type));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Helper method that checks if a variable exists given its name.
 /// </summary>
 /// <param name="name">The name of the variable</param>
 /// <returns>True if the variable exists</returns>
 public bool VariableExists(string name)
 {
     return(All.Any(v => v.Name == name));
 }
 public bool CanAccessBussinessAdmin()
 {
     return(All.Any(a => a.UserID == Context.UserInfo.UserId &&
                    a.PersonnelGroupMembers.Any(g => g.Group.GroupType == PersonnelGroupType.SiteAdmin)));
 }
 public bool IsEmailExist(string email)
 {
     return(All.Any(a => a.Email == email));
 }
Ejemplo n.º 13
0
 public static bool Has(CrossingType crossingType)
 {
     return(All.Any(crossingType.Equals));
 }
Ejemplo n.º 14
0
 public bool TodoItemExists(long id)
 {
     return(All.Any(e => e.Id == id));
 }
Ejemplo n.º 15
0
 internal bool Contains(Peer peer)
 {
     return(All.Any(peer.Equals));
 }
Ejemplo n.º 16
0
 public bool IsGroupNameDuplicate(LstPersonnelGroup group)
 {
     return(All.Any(a => a.GroupName == group.GroupName && a.DeletedDate == null && a.GroupId != group.GroupId));
 }