--- /dev/null
+// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+namespace Crow
+{
+ /// <summary>
+ /// Add this attribute to an assembly to have it search for Crow ressources (.style, images, templates,...)
+ /// </summary>
+ /// <remarks>
+ /// By default, only the entry assembly and the crow assembly will be searched for resources.
+ /// </remarks>
+ [AttributeUsage (AttributeTargets.Assembly)]
+ public class CrowAttribute : Attribute
+ {
+ }
+}
}
#endregion
+ internal static List<Assembly> crowAssemblies = new List<Assembly> ();
+
#region CTOR
static Interface ()
{
//ensure all assemblies are loaded, because IML could contains classes not instanciated in source
foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
try {
- Assembly.LoadFrom (af);
+ Assembly a =Assembly.LoadFrom (af);
+ if (a == Assembly.GetEntryAssembly () || a == Assembly.GetExecutingAssembly ())
+ continue;
+ if (a.GetCustomAttribute (typeof (CrowAttribute)) != null)
+ crowAssemblies.Add (a);
} catch {
- System.Diagnostics.Debug.WriteLine ("{0} not loaded as assembly.", af);
+ Debug.WriteLine ("{0} not loaded as assembly.", af);
}
}
//assembly, it's ignored.
loadStylingFromAssembly (Assembly.GetEntryAssembly ());
loadStylingFromAssembly (Assembly.GetExecutingAssembly ());
+
+ foreach (Assembly a in crowAssemblies) {
+ loadStylingFromAssembly (a);
+ }
}
/// <summary> Search for .style resources in assembly </summary>
protected void loadStylingFromAssembly (Assembly assembly) {
throw new ParserException (line, column, "Unexpected end of statement", resId);
ReadChar ();
if (targetsClasses.Count == 0) {
- //style constant
- if (!iFace.StylingConstants.ContainsKey (currentProperty))
- iFace.StylingConstants.Add (currentProperty, token);
+ //style constants
+ iFace.StylingConstants[currentProperty] = token;
curState = States.classNames;
} else {
foreach (string tc in targetsClasses) {
if (!iFace.Styling.ContainsKey (tc))
iFace.Styling [tc] = new Style ();
- else if (iFace.Styling [tc].ContainsKey (currentProperty))
- continue;
iFace.Styling [tc] [currentProperty] = token;
#if DESIGN_MODE
styling [tc].Locations[currentProperty] = new FileLocation(resId, line, column - token.Length - 1, token.Length);
#endif
- //System.Diagnostics.Debug.WriteLine ("Style: {3} : {0}.{1} = {2}", tc, currentProperty, token, resId);
}
curState = States.members;
}