本文整理汇总了C#中Importer.Import方法的典型用法代码示例。如果您正苦于以下问题:C# Importer.Import方法的具体用法?C# Importer.Import怎么用?C# Importer.Import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Importer
的用法示例。
在下文中一共展示了Importer.Import方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDevirtualizedAttribute
/// <summary>
/// Create the DevirtualizedAttribute TypeDef, with a "default .ctor" that
/// calls the base type's .ctor (System.Attribute).
/// </summary>
/// <returns>TypeDef</returns>
TypeDef CreateDevirtualizedAttribute()
{
var importer = new Importer(this.Module);
var attributeRef = this.Module.CorLibTypes.GetTypeRef("System", "Attribute");
var attributeCtorRef = importer.Import(attributeRef.ResolveTypeDefThrow().FindMethod(".ctor"));
var devirtualizedAttr = new TypeDefUser(
"eazdevirt.Injected", "DevirtualizedAttribute", attributeRef);
//devirtualizedAttr.Attributes = TypeAttributes.Public | TypeAttributes.AutoLayout
// | TypeAttributes.Class | TypeAttributes.AnsiClass;
var emptyCtor = new MethodDefUser(".ctor", MethodSig.CreateInstance(this.Module.CorLibTypes.Void),
MethodImplAttributes.IL | MethodImplAttributes.Managed,
MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName |
MethodAttributes.ReuseSlot | MethodAttributes.HideBySig);
var instructions = new List<Instruction>();
instructions.Add(OpCodes.Ldarg_0.ToInstruction());
instructions.Add(OpCodes.Call.ToInstruction(attributeCtorRef)); // Call the constructor .ctor
instructions.Add(OpCodes.Ret.ToInstruction());
emptyCtor.Body = new CilBody(false, instructions, new List<ExceptionHandler>(), new List<Local>());
devirtualizedAttr.Methods.Add(emptyCtor);
return devirtualizedAttr;
}
示例2: Import
private Import(string path, Importer importer)
{
Importer = importer;
var regex = new Regex(@"\.(le|c)ss$");
Path = regex.IsMatch(path) ? path : path + ".less";
Css = Path.EndsWith("css");
if(!Css)
Importer.Import(this);
}
示例3: Import
private Import(string path, Importer importer)
{
Importer = importer;
var regex = new Regex(@"\.(le|c)ss$");
Path = regex.IsMatch(path) ? path : path + ".less";
Css = Path.EndsWith("css");
if (Css && Path.StartsWith(FORCE_IMPORT_PREFIX))
{
Css = false;
Path = Path.Substring(FORCE_IMPORT_PREFIX.Length);
}
if(!Css)
Importer.Import(this);
}
示例4: Import
private Import(string path, Importer importer)
{
Importer = importer;
Path = path;
if (path.EndsWith(".css"))
{
Css = true;
} else
{
Css = !Importer.Import(this); // it is assumed to be css if it cannot be found as less
if (Css && path.EndsWith(".less"))
{
throw new FileNotFoundException("You are importing a file ending in .less that cannot be found.", path);
}
}
}
示例5: GetArrayType
private TypeDef GetArrayType(long size)
{
CreateOurType();
TypeDef arrayType;
if (_arrayTypeDictionary.TryGetValue(size, out arrayType))
return arrayType;
var importer = new Importer(_module);
var valueTypeRef = importer.Import(typeof (ValueType));
arrayType = new TypeDefUser("", $"__StaticArrayInitTypeSize={size}", valueTypeRef);
_module.UpdateRowId(arrayType);
arrayType.Attributes = TypeAttributes.NestedPrivate | TypeAttributes.ExplicitLayout |
TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.AnsiClass;
_ourType.NestedTypes.Add(arrayType);
_arrayTypeDictionary[size] = arrayType;
arrayType.ClassLayout = new ClassLayoutUser(1, (uint) size);
return arrayType;
}
示例6: Import
public LocalVM Import(TypeSigCreatorOptions typeSigCreatorOptions, ModuleDef ownerModule) {
var opts = CreateLocalOptions();
var importer = new Importer(ownerModule, ImporterOptions.TryToUseDefs);
opts.Type = importer.Import(opts.Type);
return new LocalVM(typeSigCreatorOptions, opts);
}
示例7: Import
object Import(ModuleDef ownerModule, object o) {
var importer = new Importer(ownerModule, ImporterOptions.TryToUseDefs);
var tdr = o as ITypeDefOrRef;
if (tdr != null)
return importer.Import(tdr);
var method = o as IMethod;
if (method != null && method.IsMethod)
return importer.Import(method);
var field = o as IField;
if (field != null && field.IsField)
return importer.Import(field);
var msig = o as MethodSig;
if (msig != null)
return importer.Import(msig);
Debug.Assert(o == null);
return null;
}
示例8: ImportRows
protected void ImportRows(string tableName, string[] columnNames, IEnumerable<string[]> dataValues)
{
using (var importer = new Importer(SqlConnection, tableName, columnNames))
{
importer.Import(dataValues);
}
}