/// <summary> /// Gets all the action infos from a controller info. /// </summary> /// <param name="controllerInfo">The controller info.</param> /// <param name="kind">The controller kind.</param> private static void GetActionInfos(ControllerInfo controllerInfo, ControllerKind kind) { var actions = controllerInfo.ControllerType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var action in actions) { var customAttributes = action.GetCustomAttributes(false); //Ignore if controller is marked with [SkipJavascriptGeneration] if (customAttributes.OfType <SkipJavascriptGenerationAttribute>().Any()) { continue; } //MVC Controller actions aren't generated by default. if (kind == ControllerKind.Mvc && !customAttributes.OfType <GenerateJavascriptAttribute>().Any()) { continue; } ActionInfo.GetHttpVerb(action); controllerInfo.Actions.Add(new ActionInfo { Name = action.Name, MethodInfo = action, Controller = controllerInfo, Verb = ActionInfo.GetHttpVerb(action), EnableClientCaching = customAttributes.OfType <EnableClientCacheAttribute>().Any() || controllerInfo.EnableClientCaching }); } }
/// <summary> /// Initializes a new instance of the <see cref="WindowsPhoneCommandExecutor"/> class /// for the given kind of controller and device name. /// </summary> /// <param name="controllerKind">The <see cref="ControllerKind"/> value representing /// the kind of controller to create.</param> /// <param name="deviceName">The device name for which to search when connecting.</param> /// <param name="appPath">The path to desired application installation file</param> public WindowsPhoneCommandExecutor(ControllerKind controllerKind, string deviceName, string appPath) { this.controller = new DeviceController(controllerKind, deviceName, appPath); }
private void SetOption(string name, string value) { string argumentName = name.Substring(1).ToUpperInvariant(); switch (argumentName) { case PortCommandLineOption: this.port = int.Parse(value, CultureInfo.InvariantCulture); break; case UserNameCommandLineOption: this.userName = value; break; case PasswordCommandLineOption: this.password = value; break; case ReserveUrlCommandLineOption: this.reserveUrl = true; this.urlToReserve = value; break; case RemoteShutdownCommandLineOption: this.ignoreRemoteShutdown = value.ToUpperInvariant() == "IGNORE"; break; case HubCommandLineOption: this.hubLocation = value; break; case UrlPathCommandLineOption: this.urlPath = value; break; case LogLevelCommandLineOption: LogLevel level = LogLevel.Info; if (Enum.TryParse <LogLevel>(value, true, out level)) { this.logLevel = level; } break; case UseDeviceCommandLineOption: this.controllerKind = ControllerKind.Device; break; case DeviceNameCommandLineOption: this.deviceName = value; break; case HelpCommandLineOption: case HelpShortcutCommandLineOption: this.helpRequested = true; break; case VersionCommandLineOption: case VersionShortcutCommandLineOption: this.versionRequested = true; break; } }
/// <summary> /// Initializes a new instance of the <see cref="DeviceController"/> class connecting to the /// specified kind of device with the specified name. /// </summary> /// <param name="kind">The <see cref="ControllerKind"/> of the controller.</param> /// <param name="deviceName">The name of the device to connect to.</param> public DeviceController(ControllerKind kind, string deviceName) { this.kind = kind; this.deviceName = deviceName; }
/// <summary> /// Initializes a new instance of the <see cref="DeviceController"/> class connecting to the /// specified kind of device with the specified name. /// </summary> /// <param name="kind">The <see cref="ControllerKind"/> of the controller.</param> /// <param name="deviceName">The name of the device to connect to.</param> public DeviceController(ControllerKind kind, string deviceName) { this.kind = kind; this.deviceName = deviceName; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteServer"/> class using the specified port, relative path, /// device name, device type, and logger. /// </summary> /// <param name="port">The port to listen on.</param> /// <param name="path">The relative path to connect to.</param> /// <param name="deviceName">The name of the device to which to bind the controller.</param> /// <param name="kind">The <see cref="ControllerKind"/> value describing the kind of controller to create.</param> /// <param name="log">A <see cref="Logger"/> object describing how to log information about commands executed.</param> public RemoteServer(int port, string path, string deviceName, ControllerKind kind, Logger log) : this(port, path, new WindowsPhoneCommandExecutor(kind, deviceName), log) { }
/// <summary> /// Gets the ControllerInfo collection from a list of types. /// </summary> /// <param name="targetTypes">The types that contain controllers.</param> /// <param name="kind">The kind of controller to get infos for (Web/API)</param> /// <returns></returns> private static IEnumerable <ControllerInfo> GetControllerInfos(IEnumerable <ControllerItem> targetTypes, ControllerKind kind) { var types = targetTypes.Where(t => t.Kind == kind).Select(t => t.Type); var controllerInfos = new List <ControllerInfo>(types.Count()); foreach (var targetType in types) { var customAttributes = targetType.GetCustomAttributes(false); //Ignore if controller is marked with [SkipJavascriptGeneration] if (customAttributes.OfType <SkipJavascriptGenerationAttribute>().Any()) { continue; } var controllerInfo = new ControllerInfo { ControllerType = targetType, Kind = kind, UseNamespace = customAttributes.OfType <GenerateWithNamespaceAttribute>().Any(), EnableClientCaching = customAttributes.OfType <EnableClientCacheAttribute>().Any() }; ApiReflector.GetActionInfos(controllerInfo, kind); if (controllerInfo.Actions.Any()) { controllerInfos.Add(controllerInfo); } } return(controllerInfos); }
/// <summary> /// Initializes a new instance of the <see cref="DeviceController"/> class connecting to the /// specified kind of device with the specified name. /// </summary> /// <param name="kind">The <see cref="ControllerKind"/> of the controller.</param> /// <param name="deviceName">The name of the device to connect to.</param> /// <param name="appPath">The path to desired application installation file</param> public DeviceController(ControllerKind kind, string deviceName, string appPath) { this.kind = kind; this.deviceName = deviceName; this.appPath = appPath; }