Beispiel #1
0
        public IEnumerable <Recipe> HarvestRecipes(string extensionId)
        {
            var recipes = new List <Recipe>();

            var extension = _extensionManager.GetExtension(extensionId);

            if (extension != null)
            {
                var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes");
                var recipeFiles    = _webSiteFolder.ListFiles(recipeLocation, true);

                recipeFiles.Where(r => r.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(r => {
                    try {
                        recipes.Add(_recipeParser.ParseRecipe(_webSiteFolder.ReadFile(r)));
                    }
                    catch (Exception ex) {
                        Logger.Error(ex, "Error while parsing recipe file '{0}'.", r);
                    }
                });
            }
            else
            {
                Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId);
            }

            return(recipes);
        }
Beispiel #2
0
        private ExtensionDescriptor GetExtensionDescriptor(string locationPath, string extensionId, string extensionType, string manifestPath, bool manifestIsOptional)
        {
            return(_cacheManager.Get(manifestPath, context => {
                if (!DisableMonitoring)
                {
                    Logger.Debug("Monitoring virtual path \"{0}\"", manifestPath);
                    context.Monitor(_webSiteFolder.WhenPathChanges(manifestPath));
                }

                var manifestText = _webSiteFolder.ReadFile(manifestPath);
                if (manifestText == null)
                {
                    if (manifestIsOptional)
                    {
                        manifestText = string.Format("Id: {0}", extensionId);
                    }
                    else
                    {
                        return null;
                    }
                }

                return GetDescriptorForExtension(locationPath, extensionId, extensionType, manifestText);
            }));
        }
Beispiel #3
0
 public PlacementFile Parse(string virtualPath)
 {
     return(_cacheManager.Get(virtualPath, context => {
         context.Monitor(_webSiteFolder.WhenPathChanges(virtualPath));
         var placementText = _webSiteFolder.ReadFile(virtualPath);
         return ParseImplementation(virtualPath, placementText);
     }));
 }
 public ProjectFileDescriptor Parse(string virtualPath)
 {
     return(_cacheManager.Get(virtualPath,
                              ctx => {
         ctx.Monitor(_webSiteFolder.WhenPathChanges(virtualPath));
         string content = _webSiteFolder.ReadFile(virtualPath);
         using (var reader = new StringReader(content)) {
             return Parse(reader);
         }
     }));
 }
        public PlacementFile Parse(string virtualPath)
        {
            return(_cacheManager.Get(virtualPath, true, context => {
                if (!DisableMonitoring)
                {
                    Logger.Debug("Monitoring virtual path \"{0}\"", virtualPath);
                    context.Monitor(_webSiteFolder.WhenPathChanges(virtualPath));
                }

                var placementText = _webSiteFolder.ReadFile(virtualPath);
                return ParseText(placementText);
            }));
        }
        public ProjectFileDescriptor Parse(string virtualPath)
        {
            return(_cacheManager.Get(virtualPath,
                                     ctx => {
                if (!DisableMonitoring)
                {
                    Logger.Debug("Monitoring virtual path \"{0}\"", virtualPath);
                    ctx.Monitor(_webSiteFolder.WhenPathChanges(virtualPath));
                }

                string content = _webSiteFolder.ReadFile(virtualPath);
                using (var reader = new StringReader(content)) {
                    return Parse(reader);
                }
            }));
        }
        private ExtensionDescriptor GetExtensionDescriptor(string locationPath, string extensionId, string extensionType, string manifestPath, bool manifestIsOptional)
        {
            var manifestText = _webSiteFolder.ReadFile(manifestPath);

            if (manifestText == null)
            {
                if (manifestIsOptional)
                {
                    manifestText = string.Format("Id: {0}", extensionId);
                }
                else
                {
                    return(null);
                }
            }

            return(GetDescriptorForExtension(locationPath, extensionId, extensionType, manifestText));
        }
Beispiel #8
0
        private IEnumerable <Recipe> HarvestRecipes(ExtensionDescriptor extension)
        {
            var recipes = new List <Recipe>();

            var recipeLocation = Path.Combine(extension.Location, extension.Id, "Recipes");
            var recipeFiles    = _webSiteFolder.ListFiles(recipeLocation, true);

            recipeFiles.Where(r => r.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(r => {
                try {
                    recipes.Add(_recipeParser.ParseRecipe(_webSiteFolder.ReadFile(r)));
                }
                catch (Exception ex) {
                    Logger.Error(ex, "Error while parsing recipe file '{0}'.", r);
                }
            });

            return(recipes);
        }
        private ExtensionDescriptor GetExtensionDescriptor(string locationPath, string extensionId, string extensionType, string manifestPath, bool manifestIsOptional)
        {
            return(cacheManager.Get(manifestPath, context =>
            {
                context.Monitor(webSiteFolder.WhenPathChanges(manifestPath));
                var manifestText = webSiteFolder.ReadFile(manifestPath);
                if (manifestText == null)
                {
                    if (manifestIsOptional)
                    {
                        manifestText = string.Format("Id: {0}", extensionId);
                    }
                    else
                    {
                        return null;
                    }
                }

                return GetDescriptorForExtension(locationPath, extensionId, extensionType, manifestText);
            }));
        }
        public IEnumerable <Recipe> HarvestRecipes(string extensionId)
        {
            var recipes   = new List <Recipe>();
            var extension = _extensionManager.GetExtension(extensionId);

            if (extension != null)
            {
                var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes");
                var recipeFiles    = _webSiteFolder.ListFiles(recipeLocation, true);
                recipes.AddRange(
                    from recipeFile in recipeFiles
                    where recipeFile.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)
                    select _recipeParser.ParseRecipe(_webSiteFolder.ReadFile(recipeFile)));
            }
            else
            {
                Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId);
            }

            return(recipes);
        }
Beispiel #11
0
        public void OnDisplaying(ShapeDisplayingContext context)
        {
            if (!IsActivable())
            {
                return;
            }

            var shape         = context.Shape;
            var shapeMetadata = (ShapeMetadata)context.Shape.Metadata;
            var currentTheme  = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext);
            var shapeTable    = _shapeTableManager.GetShapeTable(currentTheme.Id);

            if (!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper"))
            {
                return;
            }

            var descriptor = shapeTable.Descriptors[shapeMetadata.Type];

            // dump the Shape's content
            var dump = new ObjectDumper(6).Dump(context.Shape, "Model");

            var sb = new StringBuilder();

            ConvertToJSon(dump, sb);
            shape._Dump = sb.ToString();

            shape.Template         = null;
            shape.OriginalTemplate = descriptor.BindingSource;

            foreach (var extension in new[] { ".cshtml", ".aspx" })
            {
                foreach (var alternate in shapeMetadata.Alternates.Reverse().Concat(new [] { shapeMetadata.Type }))
                {
                    var alternateFilename = FormatShapeFilename(alternate, shapeMetadata.Type, shapeMetadata.DisplayType, currentTheme.Location + "/" + currentTheme.Id, extension);
                    if (_webSiteFolder.FileExists(alternateFilename))
                    {
                        shape.Template = alternateFilename;
                    }
                }
            }

            if (shape.Template == null)
            {
                shape.Template = descriptor.BindingSource;
            }

            if (shape.Template == null)
            {
                shape.Template = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
            }

            if (shape.OriginalTemplate == null)
            {
                shape.OriginalTemplate = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
            }

            try {
                // we know that templates are classes if they contain ':'
                if (!shape.Template.Contains(":") && _webSiteFolder.FileExists(shape.Template))
                {
                    shape.TemplateContent = _webSiteFolder.ReadFile(shape.Template);
                }
            }
            catch {
                // the url might be invalid in case of a code shape
            }

            if (shapeMetadata.PlacementSource != null && _webSiteFolder.FileExists(shapeMetadata.PlacementSource))
            {
                context.Shape.PlacementContent = _webSiteFolder.ReadFile(shapeMetadata.PlacementSource);
            }

            // Inject the Zone name
            if (shapeMetadata.Type == "Zone")
            {
                shape.Hint = ((Zone)shape).ZoneName;
            }

            shape.ShapeId = _shapeId++;
        }