public static CreateFileCSharpConfiguration CreateForProxyClass(
            string namespaceClasses
            , string namespaceGlobalOptionSets
            , CommonConfiguration commonConfig
            )
        {
            var result = new CreateFileCSharpConfiguration
            {
                TabSpacer = commonConfig.GetTabSpacer(),

                NamespaceClasses          = namespaceClasses,
                NamespaceGlobalOptionSets = namespaceGlobalOptionSets,

                GenerateAttributes           = commonConfig.GenerateProxyClassesAttributes,
                GenerateAttributesWithNameOf = commonConfig.GenerateProxyClassesAttributesWithNameOf,
                GenerateStatus          = commonConfig.GenerateProxyClassesStatusOptionSet,
                GenerateLocalOptionSet  = commonConfig.GenerateProxyClassesLocalOptionSet,
                GenerateGlobalOptionSet = commonConfig.GenerateProxyClassesGlobalOptionSet,
                GenerateOneToMany       = commonConfig.GenerateProxyClassesOneToMany,
                GenerateManyToOne       = commonConfig.GenerateProxyClassesManyToOne,
                GenerateManyToMany      = commonConfig.GenerateProxyClassesManyToMany,

                AllDescriptions         = commonConfig.GenerateCommonAllDescriptions,
                WithDependentComponents = commonConfig.GenerateSchemaEntityOptionSetsWithDependentComponents,

                WithManagedInfo = commonConfig.SolutionComponentWithManagedInfo,

                GenerateWithDebuggerNonUserCode       = commonConfig.GenerateProxyClassesWithDebuggerNonUserCode,
                UseSchemaConstInCSharpAttributes      = commonConfig.GenerateProxyClassesUseSchemaConstInCSharpAttributes,
                WithoutObsoleteAttribute              = commonConfig.GenerateProxyClassesWithoutObsoleteAttribute,
                MakeAllPropertiesEditable             = commonConfig.GenerateProxyClassesMakeAllPropertiesEditable,
                AddConstructorWithAnonymousTypeObject = commonConfig.GenerateProxyClassesAddConstructorWithAnonymousTypeObject,

                GenerateAttributesEnumsStateStatus = commonConfig.GenerateProxyClassesAttributesEnumsStateStatus,
                GenerateAttributesEnumsLocal       = commonConfig.GenerateProxyClassesAttributesEnumsLocal,
                GenerateAttributesEnumsGlobal      = commonConfig.GenerateProxyClassesAttributesEnumsGlobal,

                GenerateAttributesEnumsStateStatusUseSchemaEnum = commonConfig.GenerateProxyClassesAttributesEnumsUseSchemaStateStatusEnum,
                GenerateAttributesEnumsLocalUseSchemaEnum       = commonConfig.GenerateProxyClassesAttributesEnumsUseSchemaLocalEnum,
                GenerateAttributesEnumsGlobalUseSchemaEnum      = commonConfig.GenerateProxyClassesAttributesEnumsUseSchemaGlobalEnum,

                AddDescriptionAttribute = commonConfig.GenerateProxyClassesAddDescriptionAttribute,
            };

            return(result);
        }
        public static CreateFileCSharpConfiguration CreateForSchemaEntity(
            string namespaceClasses
            , string namespaceGlobalOptionSets
            , string typeConverterName
            , CommonConfiguration commonConfig
            )
        {
            var result = new CreateFileCSharpConfiguration
            {
                TabSpacer = commonConfig.GetTabSpacer(),

                NamespaceClasses          = namespaceClasses,
                NamespaceGlobalOptionSets = namespaceGlobalOptionSets,

                TypeConverterName = typeConverterName,

                GenerateAttributes      = commonConfig.GenerateSchemaAttributes,
                GenerateStatus          = commonConfig.GenerateSchemaStatusOptionSet,
                GenerateLocalOptionSet  = commonConfig.GenerateSchemaLocalOptionSet,
                GenerateGlobalOptionSet = commonConfig.GenerateSchemaGlobalOptionSet,
                GenerateOneToMany       = commonConfig.GenerateSchemaOneToMany,
                GenerateManyToOne       = commonConfig.GenerateSchemaManyToOne,
                GenerateManyToMany      = commonConfig.GenerateSchemaManyToMany,
                GenerateKeys            = commonConfig.GenerateSchemaKeys,

                AllDescriptions         = commonConfig.GenerateCommonAllDescriptions,
                WithDependentComponents = commonConfig.GenerateSchemaEntityOptionSetsWithDependentComponents,
                ConstantType            = commonConfig.GenerateSchemaConstantType,
                OptionSetExportType     = commonConfig.GenerateSchemaOptionSetExportType,

                GenerateSchemaIntoSchemaClass = commonConfig.GenerateSchemaIntoSchemaClass,
                WithManagedInfo = commonConfig.SolutionComponentWithManagedInfo,

                AddDescriptionAttribute = commonConfig.GenerateSchemaAddDescriptionAttribute,

                AddTypeConverterAttributeForEnums = commonConfig.GenerateSchemaAddTypeConverterAttributeForEnums,
            };

            return(result);
        }
        public static CreateFileCSharpConfiguration CreateForSdkMessageRequest(
            string namespaceClasses
            , string namespaceGlobalOptionSets
            , CommonConfiguration commonConfig
            )
        {
            var result = new CreateFileCSharpConfiguration
            {
                TabSpacer = commonConfig.GetTabSpacer(),

                NamespaceClasses          = namespaceClasses,
                NamespaceGlobalOptionSets = namespaceGlobalOptionSets,

                GenerateAttributesWithNameOf = commonConfig.GenerateSdkMessageRequestAttributesWithNameOf,

                GenerateWithDebuggerNonUserCode = commonConfig.GenerateSdkMessageRequestWithDebuggerNonUserCode,

                MakeAllPropertiesEditable = commonConfig.GenerateSdkMessageRequestMakeAllPropertiesEditable,
            };

            return(result);
        }
        private async Task CreateJavaScriptFile(IEnumerable <OptionSetMetadata> optionSets)
        {
            if (optionSets == null)
            {
                return;
            }

            if (!this.IsControlsEnabled)
            {
                return;
            }

            string folder = txtBFolder.Text.Trim();

            if (string.IsNullOrEmpty(folder))
            {
                _iWriteToOutput.WriteToOutput(null, Properties.OutputStrings.FolderForExportIsEmpty);
                folder = FileOperations.GetDefaultFolderForExportFilePath();
            }
            else if (!Directory.Exists(folder))
            {
                _iWriteToOutput.WriteToOutput(null, Properties.OutputStrings.FolderForExportDoesNotExistsFormat1, folder);
                folder = FileOperations.GetDefaultFolderForExportFilePath();
            }

            var service = await GetService();

            string optionSetsName = string.Join(",", optionSets.Select(o => o.Name).OrderBy(s => s));

            this._iWriteToOutput.WriteToOutputStartOperation(service.ConnectionData, Properties.OperationNames.CreatingFileWithGlobalOptionSetsFormat1, optionSetsName);

            ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.CreatingFileForOptionSetsFormat1, optionSetsName);

            try
            {
                string fileName = CreateGlobalOptionSetsFileCSharpHandler.CreateFileNameJavaScript(service.ConnectionData, optionSets, this._selectedItem != null);

                string filePath = Path.Combine(folder, fileName);

                if (_isJavaScript && !string.IsNullOrEmpty(_filePath))
                {
                    filePath = _filePath;
                }

                using (var writer = new StreamWriter(filePath, false, new UTF8Encoding(false)))
                {
                    var handler = new CreateGlobalOptionSetsFileJavaScriptHandler(
                        writer
                        , service
                        , _iWriteToOutput
                        , _commonConfig.GetTabSpacer()
                        , _commonConfig.GenerateSchemaGlobalOptionSetsWithDependentComponents
                        );

                    await handler.CreateFileAsync(optionSets);
                }

                if (this._selectedItem != null)
                {
                    if (_selectedItem.ProjectItem != null)
                    {
                        _selectedItem.ProjectItem.ProjectItems.AddFromFileCopy(filePath);

                        _selectedItem.ProjectItem.ContainingProject.Save();
                    }
                    else if (_selectedItem.Project != null)
                    {
                        _selectedItem.Project.ProjectItems.AddFromFile(filePath);

                        _selectedItem.Project.Save();
                    }
                }

                this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.CreatedGlobalOptionSetMetadataFileForConnectionFormat3, service.ConnectionData.Name, optionSetsName, filePath);

                this._iWriteToOutput.PerformAction(service.ConnectionData, filePath);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingFileForOptionSetsCompletedFormat1, optionSetsName);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex);

                ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.CreatingFileForOptionSetsFailedFormat1, optionSetsName);
            }

            this._iWriteToOutput.WriteToOutputEndOperation(service.ConnectionData, Properties.OperationNames.CreatingFileWithGlobalOptionSetsFormat1, optionSetsName);
        }