Exemplo n.º 1
0
        public string ValidateModelType(ModelType modelType)
        {
            // TODO: this is not a complete validation
            if (modelType == null)
            {
                return Resources.EmptyModelName;
            }

            return null;
        }
Exemplo n.º 2
0
        private bool IsControllerNameUserSet(ModelType previousModelSelected, string controllerName)
        {
            if (String.IsNullOrWhiteSpace(controllerName) || String.IsNullOrWhiteSpace(Model.ControllerRootName))
            {
                return false;
            }

            if (previousModelSelected != null)
            {
                string generatedControllerName = Model.GenerateControllerName(previousModelSelected.ShortTypeName);
                if (String.Equals(generatedControllerName, controllerName, StringComparison.Ordinal))
                {
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 3
0
        public string ValidateDataContextType(ModelType dataContextType)
        {
            // TODO: this is not a complete validation
            if (dataContextType == null)
            {
                return Resources.EmptyDbContextName;
            }

            return null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a DataContext item with the given name.
        /// </summary>
        /// <param name="typeName">The full type name of the DataContext to add.</param>
        /// <returns>The newly created item.</returns>'
        /// <remarks>
        /// We'll only generate a single DataContext item as a result of scaffolding. If the user previously
        /// selected 'new' and then did it again, we'll remove the item that was added the first time.
        /// </remarks>
        public ModelType AddNewDataContext(string typeName)
        {
            if (typeName == null)
            {
                throw new ArgumentNullException("typeName");
            }

            if (AddedDataContextItem != null)
            {
                // If the selected datacontext is removed from the collection, DataContextType will be set as the
                // value before the deleted value from the collection. If the selected datacontext name and previous datacontext
                // name are the same, the combo box will not be updated with the newly selected datacontext name but the previous
                // value from the collection. Hence, setting the datacontext to null before removing the previously added datacontext
                // from the collection.
                DataContextType = null;
                DataContextTypeName = null;
                DataContextTypesInternal.Remove(AddedDataContextItem);
            }

            AddedDataContextItem = new ModelType(typeName);
            DataContextTypesInternal.Add(AddedDataContextItem);
            return AddedDataContextItem;
        }