System.Type.IsAssignableFrom(System.Type)

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

8165 Examples 7

19 Source : CelesteNetServerModuleWrapper.cs
with MIT License
from 0x0ade

public void Load() {
            if (Module != null)
                return;
            Logger.Log(LogLevel.INF, "module", $"Loading {ID}");

            Loadreplacedembly();

            if (replacedembly == null)
                throw new Exception($"Failed to load replacedembly for {ID} - {replacedemblyPath}");

            foreach (Type type in replacedembly.GetTypes()) {
                if (typeof(CelesteNetServerModule).IsreplacedignableFrom(type) && !type.IsAbstract) {
                    Module = (CelesteNetServerModule?) Activator.CreateInstance(type);
                    break;
                }
            }

            if (Module == null)
                throw new Exception($"Found no module clreplaced in {ID} - {replacedemblyPath}");

            lock (Server.Modules) {
                Server.Modules.Add(Module);
                Server.ModuleMap[Module.GetType()] = Module;
            }

            if (Server.Initialized) {
                Logger.Log(LogLevel.INF, "module", $"Initializing {ID} (late)");
                Module.Init(this);
                if (Server.IsAlive) {
                    Logger.Log(LogLevel.INF, "module", $"Starting {ID} (late)");
                    Module.Start();
                }
                Server.Data.RescanDataTypes(replacedembly.GetTypes());
            }
        }

19 Source : DataContext.cs
with MIT License
from 0x0ade

public void RescanDataTypes(Type[] types) {
            foreach (Type type in types) {
                if (type.IsAbstract)
                    continue;

                if (typeof(DataType).IsreplacedignableFrom(type)) {
                    RuntimeHelpers.RunClreplacedConstructor(type.TypeHandle);

                    string? id = null;
                    string? source = null;
                    for (Type parent = type; parent != typeof(object) && id.IsNullOrEmpty() && source.IsNullOrEmpty(); parent = parent.BaseType ?? typeof(object)) {
                        id = parent.GetField("DataID", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) as string;
                        source = parent.GetField("DataSource", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) as string;
                    }

                    if (id.IsNullOrEmpty()) {
                        Logger.Log(LogLevel.WRN, "data", $"Found data type {type.FullName} but no DataID");
                        continue;
                    }

                    if (source.IsNullOrEmpty()) {
                        Logger.Log(LogLevel.WRN, "data", $"Found data type {type.FullName} but no DataSource");
                        continue;
                    }

                    if (IDToDataType.ContainsKey(id)) {
                        Logger.Log(LogLevel.WRN, "data", $"Found data type {type.FullName} but conflicting ID {id}");
                        continue;
                    }

                    Logger.Log(LogLevel.INF, "data", $"Found data type {type.FullName} with ID {id}");
                    IDToDataType[id] = type;
                    DataTypeToID[type] = id;
                    DataTypeToSource[type] = source;

                } else if (typeof(MetaType).IsreplacedignableFrom(type)) {
                    RuntimeHelpers.RunClreplacedConstructor(type.TypeHandle);

                    string? id = null;
                    for (Type parent = type; parent != typeof(object) && id.IsNullOrEmpty(); parent = parent.BaseType ?? typeof(object)) {
                        id = parent.GetField("MetaID", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) as string;
                    }

                    if (id.IsNullOrEmpty()) {
                        Logger.Log(LogLevel.WRN, "data", $"Found meta type {type.FullName} but no MetaID");
                        continue;
                    }

                    if (IDToMetaType.ContainsKey(id)) {
                        Logger.Log(LogLevel.WRN, "data", $"Found meta type {type.FullName} but conflicting ID {id}");
                        continue;
                    }

                    Logger.Log(LogLevel.INF, "data", $"Found meta type {type.FullName} with ID {id}");
                    IDToMetaType[id] = type;
                    MetaTypeToID[type] = id;
                }
            }
        }

19 Source : ColumnPropertyTypeParserTest.cs
with MIT License
from 0x1000000

[Test]
        public void Test()
        {
            var allTypes = typeof(TableColumn).replacedembly.GetTypes().Where(t => typeof(TableColumn).IsreplacedignableFrom(t)).ToList();

            foreach (var type in allTypes)
            {
                if (type.Name != nameof(TableColumn))
                {
                    replacedert.AreEqual("Success", ColumnPropertyTypeParser.Parse(type.Name, this, "Success"));
                }
            }
        }

19 Source : UraganoBuilder.cs
with MIT License
from 1100100

private void RegisterInterceptors()
        {
            var interceptors = ReflectHelper.GetDependencyTypes().FindAll(t => typeof(IInterceptor).IsreplacedignableFrom(t));
            foreach (var interceptor in interceptors)
            {
                RegisterScopedService(interceptor);
            }
        }

19 Source : UraganoBuilder.cs
with MIT License
from 1100100

private void RegisterServerServices()
        {
            if (!RegisterSingletonService<ServerDefaultInterceptor>())
                return;
            RegisterSingletonService<IBootstrap, ServerBootstrap>();
            AddHostedService<BootstrapStartup>();
            var types = ReflectHelper.GetDependencyTypes();
            var services = types.Where(t => t.IsInterface && typeof(IService).IsreplacedignableFrom(t)).Select(@interface => new
            {
                Interface = @interface,
                Implementation = types.FirstOrDefault(p => p.IsClreplaced && p.IsPublic && !p.IsAbstract && !p.Name.EndsWith("_____UraganoClientProxy") && @interface.IsreplacedignableFrom(p))
            }).Where(p => p.Implementation != null);

            foreach (var service in services)
            {
                //此处不使用接口来注册是避免同时启用服务器端和客户端冲突
                RegisterScopedService(service.Implementation);
                //RegisterScopedService(service.Interface, service.Implementation);
            }

            RegisterInterceptors();
        }

19 Source : UraganoBuilder.cs
with MIT License
from 1100100

private void RegisterClientServices()
        {
            if (!RegisterSingletonService<IClientFactory, ClientFactory>())
                return;
            AddHostedService<RemotingClientStartup>();
            RegisterSingletonService<ClientDefaultInterceptor>();
            RegisterSingletonService<IRemotingInvoke, RemotingInvoke>();
            RegisterSingletonService<ICircuitBreaker, PollyCircuitBreaker>();

            var types = ReflectHelper.GetDependencyTypes();
            var services = types.Where(t => t.IsInterface && typeof(IService).IsreplacedignableFrom(t)).ToList();

            //Generate client proxy
            var proxies = ProxyGenerator.GenerateProxy(services);
            foreach (var service in services)
            {
                //Register proxy clreplaced,For support meta data using scope.
                RegisterScopedService(service, proxies.FirstOrDefault(p => service.IsreplacedignableFrom(p)));
            }

            RegisterInterceptors();
        }

19 Source : ProxyGenerator.cs
with MIT License
from 1100100

public static List<Type> GenerateProxy(List<Type> interfaces)
        {
            if (interfaces.Any(p => !p.IsInterface && !typeof(IService).IsreplacedignableFrom(p)))
                throw new ArgumentException("The proxy object must be an interface and inherit IService.", nameof(interfaces));

            var replacedemblies = DependencyContext.Default.RuntimeLibraries.SelectMany(i => i.GetDefaultreplacedemblyNames(DependencyContext.Default).Select(z => replacedembly.Load(new replacedemblyName(z.Name)))).Where(i => !i.IsDynamic);

            var types = replacedemblies.Select(p => p.GetType()).Except(interfaces);
            replacedemblies = types.Aggregate(replacedemblies, (current, type) => current.Append(type.replacedembly));

            var trees = interfaces.Select(GenerateProxyTree).ToList();

            if (UraganoOptions.Output_DynamicProxy_SourceCode.Value)
            {
                for (var i = 0; i < trees.Count; i++)
                {
                    File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{interfaces[i].Name}.Implement.cs"),
                        trees[i].ToString());
                }
            }

            using (var stream = CompileClientProxy(trees,
                replacedemblies.Select(x => MetadataReference.CreateFromFile(x.Location))
                    .Concat(new[]
                    {
                        MetadataReference.CreateFromFile(typeof(Task).GetTypeInfo().replacedembly.Location)
                    })))
            {
                var replacedembly = replacedemblyLoadContext.Default.LoadFromStream(stream);
                return replacedembly.GetExportedTypes().ToList();
            }
        }

19 Source : ServiceBuilder.cs
with MIT License
from 1100100

public async Task StartAsync(CancellationToken cancellationToken)
        {
            UraganoSettings.ClientGlobalInterceptors.Reverse();
            UraganoSettings.ServerGlobalInterceptors.Reverse();

            var enableClient = ServiceProvider.GetService<ILoadBalancing>() != null;
            var enableServer = UraganoSettings.ServerSettings != null;

            var types = ReflectHelper.GetDependencyTypes();
            var services = types.Where(t => t.IsInterface && typeof(IService).IsreplacedignableFrom(t)).Select(@interface => new
            {
                Interface = @interface,
                Implementation = types.FirstOrDefault(p => p.IsClreplaced && p.IsPublic && !p.IsAbstract && !p.Name.EndsWith("_____UraganoClientProxy") && @interface.IsreplacedignableFrom(p))
            }).ToList();

            foreach (var service in services)
            {
                var imp = service.Implementation;

                var routeAttr = service.Interface.GetCustomAttribute<ServiceRouteAttribute>();
                var routePrefix = routeAttr == null ? $"{service.Interface.Namespace}/{service.Interface.Name}" : routeAttr.Route;


                var interfaceMethods = service.Interface.GetMethods();

                List<MethodInfo> implementationMethods = null;
                if (enableServer && imp != null)
                    implementationMethods = imp.GetMethods().ToList();

                var disableClientIntercept = service.Interface.GetCustomAttribute<NonInterceptAttribute>(true) != null;
                var clientClreplacedInterceptors = new List<Type>();
                if (!disableClientIntercept)
                    clientClreplacedInterceptors = service.Interface.GetCustomAttributes(true).Where(p => p is IInterceptor)
                    .Select(p => p.GetType()).ToList();

                var serverClreplacedInterceptors = new List<Type>();
                var disableServerIntercept = false;
                if (enableServer && imp != null)
                {
                    disableServerIntercept = imp.GetCustomAttribute<NonInterceptAttribute>(true) != null;
                    if (!disableServerIntercept)
                        serverClreplacedInterceptors = imp.GetCustomAttributes(true).Where(p => p is IInterceptor)
                            .Select(p => p.GetType()).ToList();
                }

                foreach (var interfaceMethod in interfaceMethods)
                {
                    MethodInfo serverMethod = null;
                    var idAttr = interfaceMethod.GetCustomAttribute<ServiceRouteAttribute>();
                    var route = idAttr == null ? $"{routePrefix}/{interfaceMethod.Name}" : $"{routePrefix}/{idAttr.Route}";

                    var clientInterceptors = new List<Type>();
                    if (enableClient && !disableClientIntercept && interfaceMethod.GetCustomAttribute<NonInterceptAttribute>(true) == null)
                    {
                        clientInterceptors.AddRange(UraganoSettings.ClientGlobalInterceptors);
                        clientInterceptors.AddRange(clientClreplacedInterceptors);
                        clientInterceptors.AddRange(interfaceMethod.GetCustomAttributes(true)
                            .Where(p => p is IInterceptor).Select(p => p.GetType()).ToList());
                        clientInterceptors.Reverse();
                    }


                    var serverInterceptors = new List<Type>();
                    if (enableServer && imp != null)
                    {
                        serverMethod = implementationMethods.First(p => IsImplementationMethod(interfaceMethod, p));
                        if (!disableServerIntercept && serverMethod?.GetCustomAttribute<NonInterceptAttribute>(true) == null)
                        {
                            serverInterceptors.AddRange(UraganoSettings.ServerGlobalInterceptors);
                            serverInterceptors.AddRange(serverClreplacedInterceptors.ToList());
                            if (serverMethod != null)
                                serverInterceptors.AddRange(serverMethod.GetCustomAttributes(true)
                                    .Where(p => p is IInterceptor).Select(p => p.GetType()).ToList());
                            serverInterceptors.Reverse();
                        }
                    }

                    ServiceFactory.Create(route, serverMethod, interfaceMethod, serverInterceptors, clientInterceptors);
                }
            }

            await Task.CompletedTask;
        }

19 Source : AdditionalTiers.cs
with GNU General Public License v3.0
from 1330-Studios

public override void OnApplicationStart() {
            var asmTypes = replacedembly.GetTypes();
            var ttypes = new Stack<SType>();
            for (int i = 0; i < asmTypes.Length; i++)
                if (typeof(TowerTask).IsreplacedignableFrom(asmTypes[i]) && !typeof(TowerTask).FullName.Equals(asmTypes[i].FullName))
                    ttypes.Push(asmTypes[i]);
            List<TowerTask> tts = new();
            foreach (var type in ttypes) {
                var tt = (TowerTask)Activator.CreateInstance(type);
                if (((long)tt.tower) != -1)
                    tts.Add(tt);
            }
            Towers = tts.ToArray();

            if (!MelonPreferences.HasEntry("Additional Tier Addon Config", "Tier 6 required pop count multiplier")) {
                MelonPreferences.CreateCategory("Additional Tier Addon Config", "Additional Tier Addon Config");
                MelonPreferences.CreateEntry("Additional Tier Addon Config", "Tier 6 required pop count multiplier", (float)1);
                MelonPreferences.CreateEntry("Additional Tier Addon Config", "Display Format", ADisplay.style);
            }

            Globals.Load();

            HarmonyInstance.Patch(Method(typeof(Tower), nameof(Tower.Hilight)), postfix: new HarmonyMethod(Method(typeof(HighlightManager), nameof(HighlightManager.Highlight))));
            HarmonyInstance.Patch(Method(typeof(Tower), nameof(Tower.UnHighlight)), postfix: new HarmonyMethod(Method(typeof(HighlightManager), nameof(HighlightManager.UnHighlight))));

            MelonLogger.Msg(ConsoleColor.Red, "Additional Tier Addon Loaded!");
            CacheBuilder.Build();
            DisplayFactory.Build();
        }

19 Source : ServiceCollectionExtensions.cs
with MIT License
from 17MKH

public static IServiceCollection AddData(this IServiceCollection services, IModuleCollection modules)
    {
        foreach (var module in modules)
        {
            var dbOptions = module.Options!.Db;
            var dbContextType = module.Layerreplacedemblies.Core.GetTypes().FirstOrDefault(m => typeof(DbContext).IsreplacedignableFrom(m));

            var dbBuilder = services.AddMkhDb(dbContextType, opt =>
            {
                opt.Provider = dbOptions.Provider;

                //Sqlite数据库自动创建数据库文件
                if (dbOptions.ConnectionString.IsNull() && dbOptions.Provider == DbProvider.Sqlite)
                {
                    string dbFilePath = Path.Combine(AppContext.BaseDirectory, "db");
                    if (!Directory.Exists(dbFilePath))
                    {
                        Directory.CreateDirectory(dbFilePath);
                    }

                    dbOptions.ConnectionString = $"Data Source={dbFilePath}/{module.Code}.db;Mode=ReadWriteCreate";
                }

                opt.ConnectionString = dbOptions.ConnectionString;
                opt.Log = dbOptions.Log;
                opt.TableNamePrefix = dbOptions.TableNamePrefix;
                opt.TableNameSeparator = dbOptions.TableNameSeparator;
                opt.Version = dbOptions.Version;
            });

            //加载仓储
            dbBuilder.AddRepositoriesFromreplacedembly(module.Layerreplacedemblies.Core);

            //启用代码优先
            if (dbOptions.CodeFirst)
            {
                dbBuilder.AddCodeFirst(opt =>
                {
                    opt.CreateDatabase = dbOptions.CreateDatabase;
                    opt.UpdateColumn = dbOptions.UpdateColumn;
                    opt.InitData = dbOptions.InitData;
                    opt.InitDataFilePath = module.DbInitFilePath;
                });
            }

            //特性事务
            foreach (var dic in module.ApplicationServices)
            {
                dbBuilder.AddTransactionAttribute(dic.Key, dic.Value);
            }

            dbBuilder.Build();
        }

        return services;
    }

19 Source : ModuleCollection.cs
with MIT License
from 17MKH

private void LoadServicesConfigurator(ModuleDescriptor descriptor)
    {
        if (descriptor.Layerreplacedemblies.Core != null)
        {
            var servicesConfiguratorType = descriptor.Layerreplacedemblies.Core.GetTypes()
                .FirstOrDefault(m => typeof(IModuleServicesConfigurator).IsreplacedignableFrom(m));

            if (servicesConfiguratorType != null)
            {
                descriptor.ServicesConfigurator =
                    (IModuleServicesConfigurator)Activator.CreateInstance(servicesConfiguratorType);
            }
        }
    }

19 Source : ApplicationBuilderExtensions.cs
with MIT License
from 17MKH

public static IApplicationBuilder UseModules(this IApplicationBuilder app, IModuleCollection modules)
    {

        foreach (var module in modules)
        {
            if (module?.Layerreplacedemblies == null)
                continue;

            var replacedembly = module.Layerreplacedemblies.Web ?? module.Layerreplacedemblies.Api;
            if (replacedembly == null)
                continue;

            var middlewareConfigurator = replacedembly.GetTypes().FirstOrDefault(m => typeof(IModuleMiddlewareConfigurator).IsreplacedignableFrom(m));
            if (middlewareConfigurator != null)
            {
                ((IModuleMiddlewareConfigurator)Activator.CreateInstance(middlewareConfigurator))?.Configure(app);
            }
        }

        return app;
    }

19 Source : MvcBuilderExtensions.cs
with MIT License
from 17MKH

public static IModuleCollection AddModules(this IMvcBuilder builder, IModuleCollection modules)
    {
        foreach (var module in modules)
        {
            var replacedembly = module.Layerreplacedemblies.Web ?? module.Layerreplacedemblies.Api;
            if (replacedembly == null)
                continue;

            if (module?.Layerreplacedemblies == null)
                continue;

            builder.AddApplicationPart(module.Layerreplacedemblies.Web ?? module.Layerreplacedemblies.Api);

            builder.AddMvcOptions(options =>
            {
                var mvcOptionsConfigurator = replacedembly.GetTypes().FirstOrDefault(m => typeof(IModuleMvcOptionsConfigurator).IsreplacedignableFrom(m));
                if (mvcOptionsConfigurator != null)
                {
                    ((IModuleMvcOptionsConfigurator)Activator.CreateInstance(mvcOptionsConfigurator))?.Configure(options);
                }
            });
        }

        return modules;
    }

19 Source : PermissionResolver.cs
with MIT License
from 17MKH

private void Load()
    {
        var controllers = _controllerResolver.Controllers;
        foreach (var controller in controllers)
        {
            if (!controller.Actions.Any())
                continue;

            foreach (var action in controller.Actions)
            {
                var permission = new PermissionDescriptor
                {
                    Action = action.Name,
                    Controller = controller.Name,
                    ModuleCode = controller.Area,
                    HttpMethod = HttpMethod.Get,
                    Mode = PermissionMode.Authorization
                };

                //请求方式
                var httpMethodAttr = action.MethodInfo.CustomAttributes.FirstOrDefault(m => typeof(HttpMethodAttribute).IsreplacedignableFrom(m.AttributeType));
                if (httpMethodAttr != null)
                {
                    var httpMethodName = httpMethodAttr.AttributeType.Name.Replace("Http", "").Replace("Attribute", "");
                    permission.HttpMethod = (HttpMethod)Enum.Parse(typeof(HttpMethod), httpMethodName);
                }

                #region ==权限模式==

                var allowAnonymousAttribute = action.MethodInfo.CustomAttributes.FirstOrDefault(m => typeof(AllowAnonymousAttribute) == m.AttributeType);
                if (allowAnonymousAttribute != null)
                {
                    permission.Mode = PermissionMode.Anonymous;
                }
                else
                {
                    var allowLoginAttribute = action.MethodInfo.CustomAttributes.FirstOrDefault(m => typeof(AllowWhenAuthenticatedAttribute) == m.AttributeType);
                    if (allowLoginAttribute != null)
                    {
                        permission.Mode = PermissionMode.Login;
                    }
                }

                #endregion

                _descriptors.Add(permission);
            }
        }
    }

19 Source : CosmosJsonNetSerializer.cs
with MIT License
from 1iveowl

public override T FromStream<T>(Stream stream)
        {
            if (typeof(Stream).IsreplacedignableFrom(typeof(T)))
            {
                return (T)(object)stream;
            }

            using var streamReader = new StreamReader(stream);
            using var jsonTextReader = new JsonTextReader(streamReader);
            
            return _serializer.Deserialize<T>(jsonTextReader);
        }

19 Source : VerifyHelper.cs
with MIT License
from 1996v

public static T Is<T>(this T actual, T expected)
        {
            if (expected == null)
            {
                replacedert.Null(actual);
                return actual;
            }

            if (typeof(T) != typeof(string) && typeof(IEnumerable).GetTypeInfo().IsreplacedignableFrom(typeof(T)))
            {
                replacedert.Equal(
                    ((IEnumerable)expected).Cast<object>().ToArray(),
                    ((IEnumerable)actual).Cast<object>().ToArray());
                return actual;
            }

            replacedert.Equal(expected, actual);
            return actual;
        }

19 Source : Serializer.cs
with MIT License
from 2881099

public static T Deserialize(Dictionary<string, string> fields)
        {
            if (typeof(ISerializable).IsreplacedignableFrom(typeof(T)))
                return _deserializer.Value(fields);
            else
                return _propertyDeserializer.Value(fields);
        }

19 Source : Serializer.cs
with MIT License
from 2881099

public static Dictionary<string, string> Serialize(T obj)
        {
            if (typeof(ISerializable).IsreplacedignableFrom(typeof(T)))
                return _serializer.Value(obj);
            else
                return _propertySerializer.Value(obj);
        }

19 Source : TccMaster.cs
with MIT License
from 2881099

TccMaster<TDBKey> Then(Type tccUnitType, object state)
        {
            if (tccUnitType == null) throw new ArgumentNullException(nameof(tccUnitType));
            var unitTypeBase = typeof(TccUnit<>);
            if (state == null && tccUnitType.BaseType.GetGenericTypeDefinition() == typeof(TccUnit<>)) unitTypeBase = unitTypeBase.MakeGenericType(tccUnitType.BaseType.GetGenericArguments()[0]);
            else unitTypeBase = unitTypeBase.MakeGenericType(state.GetType());
            if (unitTypeBase.IsreplacedignableFrom(tccUnitType) == false) throw new ArgumentException($"{tccUnitType.DisplayCsharp(false)} 必须继承 {unitTypeBase.DisplayCsharp(false)}");
            var unitCtors = tccUnitType.GetConstructors();
            if (unitCtors.Length != 1 && unitCtors[0].GetParameters().Length > 0) throw new ArgumentException($"{tccUnitType.FullName} 不能使用构造函数");

            var unitTypeConved = Type.GetType(tccUnitType.replacedemblyQualifiedName);
            if (unitTypeConved == null) throw new ArgumentException($"{tccUnitType.FullName} 无效");
            var unit = unitTypeConved.CreateInstanceGetDefaultValue() as ITccUnit;
            (unit as ITccUnitSetter)?.SetState(state);
            _thenUnits.Add(unit);
            _thenUnitInfos.Add(new TccUnitInfo
            {
                Description = unitTypeConved.GetDescription(),
                Index = _thenUnitInfos.Count + 1,
                Stage = TccUnitStage.Try,
                State = state == null ? null : Newtonsoft.Json.JsonConvert.SerializeObject(state),
                StateTypeName = state?.GetType().replacedemblyQualifiedName,
                Tid = _tid,
                TypeName = tccUnitType.replacedemblyQualifiedName,
            });
            return this;
        }

19 Source : SagaMaster.cs
with MIT License
from 2881099

SagaMaster<TDBKey> Then(Type sagaUnitType, object state)
        {
            if (sagaUnitType == null) throw new ArgumentNullException(nameof(sagaUnitType));
            var unitTypeBase = typeof(SagaUnit<>);
            if (state == null && sagaUnitType.BaseType.GetGenericTypeDefinition() == typeof(SagaUnit<>)) unitTypeBase = unitTypeBase.MakeGenericType(sagaUnitType.BaseType.GetGenericArguments()[0]);
            else unitTypeBase = unitTypeBase.MakeGenericType(state.GetType());
            if (unitTypeBase.IsreplacedignableFrom(sagaUnitType) == false) throw new ArgumentException($"{sagaUnitType.DisplayCsharp(false)} 必须继承 {unitTypeBase.DisplayCsharp(false)}");
            var unitCtors = sagaUnitType.GetConstructors();
            if (unitCtors.Length != 1 && unitCtors[0].GetParameters().Length > 0) throw new ArgumentException($"{sagaUnitType.FullName} 不能使用构造函数");

            var unitTypeConved = Type.GetType(sagaUnitType.replacedemblyQualifiedName);
            if (unitTypeConved == null) throw new ArgumentException($"{sagaUnitType.FullName} 无效");
            var unit = unitTypeConved.CreateInstanceGetDefaultValue() as ISagaUnit;
            (unit as ISagaUnitSetter)?.SetState(state);
            _thenUnits.Add(unit);
            _thenUnitInfos.Add(new SagaUnitInfo
            {
                Description = unitTypeConved.GetDescription(),
                Index = _thenUnitInfos.Count + 1,
                Stage = SagaUnitStage.Commit,
                State = state == null ? null : Newtonsoft.Json.JsonConvert.SerializeObject(state),
                StateTypeName = state?.GetType().replacedemblyQualifiedName,
                Tid = _tid,
                TypeName = sagaUnitType.replacedemblyQualifiedName,
            });
            return this;
        }

19 Source : InternalExtensions.cs
with MIT License
from 2881099

static bool IsArrayOrList(this Type that) => that == null ? false : (that.IsArray || typeof(IList).IsreplacedignableFrom(that));

19 Source : Function.cs
with GNU Affero General Public License v3.0
from 3CORESec

private void initConfig()
        {
            _alerts = new List<ISender>();
            config = JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json"));
            if (string.IsNullOrEmpty(config.SlackPath))
                config.SlackPath = Environment.GetEnvironmentVariable("SLACKPATH");
            if (string.IsNullOrEmpty(config.WebhookChannel))
                config.WebhookChannel = Environment.GetEnvironmentVariable("WEBHOOKCHANNEL");
            if (string.IsNullOrEmpty(config.WebHookToken))
                config.WebHookToken = Environment.GetEnvironmentVariable("WEBHOOKTOKEN");
            if (string.IsNullOrEmpty(config.PostUrl))
                config.PostUrl = Environment.GetEnvironmentVariable("POSTURL");
            var type = typeof(ISender);
            var types = AppDomain.CurrentDomain.Getreplacedemblies()
                .SelectMany(s => s.GetTypes())
                .Where(p => type.IsreplacedignableFrom(p) && !p.IsInterface && !p.IsAbstract);
            types.ToList().ForEach(type => {
                ConstructorInfo ctor = type.GetConstructor(new[] { typeof(Storage<SessionLog>), typeof(Config), typeof(IMemoryCache) });
                ISender instance = ctor.Invoke(new object[] { _storage, config, memoryCache }) as ISender;
                _alerts.Add(instance);
            });
        }

19 Source : ListDecorator.cs
with MIT License
from 404Lcc

internal static MethodInfo GetEnumeratorInfo(TypeModel model, Type expectedType, Type itemType, out MethodInfo moveNext, out MethodInfo current)
        {

#if WINRT || COREFX
            TypeInfo enumeratorType = null, iteratorType;
#else
            Type enumeratorType = null, iteratorType;
#endif

            // try a custom enumerator
            MethodInfo getEnumerator = Helpers.GetInstanceMethod(expectedType, "GetEnumerator", null);

            Type getReturnType = null;
            if (getEnumerator != null)
            {
                getReturnType = getEnumerator.ReturnType;
                iteratorType = getReturnType
#if WINRT || COREFX || COREFX
                    .GetTypeInfo()
#endif
                    ;
                moveNext = Helpers.GetInstanceMethod(iteratorType, "MoveNext", null);
                PropertyInfo prop = Helpers.GetProperty(iteratorType, "Current", false);
                current = prop == null ? null : Helpers.GetGetMethod(prop, false, false);
#if PROFILE259
				if (moveNext == null && (model.MapType(ienumeratorType).GetTypeInfo().IsreplacedignableFrom(iteratorType.GetTypeInfo())))
#else
				if (moveNext == null && (model.MapType(ienumeratorType).IsreplacedignableFrom(iteratorType)))
#endif
				{
					moveNext = Helpers.GetInstanceMethod(model.MapType(ienumeratorType), "MoveNext", null);
                }
                // fully typed
                if (moveNext != null && moveNext.ReturnType == model.MapType(typeof(bool))
                    && current != null && current.ReturnType == itemType)
                {
                    return getEnumerator;
                }
                moveNext = current = getEnumerator = null;
            }
            
#if !NO_GENERICS
            // try IEnumerable<T>
            Type tmp = model.MapType(typeof(System.Collections.Generic.IEnumerable<>), false);
            
            if (tmp != null)
            {
                tmp = tmp.MakeGenericType(itemType);

#if WINRT || COREFX
                enumeratorType = tmp.GetTypeInfo();
#else
                enumeratorType = tmp;
#endif
            }
;
#if PROFILE259
			if (enumeratorType != null && enumeratorType.GetTypeInfo().IsreplacedignableFrom(expectedType
#else
			if (enumeratorType != null && enumeratorType.IsreplacedignableFrom(expectedType
#endif
#if WINRT || COREFX || PROFILE259
                .GetTypeInfo()
#endif
				))
            {
                getEnumerator = Helpers.GetInstanceMethod(enumeratorType, "GetEnumerator");
                getReturnType = getEnumerator.ReturnType;

#if WINRT || COREFX
                iteratorType = getReturnType.GetTypeInfo();
#else
                iteratorType = getReturnType;
#endif

                moveNext = Helpers.GetInstanceMethod(model.MapType(ienumeratorType), "MoveNext");
                current = Helpers.GetGetMethod(Helpers.GetProperty(iteratorType, "Current", false), false, false);
                return getEnumerator;
            }
#endif
			// give up and fall-back to non-generic IEnumerable
			enumeratorType = model.MapType(ienumerableType);
            getEnumerator = Helpers.GetInstanceMethod(enumeratorType, "GetEnumerator");
            getReturnType = getEnumerator.ReturnType;
            iteratorType = getReturnType
#if WINRT || COREFX
                .GetTypeInfo()
#endif
                ;
            moveNext = Helpers.GetInstanceMethod(iteratorType, "MoveNext");
            current = Helpers.GetGetMethod(Helpers.GetProperty(iteratorType,"Current", false), false, false);
            return getEnumerator;
        }

19 Source : Helpers.cs
with MIT License
from 404Lcc

internal static bool IsreplacedignableFrom(Type target, Type type)
        {
#if WINRT || PROFILE259
			return target.GetTypeInfo().IsreplacedignableFrom(type.GetTypeInfo());
#else
            return target.IsreplacedignableFrom(type);
#endif
        }

19 Source : TypeExtensions.cs
with MIT License
from 52ABP

public static bool IsEnumerable(this Type type)
        {
            if (type == typeof (string))
            {
                return false;
            }
            return typeof (IEnumerable).IsreplacedignableFrom(type);
        }

19 Source : Helper.cs
with MIT License
from 5minlab

internal static List<T> Convert<T>(List<object> l) {
            var retval = new List<T>();
            foreach(var el in l) {
                if(el == null) { continue; }
                if(typeof(T).IsreplacedignableFrom(el.GetType())) {
                    retval.Add((T)el);
                }
            }
            return retval;
        }

19 Source : AssignIconTool.cs
with MIT License
from 5argon

[MenuItem("replacedets/Minefield/Auto-replacedign all script icons")]
        public static void replacedignIcons()
        {
            var beaconClreplacedes = MonoImporter.GetAllRuntimeMonoScripts().Where((x) =>
            {
                //There are null returning from GetClreplaced as well (why?)
                var cls = x.GetClreplaced();
                return cls == null ? false : typeof(ILabelBeacon).IsreplacedignableFrom(cls);
            });

            Texture2D navigationBeaconIcon = replacedetDatabase.LoadreplacedetAtPath<Texture2D>(replacedetDatabase.GUIDToreplacedetPath("3d6634608b55541ddac251be41744121"));
            Texture2D testBeaconIcon = replacedetDatabase.LoadreplacedetAtPath<Texture2D>(replacedetDatabase.GUIDToreplacedetPath("d99be7b16603541eebc812d11bb2edf4"));

            foreach (var bc in beaconClreplacedes)
            {
                Debug.Log($"[Minefield] replacedigning a new script icon to {bc.name}");
                SetIconForObject.Invoke(null, new object[] { bc,
                    typeof(IHandlerBeacon).IsreplacedignableFrom(bc.GetClreplaced()) ?
                    navigationBeaconIcon : testBeaconIcon });
                CopyMonoScriptIconToImporters.Invoke(null, new object[] { bc });
            }

            //Disable the icon in gizmos annotation.
            Array annotations = (Array)GetAnnotations.Invoke(null, null);

            foreach (var bc in beaconClreplacedes)
            {
                foreach (var a in annotations)
                {
                    string scriptClreplaced = (string)AnnotationScriptClreplaced.GetValue(a);
                    if (scriptClreplaced == bc.name)
                    {
                        int clreplacedId = (int)AnnotationClreplacedId.GetValue(a);
                        SetIconEnabled.Invoke(null, new object[] { clreplacedId, scriptClreplaced, 0 });
                    }
                }
            }
        }

19 Source : AnyDictionary.cs
with MIT License
from 5minlab

internal bool TryGetValue<T>(string key, out T val, T defaultVal = default(T)) {
            if(dict == null) {
                val = defaultVal;
                return false;
            }

            object obj;
            if (dict.TryGetValue(key, out obj)) {
                if (typeof(T).IsreplacedignableFrom(obj.GetType())) {
                    val = (T)Convert.ChangeType(obj, typeof(T));
                    return (val != null);
                }
            }
            val = defaultVal;
            return false;
        }

19 Source : InvokeEditor.cs
with MIT License
from 71

private void VisitSymbol(ISymbol symbol)
        {
            // Only check methods
            if (!(symbol is IMethodSymbol method))
                return;

            // Find Invoke attribute
            var attr = method.GetAttributes().FirstOrDefault(x => x.AttributeClreplaced.Name == nameof(InvokeAttribute));

            if (attr == null)
                // No attribute found, return
                return;

            // We have the attribute, find its matching method
            var info = method.GetCorrespondingMethod() as MethodInfo;

            if (info == null)
            {
                ReportWarning("Cannot invoke given method", symbol.Locations[0]);
                return;
            }

            // Check method
            if (!method.IsStatic)
                throw new DiagnosticException("A compile-time function must be static.", symbol.Locations[0]);
            if (method.IsAbstract)
                throw new DiagnosticException("A compile-time function cannot be abstract.", symbol.Locations[0]);
            if (method.ReturnType.MetadataName != "Void")
                ReportWarning("A compile-time function should return void.", symbol.Locations[0]);

            // Populate args
            ParameterInfo[] parameters = info.GetParameters();
            object[] arguments = new object[parameters.Length];

            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterInfo parameter = parameters[i];
                TypeInfo parameterType = parameter.ParameterType.GetTypeInfo();

                if (parameterType.IsreplacedignableFrom(typeof(IMethodSymbol).GetTypeInfo()))
                    arguments[i] = method;
                else if (parameterType.IsreplacedignableFrom(typeof(MethodInfo).GetTypeInfo()))
                    arguments[i] = info;
                else if (parameter.ParameterType.IsreplacedignableFrom(typeof(ITypeSymbol)))
                    arguments[i] = symbol.ContainingType;
                else if (parameter.ParameterType == typeof(TypeInfo))
                    arguments[i] = info.DeclaringType.GetTypeInfo();
                else if (parameter.ParameterType == typeof(Type))
                    arguments[i] = info.DeclaringType;
            }

            // Invoke and return
            try
            {
                info.Invoke(null, arguments);
            }
            catch (Exception e)
            {
                ReportError(e.Message, symbol.Locations[0]);
            }
        }

19 Source : Redirection.Method.cs
with MIT License
from 71

private static MethodRedirection RedirectCore(MethodBase original, MethodBase replacement, bool skipChecks)
        {
            if (original == null)
                throw new ArgumentNullException(nameof(original));
            if (replacement == null)
                throw new ArgumentNullException(nameof(replacement));

            // Check if replacement is abstract
            // We allow original abstract methods, though
            if (replacement.IsAbstract)
                throw new ArgumentException(AbstractError, nameof(replacement));

            // Skip checks if needed
            if (skipChecks)
                goto End;

            // Get return type
            Type originalReturnType = (original as MethodInfo)?.ReturnType ?? (original as ConstructorInfo)?.DeclaringType;

            if (originalReturnType == null)
                throw new ArgumentException("Invalid method.", nameof(original));

            Type replacementReturnType = (replacement as MethodInfo)?.ReturnType ?? (replacement as ConstructorInfo)?.DeclaringType;

            if (replacementReturnType == null)
                throw new ArgumentException("Invalid method.", nameof(replacement));

            // Check return type
            if (!originalReturnType.IsreplacedignableFrom(replacementReturnType) &&
                !replacementReturnType.IsreplacedignableFrom(originalReturnType))
                throw new ArgumentException("Expected both methods to return compatible types.", nameof(replacement));

            // Check signature
            ParameterInfo[] originalParams = original.GetParameters();
            ParameterInfo[] replacementParams = replacement.GetParameters();

            int length = originalParams.Length;
            int diff = 0;

            if (!original.IsStatic)
            {
                if (replacement.IsStatic)
                {
                    // Should have:
                    // instance i.original(a, b) | static replacement(i, a, b)

                    if (replacementParams.Length == 0)
                        throw new ArgumentException($"Expected first parameter of type '{original.DeclaringType}'.", nameof(replacement));
                    if (replacementParams.Length != originalParams.Length + 1)
                        throw new ArgumentException(SignatureError, nameof(replacement));

                    Type replThisType = replacementParams[0].ParameterType;
                    Type origThisType = original.DeclaringType;

                    if (!replThisType.IsreplacedignableFrom(origThisType) &&
                        !origThisType.IsreplacedignableFrom(replThisType))
                        throw new ArgumentException($"Expected first parameter replacedignable to or from '{origThisType}'.", nameof(replacement));

                    diff = -1;
                    // No need to set length, it's already good
                }
                else
                {
                    // Should have:
                    // instance i.original(a, b) | instance i.replacement(a, b)

                    if (replacementParams.Length != originalParams.Length)
                        throw new ArgumentException(SignatureError, nameof(replacement));
                }
            }
            else if (!replacement.IsStatic)
            {
                // Should have:
                // static original(i, a, b) | instance i.replacement(a, b)

                if (originalParams.Length == 0)
                    throw new ArgumentException($"Expected first parameter of type '{replacement.DeclaringType}'.", nameof(original));
                if (replacementParams.Length != originalParams.Length - 1)
                    throw new ArgumentException(SignatureError, nameof(replacement));

                Type replThisType = replacement.DeclaringType;
                Type origThisType = originalParams[0].ParameterType;

                if (!replThisType.IsreplacedignableFrom(origThisType) &&
                    !origThisType.IsreplacedignableFrom(replThisType))
                    throw new ArgumentException($"Expected first parameter replacedignable to or from '{origThisType}'.", nameof(replacement));

                diff = 1;
                length--;
            }
            else
            {
                // Should have:
                // static original(a, b) | static replacement(a, b)

                if (originalParams.Length != replacementParams.Length)
                    throw new ArgumentException(SignatureError, nameof(replacement));
            }

            // At this point all parameters will have the same index with "+ diff",
            // and the parameters not checked in this loop have already been checked. We good.
            for (int i = diff == -1 ? 1 : 0; i < length; i++)
            {
                CheckParameters(originalParams[i + diff], replacementParams[i], nameof(replacement));
            }

            End:
            return new MethodRedirection(original, replacement, true);
        }

19 Source : MacroExpander.cs
with MIT License
from 71

public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
        {
            IOperation operation = semanticModel.GetOperation(node, cancellationToken);

            if (operation == null || !operation.IsInvalid)
                return base.VisitMemberAccessExpression(node);

            // Expression is invalid, might be a late-bound object
            IOperation expression = semanticModel.GetOperation(node.Expression, cancellationToken);

            if (expression.IsInvalid)
                return base.VisitMemberAccessExpression(node);

            // Find out if it is a late-bound object...
            INamedTypeSymbol type = expression.Type as INamedTypeSymbol;

            if (type == null)
                return base.VisitMemberAccessExpression(node);

            // ... by finding its Bind method
            object[] arguments = null;

            bool IsValidBindMethod(MethodInfo mi)
            {
                if (!mi.IsStatic || mi.IsAbstract || mi.Name != "Bind")
                    return false;

                if (!typeof(ExpressionSyntax).IsreplacedignableFrom(mi.ReturnType))
                    return false;

                ParameterInfo[] parameters = mi.GetParameters();
                object[] args = new object[parameters.Length];

                for (int i = 0; i < parameters.Length; i++)
                {
                    Type paramType = parameters[i].ParameterType;

                    if (paramType.IsreplacedignableFrom(typeof(MemberAccessExpressionSyntax)))
                        args[i] = node;
                    else if (paramType == typeof(IOperation))
                        args[i] = expression;
                    else
                        return false;
                }

                arguments = args;
                return true;
            }

            Type correspondingType = type.GetCorrespondingType();

            if (correspondingType == null)
                return base.VisitMemberAccessExpression(node);

            MethodInfo bindMethod = correspondingType
                .GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
                .FirstOrDefault(IsValidBindMethod);

            if (bindMethod == null)
                return base.VisitMemberAccessExpression(node);

            // We do have a binder!
            // Call the method
            try
            {
                ExpressionSyntax result = bindMethod.Invoke(null, arguments) as ExpressionSyntax;

                return result == null
                    ? SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)
                    : base.Visit(result);
            }
            catch (Exception e)
            {
                throw new DiagnosticException("Error thrown by binding method.", e, node.GetLocation());
            }
        }

19 Source : RecyclableEventArgs.cs
with MIT License
from 7Bytes-Studio

public static RecyclableEventArgs Spawn(Type implEventArgsType)
        {
            if (!typeof(RecyclableEventArgs).IsreplacedignableFrom(implEventArgsType))
                throw new Exception(string.Format("The {0} is not the implementation type for the RecyclableEventArgs.", implEventArgsType));

            RecyclableEventArgs instance = null;
            if (0<s_Pool.Count)
            {
                lock (s_Lock)
                {
                    var current = s_Pool.First;
                    while (null!=current)
                    {
                        if (current.Value.GetType() == implEventArgsType)
                        {
                            s_Pool.Remove(current.Value);
                            instance = current.Value;
                            break;
                        }
                        current = current.Next;
                    }
                }
                    
            }

            if (null == instance)
            {
                instance = Utility.Reflection.New(implEventArgsType) as RecyclableEventArgs;

            }

            instance.OnSpawn();
            return instance;
        }

19 Source : Utility.Reflection.cs
with MIT License
from 7Bytes-Studio

public static Type[] GetImplTypes(string replacedemblyName,Type typeBase)
            {
                replacedembly replacedembly = replacedembly.Load(replacedemblyName);
                if (null != replacedembly)
                {
                    List<Type> list = new List<Type>();
                    var types = replacedembly.GetTypes();
                    if (null != types)
                        for (int i = 0; i < types.Length; i++)
                        {
                            if (types[i].IsClreplaced && !types[i].IsAbstract && typeBase.IsreplacedignableFrom(types[i]))
                            {
                                list.Add(types[i]);
                            }
                        }
                    return list.ToArray();
                }
                return null;
            }

19 Source : Utility.Reflection.cs
with MIT License
from 7Bytes-Studio

public static bool IsImplType(Type baseType,Type implType)
            {
                return baseType.IsreplacedignableFrom(implType);
            }

19 Source : EntityTree.FrameworkSingleInstance.partial.cs
with MIT License
from 7Bytes-Studio

public static object GetEnreplacedyInChildren(Type targetType)
        {
            Type enreplacedyType = null;
            foreach (var enreplacedy in FrameworkSingleInstance)
            {
                //Log.Debug(string.Format("{0}  {1}", enreplacedy.GetType(), targetType));
                enreplacedyType = enreplacedy.GetType();
                if (enreplacedyType == targetType || targetType.IsreplacedignableFrom(enreplacedyType))
                {
                    return enreplacedy;
                }
            }
            return null;
        }

19 Source : ModuleManager.cs
with MIT License
from 7Bytes-Studio

public IModule GetModule(Type moduleOrModuleInterfaceType)
        {
            CheckModuleImplOrThrow(moduleOrModuleInterfaceType);

            foreach (var child in this)
            {
                if (child.GetType()==moduleOrModuleInterfaceType || moduleOrModuleInterfaceType.IsreplacedignableFrom(child.GetType()))
                {
                   return child as IModule;
                }
            }
            return null;
        }

19 Source : ModuleManager.cs
with MIT License
from 7Bytes-Studio

public bool HasModule(Type moduleOrModuleInterfaceType)
        {
            CheckModuleImplOrThrow(moduleOrModuleInterfaceType);
            foreach (var child in this)
            {
                if (child.GetType() == moduleOrModuleInterfaceType || moduleOrModuleInterfaceType.IsreplacedignableFrom(child.GetType()))
                {
                    return true;
                }
            }
            return false;
        }

19 Source : ModuleManager.cs
with MIT License
from 7Bytes-Studio

public void UnRegister(Type moduleOrModuleInterfaceType)
        {
            if (null == moduleOrModuleInterfaceType)
            {
                Log.Fatal("注销的模块接口类型引用不能为空。");
            }
            ModuleBase target = null;
            foreach (var child in this)
            {
                if ( child.GetType() == moduleOrModuleInterfaceType || moduleOrModuleInterfaceType.IsreplacedignableFrom(child.GetType()) )
                {
                    target = child as ModuleBase;
                    break;
                }
            }

            if (null!= target)
            {
                RemoveChildNode(target);
            }
           
        }

19 Source : ModuleManager.cs
with MIT License
from 7Bytes-Studio

private void CheckModuleImplOrThrow(Type moduleType)
        {
            if (!typeof(IModule).IsreplacedignableFrom(moduleType))
                throw new Exception(string.Format("The {0} is not the implementation type for the module.", moduleType));
        }

19 Source : ObjectPool.cs
with MIT License
from 7Bytes-Studio

private static void CheckPoolImplOrThrow(Type poolType)
        {
            if (!typeof(PoolBase).IsreplacedignableFrom(poolType))
                throw new Exception(string.Format("The {0} is not the implementation type for the PoolBase.", poolType));
        }

19 Source : ObjectPool.Pool.partial.cs
with MIT License
from 7Bytes-Studio

private void CheckObjectTypeOrThrow(Type objectType)
            {
                if (!typeof(ObjectBase).IsreplacedignableFrom(objectType))
                    throw new Exception(string.Format("The {0} is not the implementation type for the ObjectBase.", objectType));
            }

19 Source : ServiceCollectionExtension.cs
with GNU Lesser General Public License v3.0
from 8720826

public static void AutoRegister(this IServiceCollection services)
        {
            #region 自动注入

            var allreplacedemblies = replacedembly.GetEntryreplacedembly().GetReferencedreplacedemblies().Select(replacedembly.Load);
            foreach (var serviceAsm in allreplacedemblies)
            {
                var serviceList = serviceAsm.GetTypes().Where(t => t.IsClreplaced && !t.IsAbstract && !t.IsInterface);

                foreach (Type serviceType in serviceList.Where(t => typeof(IScoped).IsreplacedignableFrom(t)))
                {
                    var interfaceTypes = serviceType.GetInterfaces();

                    foreach (var interfaceType in interfaceTypes)
                    {
                        services.AddScoped(interfaceType, serviceType);
                    }
                }

                foreach (Type serviceType in serviceList.Where(t => typeof(ISingleton).IsreplacedignableFrom(t)))
                {
                    var interfaceTypes = serviceType.GetInterfaces();

                    foreach (var interfaceType in interfaceTypes)
                    {
                        services.AddSingleton(interfaceType, serviceType);
                    }
                }

                foreach (Type serviceType in serviceList.Where(t => typeof(ITransient).IsreplacedignableFrom(t)))
                {
                    var interfaceTypes = serviceType.GetInterfaces();

                    foreach (var interfaceType in interfaceTypes)
                    {
                        services.AddTransient(interfaceType, serviceType);
                    }
                }

                foreach (Type serviceType in serviceList.Where(t => t.IsSubclreplacedOf(typeof(BackgroundService))))
                {
                    services.AddTransient(typeof(IHostedService), serviceType);
                }
            }
            #endregion

        }

19 Source : GH_Cloud.cs
with GNU Lesser General Public License v3.0
from 9and3

public override bool CastTo<Q>(ref Q target) {
            bool flag;
            if (!typeof(Q).IsreplacedignableFrom(typeof(PointCloud))) {
                flag = false;
            } else if (this.m_value != null) {
                Rhino.RhinoApp.WriteLine("Hi");
                /////////////////? Dim obj2 As Object = Me.m_value.DuplicateShallow   target = DirectCast(obj2, Q)
                Object o = this.m_value;//.DuplicateShallow();
                target = (Q)o;
                flag = true;
            } else {
                flag = false;
            }
            return flag;
        }

19 Source : RtmpServerBuilder.cs
with MIT License
from a1q123456

public RtmpServer Build()
        {
            _options = _options ?? new RtmpServerOptions();
            _options.Startup = _startup;
            var types = replacedembly.GetCallingreplacedembly().GetTypes();

            var registerInternalControllers = true;
            _websocketOptions._serverOptions = _options;
            foreach (var type in types)
            {
                var neverRegister = type.GetCustomAttribute<NeverRegisterAttribute>();
                if (neverRegister != null)
                {
                    continue;
                }

                if (typeof(NetStream).IsreplacedignableFrom(type) && !type.IsAbstract)
                {
                    _options.RegisterStream(type);
                }
                else if (typeof(RtmpController).IsreplacedignableFrom(type) && !type.IsAbstract)
                {
                    _options.RegisterController(type);
                }

                if (typeof(LivingController).IsreplacedignableFrom(type))
                {
                    registerInternalControllers = false;
                }
                if (_useWebSocket)
                {
                    if (typeof(WebSocketController).IsreplacedignableFrom(type) && !type.IsAbstract)
                    {
                        _websocketOptions.RegisterController(type);
                    }
                    if (typeof(WebSocketPlayController).IsreplacedignableFrom(type))
                    {
                        registerInternalControllers = false;
                    }
                }
            }

            if (registerInternalControllers)
            {
                _options.RegisterController<LivingController>();
                _options.RegisterStream<LivingStream>();
                _options.RegisterStream<RecordStream>();
                _options.RegisterController<RecordController>();
                if (_useWebSocket)
                {
                    _websocketOptions.RegisterController<WebSocketPlayController>();
                }
            }
           
            if (_useSsl)
            {
                _options.Cert = _cert;
            }
            _options.CleanupRpcRegistration();
            _options.BuildContainer();
            var ret = new RtmpServer(_options, _websocketOptions);
            return ret;
        }

19 Source : RtmpServerOptions.cs
with MIT License
from a1q123456

internal void RegisterController(Type controllerType, string appName = null)
        {
            if (!typeof(RtmpController).IsreplacedignableFrom(controllerType))
            {
                throw new InvalidOperationException("controllerType must inherit from AbstractController");
            }
            var name = appName ?? controllerType.Name.Replace("Controller", "");
            _registeredControllers.Add(name.ToLower(), controllerType);
            _rpcService.RegeisterController(controllerType);
            _builder.RegisterType(controllerType).replacedelf();
        }

19 Source : RpcService.cs
with MIT License
from a1q123456

public void PrepareMethod<T>(T instance, CommandMessage command, out MethodInfo methodInfo, out object[] callArguments) where T: RtmpController
        {
            if (!Controllers.TryGetValue(instance.GetType(), out var methods))
            {
                throw new EntryPointNotFoundException();
            }
            
            foreach (var method in methods)
            {
                if (method.MethodName != command.ProcedureName)
                {
                    continue;
                }
                var arguments = new object[method.Parameters.Count];
                var i = 0;
                foreach (var para in method.Parameters)
                {
                    if (para.IsCommandObject)
                    {
                        arguments[i] = command.CommandObject;
                        i++;
                    }
                    else if (para.IsFromCommandObject)
                    {
                        var commandObj = command.CommandObject;
                        object val = null;
                        if (!commandObj.Fields.TryGetValue(para.CommandObjectKey, out val) && !commandObj.DynamicFields.TryGetValue(para.CommandObjectKey, out val))
                        {
                            if (para.IsOptional)
                            {
                                arguments[i] = Type.Missing;
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (para.ParameterType.IsreplacedignableFrom(val.GetType()))
                        {
                            arguments[i] = val;
                            i++;
                        }
                        else
                        {
                            if (para.IsOptional)
                            {
                                arguments[i] = Type.Missing;
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else if (para.IsFromOptionalArgument)
                    {
                        var optionArguments = command.GetType().GetProperties().Where(p => p.GetCustomAttribute<OptionalArgumentAttribute>() != null).ToList();
                        if (para.OptionalArgumentIndex >= optionArguments.Count)
                        {
                            if (para.IsOptional)
                            {
                                arguments[i] = Type.Missing;
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            arguments[i] = optionArguments[i].GetValue(command);
                            i++;
                        }
                    }
                }

                if (i == arguments.Length)
                {
                    methodInfo = method.Method;
                    callArguments = arguments;
                    return;
                }
            }

            throw new EntryPointNotFoundException();
        }

19 Source : BaseDbContext.cs
with MIT License
from a34546

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            var replacedemblies = AppDomain.CurrentDomain.GetCurrentPathreplacedembly().Where(x => !(x.GetName().Name.Equals("Wei.Repository")));
            foreach (var replacedembly in replacedemblies)
            {
                var enreplacedyTypes = replacedembly.GetTypes()
                    .Where(type => !string.IsNullOrWhiteSpace(type.Namespace))
                    .Where(type => type.IsClreplaced)
                    .Where(type => type.Name != nameof(Enreplacedy))
                    .Where(type => type.BaseType != null)
                    .Where(type => typeof(ITrack).IsreplacedignableFrom(type));

                foreach (var enreplacedyType in enreplacedyTypes)
                {
                    if (modelBuilder.Model.FindEnreplacedyType(enreplacedyType) != null) continue;
                    modelBuilder.Model.AddEnreplacedyType(enreplacedyType);
                }
            }
            base.OnModelCreating(modelBuilder);
        }

19 Source : RtmpServerOptions.cs
with MIT License
from a1q123456

internal void RegisterStream(Type streamType)
        {
            if (!typeof(NetStream).IsreplacedignableFrom(streamType))
            {
                throw new InvalidOperationException("streamType must inherit from NetStream");
            }
            _rpcService.RegeisterController(streamType);
            _builder.RegisterType(streamType).replacedelf();
        }

19 Source : WebSocketOptions.cs
with MIT License
from a1q123456

internal void RegisterController(Type controllerType)
        {
            if (!typeof(WebSocketController).IsreplacedignableFrom(controllerType))
            {
                throw new ArgumentException("controller not inherit from WebSocketController");
            }
            _controllers.Add(controllerType.Name.Replace("Controller", "").ToLower(), controllerType);
            _serverOptions._builder.RegisterType(controllerType).replacedelf();
        }

19 Source : RpcService.cs
with MIT License
from a1q123456

internal void RegeisterController(Type controllerType)
        {
            var methods = controllerType.GetMethods();
            foreach (var method in methods)
            {
                var attr = method.GetCustomAttribute<RpcMethodAttribute>();
                if (attr != null)
                {
                    var rpcMethod = new RpcMethod();
                    var methodName = attr.Name ?? method.Name;
                    var parameters = method.GetParameters();
                    bool canInvoke = false;
                    var optArgIndex = 0;
                    foreach (var para in parameters)
                    {
                        var fromCommandObject = para.GetCustomAttribute<FromCommandObjectAttribute>();
                        var fromOptionalArg = para.GetCustomAttribute<FromOptionalArgumentAttribute>();
                        var commandObject = para.GetCustomAttribute<CommandObjectAttribute>();
                        if (fromCommandObject == null && fromOptionalArg == null && commandObject == null)
                        {
                            break;
                        }
                        canInvoke = true;
                        if (fromCommandObject != null)
                        {
                            var name = fromCommandObject.Key ?? para.Name;
                            rpcMethod.Parameters.Add(new RpcParameter()
                            {
                                CommandObjectKey = name,
                                IsFromCommandObject = true,
                                ParameterType = para.ParameterType,
                                IsOptional = para.IsOptional
                            });
                        }
                        else if (fromOptionalArg != null)
                        {
                            rpcMethod.Parameters.Add(new RpcParameter()
                            {
                                OptionalArgumentIndex = optArgIndex,
                                IsFromOptionalArgument = true,
                                ParameterType = para.ParameterType,
                                IsOptional = para.IsOptional
                            });
                            optArgIndex++;
                        }
                        else if (commandObject != null && para.ParameterType.IsreplacedignableFrom(typeof(AmfObject)))
                        {
                            rpcMethod.Parameters.Add(new RpcParameter()
                            {
                                IsCommandObject = true,
                                IsOptional = para.IsOptional
                            });
                        }
                    }
                    if (canInvoke || !parameters.Any())
                    {
                        rpcMethod.Method = method;
                        rpcMethod.MethodName = methodName;
                        if (!Controllers.TryGetValue(controllerType, out var mapping))
                        {
                            Controllers.Add(controllerType, new List<RpcMethod>());
                        }
                        Controllers[controllerType].Add(rpcMethod);
                    }
                }
            }
        }

See More Examples