示例#1
0
        private WebAppSettings CreateWebAppSettings()
        {
            WebAppSettings settings = new WebAppSettings();
            settings.DataOptions = new DataOptions();
            settings.DataOptions.DataObjectsNamespace = "BlogApp.DataObjects";

            settings.DataOptions.ORMFramework = new ORMFramework();
            settings.DataOptions.ORMFramework.Selected = "EntityFramework";

            return settings;
        }
示例#2
0
        public void SaveSettings()
        {
            string filePath = OutputPath + _fileName;

            WebAppSettings s = new WebAppSettings();

            s.Version   = _version;
            s.Namespace = _input["txtNamespace"].ToString();

            s.Tables = new TableObject();
            foreach (string table in Tables)
            {
                s.Tables.AddItem(new TableItem(table));
            }

            s.BusinessObjects = new BusinessObjects();
            s.BusinessObjects.BusinessObjectsNamespace = _input["txtBusinessObjectsNamespace"].ToString();
            s.BusinessObjects.Use       = Convert.ToBoolean(_input["chkCreateBusinessObjects"].ToString());
            s.BusinessObjects.ClassName = _input["ddlChooseBusinessObjects"].ToString();
            s.BusinessObjects.Selected  = GetClassValue(s.BusinessObjects.ClassName);

            s.ServiceLayer     = new ServiceLayer();
            s.ServiceLayer.Use = Convert.ToBoolean(_input["chkEnableServices"].ToString());
            s.ServiceLayer.ServiceNamespace = _input["txtServiceNamespace"].ToString();
            s.ServiceLayer.DataContract     = _input["txtDataContract"].ToString();
            s.ServiceLayer.ClassName        = _input["ddlChooseServiceType"].ToString();
            s.ServiceLayer.Selected         = GetClassValue(s.ServiceLayer.ClassName);
            s.ServiceLayer.SupportWCF       = true;

            s.DataOptions = new DataOptions();
            s.DataOptions.DataObjectsNamespace = _input["txtDataObjectsNamespace"].ToString();
            s.DataOptions.VersionColumnName    = _input["txtVersionColumnName"].ToString();
            s.DataOptions.ConnectionString     = ChopProvider(Database.ConnectionString);

            s.DataOptions.DataPattern           = new DataPattern();
            s.DataOptions.DataPattern.ClassName = _input["ddlChooseDataPattern"].ToString();
            s.DataOptions.DataPattern.Selected  = GetClassValue(s.DataOptions.DataPattern.ClassName);
            s.DataOptions.DataContext           = new DataContext();

            s.DataOptions.DataStore           = new DataStore();
            s.DataOptions.DataStore.ClassName = _input["ddlChooseDataStore"].ToString();
            s.DataOptions.DataStore.Selected  = GetClassValue(s.DataOptions.DataStore.ClassName);

            s.DataOptions.ORMFramework           = new ORMFramework();
            s.DataOptions.ORMFramework.ClassName = _input["ddlChooseOrmFramework"].ToString();
            s.DataOptions.ORMFramework.Selected  = GetClassValue(s.DataOptions.ORMFramework.ClassName);
            //s.DataOptions.ORMFramework.Version = _input["ddlChooseOrmFrameworkVersion"].ToString();

            bool isDefault = true;

            if ((_input["txtDataContextName"].ToString() != "ActionDataContext") && (_input["txtDataContextName"].ToString() != "ActionEntities"))
            {
                isDefault = false;
            }

            s.DataOptions.DataContext.IsDefault = isDefault;
            s.DataOptions.DataContext.Name      = _input["txtDataContextName"].ToString();

            isDefault = true;
            s.DataOptions.ClassPrefix = new ClassPrefix();

            if (s.DataOptions.DataStore.Selected == "SQLServer")
            {
                if (_input["txtClassPrefix"].ToString() != "SQLServer")
                {
                    isDefault = false;
                }
            }

            s.DataOptions.ClassPrefix.IsDefault = isDefault;
            s.DataOptions.ClassPrefix.Name      = s.DataOptions.DataStore.Selected;
            //s.DataOptions.ClassPrefix.Name = m_Input["txtClassPrefix"].ToString();

            isDefault = true;
            s.DataOptions.ClassSuffix = new ClassSuffix();

            if (_input["txtClassSuffix"].ToString() != "Dao")
            {
                isDefault = false;
            }

            s.DataOptions.ClassSuffix.IsDefault = isDefault;
            s.DataOptions.ClassSuffix.Name      = _input["txtClassSuffix"].ToString();

            s.Common            = new Common();
            s.Common.SaveToFile = Convert.ToBoolean(_input["chkSaveToFile"].ToString());
            s.UI                       = new UI();
            s.UI.Use                   = Convert.ToBoolean(_input["chkRenderUI"].ToString());
            s.UI.UINamespace           = _input["txtUINamespace"].ToString().Trim();
            s.UI.ClassName             = _input["ddlChooseUI"].ToString();
            s.UI.UIWcfServiceNamespace = _input["txtWCFServiceNamespace"].ToString();
            s.UI.UIFramework           = new UIFramework();
            s.UI.UIFramework.Selected  = _input["ddlChooseUI"].ToString();

            s.IoC                      = new IoC();
            s.IoC.Use                  = Convert.ToBoolean(_input["chkUseIoC"].ToString());
            s.IoC.ClassName            = _input["ddlChooseIoCProvider"].ToString();
            s.IoC.IoCProvider          = new IoCProvider();
            s.IoC.IoCProvider.Selected = _input["ddlChooseIoCProvider"].ToString();

            s.DotNet = new DotNet();
            s.DotNet.DotNetFramework          = new DotNetFramework();
            s.DotNet.DotNetFramework.Selected = _input["ddlChooseDotNetFramework"].ToString();

            s.Pluralizer                     = new Pluralizer();
            s.Pluralizer.ClassNames          = new ClassNames();
            s.Pluralizer.ClassNames.Selected = _input["ddlClassNamePluralizer"].ToString();

            s.Pluralizer.FieldNames          = new FieldNames();
            s.Pluralizer.FieldNames.Selected = _input["ddlFieldNamePluralizer"].ToString();

            s.Pluralizer.PropertyNames          = new PropertyNames();
            s.Pluralizer.PropertyNames.Selected = _input["ddlPropertyNamePluralizer"].ToString();

            try
            {
                Serializer <WebAppSettings> .Serialize(s, filePath);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        public void SaveSettings()
        {
            string filePath = OutputPath + _fileName;

            WebAppSettings s = new WebAppSettings();
            s.Version = _version;
            s.Namespace = _input["txtNamespace"].ToString();

            s.Tables = new TableObject();
            foreach (string table in Tables)
            {
                s.Tables.AddItem(new TableItem(table));
            }

            s.BusinessObjects = new BusinessObjects();
            s.BusinessObjects.BusinessObjectsNamespace = _input["txtBusinessObjectsNamespace"].ToString();
            s.BusinessObjects.Use = Convert.ToBoolean(_input["chkCreateBusinessObjects"].ToString());
            s.BusinessObjects.ClassName = _input["ddlChooseBusinessObjects"].ToString();
            s.BusinessObjects.Selected = GetClassValue(s.BusinessObjects.ClassName);

            s.ServiceLayer = new ServiceLayer();
            s.ServiceLayer.Use = Convert.ToBoolean(_input["chkEnableServices"].ToString());
            s.ServiceLayer.ServiceNamespace = _input["txtServiceNamespace"].ToString();
            s.ServiceLayer.DataContract = _input["txtDataContract"].ToString();
            s.ServiceLayer.ClassName = _input["ddlChooseServiceType"].ToString();
            s.ServiceLayer.Selected = GetClassValue(s.ServiceLayer.ClassName);
            s.ServiceLayer.SupportWCF = true;

            s.DataOptions = new DataOptions();
            s.DataOptions.DataObjectsNamespace = _input["txtDataObjectsNamespace"].ToString();
            s.DataOptions.VersionColumnName = _input["txtVersionColumnName"].ToString();
            s.DataOptions.ConnectionString = ChopProvider(Database.ConnectionString);

            s.DataOptions.DataPattern = new DataPattern();
            s.DataOptions.DataPattern.ClassName = _input["ddlChooseDataPattern"].ToString();
            s.DataOptions.DataPattern.Selected = GetClassValue(s.DataOptions.DataPattern.ClassName);
            s.DataOptions.DataContext = new DataContext();

            s.DataOptions.DataStore = new DataStore();
            s.DataOptions.DataStore.ClassName = _input["ddlChooseDataStore"].ToString();
            s.DataOptions.DataStore.Selected = GetClassValue(s.DataOptions.DataStore.ClassName);

            s.DataOptions.ORMFramework = new ORMFramework();
            s.DataOptions.ORMFramework.ClassName = _input["ddlChooseOrmFramework"].ToString();
            s.DataOptions.ORMFramework.Selected = GetClassValue(s.DataOptions.ORMFramework.ClassName);
            //s.DataOptions.ORMFramework.Version = _input["ddlChooseOrmFrameworkVersion"].ToString();

            bool isDefault = true;
            if ((_input["txtDataContextName"].ToString() != "ActionDataContext") && (_input["txtDataContextName"].ToString() != "ActionEntities"))
                isDefault = false;

            s.DataOptions.DataContext.IsDefault = isDefault;
            s.DataOptions.DataContext.Name = _input["txtDataContextName"].ToString();

            isDefault = true;
            s.DataOptions.ClassPrefix = new ClassPrefix();

            if (s.DataOptions.DataStore.Selected == "SQLServer")
            {
                if (_input["txtClassPrefix"].ToString() != "SQLServer")
                    isDefault = false;
            }

            s.DataOptions.ClassPrefix.IsDefault = isDefault;
            s.DataOptions.ClassPrefix.Name = s.DataOptions.DataStore.Selected;
            //s.DataOptions.ClassPrefix.Name = m_Input["txtClassPrefix"].ToString();

            isDefault = true;
            s.DataOptions.ClassSuffix = new ClassSuffix();

            if (_input["txtClassSuffix"].ToString() != "Dao")
                isDefault = false;

            s.DataOptions.ClassSuffix.IsDefault = isDefault;
            s.DataOptions.ClassSuffix.Name = _input["txtClassSuffix"].ToString();

            s.Common = new Common();
            s.Common.SaveToFile = Convert.ToBoolean(_input["chkSaveToFile"].ToString());
            s.UI = new UI();
            s.UI.Use = Convert.ToBoolean(_input["chkRenderUI"].ToString());
            s.UI.UINamespace = _input["txtUINamespace"].ToString().Trim();
            s.UI.ClassName = _input["ddlChooseUI"].ToString();
            s.UI.UIWcfServiceNamespace = _input["txtWCFServiceNamespace"].ToString();
            s.UI.UIFramework = new UIFramework();
            s.UI.UIFramework.Selected = _input["ddlChooseUI"].ToString();

            s.IoC = new IoC();
            s.IoC.Use = Convert.ToBoolean(_input["chkUseIoC"].ToString());
            s.IoC.ClassName = _input["ddlChooseIoCProvider"].ToString();
            s.IoC.IoCProvider = new IoCProvider();
            s.IoC.IoCProvider.Selected = _input["ddlChooseIoCProvider"].ToString();

            s.DotNet = new DotNet();
            s.DotNet.DotNetFramework = new DotNetFramework();
            s.DotNet.DotNetFramework.Selected = _input["ddlChooseDotNetFramework"].ToString();

            s.Pluralizer = new Pluralizer();
            s.Pluralizer.ClassNames = new ClassNames();
            s.Pluralizer.ClassNames.Selected = _input["ddlClassNamePluralizer"].ToString();

            s.Pluralizer.FieldNames = new FieldNames();
            s.Pluralizer.FieldNames.Selected = _input["ddlFieldNamePluralizer"].ToString();

            s.Pluralizer.PropertyNames = new PropertyNames();
            s.Pluralizer.PropertyNames.Selected = _input["ddlPropertyNamePluralizer"].ToString();

            try
            {
                Serializer<WebAppSettings>.Serialize(s, filePath);
            }
            catch (Exception)
            {
                throw;
            }
        }