private object InterpretCall(GenericScope genericScope, MethodBase method, MethodDefinition definition, object target, IReadOnlyList <object> arguments) { var context = new CilHandlerContext(genericScope, method, definition, target, arguments ?? Empty <object> .Array, _resolver, _invoker); var instruction = definition.Body.Instructions[0]; var returnType = (method as MethodInfo)?.ReturnType; while (instruction != null) { if (instruction.OpCode == OpCodes.Ret) { var result = (object)null; if (returnType != null && returnType != typeof(void)) { result = TypeSupport.Convert(context.Stack.Pop(), returnType); } if (context.Stack.Count > 0) { throw new Exception($"Unbalanced stack on return: {context.Stack.Count} extra items."); } return(result); } context.NextInstruction = instruction.Next; InterpretInstruction(instruction, context); instruction = context.NextInstruction; } throw new Exception($"Failed to reach a 'ret' instruction."); }
public void Handle(Instruction instruction, CilHandlerContext context) { var length = (int)Primitives.Convert(context.Stack.Pop(), typeof(int)); var arrayType = context.Resolver.Type(new ArrayType((TypeReference)instruction.Operand), context.GenericScope); context.Stack.Push(TypeSupport.CreateArray(arrayType, length)); }
public override bool IsAssignableFrom(Type c) { if (c == null) { return(false); } return(TypeSupport.IsAssignableFrom(this, c)); }
public override bool IsInstanceOfType(object o) { if (o == null) { return(false); } return(IsAssignableFrom(TypeSupport.GetTypeOf(o))); }
public ObjectTypeOverride(object @object, NonRuntimeType type) { if (@object is INonRuntimeObject) { throw new ArgumentException($"Attempted to override type twice ({@object})."); } if (TypeSupport.GetTypeOf(@object) == type) { throw new ArgumentException($"Attempted to override type for {@object} that already has type {type}."); } Type = Argument.NotNull(nameof(type), type); Object = @object; }
void setTypeSupport() { int i = Random.Range(0, 8); switch (i) { case 0: typeSupport = TypeSupport.hp; GetComponent <SpriteRenderer>().sprite = add_HP; break; case 1: typeSupport = TypeSupport.plane; GetComponent <SpriteRenderer>().sprite = add_Plane; break; case 2: typeSupport = TypeSupport.shield; GetComponent <SpriteRenderer>().sprite = shield; break; case 3: typeSupport = TypeSupport.up_bullet; GetComponent <SpriteRenderer>().sprite = lv_up_bullet; break; case 4: typeSupport = TypeSupport.homing; GetComponent <SpriteRenderer>().sprite = homing; break; case 5: typeSupport = TypeSupport.add_dame; GetComponent <SpriteRenderer>().sprite = add_Dame; break; case 6: typeSupport = TypeSupport.add_bullet_up; GetComponent <SpriteRenderer>().sprite = add_bullet_up; break; case 7: typeSupport = TypeSupport.add_bullet_left_right; GetComponent <SpriteRenderer>().sprite = add_bullet_left_right; break; } }
public virtual object Get(InterpretedField field) { if (_fieldValues == null) { _fieldValues = new Dictionary <string, object>(); } object value; if (!_fieldValues.TryGetValue(field.Name, out value)) { value = TypeSupport.GetDefaultValue(field.FieldType); _fieldValues.Add(field.Name, value); } return(value); }
private static MethodInfo FindTargetMethodByExplicitOverrides(MethodInfo method, Type targetType) { if (TypeSupport.IsRuntime(targetType)) { throw new NotImplementedException(); } foreach (var candidate in targetType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)) { var overrides = ((InterpretedMethod)candidate).GetExplicitOverrides(); if (overrides.Contains(method)) { return(candidate); } } return(null); }
public void setTypeSupport(TypeSupport type) { switch (type) { case TypeSupport.add_bullet_left_right: StopCoroutine(activeSupport(add_bullet_left_right)); StartCoroutine(activeSupport(add_bullet_left_right)); break; case TypeSupport.add_bullet_up: StopCoroutine(activeSupport(add_bullet_up)); StartCoroutine(activeSupport(add_bullet_up)); break; case TypeSupport.homing: StopCoroutine(activeSupport(homing)); StartCoroutine(activeSupport(homing)); break; case TypeSupport.hp: GetComponent <PlaneController>().add_HP(add_HP); break; case TypeSupport.plane: StopCoroutine(activeSupport(add_Plane)); StartCoroutine(activeSupport(add_Plane)); break; case TypeSupport.shield: active_shield(); StopCoroutine(activeSupport(shield)); StartCoroutine(activeSupport(shield)); break; case TypeSupport.add_dame: active_add_dame(); break; case TypeSupport.up_bullet: active_up_bullet(); break; } }
public Topic(string topicName, AdapterTopicQos requiredTopicQoS, TypeSupport clientTypeSupport) { if (clientTypeSupport == null) { throw new ArgumentNullException("clientTypeSupport"); } string domain = null; // just using the default partition, named after the topic name TopicName = topicName; TopicType = typeof(T).Name; // Create a DomainParticipantFactory and a DomainParticipant RegisterDomain(this, domain); ErrorHandler.CheckHandle(Participant, "DDS.DomainParticipantFactory.CreateParticipant"); // Register the required datatype. typeSupport = new TopicTypeSupport(clientTypeSupport); ReturnCode status = typeSupport.RegisterType(Participant, topicName); ErrorHandler.CheckStatus(status, "Topic.TopicMessageTypeSupport.RegisterType"); TopicQos topicQos = null; Participant.GetDefaultTopicQos(ref topicQos); ApplyQos(topicQos, requiredTopicQoS); TopicQos = topicQos; TopicMessageTopic = Participant.CreateTopic(topicName, topicName, topicQos); Participant.SetDefaultTopicQos(topicQos); if (TopicMessageTopic == null) { throw new Exception("QoS for topic " + TopicName + " FAILED!, please check QoS!"); } }
public TopicTypeSupport(TypeSupport clientTypeSupport) : base(typeof(T)) { this.clientTypeSupport = clientTypeSupport; }
public void When_creating_an_instance_from_TypeSupport_it_should_not_be_null() { Assert.IsNotNull(TypeSupport <t> .Create()); }
public void SetVariable(int index, object value) { var definition = _variableDefinitions[index]; _variablesMutable[index] = TypeSupport.Convert(value, Resolver.Type(definition.VariableType, GenericScope)); }
public static string Output(this FPdf document, string name, OutputDevice destination) { // Output PDF to some destination if (document.State < 3) { document.Close(); } if (destination == OutputDevice.Default) { if (string.IsNullOrEmpty(name)) { name = "doc.pdf"; destination = OutputDevice.StandardOutput; } else { destination = OutputDevice.SaveToFile; } } switch (destination) { case OutputDevice.StandardOutput: HttpContext.Current.Response.AppendHeader("Content-Type: application/pdf", ""); HttpContext.Current.Response.AppendHeader("Content-Disposition: inline; filename=\"" + name + "\"", ""); HttpContext.Current.Response.AppendHeader("Cache-Control: private, max-age=0, must-revalidate", ""); HttpContext.Current.Response.AppendHeader("Pragma: public", ""); HttpContext.Current.Response.Write(document.Buffer); break; case OutputDevice.Download: // Download file HttpContext.Current.Response.AppendHeader("Content-Type: application/x-download", ""); HttpContext.Current.Response.AppendHeader( "Content-Disposition: attachment; filename=\"" + name + "\"", ""); HttpContext.Current.Response.AppendHeader("Cache-Control: private, max-age=0, must-revalidate", ""); HttpContext.Current.Response.AppendHeader("Pragma: public", ""); HttpContext.Current.Response.Write(document.Buffer); break; case OutputDevice.SaveToFile: // Save to local file FileStream f = FileSystemSupport.FileOpen(name, "wb"); if (!TypeSupport.ToBoolean(f)) { throw new InvalidOperationException("Unable to create output file: " + name); } var writer = new StreamWriter(f, FPdf.PrivateEncoding); writer.Write(document.Buffer); writer.Close(); break; case OutputDevice.ReturnAsString: return(document.Buffer); default: throw new InvalidOperationException("Incorrect output destination: " + destination); break; } return(string.Empty); }
private ILType CreateTypeInternal(ITypeSymbol symbol) { var pointerSymbol = symbol as PointerSymbol; if (pointerSymbol != null) { var element = GetTypeInternal(pointerSymbol.Element); if (element == null) { return(null); } var type = element.CreatePointerType(); return(CacheTypeInternal(type)); } var refSymbol = symbol as RefSymbol; if (refSymbol != null) { var element = GetTypeInternal(refSymbol.Element); if (element == null) { return(null); } var type = element.CreateByRefType(); return(CacheTypeInternal(type)); } var arraySymbol = symbol as ArraySymbol; if (arraySymbol != null) { var element = GetTypeInternal(arraySymbol.Element); if (element == null) { return(null); } var type = element.CreateArrayType(arraySymbol.Rank); return(CacheTypeInternal(type)); } var genericSymbol = symbol as GenericSymbol; if (genericSymbol != null) { var elementType = GetTypeInternal(genericSymbol.Element); if (elementType == null) { return(null); } var genericArugments = new FastList <ILType>(genericSymbol.GenericParameters.Count); foreach (var generic in genericSymbol.GenericParameters) { var genericType = GetTypeInternal(generic); if (genericType == null) { return(null); } genericArugments.Add(genericType); } var type = elementType.CreateGenericType(genericArugments); return(CacheTypeInternal(type)); } var nameSymbol = symbol as NameSymbol; if (nameSymbol != null) { var clr = TypeSupport.GetType(nameSymbol.AssemblyQualifiedName); if (clr == null) { return(null); } var type = CLRType.Create(clr, this); return(CacheTypeInternal(type)); } return(null); }