本文整理汇总了C#中Mono类的典型用法代码示例。如果您正苦于以下问题:C# Mono类的具体用法?C# Mono怎么用?C# Mono使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mono类属于命名空间,在下文中一共展示了Mono类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Construct
/// <summary>
/// Generates a proxy that forwards all virtual method calls
/// to a single <see cref="IInterceptor"/> instance.
/// </summary>
/// <param name="originalBaseType">The base class of the type being constructed.</param>
/// <param name="baseInterfaces">The list of interfaces that the new type must implement.</param>
/// <param name="module">The module that will hold the brand new type.</param>
/// <param name="targetType">The <see cref="TypeDefinition"/> that represents the type to be created.</param>
public override void Construct(Type originalBaseType, IEnumerable<Type> baseInterfaces, ModuleDefinition module, Mono.Cecil.TypeDefinition targetType)
{
var interfaces = new HashSet<Type>(baseInterfaces);
if (!interfaces.Contains(typeof(ISerializable)))
interfaces.Add(typeof(ISerializable));
var serializableInterfaceType = module.ImportType<ISerializable>();
if (!targetType.Interfaces.Contains(serializableInterfaceType))
targetType.Interfaces.Add(serializableInterfaceType);
// Create the proxy type
base.Construct(originalBaseType, interfaces, module, targetType);
// Add the Serializable attribute
targetType.IsSerializable = true;
var serializableCtor = module.ImportConstructor<SerializableAttribute>();
var serializableAttribute = new CustomAttribute(serializableCtor);
targetType.CustomAttributes.Add(serializableAttribute);
ImplementGetObjectData(originalBaseType, baseInterfaces, module, targetType);
DefineSerializationConstructor(module, targetType);
var interceptorType = module.ImportType<IInterceptor>();
var interceptorGetterProperty = (from PropertyDefinition m in targetType.Properties
where m.Name == "Interceptor" && m.PropertyType == interceptorType
select m).First();
}
示例2: LoadModule
public void LoadModule(System.IO.Stream dllStream, System.IO.Stream pdbStream, Mono.Cecil.Cil.ISymbolReaderProvider debugInfoLoader)
{
var module = Mono.Cecil.ModuleDefinition.ReadModule(dllStream);
if (debugInfoLoader != null && pdbStream != null)
{
module.ReadSymbols(debugInfoLoader.GetSymbolReader(module, pdbStream));
}
if (module.HasAssemblyReferences)
{
foreach (var ar in module.AssemblyReferences)
{
if (moduleref.Contains(ar.Name) == false)
moduleref.Add(ar.Name);
if (moduleref.Contains(ar.FullName) == false)
moduleref.Add(ar.FullName);
}
}
//mapModule[module.Name] = module;
if (module.HasTypes)
{
foreach (var t in module.Types)
{
mapType[t.FullName] = new Type_Common_CLRSharp(this, t);
}
}
}
示例3: GenerateHtml
public static string GenerateHtml (TextDocument doc, Mono.TextEditor.Highlighting.ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
{
var htmlText = new StringBuilder ();
htmlText.AppendLine (@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
htmlText.AppendLine ("<HTML>");
htmlText.AppendLine ("<HEAD>");
htmlText.AppendLine ("<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=utf-8\">");
htmlText.AppendLine ("<META NAME=\"GENERATOR\" CONTENT=\"Mono Text Editor\">");
htmlText.AppendLine ("</HEAD>");
htmlText.AppendLine ("<BODY>");
var selection = new TextSegment (0, doc.TextLength);
int startLineNumber = doc.OffsetToLineNumber (selection.Offset);
int endLineNumber = doc.OffsetToLineNumber (selection.EndOffset);
htmlText.AppendLine ("<FONT face = '" + options.Font.Family + "'>");
bool first = true;
if (mode is SyntaxMode) {
SyntaxModeService.StartUpdate (doc, (SyntaxMode)mode, selection.Offset, selection.EndOffset);
SyntaxModeService.WaitUpdate (doc);
}
foreach (var line in doc.GetLinesBetween (startLineNumber, endLineNumber)) {
if (!first) {
htmlText.AppendLine ("<BR>");
} else {
first = false;
}
if (mode == null) {
AppendHtmlText (htmlText, doc, options, System.Math.Max (selection.Offset, line.Offset), System.Math.Min (line.EndOffset, selection.EndOffset));
continue;
}
int curSpaces = 0;
foreach (var chunk in mode.GetChunks (style, line, line.Offset, line.Length)) {
int start = System.Math.Max (selection.Offset, chunk.Offset);
int end = System.Math.Min (chunk.EndOffset, selection.EndOffset);
var chunkStyle = style.GetChunkStyle (chunk);
if (start < end) {
htmlText.Append ("<SPAN style='");
if (chunkStyle.FontWeight != Xwt.Drawing.FontWeight.Normal)
htmlText.Append ("font-weight:" + ((int)chunkStyle.FontWeight) + ";");
if (chunkStyle.FontStyle != Xwt.Drawing.FontStyle.Normal)
htmlText.Append ("font-style:" + chunkStyle.FontStyle.ToString ().ToLower () + ";");
htmlText.Append ("color:" + ((HslColor)chunkStyle.Foreground).ToPangoString () + ";");
htmlText.Append ("'>");
AppendHtmlText (htmlText, doc, options, start, end);
htmlText.Append ("</SPAN>");
}
}
}
htmlText.AppendLine ("</FONT>");
htmlText.AppendLine ("</BODY></HTML>");
if (Platform.IsWindows)
return GenerateCFHtml (htmlText.ToString ());
return htmlText.ToString ();
}
示例4: UnixSocket
protected UnixSocket (Mono.Unix.UnixEndPoint localEndPoint)
: base (System.Net.Sockets.AddressFamily.Unix,
System.Net.Sockets.SocketType.Stream,
System.Net.Sockets.ProtocolType.IP,
localEndPoint)
{
}
示例5: ModuleMetadataInfo
public ModuleMetadataInfo(Module module, Mono.Cecil.ModuleDefinition cecilModule)
{
this.Module = module;
this.CecilModule = cecilModule;
typeRefLoader = new CecilLoader();
typeRefLoader.SetCurrentModule(cecilModule);
}
示例6: AddMember
public void AddMember(IUnresolvedEntity entity, Mono.Cecil.MemberReference cecilObject)
{
rwLock.EnterWriteLock();
try {
uint token = cecilObject.MetadataToken.ToUInt32();
metadataTokens[entity] = token;
var cecilMethod = cecilObject as Mono.Cecil.MethodDefinition;
if (cecilMethod != null) {
IUnresolvedMethod method = (IUnresolvedMethod)entity;
tokenToMethod[token] = method;
if (cecilMethod.HasBody) {
var locals = cecilMethod.Body.Variables;
if (locals.Count > 0) {
localVariableTypes[method] = locals.Select(v => typeRefLoader.ReadTypeReference(v.VariableType)).ToArray();
}
if (cecilMethod.RVA != 0) {
// The method was loaded from image - we can free the memory for the body
// because Cecil will re-initialize it on demand
cecilMethod.Body = null;
}
}
}
} finally {
rwLock.ExitWriteLock();
}
}
示例7: PickTypeWriter
public ITypeWriter PickTypeWriter(Mono.Cecil.TypeDefinition td, int indentCount, TypeCollection typeCollection, ConfigBase config)
{
if (td.IsEnum)
{
return new EnumWriter(td, indentCount, typeCollection, config);
}
if (td.IsInterface)
{
return new InterfaceWriter(td, indentCount, typeCollection, config);
}
if (td.IsClass)
{
if (td.BaseType.FullName == "System.MulticastDelegate" ||
td.BaseType.FullName == "System.Delegate")
{
return new DelegateWriter(td, indentCount, typeCollection, config);
}
return new ClassWriter(td, indentCount, typeCollection, config);
}
throw new NotImplementedException("Could not get a type to generate for:" + td.FullName);
}
示例8: Collect
public void Collect(Mono.Cecil.TypeDefinition td, TypeCollection typeCollection, ConfigBase config)
{
if (td.ShouldIgnoreType())
{
return;
}
// don't duplicate types
if (typeCollection.Contains(td.FullName))
{
return;
}
StringBuilder sb = new StringBuilder();
var indentCount = 0;
ITypeWriter typeWriter = typeSelector.PickTypeWriter(td, indentCount, typeCollection, config);
td.Interfaces.Each(item =>
{
var foundType = typeCollection.LookupType(item);
if (foundType == null)
{
//TODO: This reporting a missing type is too early in the process.
// typeNotFoundErrorHandler.Handle(item);
return;
}
var itemWriter = typeSelector.PickTypeWriter(foundType, indentCount, typeCollection, config);
typeCollection.Add(foundType.Namespace, foundType.Name, itemWriter);
});
typeCollection.Add(td.Namespace, td.Name, typeWriter);
}
示例9: ActivateEvent
public override void ActivateEvent (Mono.Debugger.Event ev)
{
if (Process.MainThread.IsStopped)
ev.Activate (Process.MainThread);
else
ThrowNotSupported ("Breakpoints can't be changed while the process is running.");
}
示例10: ProcessType
public override void ProcessType(Mono.Cecil.TypeDefinition type)
{
switch (type.Namespace) {
case "System.Runtime.Serialization.Json":
switch (type.Name) {
case "JsonFormatWriterInterpreter":
TypeDefinition jwd = GetType ("System.Runtime.Serialization", "System.Runtime.Serialization.Json.JsonWriterDelegator");
PreserveMethods (jwd);
break;
}
break;
case "System.Runtime.Serialization":
// MS referencesource use reflection to call the required methods to serialize each PrimitiveDataContract subclasses
// this goes thru XmlFormatGeneratorStatics and it's a better candidate (than PrimitiveDataContract) as there are other callers
switch (type.Name) {
case "XmlFormatGeneratorStatics":
TypeDefinition xwd = GetType ("System.Runtime.Serialization", "System.Runtime.Serialization.XmlWriterDelegator");
PreserveMethods (xwd);
TypeDefinition xoswc = GetType ("System.Runtime.Serialization", "System.Runtime.Serialization.XmlObjectSerializerWriteContext");
PreserveMethods (xoswc);
TypeDefinition xosrc = GetType ("System.Runtime.Serialization", "System.Runtime.Serialization.XmlObjectSerializerReadContext");
PreserveMethods (xosrc);
TypeDefinition xrd = GetType ("System.Runtime.Serialization", "System.Runtime.Serialization.XmlReaderDelegator");
PreserveMethods (xrd);
break;
case "CollectionDataContract":
// ensure the nested type, DictionaryEnumerator and GenericDictionaryEnumerator`2, can be created thru reflection
foreach (var nt in type.NestedTypes)
PreserveConstructors (nt);
break;
}
break;
}
}
示例11: CopyFrom
public override void CopyFrom (Mono.Debugging.Evaluation.EvaluationContext gctx)
{
base.CopyFrom (gctx);
MdbEvaluationContext ctx = (MdbEvaluationContext) gctx;
thread = ctx.thread;
frame = ctx.frame;
}
示例12: Process
protected async override Task Process(Mono.Net.HttpListenerContext context)
{
var writer = new StreamWriter(context.Response.OutputStream);
writer.Write(string.Empty);
writer.Flush();
context.Response.OutputStream.Close();
}
示例13: AssemblyData
/// <summary>
/// Initializes a new instance of the <see cref="AssemblyData"/> class.
/// </summary>
/// <param name="assembly">The assembly.</param>
private AssemblyData(Mono.Cecil.AssemblyDefinition assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
_assemblyDefinition = assembly;
Refresh();
}
示例14: EnableEvent
public override void EnableEvent (Mono.Debugger.Event ev, bool enable)
{
if (enable)
ev.Activate (Process.MainThread);
else
ev.Deactivate (Process.MainThread);
}
示例15: InitBlock
private void InitBlock(Mono.Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, AnonymousClassFieldCacheRangeFilter enclosingInstance)
{
this.fcsi = fcsi;
this.inclusiveLowerPoint = inclusiveLowerPoint;
this.inclusiveUpperPoint = inclusiveUpperPoint;
this.enclosingInstance = enclosingInstance;
}