System.Type.GetInterfaces C# (CSharp) Method

GetInterfaces() public method

When overridden in a derived class, gets all the interfaces implemented or inherited by the current T:System.Type.
A static initializer is invoked and throws an exception.
public GetInterfaces ( ) : Type[]
return Type[]
        public Type[] GetInterfaces()
        {
            return interfaces.Select(x => _GetTypeFromTypeFunc(x)).ToArray();
        }

Usage Example

Ejemplo n.º 1
1
        /// <summary>
        /// Dumps everything of a single type into the cache from the filesystem for BackingData
        /// </summary>
        /// <typeparam name="T">the type to get and store</typeparam>
        /// <returns>full or partial success</returns>
        public static bool LoadAllToCache(Type objectType)
        {
            if (!objectType.GetInterfaces().Contains(typeof(IData)))
                return false;

            var fileAccessor = new NetMud.DataAccess.FileSystem.BackingData();
            var typeDirectory = fileAccessor.BaseDirectory + fileAccessor.CurrentDirectoryName + objectType.Name + "/";

            if (!fileAccessor.VerifyDirectory(typeDirectory, false))
            {
                LoggingUtility.LogError(new AccessViolationException(String.Format("Current directory for type {0} does not exist.", objectType.Name)));
                return false;
            }

            var filesDirectory = new DirectoryInfo(typeDirectory);

            foreach (var file in filesDirectory.EnumerateFiles())
            {
                try
                {
                    BackingDataCache.Add(fileAccessor.ReadEntity(file, objectType));
                }
                catch(Exception ex)
                {
                    LoggingUtility.LogError(ex);
                    //Let it keep going
                }
            }

            return true;
        }
All Usage Examples Of System.Type::GetInterfaces