Ejemplo n.º 1
0
		private void ComputeTypeInfoForProperties(ModelInfo model)
		{
			foreach (var type in model.Types)
			{
				foreach (var prop in type.Properties)
				{
					prop.TypeInfo = model.GetType(prop.TypeName);

					if (prop is CollectionInfo)
					{
						var col = (CollectionInfo) prop;
						col.ContentsType.TypeInfo = model.GetType(col.ContentsType.TypeName);
					}
				}
			}
		}
Ejemplo n.º 2
0
		private bool HasParent(ModelInfo model, TypeInfo type, Func<TypeInfo, bool> filter = null)
		{
			// the max value is just to avoid an infinite loop
			for (int i = 0; i < 10000; i++)
			{
				if (type.Extends == null)
					return false;

				var baseType = model.GetType(type.Extends);
				if (baseType == null)
					return false;

				if (filter == null || filter(baseType))
					return true;

				type = baseType;
			}

			throw new InvalidOperationException("Type hierarchy is too deep. Didn't you made a recursion?");
		}