Catel.Fody.MsCoreReferenceFinder.GetCoreTypeReference C# (CSharp) 메소드

GetCoreTypeReference() 공개 메소드

public GetCoreTypeReference ( string typeName ) : TypeReference
typeName string
리턴 Mono.Cecil.TypeReference
        public TypeReference GetCoreTypeReference(string typeName)
        {
            if (!_typeReferences.ContainsKey(typeName))
            {
                var types = GetTypes();
                _typeReferences[typeName] = types.FirstOrDefault(x => string.Equals(x.Name, typeName) || string.Equals(x.FullName, typeName));
            }

            return _typeReferences[typeName];
        }

Usage Example

예제 #1
0
        private void EnsureStaticConstructor(TypeDefinition type)
        {
            var staticConstructor = type.Constructor(true);

            if (staticConstructor == null)
            {
                FodyEnvironment.LogDebug($"\t\t\t{type.Name} - adding static constructor");

                var voidType = _msCoreReferenceFinder.GetCoreTypeReference("Void");

                staticConstructor = new MethodDefinition(".cctor", MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Static | MethodAttributes.RTSpecialName,
                                                         type.Module.ImportReference(voidType));

                var body = staticConstructor.Body;
                body.SimplifyMacros();

                body.Instructions.Add(Instruction.Create(OpCodes.Ret));

                body.OptimizeMacros();

                type.Methods.Add(staticConstructor);

                FodyEnvironment.LogDebug($"\t\t\t{type.Name} - added static constructor");
            }
        }
All Usage Examples Of Catel.Fody.MsCoreReferenceFinder::GetCoreTypeReference