/// <summary> Ensure object is ready for serialization, and calls <see cref="IHostingService.OnBeforeSerialize"/> methods /// on all managed <see cref="IHostingService"/> instances /// </summary> public void OnAfterDeserialize() { m_HostingServiceInfoMap = new Dictionary <IHostingService, HostingServiceInfo>(); foreach (var svcInfo in m_HostingServiceInfos) { IHostingService svc = CreateHostingServiceInstance(svcInfo.classRef); if (svc == null) { continue; } svc.OnAfterDeserialize(svcInfo.dataStore); m_HostingServiceInfoMap.Add(svc, svcInfo); } m_RegisteredServiceTypes = new List <Type>(); foreach (var typeRef in m_RegisteredServiceTypeRefs) { var type = Type.GetType(typeRef, false); if (type == null) { continue; } m_RegisteredServiceTypes.Add(type); } }
/// <inheritdoc/> /// <summary> Ensure object is ready for serialization, and calls <see cref="IHostingService.OnBeforeSerialize"/> methods /// on all managed <see cref="IHostingService"/> instances /// </summary> public void OnAfterDeserialize() { m_HostingServiceInfoMap = new Dictionary <IHostingService, HostingServiceInfo>(); foreach (var svcInfo in m_HostingServiceInfos) { IHostingService svc = null; var id = svcInfo.dataStore.GetData(BaseHostingService.k_InstanceIdKey, -1); if (id == -1 || !s_HostingServicesCache.ContainsKey(id) || !s_HostingServicesCache[id].TryGetTarget(out svc)) { svc = CreateHostingServiceInstance(svcInfo.classRef); } if (svc == null) { continue; } svc.OnAfterDeserialize(svcInfo.dataStore); m_HostingServiceInfoMap.Add(svc, svcInfo); s_HostingServicesCache[svc.InstanceId] = new WeakReference <IHostingService>(svc); } m_RegisteredServiceTypes = new List <Type>(); foreach (var typeRef in m_RegisteredServiceTypeRefs) { var type = Type.GetType(typeRef, false); if (type == null) { continue; } m_RegisteredServiceTypes.Add(type); } }
public FileSystemStorageService(IHostingService hostingService) { _serverRoot = hostingService.MapPath("~/"); if (string.IsNullOrEmpty(_serverRoot)) { throw new InvalidOperationException("Can't get server root!"); } }
void DrawServiceElement(IHostingService svc, List <IHostingService> svcList) { bool isDirty = false; string newName = EditorGUILayout.DelayedTextField("Service Name", svc.DescriptiveName); if (svcList.Find(s => s.DescriptiveName == newName) == default(IHostingService)) { svc.DescriptiveName = newName; m_ServicesList.Reload(); isDirty = true; } var typeAndId = string.Format("{0} ({1})", svc.GetType().Name, svc.InstanceId.ToString()); EditorGUILayout.LabelField("Service Type (ID)", typeAndId, GUILayout.MinWidth(225f)); // Allow service to provide additional GUI configuration elements svc.OnGUI(); var newIsServiceEnabled = EditorGUILayout.Toggle("Enable", svc.IsHostingServiceRunning); if (newIsServiceEnabled != svc.IsHostingServiceRunning) { if (newIsServiceEnabled) { svc.StartHostingService(); } else { svc.StopHostingService(); } isDirty = true; } EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!svc.IsHostingServiceRunning)) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Hosting Service Variables"); var manager = m_Settings.HostingServicesManager; if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false))) { manager.RefreshGlobalProfileVariables(); } GUILayout.EndHorizontal(); DrawProfileVarTable(svc); } if (isDirty && m_Settings != null) { m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, false, true); } }
/// <summary> /// Add a hosting service to the removal queue. /// </summary> /// <param name="svc">The service type to be removed.</param> /// <param name="showDialog">Indicates whether or not a warning dialogue box is shown.</param> public void RemoveService(IHostingService svc, bool showDialog = true) { if (!showDialog) { m_RemovalQueue.Add(svc); } else if (EditorUtility.DisplayDialog("Remove Service", "Are you sure you want to remove " + svc.DescriptiveName + "? This action cannot be undone.", "Ok", "Cancel")) { m_RemovalQueue.Add(svc); } }
/// <summary> /// Stops the given <see cref="IHostingService"/>, unregisters callbacks, and removes it from management. This /// function does nothing if the service is not being managed by this <see cref="HostingServicesManager"/> /// </summary> /// <param name="svc"></param> public void RemoveHostingService(IHostingService svc) { if (!m_HostingServiceInfoMap.ContainsKey(svc)) { return; } svc.StopHostingService(); m_Settings.profileSettings.UnregisterProfileStringEvaluationFunc(svc.EvaluateProfileString); m_HostingServiceInfoMap.Remove(svc); m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, true, true); }
public void Start(IHostingService host) { if (host == null) { throw new ArgumentNullException("host"); } m_tracer = host.GetTracer(GetType()); m_host = host; m_instanceName = GetInstanceName(); var tcpBaseAddress = GetTcpBaseAddress(); var httpBaseAddress = GetHealthServiceBaseAddress(); try { PerfCounters.Remove(); PerfCounters.Install(); } catch (Exception e) { m_tracer.Exception(e); throw; } var maxConcurrency = Environment.ProcessorCount * 16; var maxPending = Environment.ProcessorCount * 16; m_singletonServiceInstance = new DataService( m_host.GetTracer(typeof(DataService)), this, tcpBaseAddress.Authority + ", " + m_instanceName, maxConcurrency, null); var serviceHost = CreateServiceHost(m_singletonServiceInstance, new[] { tcpBaseAddress, httpBaseAddress }, maxConcurrency, maxPending); serviceHost.Open(); m_serviceHost = serviceHost; if (m_tracer.IsInfoEnabled) { var builder = new StringBuilder(200); foreach (var ep in serviceHost.ChannelDispatchers) { if (ep.Listener != null) { builder.AppendLine(ep.Listener.Uri.ToString()); } } m_tracer.InfoFormat("Service host [{0}] started. Listening on following base URIs:{1}{2}", m_instanceName, Environment.NewLine, builder); } }
/// <inheritdoc/> public void LogFormat(LogType logType, Object context, string format, params object[] args) { IHostingService svc = null; if (args.Length > 0) { svc = args[args.Length - 1] as IHostingService; } if (svc != null) { m_LogText += string.Format("[{0}] ", svc.DescriptiveName) + string.Format(format, args) + "\n"; m_NewLogContent = true; } Debug.unityLogger.LogFormat(logType, context, format, args); }
void DrawServiceElement(IHostingService svc) { EditorGUILayout.BeginHorizontal(); { svc.DescriptiveName = EditorGUILayout.DelayedTextField("Service EventName", svc.DescriptiveName); var newIsServiceEnabled = GUILayout.Toggle(svc.IsHostingServiceRunning, "Enable Service", "Button", GUILayout.MaxWidth(150f)); if (GUILayout.Button("Remove...", GUILayout.MaxWidth(75f))) { if (EditorUtility.DisplayDialog("Remove Service", "Are you sure?", "Ok", "Cancel")) { m_RemovalQueue.Add(svc); } } else if (newIsServiceEnabled != svc.IsHostingServiceRunning) { if (newIsServiceEnabled) { svc.StartHostingService(); } else { svc.StopHostingService(); } } } EditorGUILayout.EndHorizontal(); var typeAndId = string.Format("{0} ({1})", svc.GetType().Name, svc.InstanceId.ToString()); EditorGUILayout.LabelField("Service Type (ID)", typeAndId, GUILayout.MinWidth(225f)); EditorGUILayout.Space(); using (new EditorGUI.DisabledGroupScope(!svc.IsHostingServiceRunning)) { // Allow service to provide additional GUI configuration elements svc.OnGUI(); EditorGUILayout.Space(); DrawProfileVarTable(svc, svc.ProfileVariables); } }
void DrawProfileVarTable(IHostingService tableKey) { var manager = m_Settings.HostingServicesManager; var data = tableKey.ProfileVariables; HostingServicesProfileVarsTreeView table; if (!m_ProfileVarTables.TryGetValue(tableKey, out table)) { table = new HostingServicesProfileVarsTreeView(new TreeViewState(), HostingServicesProfileVarsTreeView.CreateHeader()); m_ProfileVarTables[tableKey] = table; m_TablePrevData[tableKey] = new Dictionary <string, string>(data); m_TablePrevManagerVariables[tableKey] = new Dictionary <string, string>(manager.GlobalProfileVariables); } else if (!DictsAreEqual(data, m_TablePrevData[tableKey]) || !DictsAreEqual(manager.GlobalProfileVariables, m_TablePrevManagerVariables[tableKey])) { table.ClearItems(); m_TablePrevData[tableKey] = new Dictionary <string, string>(data); m_TablePrevManagerVariables[tableKey] = new Dictionary <string, string>(manager.GlobalProfileVariables); } if (table.Count == 0) { foreach (var globalVar in manager.GlobalProfileVariables) { table.AddOrUpdateItem(globalVar.Key, globalVar.Value); } foreach (var kvp in data) { table.AddOrUpdateItem(kvp.Key, kvp.Value); } } var rowHeight = table.RowHeight; var tableHeight = table.multiColumnHeader.height + rowHeight + (rowHeight * (data.Count() + manager.GlobalProfileVariables.Count)); // header + 1 extra line table.OnGUI(EditorGUILayout.GetControlRect(false, tableHeight)); }
protected override void ContextClickedItem(int id) { base.ContextClickedItem(id); List <TreeViewItem> selectedNodes = GetSelectedNodes(); GenericMenu menu = new GenericMenu(); if (selectedNodes.Count > 1) { menu.AddItem(new GUIContent("Remove Services"), false, () => { for (int i = 0; i < selectedNodes.Count; i++) { // Show dialog for first entry only m_Window.RemoveService(GetService(selectedNodes[i].displayName), i == 0); } }); } else { IHostingService service = GetService(selectedNodes[0].displayName); if (service.IsHostingServiceRunning) { menu.AddItem(new GUIContent("Disable Service"), false, service.StopHostingService); } else { menu.AddItem(new GUIContent("Enable Service"), false, service.StartHostingService); } menu.AddItem(new GUIContent("Remove Service"), false, () => m_Window.RemoveService(service)); } menu.ShowAsContext(); }
public DataCenterService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public HostingServiceInterfaceTests(IHostingService svc) { m_Service = svc; }
public MembershipProvider(IEmailService email, IHostingService hosting) : base() { this.email = email; this.hosting = hosting; }
public OperationService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public DiskService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public void Start(IHostingService host) { Debug.WriteLine("Starting"); }
public VirtualMachineService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public InterfaceService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public IpAddressService(IHostingService service, string apiKey) { this.service = service; this.apiKey = apiKey; }
public ApplicationExceptionFilter(IHostingService hostingService, IModelMetadataProvider modelMetadataProvider, ILoggerService loggerService) { _hostingService = hostingService; _modelMetadataProvider = modelMetadataProvider; _logger = loggerService; }
public HostAServerViewModel(IHostingService hostingService, IClient client, IWindowManager windowManager) { _hostingService = hostingService; _client = client; _windowManager = windowManager; }
public HostingsController(IHostingService hostingService) { _hostingService = hostingService; }
static bool ProfileStringEvalDelegateIsRegistered(AddressableAssetSettings s, IHostingService svc) { var del = new AddressableAssetProfileSettings.ProfileStringEvaluationDelegate(svc.EvaluateProfileString); var list = s.profileSettings.onProfileStringEvaluation.GetInvocationList(); return(list.Contains(del)); }