Exemple #1
0
		public override void Build()
		{
			if (allTargets.Count() < 2)
				throw new Exception("Mapping requires two types");

			var leftName = allTargets.First();
			var rightName = allTargets.Skip(1).Take(1).First();
			TypeFacade left = null;
			TypeFacade right = null;
			foreach (var project in Vs.Helper.Projects)
			{
				var type = project.FindType(leftName);
				if (type != null)
					left = new TypeFacade(type);

				type = project.FindType(rightName);
				if (type != null)
					right = new TypeFacade(type);

				if (left != null && right != null)
					break;
			}

			if (left == null)
				throw new Exception(string.Format("Cannot find {0}", leftName));
			if (right == null)
				throw new Exception(string.Format("Cannot find {0}", rightName));


			Vs.Helper.ScratchFiles.Add(new MappingFile(left, right));
		}
Exemple #2
0
        public ActionResult Create()
        {
            var model = new TypeViewModel();

            model.TypeIsActiveList = new List <SelectListItem>();
            model.TypeIsActiveList.Add(new SelectListItem()
            {
                Text = "Active", Value = "true"
            });
            model.TypeIsActiveList.Add(new SelectListItem()
            {
                Text = "Inactive", Value = "false"
            });
            model.Status = true;
            using (var facade = new TypeFacade())
            {
                model.TypeCode = facade.GetNextTypeCode().ToString();
            }

            ViewBag.CreateUsername = UserInfo.FullName;
            ViewBag.UpdateUsername = UserInfo.FullName;
            ViewBag.CreateDate     = DateTime.Now;
            ViewBag.UpdateDate     = DateTime.Now;

            return(View(model));
        }
		public PropertyFacade(PropertyInfo info, TypeFacade parentType)
		{
			ParentType = parentType;
			ErrorMessages = new List<ErrorMessage>();
			Attributes = new List<GeneratedAttribute>();

			this.info = info;
			buildProperties();
			buildAttributes();
		}
Exemple #4
0
		protected void GetTargetFrom(Token token, bool throwIfNotFound = true)
		{
			Type type = null;
			var project = GetProjectFrom(token);
			if (targetTypeName != null)
			{
				type = project.FindType(targetTypeName);
			}
			if (type != null)
				this.type = new TypeFacade(type);
			if (type == null && throwIfNotFound && Vs.Helper.Flags.IsEmptyType)
			{
				this.type = TypeFacade.CreateEmptyType(targetTypeName);
				return;
			}
			if (type == null && throwIfNotFound)
				throw new Exception(
					string.Format("Count not find {0} in {1} project, make sure you've built recently in Debug Mode",
						targetTypeName, token));
		}
		private void buildProperties()
		{
			Name = info.Name;
			CamelCaseName = Name.Substring(0, 1).ToLower() + Name.Substring(1);
			PropertyType = info.PropertyType;
			StringifiedType = PropertyType.FixUpTypeName();

			if (info.PropertyType.IsScalar())
				Group = PropertyGroup.Scalar;
			else if (typeof (IEnumerable).IsAssignableFrom(info.PropertyType))
				Group = PropertyGroup.Enumerable;
			else
				Group = PropertyGroup.Navigation;

			if (Group == PropertyGroup.Navigation)
			{
				if (info.PropertyType == ParentType.SystemType)
					TypeFacade = ParentType;
				else
					TypeFacade = new TypeFacade(info.PropertyType);
			}
		}
		public override void Build()
		{
			if (!allTargets.Any())
				throw new Exception("Mapping requires a types");

			var targetName = allTargets.First();
			TypeFacade target = null;

			foreach (var project in Vs.Helper.Projects)
			{
				var type = project.FindType(targetName);
				if (type != null)
					target = new TypeFacade(type);

				if (target != null)
					break;
			}

			if (target == null)
				throw new Exception(string.Format("Cannot find {0}", targetName));

			Vs.Helper.ScratchFiles.Add(new TypeScriptModel(target));
		}