Ejemplo n.º 1
0
 public static void UnregisterAndDispose([NotNull] this IResourceRegistry registry, [CanBeNull] IDisposable disposable)
 {
     if (disposable != null && registry.UnregisterResource(disposable))
     {
         disposable.Dispose();
     }
 }
Ejemplo n.º 2
0
 public static void Register([NotNull] this IResourceRegistry registry, [CanBeNull] IDisposable disposable)
 {
     if (disposable != null)
     {
         registry.RegisterResource(disposable);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="resourceMgr"></param>
 public void Register(string key, IResourceRegistry resourceMgr)
 {
     CheckInit();
     if (!resourceMgrs.ContainsKey(key))
     {
         resourceMgrs.Add(key, resourceMgr);
     }
 }
Ejemplo n.º 4
0
 public InlineBlockOutputScope(SparkViewBase sparkView, IResourceRegistry resourceRegistry)
 {
     _sparkView        = sparkView;
     _resourceRegistry = resourceRegistry;
     _previousWriter   = sparkView.Output;
     _blockWriter      = new SpoolWriter();
     _sparkView.Output = _blockWriter;
 }
Ejemplo n.º 5
0
 public InlineBlockOutputScope(SparkViewBase sparkView, IResourceRegistry resourceRegistry)
 {
     _sparkView = sparkView;
     _resourceRegistry = resourceRegistry;
     _previousWriter = sparkView.Output;
     _blockWriter = new SpoolWriter();
     _sparkView.Output = _blockWriter;
 }
Ejemplo n.º 6
0
        public static void RequireEmbeddedResource(this IResourceRegistry registry, string assemblyName, string resourceName)
        {
            var urls = GetEmbeddedResourceUrls(registry, assemblyName, resourceName);

            foreach (var url in urls)
            {
                registry.Require(url);
            }
        }
Ejemplo n.º 7
0
        public static IReadableResourceRegistry AsReadable(this IResourceRegistry resourceRegistry)
        {
            if (resourceRegistry is IReadableResourceRegistry)
            {
                return((IReadableResourceRegistry)resourceRegistry);
            }

            return(new MakeReadableResourceRegistry(resourceRegistry));
        }
Ejemplo n.º 8
0
            private IResourceRegistry WrapDefaultWithConsolidation(IResourceRegistry registry, Func <string, IEnumerable <string> > getResourceUrls, Func <string, IEnumerable <string> > getDependencies, ref IResourceRegistry field)
            {
                if (field != null)
                {
                    return(field);
                }

                field = WrapWithConsolidation(registry, getResourceUrls, getDependencies);

                return(field);
            }
Ejemplo n.º 9
0
        public static void RequireEmbeddedResource(this IResourceRegistry registry, string assemblyName, string resourceName)
        {
            var shortAssemblyName = assemblyName.ToShortAssemblyName();

            if (!AssmanConfiguration.Current.Assemblies.Contains(shortAssemblyName))
            {
                throw new InvalidOperationException(@"Cannot include embedded resource because the assembly has not been configured in the Assman.config.  If you would like to embed a resource from the assembly '"
                                                    + assemblyName + "' then please add it to the <assemblies> list.");
            }
            var embeddedResourceVirtualPath = EmbeddedResource.GetVirtualPath(shortAssemblyName, resourceName);

            registry.Require(embeddedResourceVirtualPath);
        }
Ejemplo n.º 10
0
            private IResourceRegistry WrapWithConsolidation(IResourceRegistry registry, Func <string, IEnumerable <string> > getResourceUrls, Func <string, IEnumerable <string> > getDependencies)
            {
                if (registry is ConsolidatingResourceRegistry)
                {
                    return(registry);
                }
                else
                {
                    if (!_context.ManageDependencies)
                    {
                        getDependencies = path => Enumerable.Empty <string>();
                    }

                    return(new ConsolidatingResourceRegistry(registry, getResourceUrls, getDependencies));
                }
            }
Ejemplo n.º 11
0
        private static IEnumerable <string> GetEmbeddedResourceUrls(IResourceRegistry registry, string assemblyName, string resourceName)
        {
            string shortAssemblyName = assemblyName.ToShortAssemblyName();
            string virtualPath       = EmbeddedResource.GetVirtualPath(shortAssemblyName, resourceName);
            IEnumerable <string> resolvedUrls;

            if (!registry.TryResolvePath(virtualPath, out resolvedUrls))
            {
                throw new InvalidOperationException(
                          @"Cannot include embedded resource because it has not been configured in the Assman.config to be consolidated anywhere.
					Please add an include rule that matches the path 'assembly://"                     +
                          assemblyName + "/" + resourceName + "'.");
            }
            if (!AssmanConfiguration.Current.Assemblies.Contains(shortAssemblyName))
            {
                throw new InvalidOperationException(@"Cannot include embedded resource because the assembly has not been configured in the Assman.config.  If you would like to embed a resource from the assembly '"
                                                    + assemblyName + "' then please add it to the <assemblies> list.");
            }

            return(resolvedUrls);
        }
Ejemplo n.º 12
0
 public static void RegisterInlineBlock(this IResourceRegistry registry, string block)
 {
     registry.RegisterInlineBlock(block, null);
 }
Ejemplo n.º 13
0
 public static void RegisterInlineBlock(this IResourceRegistry registry, Action <TextWriter> block)
 {
     registry.RegisterInlineBlock(block, null);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Registers an inline block that will appear inline on the page directly below the includes of this <see cref="IResourceRegistry"/>.
 /// </summary>
 /// <param name="registry"></param>
 /// <param name="block">The inline css or javascript that will appear on the page.</param>
 /// <param name="key">A unique key used to identify the inline block.  This is optional and can be set to <c>null</c>.</param>
 public static void RegisterInlineBlock(this IResourceRegistry registry, string block, object key)
 {
     registry.RegisterInlineBlock(w => w.Write(block), key);
 }
Ejemplo n.º 15
0
 public static void RequireEmbeddedResource(this IResourceRegistry registry, Type type, string resourceName)
 {
     registry.RequireEmbeddedResource(type.Assembly.GetName().Name, resourceName);
 }
Ejemplo n.º 16
0
 internal ConsolidatingResourceRegistry(IResourceRegistry inner, Func <string, IEnumerable <string> > getResourceUrls, Func <string, IEnumerable <string> > getDependencies)
 {
     _inner           = inner;
     _getResourceUrls = getResourceUrls;
     _getDependencies = getDependencies;
 }
Ejemplo n.º 17
0
 public MakeReadableResourceRegistry(IResourceRegistry inner)
 {
     _inner = inner;
 }