public void DataMap_FullCycle_UnionMap() { NestedTypes n; Dictionary <string, object> data = new Dictionary <string, object>() { { "unionMap", new Dictionary <string, object>() { { "one", new Dictionary <string, object>() { { "int", expectedInt } } } } } }; n = new NestedTypes(data); Assert.IsTrue(n.hasUnionMap); Assert.AreEqual(NestedTypes.UnionMap.Member.Int, n.unionMap["one"].member); Assert.AreEqual(expectedInt, n.unionMap["one"].asInt); NestedTypes reclaimed = new NestedTypes(n.Data()); Assert.IsTrue(reclaimed.hasUnionMap); Assert.AreEqual(NestedTypes.UnionMap.Member.Int, reclaimed.unionMap["one"].member); Assert.AreEqual(expectedInt, reclaimed.unionMap["one"].asInt); }
public void DataMap_FullCycle_UnionArray() { NestedTypes n; Dictionary <string, object> data = new Dictionary <string, object>() { { "unionArray", new List <object>() { new Dictionary <string, object>() { { "bytes", "\u0000\u0001\u0002\u0003" } } } } }; n = new NestedTypes(data); Assert.IsTrue(n.hasUnionArray); Assert.AreEqual(NestedTypes.UnionArray.Member.Bytes, n.unionArray[0].member); CollectionAssert.AreEqual(expectedBytes, n.unionArray[0].asBytes.GetBytes()); NestedTypes reclaimed = new NestedTypes(n.Data()); Assert.IsTrue(reclaimed.hasUnionArray); Assert.AreEqual(NestedTypes.UnionArray.Member.Bytes, reclaimed.unionArray[0].member); CollectionAssert.AreEqual(expectedBytes, reclaimed.unionArray[0].asBytes.GetBytes()); }
public virtual void AddNestedType(GenBase gen) { foreach (var nest in NestedTypes) { if (gen.JavaName.StartsWith(nest.JavaName + ".")) { nest.AddNestedType(gen); return; } } var removes = new List <GenBase> (); foreach (var nest in NestedTypes) { if (nest.JavaName.StartsWith(gen.JavaName + ".")) { gen.AddNestedType(nest); removes.Add(nest); } } foreach (var rmv in removes) { NestedTypes.Remove(rmv); } NestedTypes.Add(gen); }
protected internal override void OnDeleted() { Methods.Clear(); Fields.Clear(); Properties.Clear(); Events.Clear(); NestedTypes.Clear(); _module.TypeTable.Remove(_rid); }
void AddNestedTypes(InterfaceGen iface, CodeGenerationOptions opt, CodeGeneratorContext context, GenerationInfo genInfo) { // Generate nested types for supported nested types. This is a new addition in C#8. // Prior to this, types nested in an interface had to be generated as sibling types. // The "Unnest" property is used to support backwards compatibility with pre-C#8 bindings. foreach (var nest in iface.NestedTypes.Where(t => !t.Unnest)) { NestedTypes.Add(SourceWriterExtensions.BuildManagedTypeModel(nest, opt, context, genInfo)); } }
public TypeData GetNestedTypeData(TypeDeclarationSyntax node, SemanticModel semanticModel, bool create = false) { if (NestedTypes.TryGetValue(node, out TypeData typeData)) { return(typeData); } var symbol = semanticModel.GetDeclaredSymbol(node); return(!create ? null : NestedTypes.GetOrAdd(node, syntax => new TypeData(NamespaceData, symbol, node, this))); }
void AddNestedTypes(ClassGen klass, CodeGenerationOptions opt, CodeGeneratorContext context, GenerationInfo genInfo) { foreach (var nest in klass.NestedTypes) { if (klass.BaseGen?.ContainsNestedType(nest) == true && nest is ClassGen c) { c.NeedsNew = true; } NestedTypes.Add(SourceWriterExtensions.BuildManagedTypeModel(nest, opt, context, genInfo)); } }
public override int GetHashCode() { unchecked { return((TypeHierarchy.GetHashCode() * 397) ^ NestedTypes.GetSetHashCode() ^ Delegates.GetSetHashCode() ^ EventHierarchies.GetSetHashCode() ^ Fields.GetSetHashCode() ^ MethodHierarchies.GetSetHashCode() ^ PropertyHierarchies.GetSetHashCode()); } }
public virtual void ResolveBaseMembers() { var klass = BaseTypeReference?.ReferencedType as JavaClassModel; foreach (var method in Methods) { method.FindBaseMethod(klass); } foreach (var nested in NestedTypes.OfType <JavaClassModel> ()) { nested.ResolveBaseMembers(); } }
public void CopyTo(TypeDeclaration copy) { copy._name = _name; copy._namespace = _namespace; copy._flags = _flags; copy._packingSize = PackingSize; copy._classSize = ClassSize; copy._baseType = BaseType; Interfaces.CopyTo(copy.Interfaces); GenericParameters.CopyTo(copy.GenericParameters); Methods.CopyTo(copy.Methods); Fields.CopyTo(copy.Fields); Properties.CopyTo(copy.Properties); Events.CopyTo(copy.Events); CustomAttributes.CopyTo(copy.CustomAttributes); SecurityAttributes.CopyTo(copy.SecurityAttributes); NestedTypes.CopyTo(copy.NestedTypes); }
public void SetValue() { if (GenericArguments == null) { GenericArgumentsL = null; } else { GenericArgumentsL = GenericArguments.ToList(); foreach (var i in GenericArgumentsL) { i.SetValue(); } } ImplementedInterfacesL = ImplementedInterfaces.ToList(); foreach (var i in ImplementedInterfacesL) { i.SetValue(); } NestedTypesL = NestedTypes.ToList(); foreach (var i in NestedTypesL) { i.SetValue(); } PropertiesL = Properties.ToList(); MethodsL = Methods.ToList(); foreach (var i in MethodsL) { i.SetValue(); } ConstructorsL = Constructors.ToList(); foreach (var i in ConstructorsL) { i.SetValue(); } }
public void DataMap_FullCycle_EnumMap() { NestedTypes n; Dictionary <string, object> data = new Dictionary <string, object>() { { "enumMap", new Dictionary <string, object>() { { "one", "SYMBOL_1" } } } }; n = new NestedTypes(data); Assert.IsTrue(n.hasEnumMap); Assert.AreEqual(expectedEnum, n.enumMap["one"].symbol); NestedTypes reclaimed = new NestedTypes(n.Data()); Assert.IsTrue(reclaimed.hasEnumMap); Assert.AreEqual(expectedEnum, reclaimed.enumMap["one"].symbol); }
public void DataMap_FullCycle_BytesMap() { NestedTypes n; Dictionary <string, object> data = new Dictionary <string, object>() { { "bytesMap", new Dictionary <string, object>() { { "one", "\u0000\u0001\u0002\u0003" } } } }; n = new NestedTypes(data); Assert.IsTrue(n.hasBytesMap); CollectionAssert.AreEqual(expectedBytes, n.bytesMap["one"].GetBytes()); NestedTypes reclaimed = new NestedTypes(n.Data()); Assert.IsTrue(reclaimed.hasBytesMap); CollectionAssert.AreEqual(expectedBytes, reclaimed.bytesMap["one"].GetBytes()); }
public MyNestedTypeInfo(TypeDefinition typeDefinition, MyClassInfo declaringType) : base() { Debug.Assert(Utils.IsTypeNested(typeDefinition), "Impossible! Given type is not a nested type."); string[] readableForms = Tools.GetHumanReadableForms(typeDefinition); this.name = readableForms[0]; int indexOfLastSlash = this.name.LastIndexOf('/'); Debug.Assert(indexOfLastSlash != -1 && indexOfLastSlash + 1 < this.Name.Length, "Impossible! This is a nested type."); this.name = this.name.Substring(indexOfLastSlash + 1); this.attributes = MyClassInfo.GetMyClassAttributes(typeDefinition); this.declaringType = declaringType; this.metaType = GetMetaType(typeDefinition); if (metaType == NestedTypes.Unknown) { Logger.Warning("Unrecognized meta type of '{0}'", typeDefinition.FullName); } }
private static string NestedTypesToString(NestedTypes metaType) { switch (metaType) { case NestedTypes.Class: { return("class"); } case NestedTypes.Delegate: { return("delegate"); } case NestedTypes.Enumeration: { return("enum"); } case NestedTypes.Interface: { return("interface"); } case NestedTypes.Structure: { return("struct"); } default: { Debug.Assert(false, "Impossible! Unrecognized nested type."); break; } } return(String.Empty); }
public string GetInfo() { var builder = new StringBuilder(); builder.AppendLine("Type Summary"); builder.Append(Environment.NewLine); builder.AppendLine(string.Format("Name: {0}", Name)); builder.AppendLine(string.Format("TypeCode: {0}", TypeDefinition.KnownTypeCode)); builder.AppendLine(string.Format("Methods: {0}", Methods.Count())); builder.AppendLine(string.Format("Fields: {0}", Fields.Count())); builder.AppendLine(string.Format("Nested types: {0}", NestedTypes.Count())); builder.AppendLine(string.Format("Base types: {0}", BaseTypes.Count())); // more to come builder.Append(Environment.NewLine); // if (TypeDefinition.IsAbstract) // builder.AppendLine("IsAbstract"); // if (TypeDefinition. // if (IsInternal) // builder.AppendLine("IsInternal"); // if (IsNestedPrivate) // builder.AppendLine("IsNestedPrivate"); // if (IsNestedProtected) // builder.AppendLine("IsNestedProtected"); // if (IsNestedPublic) // builder.AppendLine("IsNestedPublic"); // if (IsPublic) // builder.AppendLine("IsPublic"); // if (IsSealed) // builder.AppendLine("IsSealed"); // if (IsStruct) // builder.AppendLine("IsStruct"); return(builder.ToString()); }
public NestedTypes(KaitaiStream p__io, KaitaiStruct p__parent = null, NestedTypes p__root = null) : base(p__io) { m_parent = p__parent; m_root = p__root ?? this; _read(); }
private static string NestedTypesToString(NestedTypes metaType) { switch (metaType) { case NestedTypes.Class: { return "class"; } case NestedTypes.Delegate: { return "delegate"; } case NestedTypes.Enumeration: { return "enum"; } case NestedTypes.Interface: { return "interface"; } case NestedTypes.Structure: { return "struct"; } default: { Debug.Assert(false, "Impossible! Unrecognized nested type."); break; } } return String.Empty; }
public BoundClass(ClassGen klass, CodeGenerationOptions opt, CodeGeneratorContext context, GenerationInfo generationInfo) { context.ContextTypes.Push(klass); context.ContextGeneratedMethods = new List <Method> (); generationInfo.TypeRegistrations.Add(new KeyValuePair <string, string> (klass.RawJniName, klass.AssemblyQualifiedName)); var is_enum = klass.base_symbol != null && klass.base_symbol.FullName == "Java.Lang.Enum"; if (is_enum) { generationInfo.Enums.Add(klass.RawJniName.Replace('/', '.') + ":" + klass.Namespace + ":" + klass.JavaSimpleName); } this.opt = opt; Name = klass.Name; SetVisibility(klass.Visibility); IsShadow = klass.NeedsNew; IsAbstract = klass.IsAbstract; IsSealed = klass.IsFinal; IsPartial = true; UsePriorityOrder = true; AddImplementedInterfaces(klass); Comments.Add($"// Metadata.xml XPath class reference: path=\"{klass.MetadataXPathReference}\""); if (klass.IsDeprecated) { Attributes.Add(new ObsoleteAttr(klass.DeprecatedComment) { WriteAttributeSuffix = true }); } Attributes.Add(new RegisterAttr(klass.RawJniName, null, null, true, klass.AdditionalAttributeString()) { UseGlobal = true, UseShortForm = true }); if (klass.TypeParameters != null && klass.TypeParameters.Any()) { Attributes.Add(new CustomAttr(klass.TypeParameters.ToGeneratedAttributeString())); } // Figure out our base class string obj_type = null; if (klass.base_symbol != null) { obj_type = klass.base_symbol is GenericSymbol gs && gs.IsConcrete ? gs.GetGenericType(null) : opt.GetOutputName(klass.base_symbol.FullName); } if (klass.InheritsObject && obj_type != null) { Inherits = obj_type; } // Handle fields var seen = new HashSet <string> (); SourceWriterExtensions.AddFields(this, klass, klass.Fields, seen, opt, context); var ic = new InterfaceConstsClass(klass, seen, opt, context); if (ic.ShouldGenerate) { NestedTypes.Add(ic); } // Sibling classes if (!klass.AssemblyQualifiedName.Contains('/')) { foreach (InterfaceExtensionInfo nestedIface in klass.GetNestedInterfaceTypes()) { if (nestedIface.Type.Methods.Any(m => m.CanHaveStringOverload) || nestedIface.Type.Methods.Any(m => m.Asyncify)) { sibling_types.Add(new InterfaceExtensionsClass(nestedIface.Type, nestedIface.DeclaringType, opt)); } } } if (klass.IsAbstract) { sibling_types.Add(new ClassInvokerClass(klass, opt)); } AddNestedTypes(klass, opt, context, generationInfo); AddBindingInfrastructure(klass); AddConstructors(klass, opt, context); AddProperties(klass, opt); AddMethods(klass, opt, context); AddAbstractMembers(klass, opt, context); AddExplicitGenericInterfaceMembers(klass, opt); AddCharSequenceEnumerator(klass); context.ContextGeneratedMethods.Clear(); context.ContextTypes.Pop(); }
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration) { if (CurrentType != null) { NestedTypes = NestedTypes ?? new List <Tuple <TypeDeclaration, ITypeInfo> >(); NestedTypes.Add(new Tuple <TypeDeclaration, ITypeInfo>(typeDeclaration, CurrentType)); return; } ValidateNamespace(typeDeclaration); var rr = Resolver.ResolveNode(typeDeclaration); var fullName = rr.Type.ReflectionName; var partialType = Types.FirstOrDefault(t => t.Key == fullName); var add = true; var ignored = IgnoredTypes.Contains(fullName); var external = HasExternal(typeDeclaration); if (!external) { var resolveResult = Resolver.ResolveNode(typeDeclaration); if (resolveResult != null && resolveResult.Type != null) { var def = resolveResult.Type.GetDefinition(); external = def != null && (Validator.IsTypeFromH5Core(def.FullName) || def.ParentAssembly.AssemblyAttributes.Any(a => a.AttributeType.FullName == "H5.ExternalAttribute")); } } if ((external || ignored || IsNonScriptable(typeDeclaration)) && !IsObjectLiteral(typeDeclaration)) { if (partialType != null) { Types.Remove(partialType); } if (!ignored) { IgnoredTypes.Add(fullName); } return; } if (partialType == null) { ITypeInfo parentTypeInfo = null; var parentTypeDeclaration = typeDeclaration.GetParent <TypeDeclaration>(); if (parentTypeDeclaration != null) { var rr1 = Resolver.ResolveNode(parentTypeDeclaration); var parentName = rr1.Type.ReflectionName; parentTypeInfo = Types.FirstOrDefault(t => t.Key == parentName); } CurrentType = new TypeInfo() { Key = rr.Type.ReflectionName, TypeDeclaration = typeDeclaration, ParentType = parentTypeInfo, Name = typeDeclaration.Name, ClassType = typeDeclaration.ClassType, Namespace = Namespace, IsEnum = typeDeclaration.ClassType == ClassType.Enum, IsStatic = typeDeclaration.ClassType == ClassType.Enum || typeDeclaration.HasModifier(Modifiers.Static), IsObjectLiteral = IsObjectLiteral(typeDeclaration), Type = rr.Type }; } else { CurrentType = partialType; CurrentType.PartialTypeDeclarations.Add(typeDeclaration); add = false; } if (typeDeclaration.ClassType != ClassType.Interface) { typeDeclaration.AcceptChildren(this); } else { typeDeclaration.AcceptChildren(this); } if (add) { Types.Add(CurrentType); } if (typeDeclaration.ClassType != ClassType.Interface) { AddMissingAliases(typeDeclaration); } CurrentType = null; while (NestedTypes != null && NestedTypes.Count > 0) { var types = NestedTypes; NestedTypes = null; foreach (var nestedType in types) { VisitTypeDeclaration(nestedType.Item1); } } }
protected virtual void WriteNestedTypes() { if (NestedTypes != null && NestedTypes.Any()) { if (!Emitter.IsNewLine) { WriteNewLine(); } var typeDef = Emitter.GetTypeDefinition(); string name = Emitter.Validator.GetCustomTypeName(typeDef, Emitter, true); if (name.IsEmpty()) { name = H5Types.ToJsName(TypeInfo.Type, Emitter, true, true, nomodule: true); } Write("module "); Write(name); WriteSpace(); BeginBlock(); var last = NestedTypes.LastOrDefault(); foreach (var nestedType in NestedTypes) { Emitter.Translator.EmitNode = nestedType.TypeDeclaration; if (nestedType.IsObjectLiteral) { continue; } ITypeInfo typeInfo; if (Emitter.TypeInfoDefinitions.ContainsKey(nestedType.Key)) { typeInfo = Emitter.TypeInfoDefinitions[nestedType.Key]; nestedType.Module = typeInfo.Module; nestedType.FileName = typeInfo.FileName; nestedType.Dependencies = typeInfo.Dependencies; typeInfo = nestedType; } else { typeInfo = nestedType; } Emitter.TypeInfo = nestedType; var nestedTypes = AllTypes.Where(t => t.ParentType == nestedType); new ClassBlock(Emitter, Emitter.TypeInfo, nestedTypes, AllTypes, Namespace).Emit(); WriteNewLine(); if (nestedType != last) { WriteNewLine(); } } EndBlock(); } }
private static void Send <TGump>( bool local, Mobile m, string html, bool autoClose = true, double delay = 1.0, double pause = 3.0, Color?color = null, Action <TGump> beforeSend = null, Action <TGump> afterSend = null, AccessLevel level = AccessLevel.Player) where TGump : NotifyGump { if (!m.IsOnline() || m.AccessLevel < level) { return; } var t = typeof(TGump); if (t.IsAbstract || m.HasGump(t)) { Type[] subs; if (!NestedTypes.TryGetValue(t, out subs) || subs == null) { NestedTypes[t] = subs = t.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic) // .Where(st => st.IsChildOf <NotifyGump>()) .ToArray(); } var sub = subs.FirstOrDefault(st => !m.HasGump(st)); if (sub != null) { t = sub; } } if (IsIgnored(t, m)) { return; } if (!t.IsAbstract && !IsTextOnly(t, m)) { if (!autoClose && IsAutoClose(t, m)) { autoClose = true; } if (delay > 0.0 && !IsAnimated(t, m)) { delay = 0.0; } if (delay > 0.0) { AlterTime(t, m, ref delay); } if (pause > 3.0) { AlterTime(t, m, ref pause); pause = Math.Max(3.0, pause); } var ng = t.CreateInstanceSafe <TGump>(m, html); if (ng != null) { ng.AutoClose = autoClose; ng.AnimDuration = TimeSpan.FromSeconds(Math.Max(0, delay)); ng.PauseDuration = TimeSpan.FromSeconds(Math.Max(0, pause)); ng.HtmlColor = color ?? Color.White; if (ng.IsDisposed) { return; } if (local && OnLocalMessage != null) { OnLocalMessage(ng); } else if (!local && OnGlobalMessage != null) { OnGlobalMessage(ng); } if (beforeSend != null) { beforeSend(ng); } if (ng.IsDisposed) { return; } ng.Send(); if (ng.IsDisposed) { return; } if (afterSend != null) { afterSend(ng); } return; } } html = html.StripHtmlBreaks(true); html = html.Replace("\n", " "); html = html.StripHtml(false); html = html.StripTabs(); html = html.StripCRLF(); m.SendMessage(html); }
protected NestedStackLayout(DomainGroup dgPar, NestedStackLayout par, string n, NestedTypes type) { dgParent = dgPar; parent = par; this.type = type; subViews = new ObservableCollection <View>(); //Spring2018 Team: special casing for the top-level (displays patient name and add button) if (type == NestedTypes.DomainGroup) { AbsoluteLayout topper = new AbsoluteLayout(); topper.WidthRequest = Application.Current.MainPage.Width; topper.HeightRequest = 25; name.Text = n; name.HorizontalTextAlignment = TextAlignment.Center; Button add = new Button(); add.Text = "Add"; add.Margin = new Thickness(0, 0, 10, 0); add.Clicked += dgParent.AddButtonPressed; AbsoluteLayout.SetLayoutBounds(name, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); AbsoluteLayout.SetLayoutFlags(name, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(add, new Rectangle(1, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); AbsoluteLayout.SetLayoutFlags(add, AbsoluteLayoutFlags.PositionProportional); topper.Children.Add(name); topper.Children.Add(add); Children.Add(topper); isChildVisible = true; } else { StackLayout nameStack = new StackLayout(); nameStack.Margin = new Thickness(0, 0, 0, 0); name.Text = n; name.HorizontalTextAlignment = TextAlignment.Start; name.Margin = new Thickness(20, 0, 20, 0); nameStack.Orientation = StackOrientation.Horizontal; nameStack.Children.Add(name); nameStack.Children.Add(complete); complete.Margin = new Thickness(20, 0, 20, 0); complete.HorizontalOptions = LayoutOptions.EndAndExpand; complete.IsVisible = false; description.Margin = new Thickness(20, 0, 20, 0); //Fall2018 Team: I think this is where user taps "add" to add a new item to the list name.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { ToggleChildVisibility(); }) }); name.HorizontalOptions = LayoutOptions.Start; StackLayout buttonLayout = new StackLayout(); buttonLayout.Orientation = StackOrientation.Horizontal; buttonLayout.HeightRequest = 20; AddButtons(buttonLayout); isChildVisible = false; Children.Add(nameStack); AddSubView(buttonLayout); AddSubView(description); Children.Add(divisionLine); SetDescription("I am a description for " + n + "."); } dgParent.RegisterStack(type, this); }
public override void Build() { StateMachineBuilder = AsyncStateMachineTypeBuilder.Create(TypeBuilder, FluentActionDefinition, Logger); NestedTypes.Add(StateMachineBuilder.Type); var usingsForMethodParameters = FluentActionDefinition.Handlers .SelectMany(usingHandler => usingHandler.Usings) .Where(@using => @using.IsMethodParameter) .Distinct() .ToArray(); var methodParameterIndices = usingsForMethodParameters .Select((@using, index) => new { Using = @using, Index = index }) .ToDictionary( indexedUsing => indexedUsing.Using.GetHashCode(), indexedUsing => indexedUsing.Index + 1 // 1-based index ); var methodParameterTypes = usingsForMethodParameters .Select(@using => @using.Type) .ToArray(); var returnType = FluentActionDefinition.Handlers.Last().ReturnType; var returnTypeTask = typeof(Task <>).MakeGenericType(returnType); MethodBuilder.SetReturnType(returnTypeTask); MethodBuilder.SetParameters(methodParameterTypes); SetHttpMethodAttribute(FluentActionDefinition.HttpMethod); SetRouteAttribute(FluentActionDefinition.RouteTemplate); foreach (var customAttribute in FluentActionDefinition.CustomAttributes) { SetCustomAttribute(customAttribute); } foreach (var usingDefinition in usingsForMethodParameters) { var methodParameterIndex = methodParameterIndices[usingDefinition.GetHashCode()]; usingDefinition.DefineMethodParameter(MethodBuilder, FluentActionDefinition, usingDefinition, methodParameterIndex); } var dictionaryField = typeof(FluentActionDelegates) .GetField("All"); var dictionaryGetMethod = typeof(ConcurrentDictionary <,>) .MakeGenericType(typeof(string), typeof(Delegate)) .GetMethod("get_Item"); var ilGenerator = MethodBuilder.GetILGenerator(); // === Generate IL for action method ========================== var asyncTaskMethodBuilderType = typeof(AsyncTaskMethodBuilder <>).MakeGenericType(returnType); // Declare local variables var stateMachineLocalVariable = ilGenerator.DeclareLocal(StateMachineBuilder.Type); // Create a StateMachine and store it locally ilGenerator.Emit(OpCodes.Newobj, StateMachineBuilder.Constructor); ilGenerator.Emit(OpCodes.Stloc, stateMachineLocalVariable); // Store reference to parent in field StateMachine.Parent ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Stfld, StateMachineBuilder.ParentField); // Create an AsyncTaskMethodBuilder and store it in field StateMachine.AsyncTaskMethodBuilder ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Call, asyncTaskMethodBuilderType.GetMethod("Create")); ilGenerator.Emit(OpCodes.Stfld, StateMachineBuilder.AsyncTaskMethodBuilderField); // Set field StateMachine.State = 0 ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldc_I4_0); ilGenerator.Emit(OpCodes.Stfld, StateMachineBuilder.StateField); // Store parameters to fields in StateMachine foreach (var usingDefinition in usingsForMethodParameters) { var methodParameterIndex = methodParameterIndices[usingDefinition.GetHashCode()]; var methodParameterField = StateMachineBuilder.MethodParameterFields[methodParameterIndex - 1]; ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldarg, methodParameterIndex); ilGenerator.Emit(OpCodes.Stfld, methodParameterField); } var handlers = StateMachineBuilder.States .SelectMany(state => state.Handlers) .Where(handler => handler.Definition.Type == FluentActionHandlerType.Func || handler.Definition.Type == FluentActionHandlerType.Action); // Store delegates to fields in StateMachine foreach (var handler in handlers) { var delegateKey = FluentActionDelegates.Add(handler.Definition.Delegate); // Push Delegate ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldsfld, FluentActionDelegates.FieldInfo); ilGenerator.Emit(OpCodes.Ldstr, delegateKey); ilGenerator.Emit(OpCodes.Callvirt, FluentActionDelegates.MethodInfo); // Store in field StateMachine.StateXHandlerYDelegate ilGenerator.Emit(OpCodes.Stfld, handler.DelegateField); } // Start the AsyncTaskMethodBuilder ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldflda, StateMachineBuilder.AsyncTaskMethodBuilderField); ilGenerator.Emit(OpCodes.Ldloca, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Call, asyncTaskMethodBuilderType.GetMethod("Start").MakeGenericMethod(StateMachineBuilder.Type)); // Return the Task of AsyncTaskMethodBuilder ilGenerator.Emit(OpCodes.Ldloc, stateMachineLocalVariable); ilGenerator.Emit(OpCodes.Ldflda, StateMachineBuilder.AsyncTaskMethodBuilderField); ilGenerator.Emit(OpCodes.Call, asyncTaskMethodBuilderType.GetProperty("Task").GetGetMethod()); ilGenerator.Emit(OpCodes.Ret); }
public static NestedStackLayout CreateLayout(DomainGroup dg, NestedStackLayout par, string n, NestedTypes t, NestedTaskLayout.TaskType tt = NestedTaskLayout.TaskType.PassFail) { if (t == NestedTypes.Task) { NestedTaskLayout res = new NestedTaskLayout(dg, par, n, tt); res.EditTask(); return(res); } else { return(new NestedStackLayout(dg, par, n, t)); } }
protected void AddNestedType(TypeDeclaration type) { NestedTypes.Add(type); }
public static void Send <TGump>( Mobile m, string html, bool autoClose = true, double delay = 1.0, double pause = 3.0, Color?color = null, Action <TGump> beforeSend = null, Action <TGump> afterSend = null, AccessLevel level = AccessLevel.Player) where TGump : NotifyGump { if (!m.IsOnline() || m.AccessLevel < level) { return; } var t = typeof(TGump); if (t.IsAbstract || m.HasGump(t)) { Type[] subs; if (!NestedTypes.TryGetValue(t, out subs) || subs == null) { NestedTypes[t] = subs = t.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic) // .Where(st => st.IsChildOf <NotifyGump>()).ToArray(); } var sub = subs.FirstOrDefault(st => !m.HasGump(st)); if (sub != null) { t = sub; } } if (!t.IsAbstract) { if (IsIgnored(t.IsNested ? t.DeclaringType : t, m)) { return; } if (!IsAnimated(t.IsNested ? t.DeclaringType : t, m)) { delay = 0.0; } var ng = t.CreateInstanceSafe <TGump>(m, html); if (ng != null) { ng.AutoClose = autoClose; ng.AnimDuration = TimeSpan.FromSeconds(Math.Max(0, delay)); ng.PauseDuration = TimeSpan.FromSeconds(Math.Max(0, pause)); ng.HtmlColor = color ?? Color.White; if (beforeSend != null) { beforeSend(ng); } if (ng.IsDisposed) { return; } ng.Send(); if (afterSend != null) { afterSend(ng); } return; } } foreach (var str in html.Split(new[] { "\n", "<br>", "<BR>" }, StringSplitOptions.RemoveEmptyEntries) .Select(s => Regex.Replace(s, @"<[^>]*>", String.Empty))) { m.SendMessage(str); } }
public SubtypeC(KaitaiStream p__io, NestedTypes.SubtypeA p__parent = null, NestedTypes p__root = null) : base(p__io) { m_parent = p__parent; m_root = p__root; _read(); }
//Fall2018 Team: to do item? //Spring2018 Team: we need to have a way to load task information, but data files should be specified before that public static NestedStackLayout LoadLayout(DomainGroup dg, NestedStackLayout par, string n, NestedTypes t, NestedTaskLayout.TaskType tt = NestedTaskLayout.TaskType.PassFail) { if (t == NestedTypes.Task) { return(new NestedTaskLayout(dg, par, n, tt)); } else { return(new NestedStackLayout(dg, par, n, t)); } }