Пример #1
0
		public void Verify(VerificationContext context, ASTNode node)
		{
			// objectType
            var objectTypeName = node.GetAttribute<string>("classType");
            if (objectTypeName != null)
            {
			    var objectType = context.ResolveType(node.GetAttribute<string>("classType")) as ObjectType;

			    // foreach property
			    foreach (var child in ((Node)node).Children)
			    {
					if (child.Name == "element") 
					{
						// Verify the property exists
						var childPropertyType = context.ResolveProperty(objectType, child.GetAttribute<string>("name"));

						// Verify the value
						var value = (ASTNode)child.Children[0];
						Verifier.Verify(context, value);

						// Verify the value type is appropriate for the property type
						context.VerifyType(value.ResultType, childPropertyType);
					}
			    }

			    node.ResultType = objectType;
            }
            else
            {
                var propertyList = new List<PropertyDef>();

                foreach (var child in ((Node)node).Children)
                {
					if (child.Name == "element")
					{
						var value = (ASTNode)child.Children[0];
						Verifier.Verify(context, value);

						var property = new PropertyDef(child.GetAttribute<string>("name"), value.ResultType);
						propertyList.Add(property);
					}
                }

                var objectType = new ObjectType(Guid.NewGuid().ToString(), propertyList);

                node.ResultType = objectType;
            }
		}
Пример #2
0
 public bool EquivalentTo(PropertyDef other)
 {
     return other != null && _name == other.Name && _propertyType.EquivalentTo(other.PropertyType);
 }