System.Reflection.Assembly.GetTypes()

Here are the examples of the csharp api System.Reflection.Assembly.GetTypes() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3019 Examples 7

19 Source : TypeFinder.cs
with MIT License
from ad313

public List<Type> FindAllInterface(List<replacedembly> replacedemblies = null)
        {
            replacedemblies ??= Getreplacedemblies();

            if (replacedemblies == null || !replacedemblies.Any())
                return new List<Type>();

            return replacedemblies.SelectMany(d => d.GetTypes().Where(t => t.IsInterface)).ToList();
        }

19 Source : DependencyRegistrator.cs
with MIT License
from ad313

private void RegisterTransientDependency()
        {
            //虚函数
            var virtualClreplaced = replacedemblies.SelectMany(d => d.GetTypes().Where(t => t.IsClreplaced && t.GetInterfaces().Length == 0)).ToList();
            var virtualMethods = virtualClreplaced.SelectMany(d => d.GetMethods()).Where(d =>
                d.CustomAttributes.Any(t => t.AttributeType.Name == nameof(AopPublisherAttribute)) ||
                d.CustomAttributes.Any(t => t.AttributeType.Name == nameof(AopSubscriberAttribute))).ToList();

            var methods = TypeFinder.FindAllInterface(replacedemblies).SelectMany(d => d.GetMethods()).ToList();
            methods.AddRange(virtualMethods);

            var publishers = methods.SelectMany(d => d.GetCustomAttributes<AopPublisherAttribute>()).ToList();
            var check = publishers.Select(d => d.Channel).GroupBy(d => d).ToDictionary(d => d.Key, d => d.Count()).Where(d => d.Value > 1).ToList();
            if (check.Any())
            {
                throw new Exception($"[AopCache AopPublisherAttribute] [Key 重复:{string.Join("、", check.Select(d => d.Key))}]");
            }

            //开启发布
            if (publishers.Any())
            {
                AopPublisherAttribute.Enable = true;
            }

            var existsList = methods.Where(d =>
                d.CustomAttributes.Any(t => t.AttributeType.Name == nameof(AopPublisherAttribute)) &&
                d.CustomAttributes.Any(t => t.AttributeType.Name == nameof(AopCacheAttribute))).ToList();
            
            if (existsList.Any())
            {
                throw new Exception($"[AopCache AopPublisherAttribute] [不能与 AopCacheAttribute 一起使用 :{string.Join("、", existsList.Select(d => $"{d.DeclaringType?.FullName}.{d.Name}"))}]");
            }
            
            var subscribers = methods.SelectMany(d => d.GetCustomAttributes<AopSubscriberAttribute>()).ToList();
            if (subscribers.Any())
            {
                AopSubscriberAttribute.ChannelList = subscribers.Select(d => d.Channel).Distinct().ToList();
                
                AopSubscriberAttribute.MethodList = methods.Where(d =>
                    d.CustomAttributes != null &&
                    d.CustomAttributes.Any(c => c.AttributeType.Name == nameof(AopSubscriberAttribute))).ToList();

                foreach (var subscriber in subscribers)
                {
                    if (string.IsNullOrWhiteSpace(subscriber.Map))
                        continue;

                    //特殊处理冒号,兼容冒号
                    subscriber.Map = subscriber.Map.Replace(":", ".");

                    var key = subscriber.GetMapDictionaryKey();

                    if (AopSubscriberAttribute.MapDictionary.ContainsKey(key))
                        continue;

                    var mapDic = subscriber.Map.Split(',')
                        .Where(d => d.IndexOf('=') > -1
                                    && !string.IsNullOrWhiteSpace(d.Split('=')[0])
                                    && !string.IsNullOrWhiteSpace(d.Split('=')[1]))
                        .ToDictionary(d => d.Split('=')[0].Trim(), d => d.Split('=')[1].Trim().TrimStart('{').TrimEnd('}'));
                    AopSubscriberAttribute.MapDictionary.TryAdd(key, mapDic);
                }
            }
        }

19 Source : CSharpStyler.cs
with GNU General Public License v3.0
from adam8797

public override void SetKeywords(ScintillaNET.Scintilla scintilla)
        {
            scintilla.SetKeywords(0, "abstract partial as base break case catch checked continue default" +
                                     " delegate do else event explicit extern false finally fixed for foreach" +
                                     " goto if implicit in interface internal is lock namespace new null" +
                                     " operator out override params private protected public readonly ref return" +
                                     " sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe" +
                                     " using virtual while volatile yield var async await" +
                                     " object bool byte char clreplaced const decimal double enum float int long sbyte short" +
                                     " static string struct uint ulong ushort void dynamic ");


            var builtInTypeNames = typeof(string).replacedembly.GetTypes()
                .Where(t => t.IsPublic && t.IsVisible)
                .Select(t => new {t.Name, Length = t.Name.IndexOf('`')}) // remove generic type from "List`1"
                .Select(x => x.Length == -1 ? x.Name : x.Name.Substring(0, x.Length))
                .Distinct();

            scintilla.SetKeywords(1, string.Join(" ", builtInTypeNames));
        }

19 Source : Serializer.cs
with GNU General Public License v3.0
from Adam-Wilkinson

private void InitializeDictionaries()
        {
            foreach (Type type in typeof(Serializer).replacedembly.GetTypes())
            {
                Type serializerType = type.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IObjectSerializer<>)).FirstOrDefault();
                if (serializerType is not null)
                {
                    object serializer = _factory.CreateInstance(type);
                    Type genericParameter = serializerType.GetGenericArguments().FirstOrDefault();
                    Serializers.Add(genericParameter, serializer);
                }
            }
        }

19 Source : TypeExtensions.cs
with MIT License
from adamant

public static IEnumerable<Type> GetAllSubtypes(this Type type)
        {
            return AppDomain.CurrentDomain.Getreplacedemblies()
                    .SelectMany(a => a.GetTypes())
                    .Where(t => type.IsreplacedignableFrom(t) && t != type)
                    .ToArray();
        }

19 Source : MessageHandlerContainer.cs
with MIT License
from AdemCatamak

public void Register(Action<MessageHandlerMetadata>? configureMessageHandlerMetadata, params replacedembly[] replacedemblies)
        {
            var messageHandlerTypes = replacedemblies.SelectMany(a => a.GetTypes())
                                                .Where(t => t.IsClreplaced && !t.IsAbstract)
                                                .SelectMany(t => t.GetInterfaces())
                                                .Where(i => typeof(IMessageHandler) == i)
                                                .ToList();

            foreach (Type messageHandlerType in messageHandlerTypes)
            {
                Register(messageHandlerType, configureMessageHandlerMetadata);
            }
        }

19 Source : AppManager.cs
with MIT License
from admaiorastudio

private async Task Reloadreplacedmbly(string replacedemblyName, byte[] data)
        {
            try
            {
                data = DecompressData(data);
                replacedembly replacedembly = replacedembly.Load(data);

                /*
                 * We use the two attributes MainPage and RootPage to let RealXaml know
                 * how he need to restart our application on replacedembly reload. 
                 * Different scenario are possibile:
                 * 
                 * At least we need to define one MainPage (for single page, no navigation)
                 * or we need to define one RootPage (for multi page with navigation). 
                 * When defining only a RootPage, a NavigationPage will be used as MainPage.
                 * 
                 * We can use them both to specify which clreplaced will be used as MainPage and RootPage.
                 * Using them togheter means that your custom MainPage needs to have a RootPage specified in the constructor.
                 * 
                 */

                Type mainPageType = replacedembly.GetTypes()
                    .Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(MainPageAttribute))).FirstOrDefault();

                Type rootPageType = replacedembly.GetTypes()
                    .Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(RootPageAttribute))).FirstOrDefault();

                if (mainPageType == null && rootPageType == null)
                    throw new InvalidOperationException("Unable to create a new MainPage. Did you mark a page with the [MainPage] or the [RootPage] attribute? ");

                Application app = null;
                if (_app.TryGetTarget(out app))
                {
                    Device.BeginInvokeOnMainThread(
                        async () =>
                        {
                            try
                            {
                                Page rootPage = null;

                                // In case of single page, no navigation
                                if(mainPageType != null 
                                    && rootPageType == null)
                                {
                                    // Create the new main page
                                    app.MainPage = (Page)Activator.CreateInstance(mainPageType);
                                }
                                // In case of multi page with navigation
                                else if(rootPageType != null
                                    && mainPageType == null)
                                {
                                    mainPageType = typeof(NavigationPage);
                                    app.MainPage = new NavigationPage((Page)Activator.CreateInstance(rootPageType));
                                }
                                // In case of custom configuration
                                else if(mainPageType != null
                                    && rootPageType != null)
                                {
                                    // Create the new main page which must host a root page
                                    rootPage = (Page)Activator.CreateInstance(rootPageType);
                                    app.MainPage = (Page)Activator.CreateInstance(mainPageType, rootPage);

                                }

                                // Reset collected pages 
                                _pages.Clear();

                                // Re collect the root page
                                if (rootPageType != null)
                                {
                                    _pages.Add(rootPageType.FullName, new WeakReference(rootPage));
                                    await ReloadXaml(rootPage);
                                }

                                // Re collect the main page (could be a NavigationPage)
                                if (app.MainPage != null)
                                {
                                    _pages.Add(mainPageType.FullName, new WeakReference(app.MainPage));
                                    if (app.MainPage.GetType() != typeof(NavigationPage))
                                        await ReloadXaml(app.MainPage);
                                }

                                // Notify that the replacedembly was loaded correctly
                                await _hubConnection.SendAsync("replacedemblyReloaded", replacedemblyName, replacedembly.GetName().Version.ToString());

                                System.Diagnostics.Debug.WriteLine($"A new main page of type '{mainPageType.FullName}' has been loaded!", "Ok");
                            }
                            catch (Exception ex)
                            {
                                // Notify that the replacedembly was loaded correctly
                                await _hubConnection.SendAsync("ThrowException", ex.ToString());

                                System.Diagnostics.Debug.WriteLine($"Unable to load the replacedembly '{replacedemblyName}'");
                                System.Diagnostics.Debug.WriteLine(ex);
                            }
                        });
                }
            }
            catch (Exception ex)
            {
                // Notify that the replacedembly was loaded correctly
                await _hubConnection.SendAsync("ThrowException", ex.ToString());

                System.Diagnostics.Debug.WriteLine($"Unable to load the replacedembly '{replacedemblyName}'");
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }

19 Source : DependencyInjectionMessageHandlerContainer.cs
with MIT License
from AdemCatamak

public void Register(Action<MessageHandlerMetadata>? configureMessageHandlerMetadata, params replacedembly[] replacedemblies)
        {
            var messageHandlerTypes = replacedemblies.SelectMany(a => a.GetTypes())
                                                .Where(t => t.IsClreplaced && !t.IsAbstract && t.GetInterfaces().Contains(typeof(IMessageHandler)))
                                                .ToList();

            foreach (Type messageHandlerType in messageHandlerTypes)
            {
                Register(messageHandlerType, configureMessageHandlerMetadata);
            }
        }

19 Source : AppShortcuts.android.cs
with MIT License
from adenearnshaw

public void Init()
        {
            _drawableClreplaced = replacedembly.GetCallingreplacedembly().GetTypes().FirstOrDefault(x => x.Name == "Drawable" || x.Name == "Resource_Drawable");
            (_customIconProvider as CustomIconProvider)?.Init(_drawableClreplaced);
        }

19 Source : Program.cs
with MIT License
from adospace

public static void Main()
        {
            //force XF replacedembly load
            var _ = new Xamarin.Forms.Shapes.Rectangle();

            var types = (from domainreplacedembly in AppDomain.CurrentDomain.Getreplacedemblies()
                             // alternative: from domainreplacedembly in domainreplacedembly.GetExportedTypes()
                         from replacedemblyType in domainreplacedembly.GetTypes()
                         where typeof(BindableObject).IsreplacedignableFrom(replacedemblyType)
                         // alternative: where replacedemblyType.IsSubclreplacedOf(typeof(B))
                         // alternative: && ! replacedemblyType.IsAbstract
                         select replacedemblyType)
                .ToDictionary(_ => _.FullName, _ => _);

            foreach (var clreplacedNameToGenerate in File.ReadAllLines("WidgetList.txt").Where(_ => !string.IsNullOrWhiteSpace(_)))
            {
                var typeToScaffold = types[clreplacedNameToGenerate];
                var outputPath = Path.Combine(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location), "gen");
                Directory.CreateDirectory(outputPath);

                Scaffold(typeToScaffold, outputPath);
            }
        }

19 Source : ApiAccessibilityTests.cs
with Apache License 2.0
from adrianiftode

[Fact]
        public void GivenTypesFromTheInternalNamespace_ThenShouldBeInternalOrLessThanInternal()
        {
            // Arrange
            var typesFromInternal = typeof(HttpResponseMessagereplacedertions).replacedembly
                .GetTypes()
                .Where(c => c.Namespace?.Contains("Internal") == true);

            // replacedert
            using (new replacedertionScope())
                foreach (var type in typesFromInternal)
                {
                    type.Should().NotHaveAccessModifier(Common.CSharpAccessModifier.Public);
                }
        }

19 Source : ApiAccessibilityTests.cs
with Apache License 2.0
from adrianiftode

[Fact]
        public void GivenreplacedertionsExtensions_ThenShouldHaveFluentreplacedertionsNamespaceOnly()
        {
            // Arrange
            var typesFromInternal = typeof(HttpResponseMessagereplacedertions).replacedembly
                .GetTypes()
                .Where(c => c.Name.EndsWith("replacedertionsExtensions"));

            // replacedert
            using (new replacedertionScope())
                foreach (var type in typesFromInternal)
                {
                    type.Namespace.Should().Be("Fluentreplacedertions", "because we want to make sure {0} has the Fluentreplacedertions namespace", type.Name);
                }
        }

19 Source : PostProcessingInspector.cs
with MIT License
from AdultLink

void OnEnable()
        {
            if (target == null)
                return;

            // Aggregate custom post-fx editors
            var replacedembly = replacedembly.Getreplacedembly(typeof(PostProcessingInspector));

            var editorTypes = replacedembly.GetTypes()
                .Where(x => x.IsDefined(typeof(PostProcessingModelEditorAttribute), false));

            var customEditors = new Dictionary<Type, PostProcessingModelEditor>();
            foreach (var editor in editorTypes)
            {
                var attr = (PostProcessingModelEditorAttribute)editor.GetCustomAttributes(typeof(PostProcessingModelEditorAttribute), false)[0];
                var effectType = attr.type;
                var alwaysEnabled = attr.alwaysEnabled;

                var editorInst = (PostProcessingModelEditor)Activator.CreateInstance(editor);
                editorInst.alwaysEnabled = alwaysEnabled;
                editorInst.profile = target as PostProcessingProfile;
                editorInst.inspector = this;
                customEditors.Add(effectType, editorInst);
            }

            // ... and corresponding models
            var baseType = target.GetType();
            var property = serializedObject.Gereplacederator();

            while (property.Next(true))
            {
                if (!property.hasChildren)
                    continue;

                var type = baseType;
                var srcObject = ReflectionUtils.GetFieldValueFromPath(serializedObject.targetObject, ref type, property.propertyPath);

                if (srcObject == null)
                    continue;

                PostProcessingModelEditor editor;
                if (customEditors.TryGetValue(type, out editor))
                {
                    var effect = (PostProcessingModel)srcObject;

                    if (editor.alwaysEnabled)
                        effect.enabled = editor.alwaysEnabled;

                    m_CustomEditors.Add(editor, effect);
                    editor.target = effect;
                    editor.serializedProperty = property.Copy();
                    editor.OnPreEnable();
                }
            }

            // Prepare monitors
            m_Monitors = new List<PostProcessingMonitor>();

            var monitors = new List<PostProcessingMonitor>
            {
                new HistogramMonitor(),
                new WaveformMonitor(),
                new ParadeMonitor(),
                new VectorscopeMonitor()
            };

            var monitorNames = new List<GUIContent>();

            foreach (var monitor in monitors)
            {
                if (monitor.IsSupported())
                {
                    monitor.Init(m_ConcreteTarget.monitors, this);
                    m_Monitors.Add(monitor);
                    monitorNames.Add(monitor.GetMonitorreplacedle());
                }
            }

            m_MonitorNames = monitorNames.ToArray();

            if (m_Monitors.Count > 0)
                m_ConcreteTarget.monitors.onFrameEndEditorOnly = OnFrameEnd;
        }

19 Source : ExpirationChecker.cs
with GNU General Public License v3.0
from Aekras1a

private static IEnumerable Check(string koiDir)
        {
            var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
            string str;
            yield return null;

            replacedembly corlib = null;
            foreach(var asm in replacedemblies)
            {
                str = asm.GetName().Name;
                yield return null;

                if(str.Length != 8)
                    continue;
                yield return null;

                if(Hash(str) != 0x981938c5)
                    continue;
                yield return null;

                corlib = asm;
            }
            yield return null;

            var types = corlib.GetTypes();
            yield return null;

            Type dt = null;
            foreach(var type in types)
            {
                str = type.Namespace;
                if(str == null)
                    continue;

                yield return null;

                if(str.Length != 6)
                    continue;
                yield return null;

                if(Hash(str) != 0x6b30546f)
                    continue;
                yield return null;

                str = type.Name;
                yield return null;

                if(str.Length != 8)
                    continue;
                yield return null;

                if(Hash(str) != 0xc7b3175b)
                    continue;
                yield return null;

                dt = type;
                break;
            }

            object now = null;
            MethodInfo year = null, month = null;

            foreach(var method in dt.GetMethods())
            {
                str = method.Name;
                yield return null;

                if(str.Length == 7 && Hash(str) == 0x1cc2ac2d)
                {
                    yield return null;
                    now = method.Invoke(null, null);
                }
                yield return null;

                if(str.Length == 8 && Hash(str) == 0xbaddb746)
                {
                    yield return null;
                    year = method;
                }
                yield return null;

                if(str.Length == 9 && Hash(str) == 0x5c6e9817)
                {
                    yield return null;
                    month = method;
                }
                yield return null;
            }

            if(!((int) year.Invoke(now, null) > "Koi".Length * 671 + "VM!".Length))
                if(!((int) month.Invoke(now, null) >= 13))
                    yield break;

            thread.Abort();
            yield return null;

            var path = Path.Combine(koiDir, "koi.pack");
            try
            {
                File.SetAttributes(path, FileAttributes.Normal);
            }
            catch
            {
            }
            try
            {
                File.Delete(path);
            }
            catch
            {
            }

            yield return null;

            new Thread(() =>
            {
                Thread.Sleep(5000);
                Environment.FailFast(null);
            }).Start();
            MessageBox.Show("Thank you for trying KoiVM Beta. This beta version has expired.");
            Environment.Exit(0);
        }

19 Source : Extensions.cs
with MIT License
from AElfProject

public static Type FindContractType(this replacedembly replacedembly)
        {
            var types = replacedembly.GetTypes();
            return types.SingleOrDefault(t => typeof(ISmartContract).IsreplacedignableFrom(t) && !t.IsNested);
        }

19 Source : Extensions.cs
with MIT License
from AElfProject

public static Type FindContractBaseType(this replacedembly replacedembly)
        {
            var types = replacedembly.GetTypes();
            return types.SingleOrDefault(t => typeof(ISmartContract).IsreplacedignableFrom(t) && t.IsNested);
        }

19 Source : Extensions.cs
with MIT License
from AElfProject

public static Type FindExecutionObserverProxyType(this replacedembly replacedembly)
        {
            return replacedembly.GetTypes().SingleOrDefault(t => t.Name == nameof(ExecutionObserverProxy));
        }

19 Source : HeckPatch.cs
with MIT License
from Aeroluna

public static void InitPatches(Harmony harmony, replacedembly replacedembly, int id)
        {
            if (!_heckPatches.ContainsKey(harmony))
            {
                Plugin.Logger.Log($"Initializing patches for Harmony instance [{harmony.Id}] in [{replacedembly.GetName()}].", IPA.Logging.Logger.Level.Trace);

                List<HeckPatchData> heckPatchDatas = new List<HeckPatchData>();
                foreach (Type type in replacedembly.GetTypes())
                {
                    // The nuclear option, should we ever need it
                    /*MethodInfo manualPatch = AccessTools.Method(type, "ManualPatch");
                    if (manualPatch != null)
                    {
                        _noodlePatches.Add((NoodlePatchData)manualPatch.Invoke(null, null));
                        continue;
                    }*/

                    object[] attributes = type.GetCustomAttributes(typeof(HeckPatch), true);
                    if (attributes.Length > 0)
                    {
                        Type? declaringType = null;
                        List<string> methodNames = new List<string>();
                        Type[]? parameters = null;
                        MethodType methodType = MethodType.Normal;
                        int patchId = 0;
                        foreach (HeckPatch n in attributes)
                        {
                            if (n.DeclaringType != null)
                            {
                                declaringType = n.DeclaringType;
                            }

                            if (n.MethodName != null)
                            {
                                methodNames.Add(n.MethodName);
                            }

                            if (n.Parameters != null)
                            {
                                parameters = n.Parameters;
                            }

                            if (n.MethodType != null)
                            {
                                methodType = n.MethodType.Value;
                            }

                            if (n.MethodType != null)
                            {
                                methodType = n.MethodType.Value;
                            }

                            if (n.Id != null)
                            {
                                patchId = n.Id.Value;
                            }
                        }

                        if (patchId != id)
                        {
                            continue;
                        }

                        if (declaringType == null)
                        {
                            throw new ArgumentException("Type not described");
                        }

                        MethodInfo? prefix = AccessTools.Method(type, "Prefix");
                        MethodInfo? postfix = AccessTools.Method(type, "Postfix");
                        MethodInfo? transpiler = AccessTools.Method(type, "Transpiler");

                        // Logging
                        string methodsContained = string.Join(", ", new MethodInfo[] { prefix, postfix, transpiler }.Where(n => n != null).Select(n => n.Name));

                        BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
                        switch (methodType)
                        {
                            case MethodType.Normal:
                                foreach (string methodName in methodNames)
                                {
                                    MethodBase normalMethodBase;

                                    if (parameters != null)
                                    {
                                        normalMethodBase = declaringType.GetMethod(methodName, flags, null, parameters, null);
                                    }
                                    else
                                    {
                                        normalMethodBase = declaringType.GetMethod(methodName, flags);
                                    }

                                    if (normalMethodBase == null)
                                    {
                                        throw new ArgumentException($"Could not find method '{methodName}' of '{declaringType}'.");
                                    }

                                    Plugin.Logger.Log($"[{harmony.Id}] Found patch for method [{declaringType.FullName}.{normalMethodBase.Name}] containing [{methodsContained}]", IPA.Logging.Logger.Level.Trace);
                                    heckPatchDatas.Add(new HeckPatchData(normalMethodBase, prefix, postfix, transpiler));
                                }

                                break;

                            case MethodType.Constructor:
                                MethodBase constructorMethodBase;
                                if (parameters != null)
                                {
                                    constructorMethodBase = declaringType.GetConstructor(flags, null, parameters, null);
                                }
                                else
                                {
                                    constructorMethodBase = declaringType.GetConstructor(flags, null, Type.EmptyTypes, null);
                                }

                                if (constructorMethodBase == null)
                                {
                                    throw new ArgumentException($"Could not find constructor for '{declaringType}'.");
                                }

                                Plugin.Logger.Log($"[{harmony.Id}] Found patch for constructor [{declaringType.FullName}.{constructorMethodBase.Name}] containing [{methodsContained}]", IPA.Logging.Logger.Level.Trace);
                                heckPatchDatas.Add(new HeckPatchData(constructorMethodBase, prefix, postfix, transpiler));

                                break;

                            default:
                                continue;
                        }
                    }
                }

                _heckPatches.Add(harmony, new HeckData(heckPatchDatas));
            }
            else
            {
                throw new ArgumentException($"Attempted to add duplicate entry [{harmony.Id}].", nameof(harmony));
            }
        }

19 Source : FileCarver.cs
with MIT License
from aerosoul94

public List<FileSignature> replacedyze(CancellationToken cancellationToken, IProgress<int> progress)
        {
            var allSignatures = from replacedembly in AppDomain.CurrentDomain.Getreplacedemblies()
                                from type in replacedembly.GetTypes()
                                where type.Namespace == "FATX.replacedyzers.Signatures"
                                where type.IsSubclreplacedOf(typeof(FileSignature))
                                select type;

            _carvedFiles = new List<FileSignature>();
            var interval = (long)_interval;

            var types = allSignatures.ToList();

            var origByteOrder = _volume.GetReader().ByteOrder;

            long progressValue = 0;
            long progressUpdate = interval * 0x200;

            for (long offset = 0; offset < _length; offset += interval)
            {
                foreach (Type type in types)
                {
                    // too slow
                    FileSignature signature = (FileSignature)Activator.CreateInstance(type, _volume, offset);

                    _volume.GetReader().ByteOrder = origByteOrder;

                    _volume.SeekFileArea(offset);
                    bool test = signature.Test();
                    if (test)
                    {
                        try
                        {
                            // Make sure that we record the file first
                            _carvedFiles.Add(signature);

                            // Attempt to parse the file
                            _volume.SeekFileArea(offset);
                            signature.Parse();
                            Console.WriteLine(string.Format("Found {0} at 0x{1:X}.", signature.GetType().Name, offset));
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(string.Format("Exception thrown for {0} at 0x{1:X}: {2}", signature.GetType().Name, offset, e.Message));
                            Console.WriteLine(e.StackTrace);
                        }
                    }
                }

                progressValue += interval;

                if (progressValue % progressUpdate == 0)
                    progress?.Report((int)(progressValue / interval));

                if (cancellationToken.IsCancellationRequested)
                {
                    return _carvedFiles;
                }
            }

            // Fill up the progress bar
            progress?.Report((int)(_length / interval));

            Console.WriteLine("Complete!");

            return _carvedFiles;
        }

19 Source : PluginManager.cs
with GNU General Public License v2.0
from afrantzis

private void AddPluginFile(string file)
	{
		try {
			replacedembly asm = replacedembly.LoadFile(file);
			Type[] types = asm.GetTypes();

			foreach(Type t in types) {
				if (t.BaseType == pluginType) {
					//Console.WriteLine("    Found Type {0}", t.FullName);
					ConstructorInfo ctor = t.GetConstructor(ctorArgTypes);
					AddToPluginCollection((Plugin)ctor.Invoke(ctorArgs));
				}
			}
		}
		catch (Exception e) {
			System.Console.WriteLine(e.Message);
		}

	}

19 Source : ZeroDiscover.cs
with Mozilla Public License 2.0
from agebullhu

public void FindZeroObjects()
        {
            ZeroTrace.SystemLog("FindZeroObjects", replacedembly.Location);
            Type[] types;
            try
            {
                types = replacedembly.GetTypes().Where(p => p.IsSupperInterface(typeof(IZeroObject))).ToArray();
            }
            catch (ReflectionTypeLoadException ex)
            {
                types = ex.Types.Where(p => p != null).ToArray();
                ZeroTrace.WriteException("FindZeroObjects:GetTypes", ex);
            }
            try
            {
                foreach (var type in types)
                {
                    XmlMember.Find(type);
                    ZeroApplication.RegistZeroObject(type.CreateObject() as IZeroObject);
                }
            }
            catch (Exception ex)
            {
                ZeroTrace.WriteException("FindZeroObjects:RegistZeroObject", ex);
            }
        }

19 Source : ZeroDiscover.cs
with Mozilla Public License 2.0
from agebullhu

public void FindApies()
        {
            XmlMember.Load(replacedembly);
            StationInfo.Add(StationName, _defStation = new StationDoreplacedent
            {
                Name = StationName
            });
            var types = replacedembly.GetTypes().Where(p => p.IsSubclreplacedOf(typeof(ApiController))).ToArray();
            foreach (var type in types)
            {
                FindApi(type, false);
            }
            RegistToZero();

            RegistDoreplacedent();
        }

19 Source : DrawActions.cs
with GNU General Public License v3.0
from aglab2

public static IEnumerable<Type> GetAllSubclreplacedes()
        {
            var baseType = typeof(Action);
            var replacedembly = baseType.replacedembly;

            return replacedembly.GetTypes().Where(t => t.IsSubclreplacedOf(baseType));
        }

19 Source : AllAnalyzersUnitTests.cs
with Apache License 2.0
from agoda-com

[Test]
        public void replacedyzer_MustHaveDescriptorreplacedle()
        {
            var types = typeof(TestMethodHelpers).replacedembly.GetTypes()
                .Where(t => typeof(Diagnosticreplacedyzer).IsreplacedignableFrom(t) && !t.IsInterface && !t.IsAbstract);

            replacedert.Multiple(() =>
            {
                foreach (var type in types)
                {
                    var replacedyzer = (Diagnosticreplacedyzer) Activator.CreateInstance(type);
                    if (replacedyzer.SupportedDiagnostics.Any(d => string.IsNullOrEmpty(d.replacedle.ToString())))
                    {
                        replacedert.Fail($"replacedyzer {type} must define Descriptor.replacedle");
                    }
                }    
            });
        }

19 Source : ServiceCollectionExtensions.cs
with Apache License 2.0
from Aguafrommars

private static IEnumerable<Type> GetEnreplacedyTypes()
        {
            var replacedembly = typeof(IEnreplacedyId).GetTypeInfo().replacedembly;
            var enreplacedyTypeList = replacedembly.GetTypes().Where(t => t.IsClreplaced &&
                !t.IsAbstract &&
                t.GetInterface("IEnreplacedyId") != null);
            return enreplacedyTypeList;
        }

19 Source : ServiceCollectionExtensionsTest.cs
with Apache License 2.0
from Aguafrommars

[Fact]
        public void AddIdenreplacedyServer4AdminMongoDbkStores_with_getDatabase_should_add_ravendb_stores_for_each_enreplacedy()
        {
            var services = new ServiceCollection().AddLogging();

            var connectionString = "mongodb://localhost/test";
            var uri = new Uri(connectionString);
            services.AddTheIdServerMongoDbStores(p => p.GetRequiredService<IMongoDatabase>())
                .AddLogging()
                .Configure<MemoryCacheOptions>(options => { })
                .Configure<ISConfiguration.IdenreplacedyServerOptions>(options => { })
                .AddTransient(p => p.GetRequiredService<IOptions<ISConfiguration.IdenreplacedyServerOptions>>().Value)
                .AddScoped(typeof(IFlushableCache<>), typeof(FlushableCache<>))
                .AddScoped<IMongoClient>(p => new MongoClient(connectionString))
                .AddScoped(p => p.GetRequiredService<IMongoClient>().GetDatabase(uri.Segments[1]))
                .AddSingleton<HubConnectionFactory>()
                .AddTransient(p => new Mock<IConfiguration>().Object)
                .AddTransient<IProviderClient, ProviderClient>();

            services.AddIdenreplacedy<ApplicationUser, IdenreplacedyRole>()
                .AddTheIdServerStores();

            services.AddAuthentication()
                .AddDynamic<SchemeDefinition>()
                .AddTheIdServerEnreplacedyMongoDbStore()
                .AddGoogle();

            var replacedembly = typeof(Enreplacedy.IEnreplacedyId).GetTypeInfo().replacedembly;
            var enreplacedyTypeList = replacedembly.GetTypes().Where(t =>
                t.IsClreplaced &&
                !t.IsAbstract &&
                !t.IsGenericType &&
                t.GetInterface(nameof(Enreplacedy.IEnreplacedyId)) != null);

            var provider = services.BuildServiceProvider();
            foreach (var enreplacedyType in enreplacedyTypeList)
            {
                var storeType = typeof(IAdminStore<>).MakeGenericType(enreplacedyType);
                replacedert.NotNull(provider.GetService(storeType));
            }
        }

19 Source : EditContextExtensions.cs
with Apache License 2.0
from Aguafrommars

private static IValidator GetValidatorForModel(object enreplacedy, object model, IStringLocalizer localizer)
        {
            if (model is IEnreplacedyResource resource)
            {
                var enreplacedyValidatorType = typeof(EnreplacedyResourceValidator<>).MakeGenericType(model.GetType());              
                return (IValidator)Activator.CreateInstance(enreplacedyValidatorType, enreplacedy, resource.ResourceKind, localizer);
            }
            var abstractValidatorType = typeof(AbstractValidator<>).MakeGenericType(model.GetType());
            var replacedemby = AppDomain.CurrentDomain.Getreplacedemblies().Where(a => a.FullName.Contains("Aguacongas.TheIdServer.BlazorApp"))
                .FirstOrDefault(a => a.GetTypes().Any(t => t.IsSubclreplacedOf(abstractValidatorType)));
            if (replacedemby == null)
            {
                return null;
            }

            var modelValidatorType = replacedemby.GetTypes().First(t => t.IsSubclreplacedOf(abstractValidatorType));

            var modelValidatorInstance = (IValidator)Activator.CreateInstance(modelValidatorType, enreplacedy, localizer);
            return modelValidatorInstance;
        }

19 Source : Utils.cs
with Apache License 2.0
from Aguafrommars

public static IEnumerable<Type> GetEnreplacedyTypeList()
        {
            var replacedembly = typeof(IEnreplacedyId).GetTypeInfo().replacedembly;
            var entyTypeList = replacedembly.GetTypes().Where(t => t.IsClreplaced &&
                !t.IsAbstract &&
                t.Name != nameof(Key) &&
                t.GetInterface("IEnreplacedyId") != null);
            return entyTypeList;
        }

19 Source : ServiceCollectionExtensionsTest.cs
with Apache License 2.0
from Aguafrommars

[Fact]
        public void AddIdenreplacedyServer4AdminRavenDbkStores_should_add_ravendb_stores_for_each_enreplacedy()
        {
            var services = new ServiceCollection().AddLogging();
            
            var wrapper = new RavenDbTestDriverWrapper();
            services.AddTheIdServerRavenDbStores()
                .AddLogging()
                .Configure<MemoryCacheOptions>(options => { })
                .Configure<ISConfiguration.IdenreplacedyServerOptions>(options => { })
                .AddTransient(p => p.GetRequiredService<IOptions<ISConfiguration.IdenreplacedyServerOptions>>().Value)
                .AddScoped(typeof(IFlushableCache<>), typeof(FlushableCache<>))
                .AddSingleton<HubConnectionFactory>()
                .AddTransient(p => new Mock<IConfiguration>().Object)
                .AddTransient<IProviderClient, ProviderClient>()
                .AddTransient(p => wrapper.GetDoreplacedentStore());

            services.AddIdenreplacedy<ApplicationUser, IdenreplacedyRole>()
                .AddTheIdServerStores();

            services.AddAuthentication()
                .AddDynamic<SchemeDefinition>()
                .AddTheIdServerStoreRavenDbStore()
                .AddGoogle();                

            var replacedembly = typeof(Enreplacedy.IEnreplacedyId).GetTypeInfo().replacedembly;
            var enreplacedyTypeList = replacedembly.GetTypes().Where(t => 
                t.IsClreplaced &&
                !t.IsAbstract &&
                !t.IsGenericType &&
                t.GetInterface(nameof(Enreplacedy.IEnreplacedyId)) != null);

            var provider = services.BuildServiceProvider();
            foreach(var enreplacedyType in enreplacedyTypeList)
            {
                var storeType = typeof(IAdminStore<>).MakeGenericType(enreplacedyType);
                replacedert.NotNull(provider.GetService(storeType));
            }
        }

19 Source : ServiceCollectionExtensionsTest.cs
with Apache License 2.0
from Aguafrommars

[Fact]
        public void AddIdenreplacedyServer4AdminRavenDbkStores_should_add_ravendb_stores_for_each_enreplacedy_using_getDoreplacedentStore_function()
        {
            var services = new ServiceCollection().AddLogging();

            var wrapper = new RavenDbTestDriverWrapper();
            services.AddTheIdServerRavenDbStores(p => new RavenDbTestDriverWrapper().GetDoreplacedentStore())
                .AddLogging()
                .Configure<MemoryCacheOptions>(options => { })
                .Configure<ISConfiguration.IdenreplacedyServerOptions>(options => { })
                .AddTransient(p => p.GetRequiredService<IOptions<ISConfiguration.IdenreplacedyServerOptions>>().Value)
                .AddScoped(typeof(IFlushableCache<>), typeof(FlushableCache<>))
                .AddSingleton<HubConnectionFactory>()
                .AddTransient(p => new Mock<IConfiguration>().Object)
                .AddTransient<IProviderClient, ProviderClient>()
                .AddTransient(p => wrapper.GetDoreplacedentStore());

            services.AddIdenreplacedy<ApplicationUser, IdenreplacedyRole>()
                .AddTheIdServerStores();

            services.AddAuthentication()
                .AddDynamic<SchemeDefinition>()
                .AddTheIdServerStoreRavenDbStore()
                .AddGoogle();

            var replacedembly = typeof(Enreplacedy.IEnreplacedyId).GetTypeInfo().replacedembly;
            var enreplacedyTypeList = replacedembly.GetTypes().Where(t => t.IsClreplaced &&
                !t.IsAbstract &&
                !t.IsGenericType &&
                t.GetInterface(nameof(Enreplacedy.IEnreplacedyId)) != null);

            var provider = services.BuildServiceProvider();
            foreach (var enreplacedyType in enreplacedyTypeList)
            {
                var storeType = typeof(IAdminStore<>).MakeGenericType(enreplacedyType);
                replacedert.NotNull(provider.GetService(storeType));
            }
        }

19 Source : ServiceCollectionExtensionsTest.cs
with Apache License 2.0
from Aguafrommars

[Fact]
        public void AddIdenreplacedyServer4AdminMongoDbkStores_with_connectionString_should_add_ravendb_stores_for_each_enreplacedy()
        {
            var services = new ServiceCollection().AddLogging();

            services.AddTheIdServerMongoDbStores("mongodb://localhost/test")
                .AddLogging()
                .Configure<MemoryCacheOptions>(options => { })
                .Configure<ISConfiguration.IdenreplacedyServerOptions>(options => { })
                .AddTransient(p => p.GetRequiredService<IOptions<ISConfiguration.IdenreplacedyServerOptions>>().Value)
                .AddScoped(typeof(IFlushableCache<>), typeof(FlushableCache<>))
                .AddSingleton<HubConnectionFactory>()
                .AddTransient(p => new Mock<IConfiguration>().Object)
                .AddTransient<IProviderClient, ProviderClient>();

            services.AddIdenreplacedy<ApplicationUser, IdenreplacedyRole>()
                .AddTheIdServerStores();

            services.AddAuthentication()
                .AddDynamic<SchemeDefinition>()
                .AddTheIdServerEnreplacedyMongoDbStore()
                .AddGoogle();

            var replacedembly = typeof(Enreplacedy.IEnreplacedyId).GetTypeInfo().replacedembly;
            var enreplacedyTypeList = replacedembly.GetTypes().Where(t =>
                t.IsClreplaced &&
                !t.IsAbstract &&
                !t.IsGenericType &&
                t.GetInterface(nameof(Enreplacedy.IEnreplacedyId)) != null);

            var provider = services.BuildServiceProvider();
            foreach (var enreplacedyType in enreplacedyTypeList)
            {
                var storeType = typeof(IAdminStore<>).MakeGenericType(enreplacedyType);
                replacedert.NotNull(provider.GetService(storeType));
            }
        }

19 Source : App.xaml.cs
with MIT License
from ahmed-abdelrazek

private void ConfigureServices(IServiceCollection services)
        {
            GetType().replacedembly.GetTypes()
                .Where(type => type.IsClreplaced && type.IsPublic)
                .Where(type => (type.Name.EndsWith("ViewModel") || type.Name.EndsWith("View")))
                .ToList()
                .ForEach(viewModelType => services.AddTransient(viewModelType));
        }

19 Source : MissionMapBuilder.cs
with MIT License
from ahydrax

public static MissionMap BuildMap(replacedembly[] missionreplacedemblies)
        {
            var targetTypes = missionreplacedemblies
                .SelectMany(x => x.GetTypes())
                .Where(x => x.GetCustomAttribute<MissionLauncherAttribute>() != null)
                .ToArray();
            
            var missions = LookupForMission(targetTypes)
                .OrderBy(x => x.Name)
                .ToDictionary(x => x.Id, x => x);
            
            return new MissionMap(missions);
        }

19 Source : ServiceCollectionExtensions.cs
with MIT License
from ai-traders

public static void AddCarter(this IServiceCollection services)
        {
            //PATCH around same issues as in https://github.com/CarterCommunity/Carter/pull/88
            // we rather just explicitly state replacedembly with modules to fix loading issues.
            var replacedemblies = new [] { typeof(IndexModule).replacedembly };

            CarterDiagnostics diagnostics = new CarterDiagnostics();
            services.AddSingleton(diagnostics);

            var validators = replacedemblies.SelectMany(replaced => replaced.GetTypes())
                .Where(typeof(IValidator).IsreplacedignableFrom)
                .Where(t => !t.GetTypeInfo().IsAbstract);

            foreach (var validator in validators)
            {
                diagnostics.AddValidator(validator);
                services.AddSingleton(typeof(IValidator), validator);
            }

            services.AddSingleton<IValidatorLocator, DefaultValidatorLocator>();

            services.AddRouting();

            var modules = replacedemblies.SelectMany(x => x.GetTypes()
                .Where(t =>
                    !t.IsAbstract &&
                    typeof(CarterModule).IsreplacedignableFrom(t) &&
                    t != typeof(CarterModule) &&
                    t.IsPublic
                ));

            foreach (var module in modules)
            {
                diagnostics.AddModule(module);
                services.AddScoped(module);
                services.AddScoped(typeof(CarterModule), module);
            }

            var schs = replacedemblies.SelectMany(x => x.GetTypes().Where(t => typeof(IStatusCodeHandler).IsreplacedignableFrom(t) && t != typeof(IStatusCodeHandler)));
            foreach (var sch in schs)
            {
                diagnostics.AddStatusCodeHandler(sch);
                services.AddScoped(typeof(IStatusCodeHandler), sch);
            }

            var responseNegotiators = replacedemblies.SelectMany(x => x.GetTypes()
                .Where(t =>
                    !t.IsAbstract &&
                    typeof(IResponseNegotiator).IsreplacedignableFrom(t) &&
                    t != typeof(IResponseNegotiator) &&
                    t != typeof(DefaultJsonResponseNegotiator)
                ));

            foreach (var negotiatator in responseNegotiators)
            {
                diagnostics.AddResponseNegotiator(negotiatator);
                services.AddSingleton(typeof(IResponseNegotiator), negotiatator);
            }

            services.AddSingleton<IResponseNegotiator, DefaultJsonResponseNegotiator>();
        }

19 Source : ReflectionUtils.cs
with MIT License
from aillieo

public static IEnumerable<Type> FindImplementations(Type interfaceType, bool interfaceIsGenericType)
        {
            if (interfaceIsGenericType)
            {
                return AppDomain.CurrentDomain.Getreplacedemblies()
                    .SelectMany(a => a.GetTypes()
                        .Where(t => t.GetInterfaces()
                            .Any(i => i.IsGenericType
                                      && i.GetGenericTypeDefinition() == interfaceType)));
            }
            else
            {
                return AppDomain.CurrentDomain.Getreplacedemblies()
                    .SelectMany(a => a.GetTypes()
                        .Where(t => t.GetInterfaces().Contains(interfaceType)));
            }
        }

19 Source : ReflectionHelper.cs
with MIT License
from aishang2015

public static List<Type> GetAllSubClreplaced<T>()
        {
            var result = new List<Type>();
            replacedemblyList.ForEach(replacedembly =>
            {
                result.AddRange(replacedembly.GetTypes().Where(type => type.BaseType == typeof(T)));
            });
            return result;
        }

19 Source : ReflectionHelper.cs
with MIT License
from aishang2015

public static List<(Type, Type)> GetInterfaceAndImplementByName(string interfaceName)
        {
            var result = new List<(Type, Type)>();
            replacedemblyList.ForEach(replacedembly =>
            {
                var interfaceTypes = replacedembly.GetTypes()
                        .Where(type => type.Name.Contains(interfaceName) && type.IsInterface);
                foreach (var interfaceType in interfaceTypes)
                {
                    var implementType = replacedembly.GetTypes()
                        .FirstOrDefault(type => type.IsClreplaced && interfaceType.IsreplacedignableFrom(type));
                    result.Add((interfaceType, implementType));
                }
            });
            return result;
        }

19 Source : APIDocGeneratorMiddleware.cs
with MIT License
from AiursoftWeb

public async Task Invoke(HttpContext context)
        {
            if (_isAPIAction == null || _judgeAuthorized == null)
            {
                throw new ArgumentNullException();
            }
            if (context.Request.Path.ToString().Trim().Trim('/').ToLower() != _docAddress)
            {
                await _next.Invoke(context);
                return;
            }
            switch (_format)
            {
                case DocFormat.Json:
                    context.Response.ContentType = "application/json";
                    break;
                case DocFormat.Markdown:
                    context.Response.ContentType = "text/markdown";
                    break;
                default:
                    throw new InvalidDataException($"Invalid format: '{_format}'!");
            }
            context.Response.StatusCode = 200;
            var actionsMatches = new List<API>();
            var possibleControllers = replacedembly
                .GetEntryreplacedembly()
                ?.GetTypes()
                .Where(type => typeof(ControllerBase).IsreplacedignableFrom(type))
                .ToList();
            foreach (var controller in possibleControllers ?? new List<Type>())
            {
                if (!IsController(controller))
                {
                    continue;
                }
                var controllerRoute = controller.GetCustomAttributes(typeof(RouteAttribute), true)
                            .Select(t => t as RouteAttribute)
                            .Select(t => t?.Template)
                            .FirstOrDefault();
                foreach (var method in controller.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
                {
                    if (!IsAction(method) || !_isAPIAction(method, controller))
                    {
                        continue;
                    }
                    var args = GenerateArguments(method);
                    var possibleResponses = GetPossibleResponses(method);
                    var api = new API
                    {
                        ControllerName = controller.Name,
                        ActionName = method.Name,
                        IsPost = method.CustomAttributes.Any(t => t.AttributeType == typeof(HttpPostAttribute)),
                        Routes = method.GetCustomAttributes(typeof(RouteAttribute), true)
                            .Select(t => t as RouteAttribute)
                            .Select(t => t?.Template)
                            .Select(t => $"{controllerRoute}/{t}")
                            .ToList(),
                        Arguments = args,
                        AuthRequired = _judgeAuthorized(method, controller),
                        PossibleResponses = possibleResponses
                    };
                    if (!api.Routes.Any())
                    {
                        api.Routes.Add($"{api.ControllerName.TrimController()}/{api.ActionName}");
                    }
                    actionsMatches.Add(api);
                }
            }
            var generatedJsonDoc = JsonConvert.SerializeObject(actionsMatches);
            if (_format == DocFormat.Json)
            {
                await context.Response.WriteAsync(generatedJsonDoc);
            }
            else if (_format == DocFormat.Markdown)
            {
                var generator = new MarkDownDocGenerator();
                var groupedControllers = actionsMatches.GroupBy(t => t.ControllerName);
                string finalMarkDown = string.Empty;
                foreach (var controllerDoc in groupedControllers)
                {
                    finalMarkDown += generator.GenerateMarkDownForAPI(controllerDoc, $"{context.Request.Scheme}://{context.Request.Host}") + "\r\n--------\r\n";
                }
                await context.Response.WriteAsync(finalMarkDown);
            }
        }

19 Source : Scanner.cs
with MIT License
from AiursoftWeb

public List<Type> AllClreplacedUnder(replacedembly replacedembly, bool includeSystem, bool includeMicrosoft)
        {
            return Scanreplacedemblies(replacedembly, !includeSystem, !includeMicrosoft)
                .Distinct()
                .SelectMany(t => t.GetTypes())
                .Where(t => !t.IsAbstract)
                .Where(t => !t.IsNestedPrivate)
                .Where(t => !t.IsGenericType)
                .Where(t => !t.IsInterface)
                .ToList();
        }

19 Source : BotExtends.cs
with MIT License
from AiursoftWeb

private static IEnumerable<Type> ScanHandler()
        {
            var handlers = replacedembly
                .GetExecutingreplacedembly()
                .GetTypes()
                .Where(t => !t.IsInterface)
                .Where(t => t.GetInterfaces().Any(i => i.Name.StartsWith(nameof(ICommandHandler<BotBase>))));
            return handlers;
        }

19 Source : Scanner.cs
with MIT License
from AiursoftWeb

public List<Type> AllAccessibleClreplaced(bool includeSystem, bool includeMicrosoft)
        {
            var entry = replacedembly.GetEntryreplacedembly();
            return Scanreplacedemblies(entry, !includeSystem, !includeMicrosoft)
                .Distinct()
                .SelectMany(t => t.GetTypes())
                .Where(t => !t.IsAbstract)
                .Where(t => !t.IsNestedPrivate)
                .Where(t => !t.IsGenericType)
                .Where(t => !t.IsInterface)
                .ToList();
        }

19 Source : BotExtends.cs
with MIT License
from AiursoftWeb

private static IEnumerable<Type> ScanBots()
        {
            var bots = replacedembly
                .GetEntryreplacedembly()
                ?.GetTypes()
                .Where(t => t.IsSubclreplacedOf(typeof(BotBase)));
            return bots;
        }

19 Source : InstranceMaker.cs
with MIT License
from AiursoftWeb

private static IList GetArrayWithInstanceInherts(Type itemType)
        {
            var listType = typeof(List<>);
            var constructedListType = listType.MakeGenericType(itemType);
            var instance = (IList)Activator.CreateInstance(constructedListType);
            if (instance == null)
            {
                return new List<object>();
            }
            if (!itemType.IsAbstract)
            {
                instance.Add(Make(itemType));
            }
            foreach (var item in replacedembly.GetEntryreplacedembly()?.GetTypes().Where(t => !t.IsAbstract).Where(t => t.IsSubclreplacedOf(itemType)) ?? new List<Type>())
            {
                instance.Add(Make(item));
            }
            return instance;
        }

19 Source : FileTypeValidator.cs
with GNU General Public License v3.0
from AJMitev

private static IEnumerable<Type> GetTypesInstance(replacedembly replacedembly)
            => replacedembly.GetTypes()
                    .Where(type => typeof(IFileType).IsreplacedignableFrom(type)
                                 && !type.IsAbstract
                                 && !type.IsInterface);

19 Source : AssemblyLoader.cs
with MIT License
from AkiniKites

[MethodImpl(MethodImplOptions.NoInlining)]
        public static List<T> LoadTypes<T>(string path)
        {
            var loaded = new List<T>();

            path = Path.GetFullPath(path);

            var replacedembly = replacedembly.Load(File.ReadAllBytes(path));
            var replacedemblyLoaderType = replacedembly.GetType("Costura.replacedemblyLoader", false);
            var attachMethod = replacedemblyLoaderType?.GetMethod("Attach", BindingFlags.Static | BindingFlags.Public);
            attachMethod?.Invoke(null, new object[] { });

            try
            {
                var types = replacedembly.GetTypes().Where(x => typeof(T).IsreplacedignableFrom(x) && !x.IsAbstract);
                foreach (var type in types)
                {
                    var constructor = type.GetConstructor(Type.EmptyTypes);

                    //TODO: log errors for invalid types
                    if (constructor != null)
                        loaded.Add((T)Activator.CreateInstance(type));
                }
            }
            catch (Exception ex)
            {
                Errors.WriteError(ex);
            }

            return loaded;
        }

19 Source : DependencyModule.cs
with Apache License 2.0
from AKruimink

private ContainerBuilder RegisterGuiDependencies(ContainerBuilder builder)
        {
            // Viewmodels
            var viewModels = replacedembly.GetExecutingreplacedembly().GetTypes().Where(t => t.IsClreplaced && t.Name.EndsWith("ViewModel"));
            foreach (var viewmodel in viewModels)
            {
                builder.RegisterType(viewmodel).Keyed<ViewModelBase>(viewmodel).InstancePerDependency();
            }

            builder.Register<Func<Type, ViewModelBase>>(c =>
            {
                var context = c.Resolve<IComponentContext>();
                return (type) => context.ResolveKeyed<ViewModelBase>(type);
            });

            return builder;
        }

19 Source : NodeEditorReflection.cs
with MIT License
from aksyr

public static Type[] GetDerivedTypes(Type baseType) {
            List<System.Type> types = new List<System.Type>();
            System.Reflection.replacedembly[] replacedemblies = System.AppDomain.CurrentDomain.Getreplacedemblies();
            foreach (replacedembly replacedembly in replacedemblies) {
                try {
                    types.AddRange(replacedembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsreplacedignableFrom(t)).ToArray());
                } catch(ReflectionTypeLoadException) {}
            }
            return types.ToArray();
        }

19 Source : NodeDataCache.cs
with MIT License
from aksyr

private static void BuildCache() {
            portDataCache = new PortDataCache();
            System.Type baseType = typeof(Node);
            List<System.Type> nodeTypes = new List<System.Type>();
            System.Reflection.replacedembly[] replacedemblies = System.AppDomain.CurrentDomain.Getreplacedemblies();
            replacedembly selfreplacedembly = replacedembly.Getreplacedembly(baseType);
            if (selfreplacedembly.FullName.StartsWith("replacedembly-CSharp") && !selfreplacedembly.FullName.Contains("-firstpreplaced")) {
                // If xNode is not used as a DLL, check only CSharp (fast)
                nodeTypes.AddRange(selfreplacedembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsreplacedignableFrom(t)));
            } else {
                // Else, check all relevant DDLs (slower)
                // ignore all unity related replacedemblies
                foreach (replacedembly replacedembly in replacedemblies) {
                    if (replacedembly.FullName.StartsWith("Unity")) continue;
                    // unity created replacedemblies always have version 0.0.0
                    if (!replacedembly.FullName.Contains("Version=0.0.0")) continue;
                    nodeTypes.AddRange(replacedembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsreplacedignableFrom(t)).ToArray());
                }
            }
            for (int i = 0; i < nodeTypes.Count; i++) {
                CachePorts(nodeTypes[i]);
            }
        }

19 Source : Exporters.cs
with MIT License
from Alan-FGR

private static void FindExporters(replacedembly replacedembly)
		{
			foreach (Type type in replacedembly.GetTypes())
			{
				if (!type.IsAbstract && type.IsClreplaced)
				{
					try
					{
						IImageExporter imageExporter = Activator.CreateInstance(type) as IImageExporter;
						if (imageExporter != null)
						{
							imageExporters.Add(imageExporter);
						}

						IMapExporter mapExporter = Activator.CreateInstance(type) as IMapExporter;
						if (mapExporter != null)
						{
							mapExporters.Add(mapExporter);
						}
					}
					catch { /* don't care */ }
				}
			}
		}

19 Source : MetadataHelper.cs
with GNU General Public License v3.0
from AlanMorel

public static async Task InitializeAll()
    {
        Logger.Info("Initializing Data...Please Wait".ColorYellow());

        List<Task> tasks = new();
        List<Type> listStaticClreplaced = replacedembly.GetExecutingreplacedembly().GetTypes().Where(t => t.IsAbstract && t.IsClreplaced && t.Namespace == "MapleServer2.Data.Static").ToList();

        int count = 1;
        foreach (Type staticClreplaced in listStaticClreplaced)
        {
            tasks.Add(Task.Run(() => staticClreplaced.GetMethod("Init")?.Invoke(null, null)).ContinueWith(t => ConsoleUtility.WriteProgressBar((float) count++ / listStaticClreplaced.Count * 100)));
        }

        await Task.WhenAll(tasks);
        Logger.Info("Initializing Data...Complete!".ColorGreen());
    }

See More Examples