public override void Initial() { ParentTypes = _termStyleRepository.GetAssignmentTypesWithInsertRules(); Types = _termStyleRepository.GetEventTypes(); QueryType = Types.FirstOrDefault(); QueryParentType = ParentTypes.FirstOrDefault(); }
public void AddItem(MultipleHierarchyCardEditorInfo multipleHierarchyCardEditorInfo) { Console.WriteLine($"Add parent type {multipleHierarchyCardEditorInfo.Label}"); ParentTypes.Add(new MultipleHierarchyCardEditorInfo { Label = multipleHierarchyCardEditorInfo.Label }); }
/// <summary> /// Sets up the parent types. /// </summary> private void SetupParentTypes() { Logger.Information("Setting up parent type discovery for {Name:l}", Source.Name); for (var i = 0; i < ConcreteTypes.Length; i++) { var ConcreteType = ConcreteTypes[i]; var Types = TypeGraphs[ConcreteType]?.ToList(); if (Types is null) { continue; } ParentTypes.Add(ConcreteType, Types); } }
public TypeTracker(ISchema schema) { EnterOperationDefinition = node => { var root = node.Operation switch { OperationType.Query => schema.Query, OperationType.Mutation => schema.Mutation, OperationType.Subscription => schema.Subscription, _ => throw new ArgumentOutOfRangeException() }; Types.Push(root); }; LeaveOperationDefinition = node => { Types.TryPop(out _); }; EnterSelectionSet = node => { ParentTypes.Push(CurrentType); }; LeaveSelectionSet = node => { ParentTypes.TryPop(out _); }; EnterFieldSelection = node => { if (ParentType is not null) { var fieldDefinition = schema.GetField(ParentType.Name, node.Name); FieldDefinitions.Push(fieldDefinition ?? null); if (fieldDefinition?.Type is not null) { var fieldTypeDefinition = Ast.UnwrapAndResolveType(schema, fieldDefinition.Type); if (fieldTypeDefinition is not null && TypeIs.IsOutputType(fieldTypeDefinition)) { Types.Push(fieldTypeDefinition); } else { Types.Push(null); } } else { Types.Push(null); } }
/// <summary> /// Gets the parent mappings. /// </summary> /// <param name="objectType">Type of the object.</param> /// <returns>The IMapping list associated with the object type.</returns> public IEnumerable <IMapping> GetParentMapping(Type objectType) { if (objectType is null) { yield break; } if (objectType.Namespace.StartsWith("AspectusGeneratedTypes", StringComparison.Ordinal)) { objectType = objectType.BaseType; } if (!ParentTypes.ContainsKey(objectType)) { yield break; } foreach (var Item in ParentTypes[objectType]) { yield return(Mappings[Item]); } }
/// <summary> /// Checks if the current type is a subtype of another object type /// </summary> /// <param name="parentType">The parent type to check for</param> /// <returns></returns> public bool IsSubtypeOf(ObjectType parentType) { return(ParentTypes != null && (ParentTypes.Contains(parentType) || ParentTypes.Any(t => t.IsSubtypeOf(parentType)))); }
internal static BuildingInformationCollection ImportBuilding(string filePath) { /* BuildingInformation is what we're going to return when the building has been sucessfully imported. * Because of how the import mechanisms work, BuildingInformation has to be instantiated and visible for the entire class.*/ if (BuildingInformation == null) { SetupImport(); } using (XmlReader reader = XmlReader.Create(File.OpenRead(filePath))) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Whitespace || reader.Value == "\n") { continue; } if (reader.HasAttributes) { /* A start element marks a new parent */ if (reader.IsStartElement()) { ParentTypes parentPlaceholder; NodeParent = (Enum.TryParse(reader.Name, out parentPlaceholder) ? parentPlaceholder : ParentTypes.None); /* If whatever parent read is known, run the "preperation" for that parent */ if (AttributeMethods.ContainsKey(NodeParent)) { AttributeMethods[NodeParent].Item1?.DynamicInvoke(); } else { continue; } } /* Looping through all attributes of node/element */ for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToNextAttribute(); string name = reader.Name, value = reader.Value; var currentMemberInfo = TargetInformationList.FirstOrDefault(p => p.Name == name); if (currentMemberInfo == default(PropertyInfo)) { continue; /* Like a null-reference check-up */ } /* If necessary, do some work on the value before converting it to object[] for later use */ object[] values = AttributeMethods[NodeParent].Item2?.DynamicInvoke(value) as object[]; if (values == null) { continue; } /* Loop through values, setting the value to the correct property in the target class/struct. * Type conversion is handled through AttributeConversion: * - As stated previously, AttributeConverter is a generic method, for which types are not known at compile time. * To get around this, an instance of the method is created, in which the type is provided. * The return value from the method is the value for the set-method of the property, for which we are trying to assign a value. */ foreach (string item in values) { currentMemberInfo.SetValue(Target, AttributeConversion.MakeGenericMethod(currentMemberInfo.PropertyType).Invoke(null, new object[] { item })); } } AttributeMethods[NodeParent].Item3?.DynamicInvoke(); } } ; } /* We're finished, return the results for further working */ return((BuildingInformationCollection)BuildingInformation); }