示例#1
0
        /// <summary>
        /// Adds an executable interface by id.
        /// </summary>
        /// <returns>The full mod id if added to the game, <c>null</c> otherwise.</returns>
        /// <param name="id">The Executable Identifier to try and add.</param>
        /// <param name="inter">The interface object.</param>
        public static string RegisterExecutable(string id, Interface inter)
        {
            id = InternalUtility.Validate(id, "Executable Interface", inter.GetType().FullName, true);
            if (ModExecutables.ContainsKey(id))
            {
                return(null);
            }
            var type     = inter.GetType();
            var fileData = GenerateFileDataString(type.Assembly.GetName().Name, type.FullName, id);

            if (fileData.Length < 1 || ModExecutables.Any(pair => pair.Value.Item2 == fileData))
            {
                throw new ArgumentException("created data for '" + id + "' is not unique");
            }
            ModExecutables.Add(id, new Tuple <Interface, string>(inter, fileData));
            return(id);
        }