public void GetAttributeModifierTest() { FieldElement fieldElement = new FieldElement(); fieldElement.Name = "TestField"; fieldElement.Access = CodeAccess.Protected; fieldElement.Type = "int"; fieldElement.MemberModifiers = MemberModifiers.Static; string attribute = ElementUtilities.GetAttribute(ElementAttributeType.Modifier, fieldElement); Assert.AreEqual("Static", attribute, "Unexpected attribute."); TypeElement typeElement = new TypeElement(); typeElement.TypeModifiers = TypeModifiers.Sealed; attribute = ElementUtilities.GetAttribute(ElementAttributeType.Modifier, typeElement); Assert.AreEqual("Sealed", attribute, "Unexpected attribute."); UsingElement usingElement = new UsingElement(); usingElement.Name = "System"; attribute = ElementUtilities.GetAttribute(ElementAttributeType.Modifier, usingElement); Assert.AreEqual(string.Empty, attribute, "Unexpected attribute."); }
//Transforme un groupe sous la forme Element, dElement public override Element Déconstruire() { TypeElement type = Acces.type_BUDGET_NOMENCLATURE; Element e = new Element(); dElement d; string CodeAttribut = ""; e.ID = ID; e.Code = Code; e.Libelle = Libelle; e.Element_Type = type.ID; e.Type_Element = Enveloppe; e.Actif = Actif; //Période { CodeAttribut = "PERIODE"; d = new dElement(ID, Acces.Trouver_Attribut(type, CodeAttribut).ID, CodeAttribut, Periode.ToString()); e.Liste.Add(d); } //TypeFlux { CodeAttribut = "TYPE_FLUX"; d = new dElement(ID, Acces.Trouver_Attribut(type, CodeAttribut).ID, CodeAttribut, ((int)TypeFlux).ToString()); e.Liste.Add(d); } return(e); }
public void GetSet() { TypeElement el = new TypeElement(); el.Type = typeof(string); Assert.AreEqual(typeof(string), el.Type, "A1"); }
public TypeElement() { EnumValues = new Models.EnumValue[] {}; Interfaces = new TypeElement[] {}; PossibleTypes = new TypeElement[] {}; InputFields = new InputValue[] {}; }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as ResourceReference; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (ReferenceElement != null) { dest.ReferenceElement = (Hl7.Fhir.Model.FhirString)ReferenceElement.DeepCopy(); } if (TypeElement != null) { dest.TypeElement = (Hl7.Fhir.Model.FhirUri)TypeElement.DeepCopy(); } if (Identifier != null) { dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy(); } if (DisplayElement != null) { dest.DisplayElement = (Hl7.Fhir.Model.FhirString)DisplayElement.DeepCopy(); } return(dest); }
private List <TypeElement> GenerateTypes(int typeCount, int fieldCount, int methodCount, int parameterCount) { List <TypeElement> result = new List <TypeElement>(); for (int i = 0; i < typeCount; i++) { TypeElement te = new TypeElement(); te.Name = String.Format("Type_{0}", i); te.Namespace = ""; te.BaseType = String.Format("BaseTypeOfType_{0}", i); te.IsClass = true; te.IsInterface = false; te.IsPublic = true; if (randomizer.Next(0, 3) == 0) { te.IsSealed = true; } te.Fields = GenerateFields(fieldCount); te.Methods = GenerateMethods(methodCount, parameterCount); result.Add(te); } return(result); }
//############################################################################### //# Panel Habilete (Pokemon) # //############################################################################### // Affiche la liste habileté en fonction de la sélection du joueur private void button_afficher_habilete_Click(object sender, RoutedEventArgs e) { string choix = comboBox_liste_habilete_element.Text; Habilete[] liste = new Habilete[25]; TypeElement element = new TypeElement(); switch (choix) { case "Eau": element = TypeElement.Eau; break; case "Electricite": element = TypeElement.Electricite; break; case "Feu": element = TypeElement.Feu; break; case "Vegetation": element = TypeElement.Vegetation; break; default: element = TypeElement.Eau; break; } afficher_habilete(element); }
// Affiche le panel des habileté (affiche les habiletés de type eau par défaut) private void button_help_Click(object sender, RoutedEventArgs e) { panel_habilete.Visibility = System.Windows.Visibility.Visible; TypeElement element = TypeElement.Eau; afficher_habilete(element); }
/// <summary> /// Writes the code element body text. /// </summary> /// <param name="element">The element.</param> private void WriteBody(TextCodeElement element) { MemberElement memberElement = element as MemberElement; TypeElement parentTypeElement = GetTypeParent(element); bool isAbstract = memberElement != null && (memberElement.MemberModifiers & MemberModifiers.Abstract) == MemberModifiers.Abstract; bool inInterface = memberElement != null && parentTypeElement != null && parentTypeElement.Type == TypeElementType.Interface; if (!(isAbstract || inInterface)) { WriteBeginBlock(); Writer.WriteLine(); if (element.BodyText != null && element.BodyText.Trim().Length > 0) { WriteTextBlock(element.BodyText); Writer.WriteLine(); WriteEndBlock(element); WriteClosingComment(element, VBSymbol.BeginComment.ToString()); } else { WriteEndBlock(element); } } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as DataRequirement; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (TypeElement != null) { dest.TypeElement = (Code <Hl7.Fhir.Model.FHIRAllTypes>)TypeElement.DeepCopy(); } if (ProfileElement != null) { dest.ProfileElement = new List <Hl7.Fhir.Model.FhirUri>(ProfileElement.DeepCopy()); } if (MustSupportElement != null) { dest.MustSupportElement = new List <Hl7.Fhir.Model.FhirString>(MustSupportElement.DeepCopy()); } if (CodeFilter != null) { dest.CodeFilter = new List <Hl7.Fhir.Model.DataRequirement.CodeFilterComponent>(CodeFilter.DeepCopy()); } if (DateFilter != null) { dest.DateFilter = new List <Hl7.Fhir.Model.DataRequirement.DateFilterComponent>(DateFilter.DeepCopy()); } return(dest); }
public override string ToString() { var typeElement = TypeElement?.ToString() ?? "null"; var typeParameters = PrintTypeParameters(); return($"{GetType().Name}:{ShortName}{typeParameters}->{typeElement}"); }
public override HybridCollection <IMethod> FindExtensionMethod(ExtensionMethodInfo info) { if (!TypeElement.HasAttributeInstance(PredefinedType.EXTENSION_ATTRIBUTE_CLASS, false)) { return(HybridCollection <IMethod> .Empty); } var declaration = GetDeclaration(); if (declaration == null) { return(HybridCollection <IMethod> .Empty); } var result = HybridCollection <IMethod> .Empty; foreach (var memberDeclaration in declaration.MemberDeclarations) { if (info.ShortName == memberDeclaration.DeclaredName && info.Hash == memberDeclaration.GetTreeStartOffset().Offset&& memberDeclaration.DeclaredElement is IMethod method) { result = result.Add(method); } } return(result); }
public virtual Stream <VariableElement> GetFields(Type type) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: TypeElement procedure = _elements.getTypeElement(type.FullName); return(fieldsIn(procedure.EnclosedElements).stream()); }
public override void Read(SignatureReader rdr) { Element = rdr.ReadElementType(); mods = new CustomModifierCollection(); mods.Read(rdr); t = TypeElement.ReadType(rdr); }
public ObjConsumable(string nomObjet, TypeConsumable typeConsumable, TypeElement typeElement, int puissance) { NomObjet = nomObjet; TypeConsumable = typeConsumable; TypeElement = typeElement; Puissance = puissance; }
public void ToElementForTypeReturnsTheCorrectElement() { Type expected = typeof(TypeWithAllElements); TypeElement actual = expected.ToElement(); Assert.Equal(new TypeElement(expected), actual); }
public void EvaluateElementParentAttributesContainsTest() { IConditionExpression expression = new BinaryOperatorExpression( BinaryExpressionOperator.Contains, new ElementAttributeExpression(ElementAttributeType.Attributes, ElementAttributeScope.Parent), new StringExpression("Attribute2")); FieldElement element = new FieldElement(); element.Name = "Test"; TypeElement typeElement = new TypeElement(); typeElement.Type = TypeElementType.Structure; typeElement.Name = "TestType"; typeElement.AddChild(element); typeElement.AddAttribute(new AttributeElement("Attribute1")); typeElement.AddAttribute(new AttributeElement("Attribute24")); bool result = ConditionExpressionEvaluator.Instance.Evaluate( expression, element); Assert.IsTrue(result, "Unexpected expression evaluation result."); typeElement.ClearAttributes(); result = ConditionExpressionEvaluator.Instance.Evaluate( expression, element); Assert.IsFalse(result, "Unexpected expression evaluation result."); }
public override void RewriteChildren(NamespaceTypeDefinition namespaceTypeDefinition) { string typeName = Util.FullyQualifiedTypeNameFromType(namespaceTypeDefinition); Element currentElement = null; // Unlike all other types that visited from either a namespace or a parent, // the module type is visited from the containing module if (_systemTypes.Contains(typeName)) { currentElement = new SpecialTrimType(typeName); _trimElements.Push(currentElement); } this.RewriteChildren((NamedTypeDefinition)namespaceTypeDefinition); //namespaceTypeDefinition.ContainingUnitNamespace = this.GetCurrentNamespace(); if (!_systemTypes.Contains(typeName)) { TypeElement type = _currentTrimAssembly.GetTypeElement(typeName); MutateType(namespaceTypeDefinition, type); } if (currentElement != null) { _trimElements.Pop(); } }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (TypeElement != null) { result.AddRange(TypeElement.Validate()); } if (UnitsElement != null) { result.AddRange(UnitsElement.Validate()); } if (UcumElement != null) { result.AddRange(UcumElement.Validate()); } if (Template != null) { result.AddRange(Template.Validate()); } if (SystemElement != null) { result.AddRange(SystemElement.Validate()); } return(result); }
public Sort(string nomSort, TypeElement typeElement, int puissance, int coutMp) { NomSort = nomSort; TypeElement = typeElement; Puissance = puissance; CoutMp = coutMp; }
public string FormatName(CommandElement command, TypeElement handleType) { var methodNameParts = command.NameParts; int verbPrefixLength = 1; if (methodNameParts.First() != command.Verb) { verbPrefixLength = 0; } if (handleType.NameParts .Zip(methodNameParts.Skip(verbPrefixLength), (x, y) => x == y) .All(x => x)) { methodNameParts = methodNameParts.Take(verbPrefixLength).Concat(methodNameParts.Skip(handleType.NameParts.Count() + verbPrefixLength)).ToArray(); } else if (handleType.VkName == "VkDeviceMemory" && methodNameParts.Skip(verbPrefixLength).First() == "memory") { methodNameParts = methodNameParts.Take(verbPrefixLength).Concat(methodNameParts.Skip(verbPrefixLength + 1)).ToArray(); } else if (handleType.VkName == "VkCommandBuffer" && methodNameParts.First() == "cmd") { methodNameParts = methodNameParts.Skip(1).ToArray(); } return(JoinNameParts(methodNameParts)); }
public LanguageType GetLanguageType(string database, string language, string dbDataTypeName) { database = database.ToLower(); language = language.ToLower(); dbDataTypeName = dbDataTypeName.ToLower(); string name = String.Format("{0}-{1}", database.ToLower(), language.ToLower()); TypeMappingElementCollection mappings = ConfigManager.TypeMappingSection.Mappings; if (mappings[name] == null) { logger.Warning(string.Format(Resources.NotFoundDataTypeMapping, database, language)); return(null); //throw new ArgumentNullException(displayName, string.Format("Not Found {0} To {1} Data Type Mapping", database, language)); } TypeElement dbType = null; if (mappings[name].Types[dbDataTypeName] == null) { dbType = mappings[name].Types["default"]; logger.Warning(string.Format(YeahTools.Properties.Resources.NotFoundDataTypeItem, database, dbDataTypeName)); //throw new ArgumentNullException(displayName, string.Format("Not Found {0} {1} Data Type Item", database, dbDataTypeName)); } else { dbType = mappings[name].Types[dbDataTypeName]; } return(new LanguageType(dbType.LanguageType, dbType.DefaultValue, dbType.Alias)); }
/// <summary> /// mapped types are in GQL form e.g. [int!]! /// this could be a lot better /// </summary> /// <param name="type"></param> /// <returns></returns> private static TypeElement ConvertGqlRequiredOrList(TypeElement type) { if (type.Name.EndsWith("!")) { return(new TypeElement { Kind = "NON_NULL", Name = null, OfType = ConvertGqlRequiredOrList(new TypeElement { Kind = type.Kind, Name = type.Name.TrimEnd('!') }) }); } else if (type.Name.EndsWith("]")) { return(new TypeElement { Kind = "LIST", Name = null, OfType = ConvertGqlRequiredOrList(new TypeElement { Kind = type.Kind, Name = type.Name.TrimStart('[').TrimEnd(']') }) }); } return(type); }
/// <summary> /// Build INPUT Type to be used by Mutations /// </summary> /// <param name="schema"></param> /// <remarks> /// Since Types and Inputs cannot have the same name, camelCase the name to prevent duplicates. /// </remarks> /// <returns></returns> private static List <TypeElement> BuildInputTypes(ISchemaProvider schema) { var types = new List <TypeElement>(); foreach (ISchemaType schemaType in schema.GetNonContextTypes().Where(s => s.IsInput)) { if (schemaType.Name.StartsWith("__")) { continue; } var inputValues = new List <InputValue>(); foreach (Field field in schemaType.GetFields()) { if (field.Name.StartsWith("__")) { continue; } // Skip any property with special attribute var property = schemaType.ContextType.GetProperty(field.Name); if (property != null && GraphQLIgnoreAttribute.ShouldIgnoreMemberFromInput(property)) { continue; } // Skipping custom fields added to schema if (field.Resolve.NodeType == System.Linq.Expressions.ExpressionType.Call) { continue; } // Skipping ENUM type if (field.ReturnType.TypeDotnet.GetTypeInfo().IsEnum) { continue; } inputValues.Add(new InputValue { Name = field.Name, Description = field.Description, Type = BuildType(schema, field.ReturnType, field.ReturnType.TypeDotnet, true) }); } var typeElement = new TypeElement { Kind = "INPUT_OBJECT", Name = schemaType.Name, Description = schemaType.Description, InputFields = inputValues.ToArray() }; types.Add(typeElement); } return(types); }
public void CreateInstance_WithType() { TypeElement <SampleType> typeElement = new TypeElement <SampleType>(); typeElement.Type = typeof(DerivedSampleType); Assert.IsInstanceOf(typeof(DerivedSampleType), typeElement.CreateInstance()); }
public override IDeclaredType GetBaseClassType() { var typeElement = TypeElement.GetContainingType(); return(typeElement != null ? TypeFactory.CreateType(typeElement) : null); }
public IList <Internal> GetInternalsByTypeElement(TypeElement typeElement) { if (_internalsByTypeElement.ContainsKey(typeElement)) { return(_internalsByTypeElement[typeElement]); } return(new List <Internal>()); }
public override Stream <CompilationMessage> VisitType(TypeElement extensionClass, Void ignored) { if (IsFirstVisit(extensionClass)) { return(Stream.concat(ValidateFields(extensionClass), ValidateConstructor(extensionClass))); } return(Stream.empty()); }
public void InsertByTypeElementTypeDescendingTest() { SortBy sortBy = new SortBy(); sortBy.By = ElementAttributeType.Type; sortBy.Direction = SortDirection.Descending; SortedInserter sortedInserter = new SortedInserter(ElementType.Type, sortBy); // // Create a parent element // RegionElement regionElement = new RegionElement(); Assert.AreEqual(0, regionElement.Children.Count, "Parent element should not have any children."); // // Insert an element with a mid value. // TypeElement type1 = new TypeElement(); type1.Name = "Type1"; type1.Type = TypeElementType.Structure; sortedInserter.InsertElement(regionElement, type1); // // Insert an element that should be sorted toward the end // TypeElement type2 = new TypeElement(); type2.Name = "Type2"; type2.Type = TypeElementType.Class; sortedInserter.InsertElement(regionElement, type2); // // Insert an element that should be sorted toward the middle // TypeElement type3 = new TypeElement(); type3.Name = "Type3"; type3.Type = TypeElementType.Interface; sortedInserter.InsertElement(regionElement, type3); // // Insert an element that should be sorted toward the beginning // TypeElement type4 = new TypeElement(); type4.Name = "Type4"; type4.Type = TypeElementType.Enum; sortedInserter.InsertElement(regionElement, type4); Assert.AreEqual(4, regionElement.Children.Count, "Element was not inserted into the parent."); Assert.AreEqual(0, regionElement.Children.IndexOf(type4), "Element is not at the correct index."); Assert.AreEqual(1, regionElement.Children.IndexOf(type3), "Element is not at the correct index."); Assert.AreEqual(2, regionElement.Children.IndexOf(type1), "Element is not at the correct index."); Assert.AreEqual(3, regionElement.Children.IndexOf(type2), "Element is not at the correct index."); }
public void SutIsReflectionElement() { // Fixture setup // Exercise system var sut = new TypeElement(this.GetType()); // Verify outcome Assert.IsAssignableFrom<IReflectionElement>(sut); // Teardown }
public Combat(Aventure parti, TypeElement element) { InitializeComponent(); fenetre_difficulty.Visibility = System.Windows.Visibility.Visible; this.parti = parti; this.element = element; selectionne = parti.joueur.equipe[0]; init_interface(); }
public void SutEqualsOtherIdenticalInstance() { var t = this.GetType(); var sut = new TypeElement(t); var other = new TypeElement(t); var actual = sut.Equals(other); Assert.True(actual); }
public void AcceptNullVisitorThrows() { // Fixture setup var sut = new TypeElement(this.GetType()); // Exercise system // Verify outcome Assert.Throws<ArgumentNullException>(() => sut.Accept((IReflectionVisitor<object>)null)); // Teardown }
public void TypeIsCorrect() { // Fixture setup var expected = this.GetType(); var sut = new TypeElement(expected); // Exercise system Type actual = sut.Type; // Verify outcome Assert.Equal(expected, actual); // Teardown }
private string FilenamePartForParameter(TypeElement parameterType) { if (parameterType.IsGenericType) { TypeElement[] genericArguments = parameterType.GetGenericArguments(); // FIX: do not use Member here string genericType = parameterType.GetGenericTypeDefinition().Member.FullName.Split('`')[0]; return genericType + "`" + string.Join(",", genericArguments.Select(FilenamePartForParameter)); } else { // FIX: do not use Member here return SystemTypes.Alias(parameterType) ?? parameterType.Member.FullName; } }
public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance() { // Fixture setup var expected = new DelegatingReflectionVisitor<int>(); var sut = new TypeElement(this.GetType()); var visitor = new DelegatingReflectionVisitor<int> { OnVisitTypeElement = e => e == sut ? expected : new DelegatingReflectionVisitor<int>() }; // Exercise system var actual = sut.Accept(visitor); // Verify outcome Assert.Same(expected, actual); // Teardown }
public int IndexOf(TypeElement element) { }
public void SutDoesNotEqualAnonymousObject(object other) { var sut = new TypeElement(this.GetType()); var actual = sut.Equals(other); Assert.False(actual); }
public string Filename(TypeElement type, string prefix = "T", string suffix = ".html") { return Filename(type.Member, prefix, suffix); }
public void GetHashCodeReturnsCorrectResult(Type t) { var sut = new TypeElement(t); var actual = sut.GetHashCode(); var expected = t.GetHashCode(); Assert.Equal(expected, actual); }
public void SutDoesNotEqualDifferentInstanceOfSameType() { var sut = new TypeElement(this.GetType()); var other = new TypeElement(typeof(Version)); var actual = sut.Equals(other); Assert.False(actual); }
/// <summary> /// Normalizes the given type element. /// </summary> public TypeElement Normalize(TypeElement type) { if (type.IsGenericType && !type.IsGenericTypeDefinition) { return type.GetGenericTypeDefinition(); } return type; }
public void CopyTo(TypeElement[] array, int index) { }
public static string Alias(TypeElement type) { return Alias(type.Member); }
// Methods public void Add(TypeElement element) { }
// Get or create a cache element for a type. private static TypeElement GetOrCreateElement(Type type) { TypeElement element = (TypeElement)(typeTable[type]); if(element == null) { element = new TypeElement(); typeTable[element] = element; } return element; }
public void Remove(TypeElement element) { }