Exemple #1
0
        private void AdjustContentValue(Repository repository)
        {
            ISchemaProvider xmlSchemaProvider = new SchemaProvider();

            foreach (var schema in xmlSchemaProvider.All(repository))
            {
                ReplaceContentFileVirtualPath(repository, schema);
            }
        }
        //private void AdjustContentValue(Repository repository)
        //{
        //    ISchemaProvider xmlSchemaProvider = new SchemaProvider();
        //    foreach (var schema in xmlSchemaProvider.All(repository))
        //    {
        //        ReplaceContentFileVirtualPath(repository, schema);
        //    }
        //}
        //private void ReplaceContentFileVirtualPath(Repository repository, Schema schema)
        //{
        //    var schemaDataFile = schema.GetContentFile();
        //    if (File.Exists(schemaDataFile))
        //    {
        //        var replaceVirtualPathRegex = new Regex(RepositoryPath.BaseVirtualPath.TrimStart('~') + "/[^/]+/", RegexOptions.Compiled | RegexOptions.IgnoreCase);
        //        string virtualPathFormat = RepositoryPath.BaseVirtualPath.TrimStart('~') + "/{0}/";
        //        string data = IOUtility.ReadAsString(schemaDataFile);
        //        string newData = replaceVirtualPathRegex.Replace(data, string.Format(virtualPathFormat, repository));
        //        IOUtility.SaveStringToFile(schemaDataFile, newData);
        //    }
        //}

        public virtual void Initialize(Repository repository)
        {
            ITextContentProvider textContentProvider = Providers.DefaultProviderFactory.GetProvider <ITextContentProvider>();

            Providers.DefaultProviderFactory.GetProvider <IMediaContentProvider>().InitializeMediaContents(repository);
            ISchemaProvider schemaProvider = Providers.DefaultProviderFactory.GetProvider <ISchemaProvider>();

            //if (!(textContentProvider is TextContentProvider))
            //{
            ISchemaProvider      xmlSchemaProvider  = new SchemaProvider();
            ITextContentProvider xmlContentProvider = new TextContentProvider();

            foreach (var schema in xmlSchemaProvider.All(repository))
            {
                schemaProvider.Initialize(schema);

                textContentProvider.ImportSchemaData(schema, xmlContentProvider.ExportSchemaData(schema));
            }

            textContentProvider.ImportCategoryData(repository, xmlContentProvider.ExportCategoryData(repository));
            //}
        }