[Mono-dev] PATCH custom WebControls in skin files

Chris Toshok toshok at ximian.com
Tue Apr 11 07:53:02 EDT 2006


The addition of the "return null" isn't what bothers me in your original
version.  The point of my mail was that I want AddAssemblyByName and
AddAssemblyByFileName to have the same structure.

Chris

On Tue, 2006-04-11 at 00:26 -0700, Andrew Skiba wrote:
> I don't want to commit code like this. This
> 
> 	Exception error = null;
> 
> 	try {
> 		assembly = Assembly.LoadFrom (filename);
> 	} catch (Exception e) { error = e; }
> 
> 	if (assembly == null)
> 		ThrowParseException ("Assembly " + filename + " not
> found", error);
> 
> looks more cryptic than this:
> 
> 	try {
> 		assembly = Assembly.LoadFrom (filename);
> 	} catch (Exception e) {
> 		throw CreateParseException ("Assebly " + filename + "
> not found", e);
> 	}
> 
> So I'll wait for your opinion on refactoring ThrowParseException.
> 
> Thank you in advance.
> Andrew.
> 
> > patch looks fine, but I'd prefer an AddAssemblyByFileName 
> > that looks more like AddAssemblyByName, as in:
> > 
> > 	internal virtual Assembly AddAssemblyByFileName (string 
> > filename)
> > 	{
> > 		Assembly assembly = null;
> > 		Exception error = null;
> > 
> > 		try {
> > 			assembly = Assembly.LoadFrom (filename);
> > 		} catch (Exception e) { error = e; }
> > 
> > 		if (assembly == null)
> > 			ThrowParseException ("Assembly " + 
> > filename + " not found", error);
> > 
> > 		AddAssembly (assembly, true);
> > 		return assembly;
> > 	}
> > 
> > 
> > Chris
> > 
> > On Mon, 2006-04-10 at 02:34 -0700, Andrew Skiba wrote:
> > > When I use a custom web control in a skin file, then the 
> > dll holding 
> > > this control must be added to references when compiling 
> > PageTheme. The 
> > > attached patch makes this possible. As such references is already 
> > > found by parsers of individual skins, it's only necessary 
> > to add new 
> > > assemblies to the theme directory parser.
> > > 
> > > If no one objects, I will commit.
> > > 
> > > Index: ThemeDirectoryCompiler.cs
> > > ===================================================================
> > > --- ThemeDirectoryCompiler.cs	(revision 59261)
> > > +++ ThemeDirectoryCompiler.cs	(working copy)
> > > @@ -62,7 +62,11 @@
> > >  					if (!(o is ControlBuilder))
> > >  						continue;
> > >  					
> > ptp.RootBuilder.AppendSubBuilder ((ControlBuilder)o);
> > > -				}
> > > +				}
> > > +
> > > +				foreach (string ass in ptfp.Assemblies)
> > > +					if (!ptp.Assemblies.Contains
> > > (ass))
> > > +
> > > ptp.AddAssemblyByFileName (ass);
> > >  			}
> > >  
> > >  			PageThemeCompiler compiler = new
> > > PageThemeCompiler (ptp);
> > > Index: TemplateParser.cs
> > > ===================================================================
> > > --- TemplateParser.cs	(revision 59261)
> > > +++ TemplateParser.cs	(working copy)
> > > @@ -390,6 +390,20 @@
> > >  			}
> > >  		}
> > >  
> > > +		internal virtual Assembly AddAssemblyByFileName (string
> > > filename)
> > > +		{
> > > +			try {
> > > +				Assembly assembly = Assembly.LoadFrom
> > > (filename);
> > > +				AddAssembly (assembly, true);
> > > +				return assembly;
> > > +			}
> > > +			catch (Exception e)
> > > +			{
> > > +				ThrowParseException ("Assembly file " +
> > > filename + " not found", e);
> > > +				return null; //never gets here, only to
> > > satisfy the compiler
> > > +			}
> > > +		}
> > > +
> > >  		internal virtual Assembly AddAssemblyByName (string
> > > name)
> > >  		{
> > >  			if (anames == null)
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list