diff --git a/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests.build b/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests.build index 3e7231554..63d6e0f3b 100644 --- a/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests.build +++ b/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/Castle.ActiveRecord.Framework.Internal.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/XmlGenerationTestCase.cs b/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/XmlGenerationTestCase.cs index 5dea31f6a..e856d70ba 100644 --- a/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/XmlGenerationTestCase.cs +++ b/ActiveRecord/Castle.ActiveRecord.Framework.Internal.Tests/XmlGenerationTestCase.cs @@ -631,7 +631,7 @@ public void JoinedSubClassUseWithGenericTypeAndGenericAbstractBase() String expected = "\r\n" + "\r\n" + - " \r\n" + + " \r\n" + " \r\n" + " \r\n" + " \r\n" + diff --git a/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2005.csproj b/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2005.csproj index 309d995d6..561962ed3 100644 --- a/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2005.csproj +++ b/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests-vs2005.csproj @@ -302,6 +302,7 @@ + diff --git a/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests.build b/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests.build index af8fd72d9..1c480634d 100644 --- a/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests.build +++ b/ActiveRecord/Castle.ActiveRecord.Tests/Castle.ActiveRecord.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/ActiveRecord/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs b/ActiveRecord/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs new file mode 100644 index 000000000..5c87c158b --- /dev/null +++ b/ActiveRecord/Castle.ActiveRecord.Tests/InvalidRootTypeTestCase.cs @@ -0,0 +1,55 @@ +// Copyright 2004-2006 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.ActiveRecord.Tests +{ + using System.Collections; + using Castle.ActiveRecord.Framework; + using Castle.ActiveRecord.Framework.Config; + using NUnit.Framework; + + [TestFixture] + public class InvalidRootTypeTestCase + { + protected IConfigurationSource GetConfigSource() + { + InPlaceConfigurationSource source = new InPlaceConfigurationSource(); + + Hashtable properties = new Hashtable(); + properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SqlClientDriver"); + properties.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2000Dialect"); + properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider"); + properties.Add("hibernate.connection.connection_string", + "Data Source=.;Initial Catalog=test;Integrated Security=SSPI"); + + source.Add(typeof(ActiveRecordBase), properties); + source.Add(typeof(NonAbstractRootType), properties); + + return source; + } + + [Test, ExpectedException(typeof(ActiveRecordException))] + public void RootTypeIsNotAbstract() + { + ActiveRecordStarter.ResetInitializationFlag(); + + ActiveRecordStarter.Initialize(GetConfigSource(), + typeof(NonAbstractRootType)); + } + + public class NonAbstractRootType : ActiveRecordBase + { + } + } +} diff --git a/ActiveRecord/Castle.ActiveRecord.Tests/JoinedSubClassTestCase.cs b/ActiveRecord/Castle.ActiveRecord.Tests/JoinedSubClassTestCase.cs index c446b1c18..881b80ee2 100644 --- a/ActiveRecord/Castle.ActiveRecord.Tests/JoinedSubClassTestCase.cs +++ b/ActiveRecord/Castle.ActiveRecord.Tests/JoinedSubClassTestCase.cs @@ -54,5 +54,31 @@ public void Entities() Assert.AreEqual( ce.Name, ces[0].Name ); Assert.AreEqual( ce.Id, ces[0].Id ); } + + [Test] + public void JoinedSubClass_WithAnyProperty() + { + ActiveRecordStarter.Initialize(GetConfigSource(), + typeof(Entity), typeof(CompanyEntity), typeof(PersonEntity), typeof(ManagerEntity)); + Recreate(); + + Entity.DeleteAll(); + CompanyEntity.DeleteAll(); + PersonEntity.DeleteAll(); + ManagerEntity.DeleteAll(); + + ManagerEntity manager = new ManagerEntity(); + manager.Name = "pointy haired"; + manager.Save(); + + PersonEntity person = new PersonEntity(); + person.Name = "dilbert"; + person.Manager = manager; + person.Save(); + + PersonEntity[] people = PersonEntity.FindAll(); + Assert.AreEqual(1, people.Length); + Assert.IsNotNull(people[0].Manager); + } } } diff --git a/ActiveRecord/Castle.ActiveRecord.Tests/Model/Entity.cs b/ActiveRecord/Castle.ActiveRecord.Tests/Model/Entity.cs index 0f07ab5fd..9f2421718 100644 --- a/ActiveRecord/Castle.ActiveRecord.Tests/Model/Entity.cs +++ b/ActiveRecord/Castle.ActiveRecord.Tests/Model/Entity.cs @@ -112,6 +112,16 @@ public int Person_Id set { person_id = value; } } + private IManager manager; + + [Any(IdType = typeof(int), MetaType = typeof(string), IdColumn = "ManagerId", TypeColumn = "ManagerType")] + [Any.MetaValueAttribute("Manager", typeof(ManagerEntity))] + public virtual IManager Manager + { + get { return manager; } + set { manager = value; } + } + public new static void DeleteAll() { ActiveRecordBase.DeleteAll( typeof(PersonEntity) ); @@ -127,4 +137,47 @@ public int Person_Id return (PersonEntity) ActiveRecordBase.FindByPrimaryKey( typeof(PersonEntity), id ); } } + + [ActiveRecord("entitymanager")] + public class ManagerEntity : ActiveRecordBase, IManager + { + private int id; + + [PrimaryKey] + public int Id + { + get { return id; } + set { id = value; } + } + + private string name; + + [Property] + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public static void DeleteAll() + { + DeleteAll(typeof(ManagerEntity)); + } + + public static ManagerEntity[] FindAll() + { + return (ManagerEntity[])FindAll(typeof(ManagerEntity)); + } + + public static ManagerEntity Find(int id) + { + return (ManagerEntity)FindByPrimaryKey(typeof(ManagerEntity), id); + } + } + + public interface IManager + { + int Id { get; set; } + string Name { get; set; } + } } diff --git a/ActiveRecord/Castle.ActiveRecord/Attributes/BelongsToAttribute.cs b/ActiveRecord/Castle.ActiveRecord/Attributes/BelongsToAttribute.cs index 71a5f7156..fbb69264c 100644 --- a/ActiveRecord/Castle.ActiveRecord/Attributes/BelongsToAttribute.cs +++ b/ActiveRecord/Castle.ActiveRecord/Attributes/BelongsToAttribute.cs @@ -72,6 +72,7 @@ public class BelongsToAttribute : WithAccessAttribute private bool insert = true; private bool notnull; private bool unique; + private String propertyRef; private FetchEnum fetchMethod = FetchEnum.Unspecified; private CascadeEnum cascade = CascadeEnum.None; private NotFoundBehaviour notFoundBehaviour = NotFoundBehaviour.Default; @@ -182,6 +183,18 @@ public FetchEnum Fetch set { fetchMethod = value; } } + /// + /// From NHibernate docs: The name of a property of the + /// associated class that is joined to the primary key + /// of this class. If not specified, the primary key of + /// the associated class is used. + /// + public string PropertyRef + { + get { return propertyRef; } + set { propertyRef = value; } + } + /// /// Set to false to ignore this association when updating entities of this ActiveRecord class. /// diff --git a/ActiveRecord/Castle.ActiveRecord/Castle.ActiveRecord.build b/ActiveRecord/Castle.ActiveRecord/Castle.ActiveRecord.build index ea41eed88..32bf4b79c 100644 --- a/ActiveRecord/Castle.ActiveRecord/Castle.ActiveRecord.build +++ b/ActiveRecord/Castle.ActiveRecord/Castle.ActiveRecord.build @@ -10,7 +10,7 @@ - + diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordMediator.Generic.cs b/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordMediator.Generic.cs index 7aa117b37..bebc17cdf 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordMediator.Generic.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordMediator.Generic.cs @@ -32,7 +32,7 @@ public class ActiveRecordMediator : ActiveRecordMediator where T : class /// Whatever is returned by the delegate invocation public static object Execute(NHibernateDelegate call, T instance) { - return ActiveRecordMediator.Execute(typeof(T), call, instance); + return Execute(typeof(T), call, instance); } /// @@ -96,7 +96,7 @@ public static T FindFirst(DetachedCriteria detachedCriteria, params Order[] orde /// A targetType instance or null public static T FindFirst(DetachedCriteria criteria) { - return (T)FindFirst(typeof(T),criteria); + return (T) FindFirst(typeof(T),criteria); } /// @@ -117,7 +117,7 @@ public static T FindOne(params ICriterion[] criterias) /// A targetType instance or null public static T FindOne(DetachedCriteria criteria) { - return (T)FindOne(typeof(T), criteria); + return (T) FindOne(typeof(T), criteria); } /// @@ -138,7 +138,7 @@ public static T[] FindAll() /// public static T[] FindAll(Order[] orders, params ICriterion[] criterias) { - return (T[])FindAll(typeof(T), orders, criterias); + return (T[]) FindAll(typeof(T), orders, criterias); } /// @@ -149,7 +149,7 @@ public static T[] FindAll(Order[] orders, params ICriterion[] criterias) /// public static T[] FindAll(params ICriterion[] criterias) { - return (T[])FindAll(typeof(T), criterias); + return (T[]) FindAll(typeof(T), criterias); } /// @@ -157,7 +157,7 @@ public static T[] FindAll(params ICriterion[] criterias) /// public static T[] FindAll(DetachedCriteria detachedCriteria, params Order[] orders) { - return (T[])FindAll(typeof(T), detachedCriteria, orders); + return (T[]) FindAll(typeof(T), detachedCriteria, orders); } /// @@ -179,10 +179,9 @@ public static T[] SlicedFindAll(int firstResult, int maxResults, params ICriteri /// /// Returns a portion of the query results (sliced) /// - public static T[] SlicedFindAll(int firstResult, int maxResults, - DetachedCriteria criteria) + public static T[] SlicedFindAll(int firstResult, int maxResults, DetachedCriteria criteria, params Order[] orders) { - return (T[])SlicedFindAll(typeof(T), firstResult, maxResults, criteria); + return (T[]) SlicedFindAll(typeof(T), firstResult, maxResults, orders, criteria); } /// diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordStarter.cs b/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordStarter.cs index 1b45e5b64..eda84a24b 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordStarter.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/ActiveRecordStarter.cs @@ -446,12 +446,21 @@ private static ActiveRecordModelCollection BuildModels(ISessionFactoryHolder hol throw new ActiveRecordException( String.Format("Type `{0}` is registered already", type.FullName)); } - } - else if (TypeDefinesADatabaseBoundary(type)) + } + else if (IsConfiguredAsRootType(type)) { - SetUpConfiguration(source, type, holder); - - continue; + if (TypeDefinesADatabaseBoundary(type)) + { + SetUpConfiguration(source, type, holder); + continue; + } + else + { + throw new ActiveRecordException( + string.Format( + "Type `{0}` is not a valid root type. Make sure it is abstract and inherits from ActiveRecordBase.", + type.FullName)); + } } else if (!IsActiveRecordType(type)) { @@ -480,6 +489,11 @@ private static ActiveRecordModelCollection BuildModels(ISessionFactoryHolder hol return models; } + private static bool IsConfiguredAsRootType(Type type) + { + return configSource.GetConfiguration(type) != null; + } + private static bool TypeDefinesADatabaseBoundary(Type type) { return (type.IsAbstract && !IsTypeHierarchyBase(type)); @@ -777,7 +791,7 @@ private static void CollectValidActiveRecordTypesFromAssembly(Assembly assembly, /// /// /// - public static string CreateAnotherFile(string originalFileName, int fileCount) + private static string CreateAnotherFile(string originalFileName, int fileCount) { string path = Path.GetDirectoryName(originalFileName); string fileName = Path.GetFileNameWithoutExtension(originalFileName); diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/Config/InPlaceConfigurationSource.cs b/ActiveRecord/Castle.ActiveRecord/Framework/Config/InPlaceConfigurationSource.cs index b595a0995..ed310774e 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/Config/InPlaceConfigurationSource.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/Config/InPlaceConfigurationSource.cs @@ -372,13 +372,13 @@ private static IConfiguration ConvertToConfiguration(IDictionary properties) /// The configuration private static void ProcessConfiguration(IConfiguration config) { - const string ConnectionStringKey = "hibernate.connection.connection_string"; + const string ConnectionStringKey = "connection.connection_string"; for(int i = 0; i < config.Children.Count; ++i) { IConfiguration property = config.Children[i]; - if (property.Name == ConnectionStringKey) + if (property.Name.IndexOf(ConnectionStringKey) >= 0) { String value = property.Value; Regex connectionStringRegex = new Regex(@"ConnectionString\s*=\s*\$\{(?[^}]+)\}"); diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/Config/XmlConfigurationSource.cs b/ActiveRecord/Castle.ActiveRecord/Framework/Config/XmlConfigurationSource.cs index a8224f401..299651a22 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/Config/XmlConfigurationSource.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/Config/XmlConfigurationSource.cs @@ -94,11 +94,11 @@ protected void PopulateSource(XmlNode section) SetUpNamingStrategyType(namingStrategyTypeAtt != null ? namingStrategyTypeAtt.Value : String.Empty); - SetDebugFlag(isDebug != null && "true" == isDebug.Value); + SetDebugFlag(ConvertBool(isDebug)); - SetIsLazyByDefault(lazyByDefault != null && lazyByDefault.Value == "true"); + SetIsLazyByDefault(ConvertBool(lazyByDefault)); - SetPluralizeTableNames(pluralize != null && pluralize.Value == "true"); + SetPluralizeTableNames(ConvertBool(pluralize)); SetVerifyModelsAgainstDBSchema(verifyModelsAgainstDBSchemaAtt != null && verifyModelsAgainstDBSchemaAtt.Value == "true"); @@ -178,5 +178,10 @@ protected IDictionary BuildProperties(XmlNode node) return dict; } + + private static bool ConvertBool(XmlNode boolAttrib) + { + return boolAttrib != null && "true".Equals(boolAttrib.Value, StringComparison.OrdinalIgnoreCase); + } } } diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/Internal/Visitors/XmlGenerationVisitor.cs b/ActiveRecord/Castle.ActiveRecord/Framework/Internal/Visitors/XmlGenerationVisitor.cs index afc7bfa1d..8f49aab5b 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/Internal/Visitors/XmlGenerationVisitor.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/Internal/Visitors/XmlGenerationVisitor.cs @@ -101,6 +101,7 @@ public override void VisitModel(ActiveRecordModel model) VisitNodes(model.Fields); VisitNodes(model.Properties); VisitNodes(model.BelongsTo); + VisitNodes(model.Anys); VisitNodes(model.HasMany); VisitNodes(model.HasManyToAny); VisitNodes(model.HasAndBelongsToMany); @@ -546,7 +547,7 @@ public override void VisitBelongsTo(BelongsToModel model) if (model.BelongsToAtt.Column == null) { - AppendF("", + AppendF("", MakeAtt("name", model.Property.Name), MakeAtt("access", model.BelongsToAtt.AccessString), MakeAtt("class", MakeTypeName(model.BelongsToAtt.Type)), @@ -557,6 +558,7 @@ public override void VisitBelongsTo(BelongsToModel model) WriteIfNonNull("fetch", fetch), WriteIfFalse("update", model.BelongsToAtt.Update), WriteIfFalse("insert", model.BelongsToAtt.Insert), + WriteIfNonNull("property-ref", model.BelongsToAtt.PropertyRef), WriteIfNonNull("foreign-key", model.BelongsToAtt.ForeignKey), WriteIfNonNull("not-found", notFoundMode)); Ident(); @@ -566,13 +568,14 @@ public override void VisitBelongsTo(BelongsToModel model) } else { - AppendF("", + AppendF("", MakeAtt("name", model.Property.Name), MakeAtt("access", model.BelongsToAtt.AccessString), MakeAtt("class", MakeTypeName(model.BelongsToAtt.Type)), MakeAtt("column", model.BelongsToAtt.Column), WriteIfFalse("insert", model.BelongsToAtt.Insert), WriteIfFalse("update", model.BelongsToAtt.Update), + WriteIfNonNull("property-ref", model.BelongsToAtt.PropertyRef), WriteIfTrue("not-null", model.BelongsToAtt.NotNull), WriteIfTrue("unique", model.BelongsToAtt.Unique), WriteIfNonNull("unique-key", model.BelongsToAtt.UniqueKey), @@ -1029,7 +1032,8 @@ private String MakeCustomTypeAtt(String attName, Type type) } else { - return MakeAtt(attName, type.FullName + ", " + type.Assembly.GetName().Name); + string assemblyName = new AssemblyName(type.Assembly.FullName).Name; + return MakeAtt(attName, type.FullName + ", " + assemblyName); } } @@ -1180,7 +1184,8 @@ public static String MakeTypeName(Type type) { if (type == null) return null; - return String.Format("{0}, {1}", type.FullName, type.Assembly.GetName().Name); + string assemblyName = new AssemblyName(type.Assembly.FullName).Name; + return String.Format("{0}, {1}", type.FullName, assemblyName); } #endregion diff --git a/ActiveRecord/Castle.ActiveRecord/Framework/Scopes/SessionScope.cs b/ActiveRecord/Castle.ActiveRecord/Framework/Scopes/SessionScope.cs index 983a2ddbf..105e12402 100644 --- a/ActiveRecord/Castle.ActiveRecord/Framework/Scopes/SessionScope.cs +++ b/ActiveRecord/Castle.ActiveRecord/Framework/Scopes/SessionScope.cs @@ -14,6 +14,7 @@ namespace Castle.ActiveRecord { + using System; using System.Collections.Generic; using Castle.ActiveRecord.Framework.Scopes; using NHibernate; @@ -55,9 +56,10 @@ public SessionScope(FlushAction flushAction) : base(flushAction, SessionScopeTyp } /// - /// Disposes the specified discard changes. + /// Deprecated! Disposes the specified discard changes. Please use new SessionScope(FlushAction.Never) /// /// if set to true [discard changes]. + [Obsolete("This useage is deprecated - please use new SessionScope(FlushAction.Never)")] public void Dispose(bool discardChanges) { ThreadScopeAccessor.Instance.UnRegisterScope(this); diff --git a/ActiveRecord/Changes.txt b/ActiveRecord/Changes.txt index 315f4ef8a..04fb9dacd 100644 --- a/ActiveRecord/Changes.txt +++ b/ActiveRecord/Changes.txt @@ -1,6 +1,13 @@ +- Applied patch from Steven Radack which catches invalid configuration of multiple database types. (They must be abstract). + Now AR throws an exception rather than silently using the same database. + Release Candidate 2 =================== +- Mark SessionScope.Dispose(true) overload as deprecated. FlushMode.Never is the new black. + +- Added support for property-ref to BelongsTo (many-to-one) + - Added support for CompositeUserType properties in nested classes - Added ActiveRecordBase.Asc/Desc(params string[] propertyNames) methods to allow convenient specification of sort order. diff --git a/Committers.txt b/Committers.txt index 7e85f5862..603eee504 100644 --- a/Committers.txt +++ b/Committers.txt @@ -26,6 +26,8 @@ Committers - Ernst Naezer - Marc-Andre Cournoyer - Fabian Schmied +- Dave Godfrey +- Markus Zywitza Managers ======== @@ -53,6 +55,7 @@ PMC Members - Chad Humphries - Ayende Rahien - Fabio David Batista +- Josh Robb Emeritus ======== diff --git a/Components/Binder/Castle.Components.Binder/Castle.Components.Binder-vs2005.csproj b/Components/Binder/Castle.Components.Binder/Castle.Components.Binder-vs2005.csproj index 644be868b..4629cc166 100644 --- a/Components/Binder/Castle.Components.Binder/Castle.Components.Binder-vs2005.csproj +++ b/Components/Binder/Castle.Components.Binder/Castle.Components.Binder-vs2005.csproj @@ -72,7 +72,7 @@ False - ..\..\..\..\build\net-2.0\debug\Castle.Core.dll + ..\..\..\build\net-2.0\debug\Castle.Core.dll System diff --git a/Components/Binder/Castle.Components.Binder/Castle.Components.Binder.build b/Components/Binder/Castle.Components.Binder/Castle.Components.Binder.build index 7b9a093bb..4ac46be8d 100644 --- a/Components/Binder/Castle.Components.Binder/Castle.Components.Binder.build +++ b/Components/Binder/Castle.Components.Binder/Castle.Components.Binder.build @@ -9,7 +9,7 @@ - + diff --git a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter.Tests/DictionaryAdapterFactoryTestCase.cs b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter.Tests/DictionaryAdapterFactoryTestCase.cs index 362214d5e..c0f986173 100644 --- a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter.Tests/DictionaryAdapterFactoryTestCase.cs +++ b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter.Tests/DictionaryAdapterFactoryTestCase.cs @@ -75,10 +75,10 @@ public void UpdateAdapter_Prefix_UpdatesDictionary() person.Age = 37; person.DOB = new DateTime(1970, 7, 19); person.Friends = new List(); - Assert.AreEqual("Craig", dictionary["Person_Name"]); - Assert.AreEqual(37, dictionary["Person_Age"]); - Assert.AreEqual(new DateTime(1970, 7, 19), dictionary["Person_DOB"]); - Assert.AreEqual(0, ((IList) dictionary["Person_Friends"]).Count); + Assert.AreEqual("Craig", dictionary["Name"]); + Assert.AreEqual(37, dictionary["Age"]); + Assert.AreEqual(new DateTime(1970, 7, 19), dictionary["DOB"]); + Assert.AreEqual(0, ((IList) dictionary["Friends"]).Count); } [Test] @@ -117,7 +117,7 @@ public void UpdateAdapterAndRead_PrefixOverride_Matches() IPerson person = factory.GetAdapter(dictionary); person.Name = "Craig"; - Assert.AreEqual("Craig", dictionary["Person2_Name"]); + Assert.AreEqual("Craig", dictionary["Name"]); } [Test] @@ -141,6 +141,43 @@ public void ReadAdapter_PrefixUnitialized_ReturnsDefaults() Assert.AreEqual(default(DateTime), person.DOB); Assert.AreEqual(default(IList), person.Friends); } + + [Test] + public void UpdateAdapterAndRead_WithSeveralDifferentOverridesWithDifferentPrefixes_DictionaryKeysHaveCorrectPrefixes() + { + IPersonWithDeniedInheritancePrefix person = factory.GetAdapter(dictionary); + + string name = "Ming The Merciless"; + int numberOfFeet = 2; + string hairColour = "Muddy Golden Labrador"; + string eyeColour = "The Colour Of Broken Dreams"; + int numberOfHeads = 1; + int numberOfFingers = 3; + + person.Name = name; + person.NumberOfFeet = numberOfFeet; + person.HairColour = hairColour; + person.EyeColour = eyeColour; + person.NumberOfHeads = numberOfHeads; + person.NumberOfFingers = numberOfFingers; + + string[] keys = new string[dictionary.Keys.Count]; + dictionary.Keys.CopyTo(keys, 0); + + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "Name"; })); + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "NumberOfFeet"; })); + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "Person_HairColour"; })); + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "Person2_EyeColour"; })); + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "Person2_NumberOfHeads"; })); + Assert.IsTrue(Array.Exists(keys, delegate(string key) { return key == "NumberOfFingers"; })); + + Assert.AreEqual(name, person.Name); + Assert.AreEqual(numberOfFeet, person.NumberOfFeet); + Assert.AreEqual(hairColour, person.HairColour); + Assert.AreEqual(eyeColour, person.EyeColour); + Assert.AreEqual(numberOfHeads, person.NumberOfHeads); + Assert.AreEqual(numberOfFingers, person.NumberOfFingers); + } } public interface IPerson @@ -154,18 +191,36 @@ public interface IPerson IList Friends { get; set; } } + public interface IPersonWithoutPrefix : IPerson + { + int NumberOfFeet { get; set; } + } + [DictionaryAdapterKeyPrefix("Person_")] - public interface IPersonWithPrefix : IPerson + public interface IPersonWithPrefix : IPersonWithoutPrefix { + string HairColour { get; set; } } [DictionaryAdapterKeyPrefix("Person2_")] public interface IPersonWithPrefixOverride : IPersonWithPrefix { + string EyeColour { get; set; } + } + + public interface IPersonWithPrefixOverrideFurtherOverride : IPersonWithPrefixOverride + { + int NumberOfHeads { get; set; } + } + + [DictionaryAdapterKeyPrefix("")] + public interface IPersonWithDeniedInheritancePrefix : IPersonWithPrefixOverrideFurtherOverride + { + int NumberOfFingers { get; set; } } public interface IPersonWithMethod : IPerson { void Run(); } -} \ No newline at end of file +} diff --git a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/Castle.Components.DictionaryAdapter.build b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/Castle.Components.DictionaryAdapter.build index 550f3f6b4..965044c51 100644 --- a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/Castle.Components.DictionaryAdapter.build +++ b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/Castle.Components.DictionaryAdapter.build @@ -9,7 +9,7 @@ - + diff --git a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/DictionaryAdapterFactory.cs b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/DictionaryAdapterFactory.cs index 43b1591c6..680c3a1a2 100644 --- a/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/DictionaryAdapterFactory.cs +++ b/Components/DictionaryAdapter/Castle.Components.DictionaryAdapter/DictionaryAdapterFactory.cs @@ -65,12 +65,13 @@ private static Assembly CreateAdapterAssembly(AppDomain appDomain, String ada FieldBuilder dictionaryField = CreateAdapterDictionaryField(typeBuilder); CreateAdapterConstructor(typeBuilder, dictionaryField); - String prefix = GetPropertyPrefix(); - List properties = new List(); RecursivelyDiscoverProperties(properties, typeof(T)); - properties.ForEach( - delegate(PropertyInfo propertyInfo) { CreateAdapterProperty(typeBuilder, dictionaryField, propertyInfo, prefix); }); + properties.ForEach(delegate(PropertyInfo propertyInfo) + { + String prefix = GetPropertyPrefix(propertyInfo); + CreateAdapterProperty(typeBuilder, dictionaryField, propertyInfo, prefix); + }); typeBuilder.CreateType(); @@ -230,10 +231,20 @@ private static DictionaryAdapterKeyPrefixAttribute GetDictionaryAdapterAttribute return null; } - private static String GetPropertyPrefix() + private static String GetPropertyPrefix(PropertyInfo propertyInfo) { - DictionaryAdapterKeyPrefixAttribute prefix = GetDictionaryAdapterAttribute(typeof(T)); - return (prefix != null) ? prefix.KeyPrefix : String.Empty; + List interfaces = new List(); + RecursivelyDiscoverInterfaces(interfaces, propertyInfo.ReflectedType); + + foreach (Type type in interfaces) + { + DictionaryAdapterKeyPrefixAttribute prefix = GetDictionaryAdapterAttribute(type); + + if (prefix != null) + return prefix.KeyPrefix; + } + + return String.Empty; } private static String GetAdapterAssemblyName() @@ -271,15 +282,20 @@ private static Assembly GetExistingAdapterAssembly(AppDomain appDomain, String a }); } + private static void RecursivelyDiscoverInterfaces(List interfaces, Type currentType) + { + interfaces.Add(currentType); + + Array.ForEach(currentType.GetInterfaces(), + delegate(Type parentInterface) { RecursivelyDiscoverInterfaces(interfaces, parentInterface); }); + } + private static void RecursivelyDiscoverProperties(List properties, Type currentType) { properties.AddRange(currentType.GetProperties(BindingFlags.Public | BindingFlags.Instance)); - Array.ForEach(currentType.GetInterfaces(), - delegate(Type parentInterface) - { - RecursivelyDiscoverProperties(properties, parentInterface); - }); + Array.ForEach(currentType.GetInterfaces(), + delegate(Type parentInterface) { RecursivelyDiscoverProperties(properties, parentInterface); }); } } -} \ No newline at end of file +} diff --git a/Components/DictionaryAdapter/Changes.txt b/Components/DictionaryAdapter/Changes.txt index cd5ea7c59..94cf6ec73 100644 --- a/Components/DictionaryAdapter/Changes.txt +++ b/Components/DictionaryAdapter/Changes.txt @@ -1,6 +1,8 @@ RC 4 ==== +- Applied patch from Lee Henson allowing Types to inherit or override prefixes using [DictionaryAdapterKeyPrefix()]. + - Return default(T) for value type properties not in the dictionary - Moved for CastleContrib/Castle.Tools.CodeGenerator \ No newline at end of file diff --git a/Components/EmailSender/Castle.Components.Common.EmailSender/Castle.Components.Common.EmailSender.build b/Components/EmailSender/Castle.Components.Common.EmailSender/Castle.Components.Common.EmailSender.build index 3e9cea09e..622295f92 100644 --- a/Components/EmailSender/Castle.Components.Common.EmailSender/Castle.Components.Common.EmailSender.build +++ b/Components/EmailSender/Castle.Components.Common.EmailSender/Castle.Components.Common.EmailSender.build @@ -9,7 +9,7 @@ - + diff --git a/Components/TemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.build b/Components/TemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.build index e50aec9ef..3b14c99ce 100644 --- a/Components/TemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.build +++ b/Components/TemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine/Castle.Components.Common.TemplateEngine.NVelocityTemplateEngine.build @@ -9,7 +9,7 @@ - + diff --git a/Components/TemplateEngine/Castle.Components.Common.TemplateEngine/Castle.Components.Common.TemplateEngine.build b/Components/TemplateEngine/Castle.Components.Common.TemplateEngine/Castle.Components.Common.TemplateEngine.build index fe2eee34d..fa0c901d5 100644 --- a/Components/TemplateEngine/Castle.Components.Common.TemplateEngine/Castle.Components.Common.TemplateEngine.build +++ b/Components/TemplateEngine/Castle.Components.Common.TemplateEngine/Castle.Components.Common.TemplateEngine.build @@ -9,7 +9,7 @@ - + diff --git a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateTimeValidatorTestCase.cs b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateTimeValidatorTestCase.cs index 50833cc0a..6a196f018 100644 --- a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateTimeValidatorTestCase.cs +++ b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateTimeValidatorTestCase.cs @@ -49,7 +49,7 @@ public void InvalidDate() public void ValidDate() { Assert.IsTrue(validator.IsValid(target, "01/12/2004")); - Assert.IsTrue(validator.IsValid(target, "07/16/79")); + Assert.IsTrue(validator.IsValid(target, "07/16/1979")); Assert.IsTrue(validator.IsValid(target, "2007-01-14T12:05:25")); Assert.IsTrue(validator.IsValid(target, null)); Assert.IsTrue(validator.IsValid(target, "")); diff --git a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateValidatorTestCase.cs b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateValidatorTestCase.cs index 30097667d..18e9c728f 100644 --- a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateValidatorTestCase.cs +++ b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/DateValidatorTestCase.cs @@ -50,7 +50,7 @@ public void InvalidDate() public void ValidDate() { Assert.IsTrue(validator.IsValid(target, "01/12/2004")); - Assert.IsTrue(validator.IsValid(target, "07/16/79")); + Assert.IsTrue(validator.IsValid(target, "07/16/1979")); Assert.IsTrue(validator.IsValid(target, null)); Assert.IsTrue(validator.IsValid(target, "")); } diff --git a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs index d25008b47..2d7c522e2 100644 --- a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs +++ b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateTimeValidatorTestCase.cs @@ -49,7 +49,7 @@ public void InvalidDate() public void ValidDate() { Assert.IsTrue(validator.IsValid(target, "01/12/2004")); - Assert.IsTrue(validator.IsValid(target, "07/16/79")); + Assert.IsTrue(validator.IsValid(target, "07/16/1979")); Assert.IsTrue(validator.IsValid(target, "2007-01-14T12:05:25")); Assert.IsTrue(validator.IsValid(target, null)); Assert.IsTrue(validator.IsValid(target, "")); diff --git a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs index df095c0ce..16e79c8f0 100644 --- a/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs +++ b/Components/Validator/Castle.Components.Validator.Tests/ValidatorTests/NullableDateValidatorTestCase.cs @@ -50,7 +50,7 @@ public void InvalidDate() public void ValidDate() { Assert.IsTrue(validator.IsValid(target, "01/12/2004")); - Assert.IsTrue(validator.IsValid(target, "07/16/79")); + Assert.IsTrue(validator.IsValid(target, "07/16/1979")); Assert.IsTrue(validator.IsValid(target, null)); Assert.IsTrue(validator.IsValid(target, "")); } diff --git a/Components/Validator/Castle.Components.Validator/Castle.Components.Validator.build b/Components/Validator/Castle.Components.Validator/Castle.Components.Validator.build index e08b3607d..b03e3d8bb 100644 --- a/Components/Validator/Castle.Components.Validator/Castle.Components.Validator.build +++ b/Components/Validator/Castle.Components.Validator/Castle.Components.Validator.build @@ -11,7 +11,7 @@ - + diff --git a/Components/Validator/Castle.Components.Validator/IBrowserValidationGenerator.cs b/Components/Validator/Castle.Components.Validator/IBrowserValidationGenerator.cs index 0df20bee5..1faa14fa5 100644 --- a/Components/Validator/Castle.Components.Validator/IBrowserValidationGenerator.cs +++ b/Components/Validator/Castle.Components.Validator/IBrowserValidationGenerator.cs @@ -17,35 +17,35 @@ namespace Castle.Components.Validator using System; /// - /// Abstracts an JS validation library implementation. + /// Abstracts a JS validation library implementation. /// Each implementation should map the calls to their /// own approach to enforce validation. /// public interface IBrowserValidationGenerator { /// - /// Sets the digits only. + /// Set that a field should only accept digits. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. void SetDigitsOnly(string target, string violationMessage); /// - /// Sets the number only. + /// Set that a field should only accept numbers. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. void SetNumberOnly(string target, string violationMessage); /// - /// Sets as required. + /// Sets that a field is required. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. void SetAsRequired(string target, string violationMessage); /// - /// Sets the reg exp. + /// Sets that a field value must match the specified regular expression. /// /// The target name (ie, a hint about the controller being validated) /// The reg exp. @@ -53,112 +53,112 @@ public interface IBrowserValidationGenerator void SetRegExp(string target, string regExp, string violationMessage); /// - /// Sets the email. + /// Sets that a field value must be a valid email address. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. void SetEmail(string target, string violationMessage); /// - /// Sets the length of the exact. + /// Sets that field must have an exact lenght. /// /// The target name (ie, a hint about the controller being validated) /// The length. void SetExactLength(string target, int length); /// - /// Sets the length of the exact. + /// Sets that field must have an exact lenght. /// /// The target name (ie, a hint about the controller being validated) /// The length. - /// /// The violation message. + /// The violation message. void SetExactLength(string target, int length, string violationMessage); /// - /// Sets the length of the min. + /// Sets that field must have an minimum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. + /// The minimum length. void SetMinLength(string target, int minLength); /// - /// Sets the length of the min. + /// Sets that field must have an minimum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. + /// The minimum length. /// The violation message. void SetMinLength(string target, int minLength, string violationMessage); /// - /// Sets the length of the max. + /// Sets that field must have an maximum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the max. + /// The maximum length. void SetMaxLength(string target, int maxLength); /// - /// Sets the length of the max. + /// Sets that field must have an maximum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the max. + /// The maximum length. /// The violation message. void SetMaxLength(string target, int maxLength, string violationMessage); /// - /// Sets the length range. + /// Sets that field must be between a length range. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. - /// Length of the max. + /// The minimum length. + /// The maximum length. void SetLengthRange(string target, int minLength, int maxLength); /// - /// Sets the length range. + /// Sets that field must be between a length range. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. - /// Length of the max. + /// The minimum length. + /// The maximum length. /// The violation message. void SetLengthRange(string target, int minLength, int maxLength, string violationMessage); /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. void SetValueRange(string target, int minValue, int maxValue, string violationMessage); /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. void SetValueRange(string target, decimal minValue, decimal maxValue, string violationMessage); /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. void SetValueRange(string target, DateTime minValue, DateTime maxValue, string violationMessage); /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. void SetValueRange(string target, string minValue, string maxValue, string violationMessage); /// - /// Set as same as. + /// Set that a field value must be the same as another field's value. /// /// The target name (ie, a hint about the controller being validated) /// The name of the field to compare with. @@ -166,7 +166,7 @@ public interface IBrowserValidationGenerator void SetAsSameAs(string target, string comparisonFieldName, string violationMessage); /// - /// Set as not same as. + /// Set that a field value must _not_ be the same as another field's value. /// /// The target name (ie, a hint about the controller being validated) /// The name of the field to compare with. @@ -174,7 +174,7 @@ public interface IBrowserValidationGenerator void SetAsNotSameAs(string target, string comparisonFieldName, string violationMessage); /// - /// Set date. + /// Set that a field value must be a valid date. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. diff --git a/Core/Castle.Core/Castle.Core.build b/Core/Castle.Core/Castle.Core.build index 1e32fb7bd..59d6cb97f 100644 --- a/Core/Castle.Core/Castle.Core.build +++ b/Core/Castle.Core/Castle.Core.build @@ -9,7 +9,7 @@ - + diff --git a/Core/Castle.Core/Model/ConstructorCandidateCollection.cs b/Core/Castle.Core/Model/ConstructorCandidateCollection.cs index 1a4b54292..be0b42f4d 100644 --- a/Core/Castle.Core/Model/ConstructorCandidateCollection.cs +++ b/Core/Castle.Core/Model/ConstructorCandidateCollection.cs @@ -23,6 +23,7 @@ namespace Castle.Core [Serializable] public class ConstructorCandidateCollection : ReadOnlyCollectionBase { + private bool hasAmbiguousFewerArgumentsCandidate; private ConstructorCandidate fewerArgumentsCandidate; /// @@ -34,14 +35,21 @@ public void Add(ConstructorCandidate candidate) if (fewerArgumentsCandidate == null) { fewerArgumentsCandidate = candidate; + hasAmbiguousFewerArgumentsCandidate = false; } else { - if (candidate.Constructor.GetParameters().Length < - fewerArgumentsCandidate.Constructor.GetParameters().Length) + int constructorParamCount = candidate.Constructor.GetParameters().Length; + int fewerArgumentsCount = fewerArgumentsCandidate.Constructor.GetParameters().Length; + + if (constructorParamCount < fewerArgumentsCount) { fewerArgumentsCandidate = candidate; } + else if (constructorParamCount == fewerArgumentsCount) + { + hasAmbiguousFewerArgumentsCandidate = true; + } } InnerList.Add(candidate); @@ -56,6 +64,11 @@ public ConstructorCandidate FewerArgumentsCandidate get { return fewerArgumentsCandidate; } } + public bool HasAmbiguousFewerArgumentsCandidate + { + get { return hasAmbiguousFewerArgumentsCandidate; } + } + /// /// Clears this instance. /// diff --git a/Experiments/AnakiaNet/Anakia/AnakiaTask.cs b/Experiments/AnakiaNet/Anakia/AnakiaTask.cs index b7f6f8a15..046426771 100644 --- a/Experiments/AnakiaNet/Anakia/AnakiaTask.cs +++ b/Experiments/AnakiaNet/Anakia/AnakiaTask.cs @@ -587,7 +587,14 @@ private void FixRelativePaths(DocumentNode node) elem.RemoveAttribute("relative"); } - elem.SetAttribute("src", Relativize(level, relative)); + if (elem.Name.ToLower() == "a") + { + elem.SetAttribute("href", Relativize(level, relative)); + } + else + { + elem.SetAttribute("src", Relativize(level, relative)); + } } } diff --git a/Experiments/Attic/Winforms/AssemblyResolverDialog/Castle.Components.Winforms.AssemblyResolver/Castle.Components.Winforms.AssemblyResolver.build b/Experiments/Attic/Winforms/AssemblyResolverDialog/Castle.Components.Winforms.AssemblyResolver/Castle.Components.Winforms.AssemblyResolver.build index 7e750f9ab..eed7ac514 100644 --- a/Experiments/Attic/Winforms/AssemblyResolverDialog/Castle.Components.Winforms.AssemblyResolver/Castle.Components.Winforms.AssemblyResolver.build +++ b/Experiments/Attic/Winforms/AssemblyResolverDialog/Castle.Components.Winforms.AssemblyResolver/Castle.Components.Winforms.AssemblyResolver.build @@ -9,7 +9,7 @@ - + diff --git a/Experiments/Castle.MonoRail.Generator/Castle.MonoRail.Generator.build b/Experiments/Castle.MonoRail.Generator/Castle.MonoRail.Generator.build index 486e8c697..769ab8db8 100644 --- a/Experiments/Castle.MonoRail.Generator/Castle.MonoRail.Generator.build +++ b/Experiments/Castle.MonoRail.Generator/Castle.MonoRail.Generator.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests.build b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests.build index 9840ea4fd..875163169 100644 --- a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests.build +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.Tests/Castle.Facilities.ActiveRecordIntegration.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs index ef64fcfbc..c2749de6f 100644 --- a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/ActiveRecordFacility.cs @@ -207,10 +207,10 @@ public ConfigurationSourceAdapter(IConfiguration facilityConfig) string sessionfactoryholdertype = facilityConfig.Attributes["sessionfactoryholdertype"]; string isLazyByDefault = facilityConfig.Attributes["default-lazy"]; - SetUpThreadInfoType("true" == isWeb, threadinfotype); - SetDebugFlag("true" == isDebug); + SetUpThreadInfoType(ConvertBool(isWeb), threadinfotype); + SetDebugFlag(ConvertBool(isDebug)); SetUpSessionFactoryHolderType(sessionfactoryholdertype); - SetIsLazyByDefault("true" == isLazyByDefault); + SetIsLazyByDefault(ConvertBool(isLazyByDefault)); foreach(IConfiguration config in facilityConfig.Children) { @@ -257,5 +257,10 @@ private static Type ObtainType(String typeAtt) return type; } + + private static bool ConvertBool(string boolString) + { + return "true".Equals(boolString, StringComparison.OrdinalIgnoreCase); + } } } diff --git a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.build b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.build index 5b04aa4b6..d2f290230 100644 --- a/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.build +++ b/Facilities/ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration/Castle.Facilities.ActiveRecordIntegration.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/AspectSharp/Castle.Facilities.AspectSharp.Tests/Castle.Facilities.AspectSharp.Tests.build b/Facilities/AspectSharp/Castle.Facilities.AspectSharp.Tests/Castle.Facilities.AspectSharp.Tests.build index dc6cf860e..7d28ff3b7 100644 --- a/Facilities/AspectSharp/Castle.Facilities.AspectSharp.Tests/Castle.Facilities.AspectSharp.Tests.build +++ b/Facilities/AspectSharp/Castle.Facilities.AspectSharp.Tests/Castle.Facilities.AspectSharp.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/AspectSharp/Castle.Facilities.AspectSharp/Castle.Facilities.AspectSharp.build b/Facilities/AspectSharp/Castle.Facilities.AspectSharp/Castle.Facilities.AspectSharp.build index 390d642b1..f8e8e7969 100644 --- a/Facilities/AspectSharp/Castle.Facilities.AspectSharp/Castle.Facilities.AspectSharp.build +++ b/Facilities/AspectSharp/Castle.Facilities.AspectSharp/Castle.Facilities.AspectSharp.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.Tests/Castle.Facilities.AutomaticTransactionManagement.Tests.build b/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.Tests/Castle.Facilities.AutomaticTransactionManagement.Tests.build index 42dc2c2e6..4d37e6b9c 100644 --- a/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.Tests/Castle.Facilities.AutomaticTransactionManagement.Tests.build +++ b/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.Tests/Castle.Facilities.AutomaticTransactionManagement.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.build b/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.build index 4466623de..cc2811751 100644 --- a/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.build +++ b/Facilities/AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement/Castle.Facilities.AutomaticTransactionManagement.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration.Tests/Castle.Facilities.BatchRegistration.Tests.build b/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration.Tests/Castle.Facilities.BatchRegistration.Tests.build index c9f18a92c..212747036 100644 --- a/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration.Tests/Castle.Facilities.BatchRegistration.Tests.build +++ b/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration.Tests/Castle.Facilities.BatchRegistration.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration/Castle.Facilities.BatchRegistration.build b/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration/Castle.Facilities.BatchRegistration.build index 701d85cde..d0d40d88c 100644 --- a/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration/Castle.Facilities.BatchRegistration.build +++ b/Facilities/BatchRegistration/Castle.Facilities.BatchRegistration/Castle.Facilities.BatchRegistration.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Cache/Castle.Facilities.Cache.Tests/Castle.Facilities.Cache.Tests.build b/Facilities/Cache/Castle.Facilities.Cache.Tests/Castle.Facilities.Cache.Tests.build index 1974dd897..1277cb54c 100644 --- a/Facilities/Cache/Castle.Facilities.Cache.Tests/Castle.Facilities.Cache.Tests.build +++ b/Facilities/Cache/Castle.Facilities.Cache.Tests/Castle.Facilities.Cache.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Cache/Castle.Facilities.Cache/Castle.Facilities.Cache.build b/Facilities/Cache/Castle.Facilities.Cache/Castle.Facilities.Cache.build index dbe7f43d0..c7ea272de 100644 --- a/Facilities/Cache/Castle.Facilities.Cache/Castle.Facilities.Cache.build +++ b/Facilities/Cache/Castle.Facilities.Cache/Castle.Facilities.Cache.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Db4o/Castle.Facilities.Db4oIntegration.Tests/Castle.Facilities.Db4oIntegration.Tests.build b/Facilities/Db4o/Castle.Facilities.Db4oIntegration.Tests/Castle.Facilities.Db4oIntegration.Tests.build index fe83b2f11..8a2b69b2b 100644 --- a/Facilities/Db4o/Castle.Facilities.Db4oIntegration.Tests/Castle.Facilities.Db4oIntegration.Tests.build +++ b/Facilities/Db4o/Castle.Facilities.Db4oIntegration.Tests/Castle.Facilities.Db4oIntegration.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Db4o/Castle.Facilities.Db4oIntegration/Castle.Facilities.Db4oIntegration.build b/Facilities/Db4o/Castle.Facilities.Db4oIntegration/Castle.Facilities.Db4oIntegration.build index e56d5fb48..9fc3e52fa 100644 --- a/Facilities/Db4o/Castle.Facilities.Db4oIntegration/Castle.Facilities.Db4oIntegration.build +++ b/Facilities/Db4o/Castle.Facilities.Db4oIntegration/Castle.Facilities.Db4oIntegration.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader.Tests/Castle.Facilities.DynamicLoader.Tests.build b/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader.Tests/Castle.Facilities.DynamicLoader.Tests.build index e5552707b..f6662cb3c 100644 --- a/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader.Tests/Castle.Facilities.DynamicLoader.Tests.build +++ b/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader.Tests/Castle.Facilities.DynamicLoader.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader/Castle.Facilities.DynamicLoader.build b/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader/Castle.Facilities.DynamicLoader.build index 60826ba53..dc0b711c0 100644 --- a/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader/Castle.Facilities.DynamicLoader.build +++ b/Facilities/DynamicLoader/Castle.Facilities.DynamicLoader/Castle.Facilities.DynamicLoader.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/EventWiring/Castle.Facilities.EventWiring.Tests/Castle.Facilities.EventWiring.Tests.build b/Facilities/EventWiring/Castle.Facilities.EventWiring.Tests/Castle.Facilities.EventWiring.Tests.build index 1d4439e33..f9c810704 100644 --- a/Facilities/EventWiring/Castle.Facilities.EventWiring.Tests/Castle.Facilities.EventWiring.Tests.build +++ b/Facilities/EventWiring/Castle.Facilities.EventWiring.Tests/Castle.Facilities.EventWiring.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration.Tests/Castle.Facilities.IBatisNetIntegration.Tests.build b/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration.Tests/Castle.Facilities.IBatisNetIntegration.Tests.build index 5c2bdee42..6a4a06432 100644 --- a/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration.Tests/Castle.Facilities.IBatisNetIntegration.Tests.build +++ b/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration.Tests/Castle.Facilities.IBatisNetIntegration.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration/Castle.Facilities.IBatisNetIntegration.build b/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration/Castle.Facilities.IBatisNetIntegration.build index 22c942ce6..97d74ae31 100644 --- a/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration/Castle.Facilities.IBatisNetIntegration.build +++ b/Facilities/IBatisNet/Castle.Facilities.IBatisNetIntegration/Castle.Facilities.IBatisNetIntegration.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Logging/Castle.Facilities.Logging.Tests/Castle.Facilities.Logging.Tests.build b/Facilities/Logging/Castle.Facilities.Logging.Tests/Castle.Facilities.Logging.Tests.build index bbf5ce926..7d2477902 100644 --- a/Facilities/Logging/Castle.Facilities.Logging.Tests/Castle.Facilities.Logging.Tests.build +++ b/Facilities/Logging/Castle.Facilities.Logging.Tests/Castle.Facilities.Logging.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Logging/Castle.Facilities.Logging/Castle.Facilities.Logging.build b/Facilities/Logging/Castle.Facilities.Logging/Castle.Facilities.Logging.build index f1ed11842..fa5214aff 100644 --- a/Facilities/Logging/Castle.Facilities.Logging/Castle.Facilities.Logging.build +++ b/Facilities/Logging/Castle.Facilities.Logging/Castle.Facilities.Logging.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs b/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs index 265229f66..81d993e14 100644 --- a/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs +++ b/Facilities/Logging/Castle.Facilities.Logging/LoggingFacility.cs @@ -46,22 +46,22 @@ public class LoggingFacility : AbstractFacility { private static readonly String Log4NetLoggerFactoryTypeName = "Castle.Services.Logging.Log4netIntegration.Log4netFactory," + - "Castle.Services.Logging.Log4netIntegration,Version=1.0.0.0, Culture=neutral," + + "Castle.Services.Logging.Log4netIntegration,Version=1.0.3.0, Culture=neutral," + "PublicKeyToken=407dd0808d44fbdc"; private static readonly String NLogLoggerFactoryTypeName = "Castle.Services.Logging.NLogIntegration.NLogFactory," + - "Castle.Services.Logging.NLogIntegration,Version=1.0.0.0, Culture=neutral," + + "Castle.Services.Logging.NLogIntegration,Version=1.0.3.0, Culture=neutral," + "PublicKeyToken=407dd0808d44fbdc"; private static readonly String ExtendedLog4NetLoggerFactoryTypeName = "Castle.Services.Logging.Log4netIntegration.ExtendedLog4netFactory," + - "Castle.Services.Logging.Log4netIntegration,Version=1.0.0.0, Culture=neutral," + + "Castle.Services.Logging.Log4netIntegration,Version=1.0.3.0, Culture=neutral," + "PublicKeyToken=407dd0808d44fbdc"; private static readonly String ExtendedNLogLoggerFactoryTypeName = "Castle.Services.Logging.NLogIntegration.ExtendedNLogFactory," + - "Castle.Services.Logging.NLogIntegration,Version=1.0.0.0, Culture=neutral," + + "Castle.Services.Logging.NLogIntegration,Version=1.0.3.0, Culture=neutral," + "PublicKeyToken=407dd0808d44fbdc"; private ITypeConverter converter; diff --git a/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration.Tests/Castle.Facilities.NHibernateIntegration.Tests.build b/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration.Tests/Castle.Facilities.NHibernateIntegration.Tests.build index f553f9f04..416a7e823 100644 --- a/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration.Tests/Castle.Facilities.NHibernateIntegration.Tests.build +++ b/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration.Tests/Castle.Facilities.NHibernateIntegration.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration/Castle.Facilities.NHibernateIntegration.build b/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration/Castle.Facilities.NHibernateIntegration.build index b6f612aae..5bb55a4d4 100644 --- a/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration/Castle.Facilities.NHibernateIntegration.build +++ b/Facilities/NHibernateIntegration/Castle.Facilities.NHibernateIntegration/Castle.Facilities.NHibernateIntegration.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Prevalence/Castle.Facilities.Prevalence.Tests/Castle.Facilities.Prevalence.Tests.build b/Facilities/Prevalence/Castle.Facilities.Prevalence.Tests/Castle.Facilities.Prevalence.Tests.build index 192e96180..380af694f 100644 --- a/Facilities/Prevalence/Castle.Facilities.Prevalence.Tests/Castle.Facilities.Prevalence.Tests.build +++ b/Facilities/Prevalence/Castle.Facilities.Prevalence.Tests/Castle.Facilities.Prevalence.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Prevalence/Castle.Facilities.Prevalence/Castle.Facilities.Prevalence.build b/Facilities/Prevalence/Castle.Facilities.Prevalence/Castle.Facilities.Prevalence.build index 332a29da6..bcb038b67 100644 --- a/Facilities/Prevalence/Castle.Facilities.Prevalence/Castle.Facilities.Prevalence.build +++ b/Facilities/Prevalence/Castle.Facilities.Prevalence/Castle.Facilities.Prevalence.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/AssemblyInfo.cs b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/AssemblyInfo.cs deleted file mode 100644 index 79d16d9f6..000000000 --- a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.208 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: CLSCompliantAttribute(true)] -[assembly: ComVisibleAttribute(false)] -[assembly: AssemblyTitleAttribute("Castle.Facilities.Remoting.Tests for Microsoft .NET Framework 2.0")] -[assembly: AssemblyDescriptionAttribute("")] -[assembly: AssemblyCompanyAttribute("Castle Project")] -[assembly: AssemblyProductAttribute("Castle.Facilities.Remoting.Tests")] -[assembly: AssemblyCopyrightAttribute("Castle Project, original author or authors")] -[assembly: AssemblyVersionAttribute("1.0.0.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] -[assembly: AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: AssemblyDelaySignAttribute(false)] - -#if !DOTNET2 || MONO -[assembly: AssemblyKeyFileAttribute(@"C:\dev\DotNet\castle\svn\trunk\CastleKey.snk")] -#endif diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Castle.Facilities.Remoting.Tests.build b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Castle.Facilities.Remoting.Tests.build index 446494a37..0d08e6743 100644 --- a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Castle.Facilities.Remoting.Tests.build +++ b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Castle.Facilities.Remoting.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/client_kernelcomponent_recover.xml b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/client_kernelcomponent_recover.xml index d07f11192..69a6e5444 100644 --- a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/client_kernelcomponent_recover.xml +++ b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/client_kernelcomponent_recover.xml @@ -19,9 +19,10 @@ id="calc.service" service="Castle.Facilities.Remoting.TestComponents.ICalcService, Castle.Facilities.Remoting.TestComponents" type="Castle.Facilities.Remoting.TestComponents.CalcServiceImpl, Castle.Facilities.Remoting.TestComponents" - remoteclient="recoverableComponent" - uri="calc.service.persistent.rem" /> - + remoteclient="recoverableComponent" /> + - \ No newline at end of file + diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/server_kernelcomponent_recover.xml b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/server_kernelcomponent_recover.xml index deb5609fa..b95ce83f0 100644 --- a/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/server_kernelcomponent_recover.xml +++ b/Facilities/Remoting/Castle.Facilities.Remoting.Tests/Configs/server_kernelcomponent_recover.xml @@ -21,9 +21,10 @@ startable="true" service="Castle.Facilities.Remoting.TestComponents.ICalcService, Castle.Facilities.Remoting.TestComponents" type="Castle.Facilities.Remoting.TestComponents.CalcServiceImpl, Castle.Facilities.Remoting.TestComponents" - remoteserver="recoverableComponent" - uri="calc.service.persistent.rem" /> - + remoteserver="recoverableComponent" /> + - \ No newline at end of file + diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/AssemblyInfo.cs b/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/AssemblyInfo.cs deleted file mode 100644 index 67d8a88c4..000000000 --- a/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.208 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: CLSCompliantAttribute(true)] -[assembly: ComVisibleAttribute(false)] -[assembly: AssemblyTitleAttribute("Castle.Facilities.Remoting.TestComponents for Microsoft .NET Framework 2.0")] -[assembly: AssemblyDescriptionAttribute("")] -[assembly: AssemblyCompanyAttribute("Castle Project")] -[assembly: AssemblyProductAttribute("Castle.Facilities.Remoting.TestComponents")] -[assembly: AssemblyCopyrightAttribute("Castle Project, original author or authors")] -[assembly: AssemblyVersionAttribute("1.0.0.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")] -[assembly: AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: AssemblyDelaySignAttribute(false)] - -#if !DOTNET2 || MONO -[assembly: AssemblyKeyFileAttribute(@"C:\dev\DotNet\castle\svn\trunk\CastleKey.snk")] -#endif diff --git a/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/Castle.Facilities.Remoting.TestsComponents.build b/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/Castle.Facilities.Remoting.TestsComponents.build index 332159e1e..753fdd6cd 100644 --- a/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/Castle.Facilities.Remoting.TestsComponents.build +++ b/Facilities/Remoting/Castle.Facilities.Remoting.TestsComponents/Castle.Facilities.Remoting.TestsComponents.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Remoting/Remoting.build b/Facilities/Remoting/Remoting.build new file mode 100644 index 000000000..0c9b151c4 --- /dev/null +++ b/Facilities/Remoting/Remoting.build @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/Facilities/Remoting/default.build b/Facilities/Remoting/default.build deleted file mode 100644 index 61bf3df2f..000000000 --- a/Facilities/Remoting/default.build +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Facilities/Synchronize/Castle.Facilities.Synchronize.Tests/Castle.Facilities.Synchronize.Tests.build b/Facilities/Synchronize/Castle.Facilities.Synchronize.Tests/Castle.Facilities.Synchronize.Tests.build index 099e4d53f..295ff0892 100644 --- a/Facilities/Synchronize/Castle.Facilities.Synchronize.Tests/Castle.Facilities.Synchronize.Tests.build +++ b/Facilities/Synchronize/Castle.Facilities.Synchronize.Tests/Castle.Facilities.Synchronize.Tests.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Synchronize/Castle.Facilities.Synchronize/Castle.Facilities.Synchronize.build b/Facilities/Synchronize/Castle.Facilities.Synchronize/Castle.Facilities.Synchronize.build index 7445de99d..66b197b26 100644 --- a/Facilities/Synchronize/Castle.Facilities.Synchronize/Castle.Facilities.Synchronize.build +++ b/Facilities/Synchronize/Castle.Facilities.Synchronize/Castle.Facilities.Synchronize.build @@ -9,7 +9,7 @@ - + diff --git a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Demo/Castle.Facilities.WcfIntegration.Demo.csproj b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Demo/Castle.Facilities.WcfIntegration.Demo.csproj index b7c9ba8a0..4b3d18285 100644 --- a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Demo/Castle.Facilities.WcfIntegration.Demo.csproj +++ b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Demo/Castle.Facilities.WcfIntegration.Demo.csproj @@ -29,6 +29,7 @@ 4 + False ..\..\..\build\net-2.0\debug\Castle.MicroKernel.dll diff --git a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/WcfIntegrationFixture.cs b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/WcfIntegrationFixture.cs index b70a9dab8..ff7dec934 100644 --- a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/WcfIntegrationFixture.cs +++ b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/WcfIntegrationFixture.cs @@ -41,7 +41,7 @@ public void TestInitialize() IHandler handler = windsorContainer.Kernel.GetHandler("operations"); handler.ComponentModel.Interceptors.Add(new InterceptorReference("logging")); - handler.ComponentModel.Parameters.Add("number", "42"); + handler.AddCustomDependencyValue("number", 42); Uri uri = new Uri("net.tcp://localhost/WCF.Facility"); host = new WindsorServiceHost(windsorContainer.Kernel, typeof (Operations), diff --git a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/default.build b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/default.build index 06280a197..408c00857 100644 --- a/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/default.build +++ b/Facilities/Wcf/Castle.Facilities.WcfIntegration.Tests/default.build @@ -10,7 +10,7 @@ - + diff --git a/Facilities/Wcf/Castle.Facilities.WcfIntegration/Castle.Facilities.WcfIntegration.sln b/Facilities/Wcf/Castle.Facilities.WcfIntegration/Castle.Facilities.WcfIntegration.sln new file mode 100644 index 000000000..c027429e3 --- /dev/null +++ b/Facilities/Wcf/Castle.Facilities.WcfIntegration/Castle.Facilities.WcfIntegration.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.Facilities.WcfIntegration", "Castle.Facilities.WcfIntegration.csproj", "{0F1CAD31-322E-4266-B3A0-BB424E1AE0A9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.Facilities.WcfIntegration.Demo", "..\Castle.Facilities.WcfIntegration.Demo\Castle.Facilities.WcfIntegration.Demo.csproj", "{BCDBC6AC-C85A-4564-AB6E-354262BB1A87}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.Facilities.WcfIntegration.Tests", "..\Castle.Facilities.WcfIntegration.Tests\Castle.Facilities.WcfIntegration.Tests.csproj", "{A3CF9ED0-BE9A-4534-B756-3D680D607B0C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0F1CAD31-322E-4266-B3A0-BB424E1AE0A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F1CAD31-322E-4266-B3A0-BB424E1AE0A9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F1CAD31-322E-4266-B3A0-BB424E1AE0A9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F1CAD31-322E-4266-B3A0-BB424E1AE0A9}.Release|Any CPU.Build.0 = Release|Any CPU + {BCDBC6AC-C85A-4564-AB6E-354262BB1A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCDBC6AC-C85A-4564-AB6E-354262BB1A87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCDBC6AC-C85A-4564-AB6E-354262BB1A87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCDBC6AC-C85A-4564-AB6E-354262BB1A87}.Release|Any CPU.Build.0 = Release|Any CPU + {A3CF9ED0-BE9A-4534-B756-3D680D607B0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3CF9ED0-BE9A-4534-B756-3D680D607B0C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3CF9ED0-BE9A-4534-B756-3D680D607B0C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3CF9ED0-BE9A-4534-B756-3D680D607B0C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Facilities/Wcf/Castle.Facilities.WcfIntegration/default.build b/Facilities/Wcf/Castle.Facilities.WcfIntegration/default.build index e05213d30..5f02440e7 100644 --- a/Facilities/Wcf/Castle.Facilities.WcfIntegration/default.build +++ b/Facilities/Wcf/Castle.Facilities.WcfIntegration/default.build @@ -9,7 +9,7 @@ - + diff --git a/How to build.txt b/How to build.txt index 1fb8abcf3..c5435267d 100644 --- a/How to build.txt +++ b/How to build.txt @@ -74,6 +74,14 @@ Allowing partial trust > nant -D:assembly.allow-partially-trusted-callers=true +Building the Castle MSI installer +---------------------- + + > nant installer + +You need to have installed Sandcastle, Sandcastle Help File Builder, HTML Help 1.x compiler, and WiX v3 for running task. + + More questions? =============== diff --git a/InversionOfControl/Castle.MicroKernel.Tests/Facilities/Startable/StartableFacilityTestCase.cs b/InversionOfControl/Castle.MicroKernel.Tests/Facilities/Startable/StartableFacilityTestCase.cs index 15c6c742e..ffdc54598 100644 --- a/InversionOfControl/Castle.MicroKernel.Tests/Facilities/Startable/StartableFacilityTestCase.cs +++ b/InversionOfControl/Castle.MicroKernel.Tests/Facilities/Startable/StartableFacilityTestCase.cs @@ -83,7 +83,7 @@ public void TestComponentWithNoInterface() Assert.IsTrue(component.Stopped); } - [Test, Ignore("Pending resolution")] + [Test] public void TestStartableWithCustomDependencies() { IKernel kernel = new DefaultKernel(); diff --git a/InversionOfControl/Castle.MicroKernel.Tests/RuntimeParametersTestCase.cs b/InversionOfControl/Castle.MicroKernel.Tests/RuntimeParametersTestCase.cs index be4f97a45..d74c50a33 100644 --- a/InversionOfControl/Castle.MicroKernel.Tests/RuntimeParametersTestCase.cs +++ b/InversionOfControl/Castle.MicroKernel.Tests/RuntimeParametersTestCase.cs @@ -46,7 +46,8 @@ public void Dispose() [Test] [ExpectedException(typeof(HandlerException), "Can't create component 'compb' as it has " + "dependencies to be satisfied. \r\ncompb is waiting for the following dependencies: \r\n\r\n" + - "Services: \r\n- Castle.MicroKernel.Tests.RuntimeParameters.CompC which was not registered. \r\n" + "Services: \r\n- Castle.MicroKernel.Tests.RuntimeParameters.CompC which was not registered. \r\n\r\n" + + "Keys (components with specific keys)\r\n- myArgument which was not registered. \r\n" )] public void WithoutParameters() { diff --git a/InversionOfControl/Castle.MicroKernel.Tests/UnsatisfiedDependenciesTestCase.cs b/InversionOfControl/Castle.MicroKernel.Tests/UnsatisfiedDependenciesTestCase.cs index 73909028e..e6e43899b 100644 --- a/InversionOfControl/Castle.MicroKernel.Tests/UnsatisfiedDependenciesTestCase.cs +++ b/InversionOfControl/Castle.MicroKernel.Tests/UnsatisfiedDependenciesTestCase.cs @@ -46,9 +46,10 @@ public void UnsatisfiedService() } [Test] - [ExpectedException(typeof(DependencyResolverException), - "Could not resolve non-optional dependency for 'key' (Castle.MicroKernel.Tests.ClassComponents.CustomerImpl2). Parameter 'name' type 'System.String'" - )] + [ExpectedException(typeof(HandlerException), + "Can't create component 'key' as it has dependencies to be satisfied. \r\nkey is waiting for the following dependencies: \r\n\r\n" + + "Keys (components with specific keys)\r\n- name which was not registered. \r\n- address which was not registered. \r\n" + + "- age which was not registered. \r\n")] public void UnsatisfiedConfigValues() { MutableConfiguration config = new MutableConfiguration("component"); @@ -61,6 +62,7 @@ public void UnsatisfiedConfigValues() kernel.ConfigurationStore.AddComponentConfiguration("customer", config); kernel.AddComponent("key", typeof(CustomerImpl2)); + object instance = kernel["key"]; } diff --git a/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel-vs2005.csproj b/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel-vs2005.csproj index eaeadc58f..64e4b7941 100644 --- a/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel-vs2005.csproj +++ b/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel-vs2005.csproj @@ -356,6 +356,7 @@ Code + Code diff --git a/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel.build b/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel.build index 8891169e1..6239ebf7a 100644 --- a/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel.build +++ b/InversionOfControl/Castle.MicroKernel/Castle.MicroKernel.build @@ -9,7 +9,7 @@ - + diff --git a/InversionOfControl/Castle.MicroKernel/DefaultKernel.cs b/InversionOfControl/Castle.MicroKernel/DefaultKernel.cs index 6a7f9f206..286d9d7d2 100644 --- a/InversionOfControl/Castle.MicroKernel/DefaultKernel.cs +++ b/InversionOfControl/Castle.MicroKernel/DefaultKernel.cs @@ -913,17 +913,17 @@ public virtual IHandler[] GetHandlers(Type service) { IHandler[] genericResult = NamingSubSystem.GetHandlers(service.GetGenericTypeDefinition()); - if (result.Length == 0) - { - result = genericResult; - } - else + if (result.Length > 0) { IHandler[] mergedResult = new IHandler[result.Length + genericResult.Length]; result.CopyTo(mergedResult, 0); genericResult.CopyTo(mergedResult, result.Length); result = mergedResult; } + else + { + result = genericResult; + } } // If a parent kernel exists, we merge both results @@ -931,13 +931,11 @@ public virtual IHandler[] GetHandlers(Type service) { IHandler[] parentResult = Parent.GetHandlers(service); - if (parentResult.Length != 0) + if (parentResult.Length > 0) { IHandler[] newResult = new IHandler[result.Length + parentResult.Length]; - - Array.Copy(result, newResult, result.Length); - Array.Copy(parentResult, 0, newResult, result.Length, parentResult.Length); - + result.CopyTo(newResult, 0); + parentResult.CopyTo(newResult, result.Length); result = newResult; } } diff --git a/InversionOfControl/Castle.MicroKernel/Facilities/FactorySupport/FactoryActivator.cs b/InversionOfControl/Castle.MicroKernel/Facilities/FactorySupport/FactoryActivator.cs index 402ffe5dd..9ed87687c 100644 --- a/InversionOfControl/Castle.MicroKernel/Facilities/FactorySupport/FactoryActivator.cs +++ b/InversionOfControl/Castle.MicroKernel/Facilities/FactorySupport/FactoryActivator.cs @@ -21,6 +21,7 @@ namespace Castle.Facilities.FactorySupport using Castle.MicroKernel; using Castle.MicroKernel.ComponentActivator; using Castle.MicroKernel.Facilities; + using Castle.MicroKernel.Proxy; using Castle.MicroKernel.SubSystems.Conversion; /// @@ -57,28 +58,40 @@ protected override object Instantiate(CreationContext context) factoryType.GetMethod(factoryCreate, BindingFlags.Public | BindingFlags.Static); - MethodInfo instanceCreateMethod = - factoryType.GetMethod(factoryCreate, - BindingFlags.Public | BindingFlags.Instance); - if (staticCreateMethod != null) { return Create(null, factoryId, staticCreateMethod, factoryCreate, context); } - else if (instanceCreateMethod != null) + else { object factoryInstance = Kernel[factoryId]; - return Create(factoryInstance, factoryId, instanceCreateMethod, factoryCreate, context); - } - else - { - String message = String.Format("You have specified a factory " + - "('{2}' - method to be called: {3}) " + - "for the component '{0}' {1} but we couldn't find the creation method" + - "(neither instance or static method with the name '{3}')", - Model.Name, Model.Implementation.FullName, factoryId, factoryCreate); - throw new FacilityException(message); + MethodInfo instanceCreateMethod = + factoryInstance.GetType().GetMethod(factoryCreate, + BindingFlags.Public | BindingFlags.Instance); + + if (instanceCreateMethod == null) + { + factoryInstance = ProxyUtil.GetUnproxiedInstance(factoryInstance); + + instanceCreateMethod = + factoryInstance.GetType().GetMethod(factoryCreate, + BindingFlags.Public | BindingFlags.Instance); + } + + if (instanceCreateMethod != null) + { + return Create(factoryInstance, factoryId, instanceCreateMethod, factoryCreate, context); + } + else + { + String message = String.Format("You have specified a factory " + + "('{2}' - method to be called: {3}) " + + "for the component '{0}' {1} but we couldn't find the creation method" + + "(neither instance or static method with the name '{3}')", + Model.Name, Model.Implementation.FullName, factoryId, factoryCreate); + throw new FacilityException(message); + } } } diff --git a/InversionOfControl/Castle.MicroKernel/Facilities/Remoting/RemotingInspector.cs b/InversionOfControl/Castle.MicroKernel/Facilities/Remoting/RemotingInspector.cs index 4b7aa431d..8e908066c 100644 --- a/InversionOfControl/Castle.MicroKernel/Facilities/Remoting/RemotingInspector.cs +++ b/InversionOfControl/Castle.MicroKernel/Facilities/Remoting/RemotingInspector.cs @@ -215,7 +215,7 @@ private void ConfigureClientComponent(RemotingStrategy client, Type type, Compon { CheckHasBaseURI(); - String remoteUri = BuildUri(uri); + String remoteUri = SetUriExtensionIfNeeded(uri); model.ExtendedProperties.Add("remoting.uri", remoteUri); model.ExtendedProperties.Add("remoting.remoteregistry", remoteRegistry); diff --git a/InversionOfControl/Castle.MicroKernel/Facilities/Startable/StartableFacility.cs b/InversionOfControl/Castle.MicroKernel/Facilities/Startable/StartableFacility.cs index 4770b0577..762e2bda1 100644 --- a/InversionOfControl/Castle.MicroKernel/Facilities/Startable/StartableFacility.cs +++ b/InversionOfControl/Castle.MicroKernel/Facilities/Startable/StartableFacility.cs @@ -16,64 +16,73 @@ namespace Castle.Facilities.Startable { using System; using System.Collections; - using Castle.MicroKernel; using Castle.MicroKernel.Facilities; using Castle.MicroKernel.SubSystems.Conversion; - using Castle.Core; - - public class StartableFacility : AbstractFacility + public class StartableFacility : AbstractFacility { private ArrayList waitList = new ArrayList(); - private ITypeConverter converter; - + private ITypeConverter converter; + protected override void Init() { converter = (ITypeConverter) Kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey); - Kernel.ComponentModelCreated += + Kernel.ComponentModelCreated += new ComponentModelDelegate(OnComponentModelCreated); - Kernel.ComponentRegistered += + Kernel.ComponentRegistered += new ComponentDataDelegate(OnComponentRegistered); } private void OnComponentModelCreated(ComponentModel model) { - bool startable = + bool startable = CheckIfComponentImplementsIStartable(model) || HasStartableAttributeSet(model); model.ExtendedProperties["startable"] = startable; if (startable) { - model.LifecycleSteps.Add( - LifecycleStepType.Commission, StartConcern.Instance ); - model.LifecycleSteps.Add( - LifecycleStepType.Decommission, StopConcern.Instance ); + model.LifecycleSteps.Add( + LifecycleStepType.Commission, StartConcern.Instance); + model.LifecycleSteps.Add( + LifecycleStepType.Decommission, StopConcern.Instance); } } - private void OnComponentRegistered(String key, IHandler handler) + private void OnComponentRegistered(String key, IHandler handler) { bool startable = (bool) handler.ComponentModel.ExtendedProperties["startable"]; - + if (startable) { if (handler.CurrentState == HandlerState.WaitingDependency) { - waitList.Add( handler ); + AddHandlerToWaitingList(handler); } else { - Start( key ); + Start(key); } } CheckWaitingList(); } + private void OnHandlerStateChanged(object source, EventArgs args) + { + CheckWaitingList(); + } + + private void AddHandlerToWaitingList(IHandler handler) + { + waitList.Add(handler); + + handler.OnHandlerStateChanged += new HandlerStateDelegate(OnHandlerStateChanged); + } + /// /// For each new component registered, /// some components in the WaitingDependency @@ -81,7 +90,7 @@ private void OnComponentRegistered(String key, IHandler handler) /// private void CheckWaitingList() { - IHandler[] handlers = (IHandler[]) waitList.ToArray( typeof(IHandler) ); + IHandler[] handlers = (IHandler[]) waitList.ToArray(typeof(IHandler)); IList validList = new ArrayList(); @@ -91,12 +100,14 @@ private void CheckWaitingList() { validList.Add(handler); waitList.Remove(handler); + + handler.OnHandlerStateChanged -= new HandlerStateDelegate(OnHandlerStateChanged); } } foreach(IHandler handler in validList) { - Start( handler.ComponentModel.Name ); + Start(handler.ComponentModel.Name); } } @@ -109,26 +120,26 @@ private void Start(String key) object instance = Kernel[key]; } - private bool CheckIfComponentImplementsIStartable(ComponentModel model) - { - return typeof(IStartable).IsAssignableFrom(model.Implementation); - } - + private bool CheckIfComponentImplementsIStartable(ComponentModel model) + { + return typeof(IStartable).IsAssignableFrom(model.Implementation); + } + private bool HasStartableAttributeSet(ComponentModel model) - { - bool result = false; - - if (model.Configuration != null) - { - String startable = model.Configuration.Attributes["startable"]; - + { + bool result = false; + + if (model.Configuration != null) + { + String startable = model.Configuration.Attributes["startable"]; + if (startable != null) { result = (bool) converter.PerformConversion(startable, typeof(bool)); } - } - - return result; - } + } + + return result; + } } -} +} \ No newline at end of file diff --git a/InversionOfControl/Castle.MicroKernel/Handlers/AbstractHandler.cs b/InversionOfControl/Castle.MicroKernel/Handlers/AbstractHandler.cs index 1eaa67621..d4790a319 100644 --- a/InversionOfControl/Castle.MicroKernel/Handlers/AbstractHandler.cs +++ b/InversionOfControl/Castle.MicroKernel/Handlers/AbstractHandler.cs @@ -406,6 +406,12 @@ protected virtual void EnsureDependenciesCanBeSatisfied() { AddDependency(dependency); } + else if (dependency.DependencyType == DependencyType.Parameter && + !ComponentModel.Constructors.HasAmbiguousFewerArgumentsCandidate && + !ComponentModel.Parameters.Contains(dependency.DependencyKey)) + { + AddDependency(dependency); + } } if (state == HandlerState.Valid) @@ -460,7 +466,7 @@ protected void AddDependency(DependencyModel dependency) DependenciesByService.Add(dependency.TargetType, dependency); } - else + else if (!DependenciesByKey.Contains(dependency.DependencyKey)) { DependenciesByKey.Add(dependency.DependencyKey, dependency); } diff --git a/InversionOfControl/Castle.MicroKernel/ModelBuilder/DefaultComponentModelBuilder.cs b/InversionOfControl/Castle.MicroKernel/ModelBuilder/DefaultComponentModelBuilder.cs index 9a699615f..7935bae93 100644 --- a/InversionOfControl/Castle.MicroKernel/ModelBuilder/DefaultComponentModelBuilder.cs +++ b/InversionOfControl/Castle.MicroKernel/ModelBuilder/DefaultComponentModelBuilder.cs @@ -109,11 +109,11 @@ protected virtual void InitializeContributors() { AddContributor(new GenericInspector()); AddContributor(new ConfigurationModelInspector()); + AddContributor(new ConfigurationParametersInspector()); AddContributor(new LifestyleModelInspector()); AddContributor(new ConstructorDependenciesModelInspector()); AddContributor(new PropertiesDependenciesModelInspector()); AddContributor(new LifecycleModelInspector()); - AddContributor(new ConfigurationParametersInspector()); AddContributor(new InterceptorInspector()); AddContributor(new ComponentActivatorInspector()); AddContributor(new ComponentProxyInspector()); diff --git a/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ComponentProxyInspector.cs b/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ComponentProxyInspector.cs index 33e7794bf..3e9c1a7fe 100644 --- a/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ComponentProxyInspector.cs +++ b/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ComponentProxyInspector.cs @@ -124,6 +124,7 @@ private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ProxyOptions options = ProxyUtil.ObtainProxyOptions(model, true); options.UseSingleInterfaceProxy = behavior.UseSingleInterfaceProxy; + options.UseMarshalByRefAsBaseClass = behavior.UseMarshalByRefProxy; options.AddAdditionalInterfaces(behavior.AdditionalInterfaces); } diff --git a/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ConstructorDependenciesModelInspector.cs b/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ConstructorDependenciesModelInspector.cs index 1f75befaa..541ceb89b 100644 --- a/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ConstructorDependenciesModelInspector.cs +++ b/InversionOfControl/Castle.MicroKernel/ModelBuilder/Inspectors/ConstructorDependenciesModelInspector.cs @@ -18,6 +18,7 @@ namespace Castle.MicroKernel.ModelBuilder.Inspectors using System.Reflection; using Castle.Core; using Castle.MicroKernel.SubSystems.Conversion; + using Castle.MicroKernel.Util; /// /// This implementation of @@ -53,12 +54,11 @@ public virtual void ProcessModel(IKernel kernel, ComponentModel model) // We register each public constructor // and let the ComponentFactory select an // eligible amongst the candidates later - - model.Constructors.Add(CreateConstructorCandidate(constructor)); + model.Constructors.Add(CreateConstructorCandidate(model, constructor)); } } - protected virtual ConstructorCandidate CreateConstructorCandidate(ConstructorInfo constructor) + protected virtual ConstructorCandidate CreateConstructorCandidate(ComponentModel model, ConstructorInfo constructor) { ParameterInfo[] parameters = constructor.GetParameters(); @@ -77,10 +77,22 @@ protected virtual ConstructorCandidate CreateConstructorCandidate(ConstructorInf dependencies[i] = new DependencyModel( DependencyType.Parameter, parameter.Name, paramType, false); } - else + else { - dependencies[i] = new DependencyModel( - DependencyType.Service, parameter.Name, paramType, false); + ParameterModel modelParameter = model.Parameters[parameter.Name]; + + if (modelParameter != null && ReferenceExpressionUtil.IsReference(modelParameter.Value)) + { + String key = ReferenceExpressionUtil.ExtractComponentKey(modelParameter.Value); + + dependencies[i] = new DependencyModel( + DependencyType.ServiceOverride, key, paramType, false); + } + else + { + dependencies[i] = new DependencyModel( + DependencyType.Service, parameter.Name, paramType, false); + } } } diff --git a/InversionOfControl/Castle.MicroKernel/Proxy/ProxyUtil.cs b/InversionOfControl/Castle.MicroKernel/Proxy/ProxyUtil.cs index 8d5a89738..8f56c9ef8 100644 --- a/InversionOfControl/Castle.MicroKernel/Proxy/ProxyUtil.cs +++ b/InversionOfControl/Castle.MicroKernel/Proxy/ProxyUtil.cs @@ -14,7 +14,9 @@ namespace Castle.MicroKernel.Proxy { + using System.Runtime.Remoting; using Castle.Core; + using Castle.Core.Interceptor; /// /// Helper support for proxy configuration. @@ -39,5 +41,20 @@ public static ProxyOptions ObtainProxyOptions(ComponentModel model, bool createO return options; } + + public static object GetUnproxiedInstance(object instance) + { + if (!RemotingServices.IsTransparentProxy(instance)) + { + IProxyTargetAccessor accessor = instance as IProxyTargetAccessor; + + if (accessor != null) + { + instance = accessor.DynProxyGetTarget(); + } + } + + return instance; + } } } \ No newline at end of file diff --git a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/ComponentModelConverter.cs b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/ComponentModelConverter.cs new file mode 100644 index 000000000..934191be5 --- /dev/null +++ b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/ComponentModelConverter.cs @@ -0,0 +1,56 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.MicroKernel.SubSystems.Conversion +{ + using System; + using System.ComponentModel; + using Castle.Core.Configuration; + + /// + /// Attempts to utilize an existing for conversion + /// + [Serializable] + public class ComponentModelConverter : AbstractTypeConverter + { + public override bool CanHandleType(Type type) + { + TypeConverter converter = TypeDescriptor.GetConverter(type); + return (converter != null && converter.CanConvertFrom(typeof(String))); + } + + public override object PerformConversion(String value, Type targetType) + { + TypeConverter converter = TypeDescriptor.GetConverter(targetType); + + try + { + return converter.ConvertFrom(value); + } + catch(Exception ex) + { + String message = String.Format( + "Could not convert from '{0}' to {1}", + value, targetType.FullName); + + throw new ConverterException(message, ex); + } + } + + public override object PerformConversion(IConfiguration configuration, Type targetType) + { + return PerformConversion(configuration.Value, targetType); + } + } +} \ No newline at end of file diff --git a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/DefaultComplexConverter.cs b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/DefaultComplexConverter.cs index 0df1193e8..37a699ada 100644 --- a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/DefaultComplexConverter.cs +++ b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/DefaultComplexConverter.cs @@ -55,6 +55,8 @@ public override object PerformConversion(string value, Type targetType) /// private object CreateInstance(Type type, IConfiguration configuration) { + type = ObtainImplementation(type, configuration); + ConstructorInfo constructor = ChooseConstructor(type); object[] args = null; @@ -67,6 +69,33 @@ private object CreateInstance(Type type, IConfiguration configuration) return instance; } + private Type ObtainImplementation(Type type, IConfiguration configuration) + { + String typeNode = configuration.Attributes["type"]; + + if (String.IsNullOrEmpty(typeNode)) + { + if (type.IsInterface) + { + throw new ConverterException("A type attribute must be specified for interfaces"); + } + + return type; + } + + Type implType = (Type) Context.Composition.PerformConversion(typeNode, typeof(Type)); + + if (!type.IsAssignableFrom(implType)) + { + String message = String.Format("Type {0} is not assignable to {1}", + implType.FullName, type.FullName); + + throw new ConverterException(message); + } + + return implType; + } + /// /// Chooses the first non default constructor. Throws an exception if more than /// one non default constructor is found diff --git a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/Generics/GenericListConverter.cs b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/Generics/GenericListConverter.cs index 5ae85a747..65d5da87a 100644 --- a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/Generics/GenericListConverter.cs +++ b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/Converters/Generics/GenericListConverter.cs @@ -87,7 +87,7 @@ public object ConvertConfigurationToCollection(IConfiguration configuration) foreach(IConfiguration itemConfig in configuration.Children) { - T item = (T) parent.Context.Composition.PerformConversion(itemConfig.Value, typeof(T)); + T item = (T) parent.Context.Composition.PerformConversion(itemConfig, typeof(T)); list.Add(item); } diff --git a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/ConvertibleAttribute.cs b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/ConvertibleAttribute.cs index 9ba9f09ce..5ba4e80f4 100644 --- a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/ConvertibleAttribute.cs +++ b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/ConvertibleAttribute.cs @@ -19,7 +19,7 @@ namespace Castle.MicroKernel.SubSystems.Conversion /// /// Declares a type as being convertible by a and optionally defines the converter to be used /// - [System.AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)] + [System.AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)] public class ConvertibleAttribute : Attribute { private readonly Type converterType; diff --git a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs index ed955ba8f..c696b5048 100644 --- a/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs +++ b/InversionOfControl/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs @@ -51,6 +51,7 @@ protected virtual void InitDefaultConverters() Add(new ArrayConverter()); Add(new ComponentConverter()); Add(new AttributeAwareConverter()); + Add(new ComponentModelConverter()); } #region IConversionManager Members diff --git a/InversionOfControl/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2005.csproj b/InversionOfControl/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2005.csproj index e1316606d..002b61afd 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2005.csproj +++ b/InversionOfControl/Castle.Windsor.Tests/Castle.Windsor.Tests-vs2005.csproj @@ -221,6 +221,7 @@ Code + diff --git a/InversionOfControl/Castle.Windsor.Tests/Components/CalculatorServiceWithProxyBehavior.cs b/InversionOfControl/Castle.Windsor.Tests/Components/CalculatorServiceWithProxyBehavior.cs index 800e664b3..371cc48e3 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Components/CalculatorServiceWithProxyBehavior.cs +++ b/InversionOfControl/Castle.Windsor.Tests/Components/CalculatorServiceWithProxyBehavior.cs @@ -64,4 +64,20 @@ public void Dispose() { } } + + /// + /// Summary description for CalculatorServiceWithAttributes. + /// + [Interceptor(typeof(StandardInterceptor))] + [ComponentProxyBehavior(UseMarshalByRefProxy = true)] + public class CalculatorServiceWithMarshalByRefProxyBehavior : CalculatorService, IDisposable + { + public CalculatorServiceWithMarshalByRefProxyBehavior() + { + } + + public void Dispose() + { + } + } } \ No newline at end of file diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/FactorySupportTestCase.cs b/InversionOfControl/Castle.Windsor.Tests/Proxy/FactorySupportTestCase.cs new file mode 100644 index 000000000..5c25569af --- /dev/null +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/FactorySupportTestCase.cs @@ -0,0 +1,67 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +namespace Castle.Windsor.Tests.Proxy +{ + using System; + using Castle.Core; + using Castle.Core.Configuration; + using Castle.Core.Interceptor; + using Castle.Facilities.FactorySupport; + using Castle.Windsor.Tests.Components; + using NUnit.Framework; + + [TestFixture] + public class FactorySupportTestCase + { + private WindsorContainer container; + + [SetUp] + public void SetUp() + { + container = new WindsorContainer(); + } + + [Test] + public void FactorySupport_UsingProxiedFactory_WorksFine() + { + container.AddFacility("factories", new FactorySupportFacility()); + container.AddComponent("standard.interceptor", typeof(StandardInterceptor)); + container.AddComponent("factory", typeof(CalulcatorFactory)); + + AddComponent("calculator", typeof(ICalcService), typeof(CalculatorService), "Create"); + + ICalcService service = (ICalcService) container["calculator"]; + + Assert.IsNotNull(service); + } + + private void AddComponent(string key, Type service, Type type, string factoryMethod) + { + MutableConfiguration config = new MutableConfiguration(key); + config.Attributes["factoryId"] = "factory"; + config.Attributes["factoryCreate"] = factoryMethod; + container.Kernel.ConfigurationStore.AddComponentConfiguration(key, config); + container.Kernel.AddComponent(key, service, type); + } + + [Interceptor(typeof(StandardInterceptor))] + public class CalulcatorFactory + { + public virtual ICalcService Create() + { + return new CalculatorService(); + } + } + } +} diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorInvalidTestCase.cs b/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorInvalidTestCase.cs index cfa41dd88..dc5cd373d 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorInvalidTestCase.cs +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorInvalidTestCase.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Castle.Windsor.Tests +namespace Castle.Windsor.Tests.Proxy { using System.Configuration; using Castle.Core.Interceptor; diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorTestCase.cs b/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorTestCase.cs index b60bce446..773166707 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorTestCase.cs +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/ProxyBehaviorTestCase.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Castle.Windsor.Tests +namespace Castle.Windsor.Tests.Proxy { using System; using Castle.Core.Interceptor; @@ -94,5 +94,20 @@ public void NoSingleInterfaceProxyWithAttribute() Assert.IsNotNull(calcService); Assert.IsTrue(calcService is IDisposable, "Service proxy should expose the IDisposable interface"); } + + [Test] + public void RequestMarshalByRefProxyWithAttribute() + { + IWindsorContainer container = new WindsorContainer(); + + container.AddComponent("standard.interceptor", typeof(StandardInterceptor)); + container.AddComponent("useMarshal", typeof(ICalcService), typeof(CalculatorServiceWithMarshalByRefProxyBehavior)); + + ICalcService calcService = (ICalcService)container["useMarshal"]; + Assert.IsNotNull(calcService); + Assert.IsFalse(calcService is CalculatorServiceWithMarshalByRefProxyBehavior, "Service proxy should not expose CalculatorServiceWithMarshalByRefProxyBehavior"); + Assert.IsTrue(calcService is MarshalByRefObject, "Service proxy should expose MarshalByRefObject"); + Assert.IsTrue(calcService is IDisposable, "Service proxy should expose the IDisposable interface"); + } } } \ No newline at end of file diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/TypedFactoryFacilityTestCase.cs b/InversionOfControl/Castle.Windsor.Tests/Proxy/TypedFactoryFacilityTestCase.cs index 7a87a7eb4..1c7fee6f1 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Proxy/TypedFactoryFacilityTestCase.cs +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/TypedFactoryFacilityTestCase.cs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Castle.Windsor.Tests +namespace Castle.Windsor.Tests.Proxy { using System; using Castle.Core.Interceptor; diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactory.xml b/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactory.xml index 50e0e6e07..1b942cede 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactory.xml +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactory.xml @@ -7,7 +7,7 @@ diff --git a/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactoryCreateWithoutId.xml b/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactoryCreateWithoutId.xml index 626e4f1af..5efa1e3a9 100644 --- a/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactoryCreateWithoutId.xml +++ b/InversionOfControl/Castle.Windsor.Tests/Proxy/typedFactoryCreateWithoutId.xml @@ -7,7 +7,7 @@ diff --git a/InversionOfControl/Castle.Windsor/Castle.Windsor.build b/InversionOfControl/Castle.Windsor/Castle.Windsor.build index cd9ce7850..5f47930db 100644 --- a/InversionOfControl/Castle.Windsor/Castle.Windsor.build +++ b/InversionOfControl/Castle.Windsor/Castle.Windsor.build @@ -9,7 +9,7 @@ - + diff --git a/InversionOfControl/Changes.txt b/InversionOfControl/Changes.txt index b40710cf3..9b505ca76 100644 --- a/InversionOfControl/Changes.txt +++ b/InversionOfControl/Changes.txt @@ -1,6 +1,21 @@ RC 4 ==== +- Fixed IOC-80 + "StartableFacility erroneously tries to start a component before + RegisterCustomDependency can be called" + +- Added ComponentModelConverter to utilize System.ComponentModel TypeConverters + Very useful for converting things like Fonts and Colors + +- Updated DefaultComplexConverter to support interfaces and derived types + +- Fixed IOC-96 + "FactorySupport fails to create components if the factory instance is a proxy" + +- Fixed IOC-93 + "GenericListConverter does not handle service overrides properly" + - Fixed IOC-91 "ContextBoundObject's context is not bound when object is created by MicroKernel" diff --git a/MonoRail/Castle.MonoRail-vs2005.sln b/MonoRail/Castle.MonoRail-vs2005.sln index 11ddc1fa6..58022986f 100644 --- a/MonoRail/Castle.MonoRail-vs2005.sln +++ b/MonoRail/Castle.MonoRail-vs2005.sln @@ -67,10 +67,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.ActiveRecor EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{69461FDF-3FA6-4ABE-BB5B-80DEA06225E0}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(SolutionItems) = preProject Changes.txt = Changes.txt License.txt = License.txt @@ -80,51 +76,55 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{3C5EC9DD-79E4-4C13-ADAE-DA7416E6DAEA}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{3C5EC9DD-79E4-4C13-ADAE-DA7416E6DAEA}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Sites", "Test Sites", "{A287E189-50B7-4EA3-A683-135F9F54ACF9}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Sites", "Test Sites", "{A287E189-50B7-4EA3-A683-135F9F54ACF9}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{4CA9E7D1-3BEF-4B35-A771-EFBD1FC52BD6}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{4CA9E7D1-3BEF-4B35-A771-EFBD1FC52BD6}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{9264F1C2-88DA-497B-AD12-99AC46B0292B}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{9264F1C2-88DA-497B-AD12-99AC46B0292B}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.ActiveRecordScaffold-vs2005", "Castle.MonoRail.ActiveRecordScaffold\Castle.MonoRail.ActiveRecordScaffold-vs2005.csproj", "{8C6EA891-66AF-4F48-A2CB-98669D5E7AA9}" ProjectSection(WebsiteProperties) = preProject @@ -157,25 +157,25 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSiteBrail", "TestSiteBr EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_ Notes _", "_ Notes _", "{7EDBC715-8D03-4689-A479-16D55E419B5E}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(SolutionItems) = preProject Changes.txt = Changes.txt EndProjectSection ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ViewEngines", "ViewEngines", "{2A065720-7939-49FF-A9E1-6DCC3ED71F18}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" Release.AspNetCompiler.Debug = "False" EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ViewEngines", "ViewEngines", "{2A065720-7939-49FF-A9E1-6DCC3ED71F18}" ProjectSection(FolderStartupServices) = postProject {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} = {B4F97281-0DBD-4835-9ED8-7DFB966E87FF} EndProjectSection + ProjectSection(WebsiteProperties) = preProject + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.Debug = "False" + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.TransformFilters-vs2005", "Castle.MonoRail.TransformFilters\Castle.MonoRail.TransformFilters-vs2005.csproj", "{BB60A834-F753-4091-9709-676B6A9F0188}" ProjectSection(WebsiteProperties) = preProject @@ -219,6 +219,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.Components.Binder.Te Release.AspNetCompiler.Debug = "False" EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.MonoRail.TestSupport.Tests-vs2005", "Castle.MonoRail.TestSupport.Tests\Castle.MonoRail.TestSupport.Tests-vs2005.csproj", "{27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -317,6 +319,10 @@ Global {57ED99CE-404E-4029-A98A-2159E2E70E22}.Debug|Any CPU.Build.0 = Debug|Any CPU {57ED99CE-404E-4029-A98A-2159E2E70E22}.Release|Any CPU.ActiveCfg = Release|Any CPU {57ED99CE-404E-4029-A98A-2159E2E70E22}.Release|Any CPU.Build.0 = Release|Any CPU + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -331,6 +337,7 @@ Global {CE8B7A9D-2BA7-4E95-97BC-5829D61468C5} = {FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7} {86CAA470-BFAC-4D14-B4C2-C5BEFE3AD003} = {FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7} {57ED99CE-404E-4029-A98A-2159E2E70E22} = {FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7} + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9} = {FE6CCE8D-3C80-4299-A8F1-FF2B4FC812C7} {824EC872-2992-4518-8C41-4F87640D752A} = {A287E189-50B7-4EA3-A683-135F9F54ACF9} {22432F75-FD21-474A-AB8F-43100DE79FDB} = {A287E189-50B7-4EA3-A683-135F9F54ACF9} {7439F3D3-5F1B-4D03-ADE1-8EB85F711A53} = {A287E189-50B7-4EA3-A683-135F9F54ACF9} diff --git a/MonoRail/Castle.MonoRail.ActiveRecordScaffold/Castle.MonoRail.ActiveRecordScaffold.build b/MonoRail/Castle.MonoRail.ActiveRecordScaffold/Castle.MonoRail.ActiveRecordScaffold.build index d484c5658..5710ddf66 100644 --- a/MonoRail/Castle.MonoRail.ActiveRecordScaffold/Castle.MonoRail.ActiveRecordScaffold.build +++ b/MonoRail/Castle.MonoRail.ActiveRecordScaffold/Castle.MonoRail.ActiveRecordScaffold.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.ActiveRecordSupport/Castle.MonoRail.ActiveRecordSupport.build b/MonoRail/Castle.MonoRail.ActiveRecordSupport/Castle.MonoRail.ActiveRecordSupport.build index a866c06ce..aafd9ded4 100644 --- a/MonoRail/Castle.MonoRail.ActiveRecordSupport/Castle.MonoRail.ActiveRecordSupport.build +++ b/MonoRail/Castle.MonoRail.ActiveRecordSupport/Castle.MonoRail.ActiveRecordSupport.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/PaginationHelperTestCase.cs b/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/PaginationHelperTestCase.cs index 5c4463145..3c8b414d2 100644 --- a/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/PaginationHelperTestCase.cs +++ b/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/PaginationHelperTestCase.cs @@ -231,5 +231,130 @@ public void UsageWithGenerics() Assert.IsFalse(page.HasNext); Assert.IsTrue(page.HasPrevious); } + + + [Test] + public void CustomPaginationForObjectCollection() + { + IList items = new ArrayList(); + + /* First page */ + items.Add("1"); + items.Add("2"); + items.Add("3"); + + IPaginatedPage page = PaginationHelper.CreateCustomPage(items, 3, 1, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(1, page.FirstItem); + Assert.AreEqual(3, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsFalse(page.HasFirst); + Assert.IsTrue(page.HasLast); + Assert.IsTrue(page.HasNext); + Assert.IsFalse(page.HasPrevious); + + /* Second page */ + items.Clear(); + items.Add("4"); + items.Add("5"); + items.Add("6"); + + page = PaginationHelper.CreateCustomPage(items, 3, 2, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(4, page.FirstItem); + Assert.AreEqual(6, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsTrue(page.HasFirst); + Assert.IsTrue(page.HasLast); + Assert.IsTrue(page.HasNext); + Assert.IsTrue(page.HasPrevious); + + /* Third page, partial */ + items.Clear(); + items.Add("7"); + items.Add("8"); + + page = PaginationHelper.CreateCustomPage(items, 3, 3, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(7, page.FirstItem); + Assert.AreEqual(8, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsTrue(page.HasFirst); + Assert.IsFalse(page.HasLast); + Assert.IsFalse(page.HasNext); + Assert.IsTrue(page.HasPrevious); + } + + [Test] + public void CustomPaginationForGenericCollection() + { + IList items = new List(); + + /* First page */ + items.Add("1"); + items.Add("2"); + items.Add("3"); + + IPaginatedPage page = PaginationHelper.CreateCustomPage(items, 3, 1, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(1, page.FirstItem); + Assert.AreEqual(3, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsFalse(page.HasFirst); + Assert.IsTrue(page.HasLast); + Assert.IsTrue(page.HasNext); + Assert.IsFalse(page.HasPrevious); + + /* Second page */ + items.Clear(); + items.Add("4"); + items.Add("5"); + items.Add("6"); + + page = PaginationHelper.CreateCustomPage(items, 3, 2, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(4, page.FirstItem); + Assert.AreEqual(6, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsTrue(page.HasFirst); + Assert.IsTrue(page.HasLast); + Assert.IsTrue(page.HasNext); + Assert.IsTrue(page.HasPrevious); + + /* Third page, partial */ + items.Clear(); + items.Add("7"); + items.Add("8"); + + page = PaginationHelper.CreateCustomPage(items, 3, 3, 8); + + Assert.IsNotNull(page); + + Assert.AreEqual(7, page.FirstItem); + Assert.AreEqual(8, page.LastItem); + Assert.AreEqual(8, page.TotalItems); + + Assert.IsTrue(page.HasFirst); + Assert.IsFalse(page.HasLast); + Assert.IsFalse(page.HasNext); + Assert.IsTrue(page.HasPrevious); + } + + } } diff --git a/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/TextHelperTestCase.cs b/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/TextHelperTestCase.cs index 692aed2d8..1efe417f4 100644 --- a/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/TextHelperTestCase.cs +++ b/MonoRail/Castle.MonoRail.Framework.Tests/Helpers/TextHelperTestCase.cs @@ -16,16 +16,14 @@ namespace Castle.MonoRail.Framework.Tests.Helpers { using System; using System.Collections; - using Castle.MonoRail.Framework.Helpers; - using NUnit.Framework; [TestFixture] public class TextHelperTestCase { - private TextHelper helper = new TextHelper(); + private TextHelper helper = new TextHelper(); [Test] [ExpectedException(typeof(ArgumentNullException))] @@ -40,82 +38,82 @@ public void PascalCaseToWord_SeparatesWordsBasedOnCase() Assert.AreEqual("Sequence Info", TextHelper.PascalCaseToWord("SequenceInfo")); } - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void ToSentenceWithNull() - { - string sentence = helper.ToSentence(null); - Assert.AreEqual("", sentence); - } - - [Test] - public void ToSentenceWithStringArrayNoElements() - { - string sentence = helper.ToSentence(new string[0]); - Assert.AreEqual("", sentence); - } + [Test] + [ExpectedException(typeof(ArgumentNullException))] + public void ToSentenceWithNull() + { + string sentence = helper.ToSentence(null); + Assert.AreEqual("", sentence); + } + + [Test] + public void ToSentenceWithStringArrayNoElements() + { + string sentence = helper.ToSentence(new string[0]); + Assert.AreEqual("", sentence); + } + + [Test] + public void ToSentenceWithStringArrayOneElement() + { + string sentence = helper.ToSentence(new string[] {"apple"}); + Assert.AreEqual("apple", sentence); + } + + [Test] + public void ToSentenceWithStringArrayTwoElements() + { + string sentence = helper.ToSentence(new string[] {"apple", "banana"}); + Assert.AreEqual("apple and banana", sentence); + } + + [Test] + public void ToSentenceWithStringArrayThreeElements() + { + string sentence = helper.ToSentence(new string[] {"apple", "banana", "mango"}); + Assert.AreEqual("apple, banana and mango", sentence); + } [Test] - public void ToSentenceWithStringArrayOneElement() + public void ToSentenceWithSpecifiedConnector() { - string sentence = helper.ToSentence(new string[] { "apple" }); - Assert.AreEqual("apple", sentence); - } - - [Test] - public void ToSentenceWithStringArrayTwoElements() - { - string sentence = helper.ToSentence(new string[] { "apple", "banana" }); - Assert.AreEqual("apple and banana", sentence); - } - - [Test] - public void ToSentenceWithStringArrayThreeElements() - { - string sentence = helper.ToSentence(new string[] { "apple", "banana", "mango" }); - Assert.AreEqual("apple, banana and mango", sentence); - } - - [Test] - public void ToSentenceWithSpecifiedConnector() - { - string sentence = helper.ToSentence(new string[] { "apple", "banana", "mango" }, "y"); - Assert.AreEqual("apple, banana y mango", sentence); - } + string sentence = helper.ToSentence(new string[] {"apple", "banana", "mango"}, "y"); + Assert.AreEqual("apple, banana y mango", sentence); + } [Test] public void ToSentenceWithCommaBeforeConnectorSpecified() { - string sentence = helper.ToSentence(new string[] { "apple", "banana", "mango" }, TextHelper.DefaultConnector, false); - Assert.AreEqual("apple, banana, and mango", sentence); - } - - private class Person - { - private readonly string _firstName; - private readonly string _lastName; - - public Person(string firstName, string lastName) - { - _firstName = firstName; - _lastName = lastName; - } - - public override string ToString() - { - return _firstName + " " + _lastName; - } - } - - [Test] - public void ToSentenceWithArrayListOfPeople() - { - ArrayList people = new ArrayList(); - people.Add(new Person("Clark", "Kent")); - people.Add(new Person("Lois", "Lane")); - people.Add(new Person("Lex", "Luther")); - string sentence = helper.ToSentence(people); - Assert.AreEqual("Clark Kent, Lois Lane and Lex Luther", sentence); - } + string sentence = helper.ToSentence(new string[] {"apple", "banana", "mango"}, TextHelper.DefaultConnector, false); + Assert.AreEqual("apple, banana, and mango", sentence); + } + + private class Person + { + private readonly string _firstName; + private readonly string _lastName; + + public Person(string firstName, string lastName) + { + _firstName = firstName; + _lastName = lastName; + } + + public override string ToString() + { + return _firstName + " " + _lastName; + } + } + + [Test] + public void ToSentenceWithArrayListOfPeople() + { + ArrayList people = new ArrayList(); + people.Add(new Person("Clark", "Kent")); + people.Add(new Person("Lois", "Lane")); + people.Add(new Person("Lex", "Luther")); + string sentence = helper.ToSentence(people); + Assert.AreEqual("Clark Kent, Lois Lane and Lex Luther", sentence); + } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework.Views.NVelocity/Castle.MonoRail.Framework.Views.NVelocity.build b/MonoRail/Castle.MonoRail.Framework.Views.NVelocity/Castle.MonoRail.Framework.Views.NVelocity.build index 369080291..1b5268f0a 100644 --- a/MonoRail/Castle.MonoRail.Framework.Views.NVelocity/Castle.MonoRail.Framework.Views.NVelocity.build +++ b/MonoRail/Castle.MonoRail.Framework.Views.NVelocity/Castle.MonoRail.Framework.Views.NVelocity.build @@ -8,7 +8,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/FileDictionaryAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/FileDictionaryAdapter.cs index dfaf8505c..1b9afc87c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/FileDictionaryAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/FileDictionaryAdapter.cs @@ -18,30 +18,63 @@ namespace Castle.MonoRail.Framework.Adapters using System.Web; using System.Collections; + /// + /// Adapts the ASP.Net HttpFileCollection to MonoRail dictionary + /// public class FileDictionaryAdapter : IDictionary { private HttpFileCollection fileCollection; + /// + /// Initializes a new instance of the class. + /// + /// The file collection. public FileDictionaryAdapter(HttpFileCollection fileCollection) { this.fileCollection = fileCollection; } + /// + /// Determines whether the object contains an element with the specified key. + /// + /// The key to locate in the object. + /// + /// true if the contains an element with the key; otherwise, false. + /// + /// key is null. public bool Contains(object key) { return fileCollection[(String) key] != null; } + /// + /// Adds an element with the provided key and value to the object. + /// + /// The to use as the key of the element to add. + /// The to use as the value of the element to add. + /// An element with the same key already exists in the object. + /// key is null. + /// The is read-only.-or- The has a fixed size. public void Add(object key, object value) { throw new NotImplementedException(); } + /// + /// Removes all elements from the object. + /// + /// The object is read-only. public void Clear() { throw new NotImplementedException(); } + /// + /// Returns an object for the object. + /// + /// + /// An object for the object. + /// IDictionaryEnumerator IDictionary.GetEnumerator() { Hashtable copy = new Hashtable(); @@ -54,57 +87,117 @@ IDictionaryEnumerator IDictionary.GetEnumerator() return copy.GetEnumerator(); } + /// + /// Removes the element with the specified key from the object. + /// + /// The key of the element to remove. + /// The object is read-only.-or- The has a fixed size. + /// key is null. public void Remove(object key) { throw new NotImplementedException(); } + /// + /// Gets an object containing the keys of the object. + /// + /// + /// An object containing the keys of the object. public ICollection Keys { get { return fileCollection.Keys; } } + /// + /// Gets an object containing the values in the object. + /// + /// + /// An object containing the values in the object. public ICollection Values { get { throw new NotImplementedException(); } } + /// + /// Gets a value indicating whether the object is read-only. + /// + /// + /// true if the object is read-only; otherwise, false. public bool IsReadOnly { get { return true; } } + /// + /// Gets a value indicating whether the object has a fixed size. + /// + /// + /// true if the object has a fixed size; otherwise, false. public bool IsFixedSize { get { return true; } } + /// + /// Gets or sets the with the specified key. + /// + /// public object this[object key] { get { return fileCollection[(String) key]; } set { throw new NotImplementedException(); } } + /// + /// Copies the elements of the to an , starting at a particular index. + /// + /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. + /// The zero-based index in array at which copying begins. + /// array is null. + /// index is less than zero. + /// array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source is greater than the available space from index to the end of the destination array. + /// The type of the source cannot be cast automatically to the type of the destination array. public void CopyTo(Array array, int index) { throw new NotImplementedException(); } + /// + /// Gets the number of elements contained in the . + /// + /// + /// The number of elements contained in the . public int Count { get { return fileCollection.Count; } } + /// + /// Gets an object that can be used to synchronize access to the . + /// + /// + /// An object that can be used to synchronize access to the . public object SyncRoot { get { return this.SyncRoot; } } + /// + /// Gets a value indicating whether access to the is synchronized (thread safe). + /// + /// + /// true if access to the is synchronized (thread safe); otherwise, false. public bool IsSynchronized { get { return false; } } + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return fileCollection.GetEnumerator(); diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/RequestAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/RequestAdapter.cs index 7d15de677..9745a2f76 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/RequestAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/RequestAdapter.cs @@ -15,11 +15,9 @@ namespace Castle.MonoRail.Framework.Adapters { using System; - using System.Web; using System.Collections; using System.Collections.Specialized; - - using Castle.MonoRail.Framework; + using System.Web; /// /// This class adapts the HttpRequest to a MonoRail IRequest. @@ -29,66 +27,115 @@ public class RequestAdapter : IRequest private HttpRequest request; private FileDictionaryAdapter files; - public RequestAdapter( HttpRequest request ) + /// + /// Initializes a new instance of the class. + /// + /// The request. + public RequestAdapter(HttpRequest request) { this.request = request; } + /// + /// Gets the Http headers. + /// + /// The Http headers. public NameValueCollection Headers { get { return request.Headers; } } - public bool IsLocal - { - get { return request.Url.IsLoopback; } + /// + /// Gets a value indicating whether this requeest is from a local address. + /// + /// true if this instance is local; otherwise, false. + public bool IsLocal + { + get { return request.Url.IsLoopback; } } + /// + /// Gets the HTTP method. + /// + /// The HTTP method. public string HttpMethod { get { return request.HttpMethod; } } - + + /// + /// Gets the URI. + /// + /// The URI. public Uri Uri { get { return request.Url; } } + /// + /// Gets the raw URL. + /// + /// The raw URL. public String RawUrl { get { return request.RawUrl; } } + /// + /// Gets the file path. + /// + /// The file path. public String FilePath { get { return request.FilePath; } } + /// + /// Gets the query string. + /// + /// The query string. public NameValueCollection QueryString { get { return request.QueryString; } } + /// + /// Gets the form. + /// + /// The form. public NameValueCollection Form { get { return request.Form; } } - public byte[] BinaryRead( int count ) + /// + /// Reads the request data as a byte array. + /// + /// How many bytes. + /// + public byte[] BinaryRead(int count) { - return request.BinaryRead( count ); + return request.BinaryRead(count); } - public String this[ String key ] + /// + /// Gets the param with the specified key. + /// + /// + public String this[String key] { - get { return request[ key ]; } + get { return request[key]; } } + /// + /// Gets the per key. + /// + /// public IDictionary Files { get { - if ( files == null ) + if (files == null) { files = new FileDictionaryAdapter(request.Files); } @@ -96,35 +143,54 @@ public IDictionary Files } } + /// + /// Gets the params which accumulates headers, post, querystring and cookies. + /// + /// The params. public NameValueCollection Params { get { return request.Params; } } + /// + /// Gets the user languages. + /// + /// The user languages. public String[] UserLanguages { get { return request.UserLanguages; } } - + /// + /// Gets the IP host address of the remote client. + /// + /// The IP address of the remote client. public string UserHostAddress { get { return request.UserHostAddress; } } - public String ReadCookie( String name ) + /// + /// Reads the cookie. + /// + /// The cookie name. + /// + public String ReadCookie(String name) { - HttpCookie cookie = request.Cookies[ name ]; - if ( cookie == null ) + HttpCookie cookie = request.Cookies[name]; + if (cookie == null) { return null; } return cookie.Value; } + /// + /// Validates the input. + /// public void ValidateInput() { request.ValidateInput(); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/ResponseAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/ResponseAdapter.cs index 5c95fc39e..203e808fb 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/ResponseAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/ResponseAdapter.cs @@ -70,38 +70,67 @@ public String Charset set { response.Charset = value; } } + /// + /// Gets or sets the status code. + /// + /// The status code. public int StatusCode { get { return response.StatusCode; } set { response.StatusCode = value; } } + /// + /// Gets or sets the content type. + /// + /// The type of the content. public String ContentType { get { return response.ContentType; } set { response.ContentType = value; } } + /// + /// Appends the header. + /// + /// The name. + /// The header value. public void AppendHeader(String name, String headerValue) { response.AppendHeader(name, headerValue); } + /// + /// Gets the output. + /// + /// The output. public TextWriter Output { get { return response.Output; } } + /// + /// Gets the output stream. + /// + /// The output stream. public Stream OutputStream { get { return response.OutputStream; } } + /// + /// Writes the buffer to the browser + /// + /// The buffer. public void BinaryWrite(byte[] buffer) { response.BinaryWrite(buffer); } + /// + /// Writes the stream to the browser + /// + /// The stream. public void BinaryWrite(Stream stream) { byte[] buffer = new byte[stream.Length]; @@ -111,41 +140,73 @@ public void BinaryWrite(Stream stream) BinaryWrite(buffer); } + /// + /// Clears the response (only works if buffered) + /// public void Clear() { response.Clear(); } + /// + /// Clears the response content (only works if buffered). + /// public void ClearContent() { response.ClearContent(); } + /// + /// Writes the specified string. + /// + /// The string. public void Write(String s) { response.Write(s); } + /// + /// Writes the specified obj. + /// + /// The obj. public void Write(object obj) { response.Write(obj); } + /// + /// Writes the specified char. + /// + /// The char. public void Write(char ch) { response.Write(ch); } + /// + /// Writes the specified buffer. + /// + /// The buffer. + /// The index. + /// The count. public void Write(char[] buffer, int index, int count) { response.Write(buffer, index, count); } + /// + /// Writes the file. + /// + /// Name of the file. public void WriteFile(String fileName) { response.WriteFile(fileName); } + /// + /// Redirects the specified URL. + /// + /// The URL. public void Redirect(String url) { redirected = true; @@ -153,6 +214,11 @@ public void Redirect(String url) response.Redirect(url, false); } + /// + /// Redirects the specified URL. + /// + /// The URL. + /// if set to true [end process]. public void Redirect(String url, bool endProcess) { redirected = true; @@ -160,6 +226,11 @@ public void Redirect(String url, bool endProcess) response.Redirect(url, endProcess); } + /// + /// Redirects the specified controller. + /// + /// The controller. + /// The action. public void Redirect(String controller, String action) { redirected = true; @@ -169,6 +240,12 @@ public void Redirect(String controller, String action) response.Redirect(builder.BuildUrl(context.UrlInfo, controller, action), false); } + /// + /// Redirects the specified area. + /// + /// The area. + /// The controller. + /// The action. public void Redirect(String area, String controller, String action) { if (area == null || area.Length == 0) @@ -185,11 +262,21 @@ public void Redirect(String area, String controller, String action) } } + /// + /// Gets a value indicating whether this instance is client connected. + /// + /// + /// true if this instance is client connected; otherwise, false. + /// public bool IsClientConnected { get { return response.IsClientConnected; } } + /// + /// Gets a value indicating whether the response sent a redirect. + /// + /// true if was redirected; otherwise, false. public bool WasRedirected { get { return redirected; } diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/ServerUtilityAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/ServerUtilityAdapter.cs index 086657871..d769a77e9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/ServerUtilityAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/ServerUtilityAdapter.cs @@ -18,6 +18,9 @@ namespace Castle.MonoRail.Framework.Adapters using System.Web; using Castle.MonoRail.Framework; + /// + /// Adapts the ASP.Net HttpServerUtility to MonoRail's interface for the same service. + /// public class ServerUtilityAdapter : IServerUtility { private readonly HttpServerUtility server; diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/SessionAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/SessionAdapter.cs index a154378ea..019d64c08 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/SessionAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/SessionAdapter.cs @@ -18,85 +18,178 @@ namespace Castle.MonoRail.Framework.Adapters using System.Collections; using System.Web.SessionState; + /// + /// Adapts the ASP.Net session as a simple dictionary for MonoRail + /// public class SessionAdapter : MarshalByRefObject, IDictionary { private HttpSessionState _session; + /// + /// Initializes a new instance of the class. + /// + /// The session. public SessionAdapter( HttpSessionState session ) { _session = session; } + /// + /// Returns an object for the object. + /// + /// + /// An object for the object. + /// IDictionaryEnumerator IDictionary.GetEnumerator() { throw new NotImplementedException(); } + /// + /// Gets an object containing the keys of the object. + /// + /// + /// An object containing the keys of the object. public ICollection Keys { get { return _session.Keys; } } + /// + /// Copies the elements of the to an , starting at a particular index. + /// + /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. + /// The zero-based index in array at which copying begins. + /// array is null. + /// index is less than zero. + /// array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source is greater than the available space from index to the end of the destination array. + /// The type of the source cannot be cast automatically to the type of the destination array. public void CopyTo(Array array, int index) { throw new NotImplementedException(); } + /// + /// Gets the number of elements contained in the . + /// + /// + /// The number of elements contained in the . public int Count { get { return _session.Count; } } + /// + /// Gets an object that can be used to synchronize access to the . + /// + /// + /// An object that can be used to synchronize access to the . public object SyncRoot { get { return _session.SyncRoot; } } + /// + /// Gets a value indicating whether access to the is synchronized (thread safe). + /// + /// + /// true if access to the is synchronized (thread safe); otherwise, false. public bool IsSynchronized { get { return _session.IsSynchronized; } } + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return _session.GetEnumerator(); } + /// + /// Determines whether the object contains an element with the specified key. + /// + /// The key to locate in the object. + /// + /// true if the contains an element with the key; otherwise, false. + /// + /// key is null. public bool Contains( object key ) { return _session[ (String)key ] != null; } + /// + /// Adds an element with the provided key and value to the object. + /// + /// The to use as the key of the element to add. + /// The to use as the value of the element to add. + /// An element with the same key already exists in the object. + /// key is null. + /// The is read-only.-or- The has a fixed size. public void Add( object key, object value ) { _session.Add( (String)key, value ); } + /// + /// Removes all elements from the object. + /// + /// The object is read-only. public void Clear() { _session.Clear(); } + /// + /// Removes the element with the specified key from the object. + /// + /// The key of the element to remove. + /// The object is read-only.-or- The has a fixed size. + /// key is null. public void Remove( object key ) { _session.Remove( (String)key ); } + /// + /// Gets an object containing the values in the object. + /// + /// + /// An object containing the values in the object. public ICollection Values { get { throw new NotImplementedException(); } } + /// + /// Gets a value indicating whether the object is read-only. + /// + /// + /// true if the object is read-only; otherwise, false. public bool IsReadOnly { get { return _session.IsReadOnly; } } + /// + /// Gets a value indicating whether the object has a fixed size. + /// + /// + /// true if the object has a fixed size; otherwise, false. public bool IsFixedSize { get { return false; } } + /// + /// Gets or sets the with the specified key. + /// + /// public object this[ object key ] { get { return _session[ (String)key ]; } diff --git a/MonoRail/Castle.MonoRail.Framework/Adapters/TraceAdapter.cs b/MonoRail/Castle.MonoRail.Framework/Adapters/TraceAdapter.cs index 876ec9498..24642316b 100644 --- a/MonoRail/Castle.MonoRail.Framework/Adapters/TraceAdapter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Adapters/TraceAdapter.cs @@ -17,45 +17,80 @@ namespace Castle.MonoRail.Framework.Adapters using System; using System.Web; - using Castle.MonoRail.Framework; - + /// + /// Delegates to ASP.Net TraceContext. + /// public class TraceAdapter : ITrace { - private TraceContext _trace; + private TraceContext trace; - public TraceAdapter( TraceContext traceContext ) + /// + /// Initializes a new instance of the class. + /// + /// The trace context. + public TraceAdapter(TraceContext traceContext) { - _trace = traceContext; + trace = traceContext; } - public void Warn( String message ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. + public void Warn(String message) { - _trace.Warn( message ); + trace.Warn(message); } - public void Warn( String category, String message ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + public void Warn(String category, String message) { - _trace.Warn( category, message ); + trace.Warn(category, message); } - public void Warn( String category, String message, Exception errorInfo ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. + public void Warn(String category, String message, Exception errorInfo) { - _trace.Warn( category, message, errorInfo ); + trace.Warn(category, message, errorInfo); } - public void Write( String message ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. + public void Write(String message) { - _trace.Write( message ); + trace.Write(message); } - public void Write( String category, String message ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + public void Write(String category, String message) { - _trace.Write( category, message ); + trace.Write(category, message); } - public void Write( String category, String message, Exception errorInfo ) + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. + public void Write(String category, String message, Exception errorInfo) { - _trace.Write( category, message, errorInfo ); + trace.Write(category, message, errorInfo); } } } \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/DataBindAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/DataBindAttribute.cs index a4a2152a0..de09cc1d0 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/DataBindAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/DataBindAttribute.cs @@ -166,11 +166,20 @@ public virtual object Bind(SmartDispatcherController controller, ParameterInfo p return instance; } + /// + /// Creates the binder. + /// + /// protected virtual IDataBinder CreateBinder() { return new DataBinder(); } + /// + /// Configures the validator. + /// + /// The controller. + /// The binder. protected void ConfigureValidator(SmartDispatcherController controller, IDataBinder binder) { if (validate) @@ -183,6 +192,12 @@ protected void ConfigureValidator(SmartDispatcherController controller, IDataBin } } + /// + /// Populates the validator error summary. + /// + /// The controller. + /// The binder. + /// The instance. protected void PopulateValidatorErrorSummary(SmartDispatcherController controller, IDataBinder binder, object instance) { if (validate) @@ -191,6 +206,12 @@ protected void PopulateValidatorErrorSummary(SmartDispatcherController controlle } } + /// + /// Binds the instance errors. + /// + /// The controller. + /// The binder. + /// The instance. protected void BindInstanceErrors(SmartDispatcherController controller, IDataBinder binder, object instance) { if (instance != null) diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/DefaultActionAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/DefaultActionAttribute.cs index 4262e4095..6457371a2 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/DefaultActionAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/DefaultActionAttribute.cs @@ -20,7 +20,7 @@ namespace Castle.MonoRail.Framework /// Declares that the Controller should enable a DefaultAction method /// for request processing if no action can be found with the supplied name /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple=false), Serializable] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple=false), Serializable] public class DefaultActionAttribute : Attribute { private static readonly String DEFAULT_ACTION = "DefaultAction"; diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/LocalizationFilterAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/LocalizationFilterAttribute.cs index 6e958181e..ebcd7461d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/LocalizationFilterAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/LocalizationFilterAttribute.cs @@ -15,7 +15,7 @@ namespace Castle.MonoRail.Framework { using System; - using Castle.MonoRail.Framework.Filters; + using Filters; /// /// This is an special filter attribute. It is used @@ -39,7 +39,9 @@ public class LocalizationFilterAttribute : FilterAttribute /// "locale", but if that fails it falls back /// to the client's browser locale. /// - public LocalizationFilterAttribute() : base(ExecuteEnum.BeforeAction, typeof(LocalizationFilter)) {} + public LocalizationFilterAttribute() : base(ExecuteEnum.BeforeAction, typeof(LocalizationFilter)) + { + } /// /// Defines a new LocalizationFilter. @@ -91,6 +93,6 @@ public bool UseBrowser set { useBrowser = value; } } - #endregion + #endregion } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/TransformFilterAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/TransformFilterAttribute.cs index b090ebd03..b91b36904 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/TransformFilterAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/TransformFilterAttribute.cs @@ -51,12 +51,20 @@ public TransformFilterAttribute(Type transformFilterType) this.transformFilterType = transformFilterType; } - + + /// + /// Gets the type of the transform filter. + /// + /// The type of the transform filter. public Type TransformFilterType { get { return transformFilterType; } } + /// + /// Gets or sets the execution order. + /// + /// The execution order. public int ExecutionOrder { get { return executionOrder; } diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentDetailsAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentDetailsAttribute.cs index 2e88e48c9..5921ffccd 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentDetailsAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentDetailsAttribute.cs @@ -18,11 +18,30 @@ namespace Castle.MonoRail.Framework /// /// Decorates a to associate a custom name with it. - /// - /// Optionally you can associate the section names supported by the - /// . - /// /// + /// + /// Decorates a to associate a custom name with it. + /// + /// Optionally you can associate the section names supported by the + /// . + /// + /// + /// + /// In the code below, the class MyHeaderViewConponent will be referenced as just Header, + /// and it will support the subsections header and footer. + /// + /// + /// + /// + /// + [AttributeUsage(AttributeTargets.Class), Serializable] public class ViewComponentDetailsAttribute : Attribute { diff --git a/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentParamAttribute.cs b/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentParamAttribute.cs index 248fdd533..cfca18083 100644 --- a/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentParamAttribute.cs +++ b/MonoRail/Castle.MonoRail.Framework/Attributes/ViewComponentParamAttribute.cs @@ -20,12 +20,34 @@ namespace Castle.MonoRail.Framework /// Decorates a public property in a /// to have the framework automatically bind the value using /// the dictionary. - /// By default The property name is going to be used as a key to query the params. + /// + /// + /// By default the property name is going to be used as a key to query the params. /// /// You can also use the - /// property to define that a property is non-optional. + /// property to define that a parameter is non-optional. /// - /// + /// + /// + /// In the code below, the Text parameter will automatically be bound to the header property. + /// If there is no Text parameter, a will be thrown. + /// Simailrly, the optional CssClass parameter will be bound to the CssClass property. No error + /// occurs if there is no CssClass parameter. + /// + /// + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true), Serializable] public class ViewComponentParamAttribute : Attribute { diff --git a/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework-vs2005.csproj b/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework-vs2005.csproj index 2e9ede569..d379728b2 100644 --- a/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework-vs2005.csproj +++ b/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework-vs2005.csproj @@ -39,7 +39,8 @@ true 4096 false - 1591 + + false false false diff --git a/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework.build b/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework.build index c4d7f13bd..15fe04bd6 100644 --- a/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework.build +++ b/MonoRail/Castle.MonoRail.Framework/Castle.MonoRail.Framework.build @@ -2,18 +2,18 @@ + xmlns="http://nant.sf.net/release/0.85/nant.xsd"> + - - + + diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ControllersConfig.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ControllersConfig.cs index 0e36f2a3a..31cb4c817 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ControllersConfig.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ControllersConfig.cs @@ -19,6 +19,9 @@ namespace Castle.MonoRail.Framework.Configuration using System.Configuration; using System.Xml; + /// + /// Represents the controller node configuration + /// public class ControllersConfig : ISerializedConfig { private String[] assemblies; @@ -26,6 +29,10 @@ public class ControllersConfig : ISerializedConfig #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNode customFactoryNode = section.SelectSingleNode("customControllerFactory"); @@ -60,12 +67,20 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Gets or sets the assemblies. + /// + /// The assemblies. public string[] Assemblies { get { return assemblies; } set { assemblies = value; } } + /// + /// Gets or sets the custom controller factory. + /// + /// The custom controller factory. public Type CustomControllerFactory { get { return customControllerFactory; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrl.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrl.cs index 878778b08..c9dd5de5a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrl.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrl.cs @@ -4,6 +4,9 @@ namespace Castle.MonoRail.Framework.Configuration using System.Configuration; using System.Xml; + /// + /// Represents a url mapping + /// public class DefaultUrl : ISerializedConfig { private string url, controller, action, area; @@ -32,6 +35,10 @@ public DefaultUrl(string url, string controller, string action, string area) #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlAttribute urlAtt = section.Attributes["url"]; diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrlCollection.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrlCollection.cs index ec7fe8a08..9b6110dd9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrlCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/DefaultUrlCollection.cs @@ -3,10 +3,17 @@ namespace Castle.MonoRail.Framework.Configuration using System.Collections; using System.Xml; + /// + /// Represents a set of url mappings + /// public class DefaultUrlCollection : CollectionBase, ISerializedConfig { #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNodeList urls = section.SelectNodes("defaultUrls/add"); @@ -22,6 +29,5 @@ public void Deserialize(XmlNode section) } #endregion - } } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntry.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntry.cs index 016cbb370..c62f17e08 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntry.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntry.cs @@ -18,6 +18,9 @@ namespace Castle.MonoRail.Framework.Configuration using System.Configuration; using System.Xml; + /// + /// Represents a MonoRail extension configuration entry + /// public class ExtensionEntry : ISerializedConfig { private Type extensionType; @@ -25,6 +28,10 @@ public class ExtensionEntry : ISerializedConfig #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlAttribute typeAtt = section.Attributes["type"]; @@ -43,12 +50,20 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Gets or sets the type of the extension. + /// + /// The type of the extension. public Type ExtensionType { get { return extensionType; } set { extensionType = value; } } + /// + /// Gets or sets the extension node. + /// + /// The extension node. public XmlNode ExtensionNode { get { return extensionNode; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntryCollection.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntryCollection.cs index 1ec9ce570..dfbbe8adb 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntryCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ExtensionEntryCollection.cs @@ -17,10 +17,17 @@ namespace Castle.MonoRail.Framework.Configuration using System.Collections; using System.Xml; + /// + /// Represents a set of MonoRail extensions + /// public class ExtensionEntryCollection : CollectionBase, ISerializedConfig { #region ISerializedConfig implementation - + + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNodeList services = section.SelectNodes("extensions/extension"); @@ -36,7 +43,11 @@ public void Deserialize(XmlNode section) } #endregion - + + /// + /// Gets the at the specified index. + /// + /// public ExtensionEntry this[int index] { get { return InnerList[index] as ExtensionEntry; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ISerializedConfig.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ISerializedConfig.cs index b93b3576d..3db28fca0 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ISerializedConfig.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ISerializedConfig.cs @@ -14,7 +14,6 @@ namespace Castle.MonoRail.Framework.Configuration { - using System; using System.Xml; /// @@ -22,6 +21,10 @@ namespace Castle.MonoRail.Framework.Configuration /// public interface ISerializedConfig { + /// + /// Deserializes the specified section. + /// + /// The section. void Deserialize(XmlNode section); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailConfiguration.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailConfiguration.cs index 5c41a1e52..57dac4b3d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailConfiguration.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailConfiguration.cs @@ -19,7 +19,7 @@ namespace Castle.MonoRail.Framework.Configuration using System.Xml; /// - /// Pendent + /// Represents the MonoRail external configuration /// public class MonoRailConfiguration : ISerializedConfig { @@ -70,6 +70,10 @@ public MonoRailConfiguration(XmlNode section) : this() configurationSection = section; } + /// + /// Gets the config. + /// + /// public static MonoRailConfiguration GetConfig() { MonoRailConfiguration config = @@ -92,6 +96,10 @@ public static MonoRailConfiguration GetConfig() #region ISerializedConfig implementation + /// + /// Deserializes the specified node. + /// + /// The node. public void Deserialize(XmlNode node) { viewEngineConfig.Deserialize(node); @@ -131,76 +139,143 @@ public void Deserialize(XmlNode node) #endregion + /// + /// Gets the SMTP config. + /// + /// The SMTP config. public SmtpConfig SmtpConfig { get { return smtpConfig; } } + /// + /// Gets the view engine config. + /// + /// The view engine config. public ViewEngineConfig ViewEngineConfig { get { return viewEngineConfig; } } + /// + /// Gets the controllers config. + /// + /// The controllers config. public ControllersConfig ControllersConfig { get { return controllersConfig; } } + /// + /// Gets the view components config. + /// + /// The view components config. public ViewComponentsConfig ViewComponentsConfig { get { return viewComponentsConfig; } } + /// + /// Gets the routing rules. + /// + /// The routing rules. public RoutingRuleCollection RoutingRules { get { return routingRules; } } + /// + /// Gets the extension entries. + /// + /// The extension entries. public ExtensionEntryCollection ExtensionEntries { get { return extensions; } } + /// + /// Gets the service entries. + /// + /// The service entries. public ServiceEntryCollection ServiceEntries { get { return services; } } + /// + /// Gets the custom filter factory. + /// + /// The custom filter factory. public Type CustomFilterFactory { get { return customFilterFactory; } } + /// + /// Gets the scaffold config. + /// + /// The scaffold config. public ScaffoldConfig ScaffoldConfig { get { return scaffoldConfig; } } + /// + /// Gets a value indicating whether MR should check for client connection. + /// + /// + /// true if it should check client is connected; otherwise, false. + /// public bool CheckClientIsConnected { get { return checkClientIsConnected; } } + /// + /// Gets a value indicating whether to use windsor integration. + /// + /// + /// true if it should use windsor integration; otherwise, false. + /// public bool UseWindsorIntegration { get { return useWindsorIntegration; } } + /// + /// Gets a value indicating whether match host name and path should be used on + /// MonoRail routing. + /// + /// + /// true if it should match host name and path; otherwise, false. + /// public bool MatchHostNameAndPath { get { return matchHostNameAndPath; } } + /// + /// Gets a value indicating whether routing should exclude app path. + /// + /// true if exclude app path; otherwise, false. public bool ExcludeAppPath { get { return excludeAppPath; } } + /// + /// Gets the configuration section. + /// + /// The configuration section. public XmlNode ConfigurationSection { get { return configurationSection; } } + /// + /// Gets the default urls. + /// + /// The default urls. public DefaultUrlCollection DefaultUrls { get { return defaultUrls; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailSectionHandler.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailSectionHandler.cs index c4ab5f54e..1ade076aa 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailSectionHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/MonoRailSectionHandler.cs @@ -19,14 +19,24 @@ namespace Castle.MonoRail.Framework.Configuration using System.Xml; /// - /// Pendent + /// The MonoRail section handler /// public class MonoRailSectionHandler : IConfigurationSectionHandler { + /// + /// Initializes a new instance of the class. + /// public MonoRailSectionHandler() { } + /// + /// Creates a configuration section handler. + /// + /// + /// Configuration context object. + /// + /// The created section handler object. public virtual object Create(object parent, object configContext, XmlNode section) { MonoRailConfiguration config = new MonoRailConfiguration(section); @@ -36,6 +46,11 @@ public virtual object Create(object parent, object configContext, XmlNode sectio return config; } + /// + /// Deserializes the config section. + /// + /// The section. + /// The config. private void Deserialize(XmlNode section, MonoRailConfiguration config) { config.Deserialize(section); diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRule.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRule.cs index 02ef906af..09e3ad36d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRule.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRule.cs @@ -18,13 +18,18 @@ namespace Castle.MonoRail.Framework.Configuration using System.Text.RegularExpressions; /// - /// Pendent + /// Represents a url routing rule. /// public class RoutingRule { private String pattern, replace; private Regex rule; + /// + /// Initializes a new instance of the class. + /// + /// The regular expression pattern. + /// The replace. public RoutingRule(string pattern, string replace) { this.pattern = pattern; @@ -33,16 +38,28 @@ public RoutingRule(string pattern, string replace) rule = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); } + /// + /// Gets the pattern. + /// + /// The pattern. public String Pattern { get { return pattern; } } + /// + /// Gets the replace. + /// + /// The replace. public String Replace { get { return replace; } } + /// + /// Gets the compiled rule. + /// + /// The compiled rule. public Regex CompiledRule { get { return rule; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRuleCollection.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRuleCollection.cs index c06eac899..459bb3af5 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRuleCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/RoutingRuleCollection.cs @@ -19,10 +19,17 @@ namespace Castle.MonoRail.Framework.Configuration using System.Configuration; using System.Xml; + /// + /// Represents a set of url routing rules. + /// public class RoutingRuleCollection : CollectionBase, ISerializedConfig { #region ISerializedConfig implementation - + + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNodeList services = section.SelectNodes("routing/rule"); @@ -55,7 +62,11 @@ public void Deserialize(XmlNode section) } #endregion - + + /// + /// Gets the at the specified index. + /// + /// public RoutingRule this[int index] { get { return InnerList[index] as RoutingRule; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ScaffoldConfig.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ScaffoldConfig.cs index f18522db8..e2e5e2197 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ScaffoldConfig.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ScaffoldConfig.cs @@ -17,13 +17,23 @@ namespace Castle.MonoRail.Framework.Configuration using System; using System.Configuration; using System.Xml; + using Framework; + /// + /// Represents the Scaffolding support configuration. + /// + /// public class ScaffoldConfig : ISerializedConfig { private Type scaffoldImplType; #region ISerializedConfig implementation - + + /// + /// Deserializes the configuration section looking + /// for a 'scaffold' element with a 'type' attribute + /// + /// The section. public void Deserialize(XmlNode section) { section = section.SelectSingleNode("scaffold"); @@ -43,6 +53,11 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Gets the scaffolding support implementation type. + /// + /// + /// The type of the scaffold impl. public Type ScaffoldImplType { get { return scaffoldImplType; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntry.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntry.cs index 23869e8d1..0ab9f3734 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntry.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntry.cs @@ -17,37 +17,126 @@ namespace Castle.MonoRail.Framework.Configuration using System; using System.Configuration; using System.Xml; + using Castle.Components.Common.EmailSender; + using Castle.Components.Validator; + using Castle.MonoRail.Framework.Services.AjaxProxyGenerator; + using Framework; + using Internal; + /// + /// Enum for all known MonoRail services. + /// public enum ServiceIdentification { + /// + /// Custom ( not know service ) + /// Custom, + /// + /// The service + /// ControllerFactory, + /// + /// The service + /// ViewComponentFactory, + /// + /// The service. + /// ViewSourceLoader, + /// + /// The service. + /// FilterFactory, + /// + /// The service. + /// EmailSender, + /// + /// The service + /// ControllerDescriptorProvider, + /// + /// The service + /// ResourceDescriptorProvider, + /// + /// The service + /// RescueDescriptorProvider, + /// + /// The service + /// LayoutDescriptorProvider, + /// + /// The service + /// HelperDescriptorProvider, + /// + /// The service + /// FilterDescriptorProvider, + /// + /// The service + /// ResourceFactory, + /// + /// The service + /// EmailTemplateService, + /// + /// The service + /// ControllerTree, + /// + /// The service + /// CacheProvider, + /// + /// The service + /// ScaffoldingSupport, + /// + /// The service + /// ExecutorFactory, + /// + /// The service + /// TransformFilterDescriptorProvider, + /// + /// The service + /// TransformationFilterFactory, + /// + /// The service + /// ViewEngineManager, + /// + /// The service + /// UrlBuilder, + /// + /// The service + /// UrlTokenizer, + /// + /// The service + /// ServerUtility, + /// + /// The service + /// ValidatorRegistry, + /// + /// The service + /// AjaxProxyGenerator, } + /// + /// Represents a MonoRail service entry + /// public class ServiceEntry : ISerializedConfig { private ServiceIdentification serviceType; @@ -56,6 +145,10 @@ public class ServiceEntry : ISerializedConfig #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlAttribute idAtt = section.Attributes["id"]; @@ -97,16 +190,28 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Gets the type of the service. + /// + /// The type of the service. public ServiceIdentification ServiceType { get { return serviceType; } } + /// + /// Gets the service. + /// + /// The service. public Type Service { get { return service; } } + /// + /// Gets the interface. + /// + /// The interface. public Type Interface { get { return _interface; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntryCollection.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntryCollection.cs index 111e311f9..d42351500 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntryCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ServiceEntryCollection.cs @@ -23,23 +23,36 @@ namespace Castle.MonoRail.Framework.Configuration using Castle.MonoRail.Framework.Internal; using Castle.MonoRail.Framework.Services.AjaxProxyGenerator; - + /// + /// Represents a set of MonoRail services entries + /// public class ServiceEntryCollection : ISerializedConfig { private Hashtable service2Impl = new Hashtable(); private IList customServices = new ArrayList(); - + + /// + /// Initializes a new instance of the class. + /// public ServiceEntryCollection() { } + /// + /// Gets the custom services. + /// + /// The custom services. public ICollection CustomServices { get { return customServices; } } #region ISerializedConfig implementation - + + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNodeList services = section.SelectNodes("services/service"); @@ -70,26 +83,52 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Registers the service. + /// + /// The id. + /// The service. public void RegisterService(ServiceIdentification id, Type service) { RegisterService(ToInterface(id), service); } - + + /// + /// Registers the service. + /// + /// The inter. + /// The service. public void RegisterService(Type inter, Type service) { service2Impl[inter] = service; } - + + /// + /// Gets the service. + /// + /// The id. + /// public Type GetService(ServiceIdentification id) { return (Type) service2Impl[ToInterface(id)]; } - + + /// + /// Determines whether it has service. + /// + /// The id. + /// + /// true if the specified id has service; otherwise, false. + /// public bool HasService(ServiceIdentification id) { return service2Impl.Contains(ToInterface(id)); } - + + /// + /// Gets the service impl map. + /// + /// The service impl map. public IDictionary ServiceImplMap { get { return service2Impl; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ViewComponentsConfig.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ViewComponentsConfig.cs index 4ecb4da09..ed6de12b7 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ViewComponentsConfig.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ViewComponentsConfig.cs @@ -19,6 +19,9 @@ namespace Castle.MonoRail.Framework.Configuration using System.Configuration; using System.Xml; + /// + /// Represents the view components node configuration + /// public class ViewComponentsConfig : ISerializedConfig { private String[] assemblies; @@ -26,6 +29,10 @@ public class ViewComponentsConfig : ISerializedConfig #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlNode customFactoryNode = section.SelectSingleNode("customComponentFactory"); @@ -60,12 +67,20 @@ public void Deserialize(XmlNode section) #endregion + /// + /// Gets or sets the assemblies. + /// + /// The assemblies. public string[] Assemblies { get { return assemblies; } set { assemblies = value; } } + /// + /// Gets or sets the custom view component factory. + /// + /// The custom view component factory. public Type CustomViewComponentFactory { get { return customFactory; } diff --git a/MonoRail/Castle.MonoRail.Framework/Configuration/ViewEngineConfig.cs b/MonoRail/Castle.MonoRail.Framework/Configuration/ViewEngineConfig.cs index 94356f850..b1e550aec 100644 --- a/MonoRail/Castle.MonoRail.Framework/Configuration/ViewEngineConfig.cs +++ b/MonoRail/Castle.MonoRail.Framework/Configuration/ViewEngineConfig.cs @@ -32,6 +32,10 @@ public class ViewEngineConfig : ISerializedConfig #region ISerializedConfig implementation + /// + /// Deserializes the specified section. + /// + /// The section. public void Deserialize(XmlNode section) { XmlElement engines = (XmlElement) section.SelectSingleNode("viewEngines"); diff --git a/MonoRail/Castle.MonoRail.Framework/Constants.cs b/MonoRail/Castle.MonoRail.Framework/Constants.cs index 1ff3a2821..4dec6c4cb 100644 --- a/MonoRail/Castle.MonoRail.Framework/Constants.cs +++ b/MonoRail/Castle.MonoRail.Framework/Constants.cs @@ -17,7 +17,10 @@ namespace Castle.MonoRail.Framework using System; using System.Text.RegularExpressions; - public abstract class Constants + /// + /// MonoRail constants + /// + static class Constants { #region Controller Constants diff --git a/MonoRail/Castle.MonoRail.Framework/Controller.cs b/MonoRail/Castle.MonoRail.Framework/Controller.cs index bcdbaf643..2eca9847a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Controller.cs +++ b/MonoRail/Castle.MonoRail.Framework/Controller.cs @@ -15,6 +15,7 @@ namespace Castle.MonoRail.Framework { using System; + using System.Collections.Generic; using System.IO; using System.Web; using System.Reflection; @@ -33,7 +34,7 @@ namespace Castle.MonoRail.Framework /// Implements the core functionality and exposes the /// common methods for concrete controllers. /// - public abstract class Controller + public abstract class Controller : IDisposable { #region Fields @@ -102,7 +103,7 @@ public abstract class Controller /// Reference to the instance /// // internal IResourceFactory resourceFactory; - internal IDictionary _dynamicActions = new HybridDictionary(true); + internal IDictionary _dynamicActions = new Dictionary(StringComparer.InvariantCultureIgnoreCase); internal bool directRenderInvoked; @@ -360,13 +361,14 @@ public NameValueCollection Query get { return Request.QueryString; } } - public IDictionary DynamicActions - { - get { return _dynamicActions; } - } - - [Obsolete("Use the DynamicActions property instead")] - public IDictionary CustomActions + /// + /// Gets the dynamic actions dictionary. + /// + /// Can be used to insert dynamic actions on the controller instance. + /// + /// + /// The dynamic actions dictionary. + public IDictionary DynamicActions { get { return _dynamicActions; } } @@ -832,11 +834,21 @@ public void Redirect(string area, string controller, string action, IDictionary Redirect(UrlBuilder.BuildUrl(Context.UrlInfo, area, controller, action, parameters)); } + /// + /// Creates a querystring string representation of the namevalue collection. + /// + /// The parameters. + /// protected string ToQueryString(NameValueCollection parameters) { return CommonUtils.BuildQueryString(Context.Server, parameters, false); } + /// + /// Creates a querystring string representation of the entries in the dictionary. + /// + /// The parameters. + /// protected string ToQueryString(IDictionary parameters) { return CommonUtils.BuildQueryString(Context.Server, parameters, false); @@ -846,6 +858,11 @@ protected string ToQueryString(IDictionary parameters) #region Core members + /// + /// Extracts the services the controller uses from the context -- which ultimately + /// is a service provider. + /// + /// The context/service provider. public void InitializeFieldsFromServiceProvider(IRailsEngineContext context) { serviceProvider = context; @@ -1061,6 +1078,14 @@ protected virtual void Initialize() validator = CreateValidatorRunner(validatorRegistry); } + /// + /// Performs application-defined tasks associated + /// with freeing, releasing, or resetting unmanaged resources. + /// + public virtual void Dispose() + { + } + /// /// Creates the default validator runner. /// diff --git a/MonoRail/Castle.MonoRail.Framework/ControllerException.cs b/MonoRail/Castle.MonoRail.Framework/ControllerException.cs index 0953218f2..b1b1c028e 100644 --- a/MonoRail/Castle.MonoRail.Framework/ControllerException.cs +++ b/MonoRail/Castle.MonoRail.Framework/ControllerException.cs @@ -31,7 +31,6 @@ public ControllerException(String message) : base(message) { } - /// /// Initializes a new instance of the class. /// diff --git a/MonoRail/Castle.MonoRail.Framework/ControllerLifecycleExecutor.cs b/MonoRail/Castle.MonoRail.Framework/ControllerLifecycleExecutor.cs index a19f60b6f..703da2bfb 100644 --- a/MonoRail/Castle.MonoRail.Framework/ControllerLifecycleExecutor.cs +++ b/MonoRail/Castle.MonoRail.Framework/ControllerLifecycleExecutor.cs @@ -26,10 +26,16 @@ namespace Castle.MonoRail.Framework using Castle.MonoRail.Framework.Internal; /// - /// + /// Default implementation of + /// + /// Handles the whole controller lifecycle in a request. + /// /// - public class ControllerLifecycleExecutor : IControllerLifecycleExecutor, IServiceEnabledComponent, IDisposable + public class ControllerLifecycleExecutor : IControllerLifecycleExecutor, IServiceEnabledComponent { + /// + /// Key for the executor instance on Context.Items + /// public const String ExecutorEntry = "mr.executor"; private readonly Controller controller; @@ -111,6 +117,9 @@ public void Service(IServiceProvider provider) #region IDisposable + /// + /// Disposes the filters and resources associated with a controller. + /// public void Dispose() { DisposeFilters(); @@ -188,7 +197,10 @@ public bool SelectAction(string actionName, string controllerName, IDictionary a if (actionMethod == null) { - dynAction = controller.DynamicActions[actionName] as IDynamicAction; + if (controller.DynamicActions.ContainsKey(actionName)) + { + dynAction = controller.DynamicActions[actionName]; + } if (dynAction == null) { @@ -355,7 +367,11 @@ private void PrepareTransformFilter() { PrepareTransformFilter(actionMethod); } - + + /// + /// Prepares the transform filter. + /// + /// The method. protected void PrepareTransformFilter(MethodInfo method) { if (method == null) return; @@ -480,6 +496,9 @@ internal void InitializeControllerFieldsFromServiceProvider() } } + /// + /// Creates the and initialize helpers associated with a controller. + /// protected void CreateAndInitializeHelpers() { HybridDictionary helpers = new HybridDictionary(); @@ -682,7 +701,11 @@ private void PrepareResources() { CreateResources(actionMethod); } - + + /// + /// Creates the resources associated with a controller + /// + /// The method. protected void CreateResources(MethodInfo method) { controller.resources = new ResourceDictionary(); @@ -704,6 +727,9 @@ protected void CreateResources(MethodInfo method) } } + /// + /// Releases the resources. + /// protected void ReleaseResources() { if (controller.resources == null) return; @@ -718,6 +744,11 @@ protected void ReleaseResources() #region Filters + /// + /// Identifies if no filter should run for the given action. + /// + /// The method. + /// protected internal bool ShouldSkip(MethodInfo method) { if (method == null) @@ -841,6 +872,10 @@ private void DisposeFilters() #region Views and Layout + /// + /// Obtains the name of the default layout. + /// + /// protected String ObtainDefaultLayoutName() { if (metaDescriptor.Layout != null) @@ -923,6 +958,12 @@ protected bool PerformRescue(MethodInfo method, Exception ex) return false; } + /// + /// Gets the rescue for the specified exception type. + /// + /// The rescues. + /// Type of the exception. + /// protected RescueDescriptor GetRescueFor(IList rescues, Type exceptionType) { if (rescues == null || rescues.Count == 0) return null; @@ -949,6 +990,9 @@ protected RescueDescriptor GetRescueFor(IList rescues, Type exceptionType) #region Extension + /// + /// Raises the on action exception on extension. + /// protected void RaiseOnActionExceptionOnExtension() { ExtensionManager manager = diff --git a/MonoRail/Castle.MonoRail.Framework/Controllers/FormHelper.resx b/MonoRail/Castle.MonoRail.Framework/Controllers/FormHelper.resx index afc2d8d14..ac0da1dac 100644 --- a/MonoRail/Castle.MonoRail.Framework/Controllers/FormHelper.resx +++ b/MonoRail/Castle.MonoRail.Framework/Controllers/FormHelper.resx @@ -137,6 +137,13 @@ function monorail_formhelper_numberonly(e, exceptions, forbidalso) return true; } +function monorail_formhelper_inputfilter(e, forbid) +{ + var code = e.charCode; + if (!code) code = e.keyCode; + for(var i=0; i < forbid.length; i++) if (forbid[i] == code) return false; +} + /* The scripts on this page was produced by mordechai Sandhaus - 52action.com, and is copyrighted . If you like this script, we encourage you to use it, diff --git a/MonoRail/Castle.MonoRail.Framework/DelegateDynamicAction.cs b/MonoRail/Castle.MonoRail.Framework/DelegateDynamicAction.cs index 6876a8bf2..21fdf63a8 100644 --- a/MonoRail/Castle.MonoRail.Framework/DelegateDynamicAction.cs +++ b/MonoRail/Castle.MonoRail.Framework/DelegateDynamicAction.cs @@ -14,6 +14,10 @@ namespace Castle.MonoRail.Framework { + /// + /// Delegate to create dynamic actions without the need for a separated class. + /// + /// Controller instance public delegate void ActionDelegate(Controller controller); /// @@ -24,11 +28,20 @@ public class DelegateDynamicAction : IDynamicAction { private readonly ActionDelegate actionDelegate; + /// + /// Initializes a new instance of the class. + /// + /// The action delegate. public DelegateDynamicAction(ActionDelegate actionDelegate) { this.actionDelegate = actionDelegate; } + /// + /// Implementors should perform the action + /// upon this invocation + /// + /// public void Execute(Controller controller) { actionDelegate(controller); diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/AbstractExceptionHandler.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/AbstractExceptionHandler.cs index 7021819ba..40dbee959 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/AbstractExceptionHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/AbstractExceptionHandler.cs @@ -26,18 +26,37 @@ public abstract class AbstractExceptionHandler : IExceptionHandler { private IExceptionHandler nextHandler; + /// + /// Implementors should perform any required + /// initialization + /// public virtual void Initialize() { } + /// + /// Implementors should perform the action + /// on the exception. Note that the exception + /// is available in + /// + /// public abstract void Process(IRailsEngineContext context); + /// + /// The next exception in the sink + /// or null if none exists. + /// + /// public IExceptionHandler Next { get { return nextHandler; } set { nextHandler = value; } } + /// + /// Invokes the next handler. + /// + /// The context. protected void InvokeNext(IRailsEngineContext context) { if (nextHandler != null) @@ -46,6 +65,11 @@ protected void InvokeNext(IRailsEngineContext context) } } + /// + /// Builds the standard message. + /// + /// The context. + /// protected string BuildStandardMessage(IRailsEngineContext context) { StringBuilder sbMessage = new StringBuilder(); diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/EmailHandler.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/EmailHandler.cs index 2a1ce315f..63195e73c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/EmailHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/EmailHandler.cs @@ -21,13 +21,19 @@ namespace Castle.MonoRail.Framework.Extensions.ExceptionChaining using Castle.Components.Common.EmailSender; /// - /// + /// A handle that sends the exception by email /// public class EmailHandler : AbstractExceptionHandler, IConfigurableHandler { private String mailTo; private String mailFrom = "donotreply@castleproject.org"; + /// + /// Implementors should check for known attributes and child nodes + /// within the exceptionHandlerNode + /// + /// The Xml node + /// that represents this handler on the configuration file public void Configure(XmlNode exceptionHandlerNode) { XmlAttribute mailToAtt = exceptionHandlerNode.Attributes["mailTo"]; @@ -49,6 +55,12 @@ public void Configure(XmlNode exceptionHandlerNode) } } + /// + /// Implementors should perform the action + /// on the exception. Note that the exception + /// is available in + /// + /// public override void Process(IRailsEngineContext context) { IEmailSender emailSender = (IEmailSender) context.GetService( typeof(IEmailSender) ); diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/ExceptionChainingExtension.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/ExceptionChainingExtension.cs index 92f3c7cf9..691dc0b85 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/ExceptionChainingExtension.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/ExceptionChainingExtension.cs @@ -23,13 +23,16 @@ namespace Castle.MonoRail.Framework.Extensions.ExceptionChaining /// /// This extension allow one to perform one or more steps /// in response to an exception threw by an action. + /// /// + /// /// + /// /// /// To successfully install this extension you must register /// it on the extensions node and the handlers within the exception node: /// - /// <monoRail> + /// <monorail> /// <extensions> /// <extension type="Castle.MonoRail.Framework.Extensions.ExceptionChaining.ExceptionChainingExtension, Castle.MonoRail.Framework" /> /// </extensions> @@ -38,7 +41,7 @@ namespace Castle.MonoRail.Framework.Extensions.ExceptionChaining /// <exceptionHandler type="Type name that implements IExceptionHandler" /> /// <exceptionHandler type="Type name that implements IExceptionHandler" /> /// </exception> - /// </monoRail> + /// </monorail> /// /// /// Controllers can request IExceptionProcessor through IServiceProvider @@ -68,7 +71,12 @@ public class ExceptionChainingExtension : IMonoRailExtension, IExceptionProcesso private IExceptionHandler firstHandler; #region IMonoRailExtension implementation - + + /// + /// Gives to the extension implementor a chance to read + /// attributes and child nodes of the extension node + /// + /// The node that defines the MonoRail extension public void SetExtensionConfigNode(XmlNode node) { // Ignored @@ -78,6 +86,10 @@ public void SetExtensionConfigNode(XmlNode node) #region IServiceEnabledComponent implementation + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { ExtensionManager manager = (ExtensionManager) @@ -109,7 +121,11 @@ public void Service(IServiceProvider provider) #endregion #region IExceptionProcessor implementation - + + /// + /// Initiates the ExceptionChainingExtension manualy + /// + /// The exception to process public void ProcessException(Exception exception) { if (exception == null) return; @@ -122,6 +138,10 @@ public void ProcessException(Exception exception) #endregion + /// + /// Called when an exception happens. + /// + /// The context. private void OnException(IRailsEngineContext context) { const String mrExceptionKey = "MonoRail.ExceptionHandled"; @@ -139,6 +159,11 @@ private void OnException(IRailsEngineContext context) } } + /// + /// Installs the exception handler. + /// + /// The node. + /// Name of the type. private void InstallExceptionHandler(XmlNode node, String typeName) { IExceptionHandler handler; diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/FilteredExceptionHandler.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/FilteredExceptionHandler.cs index a1decabf1..a1c997c28 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/FilteredExceptionHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/FilteredExceptionHandler.cs @@ -31,6 +31,12 @@ public class FilteredExceptionHandler : AbstractExceptionHandler, IConfigurableH { private ArrayList excludedTypes = new ArrayList(); + /// + /// Implementors should check for known attributes and child nodes + /// within the exceptionHandlerNode + /// + /// The Xml node + /// that represents this handler on the configuration file public void Configure(XmlNode exceptionHandlerNode) { XmlNodeList excludeNodes = exceptionHandlerNode.SelectNodes("exclude"); @@ -41,6 +47,12 @@ public void Configure(XmlNode exceptionHandlerNode) } } + /// + /// Implementors should perform the action + /// on the exception. Note that the exception + /// is available in + /// + /// public override void Process(IRailsEngineContext context) { Exception ex = context.LastException is TargetInvocationException diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/LoggingExceptionHandler.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/LoggingExceptionHandler.cs index 49fcce589..e90873821 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/LoggingExceptionHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExceptionChaining/LoggingExceptionHandler.cs @@ -17,10 +17,16 @@ namespace Castle.MonoRail.Framework.Extensions.ExceptionChaining using Castle.Core.Logging; /// - /// + /// Handles that logs the exception using the the logger factory. /// public class LoggingExceptionHandler : AbstractExceptionHandler { + /// + /// Implementors should perform the action + /// on the exception. Note that the exception + /// is available in + /// + /// public override void Process(IRailsEngineContext context) { ILoggerFactory factory = (ILoggerFactory) context.GetService(typeof (ILoggerFactory)); diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/ExtensionManager.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/ExtensionManager.cs index 6823eb638..882c64085 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/ExtensionManager.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/ExtensionManager.cs @@ -18,8 +18,16 @@ namespace Castle.MonoRail.Framework using System.ComponentModel; using System.ComponentModel.Design; + /// + /// + /// + /// public delegate void ExtensionHandler(IRailsEngineContext context); + /// + /// MonoRail's extension manager. + /// It fires events related to MonoRail that can be used to add additional behaviour. + /// public class ExtensionManager : MarshalByRefObject { private static readonly object ContextCreatedEvent = new object(); @@ -39,83 +47,127 @@ public class ExtensionManager : MarshalByRefObject private IServiceContainer serviceContainer; + /// + /// Initializes a new instance of the class. + /// + /// The service container. public ExtensionManager(IServiceContainer serviceContainer) { events = new EventHandlerList(); this.serviceContainer = serviceContainer; } + /// + /// Gets the service container. + /// + /// The service container. public IServiceContainer ServiceContainer { get { return serviceContainer; } } + /// + /// Occurs when a context is created. + /// public event ExtensionHandler ContextCreated { add { events.AddHandler(ContextCreatedEvent, value); } remove { events.RemoveHandler(ContextCreatedEvent, value); } } + /// + /// Occurs when a context is disposed. + /// public event ExtensionHandler ContextDisposed { add { events.AddHandler(ContextDisposedEvent, value); } remove { events.RemoveHandler(ContextDisposedEvent, value); } } + /// + /// Occurs when an action throws an exception. + /// public event ExtensionHandler ActionException { add { events.AddHandler(ActionExceptionEvent, value); } remove { events.RemoveHandler(ActionExceptionEvent, value); } } + /// + /// Occurs when an unhandled exception is thrown. + /// public event ExtensionHandler UnhandledException { add { events.AddHandler(UnhandledExceptionEvent, value); } remove { events.RemoveHandler(UnhandledExceptionEvent, value); } } + /// + /// Occurs when a session is adquired. + /// public event ExtensionHandler AcquireSessionState { add { events.AddHandler(AcquireSessionStateEvent, value); } remove { events.RemoveHandler(AcquireSessionStateEvent, value); } } + /// + /// Occurs when a session is released. + /// public event ExtensionHandler ReleaseSessionState { add { events.AddHandler(ReleaseSessionStateEvent, value); } remove { events.RemoveHandler(ReleaseSessionStateEvent, value); } } + /// + /// Occurs before pre process a handler. + /// public event ExtensionHandler PreProcess { add { events.AddHandler(PreProcessEvent, value); } remove { events.RemoveHandler(PreProcessEvent, value); } } + /// + /// Occurs after process a handler. + /// public event ExtensionHandler PostProcess { add { events.AddHandler(PostProcessEvent, value); } remove { events.RemoveHandler(PostProcessEvent, value); } } + /// + /// Occurs when a request needs to authenticate. + /// public event ExtensionHandler AuthenticateRequest { add { events.AddHandler(AuthenticateRequestEvent, value); } remove { events.RemoveHandler(AuthenticateRequestEvent, value); } } + /// + /// Occurs when a request needs to be authorized. + /// public event ExtensionHandler AuthorizeRequest { add { events.AddHandler(AuthorizeRequestEvent, value); } remove { events.RemoveHandler(AuthorizeRequestEvent, value); } } + /// + /// Occurs upon request cache resolval. + /// public event ExtensionHandler ResolveRequestCache { add { events.AddHandler(ResolveRequestCacheEvent, value); } remove { events.RemoveHandler(ResolveRequestCacheEvent, value); } } + /// + /// Occurs when a cache need to be updated. + /// public event ExtensionHandler UpdateRequestCache { add { events.AddHandler(UpdateRequestCacheEvent, value); } diff --git a/MonoRail/Castle.MonoRail.Framework/Extensions/Session/CustomSessionExtension.cs b/MonoRail/Castle.MonoRail.Framework/Extensions/Session/CustomSessionExtension.cs index 26b281b53..9885a9c37 100644 --- a/MonoRail/Castle.MonoRail.Framework/Extensions/Session/CustomSessionExtension.cs +++ b/MonoRail/Castle.MonoRail.Framework/Extensions/Session/CustomSessionExtension.cs @@ -22,7 +22,6 @@ namespace Castle.MonoRail.Framework.Extensions.Session using Castle.MonoRail.Framework.Adapters; using Castle.MonoRail.Framework.Configuration; - /// /// This extension allow one to provide a custom /// implementation of the session available on @@ -47,7 +46,12 @@ public class CustomSessionExtension : IMonoRailExtension private ICustomSessionFactory customSession; #region IMonoRailExtension implementation - + + /// + /// Gives to the extension implementor a chance to read + /// attributes and child nodes of the extension node + /// + /// The node that defines the MonoRail extension public void SetExtensionConfigNode(XmlNode node) { // Ignored @@ -57,6 +61,10 @@ public void SetExtensionConfigNode(XmlNode node) #region IServiceEnabledComponent implementation + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { ExtensionManager manager = (ExtensionManager) provider.GetService(typeof(ExtensionManager)); @@ -81,8 +89,8 @@ public void Service(IServiceProvider provider) /// The configuration private void Init(ExtensionManager manager, MonoRailConfiguration configuration) { - manager.AcquireSessionState += new ExtensionHandler(OnAdquireSessionState); - manager.ReleaseSessionState += new ExtensionHandler(OnReleaseSessionState); + manager.AcquireSessionState += OnAdquireSessionState; + manager.ReleaseSessionState += OnReleaseSessionState; XmlAttribute customSessionAtt = configuration.ConfigurationSection.Attributes["customSession"]; @@ -119,7 +127,8 @@ private void Init(ExtensionManager manager, MonoRailConfiguration configuration) /// /// Overrides the ISession instance on . /// - /// Note that the session available through IHttpContext is left untouched + /// + /// Note that the session available through IHttpContext is left untouched /// private void OnAdquireSessionState(IRailsEngineContext context) { diff --git a/MonoRail/Castle.MonoRail.Framework/Filters/AntiGoogleWebAcceleratorFilter.cs b/MonoRail/Castle.MonoRail.Framework/Filters/AntiGoogleWebAcceleratorFilter.cs index 62f61605b..a9d623b58 100644 --- a/MonoRail/Castle.MonoRail.Framework/Filters/AntiGoogleWebAcceleratorFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Filters/AntiGoogleWebAcceleratorFilter.cs @@ -16,8 +16,22 @@ namespace Castle.MonoRail.Framework.Filters { using System.Diagnostics; + /// + /// Pendent + /// public class AntiGoogleWebAcceleratorFilter : IFilter { + /// + /// Implementors should perform they filter logic and + /// return true if the action should be processed. + /// + /// When this filter is being invoked + /// Current context + /// The controller instance + /// + /// true if the action + /// should be invoked, otherwise false + /// public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { if (context.Request.Headers["HTTP_X_MOZ"].Equals("prefetch")) diff --git a/MonoRail/Castle.MonoRail.Framework/Filters/LocalizationFilter.cs b/MonoRail/Castle.MonoRail.Framework/Filters/LocalizationFilter.cs index 02c5e24fa..49c2c93ff 100644 --- a/MonoRail/Castle.MonoRail.Framework/Filters/LocalizationFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Filters/LocalizationFilter.cs @@ -56,6 +56,10 @@ public class LocalizationFilter : IFilter, IFilterAttributeAware #region IFilterAttributeAware Members + /// + /// Sets the filter. + /// + /// The filter. public FilterAttribute Filter { set @@ -74,6 +78,15 @@ public FilterAttribute Filter #region IFilter Members + /// + /// Executes a sequence of steps to determine the browser location/culture. + /// + /// When this filter is being invoked + /// Current context + /// The controller instance + /// + /// true if the action should be invoked, otherwise false + /// public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { try @@ -103,6 +116,11 @@ public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller co #region Get locale id from the store + /// + /// Gets the user language. + /// + /// The request. + /// private String GetUserLanguage(IRequest request) { if (request.UserLanguages != null && request.UserLanguages.Length > 0) @@ -111,6 +129,11 @@ private String GetUserLanguage(IRequest request) return null; } + /// + /// Gets the locale id. + /// + /// The context. + /// private String GetLocaleId(IRailsEngineContext context) { switch(setup.Store) diff --git a/MonoRail/Castle.MonoRail.Framework/Filters/RequestValidatorFilter.cs b/MonoRail/Castle.MonoRail.Framework/Filters/RequestValidatorFilter.cs index e30a094b3..1843b5146 100644 --- a/MonoRail/Castle.MonoRail.Framework/Filters/RequestValidatorFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Filters/RequestValidatorFilter.cs @@ -16,13 +16,29 @@ namespace Castle.MonoRail.Framework.Filters { using System.Web; + /// + /// Forces ASP.Net to perform a more complete request validation + /// public class RequestValidatorFilter : IFilter { + /// + /// Initializes a new instance of the class. + /// public RequestValidatorFilter() { } - public bool Perform(Castle.MonoRail.Framework.ExecuteEnum exec, IRailsEngineContext context, Controller controller) + /// + /// + /// + /// When this filter is being invoked + /// Current context + /// The controller instance + /// + /// true if the action + /// should be invoked, otherwise false + /// + public bool Perform(ExecuteEnum exec, IRailsEngineContext context, Controller controller) { try { @@ -32,7 +48,7 @@ public bool Perform(Castle.MonoRail.Framework.ExecuteEnum exec, IRailsEngineCont object dummy = context.Request.Form; dummy = context.Request.QueryString; } - catch (HttpRequestValidationException e) + catch(HttpRequestValidationException e) { context.Flash["validationError"] = context.Server.HtmlEncode(e.Message); } diff --git a/MonoRail/Castle.MonoRail.Framework/Flash.cs b/MonoRail/Castle.MonoRail.Framework/Flash.cs index 2c9373193..34b9109d3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Flash.cs +++ b/MonoRail/Castle.MonoRail.Framework/Flash.cs @@ -18,9 +18,15 @@ namespace Castle.MonoRail.Framework using System.Runtime.Serialization; using System.Collections; + /// + /// Keeps data across a single request using the session + /// [Serializable] public class Flash : Hashtable { + /// + /// Flash key + /// public static readonly String FlashKey = "flash"; [NonSerialized] @@ -32,10 +38,17 @@ public class Flash : Hashtable [NonSerialized] private bool hasSwept; + /// + /// Initializes a new instance of the class. + /// public Flash() { } + /// + /// Initializes a new instance of the class. + /// + /// The copy. public Flash(Flash copy) { if (copy == null) return; @@ -153,17 +166,35 @@ public void Now(object key, object value) base[key] = value; } + /// + /// Adds an element with the specified key and value into the . + /// + /// The key of the element to add. + /// The value of the element to add. The value can be null. + /// The is read-only.-or- The has a fixed size. + /// An element with the same key already exists in the . + /// key is null. public override void Add(object key, object value) { InternalAdd(key, value); } + /// + /// Gets or sets the with the specified key. + /// + /// public override object this[object key] { get { return base[key]; } set { InternalAdd(key, value); } } + /// + /// Gets a value indicating whether this instance has items to keep. + /// + /// + /// true if this instance has items to keep; otherwise, false. + /// internal bool HasItemsToKeep { get { return hasItemsToKeep; } diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/AbstractHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/AbstractHelper.cs index b9f552a05..9c3a125ec 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/AbstractHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/AbstractHelper.cs @@ -23,7 +23,7 @@ namespace Castle.MonoRail.Framework.Helpers /// Optional base class for helpers. /// Extend from this class only if your helpers needs /// a reference to the controller which is using it or - /// if you need to use one of the protected methods. + /// if you need to use one of the protected utility methods. /// public abstract class AbstractHelper : IControllerAware { @@ -73,6 +73,10 @@ public IServerUtility ServerUtility set { serverUtility = value; } } + /// + /// Gets the URL helper instance. + /// + /// The URL helper. protected UrlHelper UrlHelper { get { return (UrlHelper) controller.Helpers["UrlHelper"]; } @@ -93,7 +97,11 @@ protected void MergeOptions(IDictionary userOptions, IDictionary defaultOptions) { CommonUtils.MergeOptions(userOptions, defaultOptions); } - + + /// + /// Gets the current context. + /// + /// The current context. protected IRailsEngineContext CurrentContext { get { return controller.Context; } diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/AjaxHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/AjaxHelper.cs index 1d2596a35..d083cbeec 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/AjaxHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/AjaxHelper.cs @@ -22,8 +22,14 @@ namespace Castle.MonoRail.Framework.Helpers using Castle.MonoRail.Framework.Internal; using Castle.MonoRail.Framework.Services.AjaxProxyGenerator; + /// + /// XmlHttpRequest supported events. + /// public enum CallbackEnum { + /// + /// Not initialized + /// Uninitialized, /// /// Called when the remote document is being @@ -82,7 +88,7 @@ public class AjaxHelper : AbstractHelper, IServiceEnabledComponent /// The service proviver public void Service(IServiceProvider provider) { - this.ajaxProxyGenerator = (IAjaxProxyGenerator) provider.GetService(typeof(IAjaxProxyGenerator)); + ajaxProxyGenerator = (IAjaxProxyGenerator) provider.GetService(typeof(IAjaxProxyGenerator)); } #endregion @@ -880,6 +886,46 @@ private String GetUrlOption(IDictionary options) return "'" + url + "'"; } + /// + /// Populates the by analyzing the + /// options set on the helper + /// + /// + /// + /// The following options are analyzed + /// + /// + /// + /// type + /// boolean - sets the asynchronous + /// + /// + /// method + /// string - sets the method. Possible values are post/get + /// + /// + /// evalScripts + /// boolean + /// + /// + /// position + /// string - sets the place where content is inserted (Top, Bottom, After, Before) + /// + /// + /// form + /// if present, set the parameters request to send the current form serialized + /// + /// + /// with + /// if present, set its content as the parameters for the ajax request + /// + /// + /// + /// + /// + /// Options that will be used on the js side + /// Options passed to the helper method + /// protected String BuildAjaxOptions(IDictionary jsOptions, IDictionary options) { BuildCallbacks(jsOptions, options); @@ -949,6 +995,13 @@ private void BuildCallbacks(IDictionary jsOptions, IDictionary options) } } + /// + /// Builds the callback function. + /// + /// The callback. + /// The code. + /// The name. + /// protected String BuildCallbackFunction(CallbackEnum callback, String code, out String name) { name = String.Empty; @@ -971,6 +1024,13 @@ protected String BuildCallbackFunction(CallbackEnum callback, String code, out S return String.Format("function(request) {{ {0} }} ", code); } + /// + /// Builds the observer. + /// + /// The clazz. + /// The name. + /// The options. + /// protected String BuildObserver(String clazz, String name, IDictionary options) { if (options.Contains("update") && !options.Contains("with")) @@ -989,7 +1049,13 @@ protected String BuildObserver(String clazz, String name, IDictionary options) return js.ToString(); } - + + /// + /// Gets the options. + /// + /// The URL. + /// The options. + /// public IDictionary GetOptions(String url, IDictionary options) { if (options == null) @@ -1003,6 +1069,17 @@ public IDictionary GetOptions(String url, IDictionary options) return options; } + /// + /// Gets the options. + /// + /// The URL. + /// The id of element to be updated. + /// The with. + /// The loading. + /// The loaded. + /// The complete. + /// The interactive. + /// public IDictionary GetOptions(String url, String idOfElementToBeUpdated, object with, String loading, String loaded, String complete, String interactive) { diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/DictHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/DictHelper.cs index 1e25ec3cd..530c4e3c3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/DictHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/DictHelper.cs @@ -37,6 +37,11 @@ public IDictionary CreateDict(params String[] args) return Create(args); } + /// + /// Creates a dictionary from specified arguments. + /// + /// The arguments. + /// public static IDictionary Create(params String[] args) { IDictionary dict = new HybridDictionary(true); @@ -62,6 +67,11 @@ public static IDictionary Create(params String[] args) return dict; } + /// + /// Creates a dictionary fros a name value collection. + /// + /// The collection. + /// public IDictionary FromNameValueCollection(NameValueCollection collection) { IDictionary dict = new HybridDictionary(true); diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/EffectsFatHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/EffectsFatHelper.cs index 34aee2897..ea383df80 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/EffectsFatHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/EffectsFatHelper.cs @@ -19,13 +19,24 @@ namespace Castle.MonoRail.Framework.Helpers /// /// Just apply the CSS class "fade" to any element and it will fade from yellow /// to its background color or white if none is specified. + /// + /// Key Features
/// - /// Key Features - /// * Fade an infinite number of elements. - /// * No inline JavaScript. Simply give an element a class of "fade", the script does the rest "automagically". - /// * Background color aware. FAT will do better than simply fade to white if the element (or it's parents) have a CSS background color, it will fade to that background color instead. - /// * Fade from any color. For example, if you wanted a list of error messages to fade out from red you would simply give the list a class of "fade-FF0000". - /// * Super smooth fading. By default, elements will fade at 30 frames per second (the same rate as a television) over 3 seconds. You can adjust this to any framerate and any duration. You could easily fade elements at 60 frames per second over 4, 5, 10 seconds! + /// * Fade an infinite number of elements.
+ /// + /// * No inline JavaScript. Simply give an element a class of "fade", the script does the rest "automagically".
+ /// + /// * Background color aware. FAT will do better than simply fade to white if the element (or it's parents) have a + /// CSS background color, it will fade to that background color instead.
+ /// + /// * Fade from any color. For example, if you wanted a list of error messages + /// to fade out from red you would simply give the list a class of "fade-FF0000".
+ /// + /// * Super smooth fading. By default, elements will fade at 30 frames per second + /// (the same rate as a television) over 3 seconds. You can adjust this to any + /// framerate and any duration. You could easily fade elements at 60 frames + /// per second over 4, 5, 10 seconds!
+ ///
///
/// /// NOTE: All elements to be faded must have an id tag! @@ -45,6 +56,10 @@ public String InstallScripts() return RenderScriptBlockToSource("/MonoRail/Files/EffectsFatScripts"); } + /// + /// Renders a Javascript library inside a single script tag. + /// + /// [Obsolete("Please use the preferred InstallScripts function.")] public String GetJavascriptFunctions() { diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/FormHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/FormHelper.cs index 45f573942..665d62891 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/FormHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/FormHelper.cs @@ -22,46 +22,233 @@ namespace Castle.MonoRail.Framework.Helpers using System.IO; using System.Reflection; using System.Text; + using Services; + using HtmlTextWriter = System.Web.UI.HtmlTextWriter; + using Castle.Core; using Castle.Core.Logging; + using Castle.MonoRail.Framework; using Castle.MonoRail.Framework.Helpers.ValidationStrategy; using Castle.MonoRail.Framework.Internal; - using HtmlTextWriter = System.Web.UI.HtmlTextWriter; using Castle.Components.Binder; using Castle.Components.Validator; + /// + /// Represents all scopes that the + /// uses to search for root values + /// public enum RequestContext { + /// + /// All scopes should be searched + /// All, + /// + /// Only PropertyBag should be searched + /// PropertyBag, + /// + /// Only Flash should be searched + /// Flash, + /// + /// Only Session should be searched + /// Session, - Request, + /// + /// Only Request should be searched + /// + Request, + /// + /// Only Params should be searched + /// Params } /// - /// The FormHelper allows you to output Html Input elements using the - /// conventions necessary to use the DataBinder on the server side. + /// The FormHelper allows you to output html input elements using the + /// conventions necessary to use the DataBinder on the server side. Ultimately it + /// allows you do to a bi-directional binding -- if used properly. + /// + /// + /// + /// + /// + /// + /// Using simple values: + /// On the controller: + /// + /// + /// public void MyAction() + /// { + /// PropertyBag["name"] = "John Doe"; + /// } + /// + /// + /// On the view (using NVelocity syntax) + /// + /// + /// $Form.TextField('name') // Renders an input text with value "John Doe" + /// + /// /// - /// It also query the objects available on the context to show property - /// values correctly, saving you the burden of filling text inputs, selects, - /// checkboxes and radios. + /// Using complex objects: /// + /// + /// + /// public void MyAction() + /// { + /// PropertyBag["user"] = new User("John Doe"); + /// } + /// + /// + /// On the view (using NVelocity syntax) + /// + /// + /// $Form.TextField('user.name') // Renders an input text with value "John Doe" + /// + /// + /// + /// + /// Elements generation
/// - /// Mask support. + /// + /// + /// Buttons + /// + ///
+ ///
+ /// + ///
+ ///
+ /// + /// + /// Select + /// + /// + /// + /// + /// + /// + /// Text area + /// + /// + /// + /// + /// + /// + /// Hidden field + /// + /// + /// + /// + /// + /// + /// Checkbox field + /// + ///
+ /// + ///
+ ///
+ /// + /// + /// Radio field + /// + /// + /// + /// + /// + /// + /// File upload + /// + /// + /// + /// + /// + /// + /// Text field + /// + ///
+ ///
+ ///
+ /// + ///
+ ///
+ /// + /// + /// Password field + /// + ///
+ /// + ///
+ ///
+ /// + /// + /// Labels + /// + ///
+ /// + ///
+ ///
+ /// + ///
+ ///
+ /// + /// + /// FormValidation
+ /// The following operations are related to the Form Validation support: + ///
+ /// + /// + /// and + /// Opens/close the form tag. They are required to use the form validation + /// + /// + /// + /// Disables validation altogether + /// + /// + /// + /// Sets a custom Browser validator provider + /// + /// + /// + /// Configures the helper to use the prototype easy field validation. Must be invoked before FormTag + /// + /// + /// + /// Configures the helper to use the fValidate. Deprecated. + /// + /// + /// + /// Configures the helper to use the Zebda. Must be invoked before FormTag + /// + /// + /// + /// + /// Mask support.
/// For most elements, you can use /// the entries mask and optionally mask_separator to define a /// mask for your inputs. Kudos to mordechai Sandhaus - 52action.com ///
+ /// /// /// For example: mask='2,5',mask_separator='/' will mask the content to '12/34/1234' /// - ///
+ ///
public class FormHelper : AbstractHelper, IServiceEnabledComponent { + /// + /// Common property flags for reflection + /// protected static readonly BindingFlags PropertyFlags = BindingFlags.GetProperty|BindingFlags.Public|BindingFlags.Instance|BindingFlags.IgnoreCase; + /// + /// Common property flags for reflection (with declared only) + /// protected static readonly BindingFlags PropertyFlags2 = BindingFlags.GetProperty|BindingFlags.Public|BindingFlags.Instance|BindingFlags.IgnoreCase|BindingFlags.DeclaredOnly; + /// + /// Common field flags for reflection + /// protected static readonly BindingFlags FieldFlags = BindingFlags.GetField|BindingFlags.Public|BindingFlags.Instance|BindingFlags.IgnoreCase; private int formCount; @@ -71,6 +258,9 @@ public class FormHelper : AbstractHelper, IServiceEnabledComponent private IBrowserValidatorProvider validatorProvider = new PrototypeWebValidator(); private BrowserValidationConfiguration validationConfig; + /// + /// Logger instance + /// protected ILogger logger = NullLogger.Instance; #region IServiceEnabledComponent implementation @@ -122,6 +312,47 @@ public string InstallScripts() /// The action attribute generation will use /// ///
+ /// + /// + /// + /// + /// + /// + /// $Form.FormTag("%{action='Save',id='productform'}") + /// + /// + /// Outputs: + /// + /// + /// <form method='post' action='/[appdir]/[controller]/Save.[extension]' id='productform'> + /// + /// + /// + /// + /// + /// The parameters are used to build a url and also to form the tag. For notes on the url + /// see . The other parameters supported + /// follows + /// + /// + /// + /// noaction + /// boolean. Disables the generation of an action + /// + /// + /// method + /// string. The http method to use. Defaults to post + /// + /// + /// id + /// string. The form id. + /// + /// + /// + /// More parameters can be accepted depending on the form validation strategy you are using (if any). + /// + /// + /// /// The parameters for the tag or for action and form validation generation. /// public string FormTag(IDictionary parameters) @@ -148,6 +379,39 @@ public string FormTag(IDictionary parameters) /// The action attribute generation will use /// ///
+ /// + /// + /// + /// + /// $Form.FormTag('mytarget.castle', "%{id='productform'}") + /// + /// + /// Outputs: + /// + /// + /// <form method='post' action='mytarget.castle' id='productform'> + /// + /// + /// + /// + /// + /// The following parameters are accepted. + /// + /// + /// + /// method + /// string. The http method to use. Defaults to post + /// + /// + /// id + /// string. The form id. + /// + /// + /// + /// More parameters can be accepted depending on the form validation strategy you are using (if any). + /// + /// + /// /// The hardcoded url. /// The parameters for the tag or for action and form validation generation. /// @@ -178,7 +442,7 @@ public string FormTag(string url, IDictionary parameters) } /// - /// Generate Ajax form tag for ajax based form submission + /// Generate Ajax form tag for ajax based form submission. Experimental. /// /// /// @@ -240,6 +504,10 @@ public string AjaxFormTag(IDictionary parameters) /// /// Renders an end form element. /// + /// + /// Should be used if you are using form validation. Some validation approaches + /// uses the end form before or after appending a javascript snippet. + /// /// public string EndFormTag() { @@ -257,13 +525,22 @@ public string EndFormTag() #endregion - #region Object scope related (TODO: Document) + #region Object scope related + /// + /// Pushes the specified target. Experimental. + /// + /// The target. public void Push(string target) { Push(target, null); } + /// + /// Pushes the specified target. Experimental. + /// + /// The target. + /// The parameters. public void Push(string target, IDictionary parameters) { string disableValidation = CommonUtils.ObtainEntryAndRemove(parameters, "disablevalidation", "false"); @@ -288,6 +565,9 @@ public void Push(string target, IDictionary parameters) } } + /// + /// Pops this instance. Experimental. + /// public void Pop() { objectStack.Pop(); @@ -300,7 +580,7 @@ public void Pop() /// /// Generates an input submit element. /// - /// The value. + /// The value/caption for the button. /// The element tag public string Submit(string value) { @@ -310,7 +590,7 @@ public string Submit(string value) /// /// Generates an input submit element. /// - /// The value. + /// The value/caption for the button. /// Attributes for the FormHelper method and for the html element it generates /// The element tag public string Submit(string value, IDictionary attributes) @@ -380,7 +660,7 @@ public string ButtonElement(string innerText, string type, IDictionary attribute /// Generates an input text form element /// with the supplied value ///
- /// The object to get the value from and to be based on to create the element name. + /// The string to be used to create the element name. /// Value to supply to the element (instead of querying the target) /// The generated form element public string TextFieldValue(string target, object value) @@ -392,7 +672,7 @@ public string TextFieldValue(string target, object value) /// Generates an input text form element /// with the supplied value ///
- /// The object to get the value from and to be based on to create the element name. + /// The string to be used to create the element name. /// Value to supply to the element (instead of querying the target) /// Attributes for the FormHelper method and for the html element it generates /// The generated form element @@ -411,6 +691,33 @@ public string TextFieldValue(string target, object value, IDictionary attributes /// The value is extracted from the target (if available) /// ///
+ /// + /// + /// The following example assumes that an entry username exists on the + /// or or + /// + /// + /// $Form.TextField('username') + /// + /// Outputs: + /// + /// <input type='text' name='username' id='username' value='John Doe' /> + /// + /// + /// + /// The following example assumes that an entry user exists on the + /// or or + /// + /// + /// + /// $Form.TextField('user.name') + /// + /// Outputs: + /// + /// <input type='text' name='user.name' id='user_name' value='John Doe' /> + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// The generated form element public string TextField(string target) @@ -424,6 +731,9 @@ public string TextField(string target) /// The value is extracted from the target (if available) /// ///
+ /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// Attributes for the FormHelper method and for the html element it generates /// The generated form element @@ -440,6 +750,46 @@ public string TextField(string target, IDictionary attributes) #endregion + #region FilteredTextField + + /// + /// Generates an input text element with a javascript that prevents the + /// chars listed in the forbid attribute from being entered. + /// + /// + /// You must pass an forbid value through the dictionary. + /// It must be a comma separated list of chars that cannot be accepted on the field. + /// For example: + /// + /// + /// FormHelper.FilteredTextField("product.price", {forbid='46'}) + /// + /// In this case the key code 46 (period) will not be accepted on the field. + /// + /// The value is extracted from the target (if available). + /// + /// The object to get the value from and to be based on to create the element name. + /// Attributes for the FormHelper method and for the html element it generates + /// The generated form element. + /// + /// You must invoke before using it. + /// + public string FilteredTextField(string target, IDictionary attributes) + { + target = RewriteTargetIfWithinObjectScope(target); + + object value = ObtainValue(target); + + attributes = attributes != null ? attributes : new Hashtable(); + + ApplyFilterOptions(attributes); + ApplyValidation(InputElementType.Text, target, ref attributes); + + return CreateInputElement("text", target, value, attributes); + } + + #endregion + #region NumberField /// @@ -449,11 +799,17 @@ public string TextField(string target, IDictionary attributes) /// The value is extracted from the target (if available) /// /// - /// The object to get the value from and to be based on to create the element name. - /// The generated form element + /// + /// + /// + /// /// - /// You must invoke before using it + /// You must include the formhelper javascript functions to use the NumberField. + /// See /// + /// + /// The object to get the value from and to be based on to create the element name. + /// The generated form element public string NumberField(string target) { return NumberField(target, null); @@ -465,6 +821,15 @@ public string NumberField(string target) /// /// The value is extracted from the target (if available) /// + ///
+ /// + /// The object to get the value from and to be based on to create the element name. + /// Attributes for the FormHelper method and for the html element it generates + /// The generated form element + /// + /// + /// You must include the formhelper javascript functions to use the NumberField. + /// See /// /// You can optionally pass an exceptions value through the dictionary. /// It must be a comma separated list of chars that can be accepted on the field. @@ -483,12 +848,6 @@ public string NumberField(string target) /// FormHelper.NumberField("product.price", {forbid='46'}) /// /// In this case the key code 46 (period) will not be accepted on the field. - ///
- /// The object to get the value from and to be based on to create the element name. - /// Attributes for the FormHelper method and for the html element it generates - /// The generated form element - /// - /// You must invoke before using it /// public string NumberField(string target, IDictionary attributes) { @@ -513,11 +872,17 @@ public string NumberField(string target, IDictionary attributes) /// chars other than numbers from being entered. The value is not gathered /// from the context, instead you specify it on the second argument ///
+ /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// The current value to output. /// The generated form element + /// /// - /// You must invoke before using it + /// You must include the formhelper javascript functions to use the NumberField. + /// See /// public string NumberFieldValue(string target, object value) { @@ -528,37 +893,25 @@ public string NumberFieldValue(string target, object value) /// Generates an input text element with a javascript that prevents /// chars other than numbers from being entered. The value is not gathered /// from the context, instead you specify it on the second argument - /// - /// You can optionally pass an exceptions value through the dictionary. - /// It must be a comma separated list of chars that can be accepted on the field. - /// For example: - /// - /// - /// FormHelper.NumberField("product.price", {exceptions='13,10,11'}) - /// - /// In this case the key codes 13, 10 and 11 will be accepted on the field. - /// - /// You can aslo optionally pass an forbid value through the dictionary. - /// It must be a comma separated list of chars that cannot be accepted on the field. - /// For example: - /// - /// - /// FormHelper.NumberField("product.price", {forbid='46'}) - /// - /// In this case the key code 46 (period) will not be accepted on the field. /// + /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// The current value to output. /// Attributes for the FormHelper method and for the html element it generates /// The generated form element + /// /// - /// You must invoke before using it + /// You must include the formhelper javascript functions to use the NumberField. + /// See /// public string NumberFieldValue(string target, object value, IDictionary attributes) { target = RewriteTargetIfWithinObjectScope(target); - attributes = attributes != null ? attributes : new Hashtable(); + attributes = attributes ?? new Hashtable(); ApplyNumberOnlyOptions(attributes); ApplyValidation(InputElementType.Text, target, ref attributes); @@ -719,59 +1072,6 @@ public string PasswordNumberField(string target, IDictionary attributes) #endregion - #region TextFieldFormat - - /// - /// Generates an input text element and formats the value - /// with the specified format - /// - /// The value is extracted from the target (if available) - /// - /// - /// The object to get the value from and to be based on to create the element name. - /// The format string - /// The generated form element - [Obsolete("Use the attribute 'textformat' instead")] - public string TextFieldFormat(string target, string formatString) - { - return TextFieldFormat(target, formatString, null); - } - - /// - /// Generates an input text element and formats the value - /// with the specified format - /// - /// The value is extracted from the target (if available) - /// - /// - /// The object to get the value from and to be based on to create the element name. - /// The format string - /// Attributes for the FormHelper method and for the html element it generates - /// The generated form element - [Obsolete("Use the attribute 'textformat' instead")] - public string TextFieldFormat(string target, string formatString, IDictionary attributes) - { - target = RewriteTargetIfWithinObjectScope(target); - - object value = ObtainValue(target); - - if (value != null) - { - IFormattable formattable = value as IFormattable; - - if (formattable != null) - { - value = formattable.ToString(formatString, null); - } - } - - ApplyValidation(InputElementType.Text, target, ref attributes); - - return CreateInputElement("text", target, value, attributes); - } - - #endregion - #region LabelFor /// @@ -904,6 +1204,57 @@ public string HiddenField(string target, object value, IDictionary attributes) /// the attributes as it would not be inferred. /// /// + /// + /// + /// Consider the following action code: + /// + /// public void Index() + /// { + /// // data source + /// PropertyBag["primenumbers"] = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23 }; + /// + /// // initial selection + /// PropertyBag["selectedPrimes"] = new int[] { 11, 19 }; + /// } + /// + /// + /// And the respective view code + /// + /// + /// #set($items = $FormHelper.CreateCheckboxList("selectedPrimes", $primenumbers)) + /// + /// #foreach($elem in $items) + /// $items.Item() $elem + /// #end + /// + /// + /// That will generates the following html: + /// + /// + /// <input type="checkbox" id="selectedPrimes_0_" name="selectedPrimes[0]" value="2" /> 2 + /// <input type="checkbox" id="selectedPrimes_1_" name="selectedPrimes[1]" value="3" /> 3 + /// <input type="checkbox" id="selectedPrimes_2_" name="selectedPrimes[2]" value="5" /> 5 + /// <input type="checkbox" id="selectedPrimes_3_" name="selectedPrimes[3]" value="7" /> 7 + /// <input type="checkbox" id="selectedPrimes_4_" name="selectedPrimes[4]" value="11" checked="checked" /> 11 + /// <input type="checkbox" id="selectedPrimes_5_" name="selectedPrimes[5]" value="13" /> 13 + /// <input type="checkbox" id="selectedPrimes_6_" name="selectedPrimes[6]" value="17" /> 17 + /// <input type="checkbox" id="selectedPrimes_7_" name="selectedPrimes[7]" value="19" checked="checked" /> 19 + /// <input type="checkbox" id="selectedPrimes_8_" name="selectedPrimes[8]" value="23" /> 23 + /// + /// + /// + /// To customize the id, you can call the overload: + /// + /// + /// + /// #set($items = $FormHelper.CreateCheckboxList("selectedPrimes", $primenumbers)) + /// + /// #foreach($elem in $items) + /// $items.Item("myId${velocityCount}") $Form.LabelFor("myId${velocityCount}", $elem.ToString())
+ /// #end + ///
+ ///
+ /// /// The object to get the value from and to be based on to create the element name. /// The set of available elements /// The generated form element @@ -931,6 +1282,43 @@ public CheckboxList CreateCheckboxList(string target, IEnumerable dataSource) /// the attributes as it would not be inferred. /// /// + /// + /// + /// + /// + /// Consider the following action code: + /// + /// public void Index() + /// { + /// Category[] categories = new Category[] { new Category(1, "Music"), new Category(2, "Humor"), new Category(3, "Politics") }; + /// PropertyBag["categories"] = categories; // datasource + /// + /// Blog blog = new Blog(); + /// blog.Categories = new Category[] { new Category(2, "Humor") }; // initial selection + /// PropertyBag["blog"] = blog; + /// } + /// + /// + /// And the respective view code + /// + /// + /// #set($items = $Form.CreateCheckboxList("blog.categories", $categories, "%{value='Id'}")) + /// + /// #foreach($elem in $items) + /// $items.Item() $elem + /// #end + /// + /// + /// That will generates the following html: + /// + /// + /// <input type="checkbox" id="blog_categories_0_" name="blog.categories[0].Id" value="1" /> Music + /// <input type="checkbox" id="blog_categories_1_" name="blog.categories[1].Id" value="2" checked="checked" /> Humor + /// <input type="checkbox" id="blog_categories_2_" name="blog.categories[2].Id" value="3" /> Politics + /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// The set of available elements /// Attributes for the FormHelper method and for the html element it generates @@ -945,7 +1333,7 @@ public CheckboxList CreateCheckboxList(string target, IEnumerable dataSource, ID } /// - /// + /// Outputs a checkbox element (for internal use) /// /// /// The object to get the value from and to be based on to create the element name. @@ -975,19 +1363,13 @@ internal string CheckboxItem(int index, string target, string suffix, SetItem it computedTarget += "." + suffix; } - string result = CreateInputElement("checkbox", elementId, computedTarget, item.Value, attributes); - - // I need a test case to justify this case -// string hiddenElementId = elementId + "H"; -// string hiddenElementValue = CommonUtils.ObtainEntryAndRemove(attributes, "falseValue", "false"); -// -// result += CreateInputElement("hidden", hiddenElementId, target, hiddenElementValue, null); - - return result; + return CreateInputElement("checkbox", elementId, computedTarget, item.Value, attributes); } /// - /// + /// This class is an enumerable list of checkboxes. + /// It uses the to manage the sets + /// and to control the check/uncheck state. /// public sealed class CheckboxList : IEnumerable, IEnumerator { @@ -1000,11 +1382,11 @@ public sealed class CheckboxList : IEnumerable, IEnumerator private int index = -1; /// - /// + /// Initializes a new instance of the class. /// - /// + /// The helper. /// The object to get the value from and to be based on to create the element name. - /// + /// The initial selection set. /// The set of available elements /// Attributes for the FormHelper method and for the html element it generates public CheckboxList(FormHelper helper, string target, @@ -1014,7 +1396,7 @@ public CheckboxList(FormHelper helper, string target, this.helper = helper; this.target = target; - this.attributes = attributes == null ? new HybridDictionary(true) : attributes; + this.attributes = attributes ?? new HybridDictionary(true); operationState = SetOperation.IterateOnDataSource(initialSelectionSet, dataSource, attributes); enumerator = operationState.GetEnumerator(); @@ -1059,11 +1441,24 @@ public string Item(string id) return helper.CheckboxItem(index, target, operationState.TargetSuffix, CurrentSetItem, attributes); } + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return this; } + /// + /// Advances the enumerator to the next element of the collection. + /// + /// + /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. + /// + /// The collection was modified after the enumerator was created. public bool MoveNext() { hasMovedNext = true; @@ -1074,17 +1469,31 @@ public bool MoveNext() return hasItem; } + /// + /// Sets the enumerator to its initial position, which is before the first element in the collection. + /// + /// The collection was modified after the enumerator was created. public void Reset() { index = -1; enumerator.Reset(); } + /// + /// Gets the current element in the collection. + /// + /// + /// The current element in the collection. + /// The enumerator is positioned before the first element of the collection or after the last element. public object Current { get { return CurrentSetItem.Item; } } - + + /// + /// Gets the current set item. + /// + /// The current set item. public SetItem CurrentSetItem { get { return enumerator.Current as SetItem; } @@ -1101,6 +1510,23 @@ public SetItem CurrentSetItem /// This allow the process the be aware of the unchecked value /// and act accordingly. /// + /// + /// + /// Consider the following view code: + /// + /// + /// $Form.CheckboxField('user.disabled') + /// + /// + /// That is going to output: + /// + /// + /// <input type="checkbox" id="user_disabled" name="user.disabled" value="true" /> + /// <input type="hidden" id="user_disabledH" name="user.disabled" value="false" /> + /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// The generated form element public string CheckboxField(string target) @@ -1113,12 +1539,18 @@ public string CheckboxField(string target) /// way to send a value if the primary checkbox is not checked. /// This allow the process the be aware of the unchecked value /// and act accordingly. + /// /// /// The checked and unchecked values sent to the server defaults /// to true and false. You can override them using the - /// parameters trueValue and falseValue. + /// parameters trueValue and falseValue, but the DataBinder is prepared only + /// to treat boolean arrays. /// + /// /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// Attributes for the FormHelper method and for the html element it generates /// The generated form element @@ -1175,6 +1607,41 @@ public string CheckboxField(string target, IDictionary attributes) /// It will automatically check the radio if the target /// evaluated value is equal to the specified valueToSend. /// + /// + /// + /// Consider the following action code: + /// + /// + /// public void Index() + /// { + /// PropertyBag["mode"] = FileMode.Truncate; + /// } + /// + /// + /// And the following view code: + /// + /// + /// $Form.RadioField("mode", "Append") FileMode.Append + /// $Form.RadioField("mode", "Create") FileMode.Create + /// $Form.RadioField("mode", "CreateNew") FileMode.CreateNew + /// $Form.RadioField("mode", "Open") FileMode.Open + /// $Form.RadioField("mode", "OpenOrCreate", "%{id='customhtmlid'}") FileMode.OpenOrCreate + /// $Form.RadioField("mode", "Truncate") FileMode.Truncate + /// + /// + /// That is going to output: + /// + /// + /// <input type="radio" id="mode" name="mode" value="Append" /> FileMode.Append + /// <input type="radio" id="mode" name="mode" value="Create" /> FileMode.Create + /// <input type="radio" id="mode" name="mode" value="CreateNew" /> FileMode.CreateNew + /// <input type="radio" id="mode" name="mode" value="Open" /> FileMode.Open + /// <input type="radio" id="customhtmlid" name="mode" value="OpenOrCreate" /> FileMode.OpenOrCreate + /// <input type="radio" id="mode" name="mode" value="Truncate" checked="checked" /> FileMode.Truncate + /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// /// The generated form element @@ -1189,6 +1656,9 @@ public string RadioField(string target, object valueToSend) /// It will automatically check the radio if the target /// evaluated value is equal to the specified valueToSend. /// + /// + /// + /// /// The object to get the value from and to be based on to create the element name. /// /// Attributes for the FormHelper method and for the html element it generates @@ -1352,6 +1822,14 @@ public string Select(string target, object selectedValue, IEnumerable dataSource return GenerateSelect(target, selectedValue, dataSource, attributes); } + /// + /// Generates the select. + /// + /// The target. + /// The selected value. + /// The data source. + /// The attributes. + /// protected virtual string GenerateSelect(string target, object selectedValue, IEnumerable dataSource, IDictionary attributes) { string id = CreateHtmlId(target); @@ -1427,12 +1905,12 @@ protected virtual string GenerateSelect(string target, object selectedValue, IEn #endregion - #region Enum + #region Enum /// - /// + /// Creates a list of pairs for the enum type. /// - /// + /// enum type. /// public static Pair[] EnumToPairs(Type enumType) { @@ -1502,6 +1980,12 @@ public void DisableValidation() isValidationDisabled = true; } + /// + /// Applies the validation. + /// + /// Type of the input. + /// The target. + /// The attributes. protected virtual void ApplyValidation(InputElementType inputType, string target, ref IDictionary attributes) { bool disableValidation = CommonUtils.ObtainEntryAndRemove(attributes, "disablevalidation", "false") == "true"; @@ -1562,6 +2046,11 @@ private bool IsValidationEnabled #region protected members + /// + /// Rewrites the target if within object scope. + /// + /// The target. + /// protected string RewriteTargetIfWithinObjectScope(string target) { if (objectStack.Count == 0) @@ -1631,13 +2120,26 @@ protected virtual string CreateInputElement(string type, string id, string targe type, id, target, value, GetAttributes(attributes)); } + /// + /// Creates the input element. + /// + /// The type. + /// The value. + /// The attributes. + /// protected virtual string CreateInputElement(string type, string value, IDictionary attributes) { return String.Format("", type, FormatIfNecessary(value, attributes), GetAttributes(attributes)); } - protected string FormatIfNecessary(object value, IDictionary attributes) + /// + /// Formats if necessary. + /// + /// The value. + /// The attributes. + /// + protected static string FormatIfNecessary(object value, IDictionary attributes) { string formatString = CommonUtils.ObtainEntryAndRemove(attributes, "textformat"); @@ -1658,6 +2160,13 @@ protected string FormatIfNecessary(object value, IDictionary attributes) return value.ToString(); } + /// + /// Obtains the target property. + /// + /// The context. + /// The target. + /// The action. + /// protected PropertyInfo ObtainTargetProperty(RequestContext context, string target, Action action) { string[] pieces; @@ -1703,9 +2212,9 @@ protected object ObtainValue(RequestContext context, string target) } /// - /// + /// Obtains the root instance. /// - /// + /// The context. /// The object to get the value from and to be based on to create the element name. /// The generated form element protected object ObtainRootInstance(RequestContext context, string target) @@ -1736,6 +2245,13 @@ protected object ObtainRootInstance(RequestContext context, string target) return rootInstance; } + /// + /// Obtains the root instance. + /// + /// The context. + /// The target. + /// The pieces. + /// protected object ObtainRootInstance(RequestContext context, string target, out string[] pieces) { pieces = target.Split(new char[] {'.'}); @@ -1770,6 +2286,13 @@ protected object ObtainRootInstance(RequestContext context, string target, out s return rootInstance; } + /// + /// Obtains the type of the root. + /// + /// The context. + /// The target. + /// The pieces. + /// private Type ObtainRootType(RequestContext context, string target, out string[] pieces) { pieces = target.Split(new char[] { '.' }); @@ -1966,6 +2489,13 @@ private static void ApplyNumberOnlyOptions(IDictionary attributes) attributes["onKeyPress"] = "return monorail_formhelper_numberonly(event, [" + list + "], [" + forbid + "]);"; } + private static void ApplyFilterOptions(IDictionary attributes) + { + string forbid = CommonUtils.ObtainEntryAndRemove(attributes, "forbid", String.Empty); + + attributes["onKeyPress"] = "return monorail_formhelper_inputfilter(event, [" + forbid + "]);"; + } + private void AssertIsValidArray(object instance, string property, int index) { Type instanceType = instance.GetType(); @@ -1998,7 +2528,7 @@ private void AssertIsValidArray(object instance, string property, int index) } } - private object GetArrayElement(object instance, int index) + private static object GetArrayElement(object instance, int index) { IList list = instance as IList; @@ -2192,27 +2722,56 @@ private static string CreateHtmlId(string name) return sb.ToString(); } + /// + /// Abstracts the approach to access values on objects. + /// public abstract class ValueGetter { + /// + /// Gets the name. + /// + /// The name. public abstract string Name { get; } + /// + /// Gets the value. + /// + /// The instance. + /// public abstract object GetValue(object instance); } + /// + /// Implementation of + /// that uses reflection to access values + /// public class ReflectionValueGetter : ValueGetter { private PropertyInfo propInfo; + /// + /// Initializes a new instance of the class. + /// + /// The prop info. public ReflectionValueGetter(PropertyInfo propInfo) { this.propInfo = propInfo; } + /// + /// Gets the name. + /// + /// The name. public override string Name { get { return propInfo.Name; } } + /// + /// Gets the value. + /// + /// The instance. + /// public override object GetValue(object instance) { try @@ -2233,20 +2792,37 @@ public override object GetValue(object instance) } } + /// + /// Implementation of + /// to access DataRow's value + /// public class DataRowValueGetter : ValueGetter { private readonly string columnName; + /// + /// Initializes a new instance of the class. + /// + /// Name of the column. public DataRowValueGetter(string columnName) { this.columnName = columnName; } + /// + /// Gets the name. + /// + /// The name. public override string Name { get { return columnName; } } + /// + /// Gets the value. + /// + /// The instance. + /// public override object GetValue(object instance) { DataRow row = (DataRow) instance; @@ -2255,20 +2831,37 @@ public override object GetValue(object instance) } } + /// + /// Implementation of + /// to access DataRowView's value + /// public class DataRowViewValueGetter : ValueGetter { private readonly string columnName; + /// + /// Initializes a new instance of the class. + /// + /// Name of the column. public DataRowViewValueGetter(string columnName) { this.columnName = columnName; } + /// + /// Gets the name. + /// + /// The name. public override string Name { get { return columnName; } } + /// + /// Gets the value. + /// + /// The instance. + /// public override object GetValue(object instance) { DataRowView row = (DataRowView)instance; @@ -2277,41 +2870,79 @@ public override object GetValue(object instance) } } + /// + /// Empty implementation of a + /// public class NoActionGetter : ValueGetter { + /// + /// Gets the name. + /// + /// The name. public override string Name { get { return string.Empty; } } + /// + /// Gets the value. + /// + /// The instance. + /// public override object GetValue(object instance) { return null; } } + /// + /// Implementation of + /// to access enum fields + /// public class EnumValueGetter : ValueGetter { - private Type enumType; + private readonly Type enumType; + /// + /// Initializes a new instance of the class. + /// + /// Type of the enum. public EnumValueGetter(Type enumType) { this.enumType = enumType; } + /// + /// Gets the name. + /// + /// The name. public override string Name { get { return string.Empty; } } + /// + /// Gets the value. + /// + /// The instance. + /// public override object GetValue(object instance) { return Enum.Format(enumType, Enum.Parse(enumType, Convert.ToString(instance)), "d"); } } + /// + /// Abstract factory for implementations + /// public class ValueGetterAbstractFactory { + /// + /// Creates the specified target type. + /// + /// Type of the target. + /// Name of the key. + /// public static ValueGetter Create(Type targetType, string keyName) { if (targetType == null) @@ -2353,17 +2984,32 @@ class FormScopeInfo private readonly string target; private readonly bool isValidationEnabled; + /// + /// Initializes a new instance of the class. + /// + /// The target. + /// if set to true [is validation enabled]. public FormScopeInfo(string target, bool isValidationEnabled) { this.target = target; this.isValidationEnabled = isValidationEnabled; } + /// + /// Gets the root target. + /// + /// The root target. public string RootTarget { get { return target; } } + /// + /// Gets a value indicating whether this instance is validation enabled. + /// + /// + /// true if this instance is validation enabled; otherwise, false. + /// public bool IsValidationEnabled { get { return isValidationEnabled; } diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSCollectionGenerator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSCollectionGenerator.cs index dd534fea1..efae07cc4 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSCollectionGenerator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSCollectionGenerator.cs @@ -14,6 +14,12 @@ namespace Castle.MonoRail.Framework.Helpers { + /// + /// Operations to act on a collection/array of DOM elements. + /// + /// + /// Not really implemented + /// public interface IJSCollectionGenerator { /// diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSElementGenerator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSElementGenerator.cs index 4247bbe45..74f3bd69d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSElementGenerator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSElementGenerator.cs @@ -14,23 +14,56 @@ namespace Castle.MonoRail.Framework.Helpers { - public interface IJSElementGenerator { + /// + /// Depicts the operations supported by the element Js generator. + /// + /// + /// + /// In practice you can access this generator by using the element accessor. + /// For example (using nvelocity syntax): + /// + /// + /// $page.el('element id') -> IJSElementGenerator instance + /// + /// + /// + public interface IJSElementGenerator + { /// /// Gets the parent generator. /// /// The parent generator. IJSGenerator ParentGenerator { get; } - /// - /// TODO: Document this - /// - /// The render options. - void ReplaceHtml(object renderOptions); + /// + /// Replaces the content of the element. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.el('elementid').ReplaceHtml("%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// Defines what to render + void ReplaceHtml(object renderOptions); - /// - /// TODO: Document this - /// - /// The render options. - void Replace(object renderOptions); + /// + /// Replaces the entire element's content -- and not only its innerHTML -- + /// by the content evaluated. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.el('messagediv').Replace("%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// Defines what to render + void Replace(object renderOptions); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSGenerator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSGenerator.cs index cb52d4fde..4f8e2006a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/IJSGenerator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/IJSGenerator.cs @@ -17,121 +17,388 @@ namespace Castle.MonoRail.Framework.Helpers using System; using System.Collections; using System.Text; + using Framework; + using Services; + /// + /// Depicts the contract for javascript generators. + /// + /// + /// + /// + /// Urls can be specified as string or a dictionary. If the latter, the + /// is used. See + /// + /// + /// + /// The renderOptions is also a common parameter. If you pass a string, + /// the string will be rendered. If it is a dictionary, it instructs the infrastructure to + /// render a partial content. The dictionary must contain an entry named partial + /// with the absolute path to the view to render. + /// + /// + /// + /// + /// + /// The following is an example of using it with a nvelocity + /// syntax and renders static content: + /// + /// + /// $page.InsertHtml('Bottom', 'messagestable', "Message sent") + /// + /// + /// + /// The following uses a partial view: + /// + /// + /// + /// $page.InsertHtml('Bottom', 'messagestable', "%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// The following redirects to a static page + /// + /// + /// + /// $page.RedirectTo('about.aspx') + /// + /// + /// + /// The following redirects using the + /// + /// + /// + /// $page.RedirectTo("%{controller='Home',action='index'}") + /// + /// + /// public interface IJSGenerator { /// - /// TODO: Implement and document this one + /// Inserts a content snippet relative to the element specified by the + /// /// + /// The supported positions are /// Top, After, Before, Bottom /// /// - /// - /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.InsertHtml('Bottom', 'messagestable', "%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// The position to insert the content relative to the element id + /// The target element id + /// Defines what to render void InsertHtml(string position, string id, object renderOptions); /// - /// TODO: Implement and document this one + /// Replaces the content of the specified target element. /// - /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.ReplaceHtml('messagediv', "%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// The target element id + /// Defines what to render void ReplaceHtml(String id, object renderOptions); /// - /// TODO: Implement and document this one + /// Replaces the entire target element -- and not only its innerHTML -- + /// by the content evaluated. /// - /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Replace('messagediv', "%{partial='shared/newmessage.vm'}") + /// + /// + /// + /// The target element id + /// Defines what to render void Replace(String id, object renderOptions); /// - /// TODO: Implement and document this one + /// Shows the specified elements. /// - /// + /// + /// + /// The elements must exist. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Show('div1', 'div2') + /// + /// + /// + /// The elements ids. void Show(params string[] ids); /// - /// TODO: Implement and document this one + /// Hides the specified elements. /// - /// + /// + /// + /// The elements must exist. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Hide('div1', 'div2') + /// + /// + /// + /// The elements ids. void Hide(params string[] ids); /// - /// TODO: Implement and document this one + /// Toggles the display status of the specified elements. /// - /// + /// + /// + /// The elements must exist. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Toggle('div1', 'div2') + /// + /// + /// + /// The elements ids. void Toggle(params string[] ids); /// - /// TODO: Implement and document this one + /// Remove the specified elements from the DOM. /// - /// + /// + /// + /// The elements must exist. + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Remove('div1', 'div2') + /// + /// + /// + /// The elements ids. void Remove(params string[] ids); /// - /// TODO: Implement and document this one + /// Shows a JS alert /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Alert('You won a Mercedez') + /// + /// + /// + /// The message to display. void Alert(object message); /// - /// TODO: Implement and document this one + /// Redirects to an url using the location.href. + /// This is required as most ajax libs don't care for the redirect status + /// in the http reply. /// - /// + /// + /// + /// The following redirects to a static page + /// + /// + /// $page.RedirectTo('about.aspx') + /// + /// + /// + /// The following redirects using the + /// + /// + /// + /// $page.RedirectTo("%{controller='Home',action='index'}") + /// + /// + /// + /// The URL. void RedirectTo(object url); /// /// Re-apply Behaviour css' rules. /// + /// + /// Only makes sense if you are using the Behaviour javascript library. + /// void ReApply(); /// - /// TODO: Implement and document this one + /// Generates a call to a scriptaculous' visual effect. /// - /// The name. - /// The element. - /// The options. + /// + /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.VisualEffect('ToggleSlide', 'myelement') + /// + /// + /// + /// This is especially useful to show which elements + /// where updated in an ajax call. + /// + /// + /// + /// $page.ReplaceHtml('mydiv', "Hey, I've changed") + /// $page.VisualEffect('Highlight', 'mydiv') + /// + /// + /// + /// + /// The effect name. + /// The target element. + /// The optional options. void VisualEffect(String name, String element, IDictionary options); /// - /// TODO: Implement and document this one + /// Generates a call to a scriptaculous' drop out visual effect. /// - /// The element. - /// The options. + /// + /// + /// + /// The target element. + /// The optional options. void VisualEffectDropOut(String element, IDictionary options); /// - /// TODO: Implement and document this one + /// Assigns a javascript variable with the expression. /// - /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Assign('myvariable', '10') + /// + /// + /// + /// Which outputs: + /// + /// + /// + /// myvariable = 10; + /// + /// + /// + /// With strings you can escape strings: + /// + /// + /// + /// $page.Assign('myvariable', '\'Hello world\'') + /// + /// + /// + /// Which outputs: + /// + /// + /// + /// myvariable = 'Hello world'; + /// + /// + /// + /// + /// The target variable + /// The right side expression void Assign(String variable, String expression); - /// /// Declares the specified variable as null. /// + /// + /// + /// /// The variable name. void Declare(String variable); /// - /// + /// Calls the specified function with the optional arguments. /// - /// - /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.call('myJsFunctionAlreadyDeclared', '10', "'message'", $somethingfrompropertybag, $anothermessage.to_squote) + /// + /// + /// + /// Which outputs: + /// + /// + /// + /// myJsFunctionAlreadyDeclared(10, 'message', 1001, 'who let the dogs out?') + /// + /// + /// + /// + /// The function name. + /// The arguments. void Call(object function, params object[] args); /// - /// Renders the specified render options. + /// Outputs the content using the renderOptions approach. + /// /// /// If the renderOptions is a string, the content is escaped and quoted. /// + /// /// /// If the renderOptions is a dictionary, we extract the key partial /// and evaluate the template it points to. The content is escaped and quoted. /// + /// /// + /// + /// + /// The following example uses nvelocity syntax: + /// + /// + /// $page.Call('myJsFunction', $page.render("%{partial='shared/newmessage.vm'}") ) + /// + /// + /// + /// Which outputs: + /// + /// + /// + /// myJsFunction('the content from the newmessage partial view template') + /// + /// + /// + /// /// The render options. /// object Render(object renderOptions); @@ -139,21 +406,49 @@ public interface IJSGenerator /// /// Writes the content specified to the generator instance /// + /// + /// + /// This is for advanced scenarios and for the infrastructure. Usually not useful. + /// + /// /// The content. void Write(String content); /// /// Writes the content specified to the generator instance /// + /// + /// + /// This is for advanced scenarios and for the infrastructure. Usually not useful. + /// /// The content. void AppendLine(String content); + /// + /// Dump the operations recorded so far as javascript code. + /// + /// + /// string ToString(); + /// + /// Gets the js lines. + /// + /// The js lines. StringBuilder Lines { get; } + /// + /// Creates a generator for a collection. + /// + /// The root expression. + /// IJSCollectionGenerator CreateCollectionGenerator(string root); + /// + /// Creates a generator for an element. + /// + /// The root expression. + /// IJSElementGenerator CreateElementGenerator(string root); } } \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/PaginationHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/PaginationHelper.cs index 70cd7152e..c6bb4f787 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/PaginationHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/PaginationHelper.cs @@ -27,10 +27,47 @@ namespace Castle.MonoRail.Framework.Helpers /// /// This helper allows you to easily paginate through a data source - /// (anything that implements ) + /// -- anything that implements . /// + /// + /// + /// With the pagination you expose a instance to your view, + /// that can be used to created a very detailed page navigator. + /// + /// + /// You can use up to three approaches to pagination: + /// + /// + /// + /// + /// CreatePagination + /// Uses a whole data set and creates a with a slice of it. + /// + /// + /// CreateCachedPagination + /// Caches the dataset and creates a with a slice. + /// As the cache is shared, you must be very careful on creating a cache key that uniquely represents the + /// cached dataset. + /// + /// + /// + /// CreateCustomPage + /// + /// In this case, you are handling the slicing. The is created with your + /// actual dataset and information about total. It calculates the other information based on that. + /// + /// + /// + /// + /// + /// Performance wise, the best choice is the + /// + /// public class PaginationHelper : AbstractHelper { + /// + /// The parameter key that the helper looks for on the request + /// public const string PageParameterName = "page"; #region CreatePageLink @@ -185,6 +222,15 @@ public static IPaginatedPage CreatePagination(ICollection datasource, int /// it invokes the dataObtentionCallback and caches the result /// using the specifed cacheKey /// + /// + /// + /// CreateCachedPagination is quite dangerous exactly because the cache is + /// shared. If the results vary per logged user, then the programmer must + /// rather pay a lot of attention when generating the cache key. + /// + /// It is preferable to have caching happen at a lower level of the stack, for example the NHibernate query cache. + /// + /// /// the current controller /// Cache key used to query/store the datasource /// Page size @@ -374,6 +420,12 @@ public class GenericPage : AbstractPage private readonly int sliceStart, sliceEnd; private readonly ICollection sourceList; + /// + /// Initializes a new instance of the class. + /// + /// The list. + /// The cur page. + /// Size of the page. public GenericPage(ICollection list, int curPage, int pageSize) { // Calculate slice indexes @@ -385,6 +437,11 @@ public GenericPage(ICollection list, int curPage, int pageSize) CalculatePaginationInfo(startIndex, endIndex, list.Count, pageSize, curPage); } + /// + /// Returns a enumerator for the contents + /// of this page only (not the whole set) + /// + /// Enumerator instance public override IEnumerator GetEnumerator() { if (sourceList is IList) @@ -429,16 +486,28 @@ public class GenericCustomPage : AbstractPage, IEnumerable { private readonly IList sourceList; + /// + /// Initializes a new instance of the class. + /// + /// The list. + /// The cur page. + /// Size of the page. + /// The total. public GenericCustomPage(IList list, int curPage, int pageSize, int total) { - int startIndex = 0; - int endIndex = Math.Min(startIndex + pageSize, list.Count); + int startIndex = (pageSize * curPage) - pageSize; + int endIndex = Math.Min(startIndex + pageSize, total); sourceList = list; CalculatePaginationInfo(startIndex, endIndex, total, pageSize, curPage); } + /// + /// Returns a enumerator for the contents + /// of this page only (not the whole set) + /// + /// Enumerator instance public override IEnumerator GetEnumerator() { for(int i = 0; i < sourceList.Count; i++) @@ -447,6 +516,12 @@ public override IEnumerator GetEnumerator() } } + /// + /// Returns an enumerator that iterates through the collection. + /// + /// + /// A that can be used to iterate through the collection. + /// IEnumerator IEnumerable.GetEnumerator() { for(int i = 0; i < sourceList.Count; i++) @@ -627,4 +702,4 @@ public bool HasPage(int pageNumber) /// Enumerator instance public abstract IEnumerator GetEnumerator(); } -} \ No newline at end of file +} diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/PrototypeHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/PrototypeHelper.cs index 46e5ff6c0..575ebd272 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/PrototypeHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/PrototypeHelper.cs @@ -95,14 +95,21 @@ protected override IDictionary GeneratorMethods #region Dispatchable operations /// - /// TODO: Implement and document this one - /// + /// Inserts a content snippet relative to the element specified by the + /// + /// The supported positions are /// Top, After, Before, Bottom /// /// - /// - /// - /// + /// The position to insert the content relative to the element id + /// The target element id + /// Defines what to render + /// + /// The following example uses nvelocity syntax: + /// + /// $page.InsertHtml('Bottom', 'messagestable', "%{partial='shared/newmessage.vm'}") + /// + /// public void InsertHtml(string position, string id, object renderOptions) { position = Enum.Parse(typeof(Position), position, true).ToString(); @@ -111,74 +118,143 @@ public void InsertHtml(string position, string id, object renderOptions) } /// - /// TODO: Implement and document this one + /// Replaces the content of the specified target element. /// - /// - /// + /// The target element id + /// Defines what to render + /// + /// The following example uses nvelocity syntax: + /// + /// $page.ReplaceHtml('messagediv', "%{partial='shared/newmessage.vm'}") + /// + /// public void ReplaceHtml(String id, object renderOptions) { Call("Element.update", Quote(id), Render(renderOptions)); } /// - /// TODO: Implement and document this one + /// Replaces the entire target element -- and not only its innerHTML -- + /// by the content evaluated. /// - /// - /// + /// The target element id + /// Defines what to render + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Replace('messagediv', "%{partial='shared/newmessage.vm'}") + /// + /// public void Replace(String id, object renderOptions) { Call("Element.replace", Quote(id), Render(renderOptions)); } /// - /// TODO: Implement and document this one + /// Shows the specified elements. /// - /// + /// The elements ids. + /// + /// The elements must exist. + /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Show('div1', 'div2') + /// + /// public void Show(params string[] ids) { Call("Element.show", Quote(ids)); } /// - /// TODO: Implement and document this one + /// Hides the specified elements. /// - /// + /// The elements ids. + /// + /// The elements must exist. + /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Hide('div1', 'div2') + /// + /// public void Hide(params string[] ids) { Call("Element.hide", Quote(ids)); } /// - /// TODO: Implement and document this one + /// Toggles the display status of the specified elements. /// - /// + /// The elements ids. + /// + /// The elements must exist. + /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Toggle('div1', 'div2') + /// + /// public void Toggle(params string[] ids) { Call("Element.toggle", Quote(ids)); } /// - /// TODO: Implement and document this one + /// Remove the specified elements from the DOM. /// - /// + /// The elements ids. + /// + /// The elements must exist. + /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Remove('div1', 'div2') + /// + /// public void Remove(params string[] ids) { Record(this, "[" + BuildJSArguments(Quote(ids)) + "].each(Element.remove)"); } /// - /// TODO: Implement and document this one + /// Shows a JS alert /// - /// + /// The message to display. + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Alert('You won a Mercedez') + /// + /// public void Alert(object message) { Call("alert", Quote(message)); } /// - /// TODO: Implement and document this one + /// Redirects to an url using the location.href. + /// This is required as most ajax libs don't care for the redirect status + /// in the http reply. /// - /// + /// The URL. + /// + /// The following redirects to a static page + /// + /// $page.RedirectTo('about.aspx') + /// + /// + /// The following redirects using the + /// + /// + /// $page.RedirectTo("%{controller='Home',action='index'}") + /// + /// public void RedirectTo(object url) { string target; @@ -198,17 +274,35 @@ public void RedirectTo(object url) /// /// Re-apply Behaviour css' rules. /// + /// + /// Only makes sense if you are using the Behaviour javascript library. + /// public void ReApply() { Call("Behaviour.apply"); } /// - /// TODO: Implement and document this one + /// Generates a call to a scriptaculous' visual effect. /// - /// The name. - /// The element. - /// The options. + /// The effect name. + /// The target element. + /// The optional options. + /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.VisualEffect('ToggleSlide', 'myelement') + /// + /// + /// This is especially useful to show which elements + /// where updated in an ajax call. + /// + /// + /// $page.ReplaceHtml('mydiv', "Hey, I've changed") + /// $page.VisualEffect('Highlight', 'mydiv') + /// + /// public void VisualEffect(String name, String element, IDictionary options) { Write(new ScriptaculousHelper().VisualEffect(name, element, options)); @@ -216,10 +310,11 @@ public void VisualEffect(String name, String element, IDictionary options) } /// - /// TODO: Implement and document this one + /// Generates a call to a scriptaculous' drop out visual effect. /// - /// The element. - /// The options. + /// The target element. + /// The optional options. + /// public void VisualEffectDropOut(String element, IDictionary options) { Write(new ScriptaculousHelper().VisualEffectDropOut(element, options)); @@ -227,34 +322,67 @@ public void VisualEffectDropOut(String element, IDictionary options) } /// - /// TODO: Implement and document this one + /// Assigns a javascript variable with the expression. /// - /// - /// + /// The target variable + /// The right side expression + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Assign('myvariable', '10') + /// + /// + /// Which outputs: + /// + /// + /// myvariable = 10; + /// + /// + /// With strings you can escape strings: + /// + /// + /// $page.Assign('myvariable', '\'Hello world\'') + /// + /// + /// Which outputs: + /// + /// + /// myvariable = 'Hello world'; + /// + /// public void Assign(String variable, String expression) { Record(this, variable + " = " + expression); } - #region IJSGenerator Members - /// /// Declares the specified variable as null. /// /// The variable name. + /// public void Declare(string variable) { Record(this, string.Format("var {0} = null", variable)); Record(this, Environment.NewLine); } - #endregion - /// - /// + /// Calls the specified function with the optional arguments. /// - /// - /// + /// The function name. + /// The arguments. + /// + /// The following example uses nvelocity syntax: + /// + /// $page.call('myJsFunctionAlreadyDeclared', '10', "'message'", $somethingfrompropertybag, $anothermessage.to_squote) + /// + /// + /// Which outputs: + /// + /// + /// myJsFunctionAlreadyDeclared(10, 'message', 1001, 'who let the dogs out?') + /// + /// public void Call(object function, params object[] args) { if (String.IsNullOrEmpty(function.ToString())) @@ -264,17 +392,29 @@ public void Call(object function, params object[] args) } /// - /// Renders the specified render options. + /// Outputs the content using the renderOptions approach. /// /// If the renderOptions is a string, the content is escaped and quoted. /// - /// + /// /// If the renderOptions is a dictionary, we extract the key partial /// and evaluate the template it points to. The content is escaped and quoted. /// /// /// The render options. /// + /// + /// The following example uses nvelocity syntax: + /// + /// $page.Call('myJsFunction', $page.render("%{partial='shared/newmessage.vm'}") ) + /// + /// + /// Which outputs: + /// + /// + /// myJsFunction('the content from the newmessage partial view template') + /// + /// public object Render(object renderOptions) { if (renderOptions == null) @@ -319,6 +459,9 @@ public object Render(object renderOptions) /// Writes the content specified to the generator instance /// /// The content. + /// + /// This is for advanced scenarios and for the infrastructure. Usually not useful. + /// public void Write(String content) { lines.Append(content); @@ -328,6 +471,9 @@ public void Write(String content) /// Writes the content specified to the generator instance /// /// The content. + /// + /// This is for advanced scenarios and for the infrastructure. Usually not useful. + /// public void AppendLine(String content) { Record(this, content); @@ -337,6 +483,12 @@ public void AppendLine(String content) #region Result generation (ToString) + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString() { return @"try " + @@ -350,16 +502,30 @@ public override string ToString() #endregion + /// + /// Gets the js lines. + /// + /// The js lines. public StringBuilder Lines { get { return lines; } } + /// + /// Creates a generator for a collection. + /// + /// The root expression. + /// public IJSCollectionGenerator CreateCollectionGenerator(string root) { return new PrototypeHelper.JSCollectionGenerator(this, root); } + /// + /// Creates a generator for an element. + /// + /// The root expression. + /// public IJSElementGenerator CreateElementGenerator(string root) { return new PrototypeHelper.JSElementGenerator(this, root); @@ -367,11 +533,21 @@ public IJSElementGenerator CreateElementGenerator(string root) #region Static members + /// + /// Records the specified line on the generator. + /// + /// The gen. + /// The line. public static void Record(IJSGenerator gen, string line) { gen.Lines.AppendFormat("{0};\r\n", line); } + /// + /// Builds the JS arguments. + /// + /// The args. + /// public static string BuildJSArguments(object[] args) { if (args == null || args.Length == 0) return String.Empty; @@ -392,6 +568,10 @@ public static string BuildJSArguments(object[] args) return tempBuffer.ToString(); } + /// + /// Replaces the tail by period. + /// + /// The generator. public static void ReplaceTailByPeriod(IJSGenerator generator) { int len = generator.Lines.Length; @@ -403,6 +583,10 @@ public static void ReplaceTailByPeriod(IJSGenerator generator) } } + /// + /// Removes the tail. + /// + /// The generator. public static void RemoveTail(IJSGenerator generator) { int len = generator.Lines.Length; @@ -438,6 +622,9 @@ private static string JsEscapeWithSQuotes(string content) #endregion } + /// + /// Implementation of + /// public class JSCollectionGenerator : DynamicDispatchSupport, IJSCollectionGenerator { private static readonly IDictionary DispMethods; @@ -501,6 +688,9 @@ protected override IDictionary GeneratorMethods #endregion } + /// + /// Implementation for the + /// public class JSElementGenerator : DynamicDispatchSupport, IJSElementGenerator { private static readonly IDictionary DispMethods; @@ -566,18 +756,31 @@ protected override IDictionary GeneratorMethods #region Dispatchable operations /// - /// TODO: Document this + /// Replaces the content of the element. /// - /// The render options. + /// Defines what to render + /// + /// The following example uses nvelocity syntax: + /// + /// $page.el('elementid').ReplaceHtml("%{partial='shared/newmessage.vm'}") + /// + /// public void ReplaceHtml(object renderOptions) { generator.Call("update", generator.Render(renderOptions)); } /// - /// TODO: Document this + /// Replaces the entire element's content -- and not only its innerHTML -- + /// by the content evaluated. /// - /// The render options. + /// Defines what to render + /// + /// The following example uses nvelocity syntax: + /// + /// $page.el('messagediv').Replace("%{partial='shared/newmessage.vm'}") + /// + /// public void Replace(object renderOptions) { generator.Call("replace", generator.Render(renderOptions)); @@ -587,8 +790,19 @@ public void Replace(object renderOptions) } } + /// + /// DynamicDispatch support is an infrastructure + /// that mimics a dynamic language/environment. + /// It is not finished but the idea is to allow + /// plugins to add operations to the generators. + /// public abstract class DynamicDispatchSupport { + /// + /// Populates the available methods. + /// + /// The generator methods. + /// The methods. protected static void PopulateAvailableMethods(IDictionary generatorMethods, MethodInfo[] methods) { foreach(MethodInfo method in methods) @@ -597,13 +811,30 @@ protected static void PopulateAvailableMethods(IDictionary generatorMethods, Met } } + /// + /// Gets the generator methods. + /// + /// The generator methods. protected abstract IDictionary GeneratorMethods { get; } + /// + /// Determines whether [is generator method] [the specified method]. + /// + /// The method. + /// + /// true if [is generator method] [the specified method]; otherwise, false. + /// public bool IsGeneratorMethod(string method) { return GeneratorMethods.Contains(method); } + /// + /// Dispatches the specified method. + /// + /// The method. + /// The args. + /// public object Dispatch(string method, params object[] args) { MethodInfo methodInfo = (MethodInfo) GeneratorMethods[method]; diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ScriptaculousHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ScriptaculousHelper.cs index cd0971e99..6b582872a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ScriptaculousHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ScriptaculousHelper.cs @@ -40,6 +40,10 @@ public String InstallScripts() return RenderScriptBlockToSource("/MonoRail/Files/Effects2"); } + /// + /// Gets the javascript functions. + /// + /// [Obsolete("Please use the preferred InstallScripts function.")] public String GetJavascriptFunctions() { diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/SetOperation.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/SetOperation.cs index b434b053f..479930b46 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/SetOperation.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/SetOperation.cs @@ -19,10 +19,61 @@ namespace Castle.MonoRail.Framework.Helpers using Castle.MonoRail.Framework.Internal; /// - /// + /// The SetOperation exposes an that + /// extracts information from the attributes and creates a proper configured + /// Iterator. + /// + /// It is shared by a handful of MonoRail operations related to sets. + /// /// - public class SetOperation + public static class SetOperation { + /// + /// Combines a group of well thought rules to create + /// an instance. + /// + /// + /// + /// The parameters read from the are + /// + /// + /// + /// value + /// The property name used to extract the value + /// + /// + /// text + /// The property name used to extract the display text + /// + /// + /// textformat + /// A format rule to apply to the text + /// + /// + /// valueformat + /// A format rule to apply to the value + /// + /// + /// suffix + /// If the types on both sets are different, + /// the suffix specifies a different target property + /// + /// + /// sourceProperty + /// + /// If the types on both sets are different, + /// the sourceProperty identifies a different source property to extract the value from. + /// + /// + /// + /// + /// + /// + /// + /// The initial selection. + /// The data source. + /// The attributes. + /// public static OperationState IterateOnDataSource(object initialSelection, IEnumerable dataSource, IDictionary attributes) { @@ -133,6 +184,9 @@ private static bool IsSet(object initialSelection) } } + /// + /// Represents a set element + /// public class SetItem { private readonly string value; @@ -140,6 +194,13 @@ public class SetItem private readonly string text; private readonly bool isSelected; + /// + /// Initializes a new instance of the class. + /// + /// The item. + /// The value. + /// The text. + /// if set to true [is selected]. public SetItem(object item, String value, String text, bool isSelected) { this.item = item; @@ -148,35 +209,87 @@ public SetItem(object item, String value, String text, bool isSelected) this.isSelected = isSelected; } + /// + /// Gets the item. + /// + /// The item. public object Item { get { return item; } } + /// + /// Gets the value. + /// + /// The value. public string Value { get { return value; } } + /// + /// Gets the text. + /// + /// The text. public string Text { get { return text; } } + /// + /// Gets a value indicating whether this instance is selected. + /// + /// + /// true if this instance is selected; otherwise, false. + /// public bool IsSelected { get { return isSelected; } } } + /// + /// Base class for set iterators + /// public abstract class OperationState : IEnumerable, IEnumerator { + /// + /// source type + /// protected readonly Type type; + /// + /// Value getter for value + /// protected readonly FormHelper.ValueGetter valuePropInfo; + /// + /// Value getter for text + /// protected readonly FormHelper.ValueGetter textPropInfo; - protected readonly String textFormat, valueFormat; + + /// + /// Format rule for text + /// + protected readonly String textFormat; + /// + /// Format rule for value + /// + protected readonly String valueFormat; + + /// + /// Source enumerator + /// protected IEnumerator enumerator; + /// + /// Initializes a new instance of the class. + /// + /// The type. + /// The data source. + /// if set to true [empty value case]. + /// The value property. + /// The text property. + /// The text format. + /// The value format. protected OperationState(Type type, IEnumerable dataSource, bool emptyValueCase,String valueProperty, String textProperty, String textFormat, String valueFormat) { @@ -200,6 +313,10 @@ protected OperationState(Type type, IEnumerable dataSource, } } + /// + /// Gets the target suffix. + /// + /// The target suffix. public abstract String TargetSuffix { get; } /// @@ -220,10 +337,22 @@ protected void FormatText(ref object value, string format) } } + /// + /// Creates the item representation. + /// + /// The current. + /// protected abstract SetItem CreateItemRepresentation(object current); #region IEnumerator implementation + /// + /// Advances the enumerator to the next element of the collection. + /// + /// + /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. + /// + /// The collection was modified after the enumerator was created. public bool MoveNext() { if (enumerator == null) @@ -233,6 +362,10 @@ public bool MoveNext() return enumerator.MoveNext(); } + /// + /// Sets the enumerator to its initial position, which is before the first element in the collection. + /// + /// The collection was modified after the enumerator was created. public void Reset() { if (enumerator != null) @@ -241,6 +374,12 @@ public void Reset() } } + /// + /// Gets the current element in the collection. + /// + /// + /// The current element in the collection. + /// The enumerator is positioned before the first element of the collection or after the last element. public object Current { get { return CreateItemRepresentation(enumerator.Current); } @@ -250,6 +389,12 @@ public object Current #region IEnumerable implementation + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return this; @@ -263,27 +408,52 @@ public IEnumerator GetEnumerator() /// public class NoIterationState : OperationState { + /// + /// Single instance for the iterator. + /// public static readonly NoIterationState Instance = new NoIterationState(); private NoIterationState() : base(null, null, false, null, null, null, null) { } + /// + /// Gets the target suffix. + /// + /// The target suffix. public override string TargetSuffix { get { return null; } } + /// + /// Creates the item representation. + /// + /// The current. + /// protected override SetItem CreateItemRepresentation(object current) { throw new NotImplementedException(); } } + /// + /// Simple iterator + /// public class ListDataSourceState : OperationState { private readonly string customSuffix; + /// + /// Initializes a new instance of the class. + /// + /// The type. + /// The data source. + /// The value property. + /// The text property. + /// The text format. + /// The value format. + /// The custom suffix. public ListDataSourceState(Type type, IEnumerable dataSource, String valueProperty, String textProperty, String textFormat, String valueFormat, String customSuffix) : base(type, dataSource, false, valueProperty, textProperty, textFormat, valueFormat) @@ -291,11 +461,20 @@ public ListDataSourceState(Type type, IEnumerable dataSource, String valueProper this.customSuffix = customSuffix; } + /// + /// Gets the target suffix. + /// + /// The target suffix. public override string TargetSuffix { get { return customSuffix; } } + /// + /// Creates the item representation. + /// + /// The current. + /// protected override SetItem CreateItemRepresentation(object current) { object value = current; @@ -318,11 +497,26 @@ protected override SetItem CreateItemRepresentation(object current) } } + /// + /// Iterator for sets type same type + /// public class SameTypeOperationState : OperationState { private readonly object initialSelection; private readonly bool isInitialSelectionASet; + /// + /// Initializes a new instance of the class. + /// + /// The type. + /// The initial selection. + /// The data source. + /// if set to true [empty value case]. + /// The value property. + /// The text property. + /// The text format. + /// The value format. + /// if set to true [is initial selection A set]. public SameTypeOperationState(Type type, object initialSelection, IEnumerable dataSource, bool emptyValueCase,String valueProperty, String textProperty, String textFormat, String valueFormat, bool isInitialSelectionASet) : base(type, dataSource, emptyValueCase, valueProperty, textProperty, textFormat, valueFormat) @@ -331,11 +525,20 @@ public SameTypeOperationState(Type type, object initialSelection, IEnumerable da this.isInitialSelectionASet = isInitialSelectionASet; } + /// + /// Gets the target suffix. + /// + /// The target suffix. public override string TargetSuffix { get { return valuePropInfo == null ? "" : valuePropInfo.Name; } } + /// + /// Creates the item representation. + /// + /// The current. + /// protected override SetItem CreateItemRepresentation(object current) { object value = current; @@ -360,12 +563,28 @@ protected override SetItem CreateItemRepresentation(object current) } } + /// + /// Iterator for different types on the set + /// public class DifferentTypeOperationState : OperationState { private readonly object initialSelection; private readonly bool isInitialSelectionASet; private readonly FormHelper.ValueGetter sourcePropInfo; + /// + /// Initializes a new instance of the class. + /// + /// Initial type of the selection. + /// Type of the data source. + /// The initial selection. + /// The data source. + /// The source property. + /// The value property. + /// The text property. + /// The text format. + /// The value format. + /// if set to true [is initial selection A set]. public DifferentTypeOperationState(Type initialSelectionType, Type dataSourceType, object initialSelection, IEnumerable dataSource, String sourceProperty, String valueProperty, @@ -385,11 +604,20 @@ public DifferentTypeOperationState(Type initialSelectionType, Type dataSourceTyp } } + /// + /// Gets the target suffix. + /// + /// The target suffix. public override string TargetSuffix { get { return sourcePropInfo == null ? "" : sourcePropInfo.Name; } } + /// + /// Creates the item representation. + /// + /// The current. + /// protected override SetItem CreateItemRepresentation(object current) { object value = current; diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/TextHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/TextHelper.cs index 84bf0a378..8dcd90f13 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/TextHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/TextHelper.cs @@ -24,22 +24,26 @@ namespace Castle.MonoRail.Framework.Helpers /// public class TextHelper : AbstractHelper { + /// + /// Default word connector + /// public const string DefaultConnector = "and"; /// - /// + /// Converts a camelized text to words. For instance: + /// FileWriter is converted to File Writer /// - /// + /// Content in pascal case /// - public static string PascalCaseToWord(string camelizedText) + public static string PascalCaseToWord(string pascalText) { - if (camelizedText == null) throw new ArgumentNullException("camelizedText"); + if (pascalText == null) throw new ArgumentNullException("pascalText"); - if (camelizedText == string.Empty) return string.Empty; + if (pascalText == string.Empty) return string.Empty; - StringBuilder sbText = new StringBuilder(camelizedText.Length + 4); + StringBuilder sbText = new StringBuilder(pascalText.Length + 4); - char[] chars = camelizedText.ToCharArray(); + char[] chars = pascalText.ToCharArray(); sbText.Append(chars[0]); @@ -131,7 +135,7 @@ public string ToSentence(ICollection elements) { if (elements == null) { - throw new ArgumentNullException("strings"); + throw new ArgumentNullException("elements"); } return ToSentence(elements, DefaultConnector, true); diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs index 827ff8b99..a36a6f484 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs @@ -15,15 +15,51 @@ namespace Castle.MonoRail.Framework.Helpers { using System.Collections; + using Framework; + using Services; /// + /// Helper that allows the creation of urls using a dictionary. + /// + /// + /// For more information see + /// /// /// + /// + /// + /// By default the urlhelper sets the encode to true, so the html generated is valid xhtml. + /// + /// + /// public class UrlHelper : AbstractHelper { /// - /// Builds the URL path. + /// Outputs a path constructed using the specified parameters. /// + /// + /// + /// + /// + /// The following code uses nvelocity syntax: + /// + /// + /// $url.for("%{action='Save'}") + /// + /// + /// outputs + /// + /// /ControllerNameFromContext/Save.extension_configured + /// + /// + /// $url.for("%{action='Edit',querystring='id=1'}") + /// + /// + /// outputs + /// + /// /ControllerNameFromContext/Edit.extension_configured?id=1 + /// + /// /// The parameters. /// public string For(IDictionary parameters) @@ -32,28 +68,125 @@ public string For(IDictionary parameters) return Controller.UrlBuilder.BuildUrl(Controller.Context.UrlInfo, parameters); } + /// + /// Outputs an anchor element constructed using the specified parameters. + /// + /// + /// + /// + /// + /// The following code uses nvelocity syntax: + /// + /// + /// $url.link('my link', "%{action='Save'}") + /// + /// + /// outputs + /// + /// my link ]]> + /// + /// + /// $url.link('my link', "%{action='Edit',querystring='id=1'}") + /// + /// + /// outputs + /// + /// my link ]]> + /// + /// + /// The anchor text. + /// The parameters. + /// public string Link(string innerContent, IDictionary parameters) { SetEncodeDefault(parameters); return "" + innerContent + ""; } + /// + /// Outputs an anchor element constructed using the specified parameters. + /// + /// + /// + /// + /// + /// The following code uses nvelocity syntax: + /// + /// + /// $url.link('my link', "%{action='Save'}", "%{class='buttonlink'}") + /// + /// + /// outputs + /// + /// my link ]]> + /// + /// + /// + /// The anchor text. + /// The parameters. + /// The anchor element attributes. + /// public string Link(string innerContent, IDictionary parameters, IDictionary anchorAttributes) { SetEncodeDefault(parameters); return "" + innerContent + ""; } + /// + /// Outputs a button element constructed using the specified parameters. + /// + /// + /// + /// + /// + /// The following code uses nvelocity syntax: + /// + /// + /// $url.ButtonLink('my link', "%{action='Save'}") + /// + /// + /// outputs + /// + /// my link ]]> + /// + /// + /// + /// The button text. + /// The parameters. + /// public string ButtonLink(string innerContent, IDictionary parameters) { SetEncodeDefault(parameters); return ""; } - public string ButtonLink(string innerContent, IDictionary parameters, IDictionary anchorAttributes) + /// + /// Outputs a button element constructed using the specified parameters. + /// + /// + /// + /// + /// + /// The following code uses nvelocity syntax: + /// + /// + /// $url.ButtonLink('my link', "%{action='Save'}", "%{class='buttonlink'}") + /// + /// + /// outputs + /// + /// my link ]]> + /// + /// + /// + /// The button text. + /// The parameters. + /// The button element attributes. + /// + public string ButtonLink(string innerContent, IDictionary parameters, IDictionary buttonAttributes) { SetEncodeDefault(parameters); - return ""; + return ""; } private static void SetEncodeDefault(IDictionary parameters) diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationHelper.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationHelper.cs index f3092ddfd..d8a2631a2 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationHelper.cs @@ -16,7 +16,7 @@ namespace Castle.MonoRail.Framework.Helpers { using System; using System.Collections; - using System.Collections.Specialized; + using System.Collections.Specialized; /// /// Helper that provides client-side validation. @@ -46,20 +46,26 @@ public ValidationHelper() /// public String InstallScripts() { - return InstallScripts(string.Empty); + return InstallScripts(string.Empty); + } + + /// + /// Installs the scripts. + /// + /// The locale. + /// + public string InstallScripts(string locale) + { + string queryString = null; + if (!string.IsNullOrEmpty(locale)) + { + queryString = string.Format("Locale={0}", UrlEncode(locale)); + } + return RenderScriptBlockToSource("/MonoRail/Files/ValidateConfig") + Environment.NewLine + + RenderScriptBlockToSource("/MonoRail/Files/ValidateCore") + Environment.NewLine + + RenderScriptBlockToSource("/MonoRail/Files/ValidateValidators") + Environment.NewLine + + RenderScriptBlockToSource("/MonoRail/Files/ValidateLang", queryString) + Environment.NewLine; } - public string InstallScripts(string locale) - { - string queryString = null; - if (!string.IsNullOrEmpty(locale)) - { - queryString = string.Format("Locale={0}", this.UrlEncode(locale)); - } - return RenderScriptBlockToSource("/MonoRail/Files/ValidateConfig") + Environment.NewLine + - RenderScriptBlockToSource("/MonoRail/Files/ValidateCore") + Environment.NewLine + - RenderScriptBlockToSource("/MonoRail/Files/ValidateValidators") + Environment.NewLine + - RenderScriptBlockToSource("/MonoRail/Files/ValidateLang" ,queryString) + Environment.NewLine; - } /// /// Configure the submit and validation options. @@ -134,12 +140,12 @@ public String GetValidationTriggerFunction(String formElement, IDictionary optio } return String.Format("return validateForm( {0}, {1}, {2}, {3}, {4}, {5} );", - formElement, - options["confirm"].ToString().ToLower(), - options["disable"].ToString().ToLower(), - options["disable"].ToString().ToLower(), - options["groupError"].ToString().ToLower(), - options["errorMode"]); + formElement, + options["confirm"].ToString().ToLower(), + options["disable"].ToString().ToLower(), + options["disable"].ToString().ToLower(), + options["groupError"].ToString().ToLower(), + options["errorMode"]); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/FValidateValidator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/FValidateValidator.cs index bfcb0aafc..debb5f92d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/FValidateValidator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/FValidateValidator.cs @@ -18,12 +18,21 @@ namespace Castle.MonoRail.Framework.Helpers.ValidationStrategy using System.Collections; using Castle.Components.Validator; + /// + /// Implementation of a browser validator that uses the fValidate + /// javascript library. + /// public class FValidateWebValidator : IBrowserValidatorProvider { /// - /// Pendent + /// Implementors should attempt to read their specific configuration + /// from the , configure and return + /// a class that extends from /// - /// + /// + /// + /// An instance that extends from + /// public BrowserValidationConfiguration CreateConfiguration(IDictionary parameters) { FValidateConfiguration config = new FValidateConfiguration(); @@ -32,9 +41,12 @@ public BrowserValidationConfiguration CreateConfiguration(IDictionary parameters } /// - /// Pendent + /// Implementors should return their generator instance. /// - /// + /// + /// + /// + /// A generator instance public IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguration config, InputElementType inputType, IDictionary attributes) { return new FValidateGenerator(inputType, attributes); @@ -42,8 +54,15 @@ public IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguratio #region Configuration + /// + /// Supported configuration for fValidate. + /// public class FValidateConfiguration : BrowserValidationConfiguration { + /// + /// Configures the JS library based on the supplied parameters. + /// + /// The parameters. public override void Configure(IDictionary parameters) { // ( f, bConfirm, bDisable, bDisableR, groupError, errorMode ) @@ -86,6 +105,9 @@ public override void Configure(IDictionary parameters) #region Generator + /// + /// Generator for fValidate validation. + /// public class FValidateGenerator : IBrowserValidationGenerator { private readonly InputElementType inputType; @@ -102,79 +124,149 @@ public FValidateGenerator(InputElementType inputType, IDictionary attributes) this.attributes = attributes; } + /// + /// Sets that a field is required. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetAsRequired(string target, string violationMessage) { AddValidator(target, "blank"); AddErrorMessage(violationMessage); } + /// + /// Sets that a field value must match the specified regular expression. + /// + /// The target name (ie, a hint about the controller being validated) + /// The reg exp. + /// The violation message. public void SetRegExp(string target, string regExp, string violationMessage) { throw new NotImplementedException(); } + /// + /// Sets that a field value must be a valid email address. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetEmail(string target, string violationMessage) { AddValidator(target, "email|1"); AddErrorMessage(violationMessage); } + /// + /// Set that a field should only accept digits. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetDigitsOnly(string target, string violationMessage) { - // TODO } + /// + /// Set that a field should only accept numbers. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetNumberOnly(string target, string violationMessage) { - // TODO } + /// + /// Sets that field must have an exact lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The length. public void SetExactLength(string target, int length) { // Not supported } + /// + /// Sets that field must have an exact lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The length. + /// The violation message. public void SetExactLength(string target, int length, string violationMessage) { // Not supported } + /// + /// Sets that field must have an minimum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. public void SetMinLength(string target, int minLength) { SetMinLength(target, minLength, null); } + /// + /// Sets that field must have an minimum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The violation message. public void SetMinLength(string target, int minLength, string violationMessage) { AddValidator(target, "length|" + minLength); } + /// + /// Sets that field must have an maximum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The maximum length. public void SetMaxLength(string target, int maxLength) { SetMaxLength(target, maxLength, null); } + /// + /// Sets that field must have an maximum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The maximum length. + /// The violation message. public void SetMaxLength(string target, int maxLength, string violationMessage) { // Not supported } + /// + /// Sets that field must be between a length range. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The maximum length. public void SetLengthRange(string target, int minLength, int maxLength) { AddValidator(target, "length|" + minLength + "|" + maxLength); } + /// + /// Sets that field must be between a length range. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The maximum length. + /// The violation message. public void SetLengthRange(string target, int minLength, int maxLength, string violationMessage) { AddValidator(target, "length|" + minLength + "|" + maxLength); } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, int minValue, int maxValue, string violationMessage) { @@ -182,11 +274,11 @@ public void SetValueRange(string target, int minValue, int maxValue, string viol } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, decimal minValue, decimal maxValue, string violationMessage) { @@ -194,11 +286,11 @@ public void SetValueRange(string target, decimal minValue, decimal maxValue, str } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, DateTime minValue, DateTime maxValue, string violationMessage) { @@ -206,32 +298,51 @@ public void SetValueRange(string target, DateTime minValue, DateTime maxValue, s } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, string minValue, string maxValue, string violationMessage) { } + /// + /// Set that a field value must be the same as another field's value. + /// + /// The target name (ie, a hint about the controller being validated) + /// The name of the field to compare with. + /// The violation message. public void SetAsSameAs(string target, string comparisonFieldName, string violationMessage) { - throw new NotImplementedException(); } + /// + /// Set that a field value must _not_ be the same as another field's value. + /// + /// The target name (ie, a hint about the controller being validated) + /// The name of the field to compare with. + /// The violation message. public void SetAsNotSameAs(string target, string comparisonFieldName, string violationMessage) { - throw new NotImplementedException(); } - + + /// + /// Set that a field value must be a valid date. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetDate(string target, string violationMessage) { - throw new NotImplementedException(); } + /// + /// Adds the validator. + /// + /// The target. + /// The validator. private void AddValidator(string target, string validator) { string existingValidators = (string) attributes["validators"]; diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/IBrowserValidatorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/IBrowserValidatorProvider.cs index f981610e4..7cb606efe 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/IBrowserValidatorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/IBrowserValidatorProvider.cs @@ -18,20 +18,24 @@ namespace Castle.MonoRail.Framework.Helpers.ValidationStrategy using Castle.Components.Validator; /// - /// Pendent + /// Abstracts the approach to create javascript + /// validation for forms. /// public interface IBrowserValidatorProvider { /// - /// Pendent + /// Implementors should attempt to read their specific configuration + /// from the , configure and return + /// a class that extends from /// - /// + /// An instance that extends from BrowserValidationConfiguration CreateConfiguration(IDictionary parameters); /// - /// Pendent + /// Implementors should return their generator instance. /// - /// - IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguration config, InputElementType inputType, IDictionary attributes); + /// A generator instance + IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguration config, + InputElementType inputType, IDictionary attributes); } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/PrototypeWebValidator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/PrototypeWebValidator.cs index cfafcfea7..a1f3dd279 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/PrototypeWebValidator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/PrototypeWebValidator.cs @@ -28,10 +28,14 @@ namespace Castle.MonoRail.Framework.Helpers.ValidationStrategy public class PrototypeWebValidator : IBrowserValidatorProvider { /// - /// Pendent + /// Implementors should attempt to read their specific configuration + /// from the , configure and return + /// a class that extends from /// /// - /// + /// + /// An instance that extends from + /// public BrowserValidationConfiguration CreateConfiguration(IDictionary parameters) { PrototypeValidationConfiguration config = new PrototypeValidationConfiguration(); @@ -42,12 +46,12 @@ public BrowserValidationConfiguration CreateConfiguration(IDictionary parameters } /// - /// Pendent + /// Implementors should return their generator instance. /// /// /// /// - /// + /// A generator instance public IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguration config, InputElementType inputType, IDictionary attributes) { return new PrototypeValidationGenerator((PrototypeValidationConfiguration) config, inputType, attributes); @@ -56,13 +60,19 @@ public IBrowserValidationGenerator CreateGenerator(BrowserValidationConfiguratio #region Configuration /// - /// + /// Configuration for the Prototype Field Validation /// public class PrototypeValidationConfiguration : BrowserValidationConfiguration { private IDictionary jsOptions = new Hashtable(); private Dictionary rules = new Dictionary(); + /// + /// Implementors should return any tag/js content + /// to be rendered after the form tag is closed. + /// + /// The form id. + /// public override string CreateBeforeFormClosed(string formId) { StringBuilder sb = new StringBuilder(); @@ -98,6 +108,10 @@ public override string CreateBeforeFormClosed(string formId) return AbstractHelper.ScriptBlock(sb.ToString()); } + /// + /// Configures the JS library based on the supplied parameters. + /// + /// The parameters. public override void Configure(IDictionary parameters) { string onSubmit = CommonUtils.ObtainEntryAndRemove(parameters, "on_submit", "true"); @@ -129,6 +143,12 @@ public override void Configure(IDictionary parameters) } } + /// + /// Adds a custom rule. + /// + /// Name of the class. + /// The violation message. + /// The rule. public void AddCustomRule(string className, string violationMessage, string rule) { rules[className] = new CustomRule(className, rule, violationMessage); @@ -151,6 +171,9 @@ public CustomRule(string className, string rule, string violationMessage) #region Validation Generator + /// + /// Generator for prototype field validation + /// public class PrototypeValidationGenerator : IBrowserValidationGenerator { private readonly PrototypeValidationConfiguration config; @@ -170,6 +193,11 @@ public PrototypeValidationGenerator(PrototypeValidationConfiguration config, Inp this.attributes = attributes; } + /// + /// Sets that a field is required. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetAsRequired(string target, string violationMessage) { if (inputType == InputElementType.Text) @@ -187,24 +215,45 @@ public void SetAsRequired(string target, string violationMessage) AddTitle(violationMessage); } + /// + /// Set that a field should only accept digits. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetDigitsOnly(string target, string violationMessage) { AddClass("validate-digits"); AddTitle(violationMessage); } + /// + /// Set that a field should only accept numbers. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetNumberOnly(string target, string violationMessage) { AddClass("validate-number"); AddTitle(violationMessage); } + /// + /// Sets that a field value must be a valid email address. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetEmail(string target, string violationMessage) { AddClass("validate-email"); AddTitle(violationMessage); } + /// + /// Sets that a field value must match the specified regular expression. + /// + /// The target name (ie, a hint about the controller being validated) + /// The reg exp. + /// The violation message. public void SetRegExp(string target, string regExp, string violationMessage) { string rule = "validate-regex" + regExp.GetHashCode(); @@ -213,11 +262,22 @@ public void SetRegExp(string target, string regExp, string violationMessage) AddTitle(violationMessage); } + /// + /// Sets that field must have an exact lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The length. public void SetExactLength(string target, int length) { SetExactLength(target, length, null); } + /// + /// Sets that field must have an exact lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The length. + /// The violation message. public void SetExactLength(string target, int length, string violationMessage) { string rule = "validate-exact-length-" + length; @@ -226,11 +286,22 @@ public void SetExactLength(string target, int length, string violationMessage) AddTitle(violationMessage); } + /// + /// Sets that field must have an minimum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. public void SetMinLength(string target, int minLength) { SetMinLength(target, minLength, null); } + /// + /// Sets that field must have an minimum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The violation message. public void SetMinLength(string target, int minLength, string violationMessage) { string rule = "validate-min-length-" + minLength; @@ -239,11 +310,22 @@ public void SetMinLength(string target, int minLength, string violationMessage) AddTitle(violationMessage); } + /// + /// Sets that field must have an maximum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The maximum length. public void SetMaxLength(string target, int maxLength) { SetMaxLength(target, maxLength, null); } + /// + /// Sets that field must have an maximum lenght. + /// + /// The target name (ie, a hint about the controller being validated) + /// The maximum length. + /// The violation message. public void SetMaxLength(string target, int maxLength, string violationMessage) { if (inputType == InputElementType.Text) @@ -257,36 +339,49 @@ public void SetMaxLength(string target, int maxLength, string violationMessage) AddTitle(violationMessage); } + /// + /// Sets that field must be between a length range. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The maximum length. public void SetLengthRange(string target, int minLength, int maxLength) { SetMinLength(target, minLength); SetMaxLength(target, maxLength); } + /// + /// Sets that field must be between a length range. + /// + /// The target name (ie, a hint about the controller being validated) + /// The minimum length. + /// The maximum length. + /// The violation message. public void SetLengthRange(string target, int minLength, int maxLength, string violationMessage) { SetMinLength(target, minLength, null); SetMaxLength(target, maxLength, null); AddTitle(violationMessage); } - + /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, int minValue, int maxValue, string violationMessage) { } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, decimal minValue, decimal maxValue, string violationMessage) { @@ -294,27 +389,33 @@ public void SetValueRange(string target, decimal minValue, decimal maxValue, str } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, DateTime minValue, DateTime maxValue, string violationMessage) { } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, string minValue, string maxValue, string violationMessage) { } + /// + /// Set that a field value must be the same as another field's value. + /// + /// The target name (ie, a hint about the controller being validated) + /// The name of the field to compare with. + /// The violation message. public void SetAsSameAs(string target, string comparisonFieldName, string violationMessage) { string rule = "validate-same-as-" + comparisonFieldName.ToLowerInvariant(); @@ -323,6 +424,12 @@ public void SetAsSameAs(string target, string comparisonFieldName, string violat AddTitle(violationMessage); } + /// + /// Set that a field value must _not_ be the same as another field's value. + /// + /// The target name (ie, a hint about the controller being validated) + /// The name of the field to compare with. + /// The violation message. public void SetAsNotSameAs(string target, string comparisonFieldName, string violationMessage) { string rule = "validate-not-same-as-" + comparisonFieldName.ToLowerInvariant(); @@ -331,6 +438,11 @@ public void SetAsNotSameAs(string target, string comparisonFieldName, string vio AddTitle(violationMessage); } + /// + /// Set that a field value must be a valid date. + /// + /// The target name (ie, a hint about the controller being validated) + /// The violation message. public void SetDate(string target, string violationMessage) { AddClass("validate-date"); diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/ZebdaWebValidator.cs b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/ZebdaWebValidator.cs index 938e3321c..b6200078a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/ZebdaWebValidator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/ValidationStrategy/ZebdaWebValidator.cs @@ -140,7 +140,7 @@ public ZebdaWebValidationGenerator(InputElementType inputType, IDictionary attri } /// - /// Sets the digits only. + /// Set that a field should only accept digits. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. @@ -151,7 +151,7 @@ public void SetDigitsOnly(string target, string violationMessage) } /// - /// Sets the number only. + /// Set that a field should only accept numbers. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. @@ -162,7 +162,7 @@ public void SetNumberOnly(string target, string violationMessage) } /// - /// Sets as required. + /// Sets that a field is required. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. @@ -174,7 +174,7 @@ public void SetAsRequired(string target, string violationMessage) } /// - /// Sets the reg exp. + /// Sets that a field value must match the specified regular expression. /// /// The target name (ie, a hint about the controller being validated) /// The reg exp. @@ -186,7 +186,7 @@ public void SetRegExp(string target, string regExp, string violationMessage) } /// - /// Sets the email. + /// Sets that a field value must be a valid email address. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. @@ -197,7 +197,7 @@ public void SetEmail(string target, string violationMessage) } /// - /// Sets the length of the exact. + /// Sets that field must have an exact lenght. /// /// The target name (ie, a hint about the controller being validated) /// The length. @@ -207,11 +207,11 @@ public void SetExactLength(string target, int length) } /// - /// Sets the length of the exact. + /// Sets that field must have an exact lenght. /// /// The target name (ie, a hint about the controller being validated) /// The length. - /// /// The violation message. + /// The violation message. public void SetExactLength(string target, int length, string violationMessage) { AddZebdaAttribute("length", "{max: " + length + ", min: " + length + "}"); @@ -219,20 +219,20 @@ public void SetExactLength(string target, int length, string violationMessage) } /// - /// Sets the length of the min. + /// Sets that field must have an minimum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. + /// The minimum length. public void SetMinLength(string target, int minLength) { AddZebdaAttribute("length", "{min: " + minLength + "}"); } /// - /// Sets the length of the min. + /// Sets that field must have an minimum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. + /// The minimum length. /// The violation message. public void SetMinLength(string target, int minLength, string violationMessage) { @@ -241,20 +241,20 @@ public void SetMinLength(string target, int minLength, string violationMessage) } /// - /// Sets the length of the max. + /// Sets that field must have an maximum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the max. + /// The maximum length. public void SetMaxLength(string target, int maxLength) { AddZebdaAttribute("length", "{max: " + maxLength + "}"); } /// - /// Sets the length of the max. + /// Sets that field must have an maximum lenght. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the max. + /// The maximum length. /// The violation message. public void SetMaxLength(string target, int maxLength, string violationMessage) { @@ -263,22 +263,22 @@ public void SetMaxLength(string target, int maxLength, string violationMessage) } /// - /// Sets the length range. + /// Sets that field must be between a length range. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. - /// Length of the max. + /// The minimum length. + /// The maximum length. public void SetLengthRange(string target, int minLength, int maxLength) { AddZebdaAttribute("length", "{max: " + maxLength + ", min: " + minLength + "}"); } /// - /// Sets the length range. + /// Sets that field must be between a length range. /// /// The target name (ie, a hint about the controller being validated) - /// Length of the min. - /// Length of the max. + /// The minimum length. + /// The maximum length. /// The violation message. public void SetLengthRange(string target, int minLength, int maxLength, string violationMessage) { @@ -287,11 +287,11 @@ public void SetLengthRange(string target, int minLength, int maxLength, string v } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, int minValue, int maxValue, string violationMessage) { @@ -300,11 +300,11 @@ public void SetValueRange(string target, int minValue, int maxValue, string viol } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, decimal minValue, decimal maxValue, string violationMessage) { @@ -313,29 +313,29 @@ public void SetValueRange(string target, decimal minValue, decimal maxValue, str } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, DateTime minValue, DateTime maxValue, string violationMessage) { } /// - /// Sets the value range. + /// Sets that field must be between a value range. /// /// The target name (ie, a hint about the controller being validated) - /// Value of the min. - /// Value of the max. + /// Minimum value. + /// Maximum value. /// The violation message. public void SetValueRange(string target, string minValue, string maxValue, string violationMessage) { } /// - /// Set as same as. + /// Set that a field value must be the same as another field's value. /// /// The target name (ie, a hint about the controller being validated) /// The name of the field to compare with. @@ -346,12 +346,18 @@ public void SetAsSameAs(string target, string comparisonFieldName, string violat AddTitle(violationMessage); } + /// + /// Set that a field value must _not_ be the same as another field's value. + /// + /// The target name (ie, a hint about the controller being validated) + /// The name of the field to compare with. + /// The violation message. public void SetAsNotSameAs(string target, string comparisonFieldName, string violationMessage) { - throw new NotImplementedException(); } + /// - /// Set date. + /// Set that a field value must be a valid date. /// /// The target name (ie, a hint about the controller being validated) /// The violation message. diff --git a/MonoRail/Castle.MonoRail.Framework/ICacheProvider.cs b/MonoRail/Castle.MonoRail.Framework/ICacheProvider.cs index c4773de0a..7fbf1ee9c 100644 --- a/MonoRail/Castle.MonoRail.Framework/ICacheProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/ICacheProvider.cs @@ -24,12 +24,33 @@ namespace Castle.MonoRail.Framework /// public interface ICacheProvider : IProvider { + /// + /// Determines whether the specified key is on the cache. + /// + /// The key. + /// + /// true if the cache has the key; otherwise, false. + /// bool HasKey(String key); + /// + /// Gets the cache item by the specified key. + /// + /// The key. + /// object Get(String key); + /// + /// Stores the cache item by the specified key. + /// + /// The key. + /// The data. void Store(String key, object data); + /// + /// Deletes the cache item by the specified key. + /// + /// The key. void Delete(String key); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IControllerAware.cs b/MonoRail/Castle.MonoRail.Framework/IControllerAware.cs index efaf4dd24..5bda82936 100644 --- a/MonoRail/Castle.MonoRail.Framework/IControllerAware.cs +++ b/MonoRail/Castle.MonoRail.Framework/IControllerAware.cs @@ -20,6 +20,10 @@ namespace Castle.MonoRail.Framework /// public interface IControllerAware { + /// + /// Sets the controller. + /// + /// The controller. void SetController(Controller controller); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IControllerDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/IControllerDescriptorProvider.cs index 79928eb48..19c6d20ae 100644 --- a/MonoRail/Castle.MonoRail.Framework/IControllerDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/IControllerDescriptorProvider.cs @@ -25,8 +25,18 @@ namespace Castle.MonoRail.Framework /// public interface IControllerDescriptorProvider : IProvider { + /// + /// Builds the descriptor. + /// + /// The controller. + /// ControllerMetaDescriptor BuildDescriptor(Controller controller); - + + /// + /// Builds the descriptor. + /// + /// Type of the controller. + /// ControllerMetaDescriptor BuildDescriptor(Type controllerType); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IDynamicAction.cs b/MonoRail/Castle.MonoRail.Framework/IDynamicAction.cs index 3a657cc1b..89271a5eb 100644 --- a/MonoRail/Castle.MonoRail.Framework/IDynamicAction.cs +++ b/MonoRail/Castle.MonoRail.Framework/IDynamicAction.cs @@ -18,6 +18,13 @@ namespace Castle.MonoRail.Framework /// An action that is not a method /// on the controller. /// + /// + /// + /// + /// + /// To attach a dynamic action to a controller use + /// the dictionary. + /// public interface IDynamicAction { /// diff --git a/MonoRail/Castle.MonoRail.Framework/IDynamicActionProvider.cs b/MonoRail/Castle.MonoRail.Framework/IDynamicActionProvider.cs index d78cfe5be..e08aefd1d 100644 --- a/MonoRail/Castle.MonoRail.Framework/IDynamicActionProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/IDynamicActionProvider.cs @@ -18,6 +18,13 @@ namespace Castle.MonoRail.Framework /// Defines that the implementor wants to add /// dynamic actions to controllers. /// + /// + /// + /// + /// + /// You can associate a dynamic action provider with a controller using the + /// + /// public interface IDynamicActionProvider { /// diff --git a/MonoRail/Castle.MonoRail.Framework/IFilter.cs b/MonoRail/Castle.MonoRail.Framework/IFilter.cs index f2d3bad37..d6f91632a 100644 --- a/MonoRail/Castle.MonoRail.Framework/IFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/IFilter.cs @@ -90,6 +90,10 @@ public interface IFilter /// public interface IFilterAttributeAware { + /// + /// Sets the filter. + /// + /// The filter. FilterAttribute Filter { set; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/IFilterFactory.cs b/MonoRail/Castle.MonoRail.Framework/IFilterFactory.cs index b59370590..2d4d6c4b4 100644 --- a/MonoRail/Castle.MonoRail.Framework/IFilterFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/IFilterFactory.cs @@ -22,8 +22,17 @@ namespace Castle.MonoRail.Framework /// public interface IFilterFactory { + /// + /// Creates the specified filter type. + /// + /// Type of the filter. + /// IFilter Create( Type filterType ); + /// + /// Releases the specified filter. + /// + /// The filter. void Release( IFilter filter ); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IParameterBinder.cs b/MonoRail/Castle.MonoRail.Framework/IParameterBinder.cs index 32d48c03b..75b6927fe 100644 --- a/MonoRail/Castle.MonoRail.Framework/IParameterBinder.cs +++ b/MonoRail/Castle.MonoRail.Framework/IParameterBinder.cs @@ -24,8 +24,22 @@ namespace Castle.MonoRail.Framework /// public interface IParameterBinder { + /// + /// Calculates the param points. Implementors should return value equals or greater than + /// zero indicating whether the parameter can be bound successfully. The greater the value (points) + /// the more successful the implementation indicates to the framework + /// + /// The controller. + /// The parameter info. + /// int CalculateParamPoints(SmartDispatcherController controller, ParameterInfo parameterInfo); + /// + /// Binds the specified parameters for the action. + /// + /// The controller. + /// The parameter info. + /// object Bind(SmartDispatcherController controller, ParameterInfo parameterInfo); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IRequest.cs b/MonoRail/Castle.MonoRail.Framework/IRequest.cs index f093aa378..26446acaf 100644 --- a/MonoRail/Castle.MonoRail.Framework/IRequest.cs +++ b/MonoRail/Castle.MonoRail.Framework/IRequest.cs @@ -20,7 +20,7 @@ namespace Castle.MonoRail.Framework using System.Web; /// - /// + /// Represents the request data /// public interface IRequest { @@ -35,28 +35,78 @@ public interface IRequest /// IDictionary Files { get; } + /// + /// Gets the params which accumulates headers, post, querystring and cookies. + /// + /// The params. NameValueCollection Params { get; } + /// + /// Gets a value indicating whether this requeest is from a local address. + /// + /// true if this instance is local; otherwise, false. bool IsLocal { get; } + /// + /// Gets the raw URL. + /// + /// The raw URL. String RawUrl { get; } + /// + /// Gets the URI. + /// + /// The URI. Uri Uri { get; } + /// + /// Gets the HTTP method. + /// + /// The HTTP method. String HttpMethod { get; } - + + /// + /// Gets the file path. + /// + /// The file path. String FilePath { get; } + /// + /// Reads the request data as a byte array. + /// + /// How many bytes. + /// byte[] BinaryRead(int count); + /// + /// Gets the param with the specified key. + /// + /// String this [String key] { get; } + /// + /// Reads the cookie. + /// + /// The cookie name. + /// String ReadCookie( String name ); + /// + /// Gets the query string. + /// + /// The query string. NameValueCollection QueryString { get; } + /// + /// Gets the form. + /// + /// The form. NameValueCollection Form { get; } + /// + /// Gets the user languages. + /// + /// The user languages. String[] UserLanguages { get; } /// @@ -65,6 +115,9 @@ public interface IRequest /// The IP address of the remote client. string UserHostAddress { get; } + /// + /// Validates the input. + /// void ValidateInput(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IResource.cs b/MonoRail/Castle.MonoRail.Framework/IResource.cs index 96f40799d..c40c2045e 100644 --- a/MonoRail/Castle.MonoRail.Framework/IResource.cs +++ b/MonoRail/Castle.MonoRail.Framework/IResource.cs @@ -38,12 +38,4 @@ public interface IResource : IDisposable, IEnumerable /// object GetObject(String key); } - -/* /// - /// Marker interface that declares that this attribute should - /// be used as a definition for a resource in the user ResourceFactory. - /// -// public interface IResourceDefinition -// { -// }*/ } diff --git a/MonoRail/Castle.MonoRail.Framework/IResourceFactory.cs b/MonoRail/Castle.MonoRail.Framework/IResourceFactory.cs index a0f7be2a4..1f1d3c223 100644 --- a/MonoRail/Castle.MonoRail.Framework/IResourceFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/IResourceFactory.cs @@ -24,8 +24,18 @@ namespace Castle.MonoRail.Framework /// public interface IResourceFactory { + /// + /// Creates the specified descriptor. + /// + /// The descriptor. + /// The app assembly. + /// IResource Create(ResourceDescriptor descriptor, Assembly appAssembly); + /// + /// Releases the specified resource. + /// + /// The resource. void Release(IResource resource); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IResponse.cs b/MonoRail/Castle.MonoRail.Framework/IResponse.cs index 4577c9efd..3a773e083 100644 --- a/MonoRail/Castle.MonoRail.Framework/IResponse.cs +++ b/MonoRail/Castle.MonoRail.Framework/IResponse.cs @@ -17,10 +17,21 @@ namespace Castle.MonoRail.Framework using System; using System.Web; + /// + /// Represents the response data and operations + /// public interface IResponse { + /// + /// Gets or sets the status code. + /// + /// The status code. int StatusCode { get; set; } + /// + /// Gets or sets the type of the content. + /// + /// The type of the content. String ContentType { get; set; } /// @@ -37,50 +48,148 @@ public interface IResponse /// /// Gets or sets the HTTP character set of the output stream. /// - String Charset { get; set; } + String Charset { get; set; } + /// + /// Gets the output. + /// + /// The output. System.IO.TextWriter Output { get; } - + + /// + /// Gets the output stream. + /// + /// The output stream. System.IO.Stream OutputStream { get; } + /// + /// Appends the header. + /// + /// The name. + /// The value. void AppendHeader(String name, String value); + /// + /// Writes the buffer to the browser + /// + /// The buffer. void BinaryWrite(byte[] buffer); + /// + /// Writes the stream to the browser + /// + /// The stream. void BinaryWrite(System.IO.Stream stream); + /// + /// Clears the response (only works if buffered) + /// void Clear(); + /// + /// Clears the response content (only works if buffered). + /// void ClearContent(); + /// + /// Writes the specified string. + /// + /// The string. void Write(String s); + /// + /// Writes the specified obj. + /// + /// The obj. void Write(object obj); + /// + /// Writes the specified char. + /// + /// The char. void Write(char ch); + /// + /// Writes the specified buffer. + /// + /// The buffer. + /// The index. + /// The count. void Write(char[] buffer, int index, int count); + /// + /// Writes the file. + /// + /// Name of the file. void WriteFile(String fileName); + /// + /// Redirects the specified controller. + /// + /// The controller. + /// The action. void Redirect(String controller, String action); + /// + /// Redirects the specified area. + /// + /// The area. + /// The controller. + /// The action. void Redirect(String area, String controller, String action); + /// + /// Redirects the specified URL. + /// + /// The URL. void Redirect(String url); + /// + /// Redirects the specified URL. + /// + /// The URL. + /// if set to true [end process]. void Redirect(String url, bool endProcess); + /// + /// Gets a value indicating whether the response sent a redirect. + /// + /// true if was redirected; otherwise, false. bool WasRedirected { get; } + /// + /// Gets a value indicating whether this instance is client connected. + /// + /// + /// true if this instance is client connected; otherwise, false. + /// bool IsClientConnected { get; } + /// + /// Creates a cookie. + /// + /// The name. + /// The value. void CreateCookie(String name, String value); - + + /// + /// Creates a cookie. + /// + /// The name. + /// The value. + /// The expiration. void CreateCookie(String name, String value, DateTime expiration); + /// + /// Creates a cookie. + /// + /// The cookie. void CreateCookie(HttpCookie cookie); - + + /// + /// Removes a cookie. + /// + /// The name. void RemoveCookie(string name); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IScaffoldingSupport.cs b/MonoRail/Castle.MonoRail.Framework/IScaffoldingSupport.cs index 9c7c77237..43f1113da 100644 --- a/MonoRail/Castle.MonoRail.Framework/IScaffoldingSupport.cs +++ b/MonoRail/Castle.MonoRail.Framework/IScaffoldingSupport.cs @@ -15,12 +15,17 @@ namespace Castle.MonoRail.Framework { /// - /// Pendent + /// Abstracts the implementation of scaffolding support for MonoRail. + /// + /// Implementors should use information from the controller instance + /// and add dynamic actions to it exposing operations to manipulate an entity. + /// /// public interface IScaffoldingSupport { /// - /// Pendent + /// Implementors should use this method to read information + /// from the controller instance and add dynamic actions to the controller. /// /// void Process(Controller controller); diff --git a/MonoRail/Castle.MonoRail.Framework/IServerUtility.cs b/MonoRail/Castle.MonoRail.Framework/IServerUtility.cs index 9557abd1a..f865c4ccb 100644 --- a/MonoRail/Castle.MonoRail.Framework/IServerUtility.cs +++ b/MonoRail/Castle.MonoRail.Framework/IServerUtility.cs @@ -15,8 +15,10 @@ namespace Castle.MonoRail.Framework { using System; - using System.Collections.Specialized; + /// + /// Represents utility methods that web servers provide + /// public interface IServerUtility { /// diff --git a/MonoRail/Castle.MonoRail.Framework/ITrace.cs b/MonoRail/Castle.MonoRail.Framework/ITrace.cs index 8a7d1f803..8956293a4 100644 --- a/MonoRail/Castle.MonoRail.Framework/ITrace.cs +++ b/MonoRail/Castle.MonoRail.Framework/ITrace.cs @@ -16,19 +16,51 @@ namespace Castle.MonoRail.Framework { using System; - + /// + /// Represents the trace that ASP.Net exposes + /// public interface ITrace { + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. void Warn(String message); + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. void Warn(String category, String message); + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. void Warn(String category, String message, Exception errorInfo); + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. void Write(String message); + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. void Write(String category, String message); + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. void Write(String category, String message, Exception errorInfo); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IUrlBuilder.cs b/MonoRail/Castle.MonoRail.Framework/IUrlBuilder.cs index c3162cab5..9aca99cfc 100644 --- a/MonoRail/Castle.MonoRail.Framework/IUrlBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/IUrlBuilder.cs @@ -17,20 +17,83 @@ namespace Castle.MonoRail.Framework using System.Collections; using System.Collections.Specialized; + /// + /// THe UrlBuilder service centralizes the url generation used by the whole + /// framework including redirect urls, urls generated by helpers and so on. + /// It offers a central place to change MonoRail behavior on how to deal with urls. + /// public interface IUrlBuilder { + /// + /// Builds the URL using the current url as contextual information and a parameter dictionary. + /// + /// Common parameters includes area, controller and action. + /// + /// + /// The current Url information. + /// The parameters. + /// string BuildUrl(UrlInfo current, IDictionary parameters); + /// + /// Builds an URL using the controller name and action name. + /// + /// The current Url information. + /// The controller. + /// The action. + /// string BuildUrl(UrlInfo current, string controller, string action); + /// + /// Builds an URL using the controller name, action name, and a querystring dictionary. + /// + /// The current Url information. + /// The controller. + /// The action. + /// The query string params. + /// string BuildUrl(UrlInfo current, string controller, string action, IDictionary queryStringParams); + /// + /// Builds an URL using the controller name, action name, and a querystring name value collection. + /// + /// The current Url information. + /// The controller. + /// The action. + /// The query string params. + /// string BuildUrl(UrlInfo current, string controller, string action, NameValueCollection queryStringParams); + /// + /// Builds an URL using the area name, controller name and action name. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// string BuildUrl(UrlInfo current, string area, string controller, string action); + /// + /// Builds an URL using the area name, controller name, action name, and a querystring dictionary. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// The query string params. + /// string BuildUrl(UrlInfo current, string area, string controller, string action, IDictionary queryStringParams); + /// + /// Builds an URL using the area name, controller name, action name, and a querystring name value collection. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// The query string params. + /// string BuildUrl(UrlInfo current, string area, string controller, string action, NameValueCollection queryStringParams); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IViewComponentFactory.cs b/MonoRail/Castle.MonoRail.Framework/IViewComponentFactory.cs index be0ed0947..2eb3a4ceb 100644 --- a/MonoRail/Castle.MonoRail.Framework/IViewComponentFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/IViewComponentFactory.cs @@ -22,6 +22,11 @@ namespace Castle.MonoRail.Framework /// public interface IViewComponentFactory { + /// + /// Creates the specified name. + /// + /// The name. + /// ViewComponent Create(String name); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IViewComponentRegistry.cs b/MonoRail/Castle.MonoRail.Framework/IViewComponentRegistry.cs index ab1a20569..9a389a77a 100644 --- a/MonoRail/Castle.MonoRail.Framework/IViewComponentRegistry.cs +++ b/MonoRail/Castle.MonoRail.Framework/IViewComponentRegistry.cs @@ -16,10 +16,23 @@ namespace Castle.MonoRail.Framework { using System; + /// + /// Depicts a contract for viewcomponent registry implementations + /// public interface IViewComponentRegistry { + /// + /// Adds the view component. + /// + /// The name. + /// The type. void AddViewComponent(string name, Type type); - + + /// + /// Gets the view component. + /// + /// The name. + /// Type GetViewComponent(string name); } } diff --git a/MonoRail/Castle.MonoRail.Framework/IViewSource.cs b/MonoRail/Castle.MonoRail.Framework/IViewSource.cs index 001c48896..726a93f31 100644 --- a/MonoRail/Castle.MonoRail.Framework/IViewSource.cs +++ b/MonoRail/Castle.MonoRail.Framework/IViewSource.cs @@ -17,14 +17,33 @@ namespace Castle.MonoRail.Framework using System; using System.IO; + /// + /// Represents a view template source + /// public interface IViewSource { + /// + /// Opens the view stream. + /// + /// Stream OpenViewStream(); + /// + /// Gets or sets the last updated. + /// + /// The last updated. long LastUpdated { get; set; } + /// + /// Gets the last modified. + /// + /// The last modified. long LastModified { get; } + /// + /// Gets a value indicating whether cache is enabled for it. + /// + /// true if cache is enabled for it; otherwise, false. bool EnableCache { get; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/IViewSourceLoader.cs b/MonoRail/Castle.MonoRail.Framework/IViewSourceLoader.cs index a5af8bc15..711c2058a 100644 --- a/MonoRail/Castle.MonoRail.Framework/IViewSourceLoader.cs +++ b/MonoRail/Castle.MonoRail.Framework/IViewSourceLoader.cs @@ -19,27 +19,28 @@ namespace Castle.MonoRail.Framework using System.IO; /// - /// Pendent + /// Defines a contract that abstracts view template locations. /// public interface IViewSourceLoader { /// /// Evaluates whether the specified template exists. /// + /// The template name /// true if it exists bool HasTemplate(String templateName); /// - /// + /// Builds and returns a representation of a view template /// - /// + /// The template name /// IViewSource GetViewSource(String templateName); /// - /// + /// Gets a list of views on the specified directory /// - /// + /// Directory name /// String[] ListViews(String dirName); @@ -49,12 +50,12 @@ public interface IViewSourceLoader String ViewRootDir { get; set; } /// - /// + /// Gets or sets whether the instance should use cache /// bool EnableCache { get; set; } /// - /// + /// Gets a list of assembly sources /// IList AssemblySources { get; } diff --git a/MonoRail/Castle.MonoRail.Framework/IWizardController.cs b/MonoRail/Castle.MonoRail.Framework/IWizardController.cs index e75cf4377..286bdf3f7 100644 --- a/MonoRail/Castle.MonoRail.Framework/IWizardController.cs +++ b/MonoRail/Castle.MonoRail.Framework/IWizardController.cs @@ -16,14 +16,81 @@ namespace Castle.MonoRail.Framework { using System; + /// + /// Depicts the contract for wizard controllers. + /// + /// + /// + /// + /// + /// + /// The following code shows how to create a simple wizard with two pages. + /// + /// [DynamicActionProvider(typeof(WizardActionProvider))] + /// public class MyWizardController : Controller, IWizardController + /// { + /// public void OnWizardStart() + /// { } + /// + /// public bool OnBeforeStep(String wizardName, String stepName, WizardStepPage step) + /// { + /// returtn true; + /// } + /// + /// public void OnAfterStep(String wizardName, String stepName, WizardStepPage step) + /// { } + /// + /// public WizardStepPage[] GetSteps(IRailsEngineContext context) + /// { + /// return new WizardStepPage[] { new MyPage1(), new MyPage2() }; + /// } + /// } + /// + /// + /// + /// + /// The interface members allow you to perform some logic on important + /// events from a wizard lifecycle. The must be used + /// to return the steps the wizard has. + /// public interface IWizardController { + /// + /// Called when the wizard starts. + /// + /// + /// This is invoked only once per wizard lifecycle, but can + /// happen again if the data added by the infrastructure was not found on the session. + /// void OnWizardStart(); + /// + /// Called before processing a step. Returning false tells + /// the infrastructure to stop the processing the request. + /// + /// Name of the wizard. + /// Name of the step. + /// The step instance. + /// true if the process should proceed, otherwise, false bool OnBeforeStep(String wizardName, String stepName, WizardStepPage step); + /// + /// Called after processing a step. + /// + /// Name of the wizard. + /// Name of the step. + /// The step instance. void OnAfterStep(String wizardName, String stepName, WizardStepPage step); + /// + /// Implementors should return an array of steps that compose the wizard. + /// + /// + /// This should be deterministic per session -- ie. + /// always return the same instances for the same user session. + /// + /// The web request context. + /// An array of steps WizardStepPage[] GetSteps(IRailsEngineContext context); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/ActionProviderUtil.cs b/MonoRail/Castle.MonoRail.Framework/Internal/ActionProviderUtil.cs index 30e378d42..85fd8a1c0 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/ActionProviderUtil.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/ActionProviderUtil.cs @@ -16,16 +16,23 @@ namespace Castle.MonoRail.Framework.Internal { using System; + /// + /// Util class that deals with action providers + /// public abstract class ActionProviderUtil { - public static void RegisterActions( Controller controller ) + /// + /// Registers the actions on the controller. + /// + /// The controller. + public static void RegisterActions(Controller controller) { - foreach (Type providerType in controller.MetaDescriptor.ActionProviders) + foreach(Type providerType in controller.MetaDescriptor.ActionProviders) { - IDynamicActionProvider provider = (IDynamicActionProvider) Activator.CreateInstance( providerType ); + IDynamicActionProvider provider = (IDynamicActionProvider) Activator.CreateInstance(providerType); - provider.IncludeActions( controller ); + provider.IncludeActions(controller); } } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/AssemblySourceInfo.cs b/MonoRail/Castle.MonoRail.Framework/Internal/AssemblySourceInfo.cs index 5cd29241d..9ea4a4a36 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/AssemblySourceInfo.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/AssemblySourceInfo.cs @@ -20,6 +20,9 @@ namespace Castle.MonoRail.Framework using System.IO; using System.Reflection; + /// + /// Represents a source of views in an assembly resource. + /// public class AssemblySourceInfo { private readonly String assemblyName; @@ -60,11 +63,23 @@ public string Namespace get { return _namespace; } } + /// + /// Determines whether the assembly has the specified template. + /// + /// Name of the template. + /// + /// true if the specified exists on the assembly; otherwise, false. + /// public bool HasTemplate(String templateName) { return entries.Contains(NormalizeTemplateName(templateName)); } + /// + /// Gets the template stream. + /// + /// Name of the template. + /// public Stream GetTemplateStream(String templateName) { String resourcePath = (String) entries[NormalizeTemplateName(templateName)]; @@ -72,6 +87,11 @@ public Stream GetTemplateStream(String templateName) return loadedAssembly.GetManifestResourceStream(resourcePath); } + /// + /// Collects the views on the assembly resource. + /// + /// Name of the dir. + /// The views. public void CollectViews(string dirName, ArrayList views) { int toStripLength = _namespace.Length; @@ -84,7 +104,7 @@ public void CollectViews(string dirName, ArrayList views) { String name = names[i].ToLower(System.Globalization.CultureInfo.InvariantCulture); - if (_namespace != null && name.StartsWith(_namespace.ToLower(System.Globalization.CultureInfo.InvariantCulture))) + if (name.StartsWith(_namespace.ToLower(System.Globalization.CultureInfo.InvariantCulture))) { if (name[toStripLength] == '.') { @@ -103,11 +123,19 @@ public void CollectViews(string dirName, ArrayList views) } } - private String NormalizeTemplateName(string templateName) + /// + /// Normalizes the name of the template. + /// + /// Name of the template. + /// + private static String NormalizeTemplateName(string templateName) { return templateName.Replace('/', '.').Replace('\\', '.'); } + /// + /// Registers the entries. + /// private void RegisterEntries() { int toStripLength = _namespace.Length; @@ -118,7 +146,7 @@ private void RegisterEntries() { String name = names[i].ToLower(System.Globalization.CultureInfo.InvariantCulture); - if (_namespace != null && name.StartsWith(_namespace.ToLower(System.Globalization.CultureInfo.InvariantCulture))) + if (name.StartsWith(_namespace.ToLower(System.Globalization.CultureInfo.InvariantCulture))) { if (name[toStripLength] == '.') { diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ActionMetaDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ActionMetaDescriptor.cs index 5acc4bf12..4f0bc298e 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ActionMetaDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ActionMetaDescriptor.cs @@ -28,29 +28,49 @@ public class ActionMetaDescriptor : BaseMetaDescriptor private IList skipFilters = new ArrayList(); private IList cacheConfigurers = new ArrayList(); private TransformFilterDescriptor[] transformFilters = new TransformFilterDescriptor[] {}; - + + /// + /// Gets or sets the skip rescue associated with this action. + /// + /// The skip rescue. public SkipRescueAttribute SkipRescue { get { return skipRescue; } set { skipRescue = value; } } + /// + /// Gets or sets the accessible through definition associated with this action. + /// + /// The accessible through. public AccessibleThroughAttribute AccessibleThrough { get { return accessibleThrough; } set { accessibleThrough = value; } } + /// + /// Gets the skip filters associated with this action. + /// + /// The skip filters. public IList SkipFilters { get { return skipFilters; } } + /// + /// Gets the cache configurers associated with this action. + /// + /// The cache configurers. public IList CacheConfigurers { get { return cacheConfigurers; } } + /// + /// Gets or sets the transform filters associated with this action. + /// + /// The transform filters. public TransformFilterDescriptor[] TransformFilters { get { return transformFilters; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/BaseMetaDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/BaseMetaDescriptor.cs index 0ce631a81..5b712449b 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/BaseMetaDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/BaseMetaDescriptor.cs @@ -16,6 +16,10 @@ namespace Castle.MonoRail.Framework.Internal { using System; + /// + /// Common meta descriptor that represents configuration share by + /// controllers and actions. + /// [Serializable] public abstract class BaseMetaDescriptor { @@ -23,18 +27,30 @@ public abstract class BaseMetaDescriptor private RescueDescriptor[] rescues = new RescueDescriptor[0]; private ResourceDescriptor[] resources = new ResourceDescriptor[0]; + /// + /// Gets or sets the layout descriptor. + /// + /// The layout. public LayoutDescriptor Layout { get { return layout; } set { layout = value; } } + /// + /// Gets or sets the rescues descriptors. + /// + /// The rescues. public RescueDescriptor[] Rescues { get { return rescues; } set { rescues = value; } } + /// + /// Gets or sets the resources descriptors. + /// + /// The resources. public ResourceDescriptor[] Resources { get { return resources; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerDescriptor.cs index 5e0f0a4dc..20310a3ab 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerDescriptor.cs @@ -17,7 +17,7 @@ namespace Castle.MonoRail.Framework.Internal using System; /// - /// Represents the information about a . + /// Represents the configuration associated with a . /// public class ControllerDescriptor { @@ -25,6 +25,12 @@ public class ControllerDescriptor private String name; private String area; + /// + /// Initializes a new instance of the class. + /// + /// Type of the controller. + /// The name of the controller. + /// The area associated with the controller. public ControllerDescriptor(Type controllerType, String name, String area) { this.controllerType = controllerType; @@ -32,16 +38,28 @@ public ControllerDescriptor(Type controllerType, String name, String area) this.area = area; } + /// + /// Gets the type of the controller. + /// + /// The type of the controller. public Type ControllerType { get { return controllerType; } } + /// + /// Gets the controller's name. + /// + /// The name. public String Name { get { return name; } } + /// + /// Gets the controller's area. + /// + /// The area. public String Area { get { return area; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerMetaDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerMetaDescriptor.cs index 73c23c5a5..15a53a08f 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerMetaDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ControllerMetaDescriptor.cs @@ -16,36 +16,45 @@ namespace Castle.MonoRail.Framework.Internal { using System; using System.Collections; + using System.Collections.Generic; using System.Collections.Specialized; using System.Reflection; /// /// Holds all meta information a controller might /// expose, so the attributes are collected only once. - /// This is a huge performance boost. + /// This approach translates into a huge performance boost. /// [Serializable] public class ControllerMetaDescriptor : BaseMetaDescriptor { private DefaultActionAttribute defaultAction; - private IList scaffoldings = new ArrayList(); private HelperDescriptor[] helpers; - private IList actionProviders = new ArrayList(); - private IList ajaxActions = new ArrayList(); - private Hashtable actionMetaDescriptors = new Hashtable(); - private IDictionary actions = new HybridDictionary(true); private FilterDescriptor[] filters; private TransformFilterDescriptor[] transformFilters; - + private Dictionary actionMetaDescriptors = new Dictionary(); + private IList scaffoldings = new ArrayList(); + private IList actionProviders = new List(); + private IList ajaxActions = new List(); + private IDictionary actions = new HybridDictionary(true); + + /// + /// Initializes a new instance of the class. + /// public ControllerMetaDescriptor() { } + /// + /// Gets an action descriptor with information about an action. + /// + /// The action method. + /// public ActionMetaDescriptor GetAction(MethodInfo actionMethod) { - ActionMetaDescriptor desc = (ActionMetaDescriptor) actionMetaDescriptors[actionMethod]; + ActionMetaDescriptor desc; - if (desc == null) + if (!actionMetaDescriptors.TryGetValue(actionMethod, out desc)) { desc = new ActionMetaDescriptor(); actionMetaDescriptors[actionMethod] = desc; @@ -54,44 +63,76 @@ public ActionMetaDescriptor GetAction(MethodInfo actionMethod) return desc; } + /// + /// Gets the actions. + /// + /// The actions. public IDictionary Actions { get { return actions; } } - public IList AjaxActions + /// + /// Gets the ajax actions. + /// + /// The ajax actions. + public IList AjaxActions { get { return ajaxActions; } } + /// + /// Gets or sets the default action. + /// + /// The default action. public DefaultActionAttribute DefaultAction { get { return defaultAction; } set { defaultAction = value; } } + /// + /// Gets or sets the helpers. + /// + /// The helpers. public HelperDescriptor[] Helpers { get { return helpers; } set { helpers = value; } } + /// + /// Gets or sets the filters. + /// + /// The filters. public FilterDescriptor[] Filters { get { return filters; } set { filters = value; } } + /// + /// Gets the scaffoldings. + /// + /// The scaffoldings. public IList Scaffoldings { get { return scaffoldings; } } - public IList ActionProviders + /// + /// Gets the action providers. + /// + /// The action providers. + public IList ActionProviders { get { return actionProviders; } } + /// + /// Gets or sets the transform filters. + /// + /// The transform filters. public TransformFilterDescriptor[] TransformFilters { get { return transformFilters; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/FilterDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/FilterDescriptor.cs index ecb8d8287..c2c7a5b68 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/FilterDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/FilterDescriptor.cs @@ -28,6 +28,13 @@ public class FilterDescriptor : ICloneable private IFilter filterInstance; private FilterAttribute attribute; + /// + /// Initializes a new instance of the class. + /// + /// Type of the filter. + /// The flag that defines when it should run. + /// The execution order. + /// The attribute. public FilterDescriptor(Type filterType, ExecuteEnum when, int executionOrder, FilterAttribute attribute) { this.filterType = filterType; @@ -36,33 +43,59 @@ public FilterDescriptor(Type filterType, ExecuteEnum when, int executionOrder, F this.attribute = attribute; } + /// + /// Gets the type of the filter. + /// + /// The type of the filter. public Type FilterType { get { return filterType; } } + /// + /// Gets the flag that defines when it should run. + /// + /// The when. public ExecuteEnum When { get { return when; } } + /// + /// Gets the execution order. + /// + /// The execution order. public int ExecutionOrder { get { return executionOrder; } } + /// + /// Gets or sets the filter instance. + /// + /// The filter instance. public IFilter FilterInstance { get { return filterInstance; } set { filterInstance = value; } } + /// + /// Gets or sets the attribute. + /// + /// The attribute. public FilterAttribute Attribute { get { return attribute; } set { attribute = value; } } + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// public object Clone() { return new FilterDescriptor(filterType, when, executionOrder, attribute); diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/HelperDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/HelperDescriptor.cs index e5c4988d4..196978374 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/HelperDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/HelperDescriptor.cs @@ -25,21 +25,38 @@ public class HelperDescriptor private readonly String name; private readonly Type helperType; + /// + /// Initializes a new instance of the class. + /// + /// Type of the helper. public HelperDescriptor(Type helperType) { this.helperType = helperType; } + /// + /// Initializes a new instance of the class. + /// + /// Type of the helper. + /// A custom name to use to access the helper from the view. public HelperDescriptor(Type helperType, String name) : this(helperType) { this.name = name; } + /// + /// Gets the helper name. + /// + /// The name. public string Name { get { return name; } } + /// + /// Gets the type of the helper. + /// + /// The type of the helper. public Type HelperType { get { return helperType; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IFilterDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IFilterDescriptorBuilder.cs index 9d9ce50b1..30f81db56 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IFilterDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IFilterDescriptorBuilder.cs @@ -14,8 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { + /// + /// Contract for builders. + /// public interface IFilterDescriptorBuilder { + /// + /// Builds the filter descriptors. + /// + /// FilterDescriptor[] BuildFilterDescriptors(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IHelperDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IHelperDescriptorBuilder.cs index c7875c76f..caab2b7c3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IHelperDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IHelperDescriptorBuilder.cs @@ -14,8 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { + /// + /// Contract for builders + /// public interface IHelperDescriptorBuilder { + /// + /// Builds the helper descriptors. + /// + /// HelperDescriptor[] BuildHelperDescriptors(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ILayoutDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ILayoutDescriptorBuilder.cs index 86e927fa9..1a3cd8206 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ILayoutDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ILayoutDescriptorBuilder.cs @@ -14,8 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { + /// + /// Contract for builders + /// public interface ILayoutDescriptorBuilder { + /// + /// Builds the layout descriptor. + /// + /// LayoutDescriptor BuildLayoutDescriptor(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IRescueDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IRescueDescriptorBuilder.cs index 4c2719a1a..4c0b17c7a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IRescueDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IRescueDescriptorBuilder.cs @@ -14,10 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { - using System; - + /// + /// Contract for builders + /// public interface IRescueDescriptorBuilder { + /// + /// Builds the rescue descriptors. + /// + /// RescueDescriptor[] BuildRescueDescriptors(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IResourceDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IResourceDescriptorBuilder.cs index fdd0df71b..c676a0d68 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IResourceDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/IResourceDescriptorBuilder.cs @@ -14,10 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { - using System; - + /// + /// Contract for builders + /// public interface IResourceDescriptorBuilder { + /// + /// Builds the resource descriptors. + /// + /// ResourceDescriptor[] BuildResourceDescriptors(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ITransformFilterDescriptorBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ITransformFilterDescriptorBuilder.cs index 85694d27e..3bf85f78f 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ITransformFilterDescriptorBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ITransformFilterDescriptorBuilder.cs @@ -14,8 +14,15 @@ namespace Castle.MonoRail.Framework.Internal { + /// + /// Contract for builders + /// public interface ITransformFilterDescriptorBuilder { + /// + /// Builds the transform filter descriptors. + /// + /// TransformFilterDescriptor[] BuildTransformFilterDescriptors(); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/LayoutDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/LayoutDescriptor.cs index 96e88fb82..1766bd38c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/LayoutDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/LayoutDescriptor.cs @@ -16,15 +16,26 @@ namespace Castle.MonoRail.Framework.Internal { using System; + /// + /// Represents a layout configuration + /// public class LayoutDescriptor { private readonly String layoutName; + /// + /// Initializes a new instance of the class. + /// + /// Name of the layout. public LayoutDescriptor(String layoutName) { this.layoutName = layoutName; } + /// + /// Gets the name of the layout. + /// + /// The name of the layout. public String LayoutName { get { return layoutName; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/RescueDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/RescueDescriptor.cs index 709a7f2e0..b6d2c33ba 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/RescueDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/RescueDescriptor.cs @@ -16,22 +16,38 @@ namespace Castle.MonoRail.Framework.Internal { using System; + /// + /// Represents a rescue configuration + /// public class RescueDescriptor { private readonly string viewName; private readonly Type exceptionType; + /// + /// Initializes a new instance of the class. + /// + /// Name of the rescue view. + /// Type of the exception it is associated with. public RescueDescriptor(string viewName, Type exceptionType) { this.viewName = viewName; this.exceptionType = exceptionType; } + /// + /// Gets the name of the rescue view. + /// + /// The name of the view. public string ViewName { get { return viewName; } } + /// + /// Gets the type of the exception this rescue is associated with. + /// + /// The type of the exception. public Type ExceptionType { get { return exceptionType; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ResourceDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ResourceDescriptor.cs index 148a44efc..4121bccb3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ResourceDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/ResourceDescriptor.cs @@ -16,6 +16,9 @@ namespace Castle.MonoRail.Framework.Internal { using System; + /// + /// Represents a resource configuration associated with a controller. + /// public class ResourceDescriptor { private readonly Type resourceType; @@ -24,6 +27,14 @@ public class ResourceDescriptor private readonly string cultureName; private readonly string assemblyName; + /// + /// Initializes a new instance of the class. + /// + /// Type that has the resource. + /// The name. + /// Name of the resource. + /// Name of the culture. + /// Name of the assembly. public ResourceDescriptor(Type resourceType, string name, string resourceName, string cultureName, string assemblyName) { @@ -34,26 +45,46 @@ public ResourceDescriptor(Type resourceType, string name, string resourceName, this.assemblyName = assemblyName; } + /// + /// Gets the type that has the resource. + /// + /// The type that has the resource. public Type ResourceType { get { return resourceType; } } + /// + /// Gets the name. + /// + /// The name. public string Name { get { return name; } } + /// + /// Gets the name of the resource. + /// + /// The name of the resource. public string ResourceName { get { return resourceName; } } + /// + /// Gets the name of the culture. + /// + /// The name of the culture. public string CultureName { get { return cultureName; } } + /// + /// Gets the name of the assembly. + /// + /// The name of the assembly. public string AssemblyName { get { return assemblyName; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/TransformFilterDescriptor.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/TransformFilterDescriptor.cs index 8490741d1..e1432fe17 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/TransformFilterDescriptor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Descriptors/TransformFilterDescriptor.cs @@ -26,7 +26,13 @@ public class TransformFilterDescriptor private readonly Type transformFilterType; private readonly int executionOrder; private TransformFilterAttribute attribute; - + + /// + /// Initializes a new instance of the class. + /// + /// Type of the transform filter. + /// The execution order. + /// The attribute. public TransformFilterDescriptor(Type transformFilterType, int executionOrder, TransformFilterAttribute attribute) { this.transformFilterType = transformFilterType; @@ -34,17 +40,28 @@ public TransformFilterDescriptor(Type transformFilterType, int executionOrder, T this.executionOrder = executionOrder; } + /// + /// Gets the attribute. + /// + /// The attribute. public TransformFilterAttribute Attribute { get { return attribute; } - set { attribute = value; } } + /// + /// Gets the type of the transform filter. + /// + /// The type of the transform filter. public Type TransformFilterType { get { return transformFilterType; } } + /// + /// Gets the execution order. + /// + /// The execution order. public int ExecutionOrder { get { return executionOrder; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/JSCollectionGeneratorBase.cs b/MonoRail/Castle.MonoRail.Framework/Internal/JSCollectionGeneratorBase.cs index d48f71e7f..e1645c305 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/JSCollectionGeneratorBase.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/JSCollectionGeneratorBase.cs @@ -16,9 +16,21 @@ namespace Castle.MonoRail.Framework.Internal { using Castle.MonoRail.Framework.Helpers; + /// + /// Collection related generator + /// + /// + /// Not really implemented. + /// public abstract class JSCollectionGeneratorBase { + /// + /// Collection generator instance + /// protected readonly IJSCollectionGenerator generator; + /// + /// Parent generator instance + /// protected readonly IJSGenerator parentGenerator; /// @@ -42,7 +54,6 @@ protected void InternalGet(string propName) PrototypeHelper.JSGenerator.Record(parentGenerator, propName); } - /// /// Invokes the specified method. /// diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/JSElementGeneratorBase.cs b/MonoRail/Castle.MonoRail.Framework/Internal/JSElementGeneratorBase.cs index b06a7efe2..bcc735001 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/JSElementGeneratorBase.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/JSElementGeneratorBase.cs @@ -16,9 +16,18 @@ namespace Castle.MonoRail.Framework.Internal { using Castle.MonoRail.Framework.Helpers; + /// + /// Operations related to an element + /// public abstract class JSElementGeneratorBase { + /// + /// Element generator instance + /// protected readonly IJSElementGenerator generator; + /// + /// Parent Generator instance + /// protected readonly IJSGenerator parentGenerator; /// @@ -31,12 +40,22 @@ public JSElementGeneratorBase(IJSElementGenerator generator) parentGenerator = generator.ParentGenerator; } + /// + /// Generates a get statement + /// + /// Name of the prop. protected void InternalGet(string propName) { PrototypeHelper.JSGenerator.ReplaceTailByPeriod(parentGenerator); PrototypeHelper.JSGenerator.Record(parentGenerator, propName); } + /// + /// Dispatches the invocation (late bound) + /// + /// The method. + /// The args. + /// protected object InternalInvoke(string method, object[] args) { if (method == "set") diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/JSGeneratorBase.cs b/MonoRail/Castle.MonoRail.Framework/Internal/JSGeneratorBase.cs index 753590f1f..29fc8218b 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/JSGeneratorBase.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/JSGeneratorBase.cs @@ -23,13 +23,26 @@ namespace Castle.MonoRail.Framework.Internal /// public abstract class JSGeneratorBase { + /// + /// The generator instance + /// protected readonly IJSGenerator generator; + /// + /// Initializes a new instance of the class. + /// + /// The generator. protected JSGeneratorBase(IJSGenerator generator) { this.generator = generator; } + /// + /// Executes an operation (totally late bound) + /// + /// The method. + /// The args. + /// protected object InternalInvoke(string method, params object[] args) { if (method == "el") @@ -76,10 +89,24 @@ protected object InternalInvoke(string method, params object[] args) return CreateNullGenerator(); } + /// + /// Creates a null generator. + /// + /// protected abstract object CreateNullGenerator(); + /// + /// Creates a JS collection generator. + /// + /// The collection generator. + /// protected abstract object CreateJSCollectionGenerator(IJSCollectionGenerator collectionGenerator); + /// + /// Creates a JS element generator. + /// + /// The element generator. + /// protected abstract object CreateJSElementGenerator(IJSElementGenerator elementGenerator); /// diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultFilterDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultFilterDescriptorProvider.cs index 4e239afe4..f3701a99a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultFilterDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultFilterDescriptorProvider.cs @@ -49,6 +49,15 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Implementors should collect the filter information + /// and return descriptors instances, or an empty array if none + /// was found. + /// + /// The controller type + /// + /// An array of + /// public FilterDescriptor[] CollectFilters(Type controllerType) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultHelperDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultHelperDescriptorProvider.cs index 30a2b13b9..1cc0abae4 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultHelperDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultHelperDescriptorProvider.cs @@ -49,6 +49,15 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Implementors should collect the helper information + /// and return descriptors instances, or an empty array if none + /// was found. + /// + /// The controller type + /// + /// An array of + /// public HelperDescriptor[] CollectHelpers(Type controllerType) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultLayoutDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultLayoutDescriptorProvider.cs index 9b2d93731..3487198d4 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultLayoutDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultLayoutDescriptorProvider.cs @@ -48,7 +48,16 @@ public void Service(IServiceProvider provider) } #endregion - + + /// + /// Implementors should collect the layout information + /// and return a descriptor instance, or null if none + /// was found. + /// + /// The controller type or action (MethodInfo) + /// + /// An instance + /// public LayoutDescriptor CollectLayout(MemberInfo memberInfo) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultRescueDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultRescueDescriptorProvider.cs index e22603c30..4ce5dc176 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultRescueDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultRescueDescriptorProvider.cs @@ -50,6 +50,11 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Collects the rescues. + /// + /// The type. + /// public RescueDescriptor[] CollectRescues(Type type) { if (logger.IsDebugEnabled) @@ -85,6 +90,15 @@ public RescueDescriptor[] CollectRescues(Type type) return (RescueDescriptor[]) descriptors.ToArray(typeof(RescueDescriptor)); } + /// + /// Implementors should collect the rescue information + /// and return descriptors instances, or an empty array if none + /// was found. + /// + /// The action (MethodInfo) + /// + /// An array of + /// public RescueDescriptor[] CollectRescues(MethodInfo memberInfo) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultResourceDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultResourceDescriptorProvider.cs index f33da1f38..23a561df9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultResourceDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultResourceDescriptorProvider.cs @@ -50,6 +50,11 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Collects the resources. + /// + /// The member info. + /// public ResourceDescriptor[] CollectResources(MemberInfo memberInfo) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultTransformFilterDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultTransformFilterDescriptorProvider.cs index 5b79f1e14..ef7db537d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultTransformFilterDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/DefaultTransformFilterDescriptorProvider.cs @@ -49,6 +49,15 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Implementors should collect the transformfilter information + /// and return descriptors instances, or an empty array if none + /// was found. + /// + /// The action (MethodInfo) + /// + /// An array of + /// public TransformFilterDescriptor[] CollectFilters(MemberInfo memberInfo) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/ITransformDescriptorFilterProvider.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/ITransformDescriptorFilterProvider.cs index f4f0f293c..8e9bb6b77 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Providers/ITransformDescriptorFilterProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Providers/ITransformDescriptorFilterProvider.cs @@ -14,7 +14,6 @@ namespace Castle.MonoRail.Framework.Internal { - using System; using System.Reflection; using Castle.MonoRail.Framework; diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/ResourceDictionary.cs b/MonoRail/Castle.MonoRail.Framework/Internal/ResourceDictionary.cs index 079728718..b99dfbfe6 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/ResourceDictionary.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/ResourceDictionary.cs @@ -23,44 +23,80 @@ namespace Castle.MonoRail.Framework.Internal /// public class ResourceDictionary : ICollection { - private HybridDictionary map = new HybridDictionary( true ); - - public void Add( object key, IResource resource ) + private HybridDictionary map = new HybridDictionary(true); + + /// + /// Adds the specified key. + /// + /// The key. + /// The resource. + public void Add(object key, IResource resource) { - map.Add( key, resource ); + map.Add(key, resource); } - public IResource this[ object key ] + /// + /// Gets or sets the with the specified key. + /// + /// + public IResource this[object key] { - get { return map[ key ] as IResource; } - set { map[ key ] = value; } + get { return map[key] as IResource; } + set { map[key] = value; } } + /// + /// Gets the number of elements contained in the . + /// + /// + /// The number of elements contained in the . public int Count { get { return map.Count; } } - public void Remove( object key ) + /// + /// Removes the specified key. + /// + /// The key. + public void Remove(object key) { - map.Remove( key ); + map.Remove(key); } - + + /// + /// Determines whether the resource contains the specified key. + /// + /// The key. + /// + /// true if the resource contains it; otherwise, false. + /// public bool Contains(object key) { - return map.Contains( key ); + return map.Contains(key); } + /// + /// Clears this instance. + /// public void Clear() { map.Clear(); } + /// + /// Gets the values. + /// + /// The values. public ICollection Values { get { return map.Values; } } + /// + /// Gets the keys. + /// + /// The keys. public ICollection Keys { get { return map.Keys; } @@ -68,16 +104,35 @@ public ICollection Keys #region ICollection Members + /// + /// Gets a value indicating whether access to the is synchronized (thread safe). + /// + /// + /// true if access to the is synchronized (thread safe); otherwise, false. public bool IsSynchronized { get { return map.IsSynchronized; } } + /// + /// Copies the elements of the to an , starting at a particular index. + /// + /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. + /// The zero-based index in array at which copying begins. + /// array is null. + /// index is less than zero. + /// array is multidimensional.-or- index is equal to or greater than the length of array.-or- The number of elements in the source is greater than the available space from index to the end of the destination array. + /// The type of the source cannot be cast automatically to the type of the destination array. public void CopyTo(Array array, int index) { - map.CopyTo( array, index ); + map.CopyTo(array, index); } + /// + /// Gets an object that can be used to synchronize access to the . + /// + /// + /// An object that can be used to synchronize access to the . public object SyncRoot { get { return map.SyncRoot; } @@ -87,6 +142,12 @@ public object SyncRoot #region IEnumerable Members + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// IEnumerator System.Collections.IEnumerable.GetEnumerator() { return map.GetEnumerator(); @@ -94,4 +155,4 @@ IEnumerator System.Collections.IEnumerable.GetEnumerator() #endregion } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/ResourceFacade.cs b/MonoRail/Castle.MonoRail.Framework/Internal/ResourceFacade.cs index 45840df65..ef9726844 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/ResourceFacade.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/ResourceFacade.cs @@ -14,7 +14,6 @@ namespace Castle.MonoRail.Framework.Internal { - using System; using System.Collections; using System.Globalization; using System.Resources; @@ -28,31 +27,59 @@ public class ResourceFacade : IResource private readonly ResourceManager resourceManager; private readonly CultureInfo cultureInfo; + /// + /// Initializes a new instance of the class. + /// + /// The resource manager. + /// The culture info. public ResourceFacade(ResourceManager resourceManager, CultureInfo cultureInfo) { this.resourceManager = resourceManager; this.cultureInfo = cultureInfo; } + /// + /// Returns the object linked to the specific key. + /// + /// + /// public object GetObject(string key) { return resourceManager.GetObject(key, cultureInfo); } + /// + /// Returns the object linked to the specific key as a string. + /// + /// + /// public string GetString(string key) { return resourceManager.GetString(key, cultureInfo); } + /// + /// Returns the object linked to the specific key. + /// + /// public object this[string key] { get { return resourceManager.GetObject(key, cultureInfo); } } + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// public void Dispose() { } + /// + /// Returns an enumerator that iterates through a collection. + /// + /// + /// An object that can be used to iterate through the collection. + /// public IEnumerator GetEnumerator() { return resourceManager diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/ScaffoldException.cs b/MonoRail/Castle.MonoRail.Framework/Internal/ScaffoldException.cs index a585aba12..c36561043 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/ScaffoldException.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/ScaffoldException.cs @@ -17,17 +17,34 @@ namespace Castle.MonoRail.Framework using System; using System.Runtime.Serialization; + /// + /// Exception to be used by scaffolding implementations + /// [Serializable] public class ScaffoldException : RailsException { + /// + /// Initializes a new instance of the class. + /// + /// The message. public ScaffoldException(String message) : base(message) { } + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner exception. public ScaffoldException(String message, Exception innerException) : base(message, innerException) { } + /// + /// Initializes a new instance of the class. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. public ScaffoldException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/Test/TestContextHolder.cs b/MonoRail/Castle.MonoRail.Framework/Internal/Test/TestContextHolder.cs index 1ae993fa1..eb05c03fd 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/Test/TestContextHolder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/Test/TestContextHolder.cs @@ -18,21 +18,32 @@ namespace Castle.MonoRail.Framework.Internal.Test /// /// Helper class to store the context to be used - /// for the test cases + /// for the test cases (that use the ASP.Net Runtime) /// public abstract class TestContextHolder { private static HttpContext _context; + /// + /// Initializes a new instance of the class. + /// private TestContextHolder() { } + /// + /// Sets the context. + /// + /// The context. public static void SetContext(HttpContext context) { _context = context; } + /// + /// Gets the context. + /// + /// The context. public static HttpContext Context { get { return _context; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/UrlInfo.cs b/MonoRail/Castle.MonoRail.Framework/Internal/UrlInfo.cs index ccd32730c..f36a2c273 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/UrlInfo.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/UrlInfo.cs @@ -68,46 +68,82 @@ public UrlInfo(string domain, string subdomain, string appVirtualDir, string pro this.protocol = protocol; } + /// + /// Gets the app virtual dir. + /// + /// The app virtual dir. public string AppVirtualDir { get { return appVirtualDir; } } + /// + /// Gets the port. + /// + /// The port. public int Port { get { return port; } } + /// + /// Gets the domain. + /// + /// The domain. public string Domain { get { return domain; } } + /// + /// Gets the subdomain. + /// + /// The subdomain. public string Subdomain { get { return subdomain; } } + /// + /// Gets the URL raw. + /// + /// The URL raw. public string UrlRaw { get { return urlRaw; } } + /// + /// Gets the area. + /// + /// The area. public string Area { get { return area; } } + /// + /// Gets the controller. + /// + /// The controller. public string Controller { get { return controller; } } + /// + /// Gets the action. + /// + /// The action. public string Action { get { return action; } } + /// + /// Gets the protocol. + /// + /// The protocol. public string Protocol { get { return protocol; } diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/UrlTokenizerException.cs b/MonoRail/Castle.MonoRail.Framework/Internal/UrlTokenizerException.cs index 6a1af7ab5..8ef373aca 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/UrlTokenizerException.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/UrlTokenizerException.cs @@ -23,12 +23,21 @@ namespace Castle.MonoRail.Framework.Internal [Serializable] public class UrlTokenizerException : RailsException { - public UrlTokenizerException( String message ) : base( message ) + /// + /// Initializes a new instance of the class. + /// + /// The message. + public UrlTokenizerException(String message) : base(message) { } - public UrlTokenizerException( SerializationInfo info, StreamingContext context ) : base( info, context ) + /// + /// Initializes a new instance of the class. + /// + /// The object that holds the serialized object data. + /// The contextual information about the source or destination. + public UrlTokenizerException(SerializationInfo info, StreamingContext context) : base(info, context) { } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Internal/WizardUtils.cs b/MonoRail/Castle.MonoRail.Framework/Internal/WizardUtils.cs index f29c32fd8..ae01574b7 100644 --- a/MonoRail/Castle.MonoRail.Framework/Internal/WizardUtils.cs +++ b/MonoRail/Castle.MonoRail.Framework/Internal/WizardUtils.cs @@ -17,8 +17,16 @@ namespace Castle.MonoRail.Framework.Internal using System; using System.Collections; - public abstract class WizardUtils + /// + /// Utility class for wizard related queries and operations + /// + public static class WizardUtils { + /// + /// Constructs the wizard namespace. + /// + /// The controller. + /// public static String ConstructWizardNamespace(Controller controller) { if (controller is WizardStepPage) @@ -29,6 +37,13 @@ public static String ConstructWizardNamespace(Controller controller) return String.Format("wizard.{0}", controller.Name); } + /// + /// Determines whether the current wizard has a previous step. + /// + /// The controller. + /// + /// true if has previous step; otherwise, false. + /// public static bool HasPreviousStep(Controller controller) { IRailsEngineContext context = controller.Context; @@ -40,6 +55,13 @@ public static bool HasPreviousStep(Controller controller) return currentIndex > 0; } + /// + /// Determines whether the current wizard has a next step. + /// + /// The controller. + /// + /// true if has next step; otherwise, false. + /// public static bool HasNextStep(Controller controller) { IRailsEngineContext context = controller.Context; @@ -53,6 +75,11 @@ public static bool HasNextStep(Controller controller) return (currentIndex + 1) < stepList.Count; } + /// + /// Gets the name of the previous step. + /// + /// The controller. + /// public static String GetPreviousStepName(Controller controller) { IRailsEngineContext context = controller.Context; @@ -71,6 +98,11 @@ public static String GetPreviousStepName(Controller controller) return null; } + /// + /// Gets the name of the next step. + /// + /// The controller. + /// public static String GetNextStepName(Controller controller) { IRailsEngineContext context = controller.Context; @@ -89,6 +121,11 @@ public static String GetNextStepName(Controller controller) return null; } + /// + /// Registers the current step info/state. + /// + /// The controller. + /// Name of the action. public static void RegisterCurrentStepInfo(Controller controller, String actionName) { IRailsEngineContext context = controller.Context; @@ -108,6 +145,12 @@ public static void RegisterCurrentStepInfo(Controller controller, String actionN } } + /// + /// Registers the current step info/state. + /// + /// The controller. + /// Index of the step. + /// Name of the step. public static void RegisterCurrentStepInfo(Controller controller, int stepIndex, String stepName) { IRailsEngineContext context = controller.Context; diff --git a/MonoRail/Castle.MonoRail.Framework/MonoRailHttpHandler.cs b/MonoRail/Castle.MonoRail.Framework/MonoRailHttpHandler.cs index 447690e9a..932f092ba 100644 --- a/MonoRail/Castle.MonoRail.Framework/MonoRailHttpHandler.cs +++ b/MonoRail/Castle.MonoRail.Framework/MonoRailHttpHandler.cs @@ -152,6 +152,10 @@ protected virtual UrlInfo ExtractUrlInfo(IRailsEngineContext context) return context.UrlInfo; } + /// + /// Gets the current context. + /// + /// The current context. public static IRailsEngineContext CurrentContext { get diff --git a/MonoRail/Castle.MonoRail.Framework/ServiceContainerAccessor.cs b/MonoRail/Castle.MonoRail.Framework/ServiceContainerAccessor.cs index 3f34c943c..1cf90f3e6 100644 --- a/MonoRail/Castle.MonoRail.Framework/ServiceContainerAccessor.cs +++ b/MonoRail/Castle.MonoRail.Framework/ServiceContainerAccessor.cs @@ -23,6 +23,10 @@ public class ServiceContainerAccessor { private static IServiceContainer container; + /// + /// Gets or sets the service container. + /// + /// The service container. public static IServiceContainer ServiceContainer { get { return container; } diff --git a/MonoRail/Castle.MonoRail.Framework/ServiceProviderLocator.cs b/MonoRail/Castle.MonoRail.Framework/ServiceProviderLocator.cs index c143a4e53..a8a3fef27 100644 --- a/MonoRail/Castle.MonoRail.Framework/ServiceProviderLocator.cs +++ b/MonoRail/Castle.MonoRail.Framework/ServiceProviderLocator.cs @@ -28,16 +28,27 @@ public class ServiceProviderLocator private readonly IList locatorStrategies = new List(); + /// + /// Initializes a new instance of the class. + /// public ServiceProviderLocator() { AddLocatorStrategy(new ServiceProviderAccessorStrategy()); } + /// + /// Gets the instance. + /// + /// The instance. public static ServiceProviderLocator Instance { get { return instance; } } + /// + /// Locates the service provider using the registered strategies. + /// + /// public IServiceProviderEx LocateProvider() { foreach(IAccessorStrategy strategy in locatorStrategies) @@ -53,18 +64,37 @@ public IServiceProviderEx LocateProvider() return null; } + /// + /// Adds a locator strategy. + /// + /// The strategy. public void AddLocatorStrategy(IAccessorStrategy strategy) { locatorStrategies.Add(strategy); } + /// + /// Abstract an approach to access a + /// public interface IAccessorStrategy { + /// + /// Locates the provider. + /// + /// IServiceProviderEx LocateProvider(); } + /// + /// Default strategy to access a service provider + /// public class ServiceProviderAccessorStrategy : IAccessorStrategy { + /// + /// Locates the provider using the ApplicationInstance and casting it to + /// + /// + /// public IServiceProviderEx LocateProvider() { IServiceProviderExAccessor containerAccessor = diff --git a/MonoRail/Castle.MonoRail.Framework/Services/AbstractControllerFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/AbstractControllerFactory.cs index 4a376a8b8..984af11df 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/AbstractControllerFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/AbstractControllerFactory.cs @@ -80,22 +80,42 @@ public virtual void Service(IServiceProvider provider) #endregion + /// + /// Implementors should perform their logic to + /// return a instance of . + /// If the can not be found, + /// it should return null. + /// + /// + /// public virtual Controller CreateController(UrlInfo urlInfo) { - String area = urlInfo.Area == null ? String.Empty : urlInfo.Area; + String area = urlInfo.Area ?? String.Empty; String name = urlInfo.Controller; return CreateControllerInstance(area, name); } + /// + /// Implementors should perform their logic + /// to release the instance + /// and its resources. + /// + /// public virtual void Release(Controller controller) { if (logger.IsDebugEnabled) { logger.Debug("Controller released: " + controller.GetType()); } + + controller.Dispose(); } + /// + /// Gets the tree. + /// + /// The tree. public IControllerTree Tree { get { return tree; } @@ -114,6 +134,12 @@ protected void AddBuiltInControllers() Tree.AddController("MonoRail", "Files", typeof(FilesController)); } + /// + /// Creates the controller instance. + /// + /// The area. + /// The name. + /// protected virtual Controller CreateControllerInstance(String area, String name) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Services/AbstractServiceContainer.cs b/MonoRail/Castle.MonoRail.Framework/Services/AbstractServiceContainer.cs index fb7635dfa..5acf314a4 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/AbstractServiceContainer.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/AbstractServiceContainer.cs @@ -19,6 +19,9 @@ namespace Castle.MonoRail.Framework.Services using System.Collections.Specialized; using System.ComponentModel.Design; + /// + /// Basic implementation of + /// public abstract class AbstractServiceContainer : MarshalByRefObject, IServiceContainer { private IServiceContainer parent; @@ -164,6 +167,11 @@ public object GetService(Type serviceType) #endregion + /// + /// Gets the service. + /// + /// + /// public T GetService() { return (T) GetService(typeof(T)); @@ -179,6 +187,10 @@ public IServiceContainer Parent set { parent = value; } } + /// + /// Gets the parent container. + /// + /// The parent container. private IServiceContainer ParentContainer { get diff --git a/MonoRail/Castle.MonoRail.Framework/Services/AbstractViewComponentFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/AbstractViewComponentFactory.cs index 8b22bac44..b89d8e9b8 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/AbstractViewComponentFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/AbstractViewComponentFactory.cs @@ -87,6 +87,11 @@ public virtual ViewComponent Create(String name) } } + /// + /// Resolves the type. + /// + /// The name. + /// protected Type ResolveType(string name) { if (logger.IsDebugEnabled) @@ -151,6 +156,10 @@ protected void RegisterComponent(String name, Type type) GetViewComponentRegistry().AddViewComponent(name, type); } + /// + /// Gets the view component registry. + /// + /// protected virtual IViewComponentRegistry GetViewComponentRegistry() { throw new NotImplementedException(); diff --git a/MonoRail/Castle.MonoRail.Framework/Services/AjaxProxyGenerator/PrototypeAjaxProxyGenerator.cs b/MonoRail/Castle.MonoRail.Framework/Services/AjaxProxyGenerator/PrototypeAjaxProxyGenerator.cs index 2754a0034..77986b4f6 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/AjaxProxyGenerator/PrototypeAjaxProxyGenerator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/AjaxProxyGenerator/PrototypeAjaxProxyGenerator.cs @@ -50,6 +50,9 @@ private static readonly Type /// private ILogger logger = NullLogger.Instance; + /// + /// Initializes a new instance of the class. + /// public PrototypeAjaxProxyGenerator() { } @@ -190,14 +193,19 @@ public String GenerateJSProxy(IRailsEngineContext context, string proxyName, str "var " + proxyName + " =" + nl + result + ""; } - private string GetParameterName(ParameterInfo pi) + /// + /// Gets the name of the parameter. + /// + /// The parameterInfo. + /// + private string GetParameterName(ParameterInfo paramInfo) { String paramName = null; object parameterAttribute; // change the parameter name, if using [DataBind] - parameterAttribute = GetSingleAttribute(pi, typeof(DataBindAttribute), true); + parameterAttribute = GetSingleAttribute(paramInfo, typeof(DataBindAttribute), true); if (parameterAttribute != null) { paramName = ((DataBindAttribute) parameterAttribute).Prefix; @@ -206,7 +214,7 @@ private string GetParameterName(ParameterInfo pi) if (ARFetchAttType != null) { // change the parameter name, if using [ARFetch] - parameterAttribute = GetSingleAttribute(pi, ARFetchAttType, true); + parameterAttribute = GetSingleAttribute(paramInfo, ARFetchAttType, true); if (parameterAttribute != null) { paramName = Convert.ToString(GetPropertyValue(parameterAttribute, "RequestParameterName")); @@ -218,7 +226,7 @@ private string GetParameterName(ParameterInfo pi) // use the default parameter name, if none of the parameter binders define a new name if (paramName == null || paramName.Length == 0) { - paramName = pi.Name; + paramName = paramInfo.Name; } return ToCamelCase(paramName); @@ -226,6 +234,12 @@ private string GetParameterName(ParameterInfo pi) #region Utility Methods + /// + /// Gets the property value. + /// + /// The obj. + /// Name of the prop. + /// private object GetPropertyValue(object obj, string propName) { if (obj == null) @@ -235,16 +249,27 @@ private object GetPropertyValue(object obj, string propName) return propertyInfo.GetValue(obj, null); } + /// + /// Gets the single attribute. + /// + /// The obj. + /// Type of the attribute. + /// if set to true [inherit]. + /// private object GetSingleAttribute(ICustomAttributeProvider obj, Type attributeType, bool inherit) { object[] attributes = obj.GetCustomAttributes(attributeType, inherit); return (attributes.Length > 0 ? attributes[0] : null); } + /// + /// Toes the camel case. + /// + /// The value. + /// private string ToCamelCase(string value) { - if (value == null || value.Length == 0) - return value; + if (value == null || value.Length == 0) return value; return Char.ToLower(value[0], CultureInfo.InvariantCulture) + (value.Length > 0 ? value.Substring(1) : null); diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultCacheProvider.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultCacheProvider.cs index 30d6cb6a0..09487f2db 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultCacheProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultCacheProvider.cs @@ -49,6 +49,13 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Determines whether the specified key is on the cache. + /// + /// The key. + /// + /// true if the cache has the key; otherwise, false. + /// public bool HasKey(String key) { if (logger.IsDebugEnabled) @@ -59,6 +66,11 @@ public bool HasKey(String key) return Get(key) != null; } + /// + /// Gets the cache item by the specified key. + /// + /// The key. + /// public object Get(String key) { if (logger.IsDebugEnabled) @@ -69,6 +81,11 @@ public object Get(String key) return GetCurrentContext().Cache.Get(key); } + /// + /// Stores the cache item by the specified key. + /// + /// The key. + /// The data. public void Store(String key, object data) { if (logger.IsDebugEnabled) @@ -79,6 +96,10 @@ public void Store(String key, object data) GetCurrentContext().Cache.Insert(key, data); } + /// + /// Deletes the cache item by the specified key. + /// + /// The key. public void Delete(String key) { if (logger.IsDebugEnabled) @@ -89,7 +110,11 @@ public void Delete(String key) GetCurrentContext().Cache.Remove(key); } - private HttpContext GetCurrentContext() + /// + /// Gets the current context. + /// + /// + private static HttpContext GetCurrentContext() { return HttpContext.Current; } diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerDescriptorProvider.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerDescriptorProvider.cs index 3c9ec07bf..daf384661 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerDescriptorProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerDescriptorProvider.cs @@ -48,6 +48,10 @@ public class DefaultControllerDescriptorProvider : IControllerDescriptorProvider #region IServiceEnabledComponent implementation + /// + /// Services the specified service provider. + /// + /// The service provider. public void Service(IServiceProvider serviceProvider) { ILoggerFactory loggerFactory = (ILoggerFactory) serviceProvider.GetService(typeof(ILoggerFactory)); @@ -136,7 +140,12 @@ public ControllerMetaDescriptor BuildDescriptor(Type controllerType) return desc; } - + + /// + /// Builds the for the specified controller type + /// + /// Type of the controller. + /// private ControllerMetaDescriptor InternalBuildDescriptor(Type controllerType) { if (logger.IsDebugEnabled) @@ -156,7 +165,12 @@ private ControllerMetaDescriptor InternalBuildDescriptor(Type controllerType) } #region Action data - + + /// + /// Collects the actions. + /// + /// Type of the controller. + /// The desc. private void CollectActions(Type controllerType, ControllerMetaDescriptor desc) { // HACK: GetRealControllerType is a workaround for DYNPROXY-14 bug @@ -197,6 +211,10 @@ private void CollectActions(Type controllerType, ControllerMetaDescriptor desc) } } + /// + /// Collects the action level attributes. + /// + /// The descriptor. private void CollectActionLevelAttributes(ControllerMetaDescriptor descriptor) { foreach(object action in descriptor.Actions.Values) @@ -215,6 +233,11 @@ private void CollectActionLevelAttributes(ControllerMetaDescriptor descriptor) } } + /// + /// Collects the action attributes. + /// + /// The method. + /// The descriptor. private void CollectActionAttributes(MethodInfo method, ControllerMetaDescriptor descriptor) { if (logger.IsDebugEnabled) @@ -237,8 +260,22 @@ private void CollectActionAttributes(MethodInfo method, ControllerMetaDescriptor { descriptor.AjaxActions.Add(method); } + + if (method.IsDefined(typeof(DefaultActionAttribute), true)) + { + if (descriptor.DefaultAction != null) + { + throw new RailsException("Cannot resolve a default action for {0}, DefaultActionAttribute was declared more than once.", method.DeclaringType.FullName); + } + descriptor.DefaultAction = new DefaultActionAttribute(method.Name); + } } + /// + /// Collects the skip rescue. + /// + /// The action descriptor. + /// The method. private void CollectSkipRescue(ActionMetaDescriptor actionDescriptor, MethodInfo method) { object[] attributes = method.GetCustomAttributes(typeof(SkipRescueAttribute), true); @@ -249,6 +286,11 @@ private void CollectSkipRescue(ActionMetaDescriptor actionDescriptor, MethodInfo } } + /// + /// Collects the accessible through. + /// + /// The action descriptor. + /// The method. private void CollectAccessibleThrough(ActionMetaDescriptor actionDescriptor, MethodInfo method) { object[] attributes = method.GetCustomAttributes(typeof(AccessibleThroughAttribute), true); @@ -259,6 +301,11 @@ private void CollectAccessibleThrough(ActionMetaDescriptor actionDescriptor, Met } } + /// + /// Collects the skip filter. + /// + /// The action descriptor. + /// The method. private void CollectSkipFilter(ActionMetaDescriptor actionDescriptor, MethodInfo method) { object[] attributes = method.GetCustomAttributes(typeof(SkipFilterAttribute), true); @@ -269,11 +316,21 @@ private void CollectSkipFilter(ActionMetaDescriptor actionDescriptor, MethodInfo } } + /// + /// Collects the resources. + /// + /// The desc. + /// The member info. private void CollectResources(BaseMetaDescriptor desc, MemberInfo memberInfo) { desc.Resources = resourceDescriptorProvider.CollectResources(memberInfo); } + /// + /// Collects the transform filter. + /// + /// The action descriptor. + /// The method. private void CollectTransformFilter(ActionMetaDescriptor actionDescriptor, MethodInfo method) { actionDescriptor.TransformFilters = transformFilterDescriptorProvider.CollectFilters((method)); @@ -312,6 +369,11 @@ private Type GetRealControllerType(Type controllerType) #region Controller data + /// + /// Collects the class level attributes. + /// + /// Type of the controller. + /// The descriptor. private void CollectClassLevelAttributes(Type controllerType, ControllerMetaDescriptor descriptor) { CollectHelpers(descriptor, controllerType); @@ -324,6 +386,11 @@ private void CollectClassLevelAttributes(Type controllerType, ControllerMetaDesc CollectDynamicAction(descriptor, controllerType); } + /// + /// Collects the default action. + /// + /// The descriptor. + /// Type of the controller. private void CollectDefaultAction(ControllerMetaDescriptor descriptor, Type controllerType) { object[] attributes = controllerType.GetCustomAttributes(typeof(DefaultActionAttribute), true); @@ -334,6 +401,11 @@ private void CollectDefaultAction(ControllerMetaDescriptor descriptor, Type cont } } + /// + /// Collects the scaffolding. + /// + /// The descriptor. + /// Type of the controller. private void CollectScaffolding(ControllerMetaDescriptor descriptor, Type controllerType) { object[] attributes = controllerType.GetCustomAttributes(typeof(ScaffoldingAttribute), false); @@ -347,6 +419,11 @@ private void CollectScaffolding(ControllerMetaDescriptor descriptor, Type contro } } + /// + /// Collects the dynamic action. + /// + /// The descriptor. + /// Type of the controller. private void CollectDynamicAction(ControllerMetaDescriptor descriptor, Type controllerType) { object[] attributes = controllerType.GetCustomAttributes(typeof(DynamicActionProviderAttribute), true); @@ -360,11 +437,21 @@ private void CollectDynamicAction(ControllerMetaDescriptor descriptor, Type cont } } + /// + /// Collects the helpers. + /// + /// The descriptor. + /// Type of the controller. private void CollectHelpers(ControllerMetaDescriptor descriptor, Type controllerType) { descriptor.Helpers = helperDescriptorProvider.CollectHelpers(controllerType); } + /// + /// Collects the filters. + /// + /// The descriptor. + /// Type of the controller. private void CollectFilters(ControllerMetaDescriptor descriptor, Type controllerType) { descriptor.Filters = filterDescriptorProvider.CollectFilters(controllerType); @@ -372,21 +459,41 @@ private void CollectFilters(ControllerMetaDescriptor descriptor, Type controller Array.Sort(descriptor.Filters, FilterDescriptorComparer.Instance); } + /// + /// Collects the layout. + /// + /// The descriptor. + /// The member info. private void CollectLayout(BaseMetaDescriptor descriptor, MemberInfo memberInfo) { descriptor.Layout = layoutDescriptorProvider.CollectLayout(memberInfo); } + /// + /// Collects the rescues. + /// + /// The descriptor. + /// The member info. private void CollectRescues(BaseMetaDescriptor descriptor, MethodInfo memberInfo) { descriptor.Rescues = rescueDescriptorProvider.CollectRescues(memberInfo); } + /// + /// Collects the rescues. + /// + /// The descriptor. + /// The type. private void CollectRescues(BaseMetaDescriptor descriptor, Type type) { descriptor.Rescues = rescueDescriptorProvider.CollectRescues(type); } + /// + /// Collects the cache configures. + /// + /// The descriptor. + /// The member info. private void CollectCacheConfigures(ActionMetaDescriptor descriptor, MemberInfo memberInfo) { object[] configurers = memberInfo.GetCustomAttributes(typeof(ICachePolicyConfigurer), true); @@ -410,15 +517,28 @@ class FilterDescriptorComparer : IComparer { private static readonly FilterDescriptorComparer instance = new FilterDescriptorComparer(); + /// + /// Initializes a new instance of the class. + /// private FilterDescriptorComparer() { } + /// + /// Gets the instance. + /// + /// The instance. public static FilterDescriptorComparer Instance { get { return instance; } } + /// + /// Compares the specified left. + /// + /// The left. + /// The right. + /// public int Compare(object left, object right) { return ((FilterDescriptor) left).ExecutionOrder - ((FilterDescriptor) right).ExecutionOrder; @@ -433,15 +553,28 @@ class TransformFilterDescriptorComparer : IComparer { private static readonly TransformFilterDescriptorComparer instance = new TransformFilterDescriptorComparer(); + /// + /// Initializes a new instance of the class. + /// private TransformFilterDescriptorComparer() { } + /// + /// Gets the instance. + /// + /// The instance. public static TransformFilterDescriptorComparer Instance { get { return instance; } } + /// + /// Compares the specified left. + /// + /// The left. + /// The right. + /// public int Compare(object left, object right) { return ((TransformFilterDescriptor)right).ExecutionOrder - ((TransformFilterDescriptor)left).ExecutionOrder; diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerFactory.cs index 10abc826d..5b0e43bd0 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerFactory.cs @@ -15,7 +15,6 @@ namespace Castle.MonoRail.Framework.Services { using System; - using System.Configuration; using System.Reflection; using Castle.Core; @@ -136,6 +135,10 @@ public void Inspect(Assembly assembly) } } + /// + /// Registers the controller. + /// + /// The descriptor. private void RegisterController(ControllerDescriptor descriptor) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerLifecycleExecutorFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerLifecycleExecutorFactory.cs index d8568422c..5ebfad13b 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerLifecycleExecutorFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultControllerLifecycleExecutorFactory.cs @@ -18,7 +18,7 @@ namespace Castle.MonoRail.Framework.Services using Castle.Core; /// - /// + /// Default implementation of /// public class DefaultControllerLifecycleExecutorFactory : IControllerLifecycleExecutorFactory, IServiceEnabledComponent { @@ -41,6 +41,10 @@ public IControllerLifecycleExecutor CreateExecutor(Controller controller, IRails return executor; } + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { serviceProvider = provider; diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultResourceFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultResourceFactory.cs index 2dac89107..5c1536509 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultResourceFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultResourceFactory.cs @@ -85,6 +85,11 @@ public void Release(IResource resource) resource.Dispose(); } + /// + /// Resolves the culture by name. + /// + /// The name. + /// private CultureInfo ResolveCulture(String name) { if (logger.IsDebugEnabled) @@ -104,6 +109,12 @@ private CultureInfo ResolveCulture(String name) return CultureInfo.CurrentCulture; } + /// + /// Resolves the assembly. + /// + /// The name. + /// The assembly. + /// private Assembly ResolveAssembly(String name, Assembly assembly) { if (name == null) return assembly; diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlBuilder.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlBuilder.cs index 3201ba7e4..12233e15f 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlBuilder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlBuilder.cs @@ -19,24 +19,50 @@ namespace Castle.MonoRail.Framework.Services using System.Collections.Specialized; using Castle.Core; using Castle.MonoRail.Framework.Internal; - + using Framework; + + /// + /// Default implementation of + /// + /// + /// The property defines whether the builder should output + /// file extension. This might be handy to use in combination with a url rewrite strategy + /// + /// + /// If you want to create a custom urlbuilder, you can extend this one and override + /// the + /// + /// + /// + /// public class DefaultUrlBuilder : IUrlBuilder, IServiceEnabledComponent { private bool useExtensions = true; private IServerUtility serverUtil; + /// + /// Initializes a new instance of the class. + /// public DefaultUrlBuilder() { } #region Properties + /// + /// Gets or sets a value indicating whether the builder should output an extension. + /// + /// true if should use extensions; otherwise, false. public bool UseExtensions { get { return useExtensions; } set { useExtensions = value; } } + /// + /// Gets or sets the server utility instance. + /// + /// The server util. public IServerUtility ServerUtil { get { return serverUtil; } @@ -47,6 +73,10 @@ public IServerUtility ServerUtil #region IServiceEnabledComponent + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { serverUtil = (IServerUtility) provider.GetService(typeof(IServerUtility)); @@ -56,6 +86,57 @@ public void Service(IServiceProvider provider) #region IUrlBuilder + /// + /// Builds the URL using the current url as contextual information and a parameter dictionary. + /// + /// + /// + /// + /// + /// Common parameters includes area, controller and action, which outputs + /// /area/controller/name.extension + /// + /// + /// + /// Please note that if you dont specify an area or controller name, they will be inferred from the + /// context. If you want to use an empty area, you must specify area=''. + /// This is commonly a source of confusion, so understand the following cases: + /// + /// + /// + /// + /// UrlInfo current = ... // Assume that the current is area Admin, controller Products and action List + /// + /// BuildUrl(current, {action: 'view'}) + /// // returns /Admin/Products/view.castle + /// + /// BuildUrl(current, {controller: 'Home', action: 'index'}) + /// // returns /Admin/Home/index.castle + /// + /// BuildUrl(current, {area:'', controller: 'Home', action: 'index'}) + /// // returns /Home/index.castle + /// + /// + /// + /// + /// The querystring parameter can be a string or a dictionary. It appends a query string to the url: + /// /area/controller/name.extension?id=1 + /// + /// + /// + /// The absolute parameter forces the builder to output a full url like + /// http://hostname/virtualdir/area/controller/name.extension + /// + /// + /// + /// The encode parameter forces the builder to encode the querystring + /// /controller/name.extension?id=1&name=John which is required to output full xhtml compliant content. + /// + /// + /// + /// The current Url information. + /// The parameters. + /// public virtual string BuildUrl(UrlInfo current, IDictionary parameters) { bool applySubdomain = false; @@ -120,6 +201,13 @@ public virtual string BuildUrl(UrlInfo current, IDictionary parameters) current.AppVirtualDir, current.Extension, createAbsolutePath, applySubdomain, suffix, basePath); } + /// + /// Builds an URL using the controller name and action name. + /// + /// The current Url information. + /// The controller. + /// The action. + /// public virtual string BuildUrl(UrlInfo current, string controller, string action) { Hashtable parameters = new Hashtable(); @@ -128,6 +216,14 @@ public virtual string BuildUrl(UrlInfo current, string controller, string action return BuildUrl(current, parameters); } + /// + /// Builds an URL using the controller name, action name, and a querystring dictionary. + /// + /// The current Url information. + /// The controller. + /// The action. + /// The query string params. + /// public virtual string BuildUrl(UrlInfo current, string controller, string action, IDictionary queryStringParams) { Hashtable parameters = new Hashtable(); @@ -137,6 +233,14 @@ public virtual string BuildUrl(UrlInfo current, string controller, string action return BuildUrl(current, parameters); } + /// + /// Builds an URL using the controller name, action name, and a querystring name value collection. + /// + /// The current Url information. + /// The controller. + /// The action. + /// The query string params. + /// public virtual string BuildUrl(UrlInfo current, string controller, string action, NameValueCollection queryStringParams) { Hashtable parameters = new Hashtable(); @@ -146,6 +250,14 @@ public virtual string BuildUrl(UrlInfo current, string controller, string action return BuildUrl(current, parameters); } + /// + /// Builds an URL using the area name, controller name and action name. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// public virtual string BuildUrl(UrlInfo current, string area, string controller, string action) { Hashtable parameters = new Hashtable(); @@ -155,6 +267,15 @@ public virtual string BuildUrl(UrlInfo current, string area, string controller, return BuildUrl(current, parameters); } + /// + /// Builds an URL using the area name, controller name, action name, and a querystring dictionary. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// The query string params. + /// public virtual string BuildUrl(UrlInfo current, string area, string controller, string action, IDictionary queryStringParams) { Hashtable parameters = new Hashtable(); @@ -165,6 +286,15 @@ public virtual string BuildUrl(UrlInfo current, string area, string controller, return BuildUrl(current, parameters); } + /// + /// Builds an URL using the area name, controller name, action name, and a querystring name value collection. + /// + /// The current Url information. + /// The area. + /// The controller. + /// The action. + /// The query string params. + /// public virtual string BuildUrl(UrlInfo current, string area, string controller, string action, NameValueCollection queryStringParams) { @@ -178,6 +308,22 @@ public virtual string BuildUrl(UrlInfo current, string area, string controller, #endregion + /// + /// Internals the build URL. + /// + /// The area. + /// The controller. + /// The action. + /// The protocol. + /// The port. + /// The domain. + /// The subdomain. + /// The app virtual dir. + /// The extension. + /// if set to true [absolute path]. + /// if set to true [apply subdomain]. + /// The suffix. + /// protected virtual string InternalBuildUrl(string area, string controller, string action, string protocol, string port, string domain, string subdomain, string appVirtualDir, string extension, bool absolutePath, bool applySubdomain, string suffix) @@ -187,6 +333,23 @@ protected virtual string InternalBuildUrl(string area, string controller, string applySubdomain, suffix, null); } + /// + /// Internals the build URL. + /// + /// The area. + /// The controller. + /// The action. + /// The protocol. + /// The port. + /// The domain. + /// The subdomain. + /// The app virtual dir. + /// The extension. + /// if set to true [absolute path]. + /// if set to true [apply subdomain]. + /// The suffix. + /// The base path. + /// protected virtual string InternalBuildUrl(string area, string controller, string action, string protocol, string port, string domain, string subdomain, string appVirtualDir, string extension, bool absolutePath, bool applySubdomain, string suffix, string basePath) @@ -220,6 +383,20 @@ protected virtual string InternalBuildUrl(string area, string controller, string return path; } + /// + /// Internals the build using app virtual dir. + /// + /// if set to true [absolute path]. + /// The action. + /// if set to true [apply subdomain]. + /// The app virtual dir. + /// The area. + /// The controller. + /// The domain. + /// The port. + /// The protocol. + /// The subdomain. + /// private static string InternalBuildUsingAppVirtualDir(bool absolutePath, string action, bool applySubdomain, string appVirtualDir, string area, string controller, string domain, string port, string protocol, string subdomain) { string path; @@ -262,6 +439,14 @@ private static string InternalBuildUsingAppVirtualDir(bool absolutePath, string return path; } + /// + /// Internals the build URL using base path. + /// + /// The action. + /// The area. + /// The base path. + /// The controller. + /// private static string InternalBuildUrlUsingBasePath(string action, string area, string basePath, string controller) { string path; diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlTokenizer.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlTokenizer.cs index a1ac4f00c..adf3db0aa 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlTokenizer.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultUrlTokenizer.cs @@ -27,13 +27,24 @@ namespace Castle.MonoRail.Framework.Services /// Breaks the url into smaller pieces to find out /// the requested controller, action and optionally the area. /// - /// It alsos checks for default urls. + /// It alsos checks for default urls which map a single resource to an area/controller/action /// /// public class DefaultUrlTokenizer : IUrlTokenizer, IServiceEnabledComponent { private IDictionary defaultUrl2CustomUrlInfo = new HybridDictionary(true); + /// + /// Adds the default rule mapping. + /// + /// + /// A defautl rule can associate something like a 'default.castle' + /// to a controller/action like 'Home/index.castle' + /// + /// The URL. + /// The area. + /// The controller. + /// The action. public void AddDefaultRule(string url, string area, string controller, string action) { if (area == null) @@ -46,6 +57,10 @@ public void AddDefaultRule(string url, string area, string controller, string ac #region IServiceEnabledComponent + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { MonoRailConfiguration config = (MonoRailConfiguration) provider.GetService(typeof(MonoRailConfiguration)); @@ -60,6 +75,14 @@ public void Service(IServiceProvider provider) #region IUrlTokenizer + /// + /// Tokenizes the URL. + /// + /// The raw URL. + /// The URI. + /// if set to true [is local]. + /// Virtual directory + /// public UrlInfo TokenizeUrl(string rawUrl, Uri uri, bool isLocal, string appVirtualDir) { if (rawUrl == null || rawUrl.Length == 0) @@ -118,6 +141,13 @@ public UrlInfo TokenizeUrl(string rawUrl, Uri uri, bool isLocal, string appVirtu #endregion + /// + /// Extracts the area controller action. + /// + /// The raw URL. + /// The area. + /// The controller. + /// The action. private void ExtractAreaControllerAction(string rawUrl, out string area, out string controller, out string action) { string[] parts = rawUrl.Split('/'); diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentFactory.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentFactory.cs index 71f907291..581009883 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentFactory.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentFactory.cs @@ -76,11 +76,20 @@ public override void Initialize() #endregion + /// + /// Gets the view component registry. + /// + /// protected override IViewComponentRegistry GetViewComponentRegistry() { return registry; } + /// + /// Invoked by the framework in order to give a chance to + /// obtain other services + /// + /// The service proviver public override void Service(IServiceProvider provider) { base.Service(provider); @@ -144,6 +153,11 @@ public void Inspect(Assembly assembly) } } + /// + /// Implementors should return a reference to + /// the current view engine. + /// + /// public override IViewEngine ViewEngine { get { return viewEngine; } diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentRegistry.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentRegistry.cs index 4a91cf2ef..383cc51d6 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentRegistry.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewComponentRegistry.cs @@ -17,12 +17,20 @@ namespace Castle.MonoRail.Framework.Services using System; using System.Collections; + /// + /// Centralizes the registration and lookup of ViewComponents + /// public class DefaultViewComponentRegistry : IViewComponentRegistry { - private readonly Hashtable name2Type = new Hashtable(); + private readonly Hashtable name2Type = new Hashtable(StringComparer.InvariantCultureIgnoreCase); #region IViewComponentRegistry + /// + /// Adds the view component. + /// + /// The name that can be used from the view template. + /// The type. public void AddViewComponent(string name, Type type) { ViewComponentDetailsAttribute details = GetDetails(type); @@ -49,6 +57,11 @@ public void AddViewComponent(string name, Type type) name2Type[name] = type; } + /// + /// Gets the view component. + /// + /// The name. + /// public Type GetViewComponent(string name) { name = NormalizeName(name); @@ -66,15 +79,25 @@ public Type GetViewComponent(string name) #endregion + /// + /// Normalizes the name. + /// + /// The name. + /// private string NormalizeName(string name) { - if (!name.EndsWith("Component")) + if (!name.EndsWith("Component",StringComparison.InvariantCultureIgnoreCase)) { return name + "Component"; } return name; } + /// + /// Gets the details. + /// + /// The type. + /// private static ViewComponentDetailsAttribute GetDetails(Type type) { // TODO: Add cache here, GetCustomAttributes is a lengthy call. diff --git a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewEngineManager.cs b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewEngineManager.cs index 18446eb57..0396f2a63 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewEngineManager.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/DefaultViewEngineManager.cs @@ -23,7 +23,9 @@ namespace Castle.MonoRail.Framework.Services using Castle.MonoRail.Framework.Internal; /// - /// Pendent + /// The view engine manager sits between MonoRail and all the registered + /// view engines. It is used to identify the view engine that should handle a + /// render request and delegates such requests properly. /// public class DefaultViewEngineManager : IViewEngineManager, IServiceEnabledComponent, IInitializable { @@ -44,6 +46,9 @@ public DefaultViewEngineManager() #region IInitializable + /// + /// Implementors should perform any initialization logic. + /// public void Initialize() { foreach(ViewEngineInfo info in config.ViewEngineConfig.ViewEngines) @@ -87,6 +92,10 @@ public void Initialize() #region IServiceEnabledComponent + /// + /// Services the specified service provider. + /// + /// The service provider. public void Service(IServiceProvider serviceProvider) { provider = serviceProvider; @@ -109,6 +118,14 @@ public bool HasTemplate(string templateName) return FindExistingTemplate(templateName) != null; } + /// + /// Processes the view - using the templateName + /// to obtain the correct template, + /// and using the context to output the result. + /// + /// + /// + /// public void Process(IRailsEngineContext context, Controller controller, string templateName) { String resolvedTemplateName = FindExistingTemplate(templateName); @@ -129,6 +146,18 @@ public void Process(IRailsEngineContext context, Controller controller, string t } } + /// + /// Processes the view - using the templateName + /// to obtain the correct template + /// and writes the results to the System.TextWriter. + /// + /// Please note that no layout is applied + /// + /// + /// + /// + /// + /// public void Process(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { String resolvedTemplateName = FindExistingTemplate(templateName); @@ -149,6 +178,15 @@ public void Process(TextWriter output, IRailsEngineContext context, Controller c } } + /// + /// Processes a partial view = using the partialName + /// to obtain the correct template and writes the + /// results to the System.TextWriter. + /// + /// The output. + /// The context. + /// The controller. + /// The partial name. public void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, string partialName) { String resolvedTemplateName = FindExistingTemplate(partialName); @@ -183,6 +221,11 @@ public void ProcessContents(IRailsEngineContext context, Controller controller, #endregion + /// + /// Finds the existing template. + /// + /// Name of the template. + /// private String FindExistingTemplate(string templateName) { if (Path.HasExtension(templateName)) @@ -205,6 +248,10 @@ private String FindExistingTemplate(string templateName) } } + /// + /// Contextualizes the view engine. + /// + /// The engine. private void ContextualizeViewEngine(IViewEngine engine) { MonoRailHttpHandler.CurrentContext.AddService(typeof(IViewEngine), engine); @@ -282,6 +329,11 @@ private void RegisterEngineForView(IViewEngine engine) } } + /// + /// Asserts the template exists. + /// + /// Name of the resolved template. + /// Name of the template. private void AssertTemplateExists(string resolvedTemplateName, string templateName) { if (resolvedTemplateName == null) diff --git a/MonoRail/Castle.MonoRail.Framework/Services/MonoRailSmtpSender.cs b/MonoRail/Castle.MonoRail.Framework/Services/MonoRailSmtpSender.cs index bf171b6cf..489f6ca6a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/MonoRailSmtpSender.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/MonoRailSmtpSender.cs @@ -27,12 +27,19 @@ public class MonoRailSmtpSender : IEmailSender, IServiceEnabledComponent { private SmtpSender sender; + /// + /// Initializes a new instance of the class. + /// public MonoRailSmtpSender() { } #region IServiceEnabledComponent implementation + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { MonoRailConfiguration config = (MonoRailConfiguration) provider.GetService(typeof(MonoRailConfiguration)); @@ -52,16 +59,31 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Sends a message. + /// + /// From field + /// To field + /// e-mail's subject + /// message's body public void Send(string from, string to, string subject, string messageText) { sender.Send(from, to, subject, messageText); } + /// + /// Sends a message. + /// + /// Message instance public void Send(Message message) { sender.Send(message); } + /// + /// Sends multiple messages. + /// + /// Array of messages public void Send(Message[] messages) { sender.Send(messages); diff --git a/MonoRail/Castle.MonoRail.Framework/Services/Utils/ControllerInspectionUtil.cs b/MonoRail/Castle.MonoRail.Framework/Services/Utils/ControllerInspectionUtil.cs index 753f50917..d226f7ebd 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/Utils/ControllerInspectionUtil.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/Utils/ControllerInspectionUtil.cs @@ -22,7 +22,7 @@ namespace Castle.MonoRail.Framework.Services.Utils /// Utilities methods to inspect the controller Type /// and gathers its name and area. /// - public abstract class ControllerInspectionUtil + public static class ControllerInspectionUtil { /// /// Creates a based on the conventions @@ -54,6 +54,12 @@ public static ControllerDescriptor Inspect(Type controllerType) return descriptor; } + /// + /// Obtains the name of the controller. + /// + /// The name. + /// The controller. + /// private static String ObtainControllerName(String name, Type controller) { if (name == null || name.Length == 0) @@ -63,6 +69,11 @@ private static String ObtainControllerName(String name, Type controller) return name; } + /// + /// Strips the specified name. + /// + /// The name. + /// private static String Strip(String name) { if (name.EndsWith("Controller")) diff --git a/MonoRail/Castle.MonoRail.Framework/Services/WeakReferenceCacheProvider.cs b/MonoRail/Castle.MonoRail.Framework/Services/WeakReferenceCacheProvider.cs index 480d682f0..c19c285d6 100644 --- a/MonoRail/Castle.MonoRail.Framework/Services/WeakReferenceCacheProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Services/WeakReferenceCacheProvider.cs @@ -51,11 +51,23 @@ public void Service(IServiceProvider provider) #endregion + /// + /// Determines whether the specified key is on the cache. + /// + /// The key. + /// + /// true if the cache has the key; otherwise, false. + /// public bool HasKey(String key) { return Get(key) != null; } + /// + /// Gets the cache item by the specified key. + /// + /// The key. + /// public object Get(String key) { if (logger.IsDebugEnabled) @@ -77,6 +89,11 @@ public object Get(String key) return null; } + /// + /// Stores the cache item by the specified key. + /// + /// The key. + /// The data. public void Store(String key, object data) { if (logger.IsDebugEnabled) @@ -87,6 +104,10 @@ public void Store(String key, object data) entries[key] = new WeakReference(data); } + /// + /// Deletes the cache item by the specified key. + /// + /// The key. public void Delete(String key) { if (logger.IsDebugEnabled) diff --git a/MonoRail/Castle.MonoRail.Framework/SmartDispatcherController.cs b/MonoRail/Castle.MonoRail.Framework/SmartDispatcherController.cs index 4ae476794..8342022aa 100644 --- a/MonoRail/Castle.MonoRail.Framework/SmartDispatcherController.cs +++ b/MonoRail/Castle.MonoRail.Framework/SmartDispatcherController.cs @@ -39,6 +39,10 @@ public abstract class SmartDispatcherController : Controller private TreeBuilder treeBuilder = new TreeBuilder(); private CompositeNode paramsNode, formNode, queryStringNode; private IDictionary validationSummaryPerInstance = new Dictionary(); + + /// + /// Represents the errors associated with an instance bound. + /// protected IDictionary boundInstances = new Dictionary(); /// @@ -57,11 +61,19 @@ protected SmartDispatcherController(IDataBinder binder) this.binder = binder; } + /// + /// Gets the binder. + /// + /// The binder. public IDataBinder Binder { get { return binder; } } + /// + /// Gets or sets the bound instance errors. + /// + /// The bound instance errors. public IDictionary BoundInstanceErrors { get { return boundInstances; } @@ -77,6 +89,11 @@ public IDictionary ValidationSummaryPerInstance get { return validationSummaryPerInstance; } } + /// + /// Populates the validator error summary. + /// + /// The instance. + /// The binder used for binding. protected internal void PopulateValidatorErrorSummary(object instance, IDataBinder binderUsedForBinding) { ValidationSummaryPerInstance[instance] = binderUsedForBinding.GetValidationSummary(instance); @@ -124,6 +141,12 @@ protected ErrorList GetDataBindErrors(object instance) return boundInstances[instance]; } + /// + /// Constructs the parameters for the action and invokes it. + /// + /// The method. + /// The request. + /// The action args. protected internal override void InvokeMethod(MethodInfo method, IRequest request, IDictionary actionArgs) { ParameterInfo[] parameters = method.GetParameters(); @@ -133,6 +156,15 @@ protected internal override void InvokeMethod(MethodInfo method, IRequest reques method.Invoke(this, methodArgs); } + /// + /// Uses a simple heuristic to select the best method -- especially in the + /// case of method overloads. + /// + /// The action name + /// The avaliable actions + /// The request instance + /// The custom arguments for the action + /// protected internal override MethodInfo SelectMethod(String action, IDictionary actions, IRequest request, IDictionary actionArgs) { @@ -149,6 +181,14 @@ protected internal override MethodInfo SelectMethod(String action, IDictionary a request.Params, actionArgs); } + /// + /// Selects the best method given the set of entries + /// avaliable on and + /// + /// The candidates. + /// The web params. + /// The custom action args. + /// protected virtual MethodInfo SelectBestCandidate(MethodInfo[] candidates, NameValueCollection webParams, IDictionary actionArgs) @@ -176,6 +216,11 @@ protected virtual MethodInfo SelectBestCandidate(MethodInfo[] candidates, return bestCandidate; } + /// + /// Gets the name of the request parameter. + /// + /// The param. + /// protected virtual String GetRequestParameterName(ParameterInfo param) { return param.Name; @@ -357,16 +402,40 @@ protected virtual object[] BuildMethodArguments(ParameterInfo[] parameters, IReq return args; } + /// + /// Binds the object of the specified type using the given prefix. + /// + /// Type of the target. + /// The prefix. + /// protected object BindObject(Type targetType, String prefix) { return BindObject(ParamStore.Params, targetType, prefix); } - + + /// + /// Binds the object of the specified type using the given prefix. + /// but only using the entries from the collection specified on the + /// + /// Restricts the data source of entries. + /// Type of the target. + /// The prefix. + /// protected object BindObject(ParamStore from, Type targetType, String prefix) { return BindObject(from, targetType, prefix, null, null); } + /// + /// Binds the object of the specified type using the given prefix. + /// but only using the entries from the collection specified on the + /// + /// From. + /// Type of the target. + /// The prefix. + /// The excluded properties, comma separated list. + /// The allowed properties, comma separated list. + /// protected object BindObject(ParamStore from, Type targetType, String prefix, String excludedProperties, String allowedProperties) { CompositeNode node = ObtainParamsNode(from); @@ -378,12 +447,24 @@ protected object BindObject(ParamStore from, Type targetType, String prefix, Str return instance; } - + + /// + /// Binds the object instance using the specified prefix. + /// + /// The instance. + /// The prefix. protected void BindObjectInstance(object instance, String prefix) { BindObjectInstance(instance, ParamStore.Params, prefix); } + /// + /// Binds the object instance using the given prefix. + /// but only using the entries from the collection specified on the + /// + /// The instance. + /// From. + /// The prefix. protected void BindObjectInstance(object instance, ParamStore from, String prefix) { CompositeNode node = ObtainParamsNode(from); @@ -394,16 +475,40 @@ protected void BindObjectInstance(object instance, ParamStore from, String prefi PopulateValidatorErrorSummary(instance, binder); } + /// + /// Binds the object of the specified type using the given prefix. + /// + /// Target type + /// The prefix. + /// protected T BindObject(String prefix) { return (T) BindObject(typeof(T), prefix); } - + + /// + /// Binds the object of the specified type using the given prefix. + /// but only using the entries from the collection specified on the + /// + /// Target type + /// From. + /// The prefix. + /// protected T BindObject(ParamStore from, String prefix) { return (T) BindObject(from, typeof(T), prefix); } - + + /// + /// Binds the object of the specified type using the given prefix. + /// but only using the entries from the collection specified on the + /// + /// + /// From. + /// The prefix. + /// The excluded properties. + /// The allowed properties. + /// protected T BindObject(ParamStore from, String prefix, String excludedProperties, String allowedProperties) { return (T) BindObject(from, typeof(T), prefix, excludedProperties, allowedProperties); diff --git a/MonoRail/Castle.MonoRail.Framework/Test/IMockResponse.cs b/MonoRail/Castle.MonoRail.Framework/Test/IMockResponse.cs index 493f4fa02..9cdcc4cfa 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/IMockResponse.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/IMockResponse.cs @@ -15,11 +15,24 @@ namespace Castle.MonoRail.Framework.Test { using System.Collections.Specialized; + using Framework; + /// + /// Exposes methods on top of + /// that are used by unit tests + /// public interface IMockResponse : IResponse { + /// + /// Gets the urls the request was redirected to. + /// + /// The redirected to. string RedirectedTo { get; } + /// + /// Gets the http headers. + /// + /// The headers. NameValueCollection Headers { get; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/IMockViewComponentContext.cs b/MonoRail/Castle.MonoRail.Framework/Test/IMockViewComponentContext.cs index 2c3f3a2bd..fd2a9319b 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/IMockViewComponentContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/IMockViewComponentContext.cs @@ -16,8 +16,16 @@ namespace Castle.MonoRail.Framework.Test { using System.Collections.Generic; + /// + /// Exposes methods on top of + /// that are used by unit tests + /// public interface IMockViewComponentContext : IViewComponentContext { + /// + /// Gets or sets the section render dictionary. + /// + /// The section render. IDictionary SectionRender { get; set; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockCacheProvider.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockCacheProvider.cs index 1ab42cf58..40c90843e 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockCacheProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockCacheProvider.cs @@ -18,29 +18,57 @@ namespace Castle.MonoRail.Framework.Test using System.Collections; using System.Collections.Specialized; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockCacheProvider : ICacheProvider { private IDictionary dictionary = new HybridDictionary(true); + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { } + /// + /// Determines whether the specified key is on the cache. + /// + /// The key. + /// + /// true if the cache has the key; otherwise, false. + /// public bool HasKey(string key) { return dictionary.Contains(key); } + /// + /// Gets the cache item by the specified key. + /// + /// The key. + /// public object Get(string key) { return dictionary[key]; } + /// + /// Stores the cache item by the specified key. + /// + /// The key. + /// The data. public void Store(string key, object data) { dictionary[key] = data; } + /// + /// Deletes the cache item by the specified key. + /// + /// The key. public void Delete(string key) { dictionary.Remove(key); diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockEmailTemplateService.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockEmailTemplateService.cs index d7d4c800d..676de6753 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockEmailTemplateService.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockEmailTemplateService.cs @@ -26,11 +26,25 @@ public class MockEmailTemplateService : IEmailTemplateService { private readonly MockRailsEngineContext context; + /// + /// Initializes a new instance of the class. + /// + /// The context. public MockEmailTemplateService(MockRailsEngineContext context) { this.context = context; } + /// + /// Creates an instance of + /// using the specified template for the body + /// + /// Name of the template to load. + /// Will look in Views/mail for that template file. + /// Dictionary with parameters + /// that you can use on the email template + /// If true, it will skip the layout + /// An instance of public Message RenderMailMessage(string templateName, IDictionary parameters, bool doNotApplyLayout) { context.AddMailTemplateRendered(templateName, parameters); @@ -38,6 +52,14 @@ public Message RenderMailMessage(string templateName, IDictionary parameters, bo return new Message("from", "to", "subject", "body"); } + /// + /// Renders the mail message. + /// + /// Name of the template. + /// The engine context. + /// The controller. + /// if set to true [do not apply layout]. + /// public Message RenderMailMessage(string templateName, IRailsEngineContext engineContext, Controller controller, bool doNotApplyLayout) { diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockRailsEngineContext.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockRailsEngineContext.cs index e391c0158..15bbc5142 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockRailsEngineContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockRailsEngineContext.cs @@ -25,6 +25,9 @@ namespace Castle.MonoRail.Framework.Test using Castle.MonoRail.Framework.Internal; using Castle.MonoRail.Framework.Services; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockRailsEngineContext : AbstractServiceContainer, IRailsEngineContext { private readonly string physicalPath = AppDomain.CurrentDomain.BaseDirectory; @@ -45,11 +48,21 @@ public class MockRailsEngineContext : AbstractServiceContainer, IRailsEngineCont private Exception lastException; private Controller currentController; + /// + /// Initializes a new instance of the class. + /// protected MockRailsEngineContext() { RegisterServices(); } + /// + /// Initializes a new instance of the class. + /// + /// The request. + /// The response. + /// The trace. + /// The URL info. public MockRailsEngineContext(IRequest request, IResponse response, ITrace trace, UrlInfo urlInfo) : this() { this.request = request; @@ -69,17 +82,29 @@ public virtual String RequestType get { return request.HttpMethod; } } + /// + /// Gets the request URL. + /// + /// public virtual string Url { - get { throw new NotImplementedException(); } + get { return urlInfo.UrlRaw; } } + /// + /// Gets the referring URL. + /// + /// public string UrlReferrer { get { return urlReferrer; } set { urlReferrer = value; } } + /// + /// Gets the underlying context of the API being used. + /// + /// public virtual HttpContext UnderlyingContext { get @@ -90,52 +115,95 @@ public virtual HttpContext UnderlyingContext } } + /// + /// Access the params (Query, Post, headers and Cookies) + /// + /// public virtual NameValueCollection Params { get { return request.Params; } } + /// + /// Access the session objects. + /// + /// public virtual IDictionary Session { get { return session; } } + /// + /// Gets the request object. + /// + /// public virtual IRequest Request { get { return request; } } + /// + /// Gets the response object. + /// + /// public virtual IResponse Response { get { return response; } } + /// + /// Gets the trace object. + /// + /// public virtual ITrace Trace { get { return trace; } } + /// + /// Access the Cache associated with this + /// web execution context. + /// + /// public virtual ICacheProvider Cache { get { return cacheProvider; } } + /// + /// Access a dictionary of volative items. + /// + /// public virtual Flash Flash { get { return flash; } } + /// + /// Transfer the execution to another resource. + /// + /// + /// public virtual void Transfer(string path, bool preserveForm) { throw new NotImplementedException(); } + /// + /// Gets or sets the current user. + /// + /// public IPrincipal CurrentUser { get { return currentUser; } set { currentUser = value; } } + /// + /// Gets the last exception raised during + /// the execution of an action. + /// + /// public Exception LastException { get { return lastException; } @@ -143,40 +211,65 @@ public Exception LastException } /// - /// I'm not sure about this one - /// TODO: Review it + /// Returns the application path. /// + /// public virtual string ApplicationPath { get { return urlInfo.AppVirtualDir; } } + /// + /// Returns the physical application path. + /// + /// public virtual string ApplicationPhysicalPath { get { return physicalPath; } } + /// + /// Returns the of the the current request. + /// + /// public virtual UrlInfo UrlInfo { get { return urlInfo; } } + /// + /// Returns an . + /// + /// public virtual IServerUtility Server { get { return serverUtility; } } + /// + /// Returns the Items collection from the current HttpContext. + /// + /// public virtual IDictionary Items { get { return contextItems; } } + /// + /// Gets or sets the current controller. + /// + /// The current controller. public virtual Controller CurrentController { get { return currentController; } set { currentController = value; } } + /// + /// If a container is available for the app, this + /// property exposes its instance. + /// + /// public IServiceProvider Container { get { return container; } @@ -184,21 +277,36 @@ public IServiceProvider Container #endregion + /// + /// Sets the container. + /// + /// The service provider. public void SetContainer(IServiceProvider serviceProvider) { container = serviceProvider; } + /// + /// Gets the rendered email templates. + /// + /// The rendered email templates. public virtual List RenderedEmailTemplates { get { return renderedEmailTemplates; } } + /// + /// Gets the messages sent. + /// + /// The messages sent. public virtual List MessagesSent { get { return messagesSent; } } + /// + /// Registers the services. + /// private void RegisterServices() { DefaultUrlBuilder urlBuilder = new DefaultUrlBuilder(); @@ -235,22 +343,38 @@ internal void AddEmailMessageSent(Message message) messagesSent.Add(message); } + /// + /// Represents an email template for unit test purposes + /// public class RenderedEmailTemplate { private readonly string name; private readonly IDictionary parameters; + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The parameters. public RenderedEmailTemplate(string name, IDictionary parameters) { this.name = name; this.parameters = parameters; } + /// + /// Gets the name. + /// + /// The name. public string Name { get { return name; } } + /// + /// Gets the parameters. + /// + /// The parameters. public IDictionary Parameters { get { return parameters; } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockRequest.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockRequest.cs index 749bca0c7..8fff7bee3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockRequest.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockRequest.cs @@ -17,7 +17,11 @@ namespace Castle.MonoRail.Framework.Test using System; using System.Collections; using System.Collections.Specialized; + using System.Web; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockRequest : IRequest { private NameValueCollection form = new NameValueCollection(); @@ -36,86 +40,155 @@ public class MockRequest : IRequest private string[] userLanguages = new string[] { "en-ES", "pt-BR" }; private string userHostAddress = "127.0.0.1"; + /// + /// Initializes a new instance of the class. + /// + /// The cookies. public MockRequest(IDictionary cookies) { this.cookies = cookies; } + /// + /// Reads the request data as a byte array. + /// + /// How many bytes. + /// public virtual byte[] BinaryRead(int count) { throw new NotImplementedException(); } - + + /// + /// Reads the cookie. + /// + /// The cookie name. + /// public virtual string ReadCookie(string name) { return (string) cookies[name]; } + /// + /// Validates the input. + /// public virtual void ValidateInput() { throw new NotImplementedException(); } + /// + /// Gets the Http headers. + /// + /// The Http headers. public virtual NameValueCollection Headers { get { return headers; } } + /// + /// Gets the per key. + /// + /// public virtual IDictionary Files { get { return files; } } + /// + /// Gets the params which accumulates headers, post, querystring and cookies. + /// + /// The params. public virtual NameValueCollection Params { get { return @params; } } + /// + /// Gets a value indicating whether this requeest is from a local address. + /// + /// true if this instance is local; otherwise, false. public virtual bool IsLocal { get { return isLocal; } } + /// + /// Gets the raw URL. + /// + /// The raw URL. public virtual string RawUrl { get { return rawUrl; } } + /// + /// Gets the URI. + /// + /// The URI. public virtual Uri Uri { get { return uri; } } + /// + /// Gets the HTTP method. + /// + /// The HTTP method. public virtual string HttpMethod { get { return httpMethod; } } + /// + /// Gets the file path. + /// + /// The file path. public virtual string FilePath { get { return filePath; } } + /// + /// Gets the param with the specified key. + /// + /// public virtual string this[string key] { get { throw new NotImplementedException(); } } + /// + /// Gets the query string. + /// + /// The query string. public virtual NameValueCollection QueryString { get { return queryString; } } + /// + /// Gets the form. + /// + /// The form. public virtual NameValueCollection Form { get { return form; } } + /// + /// Gets the user languages. + /// + /// The user languages. public virtual string[] UserLanguages { get { return userLanguages; } } + /// + /// Gets the IP host address of the remote client. + /// + /// The IP address of the remote client. public virtual string UserHostAddress { get { return userHostAddress; } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockResponse.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockResponse.cs index 47ab395c8..4332dc725 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockResponse.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockResponse.cs @@ -18,9 +18,11 @@ namespace Castle.MonoRail.Framework.Test using System.Collections; using System.Collections.Specialized; using System.IO; - using System.Net; using System.Web; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockResponse : IMockResponse { private readonly IDictionary cookies; @@ -37,17 +39,29 @@ public class MockResponse : IMockResponse private HttpCachePolicy cachePolicy = null; private NameValueCollection headers = new NameValueCollection(); + /// + /// Initializes a new instance of the class. + /// + /// The cookies. public MockResponse(IDictionary cookies) { this.cookies = cookies; - outputStreamWriter = new StreamWriter (outputStream); + outputStreamWriter = new StreamWriter(outputStream); } + /// + /// Gets the urls the request was redirected to. + /// + /// The redirected to. public virtual string RedirectedTo { get { return redirectedTo; } } + /// + /// Gets the http headers. + /// + /// The headers. public virtual NameValueCollection Headers { get { return headers; } @@ -55,145 +69,264 @@ public virtual NameValueCollection Headers #region IResponse Related + /// + /// Appends the header. + /// + /// The name. + /// The value. public void AppendHeader(string name, string value) { headers[name] = value; } + /// + /// Writes the buffer to the browser + /// + /// The buffer. public virtual void BinaryWrite(byte[] buffer) { - outputStream.Write (buffer, 0, buffer.Length); + outputStream.Write(buffer, 0, buffer.Length); } + /// + /// Writes the stream to the browser + /// + /// The stream. public virtual void BinaryWrite(Stream stream) { byte[] buffer = new byte[stream.Length]; - stream.Read (buffer, 0, buffer.Length); + stream.Read(buffer, 0, buffer.Length); - BinaryWrite (buffer); + BinaryWrite(buffer); } + /// + /// Clears the response (only works if buffered) + /// public virtual void Clear() { - outputStream.SetLength (0); + outputStream.SetLength(0); } + /// + /// Clears the response content (only works if buffered). + /// public virtual void ClearContent() { - outputStreamWriter.Flush (); + outputStreamWriter.Flush(); } + /// + /// Writes the specified string. + /// + /// The string. public virtual void Write(string s) { - outputStreamWriter.Write (s); + outputStreamWriter.Write(s); } + /// + /// Writes the specified obj. + /// + /// The obj. public virtual void Write(object obj) { - outputStreamWriter.Write (obj); - } + outputStreamWriter.Write(obj); + } + /// + /// Writes the specified char. + /// + /// The char. public virtual void Write(char ch) { - outputStreamWriter.Write (ch); + outputStreamWriter.Write(ch); } + /// + /// Writes the specified buffer. + /// + /// The buffer. + /// The index. + /// The count. public virtual void Write(char[] buffer, int index, int count) { - outputStreamWriter.Write (buffer, index, count); + outputStreamWriter.Write(buffer, index, count); } + /// + /// Writes the file. + /// + /// Name of the file. public virtual void WriteFile(string fileName) { throw new NotImplementedException(); } + /// + /// Redirects the specified controller. + /// + /// The controller. + /// The action. public virtual void Redirect(string controller, string action) { Redirect(BuildMockUrl(null, controller, action)); } + /// + /// Redirects the specified area. + /// + /// The area. + /// The controller. + /// The action. public virtual void Redirect(string area, string controller, string action) { Redirect(BuildMockUrl(area, controller, action)); } + /// + /// Redirects the specified URL. + /// + /// The URL. public virtual void Redirect(string url) { wasRedirected = true; redirectedTo = url; } + /// + /// Redirects the specified URL. + /// + /// The URL. + /// if set to true [end process]. public virtual void Redirect(string url, bool endProcess) { Redirect(url); } + /// + /// Creates a cookie. + /// + /// The name. + /// The value. public virtual void CreateCookie(string name, string value) { - cookies.Add(name,value); + cookies.Add(name, value); } + /// + /// Creates a cookie. + /// + /// The name. + /// The value. + /// The expiration. public virtual void CreateCookie(string name, string value, DateTime expiration) { - CreateCookie(name,value); + CreateCookie(name, value); } + /// + /// Creates a cookie. + /// + /// The cookie. public virtual void CreateCookie(HttpCookie cookie) { throw new NotSupportedException(); - } + } + /// + /// Removes a cookie. + /// + /// The name. public virtual void RemoveCookie(string name) { cookies.Remove(name); } + /// + /// Gets or sets the status code. + /// + /// The status code. public int StatusCode { get { return statusCode; } set { statusCode = value; } } + /// + /// Gets or sets the type of the content. + /// + /// The type of the content. public string ContentType { get { return contentType; } set { contentType = value; } } + /// + /// Gets the caching policy (expiration time, privacy, + /// vary clauses) of a Web page. + /// + /// public HttpCachePolicy CachePolicy { get { return cachePolicy; } } + /// + /// Sets the Cache-Control HTTP header to Public or Private. + /// + /// public string CacheControlHeader { get { return cacheControlHeader; } set { cacheControlHeader = value; } } + /// + /// Gets or sets the HTTP character set of the output stream. + /// + /// public string Charset { get { return charset; } set { charset = value; } } + /// + /// Gets the output. + /// + /// The output. public virtual TextWriter Output { get { return output; } } + /// + /// Gets the output stream. + /// + /// The output stream. public virtual Stream OutputStream { get { return outputStream; } } + /// + /// Gets a value indicating whether the response sent a redirect. + /// + /// true if was redirected; otherwise, false. public virtual bool WasRedirected { get { return wasRedirected; } } + /// + /// Gets a value indicating whether this instance is client connected. + /// + /// + /// true if this instance is client connected; otherwise, false. + /// public virtual bool IsClientConnected { get { return isClientConnected; } @@ -201,7 +334,7 @@ public virtual bool IsClientConnected #endregion - private string BuildMockUrl(string area, string controller, string action) + private static string BuildMockUrl(string area, string controller, string action) { string mockUrl = "/"; @@ -215,4 +348,4 @@ private string BuildMockUrl(string area, string controller, string action) return mockUrl; } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockScaffoldingSupport.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockScaffoldingSupport.cs index 683dd0a48..4f646e8d2 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockScaffoldingSupport.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockScaffoldingSupport.cs @@ -14,8 +14,18 @@ namespace Castle.MonoRail.Framework.Test { + using Framework; + + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockScaffoldingSupport : IScaffoldingSupport { + /// + /// Implementors should use this method to read information + /// from the controller instance and add dynamic actions to the controller. + /// + /// public void Process(Controller controller) { // Don't need to do anything diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockServerUtility.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockServerUtility.cs index 4aa6f7542..f5b445250 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockServerUtility.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockServerUtility.cs @@ -17,36 +17,75 @@ namespace Castle.MonoRail.Framework.Test using System; using System.IO; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockServerUtility : IServerUtility { + /// + /// Returns the physical path for the + /// specified virtual path. + /// + /// The virtual path. + /// The mapped path public virtual string MapPath(string virtualPath) { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, virtualPath); } + /// + /// HTML encodes a string and returns the encoded string. + /// + /// The text string to HTML encode. + /// The HTML encoded text. public virtual string HtmlEncode(string content) { return content; } + /// + /// URL encodes a string and returns the encoded string. + /// + /// The text to URL encode. + /// The URL encoded text. public virtual string UrlEncode(string content) { return content.Replace("&", "&"); } + /// + /// URL decodes a string and returns the decoded string. + /// + /// The text to URL decode. + /// The URL decoded text. public virtual string UrlDecode(string content) { return content.Replace("&", "&"); } + /// + /// URL encodes the path portion of a URL string and returns the encoded string. + /// + /// The text to URL encode. + /// The URL encoded text. public virtual string UrlPathEncode(string content) { - throw new NotImplementedException(); + return content; } + /// + /// Escapes JavaScript with Url encoding and returns the encoded string. + /// + /// The text to URL encode and escape JavaScript within. + /// + /// The URL encoded and JavaScript escaped text. + /// + /// + /// Converts quotes, single quotes and CR/LFs to their representation as an escape character. + /// public virtual string JavaScriptEscape(string content) { - throw new NotImplementedException(); + return content; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockSmtpSender.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockSmtpSender.cs index 6df4585ea..009dbaf22 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockSmtpSender.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockSmtpSender.cs @@ -1,26 +1,62 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + namespace Castle.MonoRail.Framework.Test { using Castle.Components.Common.EmailSender; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockSmtpSender : IEmailSender { private readonly MockRailsEngineContext context; + /// + /// Initializes a new instance of the class. + /// + /// The context. public MockSmtpSender(MockRailsEngineContext context) { this.context = context; } + /// + /// Sends a message. + /// + /// From field + /// To field + /// e-mail's subject + /// message's body public void Send(string from, string to, string subject, string messageText) { Send(new Message(from, to, subject, messageText)); } + /// + /// Sends a message. + /// + /// Message instance public void Send(Message message) { context.AddEmailMessageSent(message); } + /// + /// Sends multiple messages. + /// + /// Array of messages public void Send(Message[] messages) { foreach(Message message in messages) diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockTrace.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockTrace.cs index 3a3b92900..1bc9db1f1 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockTrace.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockTrace.cs @@ -16,36 +16,63 @@ namespace Castle.MonoRail.Framework.Test { using System; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockTrace : ITrace { + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. public virtual void Warn(string message) { - throw new NotImplementedException(); } + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. public virtual void Warn(string category, string message) { - throw new NotImplementedException(); } + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. public virtual void Warn(string category, string message, Exception errorInfo) { - throw new NotImplementedException(); } + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The message. public virtual void Write(string message) { - throw new NotImplementedException(); } + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. public virtual void Write(string category, string message) { - throw new NotImplementedException(); } + /// + /// Logs the specified message on the ASP.Net trace + /// + /// The category. + /// The message. + /// The error info. public virtual void Write(string category, string message, Exception errorInfo) { - throw new NotImplementedException(); } } } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockViewComponentContext.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockViewComponentContext.cs index 04c93fdf6..32a475688 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockViewComponentContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockViewComponentContext.cs @@ -20,9 +20,24 @@ namespace Castle.MonoRail.Framework.Test using System.Collections.Generic; using System.IO; + /// + /// Used to hook a viewcomponent call to render a nested section + /// + /// The content available to the section + /// The writer public delegate void TestSectionRender(IDictionary context, TextWriter writer); + + /// + /// Used to hook a viewcomponent call to render a view template + /// + /// view name + /// The content available to the view + /// The writer public delegate void TestViewRender(string name, IDictionary context, TextWriter writer); + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockViewComponentContext : IMockViewComponentContext { private string viewToRender; @@ -33,14 +48,30 @@ public class MockViewComponentContext : IMockViewComponentContext private IViewEngine viewEngine; private IDictionary section2delegate; + /// + /// Event that is raised when a section is rendered by the viewcomponent. + /// public TestSectionRender OnBodyRender; + + /// + /// Event that is raised when a view is rendered by the viewcomponent. + /// public TestViewRender OnViewRender; + /// + /// Initializes a new instance of the class. + /// protected MockViewComponentContext() { section2delegate = new Dictionary(StringComparer.InvariantCultureIgnoreCase); } + /// + /// Initializes a new instance of the class. + /// + /// Name of the component. + /// The writer. + /// The view engine. public MockViewComponentContext(string componentName, TextWriter writer, IViewEngine viewEngine) : this() { this.writer = writer; @@ -48,6 +79,10 @@ public MockViewComponentContext(string componentName, TextWriter writer, IViewEn this.viewEngine = viewEngine; } + /// + /// Gets or sets the section render dictionary. + /// + /// The section render. public IDictionary SectionRender { get { return section2delegate; } @@ -56,16 +91,33 @@ public IDictionary SectionRender #region IViewComponentContext + /// + /// Gets the name of the component. + /// + /// The name of the component. public virtual string ComponentName { get { return componentName; } } + /// + /// Determines whether the current component declaration on the view + /// has the specified section. + /// + /// Name of the section. + /// + /// true if the specified section exists; otherwise, false. + /// public bool HasSection(string sectionName) { return section2delegate.ContainsKey(sectionName); } + /// + /// Renders the view specified to the writer. + /// + /// The view template name + /// A writer to output public void RenderView(string name, TextWriter writer) { if (OnViewRender != null) @@ -74,11 +126,18 @@ public void RenderView(string name, TextWriter writer) } } + /// + /// Renders the component body. + /// public void RenderBody() { RenderBody(writer); } + /// + /// Renders the body into the specified + /// + /// The writer. public void RenderBody(TextWriter writer) { if (OnBodyRender != null) @@ -87,11 +146,22 @@ public void RenderBody(TextWriter writer) } } + /// + /// Renders the the specified section. + /// No exception will the throw if the section cannot be found. + /// + /// Name of the section. public void RenderSection(string sectionName) { RenderSection(sectionName, writer); } + /// + /// Renders the the specified section. + /// No exception will the throw if the section cannot be found. + /// + /// Name of the section. + /// The writer to output the section content. public void RenderSection(string sectionName, TextWriter writer) { if (section2delegate.ContainsKey(sectionName)) @@ -100,27 +170,49 @@ public void RenderSection(string sectionName, TextWriter writer) } } + /// + /// Gets the writer used to render the view component + /// + /// The writer. public virtual TextWriter Writer { get { return writer; } } + /// + /// Gets the dictionary that holds variables for the + /// view and for the view component + /// + /// The context vars. public virtual IDictionary ContextVars { get { return contextVars; } } + /// + /// Gets the component parameters that the view has passed + /// to the component + /// + /// The component parameters. public virtual IDictionary ComponentParameters { get { return componentParameters; } } + /// + /// Gets or sets the view to render. + /// + /// The view to render. public string ViewToRender { get { return viewToRender; } set { viewToRender = value; } } + /// + /// Gets the view engine instance. + /// + /// The view engine. public virtual IViewEngine ViewEngine { get { return viewEngine; } diff --git a/MonoRail/Castle.MonoRail.Framework/Test/MockViewEngine.cs b/MonoRail/Castle.MonoRail.Framework/Test/MockViewEngine.cs index 7ca4533f7..79fede65a 100644 --- a/MonoRail/Castle.MonoRail.Framework/Test/MockViewEngine.cs +++ b/MonoRail/Castle.MonoRail.Framework/Test/MockViewEngine.cs @@ -17,6 +17,9 @@ namespace Castle.MonoRail.Framework.Test using System; using System.IO; + /// + /// Represents a mock implementation of for unit test purposes. + /// public class MockViewEngine : IViewEngine { private string viewFileExtension; @@ -24,6 +27,13 @@ public class MockViewEngine : IViewEngine private bool supportsJSGeneration; private bool xHtmlRendering; + /// + /// Initializes a new instance of the class. + /// + /// The view file extension. + /// The js generator file extension. + /// if set to true [supports JS generation]. + /// if set to true [x HTML rendering]. public MockViewEngine(string viewFileExtension, string jsGeneratorFileExtension, bool supportsJSGeneration, bool xHtmlRendering) { this.viewFileExtension = viewFileExtension; @@ -32,62 +42,144 @@ public MockViewEngine(string viewFileExtension, string jsGeneratorFileExtension, this.xHtmlRendering = xHtmlRendering; } + /// + /// Gets a value indicating whether the view engine + /// support the generation of JS. + /// + /// + /// true if JS generation is supported; otherwise, false. + /// public virtual bool SupportsJSGeneration { get { return supportsJSGeneration; } } + /// + /// Gets or sets a value indicating whether the view engine should set the + /// content type to xhtml. + /// + /// + /// true if the content type should be set to xhtml; otherwise, false. + /// public bool XHtmlRendering { get { return xHtmlRendering; } set { xHtmlRendering = value; } } + /// + /// Gets the view template file extension. + /// + /// The view file extension. public virtual string ViewFileExtension { get { return viewFileExtension; } } + /// + /// Gets the JS generator view template file extension. + /// + /// The JS generator file extension. public virtual string JSGeneratorFileExtension { get { return jsGeneratorFileExtension; } } + /// + /// Evaluates whether the specified template exists. + /// + /// + /// true if it exists public virtual bool HasTemplate(string templateName) { throw new NotImplementedException(); } + /// + /// Processes the view - using the templateName + /// to obtain the correct template, + /// and using the context to output the result. + /// + /// + /// + /// public virtual void Process(IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Processes the view - using the templateName + /// to obtain the correct template + /// and writes the results to the . + /// No layout is applied! + /// + /// + /// + /// + /// public virtual void Process(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Implementors should return a generator instance if + /// the view engine supports JS generation. + /// + /// The request context. + /// A JS generator instance public virtual object CreateJSGenerator(IRailsEngineContext context) { throw new NotImplementedException(); } + /// + /// Processes the js generation view template - using the templateName + /// to obtain the correct template, and using the context to output the result. + /// + /// The request context. + /// The controller. + /// Name of the template. public virtual void GenerateJS(IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Processes the js generation view template - using the templateName + /// to obtain the correct template, and using the specified + /// to output the result. + /// + /// The output. + /// The request context. + /// The controller. + /// Name of the template. public virtual void GenerateJS(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Should process the specified partial. The partial name must contains + /// the path relative to the views folder. + /// + /// The output. + /// The request context. + /// The controller. + /// The partial name. public virtual void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, string partialName) { throw new NotImplementedException(); } + /// + /// Wraps the specified content in the layout using + /// the context to output the result. + /// + /// The request context. + /// The controller. + /// Content to output public virtual void ProcessContents(IRailsEngineContext context, Controller controller, string contents) { throw new NotImplementedException(); diff --git a/MonoRail/Castle.MonoRail.Framework/TransformFilters/LowerCaseTransformFilter.cs b/MonoRail/Castle.MonoRail.Framework/TransformFilters/LowerCaseTransformFilter.cs index 433d8c1e9..3b90b9564 100644 --- a/MonoRail/Castle.MonoRail.Framework/TransformFilters/LowerCaseTransformFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/TransformFilters/LowerCaseTransformFilter.cs @@ -23,11 +23,26 @@ namespace Castle.MonoRail.Framework.TransformFilters /// public class LowerCaseTransformFilter : TransformFilter { - public LowerCaseTransformFilter(Stream baseStream) - : base(baseStream) + /// + /// Initializes a new instance of the class. + /// + /// The stream to write to after filtering. + public LowerCaseTransformFilter(Stream baseStream) : base(baseStream) { } - + + /// + /// When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. + /// + /// An array of bytes. This method copies count bytes from buffer to the current stream. + /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. + /// The number of bytes to be written to the current stream. + /// An I/O error occurs. + /// The stream does not support writing. + /// Methods were called after the stream was closed. + /// buffer is null. + /// The sum of offset and count is greater than the buffer length. + /// offset or count is negative. public override void Write(byte[] buffer, int offset, int count) { if (Closed) throw new ObjectDisposedException("UpperCaseTransformFilter"); diff --git a/MonoRail/Castle.MonoRail.Framework/TransformFilters/UpperCaseTransformFilter.cs b/MonoRail/Castle.MonoRail.Framework/TransformFilters/UpperCaseTransformFilter.cs index 8171004f0..c5dc9ad45 100644 --- a/MonoRail/Castle.MonoRail.Framework/TransformFilters/UpperCaseTransformFilter.cs +++ b/MonoRail/Castle.MonoRail.Framework/TransformFilters/UpperCaseTransformFilter.cs @@ -23,11 +23,26 @@ namespace Castle.MonoRail.Framework.TransformFilters /// public class UpperCaseTransformFilter : TransformFilter { - public UpperCaseTransformFilter(Stream baseStream) - : base(baseStream) + /// + /// Initializes a new instance of the class. + /// + /// The stream to write to after filtering. + public UpperCaseTransformFilter(Stream baseStream) : base(baseStream) { } - + + /// + /// When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. + /// + /// An array of bytes. This method copies count bytes from buffer to the current stream. + /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. + /// The number of bytes to be written to the current stream. + /// An I/O error occurs. + /// The stream does not support writing. + /// Methods were called after the stream was closed. + /// buffer is null. + /// The sum of offset and count is greater than the buffer length. + /// offset or count is negative. public override void Write(byte[] buffer, int offset, int count) { if (Closed) throw new ObjectDisposedException("UpperCaseTransformFilter"); diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponent.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponent.cs index 867814efd..643eb154f 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponent.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponent.cs @@ -24,17 +24,27 @@ namespace Castle.MonoRail.Framework /// /// Base class for reusable UI Components. - /// + /// + /// /// Implementors should override /// for implement proper initialization (if necessary). /// Also implement as by default it /// will render a default view on [ViewFolderRoot]/components/[componentname]. - /// /// /// You can also override if your component supports /// neste sections (ie templates provided on the view that uses the view component. /// - /// + /// + /// Another way is to use the to specify a custom name + /// and the sections supported. + /// + /// + /// Notice that view components can render strings or views on their folder. You can + /// create sophisticate components with that mixture. Sections allow the users of your component + /// to give it a block of content, usually customizing or definiting the content to be especially + /// rendered by your component. + /// + /// /// /// A very simplist view component that renders the time. /// @@ -57,6 +67,7 @@ namespace Castle.MonoRail.Framework /// #component(ShowTime) /// /// + /// public abstract class ViewComponent { /// @@ -334,6 +345,10 @@ protected void CancelView() context.ViewToRender = null; } + /// + /// Renders the specified content back to the browser + /// + /// The content to render. protected void RenderText(String content) { context.Writer.Write(content); diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponentException.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponentException.cs index a008327f7..0e0203003 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponentException.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponentException.cs @@ -17,6 +17,9 @@ namespace Castle.MonoRail.Framework using System; using System.Runtime.Serialization; + /// + /// Exception for ViewComponent related errors. + /// [Serializable] public class ViewComponentException : Exception { diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponents/ChildContentComponent.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponents/ChildContentComponent.cs index a44d6edca..938943dab 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponents/ChildContentComponent.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponents/ChildContentComponent.cs @@ -38,7 +38,10 @@ namespace Castle.MonoRail.Framework.ViewComponents public class ChildContentComponent : ViewComponent { private readonly String EntryKey = "componentChildContent"; - + + /// + /// Obtains the content of the child. + /// protected virtual void ObtainChildContent() { StringWriter writer = new StringWriter(); @@ -48,6 +51,9 @@ protected virtual void ObtainChildContent() Context.ContextVars[EntryKey] = writer.ToString(); } + /// + /// Populates the context. + /// protected void PopulateContext() { foreach(DictionaryEntry value in ComponentParams) @@ -56,12 +62,20 @@ protected void PopulateContext() } } + /// + /// Called by the framework so the component can + /// render its content + /// public override void Render() { RenderView("default"); } - public new void RenderView(string name) + /// + /// Specifies the view to be processed after the component has finished its processing. + /// + /// + protected new void RenderView(string name) { PopulateContext(); ObtainChildContent(); @@ -69,7 +83,12 @@ public override void Render() base.RenderView(name); } - public new void RenderView(string component, string name) + /// + /// Specifies the view to be processed after the component has finished its processing. + /// + /// + /// + protected new void RenderView(string component, string name) { PopulateContext(); ObtainChildContent(); diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponents/ColumnRenderer.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponents/ColumnRenderer.cs index 529314843..056a6f43a 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponents/ColumnRenderer.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponents/ColumnRenderer.cs @@ -18,36 +18,133 @@ namespace Castle.MonoRail.Framework.ViewComponents using System.Collections; /// - /// Renders a table where each (repeated) item - /// is rendered to a column. - /// TODO: Document it properly! + /// Renders a table where each nested content is rendered on a cell. + /// + /// For example, suppose you have a dynamic list of items and what to display + /// them side by side, in four columns. As the number of elements in unknown + /// in development time, you can use the ColumnRenderer to + /// create the table and cells. + /// /// + /// + /// + /// The following example uses nvelocity view engine syntax. + /// + /// + /// + /// + /// Which should render something like: + /// + /// + /// + /// + /// + /// Custom first element + /// + /// + /// Content is Tennis + /// + /// + /// Content is Soccer + /// + /// + /// + /// + /// Content is Voleyball + /// + /// + /// + /// ]]> + /// + /// + /// + /// + /// The following sections are supported. Only the item section must be always provided.
+ /// + /// + /// start: override it in order to create the table yourself
+ /// endblock: override it in order to end the table
+ /// + /// startrow: override it in order to start the column
+ /// endrow: override it in order to end the column
+ /// + /// startcolumn: override it in order to start the cell
+ /// endcolumn: override it in order to end the cell
+ /// + /// item: must be overriden in order to display the item content (unless it's something trivial like a primitive)
+ /// empty: section used when the is empty
+ /// firstelement: if provided, will be rendered before any cells
+ ///
+ /// + /// + /// The number of columns defaults to three. + /// + ///
public class ColumnRenderer : ViewComponent { private int cols = 3; private IEnumerable enumerable; private bool dontRenderUneededTableForEmptyLists = false; + /// + /// Gets or sets the number of columns to display. + /// + /// The cols. + [ViewComponentParam] + public int Cols + { + get { return cols; } + set { cols = value; } + } + + /// + /// Gets or sets the items to show. + /// + /// The items. + [ViewComponentParam(Required = true)] + public IEnumerable Items + { + get { return enumerable; } + set { enumerable = value; } + } + + /// + /// Gets or sets a value indicating whether the component should render a table + /// even if there are no elements on the . + /// + /// + /// true if it should not render; otherwise, false. + /// + [ViewComponentParam("emptyness")] + public bool DontRenderUneededTableForEmptyLists + { + get { return dontRenderUneededTableForEmptyLists; } + set { dontRenderUneededTableForEmptyLists = value; } + } + /// /// Called by the framework once the component instance /// is initialized /// public override void Initialize() { - if (ComponentParams.Contains("cols")) + if (cols <= 0) { - cols = Convert.ToInt32(ComponentParams["cols"]); - - if (cols <= 0) - { - throw new ViewComponentException("ColumnRenderer: 'cols' parameter must be greater than zero"); - } + throw new ViewComponentException("ColumnRenderer: 'cols' parameter must be greater than zero"); } - if (ComponentParams.Contains("emptyness")) { - dontRenderUneededTableForEmptyLists = Convert.ToBoolean(ComponentParams["emptyness"]); - } - - enumerable = (IEnumerable) ComponentParams["items"]; } /// @@ -128,19 +225,6 @@ public override void Render() EndTable(); } - - private bool IsEmptyAndShouldNotRenderBrokenTableTags() - { - if (dontRenderUneededTableForEmptyLists) - { - if (enumerable == null || !enumerable.GetEnumerator().MoveNext()) - { - return true; - } - } - return false; - } - /// /// Implementor should return true only if the /// name is a known section the view component @@ -157,6 +241,18 @@ public override bool SupportsSection(string name) name == "empty"; } + private bool IsEmptyAndShouldNotRenderBrokenTableTags() + { + if (dontRenderUneededTableForEmptyLists) + { + if (enumerable == null || !enumerable.GetEnumerator().MoveNext()) + { + return true; + } + } + return false; + } + private void WriteElement(object item) { if (Context.HasSection("item")) diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponents/DiggStylePagination.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponents/DiggStylePagination.cs index d64f6a270..e40cf5a70 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponents/DiggStylePagination.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponents/DiggStylePagination.cs @@ -21,7 +21,14 @@ namespace Castle.MonoRail.Framework.ViewComponents /// /// Creates a digg style pagination. + /// + /// Based on Alex Henderson work. See + /// (Monorail Pagination with Base4.Net) + /// http://blog.bittercoder.com/PermaLink,guid,579711a8-0b16-481b-b52b-ebdfa1a7e225.aspx + /// + /// /// + /// /// /// Parameters:
/// adjacents: number of links to show around the current page
@@ -38,15 +45,10 @@ namespace Castle.MonoRail.Framework.ViewComponents /// endblock: invoked with page
/// link: invoked with pageIndex, url and text /// so you can build a custom link
- /// prev: text displayed instead of "<%lt;prev" - /// next: text displayed instead of "next>%gt;" + /// prev: text displayed instead of "<%lt;prev"
+ /// next: text displayed instead of "next>%gt;"
///
- ///
/// - /// - /// Based on Alex Henderson work. See - /// (Monorail Pagination with Base4.Net) - /// http://blog.bittercoder.com/PermaLink,guid,579711a8-0b16-481b-b52b-ebdfa1a7e225.aspx /// public class DiggStylePagination : ViewComponent { @@ -63,6 +65,10 @@ public class DiggStylePagination : ViewComponent private string paginatefunction; private IPaginatedPage page; + /// + /// Gets or sets the paginated page instance. + /// + /// The page. [ViewComponentParam(Required = true)] public IPaginatedPage Page { @@ -70,6 +76,14 @@ public IPaginatedPage Page set { page = value; } } + /// + /// Gets or sets the paginate function name. + /// + /// A paginate function is a javascript fuction + /// that receives the page index as the only argument. + /// + /// + /// The paginate function. [ViewComponentParam] public string PaginateFunction { @@ -77,6 +91,10 @@ public string PaginateFunction set { paginatefunction = value; } } + /// + /// Gets or sets the adjacents (number of links to show). + /// + /// The adjacents. [ViewComponentParam] public int Adjacents { @@ -84,6 +102,10 @@ public int Adjacents set { adjacents = value; } } + /// + /// Gets or sets a value indicating whether the component should output inline styles. + /// + /// true if it should use inline styles; otherwise, false. [ViewComponentParam] public bool UseInlineStyle { @@ -91,6 +113,12 @@ public bool UseInlineStyle set { useInlineStyle = value; } } + /// + /// Gets or sets a value indicating whether the component should render links even if there is only one page. + /// + /// + /// true if it should render; otherwise, false. + /// [ViewComponentParam] public bool RenderIfOnlyOnePage { @@ -98,6 +126,10 @@ public bool RenderIfOnlyOnePage set { renderIfOnlyOnePage = value; } } + /// + /// Gets or sets the URL to be used when generating links + /// + /// The URL. [ViewComponentParam] public string Url { @@ -126,6 +158,15 @@ public override void Initialize() PropertyBag["page"] = page; } + /// + /// Implementor should return true only if the + /// name is a known section the view component + /// supports. + /// + /// section being added + /// + /// if section is supported + /// public override bool SupportsSection(string name) { return name == StartSection || name == EndSection || name == LinkSection || name == PrevSection || name == NextSection; @@ -286,6 +327,13 @@ private void WriteNumberedLink(TextWriter writer, int index) } } + /// + /// Writes the page link. + /// + /// The writer. + /// Index of the page. + /// The text. + /// The HTML attributes. protected void WritePageLink(TextWriter writer, int pageIndex, String text, IDictionary htmlAttributes) { if (Context.HasSection(LinkSection)) diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePage.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePage.cs index 5d69dbd1f..dda330da0 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePage.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePage.cs @@ -15,10 +15,28 @@ namespace Castle.MonoRail.Framework.ViewComponents { using System.IO; + using Helpers; /// - /// + /// Renders a javascript content that changes the page + /// elements using a special dsl-like language. /// + /// + /// + /// + /// + /// The following illustrates its use. + /// + /// #blockcomponent(UpdatePage) + /// $page.ReplaceHtml('myotherdiv', 'new content') + /// $page.Highlight('mydivid') + /// #end + /// + /// + /// + /// The current implementation is dependent on + /// prototype.js and scriptaculous.js + /// public class UpdatePage : ViewComponent { /// @@ -30,6 +48,11 @@ public override void Render() Context.Writer.WriteLine(GenerateJS()); } + /// + /// Evaluates the component's body providing a page + /// instance which is a + /// + /// protected string GenerateJS() { object generator = Context.ViewEngine.CreateJSGenerator(RailsContext); diff --git a/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePageTag.cs b/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePageTag.cs index 1fdc45be4..04bcea07b 100644 --- a/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePageTag.cs +++ b/MonoRail/Castle.MonoRail.Framework/ViewComponents/UpdatePageTag.cs @@ -17,8 +17,26 @@ namespace Castle.MonoRail.Framework.ViewComponents using Castle.MonoRail.Framework.Helpers; /// - /// + /// Renders a javascript tag block with an inline javascript + /// that changes the page + /// elements using a special dsl-like language. /// + /// + /// + /// + /// + /// The following illustrates its use. + /// + /// #blockcomponent(UpdatePageTag) + /// $page.ReplaceHtml('myotherdiv', 'new content') + /// $page.Highlight('mydivid') + /// #end + /// + /// + /// + /// The current implementation is dependent on + /// prototype.js and scriptaculous.js + /// public class UpdatePageTag : UpdatePage { /// diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/Contents.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/Contents.cs index 937f1b963..bb76b29f9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/Contents.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/Contents.cs @@ -25,6 +25,10 @@ namespace Castle.MonoRail.Framework.Views.Aspx /// public class Contents : Control { + /// + /// Sends server control content to a provided object, which writes the content to be rendered on the client. + /// + /// The object that receives the server control content. protected override void Render(HtmlTextWriter writer) { byte[] contentsArray = (byte[]) HttpContext.Current.Items["rails.contents"]; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingComponent.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingComponent.cs index b0bcd400a..47094d555 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingComponent.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingComponent.cs @@ -21,22 +21,39 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Text; + /// + /// Pendent + /// [Serializable] public abstract class AbstractBindingComponent : IDataErrorInfo { - private IDictionary propertyErrors; - + private IDictionary propertyErrors; + + /// + /// Determines whether this instance is valid. + /// + /// + /// true if this instance is valid; otherwise, false. + /// public bool IsValid() { propertyErrors = null; Validate(); return propertyErrors == null || propertyErrors.Count == 0; - } - + } + + /// + /// Validates this instance. + /// protected abstract void Validate(); - #region IDataErrorInfo - + #region IDataErrorInfo + + /// + /// Gets an error message indicating what is wrong with this object. + /// + /// + /// An error message indicating what is wrong with this object. The default is an empty string (""). [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Error @@ -58,8 +75,12 @@ public string Error return string.Empty; } - } - + } + + /// + /// Gets or sets the with the specified property name. + /// + /// public string this[string propertyName] { get @@ -84,9 +105,14 @@ protected set } } - #endregion - - protected string Trim(string value) + #endregion + + /// + /// Trims the specified value. + /// + /// The value. + /// + protected static string Trim(string value) { return (value != null) ? value.Trim() : ""; } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingScope.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingScope.cs index 8d859a235..ef2802f3e 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingScope.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractBindingScope.cs @@ -16,31 +16,53 @@ namespace Castle.MonoRail.Framework.Views.Aspx { - using System; using System.Collections; + /// + /// Pendent + /// public abstract class AbstractBindingScope : IBindingScope { - #region IBindingScope - + #region IBindingScope + + /// + /// Resolves the symbol. + /// + /// The symbol. + /// object IBindingScope.ResolveSymbol(string symbol) { return ResolveSymbol(symbol); - } - + } + + /// + /// Adds the action arguments. + /// + /// The context. + /// The resolved action args. void IBindingScope.AddActionArguments(BindingContext context, IDictionary resolvedActionArgs) { AddActionArguments(context, resolvedActionArgs); } - #endregion - + #endregion + + /// + /// Resolves the symbol. + /// + /// The symbol. + /// protected virtual object ResolveSymbol(string symbol) { return null; - } - + } + + /// + /// Adds the action arguments. + /// + /// The context. + /// The resolved action args. protected virtual void AddActionArguments(BindingContext context, IDictionary resolvedActionArgs) { diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractEventScope.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractEventScope.cs index 967709db5..4c41966ec 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractEventScope.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/AbstractEventScope.cs @@ -1,73 +1,105 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System; - using System.Collections; - - public abstract class AbstractEventScope : AbstractBindingScope - { - private object source; - private EventArgs eventArgs; - private BindingContext context; - - protected AbstractEventScope(BindingContext context) - { - this.context = context; - } - - protected BindingContext Context - { - get { return context; } - } - - protected void DispatchAction(object source, EventArgs e) - { - PushEventScope(source, e); - context.DispatchAction(); - } - - protected void DispatchAction(object source, EventArgs e, string action) - { - PushEventScope(source, e); - context.DispatchAction(action); - } - - protected override object ResolveSymbol(string symbol) - { - switch(symbol) - { - case "this": - return source; - - case "event": - return eventArgs; - } - - return null; - } - - private void PushEventScope(object source, EventArgs e) - { - this.source = source; - this.eventArgs = e; - context.PushScope(this); - } - } -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System; + using System.Collections; + + /// + /// Pendent + /// + public abstract class AbstractEventScope : AbstractBindingScope + { + private object source; + private EventArgs eventArgs; + private BindingContext context; + + /// + /// Initializes a new instance of the class. + /// + /// The context. + protected AbstractEventScope(BindingContext context) + { + this.context = context; + } + + /// + /// Gets the context. + /// + /// The context. + protected BindingContext Context + { + get { return context; } + } + + /// + /// Dispatches the action. + /// + /// The source. + /// The instance containing the event data. + protected void DispatchAction(object source, EventArgs e) + { + PushEventScope(source, e); + context.DispatchAction(); + } + + /// + /// Dispatches the action. + /// + /// The source. + /// The instance containing the event data. + /// The action. + protected void DispatchAction(object source, EventArgs e, string action) + { + PushEventScope(source, e); + context.DispatchAction(action); + } + + /// + /// Resolves the symbol. + /// + /// The symbol. + /// + protected override object ResolveSymbol(string symbol) + { + switch(symbol) + { + case "this": + return source; + + case "event": + return eventArgs; + } + + return null; + } + + /// + /// Pushes the event scope. + /// + /// The source. + /// The instance containing the event data. + private void PushEventScope(object source, EventArgs e) + { + this.source = source; + this.eventArgs = e; + context.PushScope(this); + } + } +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgument.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgument.cs index 92b602544..be77f19d9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgument.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgument.cs @@ -20,6 +20,9 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Text.RegularExpressions; + /// + /// Pendent + /// [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] public class ActionArgument : AbstractBindingComponent, ICloneable @@ -29,16 +32,24 @@ public class ActionArgument : AbstractBindingComponent, ICloneable private string expression; private static readonly Regex nameRegexRule = - new Regex("^[A-za-z]([A-za-z0-9]*)$"); - + new Regex("^[A-za-z]([A-za-z0-9]*)$"); + + /// + /// Gets or sets the name. + /// + /// The name. [Category("Data"), DefaultValue("")] [Description("The name of the argument to pass to the controller action.")] public string Name { get { return name; } set { name = Trim(value); } - } - + } + + /// + /// Gets or sets the expression. + /// + /// The expression. [DisplayName("Value")] [Category("Data"), DefaultValue((string) null)] [Description("The expression for the argument to pass to the controller action.")] @@ -46,16 +57,23 @@ public string Expression { get { return expression; } set{ expression = Trim(value); } - } - + } + + /// + /// Gets or sets the value. + /// + /// The value. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public object Value { get { return value; } set { this.value = value; } - } - + } + + /// + /// Validates this instance. + /// protected override void Validate() { if (string.IsNullOrEmpty(name)) @@ -71,8 +89,14 @@ protected override void Validate() { this["Value"] = "must be specified"; } - } - + } + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// public object Clone() { ActionArgument actionArg = new ActionArgument(); @@ -80,8 +104,14 @@ public object Clone() actionArg.value = value; actionArg.expression = expression; return actionArg; - } - + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString() { if (string.IsNullOrEmpty(name)) diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgumentCollection.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgumentCollection.cs index 679d2a1c7..001704c84 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgumentCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionArgumentCollection.cs @@ -20,9 +20,18 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Drawing.Design; + /// + /// Pendent + /// [Editor(typeof(Design.ActionArgumentEditor), typeof(UITypeEditor))] public class ActionArgumentCollection : TypedCollection - { + { + /// + /// Adds the specified name. + /// + /// The name. + /// The value. + /// public ActionArgument Add(string name, object value) { ActionArgument actionArg = new ActionArgument(); @@ -30,8 +39,13 @@ public ActionArgument Add(string name, object value) actionArg.Value = value; Add(actionArg); return actionArg; - } - + } + + /// + /// Removes the specified name. + /// + /// The name. + /// public bool Remove(string name) { if (name == null) @@ -49,8 +63,13 @@ public bool Remove(string name) } return false; - } - + } + + /// + /// Performs additional custom processes before inserting a new element into the instance. + /// + /// The zero-based index at which to insert value. + /// The new value of the element at index. protected override void OnInsert(int index, object value) { ActionArgument newActionArg = (ActionArgument) value; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBinding.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBinding.cs index 52f2bb4f5..81c4f2028 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBinding.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBinding.cs @@ -1,144 +1,183 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System; - using System.ComponentModel; - using System.Web.UI; - - [Serializable] - [DefaultProperty("EventName")] - [ParseChildren(true), PersistChildren(false)] - [TypeConverter(typeof(ActionBindingTypeConverter))] - public class ActionBinding : AbstractBindingComponent - { - private string eventName = ""; - private string actionName = ""; - private ControllerBinding parent; - private ActionArgumentCollection actionArguments; - private CommandBindingCollection commandBindings; - - public ActionBinding() - { - ResetCommandDefaults(false); - } - - [Category("Behavior"), DefaultValue("")] - [Description("The name of the controller action to call.")] - [TypeConverter(typeof(ActionListConverter))] - public string ActionName - { - get { return Trim(actionName); } - set { actionName = value; } - } - - [Category("Behavior"), DefaultValue("")] - [Description("The name of the control event to track.")] - [TypeConverter(typeof(EventListConverter))] - [RefreshProperties(RefreshProperties.All)] - public string EventName - { - get { return Trim(eventName); } - set { eventName = value; } - } - - [Category("Behavior")] - [PersistenceMode(PersistenceMode.InnerProperty)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] - [Description("Maps control commands to controller actions.")] - public CommandBindingCollection CommandBindings - { - get - { - if (commandBindings == null) - { - commandBindings = new CommandBindingCollection(); - } - - return commandBindings; - } - } - - [Category("Behavior")] - [PersistenceMode(PersistenceMode.InnerProperty)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] - [Description("Arguments passed to the controller action.")] - public ActionArgumentCollection ActionArguments - { - get - { - if (actionArguments == null) - { - actionArguments = new ActionArgumentCollection(); - } - - return actionArguments; - } - } - - protected override void Validate() - { - if (string.IsNullOrEmpty(eventName)) - { - this["EventName"] = "must be specified"; - } - } - - internal ControllerBinding Parent - { - get { return parent; } - set { parent = value; } - } - - internal Control ControlInstance - { - get { return (parent != null) ? parent.ControlInstance : null; } - } - - /// - /// Reset the command defaults so they don't get serialized in the html markup. - /// - /// - internal void ResetCommandDefaults(bool isCommandEvent) - { - if (!isCommandEvent) - { - if (commandBindings != null) - { - commandBindings.Clear(); - } - } - } - - public override string ToString() - { - if (string.IsNullOrEmpty(eventName)) - { - return "Pick an event"; - } - - if (parent != null && !string.IsNullOrEmpty(parent.ControlID)) - { - return string.Format("{0}.{1}", parent.ControlID, eventName); - } - - return eventName; - } - } -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System; + using System.ComponentModel; + using System.Web.UI; + + /// + /// Pendent + /// + [Serializable] + [DefaultProperty("EventName")] + [ParseChildren(true), PersistChildren(false)] + [TypeConverter(typeof(ActionBindingTypeConverter))] + public class ActionBinding : AbstractBindingComponent + { + private string eventName = ""; + private string actionName = ""; + private ControllerBinding parent; + private ActionArgumentCollection actionArguments; + private CommandBindingCollection commandBindings; + + /// + /// Initializes a new instance of the class. + /// + public ActionBinding() + { + ResetCommandDefaults(false); + } + + /// + /// Gets or sets the name of the action. + /// + /// The name of the action. + [Category("Behavior"), DefaultValue("")] + [Description("The name of the controller action to call.")] + [TypeConverter(typeof(ActionListConverter))] + public string ActionName + { + get { return Trim(actionName); } + set { actionName = value; } + } + + /// + /// Gets or sets the name of the event. + /// + /// The name of the event. + [Category("Behavior"), DefaultValue("")] + [Description("The name of the control event to track.")] + [TypeConverter(typeof(EventListConverter))] + [RefreshProperties(RefreshProperties.All)] + public string EventName + { + get { return Trim(eventName); } + set { eventName = value; } + } + + /// + /// Gets the command bindings. + /// + /// The command bindings. + [Category("Behavior")] + [PersistenceMode(PersistenceMode.InnerProperty)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + [Description("Maps control commands to controller actions.")] + public CommandBindingCollection CommandBindings + { + get + { + if (commandBindings == null) + { + commandBindings = new CommandBindingCollection(); + } + + return commandBindings; + } + } + + /// + /// Gets the action arguments. + /// + /// The action arguments. + [Category("Behavior")] + [PersistenceMode(PersistenceMode.InnerProperty)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + [Description("Arguments passed to the controller action.")] + public ActionArgumentCollection ActionArguments + { + get + { + if (actionArguments == null) + { + actionArguments = new ActionArgumentCollection(); + } + + return actionArguments; + } + } + + /// + /// Validates this instance. + /// + protected override void Validate() + { + if (string.IsNullOrEmpty(eventName)) + { + this["EventName"] = "must be specified"; + } + } + + /// + /// Gets or sets the parent. + /// + /// The parent. + internal ControllerBinding Parent + { + get { return parent; } + set { parent = value; } + } + + /// + /// Gets the control instance. + /// + /// The control instance. + internal Control ControlInstance + { + get { return (parent != null) ? parent.ControlInstance : null; } + } + + /// + /// Reset the command defaults so they don't get serialized in the html markup. + /// + /// if set to true [is command event]. + internal void ResetCommandDefaults(bool isCommandEvent) + { + if (!isCommandEvent) + { + if (commandBindings != null) + { + commandBindings.Clear(); + } + } + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + if (string.IsNullOrEmpty(eventName)) + { + return "Pick an event"; + } + + if (parent != null && !string.IsNullOrEmpty(parent.ControlID)) + { + return string.Format("{0}.{1}", parent.ControlID, eventName); + } + + return eventName; + } + } +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBindingCollection.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBindingCollection.cs index 92bad5325..76badbc4e 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBindingCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ActionBindingCollection.cs @@ -18,18 +18,29 @@ namespace Castle.MonoRail.Framework.Views.Aspx { using System; + /// + /// Pendent + /// public class ActionBindingCollection : TypedCollection { - private readonly ControllerBinding parent; - + private readonly ControllerBinding parent; + + /// + /// Initializes a new instance of the class. + /// + /// The parent. public ActionBindingCollection(ControllerBinding parent) { if (parent == null) throw new ArgumentNullException("parent"); this.parent = parent; - } - + } + + /// + /// Gets the with the specified event name. + /// + /// public ActionBinding this[string eventName] { get @@ -44,8 +55,14 @@ public ActionBinding this[string eventName] return null; } - } - + } + + /// + /// Performs additional custom processes after setting a value in the instance. + /// + /// The zero-based index at which oldValue can be found. + /// The value to replace with newValue. + /// The new value of the element at index. protected override void OnSetComplete(int index, object oldValue, object newValue) { ActionBinding oldBinding = (ActionBinding) oldValue; @@ -55,8 +72,13 @@ protected override void OnSetComplete(int index, object oldValue, object newValu newBinding.Parent = parent; base.OnSetComplete(index, oldValue, newValue); - } - + } + + /// + /// Performs additional custom processes after inserting a new element into the instance. + /// + /// The zero-based index at which to insert value. + /// The new value of the element at index. protected override void OnInsertComplete(int index, object value) { ActionBinding binding = (ActionBinding) value; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/BindingContext.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/BindingContext.cs index cb9b0bebb..0078eb3d8 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/BindingContext.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/BindingContext.cs @@ -21,6 +21,9 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.Collections.Generic; using System.Collections.Specialized; + /// + /// Pendent + /// public class BindingContext : AbstractBindingScope { private readonly ActionBinding action; @@ -28,6 +31,11 @@ public class BindingContext : AbstractBindingScope private Stack scopes; private static readonly IExpressionEvaluator evaluator = new DataBindingEvaluator(); + /// + /// Initializes a new instance of the class. + /// + /// The binder. + /// The action. internal BindingContext(ControllerBinder binder, ActionBinding action) { if (binder == null) @@ -46,26 +54,45 @@ internal BindingContext(ControllerBinder binder, ActionBinding action) RegisterDefaultScopes(); } + /// + /// Gets the action. + /// + /// The action. public ActionBinding Action { get { return action; } } + /// + /// Pushes the scope. + /// + /// The scope. public void PushScope(IBindingScope scope) { scopes.Push(scope); } + /// + /// Dispatches the action. + /// public void DispatchAction() { DispatchAction(action.ActionName); } + /// + /// Dispatches the action. + /// + /// Name of the action. public void DispatchAction(string actionName) { binder.DispatchAction(actionName, this); } + /// + /// Resolves the action arguments. + /// + /// public IDictionary ResolveActionArguments() { HybridDictionary actionArgs = new HybridDictionary(true); @@ -78,6 +105,11 @@ public IDictionary ResolveActionArguments() return actionArgs; } + /// + /// Resolves the action arguments. + /// + /// The action args. + /// The resolved action args. public void ResolveActionArguments(ActionArgumentCollection actionArgs, IDictionary resolvedActionArgs) { @@ -106,6 +138,12 @@ public void ResolveActionArguments(ActionArgumentCollection actionArgs, } } + /// + /// Resolves the symbol. + /// + /// Name of the symbol. + /// if set to true [throw if not found]. + /// public object ResolveSymbol(string symbolName, bool throwIfNotFound) { object value = null; @@ -124,12 +162,22 @@ public object ResolveSymbol(string symbolName, bool throwIfNotFound) return value; } + /// + /// Adds the action arguments. + /// + /// The context. + /// The resolved action args. protected override void AddActionArguments(BindingContext context, IDictionary resolvedActionArgs) { context.ResolveActionArguments(action.ActionArguments, resolvedActionArgs); } + /// + /// Resolves the action argument. + /// + /// The action arg. + /// private object ResolveActionArgument(ActionArgument actionArg) { object value = actionArg.Value; @@ -147,6 +195,9 @@ private object ResolveActionArgument(ActionArgument actionArg) return value; } + /// + /// Registers the default scopes. + /// private void RegisterDefaultScopes() { scopes = new Stack(); diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBinding.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBinding.cs index ab686ec28..896a9b15d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBinding.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBinding.cs @@ -20,14 +20,21 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Web.UI; + /// + /// Pendent + /// [Serializable] [TypeConverter(typeof(ExpandableObjectConverter))] public class CommandBinding : AbstractBindingComponent { private string actionName = ""; private string commandName = ""; - private ActionArgumentCollection actionArguments; - + private ActionArgumentCollection actionArguments; + + /// + /// Gets or sets the name of the action. + /// + /// The name of the action. [Category("Behavior"), DefaultValue("")] [Description("The name of the controller action to call for the command.")] [TypeConverter(typeof(ActionListConverter))] @@ -35,16 +42,24 @@ public string ActionName { get { return Trim(actionName); } set { actionName = value; } - } - + } + + /// + /// Gets or sets the name of the command. + /// + /// The name of the command. [Category("Behavior"), DefaultValue("")] [Description("The name command to that will trigger the controller action.")] public string CommandName { get { return Trim(commandName); } set { commandName = value; } - } - + } + + /// + /// Gets the action arguments. + /// + /// The action arguments. [Category("Behavior")] [PersistenceMode(PersistenceMode.InnerProperty)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] @@ -60,16 +75,25 @@ public ActionArgumentCollection ActionArguments return actionArguments; } - } - + } + + /// + /// Validates this instance. + /// protected override void Validate() { if (string.IsNullOrEmpty(commandName)) { this["CommandName"] = "must be specified"; } - } - + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString() { if (string.IsNullOrEmpty(commandName)) diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBindingCollection.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBindingCollection.cs index bb353a40d..b39f863fa 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBindingCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandBindingCollection.cs @@ -16,6 +16,9 @@ namespace Castle.MonoRail.Framework.Views.Aspx { + /// + /// Pendent + /// public class CommandBindingCollection : TypedCollection { } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandEventHandlerDelegate.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandEventHandlerDelegate.cs index 08a6c646e..60ae32fc0 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandEventHandlerDelegate.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/CommandEventHandlerDelegate.cs @@ -22,13 +22,21 @@ namespace Castle.MonoRail.Framework.Views.Aspx internal class CommandEventHandlerDelegate : AbstractEventScope where EventArgType : CommandEventArgs { - private ActionArgumentCollection actionArgs; - - public CommandEventHandlerDelegate(BindingContext context) - : base(context) + private ActionArgumentCollection actionArgs; + + /// + /// Initializes a new instance of the class. + /// + /// The context. + public CommandEventHandlerDelegate(BindingContext context) : base(context) { - } - + } + + /// + /// Handles the event. + /// + /// The sender. + /// The e. public void HandleEvent(object sender, EventArgType e) { string actionName = ObtainCommandActionName(e); @@ -43,8 +51,13 @@ public void HandleEvent(object sender, EventArgType e) DispatchAction(sender, e, actionName); } - } - + } + + /// + /// Adds the action arguments. + /// + /// The context. + /// The resolved action args. protected override void AddActionArguments(BindingContext context, IDictionary resolvedActionArgs) { @@ -52,8 +65,13 @@ protected override void AddActionArguments(BindingContext context, { context.ResolveActionArguments(actionArgs, resolvedActionArgs); } - } - + } + + /// + /// Obtains the name of the command action. + /// + /// The instance containing the event data. + /// private string ObtainCommandActionName(CommandEventArgs e) { string actionName = null; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinder.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinder.cs index 159a867b6..62bd3d8fd 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinder.cs @@ -1,605 +1,733 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System; - using System.Collections; - using System.ComponentModel; - using System.ComponentModel.Design; - using System.Web.UI; - using System.Web.UI.Design; - - [ProvideProperty("ControllerBinding", typeof(Control))] - [NonVisualControl, Designer(typeof(Design.ControllerActionBinderDesigner))] - [ParseChildren(true, "ControllerBindings"), PersistChildren(false)] - public class ControllerBinder : Control, IExtenderProvider, IControllerBinder, ISupportInitialize - { - #region Fields - - private bool initialized; - private bool actionDispatched; - private PropertyDescriptor bindingsDescriptor; - private readonly ControllerBindingCollection bindings; - private ActionArgumentCollection actionArguments; - private readonly EventHandlerFactory eventHandlerFactory; - - private static readonly object BeforeActionEvent = new object(); - private static readonly object AfterActionEvent = new object(); - private static readonly object ActionErrorEvent = new object(); - - #endregion - - #region Constructors - - public ControllerBinder() - { - eventHandlerFactory = new EventHandlerFactory(); - bindings = new ControllerBindingCollection(this); - } - - #endregion - - #region Properties - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new bool DesignMode - { - get { return Design.DesignUtil.IsInDesignMode; } - } - - [Category("Behavior")] - [PersistenceMode(PersistenceMode.InnerProperty)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] - public ControllerBindingCollection ControllerBindings - { - get { return bindings; } - } - - [Category("Behavior")] - [PersistenceMode(PersistenceMode.InnerProperty)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] - [Description("Global arguments passed to all controller actions.")] - public ActionArgumentCollection ActionArguments - { - get - { - if (actionArguments == null) - { - actionArguments = new ActionArgumentCollection(); - } - - return actionArguments; - } - } - - #endregion - - #region Events - - [Description("Fired before the Controller action is executed.")] - public event ActionBindingDelegate BeforeAction - { - add { Events.AddHandler(BeforeActionEvent, value); } - remove { Events.RemoveHandler(BeforeActionEvent, value); } - } - - [Description("Fired after the Controller action is executed.")] - public event ActionBindingDelegate AfterAction - { - add { Events.AddHandler(AfterActionEvent, value); } - remove { Events.RemoveHandler(AfterActionEvent, value); } - } - - [Description("Fired if the Controller action raised an exception.")] - public event ActionBindingDelegate ActionError - { - add { Events.AddHandler(ActionErrorEvent, value); } - remove { Events.RemoveHandler(ActionErrorEvent, value); } - } - - protected virtual bool OnBeforeAction(ActionBinding action, IDictionary actionArgs) - { - ActionBindingDelegate eventDelegate = - (ActionBindingDelegate) Events[BeforeActionEvent]; - return (eventDelegate != null) ? eventDelegate(action, actionArgs) : true; - } - - protected virtual void OnAfterAction(ActionBinding action, IDictionary actionArgs) - { - ActionBindingDelegate eventDelegate = - (ActionBindingDelegate) Events[AfterActionEvent]; - if (eventDelegate != null) eventDelegate(action, actionArgs); - } - - protected virtual bool OnActionError(ActionBinding action, Exception ex) - { - ActionBindingErrorDelegate eventDelegate = - (ActionBindingErrorDelegate) Events[ActionErrorEvent]; - return (eventDelegate != null) ? eventDelegate(action, ex) : false; - } - - #endregion - - #region IExtenderProvider - - bool IExtenderProvider.CanExtend(object extendee) - { - return IsBindableControl(extendee as Control); - } - - public ControllerBindingProperty GetControllerBinding(Control control) - { - ControllerBinding binding = null; - - foreach(ControllerBinding candidate in ControllerBindings) - { - if (candidate.ControlID == control.ID) - { - candidate.Binder = this; - candidate.ControlInstance = control; - binding = candidate; - } - } - - if (binding == null) - { - binding = AddBinding(control); - } - - return new ControllerBindingProperty(binding); - } - - /// - /// This is never fired in ASP.NET runtime code - /// - /// - /// - public void SetControllerBinding(object extendee, object value) - { - //ControllerBindingProperty binding = (ControllerBinding) value; - //Control control = (Control) extendee; - } - - #endregion - - #region IControllerBinder - - public bool IsBindableControl(Control control) - { - if (control is ControllerBinder) return false; - - return (control != null && IsVisualControl(control) && - (!DesignMode || EventUtil.HasCompatibleEvents(control))); - } - - public ControllerBinding AddBinding(Control control) - { - ControllerBinding newBinding = new ControllerBinding(this); - newBinding.ControlInstance = control; - ControllerBindings.Add(newBinding); - - return newBinding; - } - - public Control FindControlWithID(string controlID) - { - if (DesignMode) - { - return FindControlAtDesignTime(controlID); - } - else - { - return FindControlAtRunTime(controlID); - } - } - - public string[] GetControllerActions() - { - return new string[0]; - } - - private bool IsVisualControl(Control control) - { - if (!(control is IDataSource)) - { - return !TypeDescriptor.GetAttributes(control).Contains( - NonVisualControlAttribute.NonVisual); - } - return false; - } - - private Control FindControlAtDesignTime(string controlID) - { - IContainer container = GetContainer(); - - if (container != null) - { - foreach(IComponent component in container.Components) - { - Control control = component as Control; - - if ((control != null) && (control.ID == controlID)) - { - return control; - } - } - } - - return null; - } - - private Control FindControlAtRunTime(string controlID) - { - return WebFormUtils.FindControlRecursive(Page, controlID); - } - - #endregion - - #region Designer Support - - void ISupportInitialize.BeginInit() - { - } - - void ISupportInitialize.EndInit() - { - if (!initialized && DesignMode) - { - RegisterBinderServices(); - FillMissingControlInstances(); - - IComponentChangeService changes = GetService(this); - - if (changes != null) - { - changes.ComponentChanged += OnComponentChanged; - changes.ComponentRemoved += OnComponentRemoved; - } - - initialized = true; - } - } - - private void RegisterBinderServices() - { - IServiceContainer services = GetService(this); - - if (services != null) - { - services.AddService(typeof(IControllerBinder), this); - } - } - - private void UnregisterBinderServices() - { - IServiceContainer services = GetService(this); - - if (services != null) - { - services.RemoveService(typeof(IControllerBinder)); - } - } - - private void FillMissingControlInstances() - { - foreach (ControllerBinding binding in ControllerBindings) - { - if (binding.ControlInstance == null && !string.IsNullOrEmpty(binding.ControlID)) - { - binding.ControlInstance = FindControlWithID(binding.ControlID); - } - } - } - - private void OnComponentChanged(object source, ComponentChangedEventArgs e) - { - if (IsBinderComopnent(e.Component)) - { - NotifyDesigner(); - } - } - - private void OnComponentRemoved(object source, ComponentEventArgs e) - { - // This is the only way I was able to consistently unsubscribe - // from the component change events. - - if (e.Component == this) - { - UnregisterBinderServices(); - - IComponentChangeService changes = GetService(this); - - changes.ComponentChanged -= OnComponentChanged; - changes.ComponentRemoved -= OnComponentRemoved; - } - else - { - Control control = e.Component as Control; - - if (control != null) - { - IDesignerHost designerHost = GetService(control); - - // The Loading flag is checked on the designer since all - // cotnrols are removed and then added back when switching - // between source and design mode. - - if (designerHost != null && !designerHost.Loading) - { - if (ControllerBindings.Remove(control)) - { - NotifyDesigner(); - } - } - } - } - } - - private T GetService(IComponent context) - { - if (context.Site != null) - { - return (T)Site.GetService(typeof(T)); - } - - return default(T); - } - - private IContainer GetContainer() - { - IContainer container = null; - - IDesignerHost host = GetService(this); - - if (host != null) - { - container = host.Container; - - if (container == null && Site != null) - { - container = Site.Container; - } - } - - return container; - } - - /// - /// Notifies the designer every time there is a change to - /// the child properties. This is a workaround for the Web - /// Designer not issuing SetControllerBinding invocations. - /// - private void NotifyDesigner() - { - if (DesignMode && Site != null) - { - if (bindingsDescriptor == null) - { - try - { - bindingsDescriptor = TypeDescriptor.GetProperties(this)["ControllerBindings"]; - } - catch - { - return; - } - } - - IDesignerHost host = GetService(this); - - if (host != null) - { - ControlDesigner designer = host.GetDesigner(this) as ControlDesigner; - - if (designer != null) - { - ComponentChangedEventArgs changeEvent = - new ComponentChangedEventArgs(this, bindingsDescriptor, - null, ControllerBindings); - - designer.OnComponentChanged(this, changeEvent); - } - } - } - } - - private bool IsBinderComopnent(object component) - { - return component.GetType().Namespace == GetType().Namespace; - } - - #endregion - - #region Control Runtime - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - if (Page.IsPostBack) - { - MapEventToControllerAction(); - } - } - - private void MapEventToControllerAction() - { - foreach(ControllerBinding binding in ControllerBindings) - { - if (binding.IsValid() && binding.ActionBindings.Count > 0) - { - Control control = FindControlAtRunTime(binding.ControlID); - - if (IsBindableControl(control)) - { - ApplyControlActionBindings(control, binding); - } - } - } - } - - private void ApplyControlActionBindings(Control control, ControllerBinding binding) - { - EventDescriptorCollection events = EventUtil.GetCompatibleEvents(control); - - foreach(ActionBinding action in binding.ActionBindings) - { - EventDescriptor eventToBind = events.Find(action.EventName, false); - - if (eventToBind != null) - { - BindingContext context = new BindingContext(this, action); - SubscribeToEvent(control, eventToBind, context); - } - } - } - - private void SubscribeToEvent(Control control, EventDescriptor eventToWire, - BindingContext context) - { - Type eventHandlerType; - - if (EventUtil.IsCommandEvent(eventToWire)) - { - eventHandlerType = typeof(CommandEventHandlerDelegate<>); - } - else - { - eventHandlerType = typeof(EventHandlerDelegate<>); - } - - Delegate eventHandler = eventHandlerFactory.CreateActionDelegate( - eventHandlerType, eventToWire, context); - - eventToWire.AddEventHandler(control, eventHandler); - } - - internal void DispatchAction(string actionName, BindingContext context) - { - if (actionDispatched) return; - - IDictionary actionArgs = context.ResolveActionArguments(); - - if (OnBeforeAction(context.Action, actionArgs)) - { - try - { - ContinueAction(actionName, actionArgs); - - OnAfterAction(context.Action, actionArgs); - } - catch (Exception ex) - { - if (!OnActionError(context.Action, ex)) - { - throw; - } - } - } - } - - public void ContinueAction(string actionName, IDictionary actionArgs) - { - if (actionDispatched) - { - throw new InvalidOperationException("An action has already been dispatched"); - } - - if (string.IsNullOrEmpty(actionName)) - { - throw new ArgumentException("actionName is null or empty"); - } - - Controller controller = GetCurrentController(); - - if (controller != null) - { - actionDispatched = true; - controller.Send(actionName, actionArgs); - } - else - { - throw new InvalidOperationException( - "A Controller is not present for the current context"); - } - } - - #region IBindingScope - - object IBindingScope.ResolveSymbol(string symbol) - { - return WebFormUtils.GetFieldOrProperty(Page, symbol); - } - - void IBindingScope.AddActionArguments(BindingContext context, - IDictionary resolvedActionArgs) - { - context.ResolveActionArguments(ActionArguments, resolvedActionArgs); - } - - #endregion - - private Controller GetCurrentController() - { - IControllerLifecycleExecutor executor = (IControllerLifecycleExecutor) - MonoRailHttpHandler.CurrentContext.UnderlyingContext.Items[ - ControllerLifecycleExecutor.ExecutorEntry]; - - return (executor != null) ? executor.Controller : null; - } - - #endregion - } - - #region ControllerBindingProperty - - [TypeConverter(typeof(ExpandableObjectConverter))] - public class ControllerBindingProperty - { - private ControllerBinding binding; - - internal ControllerBindingProperty(ControllerBinding binding) - { - this.binding = binding; - } - - [Category("Behavior")] - public ActionBindingCollection ActionBindings - { - get { return binding.ActionBindings; } - } - - public override string ToString() - { - return binding.ToString(); - } - } - - #endregion - - #region Event Delegates - - public delegate bool ActionBindingDelegate(ActionBinding action, IDictionary actionArgs); - - public delegate bool ActionBindingErrorDelegate(ActionBinding action, Exception ex); - - #endregion -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System; + using System.Collections; + using System.ComponentModel; + using System.ComponentModel.Design; + using System.Web.UI; + using System.Web.UI.Design; + + + /// + /// Pendent + /// + [ProvideProperty("ControllerBinding", typeof(Control))] + [NonVisualControl, Designer(typeof(Design.ControllerActionBinderDesigner))] + [ParseChildren(true, "ControllerBindings"), PersistChildren(false)] + public class ControllerBinder : Control, IExtenderProvider, IControllerBinder, ISupportInitialize + { + #region Fields + + private bool initialized; + private bool actionDispatched; + private PropertyDescriptor bindingsDescriptor; + private readonly ControllerBindingCollection bindings; + private ActionArgumentCollection actionArguments; + private readonly EventHandlerFactory eventHandlerFactory; + + private static readonly object BeforeActionEvent = new object(); + private static readonly object AfterActionEvent = new object(); + private static readonly object ActionErrorEvent = new object(); + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ControllerBinder() + { + eventHandlerFactory = new EventHandlerFactory(); + bindings = new ControllerBindingCollection(this); + } + + #endregion + + #region Properties + + /// + /// Gets a value indicating whether a control is being used on a design surface. + /// + /// + /// true if the control is being used in a designer; otherwise, false. + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new bool DesignMode + { + get { return Design.DesignUtil.IsInDesignMode; } + } + + /// + /// Gets the controller bindings. + /// + /// The controller bindings. + [Category("Behavior")] + [PersistenceMode(PersistenceMode.InnerProperty)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public ControllerBindingCollection ControllerBindings + { + get { return bindings; } + } + + /// + /// Gets the action arguments. + /// + /// The action arguments. + [Category("Behavior")] + [PersistenceMode(PersistenceMode.InnerProperty)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + [Description("Global arguments passed to all controller actions.")] + public ActionArgumentCollection ActionArguments + { + get + { + if (actionArguments == null) + { + actionArguments = new ActionArgumentCollection(); + } + + return actionArguments; + } + } + + #endregion + + #region Events + + /// + /// Occurs when [before action]. + /// + [Description("Fired before the Controller action is executed.")] + public event ActionBindingDelegate BeforeAction + { + add { Events.AddHandler(BeforeActionEvent, value); } + remove { Events.RemoveHandler(BeforeActionEvent, value); } + } + + /// + /// Occurs when [after action]. + /// + [Description("Fired after the Controller action is executed.")] + public event ActionBindingDelegate AfterAction + { + add { Events.AddHandler(AfterActionEvent, value); } + remove { Events.RemoveHandler(AfterActionEvent, value); } + } + + /// + /// Occurs when [action error]. + /// + [Description("Fired if the Controller action raised an exception.")] + public event ActionBindingDelegate ActionError + { + add { Events.AddHandler(ActionErrorEvent, value); } + remove { Events.RemoveHandler(ActionErrorEvent, value); } + } + + /// + /// Called when [before action]. + /// + /// The action. + /// The action args. + /// + protected virtual bool OnBeforeAction(ActionBinding action, IDictionary actionArgs) + { + ActionBindingDelegate eventDelegate = + (ActionBindingDelegate) Events[BeforeActionEvent]; + return (eventDelegate != null) ? eventDelegate(action, actionArgs) : true; + } + + /// + /// Called when [after action]. + /// + /// The action. + /// The action args. + protected virtual void OnAfterAction(ActionBinding action, IDictionary actionArgs) + { + ActionBindingDelegate eventDelegate = + (ActionBindingDelegate) Events[AfterActionEvent]; + if (eventDelegate != null) eventDelegate(action, actionArgs); + } + + /// + /// Called when [action error]. + /// + /// The action. + /// The ex. + /// + protected virtual bool OnActionError(ActionBinding action, Exception ex) + { + ActionBindingErrorDelegate eventDelegate = + (ActionBindingErrorDelegate) Events[ActionErrorEvent]; + return (eventDelegate != null) ? eventDelegate(action, ex) : false; + } + + #endregion + + #region IExtenderProvider + + /// + /// Specifies whether this object can provide its extender properties to the specified object. + /// + /// The to receive the extender properties. + /// + /// true if this object can provide extender properties to the specified object; otherwise, false. + /// + bool IExtenderProvider.CanExtend(object extendee) + { + return IsBindableControl(extendee as Control); + } + + /// + /// Gets the controller binding. + /// + /// The control. + /// + public ControllerBindingProperty GetControllerBinding(Control control) + { + ControllerBinding binding = null; + + foreach(ControllerBinding candidate in ControllerBindings) + { + if (candidate.ControlID == control.ID) + { + candidate.Binder = this; + candidate.ControlInstance = control; + binding = candidate; + } + } + + if (binding == null) + { + binding = AddBinding(control); + } + + return new ControllerBindingProperty(binding); + } + + /// + /// This is never fired in ASP.NET runtime code + /// + /// + /// + public void SetControllerBinding(object extendee, object value) + { + //ControllerBindingProperty binding = (ControllerBinding) value; + //Control control = (Control) extendee; + } + + #endregion + + #region IControllerBinder + + /// + /// Determines whether [is bindable control] [the specified control]. + /// + /// The control. + /// + /// true if [is bindable control] [the specified control]; otherwise, false. + /// + public bool IsBindableControl(Control control) + { + if (control is ControllerBinder) return false; + + return (control != null && IsVisualControl(control) && + (!DesignMode || EventUtil.HasCompatibleEvents(control))); + } + + /// + /// Adds the binding. + /// + /// The control. + /// + public ControllerBinding AddBinding(Control control) + { + ControllerBinding newBinding = new ControllerBinding(this); + newBinding.ControlInstance = control; + ControllerBindings.Add(newBinding); + + return newBinding; + } + + /// + /// Finds the control with ID. + /// + /// The control ID. + /// + public Control FindControlWithID(string controlID) + { + if (DesignMode) + { + return FindControlAtDesignTime(controlID); + } + else + { + return FindControlAtRunTime(controlID); + } + } + + /// + /// Gets the controller actions. + /// + /// + public string[] GetControllerActions() + { + return new string[0]; + } + + /// + /// Determines whether [is visual control] [the specified control]. + /// + /// The control. + /// + /// true if [is visual control] [the specified control]; otherwise, false. + /// + private bool IsVisualControl(Control control) + { + if (!(control is IDataSource)) + { + return !TypeDescriptor.GetAttributes(control).Contains( + NonVisualControlAttribute.NonVisual); + } + return false; + } + + /// + /// Finds the control at design time. + /// + /// The control ID. + /// + private Control FindControlAtDesignTime(string controlID) + { + IContainer container = GetContainer(); + + if (container != null) + { + foreach(IComponent component in container.Components) + { + Control control = component as Control; + + if ((control != null) && (control.ID == controlID)) + { + return control; + } + } + } + + return null; + } + + /// + /// Finds the control at run time. + /// + /// The control ID. + /// + private Control FindControlAtRunTime(string controlID) + { + return WebFormUtils.FindControlRecursive(Page, controlID); + } + + #endregion + + #region Designer Support + + void ISupportInitialize.BeginInit() + { + } + + void ISupportInitialize.EndInit() + { + if (!initialized && DesignMode) + { + RegisterBinderServices(); + FillMissingControlInstances(); + + IComponentChangeService changes = GetService(this); + + if (changes != null) + { + changes.ComponentChanged += OnComponentChanged; + changes.ComponentRemoved += OnComponentRemoved; + } + + initialized = true; + } + } + + private void RegisterBinderServices() + { + IServiceContainer services = GetService(this); + + if (services != null) + { + services.AddService(typeof(IControllerBinder), this); + } + } + + private void UnregisterBinderServices() + { + IServiceContainer services = GetService(this); + + if (services != null) + { + services.RemoveService(typeof(IControllerBinder)); + } + } + + private void FillMissingControlInstances() + { + foreach (ControllerBinding binding in ControllerBindings) + { + if (binding.ControlInstance == null && !string.IsNullOrEmpty(binding.ControlID)) + { + binding.ControlInstance = FindControlWithID(binding.ControlID); + } + } + } + + private void OnComponentChanged(object source, ComponentChangedEventArgs e) + { + if (IsBinderComopnent(e.Component)) + { + NotifyDesigner(); + } + } + + private void OnComponentRemoved(object source, ComponentEventArgs e) + { + // This is the only way I was able to consistently unsubscribe + // from the component change events. + + if (e.Component == this) + { + UnregisterBinderServices(); + + IComponentChangeService changes = GetService(this); + + changes.ComponentChanged -= OnComponentChanged; + changes.ComponentRemoved -= OnComponentRemoved; + } + else + { + Control control = e.Component as Control; + + if (control != null) + { + IDesignerHost designerHost = GetService(control); + + // The Loading flag is checked on the designer since all + // cotnrols are removed and then added back when switching + // between source and design mode. + + if (designerHost != null && !designerHost.Loading) + { + if (ControllerBindings.Remove(control)) + { + NotifyDesigner(); + } + } + } + } + } + + private T GetService(IComponent context) + { + if (context.Site != null) + { + return (T)Site.GetService(typeof(T)); + } + + return default(T); + } + + private IContainer GetContainer() + { + IContainer container = null; + + IDesignerHost host = GetService(this); + + if (host != null) + { + container = host.Container; + + if (container == null && Site != null) + { + container = Site.Container; + } + } + + return container; + } + + /// + /// Notifies the designer every time there is a change to + /// the child properties. This is a workaround for the Web + /// Designer not issuing SetControllerBinding invocations. + /// + private void NotifyDesigner() + { + if (DesignMode && Site != null) + { + if (bindingsDescriptor == null) + { + try + { + bindingsDescriptor = TypeDescriptor.GetProperties(this)["ControllerBindings"]; + } + catch + { + return; + } + } + + IDesignerHost host = GetService(this); + + if (host != null) + { + ControlDesigner designer = host.GetDesigner(this) as ControlDesigner; + + if (designer != null) + { + ComponentChangedEventArgs changeEvent = + new ComponentChangedEventArgs(this, bindingsDescriptor, + null, ControllerBindings); + + designer.OnComponentChanged(this, changeEvent); + } + } + } + } + + private bool IsBinderComopnent(object component) + { + return component.GetType().Namespace == GetType().Namespace; + } + + #endregion + + #region Control Runtime + + /// + /// Raises the event. + /// + /// The object that contains the event data. + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + if (Page.IsPostBack) + { + MapEventToControllerAction(); + } + } + + private void MapEventToControllerAction() + { + foreach(ControllerBinding binding in ControllerBindings) + { + if (binding.IsValid() && binding.ActionBindings.Count > 0) + { + Control control = FindControlAtRunTime(binding.ControlID); + + if (IsBindableControl(control)) + { + ApplyControlActionBindings(control, binding); + } + } + } + } + + private void ApplyControlActionBindings(Control control, ControllerBinding binding) + { + EventDescriptorCollection events = EventUtil.GetCompatibleEvents(control); + + foreach(ActionBinding action in binding.ActionBindings) + { + EventDescriptor eventToBind = events.Find(action.EventName, false); + + if (eventToBind != null) + { + BindingContext context = new BindingContext(this, action); + SubscribeToEvent(control, eventToBind, context); + } + } + } + + private void SubscribeToEvent(Control control, EventDescriptor eventToWire, + BindingContext context) + { + Type eventHandlerType; + + if (EventUtil.IsCommandEvent(eventToWire)) + { + eventHandlerType = typeof(CommandEventHandlerDelegate<>); + } + else + { + eventHandlerType = typeof(EventHandlerDelegate<>); + } + + Delegate eventHandler = eventHandlerFactory.CreateActionDelegate( + eventHandlerType, eventToWire, context); + + eventToWire.AddEventHandler(control, eventHandler); + } + + internal void DispatchAction(string actionName, BindingContext context) + { + if (actionDispatched) return; + + IDictionary actionArgs = context.ResolveActionArguments(); + + if (OnBeforeAction(context.Action, actionArgs)) + { + try + { + ContinueAction(actionName, actionArgs); + + OnAfterAction(context.Action, actionArgs); + } + catch (Exception ex) + { + if (!OnActionError(context.Action, ex)) + { + throw; + } + } + } + } + + /// + /// Continues the action. + /// + /// Name of the action. + /// The action args. + public void ContinueAction(string actionName, IDictionary actionArgs) + { + if (actionDispatched) + { + throw new InvalidOperationException("An action has already been dispatched"); + } + + if (string.IsNullOrEmpty(actionName)) + { + throw new ArgumentException("actionName is null or empty"); + } + + Controller controller = GetCurrentController(); + + if (controller != null) + { + actionDispatched = true; + controller.Send(actionName, actionArgs); + } + else + { + throw new InvalidOperationException( + "A Controller is not present for the current context"); + } + } + + #region IBindingScope + + object IBindingScope.ResolveSymbol(string symbol) + { + return WebFormUtils.GetFieldOrProperty(Page, symbol); + } + + void IBindingScope.AddActionArguments(BindingContext context, + IDictionary resolvedActionArgs) + { + context.ResolveActionArguments(ActionArguments, resolvedActionArgs); + } + + #endregion + + private Controller GetCurrentController() + { + IControllerLifecycleExecutor executor = (IControllerLifecycleExecutor) + MonoRailHttpHandler.CurrentContext.UnderlyingContext.Items[ + ControllerLifecycleExecutor.ExecutorEntry]; + + return (executor != null) ? executor.Controller : null; + } + + #endregion + } + + #region ControllerBindingProperty + + /// + /// Pendent + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public class ControllerBindingProperty + { + private ControllerBinding binding; + + /// + /// Initializes a new instance of the class. + /// + /// The binding. + internal ControllerBindingProperty(ControllerBinding binding) + { + this.binding = binding; + } + + /// + /// Gets the action bindings. + /// + /// The action bindings. + [Category("Behavior")] + public ActionBindingCollection ActionBindings + { + get { return binding.ActionBindings; } + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return binding.ToString(); + } + } + + #endregion + + #region Event Delegates + + /// + /// Pendent + /// + public delegate bool ActionBindingDelegate(ActionBinding action, IDictionary actionArgs); + + /// + /// Pendent + /// + public delegate bool ActionBindingErrorDelegate(ActionBinding action, Exception ex); + + #endregion +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinding.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinding.cs index d55dbec6f..164d829c9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinding.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBinding.cs @@ -20,6 +20,9 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Web.UI; + /// + /// Pendent + /// [Serializable] [DefaultProperty("ActionBindings")] [ParseChildren(true, "ActionBindings"), PersistChildren(false)] @@ -29,25 +32,40 @@ public class ControllerBinding : AbstractBindingComponent private string controlID = ""; private Control controlInstance; private ControllerBinder binder; - private ActionBindingCollection actionBindings; - + private ActionBindingCollection actionBindings; + + /// + /// Initializes a new instance of the class. + /// public ControllerBinding() { actionBindings = new ActionBindingCollection(this); - } - + } + + /// + /// Initializes a new instance of the class. + /// + /// The binder. public ControllerBinding(ControllerBinder binder) : this() { Binder = binder; - } - + } + + /// + /// Gets or sets the binder. + /// + /// The binder. [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ControllerBinder Binder { get { return binder; } set { binder = value; } - } - + } + + /// + /// Gets or sets the control ID. + /// + /// The control ID. [Browsable(true)] [NotifyParentProperty(true)] [Description("The ID of the control to that is bound."), DefaultValue("")] @@ -65,8 +83,12 @@ public string ControlID ActionBindings.Clear(); } } - } - + } + + /// + /// Gets or sets the control instance. + /// + /// The control instance. [Browsable(false)] [NotifyParentProperty(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -85,24 +107,37 @@ public Control ControlInstance } } } - } - + } + + /// + /// Gets the action bindings. + /// + /// The action bindings. [Category("Behavior")] [PersistenceMode(PersistenceMode.InnerDefaultProperty)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ActionBindingCollection ActionBindings { get { return actionBindings; } - } - + } + + /// + /// Validates this instance. + /// protected override void Validate() { if (string.IsNullOrEmpty(controlID)) { this["ControlId"] = "must be specified"; } - } - + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString() { int actionCount = ActionBindings.Count; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBindingCollection.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBindingCollection.cs index 7cb880d22..1aef54bff 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBindingCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/ControllerBindingCollection.cs @@ -19,15 +19,26 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System; using System.Web.UI; + /// + /// Pendent + /// public class ControllerBindingCollection : TypedCollection { - private readonly ControllerBinder binder; - + private readonly ControllerBinder binder; + + /// + /// Initializes a new instance of the class. + /// + /// The binder. public ControllerBindingCollection(ControllerBinder binder) { this.binder = binder; - } - + } + + /// + /// Gets the with the specified control. + /// + /// public ControllerBinding this[Control control] { get @@ -38,8 +49,12 @@ public ControllerBinding this[Control control] } return this[control.ID]; } - } - + } + + /// + /// Gets the with the specified control id. + /// + /// public ControllerBinding this[string controlId] { get @@ -59,8 +74,13 @@ public ControllerBinding this[string controlId] return null; } - } - + } + + /// + /// Removes the specified control. + /// + /// The control. + /// public bool Remove(Control control) { if (control == null) @@ -69,8 +89,13 @@ public bool Remove(Control control) } return Remove(control.ID); - } - + } + + /// + /// Removes the specified control id. + /// + /// The control id. + /// public bool Remove(string controlId) { if (controlId == null) @@ -88,8 +113,14 @@ public bool Remove(string controlId) } return false; - } - + } + + /// + /// Performs additional custom processes after setting a value in the instance. + /// + /// The zero-based index at which oldValue can be found. + /// The value to replace with newValue. + /// The new value of the element at index. protected override void OnSetComplete(int index, object oldValue, object newValue) { ControllerBinding oldBinding = (ControllerBinding) oldValue; @@ -118,8 +149,13 @@ protected override void OnInsertComplete(int index, object value) PruneEmptyBindingsInDesignMode(); base.OnInsertComplete(index, value); - } - + } + + /// + /// Performs additional custom processes after removing an element from the instance. + /// + /// The zero-based index at which value can be found. + /// The value of the element to remove from index. protected override void OnRemoveComplete(int index, object value) { ControllerBinding binding = (ControllerBinding) value; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/DataBindingEvaluator.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/DataBindingEvaluator.cs index dae3c6bf7..f6a71ba02 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/DataBindingEvaluator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/DataBindingEvaluator.cs @@ -19,11 +19,20 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System; using System.Web.UI; + /// + /// Pendent + /// public class DataBindingEvaluator : IExpressionEvaluator { private static readonly char[] indexExprStartChars = { '[', '(' }; private static readonly char[] indexExprEndChars = { ']', ')' }; + /// + /// Evaluates the specified expression. + /// + /// The expression. + /// The context. + /// public object Evaluate(string expression, BindingContext context) { bool ignoreErrors; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditor.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditor.cs index ac379540f..d65e2cee8 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditor.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditor.cs @@ -22,13 +22,32 @@ namespace Castle.MonoRail.Framework.Views.Aspx.Design using System.Windows.Forms; using System.Windows.Forms.Design; + /// + /// Pendent + /// public class ActionArgumentEditor : UITypeEditor - { + { + /// + /// Gets the editor style used by the method. + /// + /// An that can be used to gain additional context information. + /// + /// A value that indicates the style of editor used by the method. If the does not support this method, then will return . + /// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; - } - + } + + /// + /// Edits the specified object's value using the editor style indicated by the method. + /// + /// An that can be used to gain additional context information. + /// An that this editor can use to obtain services. + /// The object to edit. + /// + /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed. + /// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditorForm.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditorForm.cs index 25793e201..dd41248ac 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditorForm.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ActionArgumentsEditorForm.cs @@ -23,11 +23,19 @@ namespace Castle.MonoRail.Framework.Views.Aspx.Design using System.Windows.Forms; using WebControl=System.Web.UI.Control; + /// + /// Pendent + /// public partial class ActionArgumentsEditorForm : Form { private readonly ActionArgumentCollection actionArgs; - private readonly ITypeDescriptorContext context; - + private readonly ITypeDescriptorContext context; + + /// + /// Initializes a new instance of the class. + /// + /// The action args. + /// The context. public ActionArgumentsEditorForm(ActionArgumentCollection actionArgs, ITypeDescriptorContext context) { diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/DesignUtil.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/DesignUtil.cs index adacad62c..2843b2db3 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/DesignUtil.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/DesignUtil.cs @@ -18,8 +18,17 @@ namespace Castle.MonoRail.Framework.Views.Aspx.Design { using System.Web; + /// + /// Pendent + /// public static class DesignUtil - { + { + /// + /// Gets a value indicating whether this instance is in design mode. + /// + /// + /// true if this instance is in design mode; otherwise, false. + /// public static bool IsInDesignMode { get { return HttpContext.Current == null; } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ITarget.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ITarget.cs index 62986ab61..99499a684 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ITarget.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/ITarget.cs @@ -16,8 +16,15 @@ namespace Castle.MonoRail.Framework.Views.Aspx.Design { + /// + /// Pendent + /// public interface ITarget - { + { + /// + /// Gets the property names. + /// + /// The property names. string[] PropertyNames { get; } } } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/StandardTarget.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/StandardTarget.cs index dd56c2c87..88c8a060d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/StandardTarget.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/Design/StandardTarget.cs @@ -19,12 +19,19 @@ namespace Castle.MonoRail.Framework.Views.Aspx.Design using System; using System.ComponentModel; + /// + /// Pendent + /// public class StandardTarget : ITarget { private readonly Type type; private readonly string name; - private string[] propertyNames; - + private string[] propertyNames; + + /// + /// Initializes a new instance of the class. + /// + /// The name. public StandardTarget(string name) { if (name == null) @@ -33,10 +40,14 @@ public StandardTarget(string name) } this.name = name; - } - - public StandardTarget(Type type, string name) - : this(name) + } + + /// + /// Initializes a new instance of the class. + /// + /// The type. + /// The name. + public StandardTarget(Type type, string name) : this(name) { if (type == null) { @@ -44,10 +55,14 @@ public StandardTarget(Type type, string name) } this.type = type; - } - - public StandardTarget(object instance, string name) - : this(name) + } + + /// + /// Initializes a new instance of the class. + /// + /// The instance. + /// The name. + public StandardTarget(object instance, string name) : this(name) { if (instance == null) { @@ -55,8 +70,12 @@ public StandardTarget(object instance, string name) } type = instance.GetType(); - } - + } + + /// + /// Gets the property names. + /// + /// The property names. public string[] PropertyNames { get @@ -68,13 +87,24 @@ public string[] PropertyNames } return propertyNames; } - } - + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// public override string ToString() { return name; - } - + } + + /// + /// Collects the property names. + /// + /// The type. + /// protected virtual string[] CollectPropertyNames(Type type) { if (type == null) return new string[0]; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventHandlerDelegate.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventHandlerDelegate.cs index 2e776cc16..5784b6a00 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventHandlerDelegate.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventHandlerDelegate.cs @@ -20,12 +20,20 @@ namespace Castle.MonoRail.Framework.Views.Aspx internal class EventHandlerDelegate : AbstractEventScope where EventArgType : EventArgs - { - public EventHandlerDelegate(BindingContext context) - : base(context) + { + /// + /// Initializes a new instance of the class. + /// + /// The context. + public EventHandlerDelegate(BindingContext context) : base(context) { - } - + } + + /// + /// Handles the event. + /// + /// The sender. + /// The e. public void HandleEvent(object sender, EventArgType e) { DispatchAction(sender, e); diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventListConverter.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventListConverter.cs index 9575464a8..96e082f75 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventListConverter.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/EventListConverter.cs @@ -20,8 +20,18 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.ComponentModel; using System.Web.UI; + /// + /// Pendent + /// public class EventListConverter : StringConverter - { + { + /// + /// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context. + /// + /// An that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null. + /// + /// A that holds a standard set of valid values, or null if the data type does not support a standard set of values. + /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context != null) @@ -41,8 +51,15 @@ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContex } return base.GetStandardValues(context); - } - + } + + /// + /// Returns whether this object supports a standard set of values that can be picked from a list, using the specified context. + /// + /// An that provides a format context. + /// + /// true if should be called to find a common set of values the object supports; otherwise, false. + /// public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { if (context != null) @@ -53,8 +70,15 @@ public override bool GetStandardValuesSupported(ITypeDescriptorContext context) } return false; - } - + } + + /// + /// Returns whether the collection of standard values returned from is an exclusive list of possible values, using the specified context. + /// + /// An that provides a format context. + /// + /// true if the returned from is an exhaustive list of possible values; false if other values are possible. + /// public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IBindingScope.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IBindingScope.cs index f5ac2dc85..5c0c92e3c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IBindingScope.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IBindingScope.cs @@ -1,29 +1,42 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System.Collections; - - public interface IBindingScope - { - object ResolveSymbol(string symbol); - - void AddActionArguments(BindingContext context, IDictionary actionArgs); - } -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System.Collections; + + /// + /// Pendent + /// + public interface IBindingScope + { + /// + /// Resolves the symbol. + /// + /// The symbol. + /// + object ResolveSymbol(string symbol); + + /// + /// Adds the action arguments. + /// + /// The context. + /// The action args. + void AddActionArguments(BindingContext context, IDictionary actionArgs); + } +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IControllerBinder.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IControllerBinder.cs index 0e6bb507c..4183765c9 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IControllerBinder.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IControllerBinder.cs @@ -1,39 +1,75 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System.Web.UI; - - public interface IControllerBinder : IBindingScope - { - bool DesignMode { get; } - - ControllerBindingCollection ControllerBindings { get; } - - ActionArgumentCollection ActionArguments { get; } - - bool IsBindableControl(Control control); - - ControllerBinding AddBinding(Control control); - - Control FindControlWithID(string controlID); - - string[] GetControllerActions(); - } -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System.Web.UI; + + /// + /// Pendent + /// + public interface IControllerBinder : IBindingScope + { + /// + /// Gets a value indicating whether [design mode]. + /// + /// true if [design mode]; otherwise, false. + bool DesignMode { get; } + + /// + /// Gets the controller bindings. + /// + /// The controller bindings. + ControllerBindingCollection ControllerBindings { get; } + + /// + /// Gets the action arguments. + /// + /// The action arguments. + ActionArgumentCollection ActionArguments { get; } + + /// + /// Determines whether [is bindable control] [the specified control]. + /// + /// The control. + /// + /// true if [is bindable control] [the specified control]; otherwise, false. + /// + bool IsBindableControl(Control control); + + /// + /// Adds the binding. + /// + /// The control. + /// + ControllerBinding AddBinding(Control control); + + /// + /// Finds the control with ID. + /// + /// The control ID. + /// + Control FindControlWithID(string controlID); + + /// + /// Gets the controller actions. + /// + /// + string[] GetControllerActions(); + } +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IExpressionEvaluator.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IExpressionEvaluator.cs index 9e34a92a2..04f750b4f 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IExpressionEvaluator.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/IExpressionEvaluator.cs @@ -16,8 +16,18 @@ namespace Castle.MonoRail.Framework.Views.Aspx { + + /// + /// Pendent + /// public interface IExpressionEvaluator { + /// + /// Evaluates the specified expression. + /// + /// The expression. + /// The context. + /// object Evaluate(string expression, BindingContext context); } } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/TypedCollection.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/TypedCollection.cs index 320e8aa6a..35105e5dc 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/TypedCollection.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/ControllerBinder/TypedCollection.cs @@ -1,87 +1,125 @@ -// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if NET - -namespace Castle.MonoRail.Framework.Views.Aspx -{ - using System; - using System.Collections; - using System.ComponentModel; - - public class TypedCollection : CollectionBase - where T : AbstractBindingComponent - { - public T this[int index] - { - get { return (T) List[index]; } - set { List[index] = value; } - } - - public void Add(T member) - { - List.Add(member); - } - - public void AddAt(int index, T member) - { - List.Insert(index, member); - } - - public void Remove(T member) - { - List.Remove(member); - } - - public bool Contains(T member) - { - return List.Contains(member); - } - - protected override void OnValidate(object value) - { - base.OnValidate(value); - - if (!(value is T)) - { - throw new ArgumentException(string.Format( - "Only {0} instances are supported by this collection.", typeof(T).Name)); - } - - AbstractBindingComponent properties = (AbstractBindingComponent) value; - - // We cannot throw the exception in Design Mode since the - // Set is never called to commit the update and so - // the collection may contain invalid values. - - if (!properties.IsValid() && !Design.DesignUtil.IsInDesignMode) - { - throw new ArgumentException(properties.Error); - } - } - - #region Hide Properties for the Designer - - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new int Capacity - { - get { return base.Capacity; } - set { base.Capacity = value; } - } - - #endregion - } -} - -#endif +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#if NET + +namespace Castle.MonoRail.Framework.Views.Aspx +{ + using System; + using System.Collections; + using System.ComponentModel; + + /// + /// Pendent + /// + /// + public class TypedCollection : CollectionBase + where T : AbstractBindingComponent + { + /// + /// Gets or sets the at the specified index. + /// + /// + public T this[int index] + { + get { return (T) List[index]; } + set { List[index] = value; } + } + + /// + /// Adds the specified member. + /// + /// The member. + public void Add(T member) + { + List.Add(member); + } + + /// + /// Adds at. + /// + /// The index. + /// The member. + public void AddAt(int index, T member) + { + List.Insert(index, member); + } + + /// + /// Removes the specified member. + /// + /// The member. + public void Remove(T member) + { + List.Remove(member); + } + + /// + /// Determines whether [contains] [the specified member]. + /// + /// The member. + /// + /// true if [contains] [the specified member]; otherwise, false. + /// + public bool Contains(T member) + { + return List.Contains(member); + } + + /// + /// Performs additional custom processes when validating a value. + /// + /// The object to validate. + protected override void OnValidate(object value) + { + base.OnValidate(value); + + if (!(value is T)) + { + throw new ArgumentException(string.Format( + "Only {0} instances are supported by this collection.", typeof(T).Name)); + } + + AbstractBindingComponent properties = (AbstractBindingComponent) value; + + // We cannot throw the exception in Design Mode since the + // Set is never called to commit the update and so + // the collection may contain invalid values. + + if (!properties.IsValid() && !Design.DesignUtil.IsInDesignMode) + { + throw new ArgumentException(properties.Error); + } + } + + #region Hide Properties for the Designer + + /// + /// Gets or sets the number of elements that the can contain. + /// + /// + /// The number of elements that the can contain. + /// is set to a value that is less than . + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new int Capacity + { + get { return base.Capacity; } + set { base.Capacity = value; } + } + + #endregion + } +} + +#endif diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/InvokeHelper.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/InvokeHelper.cs index 9144e513b..be5ae07ee 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/InvokeHelper.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/InvokeHelper.cs @@ -28,6 +28,9 @@ public class InvokeHelper : Control private object[] _args; private object _arg; + /// + /// Initializes a new instance of the class. + /// public InvokeHelper() { } @@ -72,12 +75,18 @@ public object Arg set { _arg = value; } } - + /// + /// Gets the controller. + /// + /// The controller. protected Controller Controller { get { return (Controller) Context.Items[Constants.ControllerContextKey]; } } + /// + /// Binds a data source to the invoked server control and all its child controls. + /// public override void DataBind() { base.DataBind(); @@ -92,6 +101,10 @@ public override void DataBind() } } + /// + /// Sends server control content to a provided object, which writes the content to be rendered on the client. + /// + /// The object that receives the server control content. protected override void Render(HtmlTextWriter writer) { DataBind(); diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/MasterPageBase.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/MasterPageBase.cs index a33cbcffc..01796fb4c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/MasterPageBase.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/MasterPageBase.cs @@ -19,12 +19,16 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.Web.UI; /// - /// Summary description for MasterPageBase. + /// Pendent /// public class MasterPageBase : Page { private const String ViewStateKey = "__MASTERVIEWSTATE"; + /// + /// Loads any saved view-state information to the object. + /// + /// The saved view state. protected override object LoadPageStateFromPersistenceMedium() { String viewState = Request.Params[ViewStateKey]; @@ -40,6 +44,10 @@ protected override object LoadPageStateFromPersistenceMedium() } } + /// + /// Saves the page state to persistence medium. + /// + /// State of the view. protected override void SavePageStateToPersistenceMedium(object viewState) { using(StringWriter writer = new StringWriter()) diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormUtils.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormUtils.cs index aa31f8dcc..4d3724099 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormUtils.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormUtils.cs @@ -19,6 +19,9 @@ namespace Castle.MonoRail.Framework.Views.Aspx using System.Web.UI; using System.Reflection; + /// + /// Pendent + /// public static class WebFormUtils { private static readonly BindingFlags BindingFlagsGet diff --git a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormsViewEngine.cs b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormsViewEngine.cs index 3e1d5f172..971435e7c 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormsViewEngine.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/Aspx/WebFormsViewEngine.cs @@ -32,27 +32,50 @@ public class WebFormsViewEngine : ViewEngineBase private static readonly BindingFlags PropertyBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase; + /// + /// Initializes a new instance of the class. + /// public WebFormsViewEngine() { } #region ViewEngineBase overrides + /// + /// Gets a value indicating whether the view engine + /// support the generation of JS. + /// + /// + /// true if JS generation is supported; otherwise, false. + /// public override bool SupportsJSGeneration { get { return false; } } + /// + /// Gets the view file extension. + /// + /// The view file extension. public override string ViewFileExtension { get { return ".aspx"; } } + /// + /// Gets the JS generator file extension. + /// + /// The JS generator file extension. public override string JSGeneratorFileExtension { get { throw new NotImplementedException(); } } + /// + /// Evaluates whether the specified template exists. + /// + /// + /// true if it exists public override bool HasTemplate(String templateName) { return ViewSourceLoader.HasTemplate(templateName + ".aspx"); @@ -92,29 +115,64 @@ public override void Process(IRailsEngineContext context, Controller controller, ProcessInlineView(controller, viewName, httpContext); } + /// + /// Processes the view - using the templateName + /// to obtain the correct template + /// and writes the results to the System.IO.TextWriter. + /// + /// + /// + /// + /// public override void Process(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Processes the partial. + /// + /// The output. + /// The context. + /// The controller. + /// The partial name. public override void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, string partialName) { throw new NotImplementedException(); } + /// + /// Creates the JS generator. + /// + /// The context. + /// public override object CreateJSGenerator(IRailsEngineContext context) { throw new NotImplementedException(); } + /// + /// Generates the JS. + /// + /// The output. + /// The context. + /// The controller. + /// Name of the template. public override void GenerateJS(TextWriter output, IRailsEngineContext context, Controller controller, string templateName) { throw new NotImplementedException(); } + /// + /// Wraps the specified content in the layout using the + /// context to output the result. + /// + /// + /// + /// public override void ProcessContents(IRailsEngineContext context, Controller controller, String contents) { AdjustContentType(context); @@ -426,7 +484,12 @@ internal class ExecutePageProvider : IMonoRailHttpHandlerProvider private Page page; private string viewName; private WebFormsViewEngine engine; - + + /// + /// Initializes a new instance of the class. + /// + /// The engine. + /// Name of the view. public ExecutePageProvider(WebFormsViewEngine engine, string viewName) { this.page = null; @@ -434,6 +497,11 @@ public ExecutePageProvider(WebFormsViewEngine engine, string viewName) this.viewName = viewName; } + /// + /// Executes the page. + /// + /// The context. + /// public Page ExecutePage(IRailsEngineContext context) { HttpContext httpContext = context.UnderlyingContext; @@ -443,6 +511,14 @@ public Page ExecutePage(IRailsEngineContext context) return page; } + /// + /// Implementors should perform their logic to + /// return a instance of . + /// If the can not be created, + /// it should return null. + /// + /// + /// public IHttpHandler ObtainMonoRailHttpHandler(IRailsEngineContext context) { HttpContext httpContext = context.UnderlyingContext; @@ -465,6 +541,12 @@ public IHttpHandler ObtainMonoRailHttpHandler(IRailsEngineContext context) return page; } + /// + /// Implementors should perform their logic + /// to release the instance + /// and its resources. + /// + /// public void ReleaseHandler(IHttpHandler handler) { @@ -478,11 +560,19 @@ internal class DelegateMemoryStream : MemoryStream { public Stream _original; + /// + /// Initializes a new instance of the class. + /// + /// The original. public DelegateMemoryStream(Stream original) { _original = original; } + /// + /// Gets the original stream. + /// + /// The original stream. public Stream OriginalStream { get { return _original; } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/EmbeddedResourceViewSource.cs b/MonoRail/Castle.MonoRail.Framework/Views/EmbeddedResourceViewSource.cs index 345a12ad9..69251d446 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/EmbeddedResourceViewSource.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/EmbeddedResourceViewSource.cs @@ -20,35 +20,56 @@ namespace Castle.MonoRail.Framework.Views using Castle.MonoRail.Framework.Internal; /// - /// + /// Represents a view source embedded as an assembly resource. /// public class EmbeddedResourceViewSource : IViewSource { private readonly AssemblySourceInfo sourceInfo; private readonly string templateName; + /// + /// Initializes a new instance of the class. + /// + /// Name of the template. + /// The source info. public EmbeddedResourceViewSource(String templateName, AssemblySourceInfo sourceInfo) { this.templateName = templateName; this.sourceInfo = sourceInfo; } + /// + /// Opens the view stream. + /// + /// public Stream OpenViewStream() { return sourceInfo.GetTemplateStream(templateName); } + /// + /// Gets the last modified. + /// + /// The last modified. public long LastModified { get { return DateTime.MinValue.Ticks; } } + /// + /// Gets or sets the last updated. + /// + /// The last updated. public long LastUpdated { get { return DateTime.MinValue.Ticks; } set { ; } } + /// + /// Gets a value indicating whether cache is enabled for it. + /// + /// true if cache is enabled for it; otherwise, false. public bool EnableCache { get { return true; } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/FileAssemblyViewSourceLoader.cs b/MonoRail/Castle.MonoRail.Framework/Views/FileAssemblyViewSourceLoader.cs index 94bb994ca..e4bd9759d 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/FileAssemblyViewSourceLoader.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/FileAssemblyViewSourceLoader.cs @@ -23,17 +23,22 @@ namespace Castle.MonoRail.Framework using Castle.MonoRail.Framework.Views; /// - /// Pendent + /// Default implementation + /// that uses the file system and assembly source as source of view templates /// public class FileAssemblyViewSourceLoader : IViewSourceLoader, IServiceEnabledComponent { - private IList additionalSources = ArrayList.Synchronized(new ArrayList()); + private readonly IList additionalSources = ArrayList.Synchronized(new ArrayList()); private String viewRootDir; private bool enableCache = true; private FileSystemWatcher viewFolderWatcher; #region IServiceEnabledComponent implementation + /// + /// Services the specified provider. + /// + /// The provider. public void Service(IServiceProvider provider) { MonoRailConfiguration config = (MonoRailConfiguration)provider.GetService(typeof(MonoRailConfiguration)); @@ -54,6 +59,7 @@ public void Service(IServiceProvider provider) /// /// Evaluates whether the specified template exists. /// + /// The template name /// true if it exists public bool HasTemplate(String templateName) { @@ -65,6 +71,11 @@ public bool HasTemplate(String templateName) return HasTemplateOnAssemblies(templateName); } + /// + /// Builds and returns a representation of a view template + /// + /// The template name + /// public IViewSource GetViewSource(String templateName) { FileInfo fileInfo = CreateFileInfo(templateName); @@ -80,9 +91,9 @@ public IViewSource GetViewSource(String templateName) } /// - /// + /// Gets a list of views on the specified directory /// - /// + /// Directory name /// public String[] ListViews(String dirName) { @@ -105,14 +116,19 @@ public String ViewRootDir } /// - /// + /// Gets or sets whether the instance should use cache /// + /// public bool EnableCache { get { return enableCache; } set { enableCache = value; } } + /// + /// Gets a list of assembly sources + /// + /// public IList AssemblySources { get { return additionalSources; } @@ -163,7 +179,7 @@ public event FileSystemEventHandler ViewChanged } } - private event FileSystemEventHandler ViewChangedImpl; + private event FileSystemEventHandler ViewChangedImpl = delegate { }; private void DisposeViewFolderWatch() { @@ -183,19 +199,19 @@ private void InitViewFolderWatch() viewFolderWatcher.Changed += new FileSystemEventHandler(viewFolderWatcher_Changed); viewFolderWatcher.Created += new FileSystemEventHandler(viewFolderWatcher_Changed); viewFolderWatcher.Deleted += new FileSystemEventHandler(viewFolderWatcher_Changed); + viewFolderWatcher.Renamed += new RenamedEventHandler(viewFolderWatcher_Renamed); viewFolderWatcher.EnableRaisingEvents = true; } } - private void viewFolderWatcher_Changed(object sender, FileSystemEventArgs e) + private void viewFolderWatcher_Renamed(object sender, RenamedEventArgs e) { - //shouldn't ever happen, because we make sure that the watcher is only - //active when there are subscribers, but checking will prevent possible concrureny issues with it. + ViewChangedImpl(this, e); + } - if (ViewChangedImpl != null) - { - ViewChangedImpl(this, e); - } + private void viewFolderWatcher_Changed(object sender, FileSystemEventArgs e) + { + ViewChangedImpl(this, e); } #endregion diff --git a/MonoRail/Castle.MonoRail.Framework/Views/FileViewSource.cs b/MonoRail/Castle.MonoRail.Framework/Views/FileViewSource.cs index 6163f2474..fb706e337 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/FileViewSource.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/FileViewSource.cs @@ -17,7 +17,7 @@ namespace Castle.MonoRail.Framework.Views using System.IO; /// - /// Pendent + /// Represents a view template source on the file system. /// public class FileViewSource : IViewSource { @@ -25,6 +25,11 @@ public class FileViewSource : IViewSource private readonly bool enableCache; private long lastUpdated; + /// + /// Initializes a new instance of the class. + /// + /// The file info. + /// if set to true [enable cache]. public FileViewSource(FileInfo fileInfo, bool enableCache) { this.fileInfo = fileInfo; @@ -33,6 +38,10 @@ public FileViewSource(FileInfo fileInfo, bool enableCache) lastUpdated = LastModified; } + /// + /// Opens the view stream. + /// + /// public Stream OpenViewStream() { lastUpdated = LastModified; @@ -40,21 +49,32 @@ public Stream OpenViewStream() return fileInfo.OpenRead(); } + /// + /// Gets a value indicating whether cache is enabled for it. + /// + /// true if cache is enabled for it; otherwise, false. public bool EnableCache { get { return enableCache; } } + /// + /// Gets or sets the last updated. + /// + /// The last updated. public long LastUpdated { get { return lastUpdated; } set { lastUpdated = value; } } + /// + /// Gets the last modified. + /// + /// The last modified. public long LastModified { get { return File.GetLastWriteTime(fileInfo.FullName).Ticks; } } - } } diff --git a/MonoRail/Castle.MonoRail.Framework/Views/ViewEngineBase.cs b/MonoRail/Castle.MonoRail.Framework/Views/ViewEngineBase.cs index da2682e39..4b1b68660 100644 --- a/MonoRail/Castle.MonoRail.Framework/Views/ViewEngineBase.cs +++ b/MonoRail/Castle.MonoRail.Framework/Views/ViewEngineBase.cs @@ -29,6 +29,10 @@ public abstract class ViewEngineBase : IViewEngine, IServiceEnabledComponent private bool xhtmlRendering; private IViewSourceLoader viewSourceLoader; private ILogger logger = NullLogger.Instance; + + /// + /// The service provider instance + /// protected IServiceProvider serviceProvider; #region IServiceEnabledComponent implementation @@ -112,15 +116,45 @@ public bool XHtmlRendering /// public abstract void Process(TextWriter output, IRailsEngineContext context, Controller controller, String templateName); + /// + /// Should process the specified partial. The partial name must contains + /// the path relative to the views folder. + /// + /// The output. + /// The request context. + /// The controller. + /// The partial name. public abstract void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, string partialName); + /// + /// Implementors should return a generator instance if + /// the view engine supports JS generation. + /// + /// The request context. + /// A JS generator instance public abstract object CreateJSGenerator(IRailsEngineContext context); + /// + /// Processes the js generation view template - using the templateName + /// to obtain the correct template, and using the context to output the result. + /// + /// The request context. + /// The controller. + /// Name of the template. public virtual void GenerateJS(IRailsEngineContext context, Controller controller, string templateName) { GenerateJS(context.Response.Output, context, controller, templateName); } + /// + /// Processes the js generation view template - using the templateName + /// to obtain the correct template, and using the specified + /// to output the result. + /// + /// The output. + /// The request context. + /// The controller. + /// Name of the template. public abstract void GenerateJS(TextWriter output, IRailsEngineContext context, Controller controller, string templateName); /// @@ -133,11 +167,21 @@ public virtual void GenerateJS(IRailsEngineContext context, Controller controlle #region Pre/Post send view + /// + /// Invokes the + /// + /// The controller. + /// The view argument. protected virtual void PreSendView(Controller controller, object view) { controller.PreSendView(view); } + /// + /// Invokes the + /// + /// The controller. + /// The view argument. protected virtual void PostSendView(Controller controller, object view) { controller.PostSendView(view); @@ -147,12 +191,20 @@ protected virtual void PostSendView(Controller controller, object view) #region Useful properties + /// + /// Gets or sets the view source loader. + /// + /// The view source loader. protected IViewSourceLoader ViewSourceLoader { get { return viewSourceLoader; } set { viewSourceLoader = value; } } + /// + /// Gets the logger. + /// + /// The logger. protected ILogger Logger { get { return logger; } diff --git a/MonoRail/Castle.MonoRail.Framework/WizardActionProvider.cs b/MonoRail/Castle.MonoRail.Framework/WizardActionProvider.cs index 69b5b17b6..f9bde3479 100644 --- a/MonoRail/Castle.MonoRail.Framework/WizardActionProvider.cs +++ b/MonoRail/Castle.MonoRail.Framework/WizardActionProvider.cs @@ -23,12 +23,12 @@ namespace Castle.MonoRail.Framework /// /// Provide easy to use Wizard-like support. /// + /// /// - /// We use the DynamicAction infrastructure to provide - /// wizard support as we dont force + /// MonoRail uses the DynamicAction infrastructure to provide + /// wizard support so we dont force /// the programmer to inherit from a specific Controller - /// which can be quite undesirable in common business projects - /// situations. + /// which can be quite undesirable in real world projects. /// /// Nevertheless we do require that the programmer /// implements on the wizard controller. @@ -231,11 +231,22 @@ private void OnStepActionRequested(Controller controller) } } + /// + /// Represents an empty (no-op) action. + /// + /// The controller. protected void EmptyAction(Controller controller) { controller.CancelView(); } + /// + /// Determines whether all wizard specific information is on the user session. + /// + /// The controller. + /// + /// true if has session data; otherwise, false. + /// protected bool HasRequiredSessionData(Controller controller) { String wizardName = WizardUtils.ConstructWizardNamespace(controller); @@ -246,6 +257,14 @@ protected bool HasRequiredSessionData(Controller controller) context.Session.Contains(wizardName + "currentstep")); } + /// + /// Starts the wizard by adding the required information to the + /// session and invoking + /// and detecting the first step. + /// + /// The controller. + /// if set to true, a redirect + /// will be issued to the first step. protected void StartWizard(Controller controller, bool redirect) { ResetSteps(controller); @@ -271,6 +290,11 @@ protected void StartWizard(Controller controller, bool redirect) } } + /// + /// Resets the steps by invoking + /// on all steps instances. + /// + /// The controller. protected void ResetSteps(Controller controller) { IWizardController wizardController = controller as IWizardController; diff --git a/MonoRail/Castle.MonoRail.Framework/WizardStepPage.cs b/MonoRail/Castle.MonoRail.Framework/WizardStepPage.cs index d46718a96..90faa6fcf 100644 --- a/MonoRail/Castle.MonoRail.Framework/WizardStepPage.cs +++ b/MonoRail/Castle.MonoRail.Framework/WizardStepPage.cs @@ -23,19 +23,26 @@ namespace Castle.MonoRail.Framework using Castle.MonoRail.Framework.Internal; /// - /// Represents a wizard step. + /// Represents a wizard step. In essence it is a controller, but with some subtle differences. + /// See the remarks for more information. /// + /// + /// + /// + /// /// /// Implementors can optionally override /// to customize the accessible action name and /// in order to define which view /// should be used (defaults to the step name) + /// /// /// Please note that an step might have actions as well, but it follows a different /// convention to be accessed. You must use the wizard controller name, slash, the /// step name, hifen, the action name. For example /MyWizard/AddressInformation-GetCountries.rails /// Which would access the following action /// + /// /// /// public class AddressInformation : WizardStepPage /// { @@ -45,8 +52,11 @@ namespace Castle.MonoRail.Framework /// } /// } /// - /// Note that the RedirectToAction will always send to an internal action, so you should - /// omit the controller name for that. + /// + /// Note that the RedirectToAction will always send to an internal action, so you should + /// omit the controller name for that. + /// + /// /// /// You can use a family of redirect methods to go back and forward on the wizard's /// steps. @@ -62,10 +72,17 @@ public abstract class WizardStepPage : SmartDispatcherController #region Constructors + /// + /// Initializes a new instance of the class. + /// public WizardStepPage() { } + /// + /// Initializes a new instance of the class. + /// + /// The binder. public WizardStepPage(IDataBinder binder) : base(binder) { } @@ -74,6 +91,10 @@ public WizardStepPage(IDataBinder binder) : base(binder) #region Useful Properties + /// + /// Gets the wizard controller. + /// + /// The wizard controller. public Controller WizardController { get { return _wizardcontroller; } @@ -148,6 +169,15 @@ protected internal virtual bool IsPreConditionSatisfied(IRailsEngineContext cont return true; } + /// + /// Uses a simple heuristic to select the best method -- especially in the + /// case of method overloads. + /// + /// The action name + /// The avaliable actions + /// The request instance + /// The custom arguments for the action + /// protected internal override MethodInfo SelectMethod(String action, IDictionary actions, IRequest request, IDictionary actionArgs) { if (action == "RenderWizardView") diff --git a/MonoRail/Castle.MonoRail.TestSupport.Tests/BaseControllerBugsTestCase.cs b/MonoRail/Castle.MonoRail.TestSupport.Tests/BaseControllerBugsTestCase.cs new file mode 100644 index 000000000..02b28f5ae --- /dev/null +++ b/MonoRail/Castle.MonoRail.TestSupport.Tests/BaseControllerBugsTestCase.cs @@ -0,0 +1,34 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.MonoRail.TestSupport.Tests +{ + using Controllers; + using NUnit.Framework; + + [TestFixture] + public class BaseControllerBugsTestCase : BaseControllerTest + { + [Test] + public void MR_343_PrepareController_Overload_Throws_ArgumentNullException() + { + BugsController controller = new BugsController(); + PrepareController(controller); // Thrown Here + + controller.TestAction(); + + Assert.AreEqual("Filled", controller.PropertyBag["MyProperty"]); + } + } +} diff --git a/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests-vs2005.csproj b/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests-vs2005.csproj new file mode 100644 index 000000000..3520e0c4f --- /dev/null +++ b/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests-vs2005.csproj @@ -0,0 +1,61 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {27FF38D9-DC85-4AF8-B4CE-C6C24B7F01E9} + Library + Castle.MonoRail.TestSupport.Tests + Castle.MonoRail.TestSupport.Tests + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\build\net-2.0\debug\nunit.framework.dll + + + + + + + + + + + + + {EC393863-333E-49CE-94A6-654B9F323954} + Castle.MonoRail.Framework-vs2005 + + + {E572DC59-2A96-482F-BE39-E938AB47EA9D} + Castle.MonoRail.TestSupport-vs2005 + + + + + \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests.build b/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests.build new file mode 100644 index 000000000..d6a857dc9 --- /dev/null +++ b/MonoRail/Castle.MonoRail.TestSupport.Tests/Castle.MonoRail.TestSupport.Tests.build @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MonoRail/Castle.MonoRail.TestSupport.Tests/Controllers/BugsController.cs b/MonoRail/Castle.MonoRail.TestSupport.Tests/Controllers/BugsController.cs new file mode 100644 index 000000000..6295b56ae --- /dev/null +++ b/MonoRail/Castle.MonoRail.TestSupport.Tests/Controllers/BugsController.cs @@ -0,0 +1,26 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.MonoRail.TestSupport.Tests.Controllers +{ + using Framework; + + public class BugsController : Controller + { + public void TestAction() + { + PropertyBag["MyProperty"] = "Filled"; + } + } +} diff --git a/MonoRail/Castle.MonoRail.TestSupport/AbstractMRTestCase.cs b/MonoRail/Castle.MonoRail.TestSupport/AbstractMRTestCase.cs index 6e8968b4a..2177efd77 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/AbstractMRTestCase.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/AbstractMRTestCase.cs @@ -29,8 +29,9 @@ namespace Castle.MonoRail.TestSupport /// /// Base class for tests cases using the ASP.Net Runtime - /// to run the web project + /// to run the web project. Deprecated. /// + [Obsolete("Prefer the BaseControllerTest")] public abstract class AbstractMRTestCase { private static readonly String PhysicalWebDirConfigKey = "web.physical.dir"; diff --git a/MonoRail/Castle.MonoRail.TestSupport/BaseControllerTest.cs b/MonoRail/Castle.MonoRail.TestSupport/BaseControllerTest.cs index fdd8b4665..f07184269 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/BaseControllerTest.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/BaseControllerTest.cs @@ -25,8 +25,78 @@ namespace Castle.MonoRail.TestSupport public delegate void ContextInitializer(MockRailsEngineContext context); /// - /// Pendent + /// Base class that set ups the necessary infrastructure + /// to test controllers without the need + /// for an ASP.Net Runtime. /// + /// + /// + /// The following code is an example of a controller test: + /// + /// + /// [TestFixture] + /// public class LoginControllerTestCase : BaseControllerTest + /// { + /// private LoginController controller; + /// + /// [SetUp] + /// public void Init() + /// { + /// controller = new LoginController(); + /// PrepareController(controller); + /// } + /// + /// [Test] + /// public void Authenticate_Should_Use_The_AuthenticationService() + /// { + /// // set up a mock authentication service before + /// + /// controller.Authenticate("username", "my password", false); + /// + /// Assert.AreEqual(3, controller.PropertyBag.Count); + /// Assert.AreEqual("username", controller.PropertyBag["username"]); + /// Assert.AreEqual("my password", controller.PropertyBag["password"]); + /// Assert.AreEqual(false, controller.PropertyBag["autoLogin"]); + /// } + /// } + /// + /// + /// + /// The following is a more sophisticate test for an action that sends emails. + /// + /// + /// + /// [Test] + /// public void Register_Should_Add_Registration_Using_The_Repository() + /// { + /// Registration reg = new Registration("John Doe", "johndoe@gmail.com"); + /// + /// using(mockRepository.Record()) + /// { + /// registrationRepositoryMock.Add(reg); + /// } + /// + /// using(mockRepository.Playback()) + /// { + /// controller.Register(reg); // This action sends two emails + /// + /// Assert.IsTrue(HasRenderedEmailTemplateNamed("emailToManager")); + /// Assert.IsTrue(HasRenderedEmailTemplateNamed("emailToParticipant")); + /// + /// Assert.AreEqual("manager@gmail.com", MessagesSent[0].To); + /// Assert.AreEqual("johndoe@gmail.com", MessagesSent[1].To); + /// + /// Assert.AreEqual("Registration\\Success", controller.SelectedViewName); + /// } + /// } + /// + /// + /// + /// + /// + /// You must invoke -- or a different overload - + /// before making invocations to the controller. + /// public abstract class BaseControllerTest { private readonly string domain; @@ -39,10 +109,19 @@ public abstract class BaseControllerTest private ITrace trace; private IDictionary cookies; + /// + /// Initializes a new instance of the class. + /// protected BaseControllerTest() : this("app.com", "www", 80) { } + /// + /// Initializes a new instance of the class. + /// + /// The domain. + /// The domain prefix. + /// The port. protected BaseControllerTest(string domain, string domainPrefix, int port) { this.domain = domain; @@ -50,52 +129,115 @@ protected BaseControllerTest(string domain, string domainPrefix, int port) this.port = port; } + /// + /// Override to perform any pre-test set up + /// protected virtual void OnSetUp() { } + /// + /// Gets the cookies. + /// + /// The cookies. public IDictionary Cookies { get { return cookies; } } + /// + /// Gets the context. + /// + /// The context. protected IRailsEngineContext Context { get { return context; } } + /// + /// Gets the request. + /// + /// The request. public IRequest Request { get { return request; } } + /// + /// Gets the response. + /// + /// The response. public IMockResponse Response { get { return response; } } + /// + /// Gets the trace. + /// + /// The trace. public ITrace Trace { get { return trace; } } + /// + /// Prepares the controller giving it mock implementations + /// of the service it requires to function normally. + /// + /// The controller. protected void PrepareController(Controller controller) { - PrepareController(controller, null); + PrepareController(controller, InitializeRailsEngineContext); } + /// + /// Prepares the controller giving it mock implementations + /// of the service it requires to function normally. + /// + /// The controller. + /// The context initializer. protected void PrepareController(Controller controller, ContextInitializer contextInitializer) { - PrepareController(controller, "", "Controller", "Action"); + PrepareController(controller, "", "Controller", "Action", contextInitializer); } + /// + /// Prepares the controller giving it mock implementations + /// of the service it requires to function normally. + /// + /// The controller. + /// Name of the controller. + /// Name of the action. protected void PrepareController(Controller controller, string controllerName, string actionName) { PrepareController(controller, "", controllerName, actionName); } + /// + /// Prepares the controller giving it mock implementations + /// of the service it requires to function normally. + /// + /// The controller. + /// Name of the area (cannot be null). + /// Name of the controller. + /// Name of the action. protected void PrepareController(Controller controller, string areaName, string controllerName, string actionName) + { + PrepareController(controller, areaName, controllerName, actionName, InitializeRailsEngineContext); + } + + /// + /// Prepares the controller giving it mock implementations + /// of the service it requires to function normally. + /// + /// The controller. + /// Name of the area (cannot be null). + /// Name of the controller. + /// Name of the action. + /// The context initializer. + protected void PrepareController(Controller controller, string areaName, string controllerName, string actionName, ContextInitializer contextInitializer) { if (controller == null) { @@ -113,10 +255,13 @@ protected void PrepareController(Controller controller, string areaName, string { throw new ArgumentNullException("actionName"); } + if( contextInitializer == null) { + throw new ArgumentNullException("contextInitializer"); + } cookies = new HybridDictionary(true); - BuildRailsContext(areaName, controllerName, actionName); + BuildRailsContext(areaName, controllerName, actionName, contextInitializer); controller.InitializeFieldsFromServiceProvider(context); controller.InitializeControllerState(areaName, controllerName, actionName); ControllerLifecycleExecutor executor = new ControllerLifecycleExecutor(controller, context); @@ -124,36 +269,83 @@ protected void PrepareController(Controller controller, string areaName, string executor.InitializeController(controller.AreaName, controller.Name, controller.Action); } + /// + /// Constructs a mock context. + /// + /// Name of the area. + /// Name of the controller. + /// Name of the action. protected void BuildRailsContext(string areaName, string controllerName, string actionName) + { + BuildRailsContext(areaName, controllerName, actionName, InitializeRailsEngineContext); + } + + /// + /// Constructs a mock context. + /// + /// Name of the area. + /// Name of the controller. + /// Name of the action. + /// The context initializer. + protected void BuildRailsContext(string areaName, string controllerName, string actionName, ContextInitializer contextInitializer) { UrlInfo info = BuildUrlInfo(areaName, controllerName, actionName); request = BuildRequest(); response = BuildResponse(); trace = BuildTrace(); context = BuildRailsEngineContext(request, response, trace, info); + contextInitializer(context); } + /// + /// Builds the request. + /// + /// protected virtual IRequest BuildRequest() { return new MockRequest(cookies); } + /// + /// Builds the response. + /// + /// protected virtual IMockResponse BuildResponse() { return new MockResponse(cookies); } + /// + /// Builds the trace. + /// + /// protected virtual ITrace BuildTrace() { return new MockTrace(); } + /// + /// Builds the a mock context. You can override this method to + /// create a special configured mock context. + /// + /// The request. + /// The response. + /// The trace. + /// The URL info. + /// protected virtual MockRailsEngineContext BuildRailsEngineContext(IRequest request, IResponse response, ITrace trace, UrlInfo urlInfo) { return new MockRailsEngineContext(request, response, trace, urlInfo); } + /// + /// Builds the URL info that represents the contextual Url. + /// + /// Name of the area. + /// Name of the controller. + /// Name of the action. + /// protected virtual UrlInfo BuildUrlInfo(string areaName, string controllerName, string actionName) { return new UrlInfo(domain, domainPrefix, virtualDir, "http", port, @@ -161,6 +353,20 @@ protected virtual UrlInfo BuildUrlInfo(string areaName, string controllerName, s areaName, controllerName, actionName, "rails"); } + /// + /// Allows modifying of the engine context created by + /// + /// The engine context to modify + protected virtual void InitializeRailsEngineContext(MockRailsEngineContext mockRailsEngineContext) + {} + + /// + /// Determines whether a specified template was rendered -- to send an email. + /// + /// Name of the template. + /// + /// true if was rendered; otherwise, false. + /// protected bool HasRenderedEmailTemplateNamed(string templateName) { MockRailsEngineContext.RenderedEmailTemplate template = @@ -173,11 +379,19 @@ protected bool HasRenderedEmailTemplateNamed(string templateName) return template != null; } + /// + /// Gets the fake email messages sent. + /// + /// The messages sent. protected Message[] MessagesSent { get { return context.MessagesSent.ToArray(); } } + /// + /// Gets the rendered email templates. + /// + /// The rendered email templates. protected MockRailsEngineContext.RenderedEmailTemplate[] RenderedEmailTemplates { get { return context.RenderedEmailTemplates.ToArray(); } diff --git a/MonoRail/Castle.MonoRail.TestSupport/BaseViewComponentTest.cs b/MonoRail/Castle.MonoRail.TestSupport/BaseViewComponentTest.cs index 33d4f651f..f562b7720 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/BaseViewComponentTest.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/BaseViewComponentTest.cs @@ -20,21 +20,95 @@ namespace Castle.MonoRail.TestSupport using Castle.MonoRail.Framework; using Castle.MonoRail.Framework.Test; + /// + /// Base class to test view components. + /// + /// + /// + /// The following test makes sure the component rendered the inner sections correctly. + /// + /// [TestFixture] + /// public class DiggStylePaginationTestCase : BaseViewComponentTest + /// { + /// private DiggStylePagination diggComponent; + /// private IPaginatedPage singlePage, secondPageOfThree; + /// + /// [SetUp] + /// public void Init() + /// { + /// diggComponent = new DiggStylePagination(); + /// singlePage = new Page(new string[] { "a", "b", "c" }, 1, 4, 1); + /// secondPageOfThree = new Page(new string[] { "a", "b", "c", "d" }, 2, 4, 10); + /// } + /// + /// [TearDown] + /// public void Terminate() + /// { + /// CleanUp(); + /// } + /// + /// [Test] + /// public void PageWithNoLinksInvokesStartAndEndSections() + /// { + /// List<string> actions = new List<string>(); + /// // pass mock inner sections to component + /// SectionRender["startblock"] = delegate(IDictionary context, TextWriter writer) { actions.Add("started"); }; + /// SectionRender["endblock"] = delegate(IDictionary context, TextWriter writer) { actions.Add("ended"); }; + /// SectionRender["link"] = delegate(IDictionary context, TextWriter writer) { actions.Add("link"); }; + /// + /// diggComponent.Page = singlePage; + /// + /// PrepareViewComponent(diggComponent); + /// diggComponent.Render(); + /// + /// // make sure component "rendered" inner sections + /// Assert.AreEqual(2, actions.Count); + /// Assert.AreEqual("started", actions[0]); + /// Assert.AreEqual("ended", actions[1]); + /// } + /// } + /// + /// + /// + /// + /// You must call before testing a view component instance + /// and you should call after each test case (use the TearDown). + /// public abstract class BaseViewComponentTest : BaseControllerTest { private IMockViewComponentContext componentContext; private IViewEngine viewEngine; private StringWriter writer; + /// + /// Use this dictionary to add inner sections as available inner sections to + /// the view component. + /// public IDictionary SectionRender; - public TestSectionRender OnBodyRender; + + /// + /// This delegate is called when the viewcomponent renders its body. + /// + public TestSectionRender OnBodyRender; + + /// + /// This delegate is called when the viewcomponent renders a view + /// public TestViewRender OnViewRender; + /// + /// Initializes a new instance of the class. + /// protected BaseViewComponentTest() { CleanUp(); } + /// + /// Initialize the view component with mock services it needs to + /// be functional. + /// + /// The component instance. protected void PrepareViewComponent(ViewComponent component) { if (Context == null) @@ -49,11 +123,18 @@ protected void PrepareViewComponent(ViewComponent component) component.Init(Context, componentContext); } + /// + /// Gets the output -- ie what the viewcomponent wrote to the output stream. + /// + /// The output. protected string Output { get { return writer.ToString(); } } + /// + /// Cleans the up all state created to test a view component. + /// protected void CleanUp() { writer = new StringWriter(); @@ -62,11 +143,20 @@ protected void CleanUp() OnViewRender = null; } + /// + /// Builds the view engine. + /// + /// protected virtual IViewEngine BuildViewEngine() { return new MockViewEngine(".view", ".jsview", true, true); } + /// + /// Builds the view component context. + /// + /// Name of the view component. + /// protected virtual IMockViewComponentContext BuildViewComponentContext(string viewComponentName) { MockViewComponentContext compContext = new MockViewComponentContext(viewComponentName, writer, viewEngine); diff --git a/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport-vs2005.csproj b/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport-vs2005.csproj index 8b238f807..e4ae84e91 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport-vs2005.csproj +++ b/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport-vs2005.csproj @@ -73,7 +73,10 @@ ..\..\SharedLibs\net\Cassini.dll - + + False + ..\..\build\net-2.0\debug\Castle.Components.Common.EmailSender.dll + False ..\..\build\net-2.0\debug\Castle.Core.dll diff --git a/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport.build b/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport.build index 99b1497e4..95d69c4b0 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport.build +++ b/MonoRail/Castle.MonoRail.TestSupport/Castle.MonoRail.TestSupport.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.TestSupport/GenericBaseControllerTest.cs b/MonoRail/Castle.MonoRail.TestSupport/GenericBaseControllerTest.cs index e95389d7a..0537cff56 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/GenericBaseControllerTest.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/GenericBaseControllerTest.cs @@ -16,8 +16,15 @@ namespace Castle.MonoRail.TestSupport { using Castle.MonoRail.Framework; + /// + /// Base controller test that uses the controller as a generic parameter. + /// + /// Controller type public class GenericBaseControllerTest : BaseControllerTest where C : Controller { + /// + /// The typed controller instance + /// protected C controller; } } diff --git a/MonoRail/Castle.MonoRail.TestSupport/GenericBaseWizardStepTest.cs b/MonoRail/Castle.MonoRail.TestSupport/GenericBaseWizardStepTest.cs index ea2fcc60d..dce918ac0 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/GenericBaseWizardStepTest.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/GenericBaseWizardStepTest.cs @@ -16,12 +16,24 @@ namespace Castle.MonoRail.TestSupport { using Castle.MonoRail.Framework; + /// + /// Base test for wizard steps. + /// + /// The wizard step page type + /// The wizard controller -- the one that implements public class GenericBaseWizardStepTest : GenericBaseControllerTest where W : WizardStepPage where C : Controller { + /// + /// The step typed field + /// protected W wizardStep; + /// + /// Runs the page pre-condition + /// + /// protected bool RunIsPreConditionSatisfied() { object[] args = new object[] { Context }; @@ -29,6 +41,9 @@ protected bool RunIsPreConditionSatisfied() wizardStep, "IsPreConditionSatisfied", ref args); } + /// + /// Runs the step render method. + /// protected void RunRenderWizardView() { ReflectionHelper.RunInstanceMethod(typeof(WizardStepPage), wizardStep, "RenderWizardView"); diff --git a/MonoRail/Castle.MonoRail.TestSupport/MonoRailTestWorkerRequest.cs b/MonoRail/Castle.MonoRail.TestSupport/MonoRailTestWorkerRequest.cs index dba08f086..2d43531b3 100644 --- a/MonoRail/Castle.MonoRail.TestSupport/MonoRailTestWorkerRequest.cs +++ b/MonoRail/Castle.MonoRail.TestSupport/MonoRailTestWorkerRequest.cs @@ -21,6 +21,9 @@ namespace Castle.MonoRail.TestSupport using System.Collections; using System.Globalization; + /// + /// Used to integrate with the ASP.Net Runtime + /// public class MonoRailTestWorkerRequest : SimpleWorkerRequest { private TextWriter output; diff --git a/MonoRail/Castle.MonoRail.TransformFilters/Castle.MonoRail.TransformFilters.build b/MonoRail/Castle.MonoRail.TransformFilters/Castle.MonoRail.TransformFilters.build index c01ca061b..1396a354e 100644 --- a/MonoRail/Castle.MonoRail.TransformFilters/Castle.MonoRail.TransformFilters.build +++ b/MonoRail/Castle.MonoRail.TransformFilters/Castle.MonoRail.TransformFilters.build @@ -10,7 +10,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BaseViewOnlyTestFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BaseViewOnlyTestFixture.cs new file mode 100644 index 000000000..42ad385da --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BaseViewOnlyTestFixture.cs @@ -0,0 +1,58 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.MonoRail.Views.Brail.Tests +{ + using System; + using System.Collections; + using System.Configuration; + using System.IO; + using Framework; + using TestSupport; + + public class BaseViewOnlyTestFixture : BaseControllerTest + { + protected string ProcessView(string templatePath) + { + return ProcessView(new Hashtable(), templatePath); + } + + protected string ProcessView(IDictionary dictionary, string templatePath) + { + BooViewEngine bve = new BooViewEngine(); + bve.Options = new BooViewEngineOptions(); + bve.Options.SaveDirectory = Environment.CurrentDirectory; + bve.Options.SaveToDisk = true; + bve.Options.Debug = true; + string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); + bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); + bve.Initialize(); + StringWriter sw = new StringWriter(); + DummyController controller = new DummyController(); + + controller.PropertyBag = dictionary; + PrepareController(controller, "", "home", "index"); + bve.Process((TextWriter) sw, Context, (Controller) controller, templatePath); + return sw.ToString(); + } + + #region Nested type: DummyController + + private class DummyController : Controller + { + } + + #endregion + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailAjaxTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailAjaxTestCase.cs index 1bcc086ce..f757fb5ff 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailAjaxTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailAjaxTestCase.cs @@ -20,11 +20,21 @@ namespace Castle.MonoRail.Views.Brail.Tests [TestFixture] public class BrailAjaxTestCase : AbstractTestCase { + [Test] + public void BuildFormRemoteTag() + { + DoGet("ajax/BuildFormRemoteTag.rails"); + string expected = + "
"; + AssertSuccess(); + AssertReplyEqualTo(expected); + } + [Test] public void JsFunctions() { DoGet("ajax/JsFunctions.rails"); - string expected = ""; + string expected = ""; AssertSuccess(); AssertReplyEqualTo(expected); } @@ -49,16 +59,6 @@ public void LinkToRemote() AssertReplyEqualTo(expected); } - [Test] - public void BuildFormRemoteTag() - { - DoGet("ajax/BuildFormRemoteTag.rails"); - string expected = - ""; - AssertSuccess(); - AssertReplyEqualTo(expected); - } - [Test] public void ObserveField() { @@ -79,4 +79,4 @@ public void ObserveForm() AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBasicFunctionality.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBasicFunctionality.cs index 5d33a1296..ec188d43d 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBasicFunctionality.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBasicFunctionality.cs @@ -30,6 +30,24 @@ public void AppPath() AssertReplyEqualTo("Current apppath is "); } + [Test] + public void CanUseUrlHelperWithoutPrefix() + { + DoGet("home/CanUseUrlHelperWithoutPrefix.rails"); + AssertReplyEqualTo("Castle.MonoRail.Framework.Helpers.UrlHelper"); + } + + [Test] + public void WithNullableDynamicProxyObject() + { + DoGet("home/WithNullableDynamicProxyObject.rails"); + string expected = @"BarBaz +foo +what? +there"; + AssertReplyEqualTo(expected); + } + [Test] public void AppPathChangeOnTheFly() { @@ -40,12 +58,13 @@ public void AppPathChangeOnTheFly() { old = read.ReadToEnd(); } + DoGet("apppath/index.rails");//init brail engine using (TextWriter write = File.CreateText(script)) { write.Write(newContent); + write.Flush(); } - // Wait half a sec so Brail could pick up that a change in the file occured. - Thread.Sleep(500); + Thread.Sleep(1000); try { DoGet("apppath/index.rails"); diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs index 2db23951c..215589d92 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs @@ -14,10 +14,8 @@ namespace Castle.MonoRail.Views.Brail.Tests { - using Boo.Lang.Compiler; using Castle.MonoRail.Framework.Tests; using NUnit.Framework; - using Boo.Lang.Compiler.IO; [TestFixture] public class BrailBugsTestCase : AbstractTestCase @@ -31,13 +29,13 @@ public void MR_233_TagInDoubleQuotes() } - [Test] - public void MR_262_DynamicComponents() - { - DoGet("usingcomponents/DynamicComponents.rails"); - AssertSuccess(); - AssertReplyEqualTo("default component view picked up automaticallyThis is a view used by a component"); - } + [Test] + public void MR_262_DynamicComponents() + { + DoGet("usingcomponents/DynamicComponents.rails"); + AssertSuccess(); + AssertReplyEqualTo("default component view picked up automaticallyThis is a view used by a component"); + } [Test] public void MR_285_ViewName_Is_Reserved_CompilerKeyword() @@ -47,12 +45,11 @@ public void MR_285_ViewName_Is_Reserved_CompilerKeyword() AssertReplyContains("Success"); } - [Test] - public void MR_299_Inline_SubView() - { - DoGet("bugs/inlineSubView.rails"); - AssertReplyContains("Success"); - - } + [Test] + public void MR_299_Inline_SubView() + { + DoGet("bugs/inlineSubView.rails"); + AssertReplyContains("Success"); + } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailHelperTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailHelperTestCase.cs index dd59e3dd7..acfc212f2 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailHelperTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailHelperTestCase.cs @@ -25,21 +25,21 @@ namespace Castle.MonoRail.Views.Brail.Tests public class BrailHelperTestCase : AbstractTestCase { [Test] - public void InheritedHelpers() + public void DictHelperUsage() { - Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us"); - DoGet("helper/inheritedhelpers.rails"); - string expected = "Date formatted " + new DateTime(1979, 7, 16).ToShortDateString(); + DoGet("helper/DictHelperUsage.rails"); + string expected = + ""; AssertReplyEqualTo(expected); } [Test] - public void DictHelperUsage() + public void InheritedHelpers() { - DoGet("helper/DictHelperUsage.rails"); - string expected = - ""; + Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us"); + DoGet("helper/inheritedhelpers.rails"); + string expected = "Date formatted " + new DateTime(1979, 7, 16).ToShortDateString(); AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailPreProcessorFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailPreProcessorFixture.cs index b71dc3e9f..03e93c3e7 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailPreProcessorFixture.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailPreProcessorFixture.cs @@ -30,7 +30,7 @@ public void MR_248_PreProcessorBugWithRegardToNestedExpressions() "; string expected = "output \"\"\"\"\"\"\r\n" ; string s = RunThroughPreProcessor(code); diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRegressionTestFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRegressionTestFixture.cs new file mode 100644 index 000000000..074954b67 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRegressionTestFixture.cs @@ -0,0 +1,83 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.MonoRail.Views.Brail.Tests +{ + using System.Collections; + using NUnit.Framework; + + [TestFixture] + public class BrailRegressionTestFixture : BaseViewOnlyTestFixture + { + [Test] + public void CanCompareToNullableParameter() + { + Hashtable args = new Hashtable(); + args["myVariable"] = "Hello"; + string view = ProcessView(args, "regressions/CanCompareToNullableParameter"); + Assert.AreEqual("Eq", view); + } + + [Test] + public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter() + { + string view = ProcessView("regressions/questionMarkOp_if"); + Assert.AreEqual("", view); + } + + [Test] + public void CanUseQuestionMarkOperatorInIfStatementToValidatePresenceOfParameter_WhenPassed() + { + Hashtable args = new Hashtable(); + args["errorMsg"] = "Hello"; + string view = ProcessView(args, "regressions/questionMarkOp_if_whenPassed"); + Assert.AreEqual("Hello", view); + } + + [Test] + public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter() + { + string view = ProcessView("regressions/questionMarkOp_unless"); + Assert.AreEqual("\r\nError does not exist\r\n", view); + } + + [Test] + public void CanUseQuestionMarkOperatorInUnlessStatementToValidatePresenceOfParameter_whenPassed() + { + Hashtable args = new Hashtable(); + args["errorMsg"] = "Hello"; + string view = ProcessView(args, "regressions/questionMarkOp_unless_whenPassed"); + Assert.AreEqual("", view); + } + + + [Test] + public void HtmlEncodingStringInterpolation() + { + Hashtable args = new Hashtable(); + args["htmlCode"] = ""; + string view = ProcessView(args, "regressions/HtmlEncodingStringInterpolation"); + Assert.AreEqual("<script>alert('a');</script>", view); + } + + [Test] + public void StringInterpolationInCodeBlockWillNotBeEscaped() + { + Hashtable args = new Hashtable(); + args["htmlCode"] = ""; + string view = ProcessView(args, "regressions/StringInterpolationInCodeBlockWillNotBeEscaped"); + Assert.AreEqual("", view); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRoutingTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRoutingTestCase.cs index 4c3243c9f..e44b7a319 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRoutingTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailRoutingTestCase.cs @@ -36,4 +36,4 @@ public void NewsRoutingRule() AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailSubViewTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailSubViewTestCase.cs index 9efd16025..bd99a3ce8 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailSubViewTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailSubViewTestCase.cs @@ -25,7 +25,7 @@ public void BrailWillCacheSubViewsWhenUsingForwardSlash() { DoGet("subview/useLotsOfSubViews.rails"); StringBuilder sb = new StringBuilder(); - for(int i = 0; i < 50; i++) + for (int i = 0; i < 50; i++) { sb.Append("real"); } @@ -35,7 +35,7 @@ public void BrailWillCacheSubViewsWhenUsingForwardSlash() // Here we tell the controller to replace the subview with a dummy implementation // if brail doesn't cache it, it will use the real implementation, and the test will fail. sb = new StringBuilder(); - for(int i = 0; i < 50; i++) + for (int i = 0; i < 50; i++) { sb.Append("dummy"); } @@ -76,4 +76,4 @@ public void SubViewWithParameters() AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Castle.MonoRail.Views.Brail.Tests-vs2005.csproj b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Castle.MonoRail.Views.Brail.Tests-vs2005.csproj index db5b888ae..4be52374e 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Castle.MonoRail.Views.Brail.Tests-vs2005.csproj +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Castle.MonoRail.Views.Brail.Tests-vs2005.csproj @@ -47,10 +47,12 @@ + + @@ -68,6 +70,7 @@ + @@ -92,6 +95,11 @@ + + + + + diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ComponentsTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ComponentsTestCase.cs index c2cea5808..571800fca 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ComponentsTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ComponentsTestCase.cs @@ -21,54 +21,92 @@ namespace Castle.MonoRail.Views.Brail.Tests public class ComponentsTestCase : AbstractTestCase { [Test] - public void SimpleInlineViewComponent() + public void BlockComp1() { - string expected = "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2"; - DoGet("usingcomponents/index1.rails"); - AssertReplyEqualTo(expected); + DoGet("usingcomponents/index8.rails"); + AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n"); } [Test] - public void InlineComponentUsingRender() + public void CanGetParamsFromTheComponentInTheView() { - string expected = "static 1\r\nThis is a view used by a component static 2"; - DoGet("usingcomponents/index2.rails"); - AssertReplyEqualTo(expected); + DoGet("usingcomponents/template.rails"); + AssertReplyEqualTo("123"); } [Test] - public void InlineComponentNotOverridingRender() + public void CanPassParametersFromComponentToView() { - string expected = "static 1\r\ndefault component view picked up automatically static 2"; - DoGet("usingcomponents/index3.rails"); - AssertReplyEqualTo(expected); + DoGet("usingcomponents/withParams.rails"); + AssertReplyEqualTo("brail"); } [Test] - public void InlineComponentWithParam1() + public void ComponentWithInvalidSection() { - DoGet("usingcomponents/index4.rails"); - AssertReplyEqualTo("Done"); + DoGet("usingcomponent2/ComponentWithInvalidSections.rails"); + + AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'"); } [Test] - public void CanGetParamsFromTheComponentInTheView() + public void GridComponent1() { - DoGet("usingcomponents/template.rails"); - AssertReplyEqualTo("123"); + DoGet("usingcomponent2/GridComponent1.rails"); + + AssertReplyEqualTo( + @" + + + + + + + + +
EMailPhone
hammett111
Peter Griffin222
"); } [Test] - public void BlockComp1() + public void GridComponent2() { - DoGet("usingcomponents/index8.rails"); - AssertReplyEqualTo("\r\ninner content 1\r\n\r\ninner content 2\r\n"); + DoGet("usingcomponent2/GridComponent2.rails"); + AssertReplyEqualTo( + @" + + + + +
EMailPhone
Nothing here
"); + } + + [Test] + public void InlineComponentNotOverridingRender() + { + string expected = "static 1\r\ndefault component view picked up automatically static 2"; + DoGet("usingcomponents/index3.rails"); + AssertReplyEqualTo(expected); + } + + [Test] + public void InlineComponentUsingRender() + { + string expected = "static 1\r\nThis is a view used by a component static 2"; + DoGet("usingcomponents/index2.rails"); + AssertReplyEqualTo(expected); + } + + [Test] + public void InlineComponentWithParam1() + { + DoGet("usingcomponents/index4.rails"); + AssertReplyEqualTo("Done"); } [Test] public void SeveralComponentsInvocation() { - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { string expected = "static 1\r\nContent 1\r\nstatic 2\r\nContent 2\r\nstatic 3\r\nContent 3\r\nstatic 4\r\nContent 4\r\nstatic 5\r\nContent 5\r\n"; @@ -77,6 +115,14 @@ public void SeveralComponentsInvocation() } } + [Test] + public void SimpleInlineViewComponent() + { + string expected = "static 1\r\nHello from SimpleInlineViewComponent\r\nstatic 2"; + DoGet("usingcomponents/index1.rails"); + AssertReplyEqualTo(expected); + } + [Test] public void UsingCaptureFor() { @@ -90,49 +136,5 @@ public void UsingCaptureForWithLayout() DoGet("usingcomponents/captureForWithLayout.rails"); AssertReplyEqualTo("Numbers: 1234\r\n"); } - - [Test] - public void CanPassParametersFromComponentToView() - { - DoGet("usingcomponents/withParams.rails"); - AssertReplyEqualTo("brail"); - } - - [Test] - public void ComponentWithInvalidSection() - { - DoGet("usingcomponent2/ComponentWithInvalidSections.rails"); - - AssertReplyContains("The section 'invalidsection' is not supported by the ViewComponent 'GridComponent'"); - } - - [Test] - public void GridComponent1() - { - DoGet("usingcomponent2/GridComponent1.rails"); - - AssertReplyEqualTo(@" - - - - - - - - -
EMailPhone
hammett111
Peter Griffin222
"); - } - - [Test] - public void GridComponent2() - { - DoGet("usingcomponent2/GridComponent2.rails"); - AssertReplyEqualTo(@" - - - - -
EMailPhone
Nothing here
"); - } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/DslController.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/DslController.cs index d8f0c2b77..33e26789e 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/DslController.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/DslController.cs @@ -1,23 +1,21 @@ namespace Castle.MonoRail.Views.Brail.Tests.Controllers { - using System; - using System.Collections; - using Castle.MonoRail.Framework; + using System; + using Framework; - [Serializable] - public class DslController : SmartDispatcherController - { - public void registerHtml() - { - - } + [Serializable] + public class DslController : SmartDispatcherController + { + public void registerHtml() + { + } - public void AttributeOutput() - { - } + public void AttributeOutput() + { + } - public void expandParameters() - { - } - } -} + public void expandParameters() + { + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/HomeController.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/HomeController.cs index a10d7e838..ccbcf1ebc 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/HomeController.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/HomeController.cs @@ -14,7 +14,7 @@ namespace Castle.MonoRail.Views.Brail.Tests.Controllers { - using Castle.MonoRail.Framework; + using Framework; public class HomeController : SmartDispatcherController { @@ -38,4 +38,4 @@ public void Resource() { } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/LayoutController.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/LayoutController.cs index c92831c1e..d0b8281de 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/LayoutController.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Controllers/LayoutController.cs @@ -13,24 +13,22 @@ // limitations under the License. namespace Castle.MonoRail.Views.Brail.Tests.Controllers { - using Castle.MonoRail.Framework; + using Framework; [Layout("general")] public class LayoutController : SmartDispatcherController { public void Index() { - } - + public void Save() { LayoutName = "printable"; } - + public void Update() { - } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DirectRenderTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DirectRenderTestCase.cs index 5a6b49f54..60f6a937e 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DirectRenderTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DirectRenderTestCase.cs @@ -36,4 +36,4 @@ public void DirectRenderingWithLayout() AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslFixture.cs index 3a34a3fc6..2f473fb8c 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslFixture.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslFixture.cs @@ -1,57 +1,55 @@ - namespace Castle.MonoRail.Views.Brail.Tests { - using Castle.MonoRail.Framework.Tests; - using NUnit.Framework; - using Castle.MonoRail.TestSupport; - using Castle.MonoRail.Views.Brail.Tests.Controllers; - using System.IO; - using System.Configuration; + using System.Configuration; + using System.IO; + using Controllers; + using NUnit.Framework; + using TestSupport; - [TestFixture] - public class DslFixture : BaseControllerTest - { - [Test] - public void RegisterHtmlAllowsCallToHtml() - { - BooViewEngine bve = new BooViewEngine(); - string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); - bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); - bve.Initialize(); - StringWriter sw = new StringWriter(); - DslController controller = new DslController(); - PrepareController(controller, "", "dsl", "registerHtml"); - bve.Process(sw, Context, controller, "dsl/registerHtml"); - Assert.AreEqual(@"hello world", sw.ToString()); - } + [TestFixture] + public class DslFixture : BaseControllerTest + { + [Test] + public void CanOutputParagraphWithClassAttribute() + { + BooViewEngine bve = new BooViewEngine(); + string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); + bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); + bve.Initialize(); + StringWriter sw = new StringWriter(); + DslController controller = new DslController(); + PrepareController(controller, "", "dsl", "attributeOutput"); + bve.Process(sw, Context, controller, "dsl/attributeOutput"); + Assert.AreEqual("

hello world

", sw.ToString()); + } - [Test] - public void CanOutputParagraphWithClassAttribute() - { - BooViewEngine bve = new BooViewEngine(); - string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); - bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); - bve.Initialize(); - StringWriter sw = new StringWriter(); - DslController controller = new DslController(); - PrepareController(controller, "", "dsl", "attributeOutput"); - bve.Process(sw, Context, controller, "dsl/attributeOutput"); - Assert.AreEqual("

hello world

", sw.ToString()); - } + [Test] + public void ParametersCanBeReferencedByView() + { + BooViewEngine bve = new BooViewEngine(); + string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); + bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); + bve.Initialize(); + StringWriter sw = new StringWriter(); + DslController controller = new DslController(); + controller.PropertyBag["SayHelloTo"] = "Harris"; + PrepareController(controller, "", "dsl", "expandParameters"); + bve.Process(sw, Context, controller, "dsl/expandParameters"); + Assert.AreEqual("

hello, Harris

", sw.ToString()); + } - [Test] - public void ParametersCanBeReferencedByView() - { - BooViewEngine bve = new BooViewEngine(); - string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); - bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); - bve.Initialize(); - StringWriter sw = new StringWriter(); - DslController controller = new DslController(); - controller.PropertyBag["SayHelloTo"] = "Harris"; - PrepareController(controller, "", "dsl", "expandParameters"); - bve.Process(sw, Context, controller, "dsl/expandParameters"); - Assert.AreEqual("

hello, Harris

", sw.ToString()); - } - } -} + [Test] + public void RegisterHtmlAllowsCallToHtml() + { + BooViewEngine bve = new BooViewEngine(); + string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); + bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); + bve.Initialize(); + StringWriter sw = new StringWriter(); + DslController controller = new DslController(); + PrepareController(controller, "", "dsl", "registerHtml"); + bve.Process(sw, Context, controller, "dsl/registerHtml"); + Assert.AreEqual(@"hello world", sw.ToString()); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslLayoutFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslLayoutFixture.cs index 6f709ffee..190a4f0e3 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslLayoutFixture.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/DslLayoutFixture.cs @@ -14,36 +14,37 @@ namespace Castle.MonoRail.Views.Brail.Tests { - using Castle.MonoRail.Framework.Tests; - using NUnit.Framework; + using Castle.MonoRail.Framework.Tests; + using NUnit.Framework; - [TestFixture] - public class DslLayoutFixture : AbstractTestCase - { - [Test] - public void LayoutAndChildOuputUsingDsl() - { - string expected = "

Hello, Harris

"; - DoGet("dsl/testSubViewOutput.rails"); - AssertReplyEqualTo(expected); - } + [TestFixture] + public class DslLayoutFixture : AbstractTestCase + { + [Test] + public void ComponentOuputUsingDsl() + { + string expected = + "
Names
Ayende
Rahien
"; + DoGet("dsl/testSubViewWithComponents.rails"); + AssertReplyEqualTo(expected); + } - [Test] - public void ComponentOuputUsingDsl() - { - string expected = - "
Names
Ayende
Rahien
"; - DoGet("dsl/testSubViewWithComponents.rails"); - AssertReplyEqualTo(expected); - } + [Test] + public void LayoutAndChildOuputUsingDsl() + { + string expected = "

Hello, Harris

"; + DoGet("dsl/testSubViewOutput.rails"); + AssertReplyEqualTo(expected); + } - [Test] - //[Ignore("We have issue with parameters references")] - public void XmlDsl() - { - string expected = "RSS DSLTitle: AyendeDescription: AyendeTitle: RahienDescription: Rahien"; - DoGet("dsl/testXml.rails"); - AssertReplyEqualTo(expected); - } - } -} + [Test] + //[Ignore("We have issue with parameters references")] + public void XmlDsl() + { + string expected = + "RSS DSLTitle: AyendeDescription: AyendeTitle: RahienDescription: Rahien"; + DoGet("dsl/testXml.rails"); + AssertReplyEqualTo(expected); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/HappenedOnTheFieldFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/HappenedOnTheFieldFixture.cs index 8fb22bfba..781f64baf 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/HappenedOnTheFieldFixture.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/HappenedOnTheFieldFixture.cs @@ -28,4 +28,4 @@ public void UsingEmptyComponent() AssertSuccess(); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/JSGenerationTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/JSGenerationTestCase.cs index 4e19e3457..4a776caa2 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/JSGenerationTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/JSGenerationTestCase.cs @@ -14,162 +14,150 @@ namespace Castle.MonoRail.Views.Brail.Tests { - using Castle.MonoRail.Framework.Tests; - using NUnit.Framework; - - [TestFixture] - public class JSGenerationTestCase : AbstractTestCase - { - #region Stock operations - - [Test] - public void ReplaceHtml() - { - DoGet("jsgeneration/replacehtml.rails"); - AssertSuccess(); - AssertReplyContains("Element.update(\"aa\",\"new content\");"); - } - - [Test] - public void ReplaceHtmlUsingPartial() - { - DoGet("jsgeneration/replacehtmlwithpartial.rails"); - AssertSuccess(); - AssertReplyContains("Element.update(\"aa\",\"You\'re hammett
[ a ][ b ]\")"); - } - - [Test] - public void Replace() - { - DoGet("jsgeneration/replace.rails"); - AssertSuccess(); - AssertReplyContains("Element.replace(\"aa\",\"new content\")"); - } - - [Test] - public void InsertHtml() - { - DoGet("jsgeneration/InsertHtml.rails"); - AssertSuccess(); - AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");"); - AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");"); - AssertReplyContains("new Insertion.After(\"aa\",\"new content\");"); - AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");"); - } - - [Test] - public void VisualEffect() - { - DoGet("jsgeneration/visualeffect.rails"); - AssertSuccess(); - AssertReplyContains("Effect.Highlight('element1', {});"); - AssertReplyContains("Effect.Highlight('element1', {duration:4});"); - } - - [Test] - public void ShowHideToggleRemove() - { - DoGet("jsgeneration/multipleactions.rails"); - AssertSuccess(); - AssertReplyContains("Element.show(\"a\");"); - AssertReplyContains("Element.show(\"a\",\"b\",\"c\");"); - AssertReplyContains("Element.hide(\"a\");"); - AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");"); - AssertReplyContains("Element.toggle(\"a\");"); - AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");"); - AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);"); - } - - [Test] - public void MR_264() - { - DoGet("jsgeneration/mr264.rails"); - AssertReplyContains( - "Element.update(\"holder\",\"test\");\r\n"+ - "new Effect.Highlight('holder', {});"); - } - - #endregion - - #region Element related - - [Test] - public void SimpleElementAccess() - { - DoGet("jsgeneration/elementaccess.rails"); - AssertSuccess(); - AssertReplyContains("$('aa');"); - } - - [Test] - public void AccessingElementAttribute() - { - DoGet("jsgeneration/elementattribute.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').className = \"newclass\";"); - } - - [Test] - public void AccessingElementAttributeDepth() - { - DoGet("jsgeneration/elementattributedepth.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').style.display = \"none\";"); - } - - [Test] - public void AccessingElementMethod() - { - DoGet("jsgeneration/elementmethod.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').hide();"); - } - - [Test] - public void AccessingElementMethodDepth() - { - DoGet("jsgeneration/elementmethoddepth.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').read().test();"); - } - - [Test] - public void AccessingElementStockOperationReplaceHtml() - { - DoGet("jsgeneration/elementreplacehtml.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').update(\"new content\")"); - } - - [Test] - public void AccessingElementStockOperationReplace() - { - DoGet("jsgeneration/elementreplace.rails"); - AssertSuccess(); - AssertReplyContains("$('aa').replace(\"new content\")"); - } - - #endregion - - #region Select related - - [Test] - public void SimpleCollectionAccess() - { - DoGet("jsgeneration/collectionaccess.rails"); - AssertSuccess(); - AssertReplyContains("$$('aa');"); - } - - [Test] - public void CollectionFirstLast() - { - DoGet("jsgeneration/collectionfirstlast.rails"); - AssertSuccess(); - AssertReplyContains("$$('p.welcome b').first().hide();"); - AssertReplyContains("$$('p.welcome b').last().show();"); - } - - #endregion - } -} + using Castle.MonoRail.Framework.Tests; + using NUnit.Framework; + + [TestFixture] + public class JSGenerationTestCase : AbstractTestCase + { + [Test] + public void AccessingElementAttribute() + { + DoGet("jsgeneration/elementattribute.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').className = \"newclass\";"); + } + + [Test] + public void AccessingElementAttributeDepth() + { + DoGet("jsgeneration/elementattributedepth.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').style.display = \"none\";"); + } + + [Test] + public void AccessingElementMethod() + { + DoGet("jsgeneration/elementmethod.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').hide();"); + } + + [Test] + public void AccessingElementMethodDepth() + { + DoGet("jsgeneration/elementmethoddepth.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').read().test();"); + } + + [Test] + public void AccessingElementStockOperationReplace() + { + DoGet("jsgeneration/elementreplace.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').replace(\"new content\")"); + } + + [Test] + public void AccessingElementStockOperationReplaceHtml() + { + DoGet("jsgeneration/elementreplacehtml.rails"); + AssertSuccess(); + AssertReplyContains("$('aa').update(\"new content\")"); + } + + [Test] + public void CollectionFirstLast() + { + DoGet("jsgeneration/collectionfirstlast.rails"); + AssertSuccess(); + AssertReplyContains("$$('p.welcome b').first().hide();"); + AssertReplyContains("$$('p.welcome b').last().show();"); + } + + [Test] + public void InsertHtml() + { + DoGet("jsgeneration/InsertHtml.rails"); + AssertSuccess(); + AssertReplyContains("new Insertion.Top(\"aa\",\"new content\");"); + AssertReplyContains("new Insertion.Bottom(\"aa\",\"new content\");"); + AssertReplyContains("new Insertion.After(\"aa\",\"new content\");"); + AssertReplyContains("new Insertion.Before(\"aa\",\"new content\");"); + } + + [Test] + public void MR_264() + { + DoGet("jsgeneration/mr264.rails"); + AssertReplyContains( + "Element.update(\"holder\",\"test\");\r\n" + + "new Effect.Highlight('holder', {});"); + } + + [Test] + public void Replace() + { + DoGet("jsgeneration/replace.rails"); + AssertSuccess(); + AssertReplyContains("Element.replace(\"aa\",\"new content\")"); + } + + [Test] + public void ReplaceHtml() + { + DoGet("jsgeneration/replacehtml.rails"); + AssertSuccess(); + AssertReplyContains("Element.update(\"aa\",\"new content\");"); + } + + [Test] + public void ReplaceHtmlUsingPartial() + { + DoGet("jsgeneration/replacehtmlwithpartial.rails"); + AssertSuccess(); + AssertReplyContains("Element.update(\"aa\",\"You\'re hammett
[ a ][ b ]\")"); + } + + [Test] + public void ShowHideToggleRemove() + { + DoGet("jsgeneration/multipleactions.rails"); + AssertSuccess(); + AssertReplyContains("Element.show(\"a\");"); + AssertReplyContains("Element.show(\"a\",\"b\",\"c\");"); + AssertReplyContains("Element.hide(\"a\");"); + AssertReplyContains("Element.hide(\"a\",\"b\",\"c\");"); + AssertReplyContains("Element.toggle(\"a\");"); + AssertReplyContains("Element.toggle(\"a\",\"b\",\"c\");"); + AssertReplyContains("[\"a\",\"b\",\"c\"].each(Element.remove);"); + } + + [Test] + public void SimpleCollectionAccess() + { + DoGet("jsgeneration/collectionaccess.rails"); + AssertSuccess(); + AssertReplyContains("$$('aa');"); + } + + [Test] + public void SimpleElementAccess() + { + DoGet("jsgeneration/elementaccess.rails"); + AssertSuccess(); + AssertReplyContains("$('aa');"); + } + + [Test] + public void VisualEffect() + { + DoGet("jsgeneration/visualeffect.rails"); + AssertSuccess(); + AssertReplyContains("Effect.Highlight('element1', {});"); + AssertReplyContains("Effect.Highlight('element1', {duration:4});"); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/JustViewFixture.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/JustViewFixture.cs index e9011a546..367c79093 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/JustViewFixture.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/JustViewFixture.cs @@ -14,35 +14,17 @@ namespace Castle.MonoRail.Views.Brail.Tests { - using System; using System.Collections; - using System.Configuration; - using System.IO; - using Castle.MonoRail.Framework; - using Castle.MonoRail.TestSupport; using NUnit.Framework; [TestFixture] - public class JustViewFixture : BaseControllerTest + public class JustViewFixture : BaseViewOnlyTestFixture { - protected string ProcessView(string templatePath) - { - return ProcessView(new Hashtable(), templatePath); - } - - protected string ProcessView(IDictionary dictionary, string templatePath) + [Test] + public void CanRenderViewWithoutUsingFullMonoRailPipeline() { - BooViewEngine bve = new BooViewEngine(); - string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); - bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); - bve.Initialize(); - StringWriter sw = new StringWriter(); - DummyController controller = new DummyController(); - - controller.PropertyBag = dictionary; - PrepareController(controller, "", "home", "index"); - bve.Process(sw, Context, controller, templatePath); - return sw.ToString(); + string outpot = ProcessView("home/index"); + Assert.AreEqual("Brail is wonderful", outpot); } [Test] @@ -54,28 +36,14 @@ public void UsingExtentionMethods() string actual = ProcessView(dictionary, templatePath); Assert.AreEqual("No Data", actual); - } - [Test] - public void CanRenderViewWithoutUsingFullMonoRailPipeline() - { - BooViewEngine bve = new BooViewEngine(); - string viewPath = Path.Combine(ConfigurationManager.AppSettings["tests.src"], "Views"); - bve.Service(new ViewSourceLoaderServiceProvider(viewPath)); - bve.Initialize(); - StringWriter sw = new StringWriter(); - DummyController controller = new DummyController(); - PrepareController(controller, "", "home", "index"); - bve.Process(sw, Context, controller, "home/index"); - Assert.AreEqual("Brail is wonderful", sw.ToString()); - } [Test] public void WithParameters() { IDictionary dictionary = new Hashtable(); - dictionary["list"] = new int[] { 2, 5, 7, 8 }; + dictionary["list"] = new int[] {2, 5, 7, 8}; dictionary["name"] = "test"; string templatePath = "home/bag"; @@ -88,9 +56,5 @@ public void WithParameters() "; Assert.AreEqual(expected, actual); } - - private class DummyController : Controller - { - } } } \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/LanguageFeatures.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/LanguageFeatures.cs index 971f44926..d9454b492 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/LanguageFeatures.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/LanguageFeatures.cs @@ -21,27 +21,27 @@ namespace Castle.MonoRail.Views.Brail.Tests public class LanguageFeatures : AbstractTestCase { [Test] - public void NullableProperties() + public void CanHandleDynamicProxyObjects() { string expected = "\r\n" + -@" + @"

BarBaz

"; - // should not raise null exception - DoGet("Home/nullableProperties.rails"); + // should not raise ambigious match exception + DoGet("Home/withDynamicProxyObject.rails"); AssertReplyEqualTo(expected); } [Test] - public void CanHandleDynamicProxyObjects() + public void NullableProperties() { string expected = "\r\n" + -@" + @"

BarBaz

"; - // should not raise ambigious match exception - DoGet("Home/withDynamicProxyObject.rails"); + // should not raise null exception + DoGet("Home/nullableProperties.rails"); AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/OutputMethodTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/OutputMethodTestCase.cs index d80f29c94..a6a47923a 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/OutputMethodTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/OutputMethodTestCase.cs @@ -23,8 +23,7 @@ public class OutputMethodTestCase : AbstractTestCase [Test] public void HtmlAttribute() { - string expected = @" -Some text that will be <html> encoded"; + string expected = @"Some text that will be <html> encoded"; DoGet("OutputMethods/HtmlOutputAttribute.rails"); AssertReplyEqualTo(expected); } @@ -32,8 +31,7 @@ public void HtmlAttribute() [Test] public void RawAttribute() { - string expected = @" -1<2 && 3>4"; + string expected = @"1<2 && 3>4"; DoGet("OutputMethods/RawOutputAttribute.rails"); AssertReplyEqualTo(expected); } @@ -41,7 +39,7 @@ public void RawAttribute() [Test] public void MarkDownAttribute() { - string expected = "\r\n

Ayende Rahien, Rahien.

\n"; + string expected = "

Ayende Rahien, Rahien.

\n"; DoGet("OutputMethods/MarkDownOutputAttribute.rails"); AssertReplyEqualTo(expected); diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ResourceTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ResourceTestCase.cs index c39836b0f..6628995b6 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ResourceTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ResourceTestCase.cs @@ -14,6 +14,7 @@ namespace Castle.MonoRail.Views.Brail.Tests { + using System.Globalization; using System.Threading; using Castle.MonoRail.Framework.Tests; using NUnit.Framework; @@ -22,33 +23,33 @@ namespace Castle.MonoRail.Views.Brail.Tests public class ResourceTestCase : AbstractTestCase { [Test] - public void GetResources() + public void GetIndexedResources() { - Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string expected = "testValue"; - DoGet("resourced/getresources.rails"); + DoGet("resourced/indexingResources.rails"); AssertReplyEqualTo(expected); } [Test] - public void GetIndexedResources() + public void GetResources() { - Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string expected = "testValue"; - DoGet("resourced/indexingResources.rails"); + DoGet("resourced/getresources.rails"); AssertReplyEqualTo(expected); } [Test] public void IterateOnResources() { - Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string expected = "testKey: testValue"; DoGet("resourced/iterating.rails"); AssertReplyEqualTo(expected); } } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ViewSourceLoaderServiceProvider.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ViewSourceLoaderServiceProvider.cs index 05167dbfb..6727b8b2c 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/ViewSourceLoaderServiceProvider.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/ViewSourceLoaderServiceProvider.cs @@ -1,7 +1,7 @@ namespace Castle.MonoRail.Views.Brail.Tests { using System; - using Castle.MonoRail.Framework; + using Framework; internal class ViewSourceLoaderServiceProvider : IServiceProvider { @@ -16,7 +16,7 @@ public ViewSourceLoaderServiceProvider(string viewRootDir) public object GetService(Type serviceType) { - if (typeof(IViewSourceLoader) == serviceType) + if (typeof (IViewSourceLoader) == serviceType) { FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(); loader.ViewRootDir = viewRootDir; diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/CanCompareToNullableParameter.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/CanCompareToNullableParameter.brail new file mode 100644 index 000000000..1593d27a7 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/CanCompareToNullableParameter.brail @@ -0,0 +1,5 @@ +<% +if ?myVariable == "Hello": + output "Eq" +end +%> \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/HtmlEncodingStringInterpolation.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/HtmlEncodingStringInterpolation.brail new file mode 100644 index 000000000..9ec5ffa99 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/HtmlEncodingStringInterpolation.brail @@ -0,0 +1 @@ +!{htmlCode} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/StringInterpolationInCodeBlockWillNotBeEscaped.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/StringInterpolationInCodeBlockWillNotBeEscaped.brail new file mode 100644 index 000000000..6ea26e0d3 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/StringInterpolationInCodeBlockWillNotBeEscaped.brail @@ -0,0 +1 @@ +${htmlCode} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if.brail new file mode 100644 index 000000000..d2678e9b1 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if.brail @@ -0,0 +1,5 @@ +<%if ?Errors:%> + <% for errorMsg in Errors.Values: %> + ${errorMsg}
+ <% end %> +<% end %> \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if_whenPassed.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if_whenPassed.brail new file mode 100644 index 000000000..7cc977426 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_if_whenPassed.brail @@ -0,0 +1,5 @@ +<% +if ?errorMsg: + output errorMsg +end +%> \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless.brail new file mode 100644 index 000000000..27f5049b5 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless.brail @@ -0,0 +1,3 @@ +<% unless ?Errors: %> +Error does not exist +<% end %> \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless_whenPassed.brail b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless_whenPassed.brail new file mode 100644 index 000000000..c257b6241 --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/Views/regressions/questionMarkOp_unless_whenPassed.brail @@ -0,0 +1,3 @@ +<% unless ?errorMsg: %> +Error does not exist +<% end %> \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/XmlTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/XmlTestCase.cs index 590778232..6cbf44ce6 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/XmlTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/XmlTestCase.cs @@ -14,16 +14,16 @@ namespace Castle.MonoRail.Views.Brail.Tests { - using Castle.MonoRail.Framework.Tests; - using NUnit.Framework; + using Castle.MonoRail.Framework.Tests; + using NUnit.Framework; - [TestFixture] - public class XmlTestCase : AbstractTestCase - { - [Test] - public void ComplexXml() - { - string expected = @" + [TestFixture] + public class XmlTestCase : AbstractTestCase + { + [Test] + public void ComplexXml() + { + string expected = @" 0,1,2,3,4,5,6,7,8,9, html string
    @@ -35,16 +35,16 @@ html string
  1. 2
"; - DoGet("Xml/Complex.rails"); - AssertReplyEqualTo(expected); - } + DoGet("Xml/Complex.rails"); + AssertReplyEqualTo(expected); + } - [Test] - public void PureXml() - { - string expected = "0,1,2,3,4,5,6,7,8,9,"; - DoGet("Xml/Pure.rails"); - AssertReplyEqualTo(expected); - } - } -} + [Test] + public void PureXml() + { + string expected = "0,1,2,3,4,5,6,7,8,9,"; + DoGet("Xml/Pure.rails"); + AssertReplyEqualTo(expected); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail/BooViewEngine.cs b/MonoRail/Castle.MonoRail.Views.Brail/BooViewEngine.cs index cf7cf469e..8cdf9fe79 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/BooViewEngine.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/BooViewEngine.cs @@ -28,18 +28,26 @@ namespace Castle.MonoRail.Views.Brail using Boo.Lang.Compiler.Pipelines; using Boo.Lang.Compiler.Steps; using Boo.Lang.Parser; - using Castle.Core; using Castle.Core.Logging; - using Castle.MonoRail.Framework; using Castle.MonoRail.Framework.Helpers; + using Core; + using Framework; public class BooViewEngine : ViewEngineBase, IInitializable { + private static BooViewEngineOptions options; + private string baseSavePath; + + /// + /// This is used to add a reference to the common scripts for each compiled scripts + /// + private Assembly common; + /// /// This field holds all the cache of all the /// compiled types (not instances) of all the views that Brail nows of. /// - private Hashtable compilations = Hashtable.Synchronized( + private readonly Hashtable compilations = Hashtable.Synchronized( new Hashtable(StringComparer.InvariantCultureIgnoreCase)); /// @@ -48,13 +56,35 @@ public class BooViewEngine : ViewEngineBase, IInitializable /// private Hashtable constructors = new Hashtable(); - /// - /// This is used to add a reference to the common scripts for each compiled scripts - /// - private Assembly common; private ILogger logger; - private static BooViewEngineOptions options; - private string baseSavePath; + + public override bool SupportsJSGeneration + { + get { return true; } + } + + public override string ViewFileExtension + { + get { return ".brail"; } + } + + public override string JSGeneratorFileExtension + { + get { return ".brailjs"; } + } + + public string ViewRootDir + { + get { return ViewSourceLoader.ViewRootDir; } + } + + public BooViewEngineOptions Options + { + get { return options; } + set { options = value; } + } + + #region IInitializable Members public void Initialize() { @@ -76,20 +106,7 @@ public void Initialize() ViewSourceLoader.ViewChanged += new FileSystemEventHandler(OnViewChanged); } - public override bool SupportsJSGeneration - { - get { return true; } - } - - public override string ViewFileExtension - { - get { return ".brail"; } - } - - public override string JSGeneratorFileExtension - { - get { return ".brailjs"; } - } + #endregion public override bool HasTemplate(string templateName) { @@ -110,7 +127,7 @@ public override void Process(TextWriter output, IRailsEngineContext context, Con string templateName) { Log("Starting to process request for {0}", templateName); - string file = templateName.ToUpper() + ViewFileExtension; + string file = templateName + ViewFileExtension; BrailBase view; // Output may be the layout's child output if a layout exists // or the context.Response.Output if the layout is null @@ -130,7 +147,7 @@ public override void Process(TextWriter output, IRailsEngineContext context, Con } public override void ProcessPartial(TextWriter output, IRailsEngineContext context, Controller controller, - string partialName) + string partialName) { Log("Generating partial for {0}", partialName); @@ -170,8 +187,8 @@ public override void GenerateJS(TextWriter output, IRailsEngineContext context, string file = ResolveTemplateName(templateName, JSGeneratorFileExtension); BrailBase view = GetCompiledScriptInstance(file, //we use the script just to build the generator, not to output to the user - new StringWriter(), - context, controller); + new StringWriter(), + context, controller); Log("Executing JS view {0}", templateName); view.AddProperty("page", generator); view.Run(); @@ -202,7 +219,13 @@ public override void ProcessContents(IRailsEngineContext context, Controller con private void OnViewChanged(object sender, FileSystemEventArgs e) { - if (e.FullPath.IndexOf(options.CommonScriptsDirectory) != -1) + string path = e.FullPath.Substring(ViewRootDir.Length); + if(path.Length>0 && (path[0] == Path.DirectorySeparatorChar || + path[0] == Path.AltDirectorySeparatorChar)) + { + path = path.Substring(1); + } + if (path.IndexOf(options.CommonScriptsDirectory) != -1) { Log("Detected a change in commons scripts directory " + options.CommonScriptsDirectory + ", recompiling site"); // need to invalidate the entire CommonScripts assembly @@ -222,11 +245,14 @@ private void OnViewChanged(object sender, FileSystemEventArgs e) // successfully compiled the commons scripts directory. Log("Failed to recompile the commons scripts directory! {0}", ex); } - return; + + } + else + { + Log("Detected a change in {0}, removing from complied cache", e.Name); + // Will cause a recompilation + compilations[path] = null; } - Log("Detected a change in {0}, removing from complied cache", e.Name); - // Will cause a recompilation - compilations[e.Name] = null; } private static void WaitForFileToBecomeAvailableForReading(FileSystemEventArgs e) @@ -273,11 +299,11 @@ protected static string ResolveTemplateName(string templateName, string extentio { if (Path.HasExtension(templateName)) { - return templateName.ToUpper(); + return templateName; } else { - return templateName.ToUpper() + extention; + return templateName + extention; } } @@ -385,16 +411,17 @@ public Type CompileScript(string filename, bool batch) Type type; foreach (ICompilerInput input in inputs2FileName.Keys) { - string typeName = Path.GetFileNameWithoutExtension(input.Name) + "_BrailView"; + string viewName = Path.GetFileNameWithoutExtension(input.Name); + string typeName = TransformToBrailStep.GetViewTypeName(viewName); type = result.Context.GeneratedAssembly.GetType(typeName); Log("Adding {0} to the cache", type.FullName); - compilations[ inputs2FileName[input] ] = type; + compilations[inputs2FileName[input]] = type; constructors[type] = type.GetConstructor(new Type[] { - typeof(BooViewEngine), - typeof(TextWriter), - typeof(IRailsEngineContext), - typeof(Controller) + typeof (BooViewEngine), + typeof (TextWriter), + typeof (IRailsEngineContext), + typeof (Controller) }); } type = (Type)compilations[filename]; @@ -450,6 +477,7 @@ public ICompilerInput CreateInput(string name) /// * The ProcessMethodBodiesWithDuckTyping is replaced with ReplaceUknownWithParameters /// this allows to use naked parameters such as (output context.IsLocal) without using /// any special syntax + /// * The FixTryGetParameterConditionalChecks is run afterward, to transform "if ?Error" to "if not ?Error isa IgnoreNull" /// * The ExpandDuckTypedExpressions is replace with a derived step that allows the use of Dynamic Proxy assemblies /// * The IntroduceGlobalNamespaces step is removed, to allow to use common variables such as /// date and list without accidently using the Boo.Lang.BuiltIn versions @@ -472,9 +500,14 @@ private CompilationResult DoCompile(ICollection files, string na compiler.Parameters.Pipeline.Insert(0, processor); // inserting the add class step after the parser compiler.Parameters.Pipeline.Insert(2, new TransformToBrailStep(options)); - compiler.Parameters.Pipeline.Replace(typeof(ProcessMethodBodiesWithDuckTyping), new ReplaceUknownWithParameters()); - compiler.Parameters.Pipeline.Replace(typeof(ExpandDuckTypedExpressions), new ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods()); - compiler.Parameters.Pipeline.Replace(typeof(InitializeTypeSystemServices), new InitializeCustomTypeSystem()); + compiler.Parameters.Pipeline.Replace(typeof(ProcessMethodBodiesWithDuckTyping), + new ReplaceUknownWithParameters()); + compiler.Parameters.Pipeline.Replace(typeof(ExpandDuckTypedExpressions), + new ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods()); + compiler.Parameters.Pipeline.Replace(typeof(InitializeTypeSystemServices), + new InitializeCustomTypeSystem()); + compiler.Parameters.Pipeline.InsertBefore(typeof(ReplaceUknownWithParameters), + new FixTryGetParameterConditionalChecks()); compiler.Parameters.Pipeline.RemoveAt(compiler.Parameters.Pipeline.Find(typeof(IntroduceGlobalNamespaces))); return new CompilationResult(compiler.Run(), processor); @@ -518,7 +551,7 @@ public bool CompileCommonScripts() } // common setup for the compiler - private BooCompiler SetupCompiler(ICompilerInput[] files) + private static BooCompiler SetupCompiler(ICompilerInput[] files) { BooCompiler compiler = new BooCompiler(); compiler.Parameters.Ducky = true; @@ -542,17 +575,6 @@ private BooCompiler SetupCompiler(ICompilerInput[] files) return compiler; } - public string ViewRootDir - { - get { return ViewSourceLoader.ViewRootDir; } - } - - public BooViewEngineOptions Options - { - get { return options; } - set { options = value; } - } - private static void InitializeConfig() { InitializeConfig("brail"); @@ -580,56 +602,64 @@ private void Log(string msg, params object[] items) logger.DebugFormat(msg, items); } - private class LayoutViewOutput + public bool ConditionalPreProcessingOnly(string name) { - private BrailBase layout; - private TextWriter output; + return String.Equals( + Path.GetExtension(name), + JSGeneratorFileExtension, + StringComparison.InvariantCultureIgnoreCase); + } - public LayoutViewOutput(TextWriter output, BrailBase layout) + #region Nested type: CompilationResult + + private class CompilationResult + { + private CompilerContext context; + private BrailPreProcessor processor; + + public CompilationResult(CompilerContext context, BrailPreProcessor processor) { - this.layout = layout; - this.output = output; + this.context = context; + this.processor = processor; } - public BrailBase Layout + public CompilerContext Context { - get { return layout; } + get { return context; } } - public TextWriter Output + public BrailPreProcessor Processor { - get { return output; } + get { return processor; } } } - private class CompilationResult + #endregion + + #region Nested type: LayoutViewOutput + + private class LayoutViewOutput { - CompilerContext context; - BrailPreProcessor processor; + private BrailBase layout; + private TextWriter output; - public CompilerContext Context + public LayoutViewOutput(TextWriter output, BrailBase layout) { - get { return context; } + this.layout = layout; + this.output = output; } - public BrailPreProcessor Processor + public BrailBase Layout { - get { return processor; } + get { return layout; } } - public CompilationResult(CompilerContext context, BrailPreProcessor processor) + public TextWriter Output { - this.context = context; - this.processor = processor; + get { return output; } } } - public bool ConditionalPreProcessingOnly(string name) - { - return String.Equals( - Path.GetExtension(name), - JSGeneratorFileExtension, - StringComparison.InvariantCultureIgnoreCase); - } + #endregion } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail/BrailBase.cs b/MonoRail/Castle.MonoRail.Views.Brail/BrailBase.cs index 0a51a711a..9e0d1d487 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/BrailBase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/BrailBase.cs @@ -12,15 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Diagnostics; -using System.Text; - namespace Castle.MonoRail.Views.Brail { using System; using System.Collections; using System.IO; - using Castle.MonoRail.Framework; + using System.Web; + using Framework; + /// ///Base class for all the view scripts, this is the class that is responsible for /// support all the behind the scenes magic such as variable to PropertyBag trasnlation, @@ -28,31 +27,34 @@ namespace Castle.MonoRail.Views.Brail /// public abstract class BrailBase { - private TextWriter outputStream; + protected Controller __controller; /// - /// This is used by layout scripts only, for outputing the child's content + /// Reference to the DSL service /// - protected TextWriter childOutput; - private Hashtable properties; + private DslProvider _dsl; + /// - /// used to hold the ComponentParams from the view, so their views/sections could access them + /// This is used by layout scripts only, for outputing the child's content /// - private IList viewComponentsParameters; + protected TextWriter childOutput; protected IRailsEngineContext context; - protected Controller __controller; - protected BooViewEngine viewEngine; + private TextWriter outputStream; /// /// usually used by the layout to refer to its view, or a subview to its parent /// protected BrailBase parent; - /// - /// Reference to the DSL service - /// - private DslProvider _dsl; + private Hashtable properties; + + /// + /// used to hold the ComponentParams from the view, so their views/sections could access them + /// + private IList viewComponentsParameters; + + protected BooViewEngine viewEngine; /// /// Initializes a new instance of the class. @@ -64,17 +66,12 @@ public abstract class BrailBase public BrailBase(BooViewEngine viewEngine, TextWriter output, IRailsEngineContext context, Controller __controller) { this.viewEngine = viewEngine; - this.outputStream = output; + outputStream = output; this.context = context; this.__controller = __controller; InitProperties(context, __controller); } - /// - /// Runs this instance, this is generated by the script - /// - public abstract void Run(); - /// ///The path of the script, this is filled by AddBrailBaseClassStep @@ -94,34 +91,76 @@ public BooViewEngine ViewEngine get { return viewEngine; } } - /// - /// Gets the DSL provider - /// - /// Reference to the current DSL Provider - public DslProvider Dsl - { - get - { - BrailBase view = this; - if (null == view._dsl) - { - view._dsl = new DslProvider(view); - } - - return view._dsl; - //while (view.parent != null) - //{ - // view = view.parent; - //} - - //if (view._dsl == null) - //{ - // view._dsl = new DslProvider(view); - //} - - //return view._dsl; - } - } + /// + /// Gets the DSL provider + /// + /// Reference to the current DSL Provider + public DslProvider Dsl + { + get + { + BrailBase view = this; + if (null == view._dsl) + { + view._dsl = new DslProvider(view); + } + + return view._dsl; + //while (view.parent != null) + //{ + // view = view.parent; + //} + + //if (view._dsl == null) + //{ + // view._dsl = new DslProvider(view); + //} + + //return view._dsl; + } + } + + /// + /// Gets the flash. + /// + /// The flash. + public Flash Flash + { + get { return context.Flash; } + } + + /// + /// Gets the output stream. + /// + /// The output stream. + public TextWriter OutputStream + { + get { return outputStream; } + } + + /// + /// Gets or sets the child output. + /// + /// The child output. + public TextWriter ChildOutput + { + get { return childOutput; } + set { childOutput = value; } + } + + /// + /// Gets the properties. + /// + /// The properties. + public IDictionary Properties + { + get { return properties; } + } + + /// + /// Runs this instance, this is generated by the script + /// + public abstract void Run(); /// /// Output the subview to the client, this is either a relative path "SubView" which @@ -142,7 +181,7 @@ public string OutputSubView(string subviewName) public string OutputSubView(string subviewName, IDictionary parameters) { OutputSubView(subviewName, outputStream, parameters); - return string.Empty; + return string.Empty; } /// @@ -252,24 +291,6 @@ public bool IsDefined(string name) return search.Found; } - /// - /// Gets the flash. - /// - /// The flash. - public Flash Flash - { - get { return context.Flash; } - } - - /// - /// Gets the output stream. - /// - /// The output stream. - public TextWriter OutputStream - { - get { return outputStream; } - } - /// /// This is required because we may want to replace the output stream and get the correct /// behavior from components call RenderText() or RenderSection() @@ -282,22 +303,15 @@ public IDisposable SetOutputStream(TextWriter newOutputStream) } /// - /// Gets or sets the child output. - /// - /// The child output. - public TextWriter ChildOutput - { - get { return childOutput; } - set { childOutput = value; } - } - - /// - /// Gets the properties. + /// Will output the given value as escaped HTML /// - /// The properties. - public IDictionary Properties + /// + public void OutputEscaped(object toOutput) { - get { return properties; } + if (toOutput == null) + return; + string str = toOutput.ToString(); + OutputStream.Write(HttpUtility.HtmlEncode(str)); } /// @@ -332,27 +346,28 @@ public void RemoveViewComponentProperties(IDictionary propertiesToRemove) return; viewComponentsParameters.Remove(propertiesToRemove); } - public void RenderComponent(string componentName) - { - RenderComponent(componentName, new Hashtable()); - } - public void RenderComponent(string componentName, IDictionary parameters) - { - BrailViewComponentContext componentContext = - new BrailViewComponentContext(this, null, componentName, OutputStream, - new Hashtable(StringComparer.InvariantCultureIgnoreCase)); - this.AddViewComponentProperties(componentContext.ComponentParameters); - IViewComponentFactory componentFactory = (IViewComponentFactory)this.context.GetService(typeof(IViewComponentFactory)); - ViewComponent component = componentFactory.Create(componentName); - component.Init(this.context, componentContext); - component.Render(); - if (componentContext.ViewToRender != null) - { - this.OutputSubView("/" + componentContext.ViewToRender, componentContext.ComponentParameters); - } - this.RemoveViewComponentProperties(componentContext.ComponentParameters); - - } + + public void RenderComponent(string componentName) + { + RenderComponent(componentName, new Hashtable()); + } + + public void RenderComponent(string componentName, IDictionary parameters) + { + BrailViewComponentContext componentContext = + new BrailViewComponentContext(this, null, componentName, OutputStream, + new Hashtable(StringComparer.InvariantCultureIgnoreCase)); + AddViewComponentProperties(componentContext.ComponentParameters); + IViewComponentFactory componentFactory = (IViewComponentFactory) context.GetService(typeof (IViewComponentFactory)); + ViewComponent component = componentFactory.Create(componentName); + component.Init(context, componentContext); + component.Render(); + if (componentContext.ViewToRender != null) + { + OutputSubView("/" + componentContext.ViewToRender, componentContext.ComponentParameters); + } + RemoveViewComponentProperties(componentContext.ComponentParameters); + } /// /// Initialize all the properties that a script may need @@ -364,8 +379,9 @@ public void RenderComponent(string componentName, IDictionary parameters) private void InitProperties(IRailsEngineContext myContext, Controller myController) { properties = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - //properties.Add("dsl", new DslWrapper(this)); + //properties.Add("dsl", new DslWrapper(this)); properties.Add("Controller", myController); + properties.Add("Context", myContext); properties.Add("request", myContext.Request); properties.Add("response", myContext.Response); properties.Add("session", myContext.Session); @@ -394,7 +410,7 @@ private void InitProperties(IRailsEngineContext myContext, Controller myControll { properties[entry.Key] = entry.Value; } - + foreach (DictionaryEntry entry in myController.Helpers) { properties[entry.Key] = entry.Value; @@ -403,10 +419,18 @@ private void InitProperties(IRailsEngineContext myContext, Controller myControll properties["siteRoot"] = myContext.ApplicationPath; } + #region Nested type: ParameterSearch + private class ParameterSearch { - private bool found; - private object value; + private readonly bool found; + private readonly object value; + + public ParameterSearch(object value, bool found) + { + this.found = found; + this.value = value; + } public bool Found { @@ -417,14 +441,12 @@ public object Value { get { return value; } } - - public ParameterSearch(object value, bool found) - { - this.found = found; - this.value = value; - } } + #endregion + + #region Nested type: ReturnOutputStreamToInitialWriter + private class ReturnOutputStreamToInitialWriter : IDisposable { private TextWriter initialWriter; @@ -436,10 +458,16 @@ public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, BrailBase par this.parent = parent; } + #region IDisposable Members + public void Dispose() { parent.outputStream = initialWriter; } + + #endregion } + + #endregion } -} +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail/BrailPreProcessor.cs b/MonoRail/Castle.MonoRail.Views.Brail/BrailPreProcessor.cs index 8a1139cd3..ae496be48 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/BrailPreProcessor.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/BrailPreProcessor.cs @@ -133,7 +133,7 @@ private static void Output(StringWriter buffer, string code) string text = code.Substring(start, position.Start - start); OutputText(buffer, text); string expression = code.Substring(position.Start + 2, position.End - (position.Start + 2)); - OutputExpression(buffer, expression); + OutputExpression(buffer, expression, position.ShouldEscape); start = position.End + 1; } string remainingText = code.Substring(start, code.Length - start); @@ -148,9 +148,12 @@ private static void OutputText(StringWriter buffer, string code) buffer.WriteLine("\"\"\""); } - private static void OutputExpression(StringWriter buffer, string code) + private static void OutputExpression(TextWriter buffer, string code, bool shouldEscape) { - buffer.Write("output "); + if(shouldEscape) + buffer.Write("OutputEscaped "); + else + buffer.Write("output "); buffer.WriteLine(code); } @@ -171,11 +174,12 @@ private static IList GetExpressionsPositions(string code) { List bracesPositions = new List(); bool prevCharWasDollar = false; + bool prevCharWasBang = false; for (int index = 0; index < code.Length; index++) { if (code[index] == '{') { - bracesPositions.Add(new ExpressionPosition(index - 1, -1, prevCharWasDollar)); + bracesPositions.Add(new ExpressionPosition(index - 1, -1, prevCharWasDollar || prevCharWasBang, prevCharWasBang)); } if (code[index] == '}' && bracesPositions.Count > 0) { @@ -191,10 +195,11 @@ private static IList GetExpressionsPositions(string code) } //handles escaping expressions with $$ as well prevCharWasDollar = code[index] == '$' && !prevCharWasDollar; + prevCharWasBang = code[index] == '!' && !prevCharWasBang; } bracesPositions.RemoveAll(delegate(ExpressionPosition obj) { - return !obj.PrevCharWasDollar; + return !obj.PrevCharWasDollarOrBang; }); return bracesPositions; } @@ -205,17 +210,19 @@ private static bool ParentExpressionIsNotValid(List bracesPo if (index - 2 < 0) return false; ExpressionPosition parentExpression = bracesPositions[index - 2]; - if (parentExpression.PrevCharWasDollar == false) + if (parentExpression.PrevCharWasDollarOrBang == false) return ParentExpressionIsNotValid(bracesPositions, index - 1); return parentExpression.End == -1; } private class ExpressionPosition { - private int start, end; - private readonly bool prevCharWasDollar; + private readonly int start; + private int end; + private readonly bool prevCharWasDollarOrBang; + private readonly bool shouldEscape; - public int Start + public int Start { get { return start; } } @@ -226,16 +233,22 @@ public int End set { end = value; } } - public bool PrevCharWasDollar + public bool PrevCharWasDollarOrBang { - get { return prevCharWasDollar; } + get { return prevCharWasDollarOrBang; } } - public ExpressionPosition(int start, int end, bool prevCharWasDollar) + public bool ShouldEscape + { + get { return shouldEscape; } + } + + public ExpressionPosition(int start, int end, bool prevCharWasDollarOrBang, bool shouldEscape) { this.start = start; this.end = end; - this.prevCharWasDollar = prevCharWasDollar; + this.prevCharWasDollarOrBang = prevCharWasDollarOrBang; + this.shouldEscape = shouldEscape; } } diff --git a/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail-vs2005.csproj b/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail-vs2005.csproj index 18561fef1..758c10b54 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail-vs2005.csproj +++ b/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail-vs2005.csproj @@ -73,6 +73,7 @@ + diff --git a/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail.build b/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail.build index 30b6cba54..d03ac9b21 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail.build +++ b/MonoRail/Castle.MonoRail.Views.Brail/Castle.MonoRail.Views.Brail.build @@ -8,7 +8,7 @@ - + diff --git a/MonoRail/Castle.MonoRail.Views.Brail/FixTryGetParameterConditionalChecks.cs b/MonoRail/Castle.MonoRail.Views.Brail/FixTryGetParameterConditionalChecks.cs new file mode 100644 index 000000000..a0097aebe --- /dev/null +++ b/MonoRail/Castle.MonoRail.Views.Brail/FixTryGetParameterConditionalChecks.cs @@ -0,0 +1,78 @@ +namespace Castle.MonoRail.Views.Brail +{ + using Boo.Lang.Compiler.Ast; + using Boo.Lang.Compiler.Steps; + + /// + /// We need to handle the following code: + /// if ?Error: + /// end + /// + /// However, because ?Op will return an IgnoreNull object, we can't just + /// use the default boo behavior, but need to fix it up + /// + public class FixTryGetParameterConditionalChecks : AbstractNamespaceSensitiveTransformerCompilerStep + { + public override void Run() + { + Visit(CompileUnit); + } + + public override void OnBinaryExpression(BinaryExpression node) + { + if (node.Operator != BinaryOperatorType.Equality) + return; + + if (IsTryGetParameterInvocation(node.Left) == false && + IsTryGetParameterInvocation(node.Right) == false) + return; + + MethodInvocationExpression mie = new MethodInvocationExpression(); + ReferenceExpression expression = AstUtil.CreateReferenceExpression("Castle.MonoRail.Views.Brail.IgnoreNull.AreEqual"); + mie.Target = expression; + mie.Arguments.Add(node.Left); + mie.Arguments.Add(node.Right); + + ReplaceCurrentNode(mie); + } + + + public override void OnIfStatement(IfStatement node) + { + base.OnIfStatement(node); + node.Condition = FixCondition(node.Condition); + } + + public override void OnUnlessStatement(UnlessStatement node) + { + base.OnUnlessStatement(node); + node.Condition = FixCondition(node.Condition); + } + + private Expression FixCondition(Expression condition) + { + if (IsTryGetParameterInvocation(condition) == false) + return condition; + + string name = ((ReferenceExpression) condition).Name.Substring(1); + condition = new MethodInvocationExpression( + new MemberReferenceExpression(new SuperLiteralExpression(), "TryGetParameter"), + new StringLiteralExpression(name) + ); + + MemberReferenceExpression isNull = + new MemberReferenceExpression(condition, "_IsIgnoreNullReferencingNotNullObject_"); + + return isNull; + } + + private static bool IsTryGetParameterInvocation(Expression condition) + { + ReferenceExpression expression = condition as ReferenceExpression; + if (expression == null) + return false; + + return expression.Name.StartsWith("?"); + } + } +} \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail/IgnoreNull.cs b/MonoRail/Castle.MonoRail.Views.Brail/IgnoreNull.cs index 18b14e494..5fbd55e52 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/IgnoreNull.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/IgnoreNull.cs @@ -14,13 +14,13 @@ namespace Castle.MonoRail.Views.Brail { - using System.Reflection; + using System; + using System.Collections.Generic; using Boo.Lang; - using Castle.MonoRail.Framework; public class IgnoreNull : IQuackFu { - private object target; + private readonly object target; public IgnoreNull(object target) { @@ -29,33 +29,48 @@ public IgnoreNull(object target) public object QuackGet(string name, object[] parameters) { + if (name == "_IsIgnoreNullReferencingNotNullObject_") + return target != null; + if (target == null) return this; - PropertyInfo property = target.GetType().GetProperty(name); - if (property == null) - throw new RailsException("Could not find property " + name + " on " + target.GetType().FullName); - return new IgnoreNull(property.GetValue(target, parameters)); + object value; + if (IsNullOrEmpty(parameters)) + value = ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.GetProperty(target, name); + else + value = ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.GetSlice(target, name, parameters); + return new IgnoreNull(value); + } + + private static bool IsNullOrEmpty(object[] parameters) + { + return parameters == null || parameters.Length == 0; } public object QuackSet(string name, object[] parameters, object obj) { if (target == null) return this; - PropertyInfo property = target.GetType().GetProperty(name); - if (property == null) - throw new RailsException("Could not find property " + name + " on " + target.GetType().FullName); - property.SetValue(target, obj, parameters); + if (IsNullOrEmpty(parameters)) + ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.SetProperty(target, name, obj); + else + ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.SetSlice(target, name, GetParameterArray(parameters, obj)); return this; } + private static object[] GetParameterArray(object[] parameters, object obj) + { + List args = new List(parameters); + args.Add(obj); + return args.ToArray(); + } + public object QuackInvoke(string name, object[] args) { if (target == null) return this; - MethodInfo method = target.GetType().GetMethod(name); - if (method == null) - throw new RailsException("Could not find method " + name + " on " + target.GetType().FullName); - return new IgnoreNull(method.Invoke(target, args)); + object value = ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.Invoke(target, name, args); + return new IgnoreNull(value); } public override string ToString() @@ -64,5 +79,16 @@ public override string ToString() return string.Empty; return target.ToString(); } + + public static bool AreEqual(object left, object right) + { + IgnoreNull temp = left as IgnoreNull; + if (temp != null) + left = temp.target; + temp = right as IgnoreNull; + if (temp != null) + right = temp.target; + return Equals(left, right); + } } } diff --git a/MonoRail/Castle.MonoRail.Views.Brail/Macros/ComponentMacro.cs b/MonoRail/Castle.MonoRail.Views.Brail/Macros/ComponentMacro.cs index 31a47fb15..b145fd259 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/Macros/ComponentMacro.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/Macros/ComponentMacro.cs @@ -69,9 +69,9 @@ public override Statement Expand(MacroStatement macro) InternalLocal viewComponentFactoryLocal = CodeBuilder.DeclareLocal(method, "viewComponentFactory", TypeSystemServices.Map( typeof(IViewComponentFactory))); - // viewComponentFactory = MonoRailHttpHandler.CurrentContext.GetService(IViewComponentFactory) + // viewComponentFactory = context.GetService(IViewComponentFactory) MethodInvocationExpression callService = new MethodInvocationExpression( - AstUtil.CreateReferenceExpression("MonoRailHttpHandler.CurrentContext.GetService")); + AstUtil.CreateReferenceExpression("context.GetService")); callService.Arguments.Add(CodeBuilder.CreateTypeofExpression(typeof(IViewComponentFactory))); block.Add(new BinaryExpression(BinaryOperatorType.Assign, diff --git a/MonoRail/Castle.MonoRail.Views.Brail/ReplaceUknownWithParameters.cs b/MonoRail/Castle.MonoRail.Views.Brail/ReplaceUknownWithParameters.cs index f50ad46d5..c5bf8c097 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/ReplaceUknownWithParameters.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/ReplaceUknownWithParameters.cs @@ -18,9 +18,11 @@ namespace Castle.MonoRail.Views.Brail using Boo.Lang.Compiler.Ast; using Boo.Lang.Compiler.Steps; using Boo.Lang.Compiler.TypeSystem; - // Replace any uknown identifier with a call to GetParameter('unknown') - // this mean that unknonw identifier in scripts will only fail in run time if they - // were not defined by the controller. + /// + /// Replace any uknown identifier with a call to GetParameter('unknown') + /// this mean that unknonw identifier in scripts will only fail in run time if they + /// were not defined by the controller. + /// public class ReplaceUknownWithParameters : ProcessMethodBodiesWithDuckTyping { private IMethod _getParam; diff --git a/MonoRail/Castle.MonoRail.Views.Brail/TransformToBrailStep.cs b/MonoRail/Castle.MonoRail.Views.Brail/TransformToBrailStep.cs index 72b43c35f..94c7946b1 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/TransformToBrailStep.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/TransformToBrailStep.cs @@ -50,7 +50,7 @@ public override void Run() } ClassDefinition macro = new ClassDefinition(); - macro.Name = module.FullName + "_BrailView"; + macro.Name = GetViewTypeName(module.FullName); macro.BaseTypes.Add(new SimpleTypeReference("Castle.MonoRail.Views.Brail.BrailBase")); AddConstructor(macro); @@ -67,6 +67,11 @@ public override void Run() } } + public static string GetViewTypeName(string name) + { + return "BrailView_"+ name; + } + // get the directory name where this script reside and create a property // that return this value. // this is used to calculate relative paths when loading subviews. diff --git a/MonoRail/Castle.MonoRail.WindsorExtension/Castle.MonoRail.WindsorExtension.build b/MonoRail/Castle.MonoRail.WindsorExtension/Castle.MonoRail.WindsorExtension.build index f4c2e60cb..bf8124ee8 100644 --- a/MonoRail/Castle.MonoRail.WindsorExtension/Castle.MonoRail.WindsorExtension.build +++ b/MonoRail/Castle.MonoRail.WindsorExtension/Castle.MonoRail.WindsorExtension.build @@ -8,7 +8,7 @@ - + diff --git a/MonoRail/Castle.Monorail.JSONSupport/Castle.Monorail.JSONSupport.build b/MonoRail/Castle.Monorail.JSONSupport/Castle.Monorail.JSONSupport.build index 4c4c99d50..547b17de2 100644 --- a/MonoRail/Castle.Monorail.JSONSupport/Castle.Monorail.JSONSupport.build +++ b/MonoRail/Castle.Monorail.JSONSupport/Castle.Monorail.JSONSupport.build @@ -10,7 +10,7 @@ - + diff --git a/MonoRail/Castle.Monorail.JSONSupport/JSONBinderAttribute.cs b/MonoRail/Castle.Monorail.JSONSupport/JSONBinderAttribute.cs index 190683a8a..98e2c1cf3 100644 --- a/MonoRail/Castle.Monorail.JSONSupport/JSONBinderAttribute.cs +++ b/MonoRail/Castle.Monorail.JSONSupport/JSONBinderAttribute.cs @@ -20,9 +20,50 @@ namespace Castle.Monorail.JSONSupport using Newtonsoft.Json; /// - /// Extends with - /// the functionality. + /// Extends with the functionality. + /// In other words, enable biding of JSON formatted values on POCO objects. /// + /// + /// + /// The following demonstrates how to bind a JSON querystring value representing a Car object instance + /// to a POCO Car object instance: + /// + /// The querystring: + /// + /// car={Wheels=4,Year=2007,Model='Cheap'} + /// + /// And you want to bind those values to a instance of yours Car class, which looks like this: + /// + /// public class Car + /// { + /// private int wheels, year; + /// private string model; + /// + /// public int Wheels + /// { + /// get { return wheels; } + /// set { wheels = value; } + /// } + /// + /// public int Year + /// { + /// get { return year; } + /// set { year = value; } + /// } + /// + /// public string Model + /// { + /// get { return model; } + /// set { model = value; } + /// } + /// } + /// + /// Using the and the , all you have to + /// do is to mark the method parameter with the attribute, like the following example: + /// + /// public void MyAction([JSONBinder("car")] Car car) + /// + /// [AttributeUsage(AttributeTargets.Parameter)] public class JSONBinderAttribute : Attribute, IParameterBinder { @@ -42,16 +83,37 @@ public JSONBinderAttribute(string entryKey) this.entryKey = entryKey; } + /// + /// Gets the entry key. + /// + /// + /// The entry key, which is the form or querystring key that identifies the JSON persisted content. + /// + /// The entry key. public string EntryKey { get { return this.entryKey; } } - + + /// + /// Calculates the param points. Implementors should return value equals or greater than + /// zero indicating whether the parameter can be bound successfully. The greater the value (points) + /// the more successful the implementation indicates to the framework + /// + /// The controller. + /// The parameter info. + /// public int CalculateParamPoints(SmartDispatcherController controller, ParameterInfo parameterInfo) { return controller.Params[entryKey] != null ? 1 : 0; } + /// + /// Binds the specified parameter for the action. + /// + /// The controller. + /// The parameter info. + /// A instance based on the JSON values present in the . public object Bind(SmartDispatcherController controller, ParameterInfo parameterInfo) { string entryValue = controller.Params[entryKey]; @@ -59,6 +121,12 @@ public object Bind(SmartDispatcherController controller, ParameterInfo parameter return Bind(entryValue, parameterInfo.ParameterType); } + /// + /// Binds the specified entry value to a instance of a given Type(). + /// + /// The entry value containing the JSON formatted content. + /// Type of the binded object. + /// A instance based on the JSON values present in the . public static object Bind(string entryValue, Type parameterType) { return JavaScriptConvert.DeserializeObject(entryValue, parameterType); diff --git a/MonoRail/Castle.Monorail.JSONSupport/JSONHelper.cs b/MonoRail/Castle.Monorail.JSONSupport/JSONHelper.cs index 3c707f382..e49f8e2aa 100644 --- a/MonoRail/Castle.Monorail.JSONSupport/JSONHelper.cs +++ b/MonoRail/Castle.Monorail.JSONSupport/JSONHelper.cs @@ -17,8 +17,34 @@ namespace Castle.Monorail.JSONSupport using Castle.MonoRail.Framework.Helpers; using Newtonsoft.Json; + /// + /// Provides utilities methods to work with JSON. + /// public class JSONHelper : AbstractHelper { + /// + /// Converts a instance of the model to its JSON representation. + /// + /// The model. + /// The JSON representation of the model. + /// + /// You've constructed a car object instance, like this one: + /// + /// Car car = new Car(); + /// + /// car.Wheels = 4; + /// car.Model = "Cheap"; + /// car.Year = 2007; + /// + /// And to transform it to JSON, you must invoke the method passing the instance. + /// + /// helper.ToJSON(car) + /// + /// Which will generate the JSON string: + /// + /// {Wheels=4,Year=2007,Model='Cheap'} + /// + /// public string ToJSON(object model) { return JavaScriptConvert.SerializeObject(model); diff --git a/MonoRail/Changes.txt b/MonoRail/Changes.txt index a3a027fed..80a2a8b8e 100644 --- a/MonoRail/Changes.txt +++ b/MonoRail/Changes.txt @@ -1,9 +1,15 @@ Change history -------------- +- Applied Robert Ream's patch which allows [DefaultAction] to be applied to Actions. This means that no strings are required. + +- BaseControllerTest supports the ContextInitializer delegate, which makes it easier to modify the MockRailsEngineContext + Release Candidate 3 =================== +- Added IDisposable/Dispose back to the controller + - Applied Lee Henson's patch adding generic overloads to ReflectionHelper - Added a few more RenderView overloads that take a mimeType to configure the Response.ContentType diff --git a/MonoRail/NewGenerator/Castle.NewGenerator.CLI/Castle.NewGenerator.CLI.build b/MonoRail/NewGenerator/Castle.NewGenerator.CLI/Castle.NewGenerator.CLI.build index 1b203e92b..1acb3279c 100644 --- a/MonoRail/NewGenerator/Castle.NewGenerator.CLI/Castle.NewGenerator.CLI.build +++ b/MonoRail/NewGenerator/Castle.NewGenerator.CLI/Castle.NewGenerator.CLI.build @@ -10,7 +10,7 @@ - + diff --git a/MonoRail/NewGenerator/Castle.NewGenerator.Core/Castle.NewGenerator.Core.build b/MonoRail/NewGenerator/Castle.NewGenerator.Core/Castle.NewGenerator.Core.build index 78e6bdb55..2116f5cc8 100644 --- a/MonoRail/NewGenerator/Castle.NewGenerator.Core/Castle.NewGenerator.Core.build +++ b/MonoRail/NewGenerator/Castle.NewGenerator.Core/Castle.NewGenerator.Core.build @@ -10,7 +10,7 @@ - + diff --git a/MonoRail/NewGenerator/Castle.NewGenerator.Core/DefaultGeneratorService.cs b/MonoRail/NewGenerator/Castle.NewGenerator.Core/DefaultGeneratorService.cs index d13ed402a..b6bcead1e 100644 --- a/MonoRail/NewGenerator/Castle.NewGenerator.Core/DefaultGeneratorService.cs +++ b/MonoRail/NewGenerator/Castle.NewGenerator.Core/DefaultGeneratorService.cs @@ -90,7 +90,7 @@ public VSSolution CreateSolution(string name, string solutionFolder, params VSPr { VSSolution solution = new VSSolution(name, solutionFolder, Path.Combine(solutionFolder, name + ".sln")); - foreach(VSProject project in projects) + foreach (VSProject project in projects) { solution.Add(project); } diff --git a/MonoRail/TestSite/TestSite.build b/MonoRail/TestSite/TestSite.build index 43232c208..80fe9a18b 100644 --- a/MonoRail/TestSite/TestSite.build +++ b/MonoRail/TestSite/TestSite.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/TestSiteBrail/Controllers/HomeController.cs b/MonoRail/TestSiteBrail/Controllers/HomeController.cs index d0e19120f..d092d6bfa 100644 --- a/MonoRail/TestSiteBrail/Controllers/HomeController.cs +++ b/MonoRail/TestSiteBrail/Controllers/HomeController.cs @@ -24,6 +24,11 @@ namespace Castle.MonoRail.Views.Brail.TestSite.Controllers [Serializable] public class HomeController : Controller { + public void CanUseUrlHelperWithoutPrefix() + { + + } + public void Bag() { this.PropertyBag.Add("CustomerName", "hammett"); @@ -82,12 +87,33 @@ public void WithDynamicProxyObject() PropertyBag["src"] = o; } + public void WithNullableDynamicProxyObject() + { + ProxyGenerator generator = new ProxyGenerator(); + SimpleProxy proxy = (SimpleProxy)generator.CreateClassProxy(typeof(SimpleProxy), new StandardInterceptor()); + PropertyBag["src"] = proxy; + } + public class SimpleProxy { + private string text = "BarBaz"; + readonly Hashtable items = new Hashtable(); + + public virtual object this[string key] + { + get { return items[key]; } + set{ items[key] = value; } + } + public virtual string Text { - get { return "BarBaz"; } - set { } + get { return text; } + set { text = value;} + } + + public virtual string Say() + { + return "what?"; } } diff --git a/MonoRail/TestSiteBrail/TestSiteBrail.build b/MonoRail/TestSiteBrail/TestSiteBrail.build index d7fa96e62..097eb015d 100644 --- a/MonoRail/TestSiteBrail/TestSiteBrail.build +++ b/MonoRail/TestSiteBrail/TestSiteBrail.build @@ -30,7 +30,7 @@ - + diff --git a/MonoRail/TestSiteBrail/TestSiteBrail.csproj b/MonoRail/TestSiteBrail/TestSiteBrail.csproj index 783f244b0..899be57fb 100644 --- a/MonoRail/TestSiteBrail/TestSiteBrail.csproj +++ b/MonoRail/TestSiteBrail/TestSiteBrail.csproj @@ -211,7 +211,9 @@ + + diff --git a/MonoRail/TestSiteBrail/Views/OutputMethods/HtmlOutputAttribute.brail b/MonoRail/TestSiteBrail/Views/OutputMethods/HtmlOutputAttribute.brail index 9227fd965..554b11bf5 100644 --- a/MonoRail/TestSiteBrail/Views/OutputMethods/HtmlOutputAttribute.brail +++ b/MonoRail/TestSiteBrail/Views/OutputMethods/HtmlOutputAttribute.brail @@ -3,5 +3,5 @@ def HtmlMethod(): return "Some text that will be encoded" end -%> -${HtmlMethod()} \ No newline at end of file +output HtmlMethod() +%> \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/OutputMethods/MarkDownOutputAttribute.brail b/MonoRail/TestSiteBrail/Views/OutputMethods/MarkDownOutputAttribute.brail index efb21a049..af9437ed3 100644 --- a/MonoRail/TestSiteBrail/Views/OutputMethods/MarkDownOutputAttribute.brail +++ b/MonoRail/TestSiteBrail/Views/OutputMethods/MarkDownOutputAttribute.brail @@ -3,5 +3,5 @@ def MarkDownOutput(): return "[Ayende Rahien](http://www.ayende.com/), __Rahien__." end -%> -${MarkDownOutput()} \ No newline at end of file +output MarkDownOutput() +%> \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/OutputMethods/RawOutputAttribute.brail b/MonoRail/TestSiteBrail/Views/OutputMethods/RawOutputAttribute.brail index c77909560..f5596ae69 100644 --- a/MonoRail/TestSiteBrail/Views/OutputMethods/RawOutputAttribute.brail +++ b/MonoRail/TestSiteBrail/Views/OutputMethods/RawOutputAttribute.brail @@ -3,5 +3,5 @@ def RawOutput(): return "1<2 && 3>4" end -%> -${RawOutput()} \ No newline at end of file +output RawOutput() +%> \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/home/CanUseUrlHelperWithoutPrefix.brail b/MonoRail/TestSiteBrail/Views/home/CanUseUrlHelperWithoutPrefix.brail new file mode 100644 index 000000000..d117691cd --- /dev/null +++ b/MonoRail/TestSiteBrail/Views/home/CanUseUrlHelperWithoutPrefix.brail @@ -0,0 +1 @@ +${Url} \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/home/WithNullableDynamicProxyObject.brail b/MonoRail/TestSiteBrail/Views/home/WithNullableDynamicProxyObject.brail new file mode 100644 index 000000000..03a4b7454 --- /dev/null +++ b/MonoRail/TestSiteBrail/Views/home/WithNullableDynamicProxyObject.brail @@ -0,0 +1,12 @@ +<% output ?src.Text %> +<% +?src.Text = "foo" +output ?src.Text +%> +<% +output ?src.Say() +%> +<% +?src["hi"] = "there" +output ?src["hi"] +%> \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions.brail b/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions.brail index f93e2b892..09e9dccb9 100644 --- a/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions.brail +++ b/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions.brail @@ -1,4 +1,6 @@ -${Html.LinkToAttributed( title ,@customers, @list, { +<% +output Html.LinkToAttributed( title ,@customers, @list, { @onclick: "paginate(${pageIndex})" } -)} \ No newline at end of file +) +%> \ No newline at end of file diff --git a/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions2.brail b/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions2.brail index 5b1286b2a..bb4ae2f27 100644 --- a/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions2.brail +++ b/MonoRail/TestSiteBrail/Views/home/complexNestedExpressions2.brail @@ -1,4 +1,5 @@ -${UrlHelper.Link(title, +<% +output UrlHelper.Link(title, { @controller: "customers", @action: "list", @@ -7,4 +8,5 @@ ${UrlHelper.Link(title, { @onclick: "alert(${pageIndex})" } -)} \ No newline at end of file +) +%> \ No newline at end of file diff --git a/MonoRail/TestSiteNVelocity/TestSiteNVelocity.build b/MonoRail/TestSiteNVelocity/TestSiteNVelocity.build index d23600700..2aa0285e2 100644 --- a/MonoRail/TestSiteNVelocity/TestSiteNVelocity.build +++ b/MonoRail/TestSiteNVelocity/TestSiteNVelocity.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/TestSiteWindsor/TestSiteWindsor.build b/MonoRail/TestSiteWindsor/TestSiteWindsor.build index c0f5fc5ed..88ca111ff 100644 --- a/MonoRail/TestSiteWindsor/TestSiteWindsor.build +++ b/MonoRail/TestSiteWindsor/TestSiteWindsor.build @@ -9,7 +9,7 @@ - + diff --git a/MonoRail/monorail.build b/MonoRail/monorail.build index df3628f79..d7130d9d2 100644 --- a/MonoRail/monorail.build +++ b/MonoRail/monorail.build @@ -36,6 +36,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Setup/Binary/License.rtf b/Setup/Binary/License.rtf index 958f9f988..518d5891f 100644 --- a/Setup/Binary/License.rtf +++ b/Setup/Binary/License.rtf @@ -1,130 +1,57 @@ -{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} -{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f3\froman\fcharset2\fprq2{\*\panose 05050102010706020507}Symbol;}{\f10\fnil\fcharset2\fprq2{\*\panose 05000000000000000000}Wingdings;} -{\f35\fswiss\fcharset0\fprq2{\*\panose 020b0604030504040204}Tahoma;}{\f36\froman\fcharset238\fprq2 Times New Roman CE;}{\f37\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f39\froman\fcharset161\fprq2 Times New Roman Greek;} -{\f40\froman\fcharset162\fprq2 Times New Roman Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f42\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman Baltic;} -{\f44\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f56\fmodern\fcharset238\fprq1 Courier New CE;}{\f57\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f59\fmodern\fcharset161\fprq1 Courier New Greek;} -{\f60\fmodern\fcharset162\fprq1 Courier New Tur;}{\f61\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f62\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f63\fmodern\fcharset186\fprq1 Courier New Baltic;} -{\f64\fmodern\fcharset163\fprq1 Courier New (Vietnamese);}{\f386\fswiss\fcharset238\fprq2 Tahoma CE;}{\f387\fswiss\fcharset204\fprq2 Tahoma Cyr;}{\f389\fswiss\fcharset161\fprq2 Tahoma Greek;}{\f390\fswiss\fcharset162\fprq2 Tahoma Tur;} -{\f391\fswiss\fcharset177\fprq2 Tahoma (Hebrew);}{\f392\fswiss\fcharset178\fprq2 Tahoma (Arabic);}{\f393\fswiss\fcharset186\fprq2 Tahoma Baltic;}{\f394\fswiss\fcharset163\fprq2 Tahoma (Vietnamese);}{\f395\fswiss\fcharset222\fprq2 Tahoma (Thai);}} -{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0; -\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 -\fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\* -\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv -\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 -\f2\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 \styrsid3112477 Plain Text;}{\s16\ql \li0\ri0\sb100\sa100\sbauto1\saauto1\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 -\fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext16 \styrsid7093371 Normal (Web);}}{\*\listtable{\list\listtemplateid1165666524\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1 -\levelspace360\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\fbias0 \fi-360\li720\jclisttab\tx720\lin720 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0 -{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\fbias0 \fi-360\li1440\jclisttab\tx1440\lin1440 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698693 -\'01\u-3929 ?;}{\levelnumbers;}\f10\fbias0 \fi-360\li2160\jclisttab\tx2160\lin2160 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers -;}\f3\fbias0 \fi-360\li2880\jclisttab\tx2880\lin2880 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\fbias0 \fi-360\li3600 -\jclisttab\tx3600\lin3600 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f10\fbias0 \fi-360\li4320\jclisttab\tx4320\lin4320 } -{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\fbias0 \fi-360\li5040\jclisttab\tx5040\lin5040 }{\listlevel\levelnfc23 -\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\fbias0 \fi-360\li5760\jclisttab\tx5760\lin5760 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0 -\levelfollow0\levelstartat1\levelspace360\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f10\fbias0 \fi-360\li6480\jclisttab\tx6480\lin6480 }{\listname ;}\listid646591167}{\list\listtemplateid286263634{\listlevel\levelnfc4 -\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\jclisttab\tx720\lin720 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0 -\levelindent0{\leveltext\'02\'01.;}{\levelnumbers\'01;}\fi-360\li1440\jclisttab\tx1440\lin1440 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'02.;}{\levelnumbers\'01;}\fi-360\li2160 -\jclisttab\tx2160\lin2160 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'03.;}{\levelnumbers\'01;}\fi-360\li2880\jclisttab\tx2880\lin2880 }{\listlevel\levelnfc4\levelnfcn4\leveljc0 -\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'04.;}{\levelnumbers\'01;}\fi-360\li3600\jclisttab\tx3600\lin3600 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0 -{\leveltext\'02\'05.;}{\levelnumbers\'01;}\fi-360\li4320\jclisttab\tx4320\lin4320 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'06.;}{\levelnumbers\'01;}\fi-360\li5040 -\jclisttab\tx5040\lin5040 }{\listlevel\levelnfc4\levelnfcn4\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'07.;}{\levelnumbers\'01;}\fi-360\li5760\jclisttab\tx5760\lin5760 }{\listlevel\levelnfc4\levelnfcn4\leveljc0 -\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'08.;}{\levelnumbers\'01;}\fi-360\li6480\jclisttab\tx6480\lin6480 }{\listname ;}\listid1901746295}}{\*\listoverridetable{\listoverride\listid1901746295\listoverridecount0\ls1} -{\listoverride\listid646591167\listoverridecount0\ls2}}{\*\pgptbl {\pgp\ipgp0\itap0\li0\ri0\sb0\sa0}}{\*\rsidtbl \rsid28426\rsid3112477\rsid7093371\rsid7360708\rsid9005992\rsid10307380\rsid12669558\rsid13774519\rsid14509759\rsid14950620\rsid15481349} -{\*\generator Microsoft Word 10.0.2627;}{\info{\title Common Public License Version 1}{\author Bob Arnson}{\operator hammett}{\creatim\yr2005\mo7\dy28\hr23\min4}{\revtim\yr2006\mo10\dy13\hr10\min19}{\version8}{\edmins5}{\nofpages3}{\nofwords1362} -{\nofchars7769}{\*\company None of Your Business, Inc.}{\nofcharsws9113}{\vern16437}}\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440 -\dghshow1\dgvshow1\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\rsidroot3112477 \fet0\sectd -\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid10307380\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}} -{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang -{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain -\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid7093371 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\f35\fs20\insrsid15481349\charrsid7093371 Copyright 2004-200}{\b\f35\fs20\insrsid28426 6}{ -\b\f35\fs20\insrsid15481349\charrsid7093371 Castle Project - http://www.castleproject.org/ -\par }{\f35\fs20\insrsid15481349\charrsid7093371 -\par Licensed under the Apache License, Version 2.0 (the "License"); -\par }{\f35\fs20\insrsid7093371\charrsid7093371 {\*\bkmkstart definitions} -\par 1. Definitions{\*\bkmkend definitions}.}{\f35\fs20\insrsid7093371 -\par }{\f35\fs20\insrsid7093371\charrsid7093371 -\par "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. -\par "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. -\par "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indi -rect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. -\par "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. -\par "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. -\par "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. -\par "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). -\par "Derivative Works" shall mean any work, whether in Source or Object fo -rm, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not in -clude works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. -\par "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or addi -tions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of thi -s - definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking sy -stems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -\par "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart copyright} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 2. Grant of Copyright License{\*\bkmkend copyright}. }{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 Subject to the terms and cond -itions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and dist -ribute the Work and such Derivative Works in Source or Object form. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart patent} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 3. Grant of Patent License{\*\bkmkend patent}. }{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, roya -lty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are n -e -cessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a la -w -suit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is -filed. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart redistribution} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 4. Redistribution{\*\bkmkend redistribution}.}{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: }{ -\f35\fs20\insrsid7093371 -\par }{\f35\fs20\insrsid7093371\charrsid7093371 -\par {\listtext\pard\plain\f3\fs20\insrsid7093371\charrsid7093371 \loch\af3\dbch\af0\hich\f3 \'b7\tab}}\pard \ql \fi-360\li720\ri0\widctlpar\jclisttab\tx720\aspalpha\aspnum\faauto\ls2\adjustright\rin0\lin720\itap0\pararsid7093371 { -\f35\fs20\insrsid7093371\charrsid7093371 You must give any other recipients of the Work or Derivative Works a copy of this License; and -\par {\listtext\pard\plain\f3\fs20\insrsid7093371\charrsid7093371 \loch\af3\dbch\af0\hich\f3 \'b7\tab}You must cause any modified files to carry prominent notices stating that You changed the files; and -\par {\listtext\pard\plain\f3\fs20\insrsid7093371\charrsid7093371 \loch\af3\dbch\af0\hich\f3 \'b7\tab}You must retain, in the Source form of an -y Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and}{\f35\fs20\insrsid7093371 -\par {\listtext\pard\plain\f3\fs20\insrsid7093371\charrsid7093371 \loch\af3\dbch\af0\hich\f3 \'b7\tab}}{\f35\fs20\insrsid7093371\charrsid7093371 If the Work includes a "NOTICE" text -file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in -a -t least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if an -d - wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an - addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. -\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid7093371 {\f35\fs20\insrsid7093371 -\par }{\f35\fs20\insrsid7093371\charrsid7093371 You may add Your own copyright statement to Your modifications and may provide additional or different license terms - and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. -\par {\*\bkmkstart contributions}5. Submission of Contributions{\*\bkmkend contributions} -. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additio -nal terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart trademarks} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 6. Trademarks{\*\bkmkend trademarks}. }{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 This License d -oes not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart no_warranty} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 7. Disclaimer of Warranty{\*\bkmkend no_warranty}. }{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either ex -press or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the W -ork and assume any risks associated with Your exercise of permissions under this License. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart no_liability} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 8. Limitation of Liability{\*\bkmkend no_liability}.}{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless re -quired by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as - -a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributo -r has been advised of the possibility of such damages. -\par }{\f35\fs20\insrsid7093371 {\*\bkmkstart additional} -\par }{\f35\fs20\insrsid7093371\charrsid7093371 9. Accepting Warranty or Additional Liability{\*\bkmkend additional}. }{\f35\fs20\insrsid7093371 -\par -\par }{\f35\fs20\insrsid7093371\charrsid7093371 While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, wa -rranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if -You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. -\par }{\f35\fs20\insrsid7093371 -\par }{\f35\fs20\insrsid7093371\charrsid7093371 -\par }} \ No newline at end of file +{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}{\f1\froman\fprq2\fcharset2 Symbol;}} +{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\b\f0\fs20 Copyright 2004-2007 Castle Project - http://www.castleproject.org/\par +\b0 \par +Licensed under the Apache License, Version 2.0 (the "License");\par +\par +1. Definitions.\par +\par +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. \par +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. \par +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. \par +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. \par +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. \par +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. \par +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). \par +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. \par +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." \par +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. \par +\par +2. Grant of Copyright License. \par +\par +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. \par +\par +3. Grant of Patent License. \par +\par +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. \par +\par +4. Redistribution.\par +\par +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: \par +\par +\pard\fi-360\li720\tx720\f1\'b7\tab\f0 You must give any other recipients of the Work or Derivative Works a copy of this License; and \par +\pard\fi-360\li720\f1\'b7\tab\f0 You must cause any modified files to carry prominent notices stating that You changed the files; and \par +\f1\'b7\tab\f0 You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and\par +\f1\'b7\tab\f0 If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.\par +\pard\par +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. \par +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. \par +\par +6. Trademarks. \par +\par +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. \par +\par +7. Disclaimer of Warranty. \par +\par +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. \par +\par +8. Limitation of Liability.\par +\par +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. \par +\par +9. Accepting Warranty or Additional Liability. \par +\par +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. \par +\par +\par +} + \ No newline at end of file diff --git a/Setup/Castle.wxs b/Setup/Castle.wxs index 795d57958..de933d5a7 100644 --- a/Setup/Castle.wxs +++ b/Setup/Castle.wxs @@ -3,7 +3,7 @@ - + - + Privileged - - - - - - - - @@ -38,28 +29,23 @@ - - - - - + - + - + - + - + @@ -67,112 +53,101 @@ - + - + - + - + - + - + - + - - + - - + + - + Description='Castle documentation in chm format' Level='1'> + - + - + - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + - + diff --git a/Setup/Docs.wxs b/Setup/Docs.wxs index 17d707227..c008b0c8b 100644 --- a/Setup/Docs.wxs +++ b/Setup/Docs.wxs @@ -1,62 +1,40 @@ - + - + - + - - - - + - + + + - - - - - + + - - - + - - - - - - - - - - - - - - - - + + + + + diff --git a/Setup/Includes.wxi b/Setup/Includes.wxi index c2649a004..fa069547e 100644 --- a/Setup/Includes.wxi +++ b/Setup/Includes.wxi @@ -7,11 +7,11 @@ - + - + diff --git a/Setup/ReleaseNotes.wxs b/Setup/ReleaseNotes.wxs index f0e00e669..4a26d8bb8 100644 --- a/Setup/ReleaseNotes.wxs +++ b/Setup/ReleaseNotes.wxs @@ -1,135 +1,145 @@ - + - + - - + + - - - - - - - - - - - - + + + + + - - + - + - - - - - - + + - + + + - - - + + + + + + + + - - - - - - - - - + --> - + + + + + + - + Name="Transaction Release Notes.txt" + Source="$(var.ReleaseNotesDir)\Services\Transaction Release Notes.txt" /> - - + + - + - + diff --git a/Setup/Samples.wxs b/Setup/Samples.wxs index 416daa7b2..09750e26e 100644 --- a/Setup/Samples.wxs +++ b/Setup/Samples.wxs @@ -1,19 +1,19 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/Setup/Setup.build b/Setup/Setup.build index bfb735fef..1d636cbb2 100644 --- a/Setup/Setup.build +++ b/Setup/Setup.build @@ -19,7 +19,7 @@ - + @@ -46,38 +46,39 @@ + commandline="-nologo Castle.wxs UI.wxs Bin.wxs Docs.wxs ReleaseNotes.wxs Samples.wxs Sources.wxs WizardVs2005.wxs " /> + commandline='-wx -out ${build.msi.fullpath} Castle.wixobj UI.wixobj Bin.wixobj Docs.wixobj ReleaseNotes.wixobj Samples.wixobj Sources.wixobj WizardVs2005.wixobj" '> - - - <?xml version="1.0" encoding="utf-8"?> - <Include Id="LocationInclude"> - <?define BuildBaseDir="${path::get-full-path(build.base.dir)}"?> - <?define BuildNet11Dir="${path::get-full-path(build.base.dir)}\net-1.1\${project.config}"?> - <?define BuildNet20Dir="${path::get-full-path(build.base.dir)}\net-2.0\${project.config}"?> - <?define ReleaseNotesDir="${releasenotes.dir}"?> - <?define SharedLibs="${path::get-full-path('${root.dir}\..\..\SharedLibs')}"?> - <?define WizardDir="${path::get-full-path(root.dir)}\Tools\VSNetWizards"?> - <?define VSTemplates70="${path::get-full-path(root.dir)}\Tools\VSNetWizards\CastleTemplates\VS7"?> - <?define VSTemplates80="${path::get-full-path(root.dir)}\Tools\VSNetWizards\CastleTemplates\VS8"?> - - </Include> - + + <?xml version="1.0" encoding="utf-8"?> + <Include Id="LocationInclude"> + <?define BuildBaseDir="${path::get-full-path(build.base.dir)}"?> + <?define BuildNet11Dir="${path::get-full-path(build.base.dir)}\net-1.1\${project.config}"?> + <?define BuildNet20Dir="${path::get-full-path(build.base.dir)}\net-2.0\${project.config}"?> + <?define ReleaseNotesDir="${releasenotes.dir}"?> + <?define DocsDir="${docs.dir}"?> + <?define SharedLibs="${path::get-full-path('${root.dir}\..\..\SharedLibs')}"?> - - <?xml version="1.0" encoding="utf-8"?> - <Include Id="VersionNumberInclude"> - <?define MajorVersion="${project.major}"?> - <?define MinorVersion="${project.minor}"?> - <?define MicroVersion="${project.build}"?> - <?define BuildVersion="${project.revision}"?> - </Include> + <?define WizardDir="${path::get-full-path(root.dir)}\Tools\VSNetWizards"?> + <?define VSTemplates70="${path::get-full-path(root.dir)}\Tools\VSNetWizards\CastleTemplates\VS7"?> + <?define VSTemplates80="${path::get-full-path(root.dir)}\Tools\VSNetWizards\CastleTemplates\VS8"?> + + </Include> + + + + <?xml version="1.0" encoding="utf-8"?> + <Include Id="VersionNumberInclude"> + <?define MajorVersion="${project.major}"?> + <?define MinorVersion="${project.minor}"?> + <?define MicroVersion="${project.build}"?> + <?define BuildVersion="${project.revision}"?> + </Include> \ No newline at end of file diff --git a/Setup/Sources.wxs b/Setup/Sources.wxs index 38e12c4ff..f31952aea 100644 --- a/Setup/Sources.wxs +++ b/Setup/Sources.wxs @@ -1,15 +1,15 @@ - + - + - - - - - + + + + + - + diff --git a/Setup/UI.wxs b/Setup/UI.wxs index 36d45af42..e77b5532c 100644 --- a/Setup/UI.wxs +++ b/Setup/UI.wxs @@ -1,166 +1,166 @@ - + - - DlgFont8 - ErrorDlg + + DlgFont8 + ErrorDlg - - - - 1 - - - - - The [Wizard] will create a server image of [ProductName], at a specified network location. Click Next to continue or Cancel to exit the [Wizard]. - - - - {\VerdanaBold13}Welcome to the [ProductName] [Wizard] - - + + 1 + + + + + The [Wizard] will create a server image of [ProductName], at a specified network location. Click Next to continue or Cancel to exit the [Wizard]. + + + + {\VerdanaBold13}Welcome to the [ProductName] [Wizard] + + - - - 1 - - - - - - - Please wait while the [Wizard] prepares to guide you through the installation. - - - - - - {\VerdanaBold13}Welcome to the [ProductName] [Wizard] - - - - - + + + 1 + + + + + + + Please wait while the [Wizard] prepares to guide you through the installation. + + + + + + {\VerdanaBold13}Welcome to the [ProductName] [Wizard] + + + + + - - - 1 - - - - - - - - - Please wait while the [Wizard] [Progress2] [ProductName]. This may take several minutes. - - - - [DlgTitleFont][Progress1] [ProductName] - - - - - - - + + + 1 + + + + + + + + + Please wait while the [Wizard] [Progress2] [ProductName]. This may take several minutes. + + + + [DlgTitleFont][Progress1] [ProductName] + + + + + + + - - - 1 - - - - - - - {\VerdanaBold13}[ProductName] [Wizard] was interrupted - - - [ProductName] setup was interrupted. Your system has not been modified. To install this program at a later time, please run the installation again. - - - Click the Finish button to exit the [Wizard]. - - + + + 1 + + + + + + + {\VerdanaBold13}[ProductName] [Wizard] was interrupted + + + [ProductName] setup was interrupted. Your system has not been modified. To install this program at a later time, please run the installation again. + + + Click the Finish button to exit the [Wizard]. + + - - - 1 - - - - - - - {\VerdanaBold13}[ProductName] [Wizard] ended prematurely - - - [ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again. - - - Click the Finish button to exit the [Wizard]. - - + + + 1 + + + + + + + {\VerdanaBold13}[ProductName] [Wizard] ended prematurely + + + [ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again. + + + Click the Finish button to exit the [Wizard]. + + - - - 1 - - - - - - Click the Finish button to exit the [Wizard]. - - - - {\VerdanaBold13}[ProductName] [Wizard] completed successfully - - + + + 1 + + + + + + Click the Finish button to exit the [Wizard]. + + + + {\VerdanaBold13}[ProductName] [Wizard] completed successfully + + - - - - 1 - 1 - - - 1 - 1 - - - - - - - 1 - - - 1 - - - - - - Browse to the destination folder - - - - [DlgTitleFont]Change current destination folder - - - + + + + 1 + 1 + + + 1 + 1 + + + + + + + 1 + + + 1 + + + + + + Browse to the destination folder + + + + [DlgTitleFont]Change current destination folder + + + - - - - - - 1 - 1 - - - 1 - 1 - - - - - - - 1 - - - 1 - - - - - - Browse to the destination folder - - - - [DlgTitleFont]Change current destination folder - - - + + + + 1 + 1 + + + 1 + 1 + + + + + + + 1 + + + 1 + + + + + + Browse to the destination folder + + + + [DlgTitleFont]Change current destination folder + + + - - - 1 - - - 1 - - - Are you sure you want to cancel [ProductName] installation? - - - + + + 1 + + + 1 + + + Are you sure you want to cancel [ProductName] installation? + + + - - - - 1 - Installed - - - 1 - - - - Disk &Usage - 1 - - - - - - - - 1 - - - - 1 - - - - Select the way you want features to be installed. - - - Click on the icons in the tree below to change the way features will be installed. - - - - [DlgTitleFont]Custom Setup - - - - - Multiline description of the currently selected item. - - - - The size of the currently selected item. - - - - <The selection's path> - - - Installed - - - - Installed - - + + + + 1 + Installed + + + 1 + + + + Disk &Usage + 1 + + + + + + + + + + + + 1 + + + + 1 + + + + Select the way you want features to be installed. + + + Click on the icons in the tree below to change the way features will be installed. + + + + [DlgTitleFont]Custom Setup + + + + + Multiline description of the currently selected item. + + + + The size of the currently selected item. + + + + <The selection's path> + + + Installed + + + + Installed + + - - - 1 - - - - The disk space required for the installation of the selected features. - - - The highlighted volumes (if any) do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). - - - - [DlgTitleFont]Disk Space Requirements - - - - {120}{70}{70}{70}{70} - - + + + 1 + + + + The disk space required for the installation of the selected features. + + + The highlighted volumes (if any) do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). + + + + [DlgTitleFont]Disk Space Requirements + + + + {120}{70}{70}{70}{70} + + - - - - 1 - - - 1 - - - 1 - - - - 1 - - - 1 - - - 1 - - - 1 - - + + + + 1 + + + 1 + + + 1 + + + + 1 + + + 1 + + + 1 + + + 1 + + - - - 1 - - - 1 - - - 1 - - - - Some files that need to be updated are currently in use. - - - The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it. - - - - [DlgTitleFont]Files in Use - - - - + + + 1 + + + 1 + + + 1 + + + + Some files that need to be updated are currently in use. + + + The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it. + + + + [DlgTitleFont]Files in Use + + + + - - - - 1 - - - - CostingComplete = 1 - 1]]> - "Yes"]]> - IAgree = "Yes" - - - 1 - - - - - - - Please read the following license agreement carefully - - - - [DlgTitleFont]End-User License Agreement - - - + + + + 1 + + + + + + CostingComplete = 1 + + 1]]> + + "Yes"]]> + IAgree = "Yes" + + + 1 + + + + + + + Please read the following license agreement carefully + + + + [DlgTitleFont]End-User License Agreement + + + - - - [DlgTitleFont]&Modify - - - 1 - 1 - 1 - 1 - - - [DlgTitleFont]Re&pair - - - 1 - 1 - 1 - 1 - - - [DlgTitleFont]&Remove - - - 1 - 1 - 1 - 1 - - - 1 - - - - 1 - - - - Select the operation you wish to perform. - - - - [DlgTitleFont]Modify, Repair or Remove installation - - - - Allows users to change the way features are installed. - - - Removes [ProductName] from your computer. - - - Repairs errors in the most recent installation state - fixes missing or corrupt files, shortcuts and registry entries. - - + + + [DlgTitleFont]&Modify + + + 1 + 1 + 1 + 1 + + + [DlgTitleFont]Re&pair + + + 1 + 1 + 1 + 1 + + + [DlgTitleFont]&Remove + + + 1 + 1 + 1 + 1 + + + 1 + + + + 1 + + + + Select the operation you wish to perform. + + + + [DlgTitleFont]Modify, Repair or Remove installation + + + + Allows users to change the way features are installed. + + + Removes [ProductName] from your computer. + + + Repairs errors in the most recent installation state - fixes missing or corrupt files, shortcuts and registry entries. + + - - - CostingComplete = 1 - 1 - - - 1 - - - - - The [Wizard] will allow you to change the way [ProductName] features are installed on your computer or even to remove [ProductName] from your computer. Click Next to continue or Cancel to exit the [Wizard]. - - - - {\VerdanaBold13}Welcome to the [ProductName] [Wizard] - - + + + CostingComplete = 1 + 1 + + + 1 + + + + + The [Wizard] will allow you to change the way [ProductName] features are installed on your computer or even to remove [ProductName] from your computer. Click Next to continue or Cancel to exit the [Wizard]. + + + + {\VerdanaBold13}Welcome to the [ProductName] [Wizard] + + - - - 1 - - - - Disk space required for the installation exceeds available disk space. - - - The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). - - - - [DlgTitleFont]Out of Disk Space - - - - {120}{70}{70}{70}{70} - - + + + 1 + + + + Disk space required for the installation exceeds available disk space. + + + The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). + + + + [DlgTitleFont]Out of Disk Space + + + + {120}{70}{70}{70}{70} + + - - - 1 - - - 1 - 1 - - - - Disk space required for the installation exceeds available disk space. - - - The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). - - - - [DlgTitleFont]Out of Disk Space - - - - {120}{70}{70}{70}{70} - - - Alternatively, you may choose to disable the installer's rollback functionality. This allows the installer to restore your computer's original state should the installation be interrupted in any way. Click Yes if you wish to take the risk to disable rollback. - - + + + 1 + + + 1 + 1 + + + + Disk space required for the installation exceeds available disk space. + + + The highlighted volumes do not have enough disk space available for the currently selected features. You can either remove some files from the highlighted volumes, or choose to install less features onto local drive(s), or select different destination drive(s). + + + + [DlgTitleFont]Out of Disk Space + + + + {120}{70}{70}{70}{70} + + + Alternatively, you may choose to disable the installer's rollback functionality. This allows the installer to restore your computer's original state should the installation be interrupted in any way. Click Yes if you wish to take the risk to disable rollback. + + - - - CostingComplete = 1 - 1]]> - - - - - - - 1 - - - - - The [Wizard] will complete the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the [Wizard]. - - - - {\VerdanaBold13}Resuming the [ProductName] [Wizard] - - + + + CostingComplete = 1 + + 1]]> + + + + + + + + + + + + + + + 1 + + + + + The [Wizard] will complete the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the [Wizard]. + + + + {\VerdanaBold13}Resuming the [ProductName] [Wizard] + + - - - - [DlgTitleFont]C&ustom - - - 1 - 1 - - - Allows users to choose which program features will be installed and where they will be installed. Recommended for advanced users. - + + [DlgTitleFont]C&ustom + + + 1 + 1 + + + Allows users to choose which program features will be installed and where they will be installed. Recommended for advanced users. + - - [DlgTitleFont]C&omplete - - - 1 - 1 - 1 - - - All program features will be installed. (Requires most disk space) - - - - 1]]> - ShowUserRegistrationDlg = 1 - - - - 1 - - - - Choose the setup type that best suits your needs - - - - [DlgTitleFont]Choose Setup Type - - - + + [DlgTitleFont]C&omplete + + + 1 + 1 + 1 + + + All program features will be installed. (Requires most disk space) + - - - - - - - CD &Key: - - - - 1 - - - 0 - CostingComplete = 1 - ProductID - - - 1 - - - - Please enter your customer information - - - - [DlgTitleFont]Customer Information - - - + + + 1]]> + ShowUserRegistrationDlg = 1 + + + + 1 + + + + Choose the setup type that best suits your needs + + + + [DlgTitleFont]Choose Setup Type + + + - - - 1]]> - - - - - - - 1 - - - - - - - - - - The [Wizard] is ready to begin the [InstallMode] installation - - - Click Install to begin the installation. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. - - - - [DlgTitleFont]Ready to Install - - - + + + + + + + + + + + + The [Wizard] is ready to begin the [InstallMode] installation + + + Click Install to begin the installation. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. + + + + [DlgTitleFont]Ready to Install + + + - - - 1 - - - 1]]> - 1]]> - - - - - - - 1 - - - - You have chosen to remove the program from your computer. - - - Click Remove to remove [ProductName] from your computer. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. - - - - [DlgTitleFont]Remove [ProductName] - - - + + + 1 + + + + 1]]> + + 1]]> + + + + + + + + + + + + + + + 1 + + + + You have chosen to remove the program from your computer. + + + Click Remove to remove [ProductName] from your computer. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. + + + + [DlgTitleFont]Remove [ProductName] + + + - - - 1]]> - 1]]> - 1]]> - - - - - - - 1 - - - - 1 - - - The [Wizard] is ready to begin the repair of [ProductName]. - - - Click Repair to repair the installation of [ProductName]. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. - - - - [DlgTitleFont]Repair [ProductName] - - - + + + + 1]]> + + 1]]> + + 1]]> + + + + + + + + + + + + + + + 1 + + + + 1 + + + The [Wizard] is ready to begin the repair of [ProductName]. + + + Click Repair to repair the installation of [ProductName]. If you want to review or change any of your installation settings, click Back. Click Cancel to exit the wizard. + + + + [DlgTitleFont]Repair [ProductName] + + + - - - 1 - - - Please wait while the installer finishes determining your disk space requirements. - - - + + + 1 + + + Please wait while the installer finishes determining your disk space requirements. + + + - - - 1 - - - 1 - - - - - The [Wizard] will install [ProductName] on your computer. Click Next to continue or Cancel to exit the [Wizard]. - - - - {\VerdanaBold13}Welcome to the [ProductName] [Wizard] - - + + + 1 + + + 1 + + + + + The [Wizard] will install [ProductName] on your computer. Click Next to continue or Cancel to exit the [Wizard]. + + + + {\VerdanaBold13}Welcome to the [ProductName] [Wizard] + + + + + + + - - - - + + + - - - + + bytes + GB + KB + MB + Entire feature will be unavailable + Feature will be installed when required + Entire feature will be installed to run from CD + Entire feature will be installed on local hard drive + Entire feature will be installed to run from network + Will be installed to run from CD + Will be installed on local hard drive + Will be installed to run from network + Gathering required information... + This feature will remain uninstalled + This feature will be set to be installed when required + This feature will be installed to run from CD + This feature will be installed on the local hard drive + This feature will be installed to run from the network + This feature will become unavailable + Will be installed when required + This feature will be available to run from CD + This feature will be installed on your local hard drive + This feature will be available to run from the network + This feature will be uninstalled completely, you won't be able to run it from CD + This feature will change from run from CD state to set to be installed when required + This feature will remain to be run from CD + This feature will change from run from CD state to be installed on the local hard drive + This feature frees up [1] on your hard drive. + This feature requires [1] on your hard drive. + Compiling cost for this feature... + This feature will be completely removed + This feature will be removed from your local hard drive, but will be set to be installed when required + This feature will be removed from your local hard drive, but will be still available to run from CD + This feature will remain on you local hard drive + This feature will be removed from your local hard drive, but will be still available to run from the network + This feature will be uninstalled completely, you won't be able to run it from the network + This feature will change from run from network state to set to be installed when required + This feature will change from run from network state to be installed on the local hard drive + This feature will remain to be run from the network + This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive. + This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive. + This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive. + This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive. + Time remaining: {[1] minutes }{[2] seconds} + Available + Difference + Required + Disk Size + Volume + Computing space requirements + Computing space requirements + Computing space requirements + Validating install + Copying new files + Copying network install files + Creating shortcuts + Publishing Qualified Components + Publishing Product Features + Publishing product information + Registering Class servers + Registering extension servers + Registering MIME info + Registering program identifiers + Allocating registry space + Searching for installed applications + Binding executables + Searching for qualifying products + Creating folders + Deleting services + Creating duplicate files + Searching for related applications + Installing ODBC components + Installing new services + Evaluating launch conditions + Migrating feature states from related applications + Moving files + Patching files + Updating component registration + Registering COM+ Applications and Components + Registering fonts + Registering product + Registering type libraries + Registering user + Removing duplicated files + Updating environment strings + Removing applications + Removing files + Removing folders + Removing INI files entries + Removing ODBC components + Removing system registry values + Removing shortcuts + Searching for qualifying products + Registering modules + Unregistering modules + Initializing ODBC directories + Starting services + Stopping services + Unpublishing Qualified Components + Unpublishing Product Features + Unregister Class servers + Unregistering COM+ Applications and Components + Unregistering extension servers + Unregistering fonts + Unregistering MIME info + Unregistering program identifiers + Unregistering type libraries + Updating environment strings + Writing INI files values + Writing system registry values + Advertising application + Generating script operations for action: + Installing system catalog + Publishing assembly information + Unpublishing assembly information + Rolling back action: + Removing backup files + Removing moved files + Unpublishing product information + {{Fatal error: }} + {{Error [1]. }} + Warning [1]. + + Info [1]. + The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is [1]. {{The arguments are: [2], [3], [4]}} + + {{Disk full: }} + Action [Time]: [1]. [2] + [ProductName] + {[2]}{, [3]}{, [4]} + Message type: [1], Argument: [2] + === Logging started: [Date] [Time] === + === Logging stopped: [Date] [Time] === + Action start [Time]: [1]. + Action ended [Time]: [1]. Return value [2]. + Time remaining: {[1] minutes }{[2] seconds} + Out of memory. Shut down other applications before retrying. + Installer is no longer responding. + Installer stopped prematurely. + Please wait while Windows configures [ProductName] + Gathering required information... + Removing older versions of this application... + Preparing to remove older versions of this application... + {[ProductName] }Setup completed successfully. + {[ProductName] }Setup failed. + Error reading from file: [2]. {{ System error [3].}} Verify that the file exists and that you can access it. + Cannot create the file '[2]'. A directory with this name already exists. Cancel the install and try installing to a different location. + Please insert the disk: [2] + The installer has insufficient privileges to access this directory: [2]. The installation cannot continue. Log on as administrator or contact your system administrator. + Error writing to file: [2]. Verify that you have access to that directory. + Error reading from file [2]. {{ System error [3].}} Verify that the file exists and that you can access it. + Another application has exclusive access to the file '[2]'. Please shut down all other applications, then click Retry. + There is not enough disk space to install this file: [2]. Free some disk space and click Retry, or click Cancel to exit. + Source file not found: [2]. Verify that the file exists and that you can access it. + Error reading from file: [3]. {{ System error [2].}} Verify that the file exists and that you can access it. + Error writing to file: [3]. {{ System error [2].}} Verify that you have access to that directory. + Source file not found{{(cabinet)}}: [2]. Verify that the file exists and that you can access it. + Cannot create the directory '[2]'. A file with this name already exists. Please rename or remove the file and click retry, or click Cancel to exit. + The volume [2] is currently unavailable. Please select another. + The specified path '[2]' is unavailable. + Unable to write to the specified folder: [2]. + A network error occurred while attempting to read from the file: [2] + An error occurred while attempting to create the directory: [2] + A network error occurred while attempting to create the directory: [2] + A network error occurred while attempting to open the source file cabinet: [2] + The specified path is too long: [2] + The Installer has insufficient privileges to modify this file: [2]. + A portion of the folder path '[2]' is invalid. It is either empty or exceeds the length allowed by the system. + The folder path '[2]' contains words that are not valid in folder paths. + The folder path '[2]' contains an invalid character. + '[2]' is not a valid short file name. + Error getting file security: [3] GetLastError: [2] + Invalid Drive: [2] + Error applying patch to file [2]. It has probably been updated by other means, and can no longer be modified by this patch. For more information contact your patch vendor. {{System Error: [3]}} + A file that is required cannot be installed because the cabinet file [2] is not digitally signed. This may indicate that the cabinet file is corrupt. + A file that is required cannot be installed because the cabinet file [2] has an invalid digital signature. This may indicate that the cabinet file is corrupt.{{ Error [3] was returned by WinVerifyTrust.}} + Failed to correctly copy [2] file: CRC error. + Failed to correctly move [2] file: CRC error. + Failed to correctly patch [2] file: CRC error. + The file '[2]' cannot be installed because the file cannot be found in cabinet file '[3]'. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package. + The cabinet file '[2]' required for this installation is corrupt and cannot be used. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package. + There was an error creating a temporary file that is needed to complete this installation.{{ Folder: [3]. System error code: [2]}} + Could not create key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not open key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not delete value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not delete key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not read value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not write value [2] to key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not get value names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not get sub key names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not read security information for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. + Could not increase the available registry space. [2] KB of free registry space is required for the installation of this application. + Another installation is in progress. You must complete that installation before continuing this one. + Error accessing secured data. Please make sure the Windows Installer is configured properly and try the install again. + User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. Your current install will now continue. + User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. + Out of disk space -- Volume: '[2]'; required space: [3] KB; available space: [4] KB. Free some disk space and retry. + Are you sure you want to cancel? + The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}. Close that application and retry. + The product '[2]' is already installed, preventing the installation of this product. The two products are incompatible. + There is not enough disk space on the volume '[2]' to continue the install with recovery enabled. [3] KB are required, but only [4] KB are available. Click Ignore to continue the install without saving recovery information, click Retry to check for available space again, or click Cancel to quit the installation. + Could not access network location [2]. + The following applications should be closed before continuing the install: + Could not find any previously installed compliant products on the machine for installing this product. + An error occurred while applying security settings. [2] is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. {{Unable to locate the user's SID, system error [3]}} + The key [2] is not valid. Verify that you entered the correct key. + The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to manually restart later. + You must restart your system for the configuration changes made to [2] to take effect. Click Yes to restart now or No if you plan to manually restart later. + An installation for [2] is currently suspended. You must undo the changes made by that installation to continue. Do you want to undo those changes? + A previous installation for this product is in progress. You must undo the changes made by that installation to continue. Do you want to undo those changes? + An installation package for the product [2] cannot be found. Try the installation again using a valid copy of the installation package '[3]'. + Installation completed successfully. + Installation failed. + Product: [2] -- [3] + You may either restore your computer to its previous state or continue the install later. Would you like to restore? + An error occurred while writing installation information to disk. Check to make sure enough disk space is available, and click Retry, or Cancel to end the install. + One or more of the files required to restore your computer to its previous state could not be found. Restoration will not be possible. + [2] cannot install one of its required products. Contact your technical support group. {{System Error: [3].}} + The older version of [2] cannot be removed. Contact your technical support group. {{System Error [3].}} + Installed [2] + Configured [2] + Removed [2] + File [2] was rejected by digital signature policy. + The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance. + There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. {{Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] }} + There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action: [2], location: [3], command: [4] }} + There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. {{Action [2], location: [3], command: [4] }} + There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action [2], entry: [3], library: [4] }} + Removal completed successfully. + Removal failed. + Advertisement completed successfully. + Advertisement failed. + Configuration completed successfully. + Configuration failed. + You must be an Administrator to remove this application. To remove this application, you can log on as an Administrator, or contact your technical support group for assistance. + The path [2] is not valid. Please specify a valid path. + Out of memory. Shut down other applications before retrying. + There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to go back to the previously selected volume. + There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to return to the browse dialog and select a different volume. + The folder [2] does not exist. Please enter a path to an existing folder. + You have insufficient privileges to read this folder. + A valid destination folder for the install could not be determined. + Error attempting to read from the source install database: [2]. + Scheduling reboot operation: Renaming file [2] to [3]. Must reboot to complete operation. + Scheduling reboot operation: Deleting file [2]. Must reboot to complete operation. + Module [2] failed to register. HRESULT [3]. Contact your support personnel. + Module [2] failed to unregister. HRESULT [3]. Contact your support personnel. + Failed to cache package [2]. Error: [3]. Contact your support personnel. + Could not register font [2]. Verify that you have sufficient permissions to install fonts, and that the system supports this font. + Could not unregister font [2]. Verify that you that you have sufficient permissions to remove fonts. + Could not create Shortcut [2]. Verify that the destination folder exists and that you can access it. + Could not remove Shortcut [2]. Verify that the shortcut file exists and that you can access it. + Could not register type library for file [2]. Contact your support personnel. + Could not unregister type library for file [2]. Contact your support personnel. + Could not update the ini file [2][3]. Verify that the file exists and that you can access it. + Could not schedule file [2] to replace file [3] on reboot. Verify that you have write permissions to file [3]. + Error removing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel. + Error installing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel. + Error removing ODBC driver: [4], ODBC error [2]: [3]. Verify that you have sufficient privileges to remove ODBC drivers. + Error installing ODBC driver: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it. + Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it. + Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services. + Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services. + Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services. + Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services. + Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables. + You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation. + Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file. + Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000. + Error registering COM+ Application. Contact your support personnel for more information. + Error unregistering COM+ Application. Contact your support personnel for more information. + The description for service '[2]' ([3]) could not be changed. + The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}} + The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}} + The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\r\n[3]}} + User installations are disabled via policy on the machine. + An error occured during the installation of assembly component [2]. HRESULT: [3]. {{assembly interface: [4], function: [5], assembly name: [6]}} - - bytes - GB - KB - MB - Entire feature will be unavailable - Feature will be installed when required - Entire feature will be installed to run from CD - Entire feature will be installed on local hard drive - Entire feature will be installed to run from network - Will be installed to run from CD - Will be installed on local hard drive - Will be installed to run from network - Gathering required information... - This feature will remain uninstalled - This feature will be set to be installed when required - This feature will be installed to run from CD - This feature will be installed on the local hard drive - This feature will be installed to run from the network - This feature will become unavailable - Will be installed when required - This feature will be available to run from CD - This feature will be installed on your local hard drive - This feature will be available to run from the network - This feature will be uninstalled completely, you won't be able to run it from CD - This feature will change from run from CD state to set to be installed when required - This feature will remain to be run from CD - This feature will change from run from CD state to be installed on the local hard drive - This feature frees up [1] on your hard drive. - This feature requires [1] on your hard drive. - Compiling cost for this feature... - This feature will be completely removed - This feature will be removed from your local hard drive, but will be set to be installed when required - This feature will be removed from your local hard drive, but will be still available to run from CD - This feature will remain on you local hard drive - This feature will be removed from your local hard drive, but will be still available to run from the network - This feature will be uninstalled completely, you won't be able to run it from the network - This feature will change from run from network state to set to be installed when required - This feature will change from run from network state to be installed on the local hard drive - This feature will remain to be run from the network - This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive. - This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive. - This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive. - This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive. - Time remaining: {[1] minutes }{[2] seconds} - Available - Difference - Required - Disk Size - Volume - Computing space requirements - Computing space requirements - Computing space requirements - Validating install - Copying new files - Copying network install files - Creating shortcuts - Publishing Qualified Components - Publishing Product Features - Publishing product information - Registering Class servers - Registering extension servers - Registering MIME info - Registering program identifiers - Allocating registry space - Searching for installed applications - Binding executables - Searching for qualifying products - Creating folders - Deleting services - Creating duplicate files - Searching for related applications - Installing ODBC components - Installing new services - Evaluating launch conditions - Migrating feature states from related applications - Moving files - Patching files - Updating component registration - Registering COM+ Applications and Components - Registering fonts - Registering product - Registering type libraries - Registering user - Removing duplicated files - Updating environment strings - Removing applications - Removing files - Removing folders - Removing INI files entries - Removing ODBC components - Removing system registry values - Removing shortcuts - Searching for qualifying products - Registering modules - Unregistering modules - Initializing ODBC directories - Starting services - Stopping services - Unpublishing Qualified Components - Unpublishing Product Features - Unregister Class servers - Unregistering COM+ Applications and Components - Unregistering extension servers - Unregistering fonts - Unregistering MIME info - Unregistering program identifiers - Unregistering type libraries - Updating environment strings - Writing INI files values - Writing system registry values - Advertising application - Generating script operations for action: - Installing system catalog - Publishing assembly information - Unpublishing assembly information - Rolling back action: - Removing backup files - Removing moved files - Unpublishing product information - {{Fatal error: }} - {{Error [1]. }} - Warning [1]. - - Info [1]. - The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is [1]. {{The arguments are: [2], [3], [4]}} - - {{Disk full: }} - Action [Time]: [1]. [2] - [ProductName] - {[2]}{, [3]}{, [4]} - Message type: [1], Argument: [2] - === Logging started: [Date] [Time] === - === Logging stopped: [Date] [Time] === - Action start [Time]: [1]. - Action ended [Time]: [1]. Return value [2]. - Time remaining: {[1] minutes }{[2] seconds} - Out of memory. Shut down other applications before retrying. - Installer is no longer responding. - Installer stopped prematurely. - Please wait while Windows configures [ProductName] - Gathering required information... - Removing older versions of this application... - Preparing to remove older versions of this application... - {[ProductName] }Setup completed successfully. - {[ProductName] }Setup failed. - Error reading from file: [2]. {{ System error [3].}} Verify that the file exists and that you can access it. - Cannot create the file '[2]'. A directory with this name already exists. Cancel the install and try installing to a different location. - Please insert the disk: [2] - The installer has insufficient privileges to access this directory: [2]. The installation cannot continue. Log on as administrator or contact your system administrator. - Error writing to file: [2]. Verify that you have access to that directory. - Error reading from file [2]. {{ System error [3].}} Verify that the file exists and that you can access it. - Another application has exclusive access to the file '[2]'. Please shut down all other applications, then click Retry. - There is not enough disk space to install this file: [2]. Free some disk space and click Retry, or click Cancel to exit. - Source file not found: [2]. Verify that the file exists and that you can access it. - Error reading from file: [3]. {{ System error [2].}} Verify that the file exists and that you can access it. - Error writing to file: [3]. {{ System error [2].}} Verify that you have access to that directory. - Source file not found{{(cabinet)}}: [2]. Verify that the file exists and that you can access it. - Cannot create the directory '[2]'. A file with this name already exists. Please rename or remove the file and click retry, or click Cancel to exit. - The volume [2] is currently unavailable. Please select another. - The specified path '[2]' is unavailable. - Unable to write to the specified folder: [2]. - A network error occurred while attempting to read from the file: [2] - An error occurred while attempting to create the directory: [2] - A network error occurred while attempting to create the directory: [2] - A network error occurred while attempting to open the source file cabinet: [2] - The specified path is too long: [2] - The Installer has insufficient privileges to modify this file: [2]. - A portion of the folder path '[2]' is invalid. It is either empty or exceeds the length allowed by the system. - The folder path '[2]' contains words that are not valid in folder paths. - The folder path '[2]' contains an invalid character. - '[2]' is not a valid short file name. - Error getting file security: [3] GetLastError: [2] - Invalid Drive: [2] - Error applying patch to file [2]. It has probably been updated by other means, and can no longer be modified by this patch. For more information contact your patch vendor. {{System Error: [3]}} - A file that is required cannot be installed because the cabinet file [2] is not digitally signed. This may indicate that the cabinet file is corrupt. - A file that is required cannot be installed because the cabinet file [2] has an invalid digital signature. This may indicate that the cabinet file is corrupt.{{ Error [3] was returned by WinVerifyTrust.}} - Failed to correctly copy [2] file: CRC error. - Failed to correctly move [2] file: CRC error. - Failed to correctly patch [2] file: CRC error. - The file '[2]' cannot be installed because the file cannot be found in cabinet file '[3]'. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package. - The cabinet file '[2]' required for this installation is corrupt and cannot be used. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package. - There was an error creating a temporary file that is needed to complete this installation.{{ Folder: [3]. System error code: [2]}} - Could not create key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not open key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not delete value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not delete key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not read value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not write value [2] to key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not get value names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not get sub key names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not read security information for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. - Could not increase the available registry space. [2] KB of free registry space is required for the installation of this application. - Another installation is in progress. You must complete that installation before continuing this one. - Error accessing secured data. Please make sure the Windows Installer is configured properly and try the install again. - User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. Your current install will now continue. - User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. - Out of disk space -- Volume: '[2]'; required space: [3] KB; available space: [4] KB. Free some disk space and retry. - Are you sure you want to cancel? - The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}. Close that application and retry. - The product '[2]' is already installed, preventing the installation of this product. The two products are incompatible. - There is not enough disk space on the volume '[2]' to continue the install with recovery enabled. [3] KB are required, but only [4] KB are available. Click Ignore to continue the install without saving recovery information, click Retry to check for available space again, or click Cancel to quit the installation. - Could not access network location [2]. - The following applications should be closed before continuing the install: - Could not find any previously installed compliant products on the machine for installing this product. - An error occurred while applying security settings. [2] is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. {{Unable to locate the user's SID, system error [3]}} - The key [2] is not valid. Verify that you entered the correct key. - The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to manually restart later. - You must restart your system for the configuration changes made to [2] to take effect. Click Yes to restart now or No if you plan to manually restart later. - An installation for [2] is currently suspended. You must undo the changes made by that installation to continue. Do you want to undo those changes? - A previous installation for this product is in progress. You must undo the changes made by that installation to continue. Do you want to undo those changes? - An installation package for the product [2] cannot be found. Try the installation again using a valid copy of the installation package '[3]'. - Installation completed successfully. - Installation failed. - Product: [2] -- [3] - You may either restore your computer to its previous state or continue the install later. Would you like to restore? - An error occurred while writing installation information to disk. Check to make sure enough disk space is available, and click Retry, or Cancel to end the install. - One or more of the files required to restore your computer to its previous state could not be found. Restoration will not be possible. - [2] cannot install one of its required products. Contact your technical support group. {{System Error: [3].}} - The older version of [2] cannot be removed. Contact your technical support group. {{System Error [3].}} - Installed [2] - Configured [2] - Removed [2] - File [2] was rejected by digital signature policy. - The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance. - There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. {{Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] }} - There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action: [2], location: [3], command: [4] }} - There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. {{Action [2], location: [3], command: [4] }} - There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action [2], entry: [3], library: [4] }} - Removal completed successfully. - Removal failed. - Advertisement completed successfully. - Advertisement failed. - Configuration completed successfully. - Configuration failed. - You must be an Administrator to remove this application. To remove this application, you can log on as an Administrator, or contact your technical support group for assistance. - The path [2] is not valid. Please specify a valid path. - Out of memory. Shut down other applications before retrying. - There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to go back to the previously selected volume. - There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to return to the browse dialog and select a different volume. - The folder [2] does not exist. Please enter a path to an existing folder. - You have insufficient privileges to read this folder. - A valid destination folder for the install could not be determined. - Error attempting to read from the source install database: [2]. - Scheduling reboot operation: Renaming file [2] to [3]. Must reboot to complete operation. - Scheduling reboot operation: Deleting file [2]. Must reboot to complete operation. - Module [2] failed to register. HRESULT [3]. Contact your support personnel. - Module [2] failed to unregister. HRESULT [3]. Contact your support personnel. - Failed to cache package [2]. Error: [3]. Contact your support personnel. - Could not register font [2]. Verify that you have sufficient permissions to install fonts, and that the system supports this font. - Could not unregister font [2]. Verify that you that you have sufficient permissions to remove fonts. - Could not create Shortcut [2]. Verify that the destination folder exists and that you can access it. - Could not remove Shortcut [2]. Verify that the shortcut file exists and that you can access it. - Could not register type library for file [2]. Contact your support personnel. - Could not unregister type library for file [2]. Contact your support personnel. - Could not update the ini file [2][3]. Verify that the file exists and that you can access it. - Could not schedule file [2] to replace file [3] on reboot. Verify that you have write permissions to file [3]. - Error removing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel. - Error installing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel. - Error removing ODBC driver: [4], ODBC error [2]: [3]. Verify that you have sufficient privileges to remove ODBC drivers. - Error installing ODBC driver: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it. - Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it. - Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services. - Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services. - Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services. - Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services. - Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables. - You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation. - Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file. - Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000. - Error registering COM+ Application. Contact your support personnel for more information. - Error unregistering COM+ Application. Contact your support personnel for more information. - The description for service '[2]' ([3]) could not be changed. - The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}} - The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}} - The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\r\n[3]}} - User installations are disabled via policy on the machine. - An error occured during the installation of assembly component [2]. HRESULT: [3]. {{assembly interface: [4], function: [5], assembly name: [6]}} + + + + + + + + - - - - - - - - + + + + + + NOT Installed + Installed AND (RESUME OR Preselected) + Installed AND NOT RESUME AND NOT Preselected + + - - - - - - NOT Installed - Installed AND (RESUME OR Preselected) - Installed AND NOT RESUME AND NOT Preselected - - - - - - - - - - - - - - - + + + + + + + + + + + + - + - licensefile - 2 - &No - &Install - Setup - Br&owse - custicon - &Next > - < &Back - Typical - installs - No - Setup Wizard - removico - exclamic - 0 - - &Reset - &Remove - completi - &Yes - &Exit - &Return - dlgbmp - {&DlgFontBold8} - &Ignore - repairic - &Resume - insticon - &Finish - P - @@@@@]]> - Installing - Cancel - 3 - info - &Repair - &Retry - bannrbmp - OK + licensefile + 2 + &No + &Install + Setup + Br&owse + custicon + &Next > + < &Back + Typical + installs + No + Setup Wizard + removico + exclamic + 0 + + &Reset + &Remove + completi + &Yes + &Exit + &Return + dlgbmp + {&DlgFontBold8} + &Ignore + repairic + &Resume + insticon + &Finish + P + + @@@@@]]> + Installing + Cancel + 3 + info + &Repair + &Retry + bannrbmp + OK - + diff --git a/Setup/WizardVs2003.wxs b/Setup/WizardVs2003.wxs deleted file mode 100644 index ca26a17a6..000000000 --- a/Setup/WizardVs2003.wxs +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VS2003_SCHEMAS_DIR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Setup/WizardVs2005.wxs b/Setup/WizardVs2005.wxs index 6b12ced79..b9807aab0 100644 --- a/Setup/WizardVs2005.wxs +++ b/Setup/WizardVs2005.wxs @@ -1,194 +1,286 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VS2005_SCHEMAS_DIR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + VS2005_SCHEMAS_DIR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/AccessLevelTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/AccessLevelTestCase.cs index 1d548076b..5fb481755 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/AccessLevelTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/AccessLevelTestCase.cs @@ -27,8 +27,6 @@ public class AccessLevelTestCase : BasePEVerifyTestCase [Test] public void ProtectedConstructor() { - ProxyGenerator generator = new ProxyGenerator(); - NonPublicConstructorClass proxy = generator.CreateClassProxy( typeof(NonPublicConstructorClass), new StandardInterceptor()) @@ -40,10 +38,21 @@ public void ProtectedConstructor() } [Test] - public void ProtectedMethods() + public void ProtectedInternalConstructor () { - ProxyGenerator generator = new ProxyGenerator(); + ProtectedInternalConstructorClass proxy = + generator.CreateClassProxy ( + typeof (ProtectedInternalConstructorClass), new StandardInterceptor()) + as ProtectedInternalConstructorClass; + + Assert.IsNotNull (proxy); + proxy.DoSomething(); + } + + [Test] + public void ProtectedMethods() + { LogInvocationInterceptor logger = new LogInvocationInterceptor(); NonPublicMethodsClass proxy = (NonPublicMethodsClass) diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BasePEVerifyTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BasePEVerifyTestCase.cs index 32b848a28..00b474d6d 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BasePEVerifyTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BasePEVerifyTestCase.cs @@ -35,10 +35,13 @@ public virtual void Init() [TearDown] public virtual void TearDown () { - RunPEVerifyOnGeneratedAssembly (); + if (generator.ProxyBuilder.ModuleScope.StrongNamedModule != null) + RunPEVerifyOnGeneratedAssembly (generator.ProxyBuilder.ModuleScope.StrongNamedModule.FullyQualifiedName); + if (generator.ProxyBuilder.ModuleScope.WeakNamedModule != null) + RunPEVerifyOnGeneratedAssembly (generator.ProxyBuilder.ModuleScope.WeakNamedModule.FullyQualifiedName); } - public void RunPEVerifyOnGeneratedAssembly() + public void RunPEVerifyOnGeneratedAssembly(string assemblyPath) { Process process = new Process(); @@ -59,14 +62,14 @@ public void RunPEVerifyOnGeneratedAssembly() process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; - process.StartInfo.Arguments = ModuleScope.DEFAULT_FILE_NAME + " /VERBOSE"; + process.StartInfo.Arguments = assemblyPath + " /VERBOSE"; process.Start(); string processOutput = process.StandardOutput.ReadToEnd(); process.WaitForExit(); string result = process.ExitCode + " code "; - Console.WriteLine(result); + Console.WriteLine(GetType().FullName + ": " + result); if (process.ExitCode != 0) { diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BugsReportedTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BugsReportedTestCase.cs index f7cfda535..886bc2e21 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BugsReportedTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/BugsReportedTestCase.cs @@ -20,13 +20,11 @@ namespace Castle.DynamicProxy.Tests using NUnit.Framework; [TestFixture] - public class BugsReportedTestCase + public class BugsReportedTestCase : BasePEVerifyTestCase { [Test] public void InterfaceInheritance() { - ProxyGenerator generator = new ProxyGenerator(); - ICameraService proxy = (ICameraService) generator.CreateInterfaceProxyWithTarget(typeof(ICameraService), new CameraService(), @@ -41,8 +39,6 @@ public void InterfaceInheritance() [Test] public void ProxyInterfaceWithSetterOnly() { - ProxyGenerator generator = new ProxyGenerator(); - IHaveOnlySetter proxy = (IHaveOnlySetter) generator.CreateInterfaceProxyWithTarget(typeof(IHaveOnlySetter), new HaveOnlySetter(), @@ -59,8 +55,6 @@ public void ProxyInterfaceWithSetterOnly() )] public void CallingProceedOnAbstractMethodShouldThrowException() { - ProxyGenerator generator = new ProxyGenerator(); - AbstractClass proxy = (AbstractClass) generator.CreateClassProxy(typeof(AbstractClass), ProxyGenerationOptions.Default, new StandardInterceptor()); @@ -73,8 +67,6 @@ public void CallingProceedOnAbstractMethodShouldThrowException() [Test] public void ProxyTypeThatInheritFromGenericType() { - ProxyGenerator generator = new ProxyGenerator(); - IUserRepository proxy = (IUserRepository) generator.CreateInterfaceProxyWithoutTarget(typeof(IUserRepository), new SkipCallingMethodInterceptor()); @@ -85,9 +77,8 @@ public void ProxyTypeThatInheritFromGenericType() [Test] public void DYNPROXY_51_GenericMarkerInterface() { - ProxyGenerator gen = new ProxyGenerator(); WithMixin p = - (WithMixin) gen.CreateClassProxy(typeof(WithMixin), new Type[] {typeof(Marker)}, new IInterceptor[0]); + (WithMixin) generator.CreateClassProxy(typeof(WithMixin), new Type[] {typeof(Marker)}, new IInterceptor[0]); p.Method(); } } diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Castle.DynamicProxy.Tests-vs2005.csproj b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Castle.DynamicProxy.Tests-vs2005.csproj index 88f9b485c..b826e61ed 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Castle.DynamicProxy.Tests-vs2005.csproj +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Castle.DynamicProxy.Tests-vs2005.csproj @@ -109,6 +109,7 @@ + diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/ClassWithAttributesTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/ClassWithAttributesTestCase.cs index 20d3a8daa..7853c9438 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/ClassWithAttributesTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/ClassWithAttributesTestCase.cs @@ -25,8 +25,6 @@ public class ClassWithAttributesTestCase : BasePEVerifyTestCase [Test] public void EnsureProxyHasAttributesOnClassAndMethods() { - ProxyGenerator generator = new ProxyGenerator(); - AttributedClass instance = (AttributedClass) generator.CreateClassProxy(typeof(AttributedClass), new StandardInterceptor()); @@ -42,8 +40,6 @@ public void EnsureProxyHasAttributesOnClassAndMethods() [Test] public void EnsureProxyHasAttributesOnClassAndMethods_ComplexAttributes() { - ProxyGenerator generator = new ProxyGenerator(); - AttributedClass2 instance = (AttributedClass2) generator.CreateClassProxy(typeof(AttributedClass2), new StandardInterceptor()); diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ClassWithConstructors.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ClassWithConstructors.cs index daddc8c0c..2a9ff8f3e 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ClassWithConstructors.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ClassWithConstructors.cs @@ -32,7 +32,17 @@ public ClassWithConstructors(String name, int x) this.x = x; } - public string Name + protected ClassWithConstructors (double name) + : this (name.ToString ()) + { + } + + protected internal ClassWithConstructors (double name, double x) + : this (name.ToString (), (int) x) + { + } + + public string Name { get { return name; } } diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ProtectedInternalConstructorClass.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ProtectedInternalConstructorClass.cs new file mode 100644 index 000000000..e0b59f1a5 --- /dev/null +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/Classes/ProtectedInternalConstructorClass.cs @@ -0,0 +1,33 @@ +// Copyright 2004-2007 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Castle.DynamicProxy.Tests.Classes +{ + public class ProtectedInternalConstructorClass + { + //Added internal keyword + protected internal ProtectedInternalConstructorClass() + { + } + + public virtual void DoSomething() + { + } + + public static ProtectedInternalConstructorClass Create() + { + return new ProtectedInternalConstructorClass(); + } + } +} diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/GenerationHookTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/GenerationHookTestCase.cs index 5bf9f16cc..0e28629fb 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/GenerationHookTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/GenerationHookTestCase.cs @@ -23,16 +23,8 @@ namespace Castle.DynamicProxy.Tests using NUnit.Framework; [TestFixture] - public class GenerationHookTestCase + public class GenerationHookTestCase : BasePEVerifyTestCase { - private ProxyGenerator generator; - - [SetUp] - public void Init() - { - generator = new ProxyGenerator(); - } - [Test] public void HookIsUsedForConcreteClassProxy() { diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/MethodsWithAttributesOnParametersTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/MethodsWithAttributesOnParametersTestCase.cs index 5c83db194..2537a3ffb 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/MethodsWithAttributesOnParametersTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/MethodsWithAttributesOnParametersTestCase.cs @@ -26,10 +26,8 @@ public class MethodsWithAttributesOnParametersTestCase : BasePEVerifyTestCase [ExpectedException(typeof(ArgumentException), "No default value for argument")] public void ParametersAreCopiedToProxiedObject() { - ProxyGenerator pg = new ProxyGenerator(); - ClassWithAttributesOnMethodParameters requiredObj = (ClassWithAttributesOnMethodParameters) - pg.CreateClassProxy( + generator.CreateClassProxy( typeof(ClassWithAttributesOnMethodParameters), new RequiredParamInterceptor()); @@ -39,10 +37,8 @@ public void ParametersAreCopiedToProxiedObject() [Test] public void CanGetParameterAttributeFromProxiedObject() { - ProxyGenerator pg = new ProxyGenerator(); - ClassWithAttributesOnMethodParameters requiredObj = (ClassWithAttributesOnMethodParameters) - pg.CreateClassProxy( + generator.CreateClassProxy( typeof(ClassWithAttributesOnMethodParameters), new RequiredParamInterceptor()); diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/OutRefParams.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/OutRefParams.cs index 2733f24d5..feb83ebba 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/OutRefParams.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/OutRefParams.cs @@ -21,16 +21,8 @@ namespace Castle.DynamicProxy.Tests using NUnit.Framework; [TestFixture] - public class OutRefParams + public class OutRefParams : BasePEVerifyTestCase { - private ProxyGenerator generator; - - [SetUp] - public void Init() - { - generator = new ProxyGenerator(); - } - [Test] public void CanCreateProxyOfInterfaceWithOutParameter() { diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/XmlSerializationTestCase.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/XmlSerializationTestCase.cs index 243222cf8..d39d65899 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/XmlSerializationTestCase.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy.Tests/XmlSerializationTestCase.cs @@ -26,10 +26,8 @@ public class XmlSerializationTestCase : BasePEVerifyTestCase [Test, Ignore("Could not come up with a solution for this")] public void ProxyIsXmlSerializable() { - ProxyGenerator gen = new ProxyGenerator(); - ClassToSerialize proxy = (ClassToSerialize) - gen.CreateClassProxy(typeof(ClassToSerialize), new StandardInterceptor()); + generator.CreateClassProxy(typeof(ClassToSerialize), new StandardInterceptor()); XmlSerializer serializer = new XmlSerializer(proxy.GetType()); diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Castle.DynamicProxy.build b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Castle.DynamicProxy.build index 8989303f3..9beb0e62b 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Castle.DynamicProxy.build +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Castle.DynamicProxy.build @@ -9,7 +9,7 @@ - + diff --git a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Generators/BaseProxyGenerator.cs b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Generators/BaseProxyGenerator.cs index 6240e74f0..be1ac6be1 100644 --- a/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Generators/BaseProxyGenerator.cs +++ b/Tools/Castle.DynamicProxy2/Castle.DynamicProxy/Generators/BaseProxyGenerator.cs @@ -1071,7 +1071,7 @@ protected void GenerateConstructors(ClassEmitter emitter, Type baseType, params foreach(ConstructorInfo constructor in constructors) { - if (constructor.IsPublic || constructor.IsFamily + if (constructor.IsPublic || constructor.IsFamily || constructor.IsFamilyOrAssembly || (constructor.IsAssembly && InternalsHelper.IsInternalToDynamicProxy(constructor.DeclaringType.Assembly))) GenerateConstructor(emitter, constructor, fields); } diff --git a/Tools/Castle.DynamicProxy2/Changes.txt b/Tools/Castle.DynamicProxy2/Changes.txt index 22d6acc99..56b12e302 100644 --- a/Tools/Castle.DynamicProxy2/Changes.txt +++ b/Tools/Castle.DynamicProxy2/Changes.txt @@ -1,5 +1,9 @@ Beta 1 Version 1.0.0.0 ====================== +- Made BasePEVerifyTestCase only check those assemblies that were actually generated in the test case, see DYNPROXY-68 +- Fixed bug with protected internal constructors, see DYNPROXY-66/DYNPROXY-67 +- Fixed test cases not using the ProxyGenerator supplied by BasePEVerifyTestCase, see DYNPROXY-69 + - Added StrongNameUtil, which provides methods for checking whether an assembly is signed/a type comes from a signed assembly - Added an additional constructor overload to ClassEmitter, allowing to force it to use an unsigned assembly diff --git a/Tools/NVelocity/src/NVelocity.Tests/NVelocity.Tests.build b/Tools/NVelocity/src/NVelocity.Tests/NVelocity.Tests.build index fb89eac9c..70e287fda 100644 --- a/Tools/NVelocity/src/NVelocity.Tests/NVelocity.Tests.build +++ b/Tools/NVelocity/src/NVelocity.Tests/NVelocity.Tests.build @@ -9,7 +9,7 @@ - + diff --git a/Tools/NVelocity/src/NVelocity/NVelocity.build b/Tools/NVelocity/src/NVelocity/NVelocity.build index e9ee0fa79..e5097b510 100644 --- a/Tools/NVelocity/src/NVelocity/NVelocity.build +++ b/Tools/NVelocity/src/NVelocity/NVelocity.build @@ -9,7 +9,7 @@ - + diff --git a/Tools/Tools.build b/Tools/Tools.build index 02a780f2b..4d203089a 100644 --- a/Tools/Tools.build +++ b/Tools/Tools.build @@ -13,22 +13,9 @@ + - - - - - - - - - - - - - - diff --git a/Tools/VSNetWizards/Castle ActiveRecord Project VS7.vsz b/Tools/VSNetWizards/Castle ActiveRecord Project VS7.vsz deleted file mode 100644 index 9fcd77495..000000000 --- a/Tools/VSNetWizards/Castle ActiveRecord Project VS7.vsz +++ /dev/null @@ -1,2 +0,0 @@ -VSWIZARD 7.0 -Wizard="Castle.ActiveRecordModelProjectWizardVS7" \ No newline at end of file diff --git a/Tools/VSNetWizards/Castle MonoRail Project VS7.vsz b/Tools/VSNetWizards/Castle MonoRail Project VS7.vsz deleted file mode 100644 index 1ef0b3c6c..000000000 --- a/Tools/VSNetWizards/Castle MonoRail Project VS7.vsz +++ /dev/null @@ -1,2 +0,0 @@ -VSWIZARD 7.0 -Wizard="Castle.MonoRailProjectWizardVS7" \ No newline at end of file diff --git a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/AssemblyInfo.cs b/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/AssemblyInfo.cs deleted file mode 100644 index 30bde9c13..000000000 --- a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/AssemblyInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; - -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: CLSCompliantAttribute(false)] -[assembly: ComVisibleAttribute(true)] -[assembly: AssemblyTitleAttribute("Castle.VSNetIntegration.CastleWizards for Microsoft .NET Framework 1.1")] -[assembly: AssemblyDescriptionAttribute("Castle Project Visual Studio Wizards")] -[assembly: AssemblyCompanyAttribute("Castle Project")] -[assembly: AssemblyProductAttribute("Castle.VSNetIntegration.CastleWizards")] -[assembly: AssemblyCopyrightAttribute("Copyright (c) 2004,2005,2006,2007 Castle Project - http://www.castleproject.org")] -[assembly: AssemblyVersionAttribute("1.0.3.0")] -[assembly: AssemblyInformationalVersionAttribute("1.0.3.0")] -[assembly: AssemblyFileVersionAttribute("1.0.3.0")] -[assembly: AssemblyKeyFileAttribute(@"..\..\..\..\..\CastleKey.snk")] -[assembly: AssemblyDelaySignAttribute(false)] -[assembly: AllowPartiallyTrustedCallersAttribute()] - diff --git a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/MonoRailProjectWizard.cs b/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/MonoRailProjectWizard.cs index ea2c436be..77a8b05fe 100644 --- a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/MonoRailProjectWizard.cs +++ b/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/MonoRailProjectWizard.cs @@ -237,7 +237,7 @@ private void AddRoutingConfiguration(XmlDocument webConfigDoc, XmlElement mrNode addRoutingElem.SetAttribute("name", "routing"); addRoutingElem.SetAttribute("type", "Castle.MonoRail.Framework.RoutingModule, Castle.MonoRail.Framework"); - httpModules.InsertBefore(httpModules.FirstChild, addRoutingElem); + httpModules.InsertBefore(addRoutingElem, httpModules.FirstChild); } private void AddViewEngineConfiguration(XmlDocument webConfigDoc, XmlElement mrNode) diff --git a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/wizards.build b/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/wizards.build index 780c2094a..58a74f0e1 100644 --- a/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/wizards.build +++ b/Tools/VSNetWizards/Castle.VSNetIntegration.CastleWizards/wizards.build @@ -9,7 +9,8 @@ - + + @@ -17,16 +18,10 @@ - - - - - - - + @@ -37,7 +32,7 @@ - + diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProject/ARProject.csproj b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProject/ARProject.csproj index ff9907ef0..3b5f03dfe 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProject/ARProject.csproj +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProject/ARProject.csproj @@ -78,7 +78,7 @@ Castle.ActiveRecord ..\..\..\..\..\..\..\castleall\trunk\ActiveRecord\bin\Castle.ActiveRecord.dll - + Iesi.Collections ..\..\..\..\..\..\..\castleall\trunk\ActiveRecord\bin\Iesi.Collections.dll diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProjectTest/ARProjectTest.csproj b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProjectTest/ARProjectTest.csproj index ab9a9e196..2bd290933 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProjectTest/ARProjectTest.csproj +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/ARProjectTest/ARProjectTest.csproj @@ -78,7 +78,7 @@ Castle.ActiveRecord ..\..\..\..\..\..\..\castleall\trunk\ActiveRecord\bin\Castle.ActiveRecord.dll - + Castle.DynamicProxy ..\..\..\..\..\..\..\castleall\trunk\ActiveRecord\bin\Castle.DynamicProxy.dll diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Content/images/empty.txt b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Content/images/empty.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/MRProject.csproj b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/MRProject.csproj index f91b4b556..1cb6aeb93 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/MRProject.csproj +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/MRProject.csproj @@ -29,23 +29,23 @@ 4 - + False Castle.Components.Binder.dll - + False Castle.Components.Validator.dll - + False Castle.Components.Common.EmailSender.dll - + False Castle.Core.dll - + False Castle.MonoRail.Framework.dll diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Readme.txt b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Readme.txt index c94e6e453..44e4f9512 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Readme.txt +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/Readme.txt @@ -10,7 +10,7 @@ Windsor Container Integration If you are using the Windsor container integration you must remember to register all new controllers on -the controller.config file +the Config/controllers.config file ViewComponents must be registered as well. Filters can be optionally registered on the container. diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.brail b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.brail index a84bb8c2a..fa2b3f82c 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.brail +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.brail @@ -9,10 +9,10 @@ - - - - + + + + @@ -39,10 +39,10 @@

Further Reference

diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.vm b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.vm index 9f09c5b45..1fcdde361 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.vm +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProject/ViewsPlaceHolder/layout_default.vm @@ -38,10 +38,10 @@

Further Reference

diff --git a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProjectTest/MRProjectTest.csproj b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProjectTest/MRProjectTest.csproj index 82445e98c..6709bba4f 100644 --- a/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProjectTest/MRProjectTest.csproj +++ b/Tools/VSNetWizards/CastleTemplates/VS8/CSharp/MRProjectTest/MRProjectTest.csproj @@ -74,8 +74,8 @@ prompt - - + + nunit.framework C:\devtools\nunit\bin\nunit.framework.dll diff --git a/Tools/VSNetWizards/Changes.txt b/Tools/VSNetWizards/Changes.txt index bdb115f06..f98fbd13f 100644 --- a/Tools/VSNetWizards/Changes.txt +++ b/Tools/VSNetWizards/Changes.txt @@ -1,3 +1,8 @@ +1.0 +=== + +- Applied Colin Ramsay's patch fixing exception when routing is enabled on MR wizard + RC 3 ==== diff --git a/Tools/VSNetWizards/VsNetIntegration.build b/Tools/VSNetWizards/VsNetIntegration.build index 8d692ac36..ae519ca9f 100644 --- a/Tools/VSNetWizards/VsNetIntegration.build +++ b/Tools/VSNetWizards/VsNetIntegration.build @@ -4,7 +4,10 @@ default="build" xmlns="http://nant.sf.net/release/0.85/nant.xsd" > - + + + + diff --git a/common.xml b/common.xml index 21393f194..e58b6b3b1 100644 --- a/common.xml +++ b/common.xml @@ -34,7 +34,7 @@ - + @@ -80,11 +80,12 @@ - + - + + @@ -98,17 +99,6 @@ - - - - - - - - - - - @@ -165,7 +155,7 @@ @@ -185,7 +175,7 @@ failonerror="false"/> @@ -227,4 +217,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cruise.build b/cruise.build index 65cfa1c01..b80aeadfd 100644 --- a/cruise.build +++ b/cruise.build @@ -8,22 +8,6 @@ --> This build file is for use with CruiseControl.NET - - - - - - - - - - - - - @@ -37,7 +39,7 @@ depends="init recreate-build-directory build" description="Rebuilds Castle in the current configuration" /> - + @@ -189,7 +191,9 @@ + @@ -268,7 +272,9 @@ + @@ -581,9 +587,8 @@ - - - + + @@ -608,8 +613,8 @@ - - + + @@ -633,9 +638,8 @@ - - - + + @@ -647,9 +651,6 @@ - - - @@ -659,8 +660,8 @@ - - + + @@ -935,6 +936,8 @@ + + @@ -957,6 +960,8 @@ + + @@ -974,6 +979,8 @@ + + @@ -982,15 +989,27 @@ + + + + + + + + + + + + - + @@ -1001,146 +1020,54 @@ + + - - - Documentation generation. - - + Documentation generation. - Docs generation properties. - - - - Generates documentation with default properties. - + + Generates documentation for developers, with all missing information indicated and private members visible. - - - + + + - Generates documentation for release. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copies all files to be documented to a single location to speed up the documentation process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + Cleans up prior to documentation generation. - + diff --git a/docs/ActiveRecordIntro.html b/docs/ActiveRecordIntro.html new file mode 100644 index 000000000..54a52fd58 --- /dev/null +++ b/docs/ActiveRecordIntro.html @@ -0,0 +1,95 @@ + + +ActiveRecord + + + + + + +
+
+

Castle ActiveRecord

+ + + + +

+The Castle ActiveRecord project is an implementation of the ActiveRecord pattern for .NET. The ActiveRecord pattern +consists on instance properties representing a record in the database, instance methods acting on that specific record +and static methods acting on all records. +

+ +

+Castle ActiveRecord is built on top of NHibernate, but its attribute-based mapping free the developer of writing XML +for database-to-object mapping, which is needed when using NHibernate directly. +

+ +
+[ActiveRecord]
+public class Blog : ActiveRecordBase
+{
+    private int id;
+    private string name;
+    private string author;
+
+    [PrimaryKey]
+    public int Id
+    {
+        get { return id; }
+        set { id = value; }
+    }
+
+    [Property]
+    public string Name
+    {
+        get { return name; }
+        set { name = value; }
+    }
+
+    [Property]
+    public string Author
+    {
+        get { return author; }
+        set { author = value; }
+    }
+}
+
+ +

+ActiveRecord resources: +

+ + + +
+
+ + + + \ No newline at end of file diff --git a/docs/DynamicProxyIntro.html b/docs/DynamicProxyIntro.html new file mode 100644 index 000000000..fd0172214 --- /dev/null +++ b/docs/DynamicProxyIntro.html @@ -0,0 +1,57 @@ + + + + DynamicProxy + + + + + + + +
+
+

Castle DynamicProxy

+ + + + +

+The DynamicProxy project was created to overcome the CLR's proxy (in)capabilities. +There are proxies in the CLR world, but they can be considered a bit intrusive as they +force one to extend MarshalByRefObject or ContextBoundObject. +

+ +

+You can use DynamicProxy to generate lightweight proxies on the fly for one or more +interfaces or even concrete classes (but only virtual methods will be intercepted). +

+ + + + +
+
+ + + + \ No newline at end of file diff --git a/docs/FacilitiesIntro.html b/docs/FacilitiesIntro.html new file mode 100644 index 000000000..d20cbf235 --- /dev/null +++ b/docs/FacilitiesIntro.html @@ -0,0 +1,53 @@ + + + + Facilities + + + + + + + +
+
+

Castle Facilities

+ + + + +

+Facilities augment the MicroKernel capabilities by integrating it with a different project or technology, or by implementing new semantics. +

+ +

Facilities resources

+ + + +
+
+ + + + \ No newline at end of file diff --git a/docs/Intro.html b/docs/Intro.html new file mode 100644 index 000000000..1115ed08a --- /dev/null +++ b/docs/Intro.html @@ -0,0 +1,103 @@ + + + + Introduction + + + + + + +
+
+ +

+ Welcome to the Castle Project +

+ +

+ A project created by developers in an attempt to make enterprise + application development easier and enjoyable. + Castle is an open source project for .net that aspires to simplify + the development of enterprise and web applications. Offering a set of tools + (working together or independently) and integration with others open source projects, + Castle helps you get more done with less code. +

+ +

+ The following top level projects constitute the Castle Project: +

+ +

Castle ActiveRecord

+ +

+ The enterprise data mapping pattern implemented using NHibernate. +

+ +

Castle MonoRail

+

+ MonoRail is a MVC framework inspired by ActionPack, a paradigm shift to simplicity. +

+ +

MicroKernel/Windsor

+

+ A lightweight inversion of control container core and a container targeting the common enterprise needs. +

+ +

+ Castle Project also offers these other projects: +

+ +

Components

+

+ Components to handle common problems, from Validation to Template processing. +

+ +

Facitilies

+

+ Facilities augment the MicroKernel capabilities by integrating it with a + different project or technology, or by implementing new semantics. +

+ +

Services

+

+ Common services used by enterprise applications like logging and transaction services. +

+ +

DynamicProxy

+

+ A lightweight proxy generator for interfaces and concrete classes used by several .net open source projects. +

+ +

NVelocity

+

+ A fork from the official port with several bug fixes and improvements. +

+ +
+
+ + + + \ No newline at end of file diff --git a/docs/MicroKernelIntro.html b/docs/MicroKernelIntro.html new file mode 100644 index 000000000..b3f795189 --- /dev/null +++ b/docs/MicroKernelIntro.html @@ -0,0 +1,72 @@ + + + + MicroKernel/Windsor + + + + + + + +
+
+

Castle MicroKernel/Windsor

+ + + + +

+The Castle MicroKernel is an inversion of control container that was designed for extensibility. It combines facilities to grow orthogonally. These facilities work side-by-side, without interfering or depending on each other, to allow you to easily extend the container functionality by plugging in new concerns and semantics. You can use it as an embeddable container on tools that support extensions or plugin support, such as tools which exposes configurable pipelines or compilers. The container is set up and configured through code, and can be extended to work with a configuration system that your project supports. +

+ +

+Castle Windsor aggregates the MicroKernel and exposes a powerful configuration support. It is suitable for common enterprise application needs. It is able to register facilities and components based on the configuration and adds support for interceptors. +

+ +

+The Castle MicroKernel and Castle Windsor are good options if you are fond of the Inversion of Control principle. This happens a lot to developers that come from the Java camp. +

+

+The MicroKernel is undoubtably the most extensible container for .Net. This is a high point as you can use it as the rendezvous for frameworks your company has, combining them. +

+

+IoC containers favors reuse as they allow you to use a natural idiom to expose the component's dependencies. This allow components to be used with or without containers. Hence you quickly end up with a library of reusable components that can be shared among projects, as long as you apply the Separation of Concerns principle. +

+ +

+MicroKernel/Windsor resources: +

+ + + +
+
+ + + + \ No newline at end of file diff --git a/docs/MonoRailIntro.html b/docs/MonoRailIntro.html new file mode 100644 index 000000000..cdfab4caa --- /dev/null +++ b/docs/MonoRailIntro.html @@ -0,0 +1,68 @@ + + + + MonoRail + + + + + + + +
+
+

Castle MonoRail

+ + + + +

+MonoRail is a MVC Web Framework inspired by Action Pack. +

+ +

+MonoRail differs from the standard WebForms way of development as it enforces separation of concerns; controllers just handle application flow, models represent the data, and the view is just concerned about presentation logic. Consequently, you write less code and end up with a more maintainable application. +

+ +

+Although the project name is MonoRail, we do not have any affiliation with the Mono project. +MonoRail runs on Microsoft .Net 2.0, 3.5 and Mono. +

+ +

+MonoRail resources: +

+ + + + +
+
+ + + + \ No newline at end of file diff --git a/docs/NVelocityIntro.html b/docs/NVelocityIntro.html new file mode 100644 index 000000000..de5886461 --- /dev/null +++ b/docs/NVelocityIntro.html @@ -0,0 +1,66 @@ + + + + NVelocity + + + + + + + +
+
+

Castle NVelocity

+ + + + +

+NVelocity is a port of the excellent Apache Jakarta Velocity project. +It is a very simple, easy to learn and extensible template engine. +

+ +

+Due to the lack of releases, support and bug fixes on the original port, +the Castle Team decided to fork the project, bringing it to our code repository, +fixing the bugs and improving it with more features. +

+ +

+NVelocity resources: +

+ + + +
+
+ + + + \ No newline at end of file diff --git a/docs/ServicesIntro.html b/docs/ServicesIntro.html new file mode 100644 index 000000000..dd6db8442 --- /dev/null +++ b/docs/ServicesIntro.html @@ -0,0 +1,54 @@ + + + + Services + + + + + + + +
+
+

Castle Services

+ + + + +

+Castle services were created to offer a standard API. +They define a core API/specs so others projects can make use of and extend them as needed. +

+ +

Services resources

+ + + +
+
+ + + + \ No newline at end of file diff --git a/docs/Team.html b/docs/Team.html new file mode 100644 index 000000000..aaeec29fa --- /dev/null +++ b/docs/Team.html @@ -0,0 +1,121 @@ + + +Castle Team + + + + + + +
+
+

Project roles and team

+ + + + +

+The Castle Project is made of the following roles: +

+ +
    +
  • Committer: have access to the code repository and has binding votes
  • +
  • PMC Chair: leads the PMC
  • +
  • PMC Members: vote new committers, oversee the project goals in mid to long terms
  • +
  • Patch Manager: guarantees that submitted patches will not be forgotten
  • +
  • Documentation Manager: enforces standards on the documentation
  • +
+ +

Active members

+ +

+The following is the list of people actively involved with the Castle Project ordered by the inclusion date. +

+ +
    +
  • hammett/Hamilton Verissimo
  • +
  • Henry Conceição
  • +
  • Kevin Williams
  • +
  • Craig Neuwirt
  • +
  • Fabio David Batista
  • +
  • Ayende Rahien
  • +
  • G. Richard Bellamy
  • +
  • Roelof Blom
  • +
  • Josh Robb
  • +
  • Ernst Naezer
  • +
  • Fabian Schmied
  • +
  • Dave Godfrey
  • +
  • Markus Zywitza
  • +
+ +

Managers

+ +

+Patch Manager: Josh Robb +

+

+Documentation Manager: hammett +

+ +

PMC Members

+ +

+(ordered by the date when joined the PMC) +

+ +
    +
  • hammett/Hamilton Verissimo (Chair)
  • +
  • Henry Conceição
  • +
  • Kevin Williams
  • +
  • Craig Neuwirt
  • +
  • Ayende Rahien
  • +
  • Fabio David Batista
  • +
  • Roelof Blom
  • +
  • Josh Robb
  • +
+ +

Emeritus

+ +

+(no longer active committers) +

+ +
    +
  • Gilles Bayon
  • +
  • Dan
  • +
  • Andrew Hallock
  • +
  • Jason Nelson
  • +
  • Dru Sellers
  • +
  • John Morales
  • +
  • CobraLord
  • +
  • Tatham Oddie
  • +
  • Chad Humphries
  • +
  • Ahmed Ghandour
  • +
  • Marc-Andre Cournoyer
  • +
+ +
+
+ + + + \ No newline at end of file diff --git a/docs/resources.html b/docs/resources.html new file mode 100644 index 000000000..dc8b8d68c --- /dev/null +++ b/docs/resources.html @@ -0,0 +1,58 @@ + + +Resources + + + + + + +
+
+

Resources

+ + + + +

+The following web sites contain useful information +

+ + + +

+The team can be reached using +our mailing lists. +

+ +
+
+ + + + \ No newline at end of file diff --git a/docs/styles/Presentation.css b/docs/styles/Presentation.css new file mode 100644 index 000000000..091522e2e --- /dev/null +++ b/docs/styles/Presentation.css @@ -0,0 +1,977 @@ +/* * * This file was autogenerated by Styler at 02:02 on 02/15/2003 * * */ + + +/*********************************************************** + * SCRIPT-SUPPORTING STYLES + ***********************************************************/ + +/* Defines the userData cache persistence mechanism. */ +.userDataStyle +{ + behavior: url(#default#userData); +} + +/* Used to save the scroll bar position when navigating away from a page. */ +div.saveHistory +{ + behavior: url(#default#saveHistory); +} + +/* Formats the expand/collapse images for all collapsible regions. */ +img.toggle +{ + border: 0; + margin-right: 5; +} + +/* Formats the Language filter drop-down image. */ +img#languageFilterImage +{ + border: 0; + margin-left: 0; + vertical-align: middle; +} + +/* Formats the Members Options filter drop-down image. */ +img#membersOptionsFilterImage +{ + border: 0; + margin-left: 0; + vertical-align: middle; +} + +/* Formats the Collapse All/Expand All images. */ +img#toggleAllImage +{ + margin-left: 0; + vertical-align: middle; +} + +/* Supports XLinks */ +MSHelp\:link +{ + text-decoration: underline; + color: #0000ff; + hoverColor: #3366ff; + filterString: ; +} + + +/*********************************************************** + * CONTENT PRESENTATION STYLES + ***********************************************************/ + +body +{ + background: #FFFFFF; + color: #000000; + font-family: Verdana; + font-size: medium; + font-style: normal; + font-weight: normal; + margin-top: 0; + margin-bottom: 0; + margin-left: 0; + margin-right: 0; + width: 100%; +} + +dl +{ + margin-top: 15; + margin-bottom:5; + padding-left: 1; +} + +/*dt +{ + font-style: italic; +}*/ + +dd +{ + margin-left: 0; +} + +ul +{ + margin-top:0; + margin-bottom:0; + margin-left: 17; + list-style-type: disc; +} + +ul ul +{ + margin-bottom: 4; + margin-left: 17; + margin-top: 3; + list-style-type: disc; +} + +ol +{ + margin-top:0; + margin-bottom:0; + margin-left: 28; + list-style-type: decimal; +} + +ol ol +{ + margin-bottom: 4; + margin-left: 28; + margin-top: 3; + list-style-type: lower-alpha; +} + +li +{ + margin-top:-2; + margin-bottom: 3; +} + +p +{ + margin-top: 10; + margin-bottom: 5; +} +a[href] +{ + color: #0000FF; +} + +a:visited +{ + color: #0000FF; +} + +a:hover +{ + color: #3366FF; +} + +code +{ + font-family: Monospace, Courier New, Courier; + font-size: 105%; + color: #000066; +} + +span.parameter { + font-style: italic; + font-weight:bold; +} + +span.italic { + font-style: italic; +} + +span.referenceNoLink { + font-weight: bold; +} + +span.nolink { + font-weight: bold; +} + +span.nonLinkTerm { + font-weight: bold; +} + +span.linkTerm { + font-weight:normal; +} + +/*********************************************************** + * STRUCTURE PRESENTATION STYLES + ***********************************************************/ + +/* Applies to everything below the non-scrolling header region. */ +div#mainSection +{ + font-size: 62.5%; + width: 100%; +} +html>body #mainSection +{ + font-size:73%; + width: 100%; +} + +/* Applies to everything below the non-scrolling header region, minus the footer. */ +div#mainBody +{ + font-size: 100%; + margin-left: 15; + margin-top: 10; + padding-bottom: 20; +} + +html>body #mainBody +{ + font-size: 93%; + margin-left: 15; + margin-top: 10; + padding-bottom: 20; +} + +/* Adds right padding for all blocks in mainBody */ +div#mainBody p, div#mainBody ol, div#mainBody ul, div#mainBody dl +{ + padding-right: 5; +} + +/*------------------------------ Begin Non-scrolling Header Region Styles -------------------------------*/ +/* Applies to the entire non-scrolling header region. */ +div#header +{ + background-color: #D4DFFF; + padding-top: 0; + padding-bottom: 0; + padding-left: 0; + padding-right: 0; +} + +/* Applies to both tables in the non-scrolling header region. */ +div#header table +{ + border-bottom-color: #C8CDDE; + border-bottom-style: solid; + border-bottom-width: 1; + width: 100%; +} + +/* Applies to cells in both tables in the non-scrolling header region. */ +div#header table td +{ + color: #0000FF; + font-size: 70%; + margin-top: 0; + margin-bottom: 0; + padding-right: 20; +} +/* Applies to second row in the upper table of the non-scrolling header region. */ +div#header table tr#headerTableRow2 td +{ + padding-left: 13px; +} + +/* Applies to the last row in the upper table of the non-scrolling header region. Text + in this row includes See Also, Constructors, Methods, and Properties. */ +div#header table tr#headerTableRow3 td +{ + padding-bottom: 2; + padding-top: 5; + padding-left: 15; +} + +/* Applies to the lower table in the non-scrolling header region. Text in this table + includes Collapse All/Expand All, Language Filter, and Members Options. */ +div#header table#bottomTable +{ + border-top-color: #FFFFFF; + border-top-style: solid; + border-top-width: 1; + text-align: left; + padding-left: 15; +} + +/* Formats the first column--the one that displays icons--in mref list tables (such as Public Constructors, + Protected Constructors, Public Properties, Protected Properties, and so on). */ +div#mainSection table td.imageCell +{ + white-space: nowrap; +} +/*------------------------------ End General Table Styles -------------------------------*/ + +/*------------------------------ Begin General Table Styles -------------------------------*/ + +div#mainBody div.alert, div#mainBody div.code, div#mainBody div.tableSection +{ + width:98.9%; +} + +div#mainBody div.section div.alert, div#mainBody div.section div.code, +div#mainBody div.section div.tableSection +{ + width:100%; +} + +div#mainBody div.section ul div.alert, div#mainBody div.section ul div.code, +div#mainBody div.section ul div.tableSection, div#mainBody div.section ol div.alert, +div#mainBody div.section ol div.code, div#mainBody div.section ol div.tableSection +{ + width:100%; +} + +div.alert p, div.code p +{ + margin-top:5; + margin-bottom:8; +} +dd p +{ + margin-top:2; + margin-bottom:8; +} +div.tableSection p +{ + margin-top:1; + margin-bottom:4; +} +li p +{ + margin-top:2; + margin-bottom:2; +} +div.seeAlsoNoToggleSection dl +{ + margin-top:8; + margin-bottom:1; + padding-left:1; +} +div.seeAlsoNoToggleSection dd p +{ + margin-top:2; + margin-bottom:8; +} +div.section dl +{ + margin-top:8; + margin-bottom:1; + padding-left:1; +} +div.section dd p +{ + margin-top:2; + margin-bottom:8; +} +/*------------------------------ End General Table Styles -------------------------------*/ + + + +/*------------------------------ Begin Syntax and Snipper Code Block Styles -------------------------------*/ +div.code table +{ + border: 0; + font-size: 95%; + margin-bottom: 5; + margin-top:-.4em; + width: 100% +} + +div.code table th +{ + background: #EFEFF7; + border-bottom-color: #C8CDDE; + border-bottom-style: solid; + border-bottom-width: 1; + color: #000066; + font-weight: bold; + padding-left: 5; + padding-right: 5; +} + +div.code table td +{ + background: #F7F7FF; + border-top-color: #FFFFFF; + border-top-style: solid; + border-top-width: 1; + padding-left: 5; + padding-right: 5; + padding-top: 5; +} +/* Applies to the running header text in the first row of the upper table in the + non-scrolling header region. */ +span#runningHeaderText +{ + color: #003399; + font-size: 90%; + padding-left: 13; +} + +/* Applies to the topic title in the second row of the upper table in the + non-scrolling header region. */ +span#nsrTitle +{ + color: #003399; + font-size: 120%; + font-weight: 600; +} +/*------------------------------ End Non-scrolling Header Region Styles -------------------------------*/ + + +/* Formats the footer. Currently, the transforms pass in two parameters to the + footer SSC, but the default footer SSC doesn't use either parameter. + TODO: Investigate whether the default footer SSC has any impact on doc spec. */ +div#footer +{ + font-size: 80%; + margin-top: 0; + margin-bottom: 0; + margin-left: 0; + margin-right: 0; + padding-top: 8; + padding-bottom: 6; + padding-left: 5; + padding-right: 2; + width: 100%; +} + +html>body div#footer +{ + font-size: 80%; + margin-top: 0; + margin-bottom: 0; + margin-left: 0; + margin-right: 0; + padding-top: 2; + padding-bottom: 6; + padding-left: 5; + padding-right: 2; + width: 98%; +} + +/* Unable to find this style in the transforms. The default footer SSC adds a plain horizontal rule. + TODO: Determine whether this style is required by the doc spec. */ +/* +hr#footerHR +{ + border-bottom-color: #EEEEFF; + border-bottom-style: solid; + border-bottom-width: 1; + border-top-color: C8CDDE; + border-top-style: solid; + border-top-width: 1; + height: 3; + color: #D4DFFF; +} +*/ + +/******************************************************************************************************************** + Collapsible Section Structure + +

// Format of the collapsible section text + // Defines the onclick procedure for the expand/collapse section + // Expand/collapse image + + +

+ +
// The body of the collapsible section; hidden by default +
+ + + The ExpandCollapse() function is responsible for toggling the expand/collapse image, and for + displaying/hiding the body of the collapsible section. +********************************************************************************************************************/ + +/* Applies to the body of a collapsible section */ +div.seeAlsoNoToggleSection +{ + margin-left:0; + padding-top: 2; + padding-bottom: 2; + padding-left: 0; + padding-right: 15; + width: 100%; +} + +div.section +{ + margin-left:0; + padding-top: 2; + padding-bottom: 2; + padding-left: 16; + padding-right: 15; + width: 100%; +} +html>body div.section +{ + margin-left:0; + padding-top: 2; + padding-bottom: 2; + padding-left: 16; + padding-right: 15; + width: 97%; +} +div.seeSection +{ + margin-left:0; + padding-top: 0; + padding-bottom: 2; + padding-left: 16; + padding-right: 15; + width: 100%; +} + +/*------------------------------ Begin Heading Styles -------------------------------*/ +/* As far as I can tell, only

tags use this class. + TODO: Decide whether to roll these attributes into the h1.heading style */ +.heading +{ + font-weight: bold; + margin-top: 18; + margin-bottom: 8; +} + +/* All

headings. */ +h1.heading +{ + color: #003399; + font-size: 130%; +} +h1 +{ + color: #003399; + font-size: 130%; +}} +h2 +{ + color: #003399; + font-size: 120%; +}} + + +/* Applies to table titles and subsection titles. */ +.subHeading +{ + font-weight: bold; + margin-bottom: 4; +} +.procedureSubHeading +{ + font-weight: bold; + margin-bottom: 4; +} + +/* Formats the titles of author-generated tables. */ +h3.subHeading +{ + color: #000000; + font-size: 120%; + font-weight:800; +} + +h3.procedureSubHeading +{ + color: #003399; + font-size: 120%; +} + +/* Formats the titles of all subsections. */ +h4.subHeading +{ + color: #000000; + font-size: 110%; + font-weight:800; +} +span.labelheading, div.labelheading +{ + font-size:100%; + color:#003399; +} + +/*------------------------------ End Heading Styles -------------------------------*/ + + +/*------------------------------ Begin Image Styles -------------------------------*/ +img.copyCodeImage +{ + border: 0; + margin: 1; + margin-right: 3; +} + +img.downloadCodeImage +{ + border: 0; + margin-right: 3; +} + +img.viewCodeImage +{ + border: 0; + margin-right: 3; +} + +img.note +{ + border: 0; + margin-right: 3; +} +/*------------------------------ End Image Styles -------------------------------*/ + + +/*------------------------------ Begin General Table Styles -------------------------------*/ +div#mainSection table +{ + border: 0; + font-size: 100%; + width: 98.9%; + margin-top: 5px; + margin-bottom: 5px; +} + +div#mainSection table tr +{ + vertical-align: top; +} + +div#mainSection table th +{ + background-color: #EFEFF7; + border-bottom: 1px solid #C8CDDE; + border-left: 1px none #D5D5D3; + color: #000066; + padding-left: 5px; + padding-right: 5px; + text-align: left; +} + +div#mainSection table td +{ + background-color: #F7F7FF; + border-bottom: 1px solid #D5D5D3; + border-left: 1px none #D5D5D3; + padding-left: 5px; + padding-right: 5px; +} + +/* Formats the first column--the one that displays icons--in mref list tables (such as Public Constructors, + Protected Constructors, Public Properties, Protected Properties, and so on). */ +div#mainSection table td.imageCell +{ + white-space: nowrap; +} +/*------------------------------ End General Table Styles -------------------------------*/ + + +/*------------------------------ Begin Syntax and Snipper Code Block Styles -------------------------------*/ +div.code table +{ + border: 0; + font-size: 95%; + margin-bottom: 5; + width: 100% +} + +div.code table th +{ + background: #EFEFF7; + border-bottom-color: #C8CDDE; + border-bottom-style: solid; + border-bottom-width: 1; + color: #000066; + font-weight: bold; + padding-left: 5; + padding-right: 5; +} + +div.code table td +{ + background: #F7F7FF; + border-top-color: #FFFFFF; + border-top-style: solid; + border-top-width: 1; + padding-left: 5; + padding-right: 5; + padding-top: 5; +} +/*------------------------------ End Syntax and Snipper Code Block Styles -------------------------------*/ + + +/*------------------------------ Begin Note Styles -------------------------------*/ +div.alert table +{ + border: 0; + font-size: 100%; + width: 100%; +} + +div.alert table th +{ + background: #EFEFF7; + border-bottom-width: 0; + color: #000066; + padding-left: 5; + padding-right: 5; +} + +div.alert table td +{ + background: #F7F7FF; + border-top-color: #FFFFFF; + border-top-style: solid; + border-top-width: 1; + padding-left: 5; + padding-right: 5; +} + + +/*------------------------------ End Note Styles -------------------------------*/ + + +/* Applies to the copy code text and image. */ +span.copyCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: pointer; + float: right; + display: inline; + text-align: right; +} + +span.copyCodeOnHover +{ + color: #E85F17; + font-size:xx-small; + font-weight: normal; + cursor: pointer; + float: left; + display: inline; + text-align: left; + padding-bottom:10px; + text-decoration: underline; +} + +.downloadCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: pointer; +} + +.viewCode +{ + color: #0000ff; + font-size: 90%; + font-weight: normal; + cursor: pointer; +} + +/* Formats the code in syntax and usage blocks, and the code in non-snipper code blocks. */ +div.code pre +{ + font-family: Monospace, Courier New, Courier; + font-size: 105%; + color: #000066; + background: #F7F7FF; +} + +/* Formats parameter tooltips. */ +.tip +{ + color: #0000FF; + font-style: italic; + cursor: pointer; + text-decoration:underline; +} + +/* Applies to the language labels in the Language Filter drop-down list. */ +.languageFilter +{ + color: #0000FF; + cursor: pointer; + text-decoration:underline; + padding-bottom:4; +} + +/* Applies to text styled as math. This text is passed as a parameter to the italics SSC definition */ +.math +{ + font-family: Times New Roman; + font-size: 125% +} + +/* The sourceCodeList class doesn't appear in the transforms. + TODO: Find out whether this style is needed for the doc spec. */ +/* +.sourceCodeList +{ + font-family: Verdana; + font-size: 90%; +} +*/ + +/* The viewCode class doesn't appear in the transforms. + TODO: Find out whether this style is needed for the doc spec. */ +/* +pre.viewCode +{ + width: 100%; + overflow: auto; +} +*/ + +/* Dropdown areas */ + +#languageSpan { + position: absolute; + visibility: hidden; + border-style: solid; + border-width: 1px; + border-color: #C8CDDE; + background: #d4dfff; + padding: 4px; + font-size: 70%; +} + +#membersOptionsSpan { + position: absolute; + visibility: hidden; + border-style: solid; + border-width: 1px; + border-color: #C8CDDE; + background: #d4dfff; + padding: 4px; + font-size: 70%; +} + +/* Line seperating footer from main body */ + +div.footerLine { + margin: 0; + width: 100%; + padding-top: 8; + padding-bottom: 6; + padding-left: 5; + padding-right: 2; + +} + +div.hr1 { + margin: 0; + width: 100%; + height: 1px; + padding: 0; + background: #C8CDDE; + font-size: 1px; +} + +div.hr2 { + margin: 0; + width: 100%; + height: 1px; + padding: 0; + background: #D4DFFF; + font-size: 1px; +} + +div.hr3 { + margin: 0; + width: 100%; + height: 1px; + padding: 0; + background: #EEEEFF; + font-size: 1px; +} + +span.cs { + display: none; +} + +span.vb { + display: inline; +} + +span.cpp { + display: none; +} + +span.code { + font-family: Monospace, Courier New, Courier; + font-size: 105%; + color: #000066; +} +span.ui { + font-weight: bold; +} +span.math { + font-style: italic; +} +span.input { + font-weight: bold; +} +span.term { + font-style: italic; +} +span.label +{ + font-weight: bold; +} +span.foreignPhrase { + font-style: italic; +} +span.placeholder { + font-style: italic; +} +span.keyword +{ + font-weight: bold; +} +span.typeparameter +{ + font-style:italic; +} + +div.caption +{ + font-weight: bold; + font-size:100%; + color:#003399; +} + +/* syntax styles */ + +div.code span.identifier +{ + font-weight: bold; +} + +div.code span.keyword +{ + color: green; +} + +div.code span.parameter +{ + font-style: italic; + color: purple; +} + +div.code span.literal +{ + color: purple; +} + +div.code span.comment +{ + color: red; +} + +span.syntaxLabel +{ + color:#0481DA; + font-weight:bold; +} +span.introStyle +{ + color:DarkGray; +} + +div.seeAlsoStyle +{ + padding-top:5px; + +} +/* end of syntax styles */ + +/* Glossary */ +SPAN.clsGlossary {cursor: default; color: #509950; font-weight: bold;} +DIV.clsTooltip {border: 1px solid black; padding: 2px; position: absolute; top: 0; left: 0; display: none; background-color: #FFFFAA; color: black; font-size: 8pt; font-family: Arial;} diff --git a/sandcastle_docs.shfb b/sandcastle_docs.shfb index 9215c2605..2b1e0a893 100644 --- a/sandcastle_docs.shfb +++ b/sandcastle_docs.shfb @@ -16,7 +16,6 @@ - @@ -34,6 +33,11 @@ + + + + + @@ -42,8 +46,8 @@ Attributes, InheritedMembers, InheritedFrameworkMembers, Protected, SealedProtected - C:\dev\castle\svn\trunk\docs\output\ - + C:\dev\castledocs\ + True Website @@ -58,11 +62,11 @@ Castle Project API Documentation en-US - + http://www.castleproject.org/ Castle Project (c) 2004-2007 - + castle-project-devel@googlegroups.com - + Castle Project welcomes contributions. Help make Castle better, get involved. Local Msdn vs2005