/// <summary> /// Locates the controller info for performing the specified action with the specified type by looking at the base types of the provided type. /// </summary> /// <param name="action">The action that is to be performed by the controller.</param> /// <param name="type">The type that is involved in the action.</param> /// <returns>The controller info for the specified scenario.</returns> public ControllerInfo LocateFromBaseTypes(string action, Type type) { ControllerInfo controllerInfo = null; // Disabled logging to boost performance //using (LogGroup logGroup = LogGroup.Start("Locating via base types the controller for the action '" + action + "' and type '" + type.Name + "'.", NLog.LogLevel.Debug)) //{ TypeNavigator navigator = new TypeNavigator(type); while (navigator.HasNext && controllerInfo == null) { Type nextType = navigator.Next(); string key = Controllers.GetControllerKey(action, nextType.Name); // If a controller exists for the base type then use it if (Controllers.ControllerExists(key)) { // LogWriter.Debug("Found match with key: " + key); controllerInfo = Controllers[key]; break; } // TODO: Check if needed. It shouldn't be. The other call to LocateFromInterfaces in LocateFromHeirarchy should be sufficient // Otherwise check the interfaces of that base type //else //{ // controllerInfo = LocateFromInterfaces(action, nextType); //} } //} return(controllerInfo); }
/// <summary> /// Locates the projection info for performing the specified action with the specified type by looking at the base types of the provided type. /// </summary> /// <param name="action">The action that is to be performed by the projection.</param> /// <param name="type">The type that is involved in the action.</param> /// <param name="format">The output format of the projection to locate.</param> /// <returns>The projection info for the specified scenario.</returns> public ProjectionInfo LocateFromBaseTypes(string action, Type type, ProjectionFormat format) { ProjectionInfo projectionInfo = null; using (LogGroup logGroup = LogGroup.StartDebug("Locating projection from base types.")) { TypeNavigator navigator = new TypeNavigator(type); while (navigator.HasNext && projectionInfo == null) { Type nextType = navigator.Next(); string key = Projections.GetProjectionKey(action, nextType.Name, format); // If a projection exists for the base type then use it if (Projections.ContainsKey(key)) { projectionInfo = Projections.GetByKey(key); break; } } } return(projectionInfo); }
protected void GivenReferencedTypes(IEnumerable <Type> types) { TheTypeNavigator = new TypeNavigator(types); TheViewExplorer = MockRepository.GenerateMock <IViewExplorer>(); TheViewExplorer.Expect(x => x.GetTypeNavigator()).Return(TheTypeNavigator); TheViewExplorer.Expect(x => x.GetLocalVariableChunks()).Return(null); TheViewExplorer.Expect(x => x.GetViewDataVariableChunks()).Return(null); }
public void Test_HasNext_False() { Type type = typeof(object); TypeNavigator navigator = new TypeNavigator(type); Assert.IsFalse(navigator.HasNext, "HasNext is true when it should be false."); }
public void Test_HasNext_True() { Type type = typeof(TestArticle); TypeNavigator navigator = new TypeNavigator(type); Assert.IsTrue(navigator.HasNext, "HasNext is false when it should be true."); }
public CompletionBuilder(IViewExplorer viewExplorer) { if (viewExplorer == null) { throw new ArgumentNullException("viewExplorer"); } _viewExplorer = viewExplorer; _typeNavigator = viewExplorer.GetTypeNavigator(); }
/// <summary> /// Locates the reaction info for performing the specified action with the specified type by looking at the base types of the provided type. /// </summary> /// <param name="action">The action that is to be performed by the reaction.</param> /// <param name="type">The type that is involved in the action.</param> /// <returns>The reaction info for the specified scenario.</returns> public ReactionInfo[] LocateFromBaseTypes(string action, Type type) { ReactionInfoCollection reactionInfos = new ReactionInfoCollection(); // Logging commented out to boost performance //using (LogGroup logGroup = LogGroup.StartDebug("Locating reaction via the base types of the '" + (type != null ? type.FullName : "[null]") + "' type.")) //{ if (action == null) { throw new ArgumentNullException("action"); } if (action == String.Empty) { throw new ArgumentException("An action must be specified."); } if (type == null) { throw new ArgumentNullException("type"); } TypeNavigator navigator = new TypeNavigator(type); while (navigator.HasNext) { Type nextType = navigator.Next(); if (nextType != null) { //using (LogGroup logGroup2 = LogGroup.StartDebug("Checking base type: " + nextType.FullName)) //{ string key = Reactions.GetReactionsKey(action, nextType.Name); //LogWriter.Debug("Key: " + key); // If a reaction exists for the base type then use it if (Reactions.ReactionExists(key)) { if (Reactions.ContainsKey(key)) { reactionInfos.AddRange(Reactions[key]); } //LogWriter.Debug("Reactions found: " + reactionInfos.Count.ToString()); } //} } } //} return(reactionInfos.ToArray()); }
// ReSharper disable once InternalOrPrivateMemberNotDocumented private string SetupTypeNavControl(out TypeNavigator control) { const string controlName = "typeNav"; control = new TypeNavigator { Name = controlName }; control.SetValue( Props.RenderedTypeProperty , typeof(Dictionary <string, List <Tuple <int, object> > >) ); return(controlName); }
public void Test_Next() { Type type = typeof(TestArticle); TypeNavigator navigator = new TypeNavigator(type); ArrayList list = new ArrayList(); while (navigator.HasNext) { list.Add(navigator.Next()); } Assert.AreEqual(4, list.Count, "Invalid number of types identified."); }
/// <summary> /// Locates the strategy info for performing the specified action with the specified type by looking at the base types of the provided type. /// </summary> /// <param name="action">The action that is to be performed by the strategy.</param> /// <param name="type">The type that is involved in the action.</param> /// <returns>The strategy info for the specified scenario.</returns> public StrategyInfo LocateFromBaseTypes(string action, Type type) { StrategyInfo strategyInfo = null; //using (LogGroup logGroup = LogGroup.Start("Locating strategy via the base types of the provided type.", NLog.LogLevel.Debug)) //{ TypeNavigator navigator = new TypeNavigator(type); while (navigator.HasNext && strategyInfo == null) { Type nextType = navigator.Next(); if (strategyInfo == null) { // using (LogGroup logGroup2 = LogGroup.Start("Checking base type: " + nextType.FullName, NLog.LogLevel.Debug)) // { string key = StrategyInfo.GetStrategyKey(action, nextType.Name); // LogWriter.Debug("Key: " + key); // If a strategy exists for the base type then use it if (Strategies.StrategyExists(key)) { strategyInfo = Strategies[key]; // LogWriter.Debug("Strategy found: " + strategyInfo.StrategyType); } // TODO: Check if needed. It shouldn't be. The other call to LocateFromInterfaces in LocateFromHeirarchy should be sufficient // Otherwise check the interfaces of that base type //else //{ // strategyInfo = LocateFromInterfaces(action, nextType); //} // } } } //} return(strategyInfo); }
/// <summary> /// Locates the part info for performing the specified action with the specified type by looking at the base types of the provided type. /// </summary> /// <param name="action">The action that is to be performed by the part.</param> /// <param name="type">The type that is involved in the action.</param> /// <param name="format">The output format of the part to locate.</param> /// <returns>The part info for the specified scenario.</returns> public PartInfo LocateFromBaseTypes(string action, Type type) { PartInfo partInfo = null; TypeNavigator navigator = new TypeNavigator(type); while (navigator.HasNext && partInfo == null) { Type nextType = navigator.Next(); string key = Parts.GetPartKey(action, nextType.Name); // If a part exists for the base type then use it if (Parts.PartExists(key)) { partInfo = Parts[key]; break; } } return(partInfo); }