System.Collections.Generic.List.Add(System.Type)

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

1075 Examples 7

19 View Source File : ServiceProviderHelper.cs
License : Apache License 2.0
Project Creator : AmpScm

public static IDisposable AddService(Type t, object instance)
        {
            _types.Add(t);
            return new ServiceProviderHelper(t, instance);
        }

19 View Source File : MessageHandlingService.cs
License : MIT License
Project Creator : AntonyVorontsov

private async Task ProcessMessageEvent(MessageHandlingContext context, IEnumerable<string> matchingRoutes)
        {
            var container = _messageHandlerContainers.FirstOrDefault(x => x.Exchange == context.Message.Exchange) ??
                _messageHandlerContainers.FirstOrDefault(x => x.IsGeneral);
            if (container is null)
            {
                return;
            }

            var messageHandlerOrderingContainers = new List<MessageHandlerOrderingContainer>();
            foreach (var matchingRoute in matchingRoutes)
            {
                if (!container.MessageHandlers.ContainsKey(matchingRoute))
                {
                    continue;
                }

                var orderingContainers = container.MessageHandlers[matchingRoute]
                    .Select(handler => new MessageHandlerOrderingContainer(handler, matchingRoute, container.GetOrderForHandler(handler)));
                messageHandlerOrderingContainers.AddRange(orderingContainers);
            }

            var executedHandlers = new List<Type>();
            var orderedContainers = messageHandlerOrderingContainers.OrderByDescending(x => x.Order)
                .ThenByDescending(x => x.MessageHandler.GetHashCode())
                .ToList();
            foreach (var orderedContainer in orderedContainers)
            {
                var handlerType = orderedContainer.MessageHandler.GetType();
                if (executedHandlers.Contains(handlerType))
                {
                    continue;
                }

                switch (orderedContainer.MessageHandler)
                {
                    case IMessageHandler messageHandler:
                        RunMessageHandler(messageHandler, context, orderedContainer.MatchingRoute);
                        break;
                    case IAsyncMessageHandler asyncMessageHandler:
                        await RunAsyncMessageHandler(asyncMessageHandler, context, orderedContainer.MatchingRoute).ConfigureAwait(false);
                        break;
                    default:
                        throw new NotSupportedException($"The type {orderedContainer.MessageHandler.GetType()} of message handler is not supported.");
                }

                executedHandlers.Add(handlerType);
            }
        }

19 View Source File : DefaultContractResolver.cs
License : MIT License
Project Creator : akaskela

private List<Type> GetClreplacedHierarchyForType(Type type)
        {
            List<Type> ret = new List<Type>();

            Type current = type;
            while (current != null && current != typeof(object))
            {
                ret.Add(current);
                current = current.BaseType();
            }

            // Return the clreplaced list in order of simple => complex
            ret.Reverse();
            return ret;
        }

19 View Source File : Hooks.cs
License : MIT License
Project Creator : alfa-laboratory

[BeforeTestRun]
        public static void Initialize()
        {
            var obj = ReplaceMethods.Get() as List<Type>;
            if (!obj.Contains(typeof(GenerationFunctions)))
            {
                (ReplaceMethods.Get() as List<Type>).Add(typeof(GenerationFunctions));
            }
        }

19 View Source File : NodeProvider.cs
License : MIT License
Project Creator : alelievr

static bool IsNodeSpecificToGraph(Type nodeType)
		{
			var isCompatibleWithGraphMethods = nodeType.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).Where(m => m.GetCustomAttribute<IsCompatibleWithGraph>() != null);
			var nodeMenuAttributes = nodeType.GetCustomAttributes<NodeMenuItemAttribute>();

			List<Type> compatibleGraphTypes = nodeMenuAttributes.Where(n => n.onlyCompatibleWithGraph != null).Select(a => a.onlyCompatibleWithGraph).ToList();

			List<MethodInfo> compatibleMethods = new List<MethodInfo>();
			foreach (var method in isCompatibleWithGraphMethods)
			{
				// Check if the method is static and have the correct prototype
				var p = method.GetParameters();
				if (method.ReturnType != typeof(bool) || p.Count() != 1 || p[0].ParameterType != typeof(BaseGraph))
					Debug.LogError($"The function '{method.Name}' marked with the IsCompatibleWithGraph attribute either doesn't return a boolean or doesn't take one parameter of BaseGraph type.");
				else
					compatibleMethods.Add(method);
			}

			if (compatibleMethods.Count > 0 || compatibleGraphTypes.Count > 0)
			{
				// We still need to add the element in specificNode even without specific graph
				if (compatibleGraphTypes.Count == 0)
					compatibleGraphTypes.Add(null);

				foreach (var graphType in compatibleGraphTypes)
				{
					specificNodes.Add(new NodeSpecificToGraph{
						nodeType = nodeType,
						isCompatibleWithGraph = compatibleMethods,
						compatibleWithGraphType = graphType
					});
				}
				return true;
			}
			return false;
		}

19 View Source File : Ldftn.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a

public void Load(DarksVMContext ctx, out ExecutionState state)
        {
            var sp = ctx.Registers[DarksVMConstants.REG_SP].U4;
            var methodSlot = ctx.Stack[sp--];
            var objectSlot = ctx.Stack[sp];

            if(objectSlot.O != null)
            {
                var method = (MethodInfo) ctx.Instance.Data.LookupReference(methodSlot.U4);
                var type = objectSlot.O.GetType();

                var baseTypes = new List<Type>();
                do
                {
                    baseTypes.Add(type);
                    type = type.BaseType;
                } while(type != null && type != method.DeclaringType);
                baseTypes.Reverse();

                var found = method;
                const BindingFlags fl = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
                foreach(var baseType in baseTypes)
                foreach(var m in baseType.GetMethods(fl))
                    if(m.GetBaseDefinition() == found)
                    {
                        found = m;
                        break;
                    }

                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) found.MethodHandle.GetFunctionPointer()};
            }
            if(objectSlot.U8 != 0)
            {
                // intra linking
                var entryKey = ctx.Stack[--sp].U4;
                var codeAdr = methodSlot.U8;
                var sig = ctx.Instance.Data.LookupExport(objectSlot.U4).Signature;
                var ptr = DarksVMTrampoline.CreateTrampoline(ctx.Instance.Data.Module, codeAdr, entryKey, sig, objectSlot.U4);
                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) ptr};
            }
            else
            {
                var method = (MethodBase) ctx.Instance.Data.LookupReference(methodSlot.U4);
                ctx.Stack[sp] = new DarksVMSlot {U8 = (ulong) method.MethodHandle.GetFunctionPointer()};
            }

            ctx.Stack.SetTopPosition(sp);
            ctx.Registers[DarksVMConstants.REG_SP].U4 = sp;
            state = ExecutionState.Next;
        }

19 View Source File : InMemoryEventBusSubscriptionsManager.cs
License : Apache License 2.0
Project Creator : anjoy8

public void AddSubscription<T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler<T>
        {
            var eventName = GetEventKey<T>();

            DoAddSubscription(typeof(TH), eventName, isDynamic: false);

            if (!_eventTypes.Contains(typeof(T)))
            {
                _eventTypes.Add(typeof(T));
            }
        }

19 View Source File : UMARecipeBase.cs
License : Apache License 2.0
Project Creator : A7ocin

public static Type[] GetRecipeFormats()
		{
			if (recipeFormats == null)
			{
				var formats = new List<Type>(20);
				var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
				foreach (var replacedembly in replacedemblies)
				{
					var types = replacedembly.GetTypes();
					for (int i = 0; i < types.Length; i++)
					{
						var type = types[i];
						if (type.IsSubclreplacedOf(typeof(UMARecipeBase)) && !type.IsAbstract)
						{
							formats.Add(type);
						}
					}
				}
				recipeFormats = formats.ToArray();
			}
			return recipeFormats;
		}

19 View Source File : ReflectionHelper.cs
License : GNU General Public License v3.0
Project Creator : arduosoft

public List<Type> GetAnnotatedBy<T>() where T : Attribute
        {
            _logger.LogDebug("Get all entries annotated by {0}", typeof(T).FullName);
            List<Type> result = new List<Type>();
            List<replacedembly> bundledreplacedemblies = replacedemblyScope;

            foreach (replacedembly replacedembly in bundledreplacedemblies)
            {
                _logger.LogDebug("loading from" + replacedembly.FullName);

                Type[] types = replacedembly.GetTypes();

                foreach (Type type in types)
                {
                    if (type.GetCustomAttributes(typeof(T), true).Length > 0)
                    {
                        result.Add(type);
                    }
                }
            }
            return result;
        }

19 View Source File : TypeExtensions.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public static List<Type> GetAllSubClreplacedesOf(this Type rootType, replacedembly[] searchreplacedemblies = null)
        {
            if (!rootType.IsClreplaced) return null;

            if (searchreplacedemblies == null) { searchreplacedemblies = AppDomain.CurrentDomain.Getreplacedemblies(); }

            var results = new List<Type>();

            Parallel.ForEach(searchreplacedemblies, (replacedembly) =>
            {
                Parallel.ForEach(replacedembly.GetTypes(), (type) =>
                {
                    if (type != null && type.IsClreplaced && !type.IsAbstract && type.IsSubclreplacedOf(rootType))
                    {
                        results.Add(type);
                    }
                });
            });

            return results;
        }

19 View Source File : QueueableService.cs
License : MIT License
Project Creator : alexandrebeato

public void AdicionarComando(Type comando)
        {
            if (Comandos == null)
                Comandos = new List<Type>();

            if (Comandos.Contains(comando))
                return;

            Comandos.Add(comando);
        }

19 View Source File : PopupSelectionMenu.cs
License : MIT License
Project Creator : alen-smajic

public override void OnGUI(Rect rect)
		{
			if (_modTypes == null || _modTypes.Count == 0)
			{
				_modTypes = new List<Type>();

				AppDomain currentDomain = AppDomain.CurrentDomain;
				replacedembly[] replacedemblies = currentDomain.Getreplacedemblies();
				for (int i = 0; i < replacedemblies.Length; i++)
				{
					Type[] types = replacedemblies[i].GetTypes();
					for (int j = 0; j < types.Length; j++)
					{
						if (types[j].IsSubclreplacedOf(_type))
						{
							_modTypes.Add(types[j]);
						}
					}
				}
			}

			GUILayout.Label(String.Format("{0}s", _type.Name), EditorStyles.boldLabel);
			var st = new GUIStyle();
			st.padding = new RectOffset(0, 0, 15, 15);
			_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, st);

			for (int i = 0; i < _modTypes.Count; i++)
			{
				Type replacedet = _modTypes[i];
				if (replacedet == null) //yea turns out this can happen
					continue;
				var style = GUI.skin.button;
				style.alignment = TextAnchor.MiddleLeft;
				string shortTypeName = GetShortTypeName(replacedet.ToString());
				if (GUILayout.Button(shortTypeName, style))
				{
					CreateNewModiferInstance(replacedet, shortTypeName);
					editorWindow.Close();
				}
			}
			EditorGUILayout.EndScrollView();
		}

19 View Source File : AbpElsaModule.cs
License : Apache License 2.0
Project Creator : AbpApp

private static void AutoAddWorkFlowDefinitions(IServiceCollection services)
        {
            var activityDefinitionList= new ActivityDefinitionList();
            var definitionProviders = new List<Type>();
            services.OnRegistred(context =>
            {
                if (typeof(IActivity).IsreplacedignableFrom(context.ImplementationType))
                {
                    activityDefinitionList.Add(ActivityDescriber.Describe(context.ImplementationType));
                }

                if (typeof(IWorkflowProvider).IsreplacedignableFrom(context.ImplementationType)) {
                    definitionProviders.Add(context.ImplementationType);
                }
            });
            services.Configure<AbpElsaOptions>(options =>
            {
                options.ActivityDefinitions = activityDefinitionList;
                options.DefinitionProviders.AddIfNotContains(definitionProviders);
            });
        }

19 View Source File : ClingyEditorUtils.cs
License : MIT License
Project Creator : all-iver

public static System.Type[] GetAllDerivedTypes(this System.AppDomain aAppDomain, System.Type aType) {
            var result = new List<System.Type>();
            var replacedemblies = aAppDomain.Getreplacedemblies();
            foreach (var replacedembly in replacedemblies) {
                var types = replacedembly.GetTypes();
                foreach (var type in types) {
                    if (type.IsSubclreplacedOf(aType))
                        result.Add(type);
                }
            }
            return result.ToArray();
        }

19 View Source File : Amf0Reader.cs
License : MIT License
Project Creator : a1q123456

public void RegisterType<T>() where T : new()
        {
            var type = typeof(T);
            var props = type.GetProperties();
            var fields = props.Where(p => p.CanWrite && Attribute.GetCustomAttribute(p, typeof(ClreplacedFieldAttribute)) != null).ToList();
            var members = fields.ToDictionary(p => ((ClreplacedFieldAttribute)Attribute.GetCustomAttribute(p, typeof(ClreplacedFieldAttribute))).Name ?? p.Name, p => new Action<object, object>(p.SetValue));
            if (members.Keys.Where(s => string.IsNullOrEmpty(s)).Any())
            {
                throw new InvalidOperationException("Field name cannot be empty or null");
            }
            string mapedName = null;
            var attr = type.GetCustomAttribute<TypedObjectAttribute>();
            if (attr != null)
            {
                mapedName = attr.Name;
            }
            var typeName = mapedName == null ? type.Name : mapedName;
            var state = new TypeRegisterState()
            {
                Members = members,
                Type = type
            };
            _registeredTypes.Add(type);
            _registeredTypeStates.Add(typeName, state);
            _amf3Reader.RegisterTypedObject(typeName, state);
        }

19 View Source File : InspectorScript.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm

private List<Type> FindAllDerivedTypes(Type baseType)
        {
            List<Type> resultTypes = new List<Type>();
            foreach (var replacedembly in AppDomain.CurrentDomain.Getreplacedemblies())
            {
                var replacedemblyTypes = replacedembly.GetTypes();
                // Debug.Log(replacedembly.GetName() + ":");
                foreach (var type in replacedemblyTypes)
                {
                    //Debug.Log("   " + type.ToString());
                    if (type != baseType && baseType.IsreplacedignableFrom(type))
                    {
                        // Debug.Log("   " + type.ToString());
                        resultTypes.Add(baseType);
                    }
                }
            }

            return resultTypes;
        }

19 View Source File : DynamicAuthenticationBuilder.cs
License : MIT License
Project Creator : Aguafrommars

public override AuthenticationBuilder AddScheme<TOptions, THandler>(string authenticationScheme, string displayName, Action<TOptions> configureOptions)
        {
            _handlerTypes.Add(typeof(THandler));
            Services.AddSingleton(provider => 
                new OptionsMonitorCacheWrapper<TOptions>
                (
                    provider.GetRequiredService<IOptionsMonitorCache<TOptions>>(),
                    provider.GetRequiredService<IEnumerable<IPostConfigureOptions<TOptions>>>(),
                    (name, configure) =>
                    {
                        configureOptions?.Invoke(configure);
                    }
                )
            );
            return this;
        }

19 View Source File : Plugin.cs
License : GNU General Public License v3.0
Project Creator : anotak

public Type[] FindClreplacedes(Type t)
		{
			List<Type> found = new List<Type>();
			Type[] types;
			
			// Get all exported types
			types = asm.GetExportedTypes();
			foreach(Type it in types)
			{
				// Compare types
				if(t.IsreplacedignableFrom(it)) found.Add(it);
			}

			// Return list
			return found.ToArray();
		}

19 View Source File : Amf3Reader.cs
License : MIT License
Project Creator : a1q123456

public void RegisterTypedObject<T>() where T: new()
        {
            var type = typeof(T);
            var props = type.GetProperties();
            var fields = props.Where(p => p.CanWrite && Attribute.GetCustomAttribute(p, typeof(ClreplacedFieldAttribute)) != null).ToList();
            var members = fields.ToDictionary(p => ((ClreplacedFieldAttribute)Attribute.GetCustomAttribute(p, typeof(ClreplacedFieldAttribute))).Name ?? p.Name, p => new Action<object, object>(p.SetValue));
            if (members.Keys.Where(s => string.IsNullOrEmpty(s)).Any())
            {
                throw new InvalidOperationException("Field name cannot be empty or null");
            }
            string mapedName = null;
            var attr = type.GetCustomAttribute<TypedObjectAttribute>();
            if (attr != null)
            {
                mapedName = attr.Name;
            }

            var typeName = mapedName == null ? type.Name : mapedName;
            var state = new TypeRegisterState()
            {
                Members = members,
                Type = type
            };
            _registeredTypes.Add(type);
            _registeredTypedObejectStates.Add(typeName, state);
        }

19 View Source File : PhotonEditor.cs
License : MIT License
Project Creator : ArcturusZhang

public static System.Type[] GetAllSubTypesInScripts(System.Type aBaseClreplaced)
        {
            var result = new System.Collections.Generic.List<System.Type>();
            System.Reflection.replacedembly[] AS = System.AppDomain.CurrentDomain.Getreplacedemblies();
            foreach (var A in AS)
            {
                // this skips all but the Unity-scripted replacedemblies for RPC-list creation. You could remove this to search all replacedemblies in project
                if (!A.FullName.StartsWith("replacedembly-"))
                {
                    // Debug.Log("Skipping replacedembly: " + A);
                    continue;
                }

                //Debug.Log("replacedembly: " + A.FullName);
                System.Type[] types = A.GetTypes();
                foreach (var T in types)
                {
                    if (T.IsSubclreplacedOf(aBaseClreplaced))
                    {
                        result.Add(T);
                    }
                }
            }
            return result.ToArray();
        }

19 View Source File : ArchetypePool.cs
License : MIT License
Project Creator : Alan-FGR

public void PrintDebugData(Type[] typeMap)
    {
        List<Type> archetypeTypes = new List<Type>();

        for (int i = 0; i < componentBuffers_.Count; i++)
        {
            var type = typeMap[componentBuffers_.KeysPtr[i].FirstPosition];
            archetypeTypes.Add(type);
        }

        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine($"  {GetType()}<{string.Join(", ", archetypeTypes)}>({Count}), {archetypeFlags_}");
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine($"   ind2uid={string.Join(", ", indicesToUIDs_)}");

        for (int i = 0; i < componentBuffers_.Count; i++)
        {
            var type = typeMap[componentBuffers_.KeysPtr[i].FirstPosition];
            componentBuffers_.Values[i].PrintDebugData(Count, type);
        };
    }

19 View Source File : NodeProvider.cs
License : MIT License
Project Creator : alelievr

static void BuildCacheForNode(Type nodeType, NodeDescriptions targetDescription, BaseGraph graph = null)
		{
			var attrs = nodeType.GetCustomAttributes(typeof(NodeMenuItemAttribute), false) as NodeMenuItemAttribute[];

			if (attrs != null && attrs.Length > 0)
			{
				foreach (var attr in attrs)
					targetDescription.nodePerMenureplacedle[attr.menureplacedle] = nodeType;
			}

			foreach (var field in nodeType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
			{
				if (field.GetCustomAttribute<HideInInspector>() == null && field.GetCustomAttributes().Any(c => c is InputAttribute || c is OutputAttribute))
					targetDescription.slotTypes.Add(field.FieldType);
			}

			ProvideNodePortCreationDescription(nodeType, targetDescription, graph);
		}

19 View Source File : UMAAssetIndexerEditor.cs
License : Apache License 2.0
Project Creator : A7ocin

public void ShowTypes()
		{
			GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
			GUILayout.Space(10);
			bShowTypes = EditorGUILayout.Foldout(bShowTypes, "Additional Indexed Types");
			GUILayout.EndHorizontal();

			if (bShowTypes)
			{
				GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.875f, 1f));

				// Draw and handle the Drag/Drop
				GUILayout.Space(20);
				Rect dropTypeArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
				GUI.Box(dropTypeArea, "Drag a single type here to start indexing that type.");
				GUILayout.Space(20);
				DropAreaType(dropTypeArea);
				foreach (string s in UAI.IndexedTypeNames)
				{
					System.Type CurrentType = System.Type.GetType(s);
					GUILayout.BeginHorizontal(EditorStyles.textField);
					GUILayout.Label(CurrentType.ToString(), GUILayout.MinWidth(240));
					if (GUILayout.Button("-", GUILayout.Width(20.0f)))
					{
						RemovedTypes.Add(CurrentType);
					}
					GUILayout.EndHorizontal();
				}
				GUIHelper.EndVerticalPadded(10);
			}
		}

19 View Source File : CustomPortIO.cs
License : MIT License
Project Creator : alelievr

static void AddreplacedignableTypes(Type fromType, Type toType)
		{
			if (!replacedignableTypes.ContainsKey(fromType))
				replacedignableTypes[fromType] = new List< Type >();

			replacedignableTypes[fromType].Add(toType);
		}

19 View Source File : TypeReferencePropertyDrawer.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private static void FilterTypes(replacedembly replacedembly, SystemTypeAttribute filter, ICollection<Type> excludedTypes, List<Type> output)
        {
            foreach (var type in replacedembly.GetLoadableTypes())
            {
                bool isValid = type.IsValueType && !type.IsEnum || type.IsClreplaced;
                if (!type.IsVisible || !isValid)
                {
                    continue;
                }

                if (filter != null && !filter.IsConstraintSatisfied(type))
                {
                    continue;
                }

                if (excludedTypes != null && excludedTypes.Contains(type))
                {
                    continue;
                }

                output.Add(type);
            }
        }

19 View Source File : Instruction.cs
License : MIT License
Project Creator : alexanderkyte

public override void Emit (IEnumerator<WebreplacedemblyInstruction> cursor, ILGenerator ilgen, WebreplacedemblyCodeParser top_level)
		{
			String method;
			switch (Opcode) {
				case 0x28:
					method = "Load32Bitreplacedigned32";
					break;
				case 0x29:
					method = "Load64Bitreplacedigned64";
					break;
				case 0x2a:
					method = "LoadSingle";
					break;
				case 0x2b:
					method = "LoadDouble";
					break;
				case 0x2c:
					method = "LoadSigned8Bitreplacedigned32";
					break;
				case 0x2d:
					method = "LoadUnsigned8Bitreplacedigned32";
					break;
				case 0x2e:
					method = "LoadSigned16Bitreplacedigned32";
					break;
				case 0x2f:
					method = "LoadUnsigned16Bitreplacedigned32";
					break;
				case 0x30:
					method = "LoadSigned8Bitreplacedigned64";
					break;
				case 0x31:
					method = "LoadUnsigned8Bitreplacedigned64";
					break;
				case 0x32:
					method = "LoadSigned16Bitreplacedigned64";
					break;
				case 0x33:
					method = "LoadUnsigned16Bitreplacedigned64";
					break;
				case 0x34:
					method = "LoadSigned32Bitreplacedigned64";
					break;
				case 0x35:
					method = "LoadUnsigned32Bitreplacedigned64";
					break;

				case 0x36:
					method = "Store32BitFrom32";
					break;
				case 0x37:
					method = "Store64BitFrom32";
					break;
				case 0x38:
					method = "StoreSingle";
					break;
				case 0x39:
					method = "StoreDouble";
					break;

				case 0x3a:
					method = "Store8BitFrom32";
					break;
				case 0x3b:
					method = "Store16BitFrom32";
					break;
				case 0x3c:
					method = "Store8BitFrom64";
					break;
				case 0x3d:
					method = "Store16BitFrom64";
					break;
				case 0x3e:
					method = "Store32BitFrom64";
					break;

				case 0x3f:
					method = "CurrentMemory";
					break;
				case 0x40:
					method = "GrowMemory";
					break;
				default:
					throw new Exception (String.Format("Should not be reached: {0:X}", Opcode));
			}

			// Our opcode has an offset to apply to this address on top of the stack
			// FIXME: we ignore alignment
			ilgen.Emit (OpCodes.Ldc_I4, Convert.ToInt32 (offset));
			ilgen.Emit (OpCodes.Add);

			// Now we want to set ourselves up for a call
			var method_info = typeof (WebreplacedemblyModule).GetMethod (method, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method_info == null)
				throw new Exception (String.Format("Could not find {0} in runtime", method));
			var call_types = new List<Type> ();

			foreach (var param_info in method_info.GetParameters ())
				call_types.Add (param_info.ParameterType);

			ShiftThisArgToFront (ilgen, call_types.ToArray ());
			ilgen.Emit(OpCodes.Call, method_info);

			return;
		}

19 View Source File : DbSchema.cs
License : MIT License
Project Creator : AlenToma

public CodeToDataBaseMergeCollection GetDatabase_Diff(Type tableType, CodeToDataBaseMergeCollection str = null, List<Type> createdTables = null)
        {

            str = str ?? new CodeToDataBaseMergeCollection(_repository);
            if (tableType.GetCustomAttribute<ExcludeFromAbstract>() != null || _alreadyControlled.Any(x => x == tableType))
                return str;
            _repository.CreateSchema(tableType);
            tableType = tableType.GetActualType();
            _alreadyControlled.Add(tableType);
            createdTables = createdTables ?? new List<Type>();
            if (createdTables.Any(x => x == tableType) || tableType.GetPrimaryKey() == null)
                return str;

            if (CodeToDataBaseMergeCollection.ExecutedData.ContainsKey(tableType.FullName + _repository.DataBaseTypes.ToString()))
                return str;

            createdTables.Add(tableType);
            var table = _repository.GetColumnSchema(tableType);
            var tableName = tableType.TableName();
            var props = DeepCloner.GetFastDeepClonerProperties(tableType).Where(x => x.CanRead && !x.ContainAttribute<ExcludeFromAbstract>());
            var codeToDataBaseMerge = new CodeToDataBaseMerge() { Object_Type = tableType };
            var isPrimaryKey = "";
            if (!IsValidName(tableName.Name))
                throw new EnreplacedyException(tableName.Name + " is not a valid Name for the current provider " + _repository.DataBaseTypes);


            if (!table.Values.Any())
            {
                codeToDataBaseMerge.Sql = new StringBuilder($"CREATE TABLE {tableName.GetName(_repository.DataBaseTypes)} (");
                foreach (var prop in props.Where(x => (x.GetDbTypeByType(_repository.DataBaseTypes) != null || !x.IsInternalType ||
                x.ContainAttribute<JsonDoreplacedent>() || x.ContainAttribute<XmlDoreplacedent>()) &&
                !x.ContainAttribute<ExcludeFromAbstract>()).GroupBy(x => x.Name).Select(x => x.First())
                        .OrderBy(x => x.ContainAttribute<PrimaryKey>() ? null : x.Name))
                {
                    if (!prop.IsInternalType && !prop.ContainAttribute<JsonDoreplacedent>() && !prop.ContainAttribute<XmlDoreplacedent>())
                    {
                        if (!str.Any(x => x.Object_Type == prop.PropertyType.GetActualType()) && createdTables.All(x => x != prop.PropertyType.GetActualType()))
                            GetDatabase_Diff(prop.PropertyType, str, createdTables);
                        continue;
                    }

                    isPrimaryKey = prop.ContainAttribute<PrimaryKey>() ? prop.GetPropertyName() : isPrimaryKey;
                    var foreignKey = prop.GetCustomAttribute<ForeignKey>();
                    var dbType = prop.GetDbTypeByType(_repository.DataBaseTypes);
                    var propName = string.Format("[{0}]", prop.GetPropertyName());
                    codeToDataBaseMerge.Sql.Append(propName + " ");
                    if (!IsValidName(prop.GetPropertyName()))
                        throw new Exception(prop.GetPropertyName() + " is not a valid Name for the current provider " + _repository.DataBaseTypes);



                    if (!prop.ContainAttribute<PrimaryKey>() || _repository.DataBaseTypes == DataBaseTypes.Mssql)
                        codeToDataBaseMerge.Sql.Append(dbType + " ");


                    if (foreignKey != null && createdTables.All(x => x != foreignKey.Type))
                        GetDatabase_Diff(foreignKey.Type, str, createdTables);

                    if (prop.ContainAttribute<PrimaryKey>())
                    {
                        if (prop.PropertyType.IsNumeric() && prop.GetCustomAttribute<PrimaryKey>().AutoGenerate)
                            codeToDataBaseMerge.Sql.Append(_repository.DataBaseTypes == DataBaseTypes.Mssql ? "IDENreplacedY(1,1) NOT NULL," : (_repository.DataBaseTypes == DataBaseTypes.Sqllight ? " Integer PRIMARY KEY AUTOINCREMENT," : " BIGSERIAL PRIMARY KEY,"));
                        else codeToDataBaseMerge.Sql.Append(_repository.DataBaseTypes == DataBaseTypes.Mssql ? "NOT NULL," : " " + dbType + "  PRIMARY KEY,");
                        continue;
                    }

                    if (foreignKey != null)
                    {
                        var key = propName + "-" + tableName.GetName(_repository.DataBaseTypes);
                        if (!str.Keys.ContainsKey(key))
                            str.Keys.Add(key, new Tuple<string, ForeignKey>(tableName.GetName(_repository.DataBaseTypes), foreignKey));
                    }

                    codeToDataBaseMerge.Sql.Append((Nullable.GetUnderlyingType(prop.PropertyType) != null || prop.PropertyType == typeof(string)) && !prop.ContainAttribute<NotNullable>() ? " NULL," : " NOT NULL,");
                }

                if (str.Keys.Any() && _repository.DataBaseTypes == DataBaseTypes.Sqllight)
                {
                    while (str.Keys.Any(x => x.Value.Item1 == tableName.Name))
                    {

                        var key = str.Keys.FirstOrDefault(x => x.Value.Item1 == tableName.Name);
                        var type = key.Value.Item2.Type.GetActualType();
                        var keyPrimary = type.GetPrimaryKey().GetPropertyName();
                        var tb = type.TableName();
                        codeToDataBaseMerge.Sql.Append("FOREIGN KEY(" + key.Key.Split('-')[0] + ") REFERENCES " + tb.GetName(_repository.DataBaseTypes) + "(" + keyPrimary + "),");
                        str.Keys.Remove(key.Key);
                    }

                }

                if (!string.IsNullOrEmpty(isPrimaryKey) && _repository.DataBaseTypes == DataBaseTypes.Mssql)
                {
                    codeToDataBaseMerge.Sql.Append(" CONSTRAINT [PK_" + tableName.Name + "] PRIMARY KEY CLUSTERED");
                    codeToDataBaseMerge.Sql.Append(" ([" + isPrimaryKey + "] ASC");
                    codeToDataBaseMerge.Sql.Append(")");
                    codeToDataBaseMerge.Sql.Append("WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]");
                    codeToDataBaseMerge.Sql.Append(") ON [PRIMARY]");
                }
                else
                {
                    if (_repository.DataBaseTypes == DataBaseTypes.Sqllight)
                        codeToDataBaseMerge.Sql = new StringBuilder(codeToDataBaseMerge.Sql.ToString().TrimEnd(','));
                    codeToDataBaseMerge.Sql.Append(")");
                }

                str.Add(codeToDataBaseMerge);
            }
            else
            {
                foreach (var prop in props.Where(x => (x.GetDbTypeByType(_repository.DataBaseTypes) != null || !x.IsInternalType) && !x.ContainAttribute<ExcludeFromAbstract>()).GroupBy(x => x.Name).Select(x => x.First())
                .OrderBy(x => x.ContainAttribute<PrimaryKey>() ? null : x.Name))
                {

                    if (prop.ContainAttribute<ForeignKey>())
                        GetDatabase_Diff(prop.GetCustomAttribute<ForeignKey>().Type, str, createdTables);
                    var propType = prop.PropertyType;
                    if (prop.ContainAttribute<Stringify>() ||
                        prop.ContainAttribute<DataEncode>() ||
                        prop.ContainAttribute<ToBase64String>() ||
                        prop.ContainAttribute<JsonDoreplacedent>() ||
                        prop.ContainAttribute<XmlDoreplacedent>())
                        propType = typeof(string);

                    var modify = prop.IsInternalType || prop.ContainAttribute<JsonDoreplacedent>() || prop.ContainAttribute<XmlDoreplacedent>() ? (_repository.DataBaseTypes == DataBaseTypes.PostgreSql ? table.Get(prop.GetPropertyName().ToLower()) : table.Get(prop.GetPropertyName())) : null;
                    if (modify != null)
                    {

                        if (_repository.DataBaseTypes != DataBaseTypes.Sqllight && !(prop.GetDbTypeListByType(_repository.DataBaseTypes).Any(x => x.ToLower().Contains(modify.DataType.ToLower()))) && _repository.DataBaseTypes != DataBaseTypes.PostgreSql)
                        {
                            var constraine = Properties.Resources.DropContraine
                                .Replace("@tb", $"'{tableName.Name}'").Replace("@col", $"'{prop.GetPropertyName()}'")
                                .Replace("@schema", $"'{tableName.Schema ?? ""}'")
                                .Replace("@TableName", "@" + counter++)
                                .Replace("@ColumnName", "@" + counter++)
                                .Replace("@fullName", "@" + counter++)
                                .Replace("@DROP_COMMAND", "@" + counter++)
                                .Replace("@FOREIGN_KEY_NAME", "@" + counter++);
                            codeToDataBaseMerge.Sql.Append(constraine);
                            codeToDataBaseMerge.Sql.Append($"\nALTER TABLE {tableName.GetName(_repository.DataBaseTypes)} ALTER COLUMN [{prop.GetPropertyName()}] {prop.GetDbTypeByType(_repository.DataBaseTypes)} {((Nullable.GetUnderlyingType(propType) != null || propType == typeof(string)) && !prop.ContainAttribute<NotNullable>() ? " NULL" : " NOT NULL")}");
                        }
                        else
                        {
                            if (!(prop.GetDbTypeListByType(_repository.DataBaseTypes).Any(x => x.ToLower().Contains(modify.DataType.ToLower()))) && _repository.DataBaseTypes == DataBaseTypes.PostgreSql)
                                codeToDataBaseMerge.Sql.Append($"\nALTER TABLE {tableName.GetName(_repository.DataBaseTypes)} ALTER COLUMN [{prop.GetPropertyName()}] TYPE {prop.GetDbTypeByType(_repository.DataBaseTypes)}, ALTER COLUMN [{prop.GetPropertyName()}] SET DEFAULT {Querys.GetValueByTypeSTRING(MethodHelper.ConvertValue(null, propType), _repository.DataBaseTypes)};");


                        }
                    }
                    else if (!prop.IsInternalType && !prop.ContainAttribute<JsonDoreplacedent>() && !prop.ContainAttribute<XmlDoreplacedent>())
                        GetDatabase_Diff(prop.PropertyType, str, createdTables);
                    else
                    {
                        codeToDataBaseMerge.Sql.Append(string.Format("\nALTER TABLE {0} ADD " + (_repository.DataBaseTypes == DataBaseTypes.PostgreSql ? "COLUMN" : "") + " [{1}] {2} {3} DEFAULT {4};", tableName.GetName(_repository.DataBaseTypes), prop.GetPropertyName(), prop.GetDbTypeByType(_repository.DataBaseTypes),
                              (Nullable.GetUnderlyingType(propType) != null || propType == typeof(string)) && !prop.ContainAttribute<NotNullable>() ? " NULL" : " NOT NULL", Querys.GetValueByTypeSTRING(MethodHelper.ConvertValue(null, propType), _repository.DataBaseTypes)));
                    }
                }
            }

            var colRemove = new CodeToDataBaseMerge() { Object_Type = tableType };
            // Now lets clean the table and remove unused columns
            foreach (var col in table.Values.Where(x =>
             !props.Any(a => string.Equals(x.ColumnName, a.GetPropertyName(), StringComparison.CurrentCultureIgnoreCase) &&
             (a.GetDbTypeByType(_repository.DataBaseTypes) != null || (!a.IsInternalType || a.ContainAttribute<JsonDoreplacedent>() || a.ContainAttribute<XmlDoreplacedent>())) &&
             !a.ContainAttribute<ExcludeFromAbstract>())))
            {
                if (_repository.DataBaseTypes != DataBaseTypes.Sqllight)
                {
                    if (_repository.DataBaseTypes == DataBaseTypes.Mssql)
                    {
                        var constraine = Properties.Resources.DropContraine
                            .Replace("@tb", $"'{tableName.Name}'")
                            .Replace("@col", $"'{col.ColumnName}'")
                            .Replace("@schema", $"'{tableName.Schema ?? ""}'")
                            .Replace("@TableName", "@" + counter++)
                            .Replace("@ColumnName", "@" + counter++)
                            .Replace("@fullName", "@" + counter++)
                            .Replace("@DROP_COMMAND", "@" + counter++)
                            .Replace("@FOREIGN_KEY_NAME", "@" + counter++);

                        colRemove.Sql.Append(constraine);

                    }
                    colRemove.Sql.Append(string.Format("\nALTER TABLE {0} DROP COLUMN IF EXISTS [{1}];", tableName.GetName(_repository.DataBaseTypes), col.ColumnName));

                }
                else
                {
                    colRemove.Sql.Append(string.Format("DROP TABLE IF exists [{0}_temp];\nCREATE TABLE [{0}_temp] AS SELECT {1} FROM [{0}];", tableName.Name, string.Join(",", table.Values.ToList().FindAll(x =>
                    props.Any(a => string.Equals(x.ColumnName, a.GetPropertyName(), StringComparison.CurrentCultureIgnoreCase) &&
                    (a.GetDbTypeByType(_repository.DataBaseTypes) != null || !a.IsInternalType) &&
                    !a.ContainAttribute<ExcludeFromAbstract>())).Select(x => x.ColumnName))));
                    colRemove.Sql.Append(string.Format("DROP TABLE [{0}];\n", tableName.Name));
                    colRemove.Sql.Append(string.Format("ALTER TABLE [{0}_temp] RENAME TO [{0}]; ", tableName.Name));
                }
                colRemove.DataLoss = true;
            }
            str.Add(colRemove);

            foreach (var prop in props.Where(x => !x.IsInternalType && !x.ContainAttribute<JsonDoreplacedent>() && !x.ContainAttribute<XmlDoreplacedent>() && !x.ContainAttribute<XmlDoreplacedent>() && !x.ContainAttribute<ExcludeFromAbstract>()).GroupBy(x => x.Name).Select(x => x.First()))
            {
                var type = prop.PropertyType.GetActualType();
                if (type.GetPrimaryKey() != null)
                    GetDatabase_Diff(type, str, createdTables);
            }

            str.Add(codeToDataBaseMerge);
            return str;
        }

19 View Source File : AwaiterExtensions.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private static List<Type> GenerateObjectTrace(IEnumerable<IEnumerator> enumerators)
            {
                var objTrace = new List<Type>();

                foreach (var enumerator in enumerators)
                {
                    // NOTE: This only works with scripting engine 4.6
                    // And could easily stop working with unity updates
                    var field = enumerator.GetType().GetField("$this", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                    if (field == null)
                    {
                        continue;
                    }

                    var obj = field.GetValue(enumerator);

                    if (obj == null)
                    {
                        continue;
                    }

                    var objType = obj.GetType();

                    if (!objTrace.Any() || objType != objTrace.Last())
                    {
                        objTrace.Add(objType);
                    }
                }

                objTrace.Reverse();
                return objTrace;
            }

19 View Source File : PluginManager.cs
License : GNU General Public License v3.0
Project Creator : alexdillon

public void LoadPlugins(string pluginsPath)
        {
            this.GroupChatPluginsAutoInstalled.Clear();
            this.GroupChatPluginsBuiltIn.Clear();
            this.GroupChatPluginsManuallyInstalled.Clear();

            this.MessageComposePluginsAutoInstalled.Clear();
            this.MessageComposePluginsBuiltIn.Clear();
            this.MessageComposePluginsManuallyInstalled.Clear();

            Directory.CreateDirectory(pluginsPath);
            Directory.CreateDirectory(Path.Combine(pluginsPath, PluginInstaller.PackagesDirectory));

            if (Directory.Exists(pluginsPath))
            {
                // Handle staged removals
                foreach (var file in Directory.GetFiles(Path.Combine(pluginsPath, PluginInstaller.PackagesDirectory), "*.rm"))
                {
                    if (Path.GetFileNameWithoutExtension(file).EndsWith(PluginInstaller.StagingSuffix))
                    {
                        var originalPluginName = Path.GetFileNameWithoutExtension(file).Replace(PluginInstaller.StagingSuffix, string.Empty);
                        var originalPluginFullPath = Path.Combine(pluginsPath, PluginInstaller.PackagesDirectory, originalPluginName);

                        if (new FileInfo(file).Length == 0)
                        {
                            // Delete the zero-byte staging stub
                            File.Delete(file);

                            // Delete the staged installation directory
                            if (Directory.Exists(originalPluginFullPath))
                            {
                                Directory.Delete(originalPluginFullPath, true);
                            }
                        }
                    }
                }

                // Handle staged upgrades
                foreach (var directory in Directory.GetDirectories(Path.Combine(pluginsPath, PluginInstaller.PackagesDirectory)))
                {
                    if (Path.GetFileNameWithoutExtension(directory).EndsWith(PluginInstaller.StagingSuffix))
                    {
                        var originalPluginName = Path.GetFileNameWithoutExtension(directory).Replace(PluginInstaller.StagingSuffix, string.Empty);
                        var originalPluginFullPath = Path.Combine(pluginsPath, PluginInstaller.PackagesDirectory, originalPluginName);

                        if (Directory.Exists(originalPluginFullPath))
                        {
                            Directory.Delete(originalPluginFullPath, true);
                        }

                        Directory.Move(directory, originalPluginFullPath);
                    }
                }

                var dllFileNames = Directory.GetFiles(pluginsPath, "*.dll", SearchOption.AllDirectories);

                var replacedemblies = new List<replacedembly>(dllFileNames.Length);
                foreach (string dllFile in dllFileNames)
                {
                    var an = replacedemblyName.GetreplacedemblyName(dllFile);
                    var replacedembly = replacedembly.Load(an);
                    replacedemblies.Add(replacedembly);
                }

                var pluginType = typeof(PluginBase);
                var pluginTypes = new List<Type>();
                foreach (var replacedembly in replacedemblies)
                {
                    if (replacedembly != null)
                    {
                        try
                        {
                            var types = replacedembly.GetTypes();
                            foreach (var type in types)
                            {
                                if (type.IsInterface || type.IsAbstract)
                                {
                                    continue;
                                }
                                else
                                {
                                    if (type.IsSubclreplacedOf(pluginType))
                                    {
                                        pluginTypes.Add(type);
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            Debug.WriteLine($"Failed to load plugin {replacedembly.FullName}");
                        }
                    }
                }

                var pluginInstaller = Ioc.Default.GetService<PluginInstaller>();

                foreach (var type in pluginTypes)
                {
                    var hostedreplacedemblyName = Path.GetFileNameWithoutExtension(Path.GetDirectoryName(type.Module.replacedembly.Location));
                    var installedPlugin = pluginInstaller.InstalledPlugins.FirstOrDefault(p => p.InstallationGuid == hostedreplacedemblyName);

                    var plugin = (PluginBase)Activator.CreateInstance(type);

                    if (plugin is IMessageComposePlugin messageComposePlugin)
                    {
                        if (installedPlugin == null)
                        {
                            this.MessageComposePluginsManuallyInstalled.Add(messageComposePlugin);
                        }
                        else
                        {
                            this.MessageComposePluginsAutoInstalled.Add(messageComposePlugin);
                        }
                    }
                    else if (plugin is IGroupChatPlugin groupChatPlugin)
                    {
                        if (installedPlugin == null)
                        {
                            this.GroupChatPluginsManuallyInstalled.Add(groupChatPlugin);
                        }
                        else
                        {
                            this.GroupChatPluginsAutoInstalled.Add(groupChatPlugin);
                        }
                    }
                }
            }

            // Load plugins that ship directly in GMDC/Wpf
            this.GroupChatPluginsBuiltIn.Add(new ImageGalleryPlugin());
        }

19 View Source File : UMAAssetIndexer.cs
License : Apache License 2.0
Project Creator : A7ocin

void ISerializationCallbackReceiver.OnAfterDeserialize()
        {
            var st = StartTimer();
            #region typestuff
            List<System.Type> newTypes = new List<System.Type>()
        {
        (typeof(SlotDatareplacedet)),
        (typeof(OverlayDatareplacedet)),
        (typeof(RaceData)),
        (typeof(UMATextRecipe)),
        (typeof(UMAWardrobeRecipe)),
        (typeof(UMAWardrobeCollection)),
        (typeof(RuntimeAnimatorController)),
#if UNITY_EDITOR
        (typeof(AnimatorController)),
#endif
        (typeof(DynamireplacedADnareplacedet)),
        (typeof(Textreplacedet))
        };

            TypeToLookup = new Dictionary<System.Type, System.Type>()
        {
        { (typeof(SlotDatareplacedet)),(typeof(SlotDatareplacedet)) },
        { (typeof(OverlayDatareplacedet)),(typeof(OverlayDatareplacedet)) },
        { (typeof(RaceData)),(typeof(RaceData)) },
        { (typeof(UMATextRecipe)),(typeof(UMATextRecipe)) },
        { (typeof(UMAWardrobeRecipe)),(typeof(UMAWardrobeRecipe)) },
        { (typeof(UMAWardrobeCollection)),(typeof(UMAWardrobeCollection)) },
        { (typeof(RuntimeAnimatorController)),(typeof(RuntimeAnimatorController)) },
#if UNITY_EDITOR
        { (typeof(AnimatorController)),(typeof(RuntimeAnimatorController)) },
#endif
        {  typeof(Textreplacedet), typeof(Textreplacedet) },
        { (typeof(DynamireplacedADnareplacedet)), (typeof(DynamireplacedADnareplacedet)) }
        };

            List<string> invalidTypeNames = new List<string>();
            // Add the additional Types.
            foreach (string s in IndexedTypeNames)
            {
                if (s == "")
                    continue;
                System.Type sType = System.Type.GetType(s);
                if (sType == null)
                {
                    invalidTypeNames.Add(s);
                    Debug.LogWarning("Could not find type for " + s);
                    continue;
                }
                newTypes.Add(sType);
                if (!TypeToLookup.ContainsKey(sType))
                {
                    TypeToLookup.Add(sType, sType);
                }
            }

            Types = newTypes.ToArray();

            if (invalidTypeNames.Count > 0)
            {
                foreach (string ivs in invalidTypeNames)
                {
                    IndexedTypeNames.Remove(ivs);
                }
            }
            BuildStringTypes();
            #endregion
            UpdateSerializedDictionaryItems();
            StopTimer(st, "Before Serialize");
        }

19 View Source File : ToolManager.cs
License : Apache License 2.0
Project Creator : Algoryx

private static Type FindCustomToolType( Type targetType )
    {
      if ( targetType == null || m_cachedIgnoredTypes.Contains( targetType ) )
        return null;

      Type customToolType = null;
      if ( !m_cachedCustomToolTypeMap.TryGetValue( targetType, out customToolType ) ) {
        Type[] types = null;
        try {
          types = m_replacedembliesWithCustomTools.SelectMany( name => replacedembly.Load( name ).GetTypes() ).ToArray();
        }
        catch ( Exception ) {
        }

        if ( types == null )
          types = replacedembly.Load( Manager.AGXUnityEditorreplacedemblyName ).GetTypes();

        var customToolTypes = new List<Type>();
        foreach ( var type in types ) {
          // CustomTool attribute can only be used with tools
          // inheriting from CustomTargetTool.
          if ( !typeof( CustomTargetTool ).IsreplacedignableFrom( type ) )
            continue;

          var customToolAttribute = type.GetCustomAttribute<CustomToolAttribute>( false );
          if ( customToolAttribute == null )
            continue;

          // Exact match - break search.
          if ( customToolAttribute.Type == targetType ) {
            customToolTypes.Clear();
            customToolTypes.Add( type );
            break;
          }
          // Type of custom tool desired type is replacedignable from current
          // target type. Store this if an exact match comes later.
          // E.g.: CustomTool( typeof( Shape ) ) and CustomTool( typeof( Box ) ).
          else if ( customToolAttribute.Type.IsreplacedignableFrom( targetType ) )
            customToolTypes.Add( type );
        }

        customToolType = customToolTypes.FirstOrDefault();
        if ( customToolType != null )
          m_cachedCustomToolTypeMap.Add( targetType, customToolType );
      }

      if ( customToolType == null )
        m_cachedIgnoredTypes.Add( targetType );

      return customToolType;
    }

19 View Source File : MessageHandlerContainer.cs
License : MIT License
Project Creator : AdemCatamak

private static List<Type> GetPayloadTypes(Type messageHandlerType)
        {
            List<Type> payloadTypes = new List<Type>();
            foreach (Type interfaceType in messageHandlerType.GetInterfaces())
            {
                if (interfaceType.IsGenericType
                 && interfaceType.GetGenericTypeDefinition() == typeof(IMessageHandler<>))
                {
                    payloadTypes.Add(interfaceType.GetGenericArguments()[0]);
                }
            }

            return payloadTypes.Distinct().ToList();
        }

19 View Source File : ActionDispatcher.cs
License : Apache License 2.0
Project Creator : allenai

private static List<MethodInfo> getCandidateMethods(Type targetType, string action) {
        Dictionary<string, List<MethodInfo>> methodDispatchTable = getMethodDispatchTable(targetType);
        if (!methodDispatchTable.ContainsKey(action)) {
            List<MethodInfo> methods = new List<MethodInfo>();

            List<Type> hierarchy = new List<Type>();

            // not completely generic
            Type ht = targetType;
            while (ht != typeof(object)) {
                hierarchy.Add(ht);
                ht = ht.BaseType;
            }

            foreach (MethodInfo mi in getMethods(targetType)) {
                if (mi.Name != action) {
                    continue;
                }
                bool replaced = false;

                // we do this to handle the case of a child method hiding a method in the parent
                // in which case both methods will show up.  This happens if virtual, override or new
                // are not used
                ParameterInfo[] sourceParams = mi.GetParameters();

                for (int j = 0; j < methods.Count && !replaced; j++) {
                    bool signatureMatch = true;
                    ParameterInfo[] targetParams = methods[j].GetParameters();
                    int minCommon = Math.Min(sourceParams.Length, targetParams.Length);
                    for (int k = 0; k < minCommon; k++) {
                        if (sourceParams[k].ParameterType != targetParams[k].ParameterType) {
                            signatureMatch = false;
                            break;
                        }
                    }

                    if (sourceParams.Length > targetParams.Length && !sourceParams[minCommon].HasDefaultValue) {
                        signatureMatch = false;
                    } else if (targetParams.Length > sourceParams.Length && !targetParams[minCommon].HasDefaultValue) {
                        signatureMatch = false;
                    }

                    // if the method is more specific and the parameters match
                    // we will dispatch to this method instead of the base type
                    if (signatureMatch) {
                        // this happens if one method has a trailing optional value and all 
                        // other parameter types match
                        if (targetParams.Length != sourceParams.Length) {
                            throw new AmbiguousActionException("Signature match found in the same clreplaced");
                        }

                        replaced = true;
                        if (hierarchy.IndexOf(mi.DeclaringType) < hierarchy.IndexOf(methods[j].DeclaringType)) {
                            methods[j] = mi;
                        }
                    }
                }

                if (!replaced) {
                    // we sort the list of methods so that we evaluate
                    // methods with fewer and possible no params first
                    // and then match methods with greater params
                    methods.Add(mi);
                    MethodParamComparer mc = new MethodParamComparer();
                    methods.Sort(mc);
                }
            }

            // must perform replacedignment here, since an exception could be thrown during
            // the creation of the list. if the list were replacedigned directly to the allMethodDispatchTable
            // its possible that it would be only partially populated
            methodDispatchTable[action] = methods;
        }

        return methodDispatchTable[action];
    }

19 View Source File : FilterManager.cs
License : MIT License
Project Creator : 99x

internal void Register<T>() where T: AbstractFilter
        {
            this.filterChain.Add(typeof(T));
        }

19 View Source File : InspectorScript.cs
License : GNU General Public License v3.0
Project Creator : AndrasMumm

private string GetTypeString(GameObject obj)
        {
            string typeString = "";
            Queue<Type> toDo = new Queue<Type>();
            List<Type> result = new List<Type>();

            toDo.Enqueue(obj.GetType());
            while (toDo.Count > 0)
            {
                Type type = toDo.Dequeue();
                List<Type> dTypes = new List<Type>();
                if (derivedTypes.TryGetValue(type, out dTypes))
                {
                    foreach (Type t in dTypes)
                    {
                        if (!result.Contains(t))
                        {
                            toDo.Enqueue(t);
                            result.Add(t);
                        }
                    }
                }
            }

            foreach (Type t in result)
            {
                if (typeString != "") typeString += "=>";
                typeString += t.ToString();
            }

            return typeString;
        }

19 View Source File : EntityObjectBase.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static void RegisteSupperType(Type type)
        {
            if (typeList.Contains(type))
            {
                return;
            }
            typeList.Add(type);
            _haseNew = true;
        }

19 View Source File : AutofacModuleRegister.cs
License : Apache License 2.0
Project Creator : anjoy8

protected override void Load(ContainerBuilder builder)
        {
            var basePath = AppContext.BaseDirectory;
            //builder.RegisterType<AdvertisementServices>().As<IAdvertisementServices>();


            #region 带有接口层的服务注入

            var servicesDllFile = Path.Combine(basePath, "Blog.Core.Services.dll");
            var repositoryDllFile = Path.Combine(basePath, "Blog.Core.Repository.dll");

            if (!(File.Exists(servicesDllFile) && File.Exists(repositoryDllFile)))
            {
                var msg = "Repository.dll和service.dll 丢失,因为项目解耦了,所以需要先F6编译,再F5运行,请检查 bin 文件夹,并拷贝。";
                log.Error(msg);
                throw new Exception(msg);
            }



            // AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。
            var cacheType = new List<Type>();
            if (Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool())
            {
                builder.RegisterType<BlogRedisCacheAOP>();
                cacheType.Add(typeof(BlogRedisCacheAOP));
            }
            if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
            {
                builder.RegisterType<BlogCacheAOP>();
                cacheType.Add(typeof(BlogCacheAOP));
            }
            if (Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool())
            {
                builder.RegisterType<BlogTranAOP>();
                cacheType.Add(typeof(BlogTranAOP));
            }
            if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
            {
                builder.RegisterType<BlogLogAOP>();
                cacheType.Add(typeof(BlogLogAOP));
            }

            builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IBaseRepository<>)).InstancePerDependency();//注册仓储

            // 获取 Service.dll 程序集服务,并注册
            var replacedemblysServices = replacedembly.LoadFrom(servicesDllFile);
            builder.RegisterreplacedemblyTypes(replacedemblysServices)
                      .AsImplementedInterfaces()
                      .InstancePerDependency()
                      .PropertiesAutowired()
                      .EnableInterfaceInterceptors()//引用Autofac.Extras.DynamicProxy;
                      .InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。

            // 获取 Repository.dll 程序集服务,并注册
            var replacedemblysRepository = replacedembly.LoadFrom(repositoryDllFile);
            builder.RegisterreplacedemblyTypes(replacedemblysRepository)
                   .AsImplementedInterfaces()
                   .PropertiesAutowired()
                   .InstancePerDependency();

            #endregion

            #region 没有接口层的服务层注入

            //因为没有接口层,所以不能实现解耦,只能用 Load 方法。
            //注意如果使用没有接口的服务,并想对其使用 AOP 拦截,就必须设置为虚方法
            //var replacedemblysServicesNoInterfaces = replacedembly.Load("Blog.Core.Services");
            //builder.RegisterreplacedemblyTypes(replacedemblysServicesNoInterfaces);

            #endregion

            #region 没有接口的单独类,启用clreplaced代理拦截

            //只能注入该类中的虚方法,且必须是public
            //这里仅仅是一个单独类无接口测试,不用过多追问
            builder.RegisterreplacedemblyTypes(replacedembly.Getreplacedembly(typeof(Love)))
                .EnableClreplacedInterceptors()
                .InterceptedBy(cacheType.ToArray());
            #endregion

            #region 单独注册一个含有接口的类,启用interface代理拦截

            //不用虚方法
            //builder.RegisterType<AopService>().As<IAopService>()
            //   .AsImplementedInterfaces()
            //   .EnableInterfaceInterceptors()
            //   .InterceptedBy(typeof(BlogCacheAOP));
            #endregion

        }

19 View Source File : UMAAssetIndexer.cs
License : Apache License 2.0
Project Creator : A7ocin

public void AddType(System.Type sType)
        {
            string QualifiedName = sType.replacedemblyQualifiedName;
            if (IsAdditionalIndexedType(QualifiedName)) return;

            List<System.Type> newTypes = new List<System.Type>();
            newTypes.AddRange(Types);
            newTypes.Add(sType);
            Types = newTypes.ToArray();
            TypeToLookup.Add(sType, sType);
            IndexedTypeNames.Add(sType.replacedemblyQualifiedName);
            BuildStringTypes();
        }

19 View Source File : AutofacModuleRegister.cs
License : Apache License 2.0
Project Creator : anjoy8

protected override void Load(ContainerBuilder builder)
        {
            var basePath = AppContext.BaseDirectory;


            builder.RegisterType<BlogLogAOP>();
            builder.RegisterType<BlogCacheAOP>();//可以直接替换其他拦截器

            #region Service.dll 注入,有对应接口
            try
            {
                var servicesDllFile = Path.Combine(basePath, "Student.Achieve.Repository.dll");
                var replacedemblysServices = replacedembly.LoadFrom(servicesDllFile);

                var cacheType = new List<Type>();
                if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
                {
                    cacheType.Add(typeof(BlogLogAOP));
                }
                if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
                {
                    cacheType.Add(typeof(BlogCacheAOP));
                }

                builder.RegisterreplacedemblyTypes(replacedemblysServices)
                          .AsImplementedInterfaces()
                          .InstancePerLifetimeScope()
                          .EnableInterfaceInterceptors()
                          .InterceptedBy(cacheType.ToArray());
                #endregion


            }
            catch (Exception ex)
            {
                throw new Exception("※※★※※ 如果你是第一次下载项目,请先对整个解决方案dotnet build(F6编译),然后再对api层 dotnet run(F5执行),\n因为解耦了,如果你是发布的模式,请检查bin文件夹是否存在Repository.dll和service.dll ※※★※※" + ex.Message + "\n" + ex.InnerException);
            }


        }

19 View Source File : ContextInitializer.cs
License : MIT License
Project Creator : aishang2015

public static void ConfigurationEnreplacedy(this ModelBuilder builder, Type dbContextType)
        {
            var replacedemblyList = ReflectionHelper.replacedemblyList;

            replacedemblyList.ForEach(replacedembly =>
            {
                var enreplacedyTypeList = new List<Type>();
                foreach (var type in replacedembly.GetTypes())
                {
                    var attribute = type.GetCustomAttributes(typeof(EnreplacedyAttribute), false).FirstOrDefault();
                    if (attribute != null)
                    {
                        if (dbContextType == ((EnreplacedyAttribute)attribute).DbContextType)
                        {
                            builder.Enreplacedy(type);
                            enreplacedyTypeList.Add(type);
                        }
                    }
                }

                builder.ApplyConfigurationsFromreplacedembly(replacedembly, type =>
                {
                    var findType = type.GetInterface(typeof(IEnreplacedyTypeConfiguration<>).Name)
                        ?.GetGenericArguments()?.FirstOrDefault();
                    if (findType != null && enreplacedyTypeList.Contains(findType))
                    {
                        return true;
                    }
                    return false;
                });
            });
        }

19 View Source File : BuilderPlug.cs
License : GNU General Public License v3.0
Project Creator : anotak

public Type[] FindClreplacedes(Type t)
		{
			List<Type> found = new List<Type>();
			Type[] types;

			// Get all exported types
			types = replacedembly.GetExecutingreplacedembly().GetTypes();
			foreach(Type it in types)
			{
				// Compare types
				if(t.IsreplacedignableFrom(it)) found.Add(it);
			}

			// Return list
			return found.ToArray();
		}

19 View Source File : Utility.Reflection.cs
License : MIT License
Project Creator : 7Bytes-Studio

public static Type[] GetImplTypes(string[] replacedemblyNames,Type typeBase)
            {
                List<Type> list = new List<Type>();
                for (int i = 0; i < replacedemblyNames.Length; i++)
                {
                    var tps = GetImplTypes(replacedemblyNames[i], typeBase);
                    if (null!=tps)
                    {
                        for (int j = 0; j < tps.Length; j++)
                        {
                            list.Add(tps[j]);
                        }
                    }
                }
                return list.ToArray();
            }

19 View Source File : FunctionTag.cs
License : MIT License
Project Creator : aprilyush

private object GetFunctionResult()
        {
            //计算表达式的值
            object value = null;
            List<object> funcParams = new List<object>();
            List<Type>   funcParamsTypes = new List<Type>();
            foreach (IExpression exp in this.FunctionArgs)
            {
                object expValue = exp.GetValue();
                funcParams.Add(expValue);
                funcParamsTypes.Add(expValue == null ? typeof(object) : expValue.GetType());
            }

            string invokeMethod = this.Method.GetTextValue();
            if (this.Type == null)
            {
                //调用自定义函数
                UserDefinedFunction func;
                if (this.OwnerTemplate.UserDefinedFunctions.TryGetValue(invokeMethod, out func))
                {
                    value = func(funcParams.ToArray());
                }
            }
            else
            {
                //如果类型定义的是变量表达式则获取表达式的值,否则建立类型
                object container = this.Type.Value is VariableExpression ? this.Type.Value.GetValue() : Utility.CreateType(this.Type.Value.GetValue().ToString());

                if (container != null)
                {
                    System.Type type = container is System.Type ? (System.Type)container : container.GetType();
                    BindingFlags flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.IgnoreCase;
                    if (!(container is System.Type)) flags |= BindingFlags.Instance;

                    MethodInfo method = type.GetMethod(invokeMethod, flags, null, funcParamsTypes.ToArray(), null);
                    if (method == null)
                    {
                        //获取所有同名的方法
                        MemberInfo[] methods = type.GetMember(invokeMethod, flags | BindingFlags.InvokeMethod);
                        foreach (MethodInfo m in methods)
                        {
                            ParameterInfo[] parameters = m.GetParameters();
                            if (parameters.Length == 1
                                && parameters[0].ParameterType.IsArray
                                && parameters[0].ParameterType.FullName == "System.Object[]")
                            {
                                //如果函数只有一个参数,并且是Object数组参数
                                try
                                {
                                    value = m.Invoke(container is System.Type ? null : container, new object[] { funcParams.ToArray() });
                                    //不出错.则退出查找
                                    break;
                                }
                                catch (TargetInvocationException e)
                                {
                                    throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
                                }
                                catch { }
                            }
                            else if (parameters.Length == funcParams.Count)
                            {
                                //尝试转换类型
                                List<object> paramValues = new List<object>();
                                for (var i = 0; i < parameters.Length; i++)
                                {
                                    object v = funcParams[i];
                                    if (parameters[i].ParameterType != funcParamsTypes[i] && v != null)
                                    {
                                        v = Utility.ConvertTo(funcParams[i].ToString(), parameters[i].ParameterType);
                                        if (v == null) break;   //转换失败则尝试下一个方法

                                        paramValues.Add(v);
                                    }
                                    else
                                    {
                                        paramValues.Add(v);
                                    }
                                }
                                if (paramValues.Count == parameters.Length)
                                {
                                    try
                                    {
                                        value = m.Invoke(container is System.Type ? null : container, paramValues.ToArray());
                                        //不出错.则退出查找
                                        break;
                                    }
                                    catch (TargetInvocationException e)
                                    {
                                        throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
                                    }
                                    catch { }
                                }
                                paramValues.Clear();
                            }
                        }
                    }
                    else
                    {
                        //执行方法
                        try
                        {
                            value = method.Invoke(container is System.Type ? null : container, funcParams.ToArray());
                        }
                        catch (TargetInvocationException e)
                        {
                            throw new Exception(string.Format("在执行标签“{0}”的方法时出错", this.ToString()), e);
                        }
                        catch
                        {
                            value = null;
                        }
                    }
                }
            }

            return value;
        }

19 View Source File : NodeDataCache.cs
License : MIT License
Project Creator : aksyr

public void OnBeforeSerialize() {
                keys.Clear();
                values.Clear();
                foreach (var pair in this) {
                    keys.Add(pair.Key);
                    values.Add(pair.Value);
                }
            }

19 View Source File : InMemoryEventBusSubscriptionsManager.cs
License : MIT License
Project Creator : Abdulrhman5

public void AddSubscription<T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler<T>
        {
            var eventName = GetEventKey<T>();

            DoAddSubscription(typeof(TH), eventName);

            if (!_eventTypes.Contains(typeof(T)))
            {
                _eventTypes.Add(typeof(T));
            }
        }

19 View Source File : Utility.Reflection.cs
License : MIT License
Project Creator : 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 View Source File : ObjectPool.PoolFactoryBinder.partial.cs
License : MIT License
Project Creator : 7Bytes-Studio

public Type[] GetBindingTypes()
            {
                List<Type> list = new List<Type>();
                foreach (var k in m_BindDic.Keys)
                {
                    list.Add(k);
                }
                return list.ToArray();
            }

19 View Source File : UMAAssetIndexerEditor.cs
License : Apache License 2.0
Project Creator : A7ocin

private void DropAreaType(Rect dropArea)
		{

			var evt = Event.current;

			if (evt.type == EventType.DragUpdated)
			{
				if (dropArea.Contains(evt.mousePosition))
				{
					DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
				}
			}

			if (evt.type == EventType.DragPerform)
			{
				if (dropArea.Contains(evt.mousePosition))
				{
					DragAndDrop.AcceptDrag();
					AddedTypes.Clear();
					UnityEngine.Object[] draggedObjects = DragAndDrop.objectReferences as UnityEngine.Object[];
					for (int i = 0; i < draggedObjects.Length; i++)
					{
						if (draggedObjects[i])
						{
							System.Type sType = draggedObjects[i].GetType();

							AddedTypes.Add(sType);
						}
					}
				}
			}
		}

19 View Source File : TypeReferencePropertyDrawer.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private static Type[] FindTypesByName(string typeName, SystemTypeAttribute filter)
        {
            List<Type> types = new List<Type>();
            foreach (Type t in GetFilteredTypes(filter))
            {
                if (t.Name.Equals(typeName))
                {
                    types.Add(t);
                }
            }
            return types.ToArray();
        }

19 View Source File : Parser.cs
License : MIT License
Project Creator : alexanderkyte

public Type [] EmitParams ()
		{
			if (parameters.Length == 0)
				return null;

			var acreplaced = new List<Type> ();
			foreach (var res in parameters)
				acreplaced.Add (WebreplacedemblyValueType.Convert ((byte) res));

			return acreplaced.ToArray ();
		}

See More Examples