public Connection(string account, string user, string hash) { config = new AssemblyConfig(account, user, hash); handler = new HttpClientHandler { CookieContainer = new CookieContainer(), UseCookies = true, UseDefaultCredentials = true }; Client = new HttpClient(handler); Client.DefaultRequestHeaders.Accept.Clear(); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded")); Client.BaseAddress = config.Url.Base; this.logger = new LoggerConfiguration() .WriteTo.Seq("http://logs.fitness-pro.ru:5341") .CreateLogger(); logger.Information("Создан объект подключения к AmoCRM"); Timer keepConnection = new Timer( new TimerCallback(Auth), null, 0, 420000); //Auth(null); }
public async Task <Failable <User> > LoginAsync(Login login) { const string settingsName = "LoginClientBaseAddress"; try { var uri = AssemblyConfig <RegisterClient> .GetValue(settingsName); var response = await Client.PostAsync(new Uri(uri), login.ToJsonContent()); var result = await HandleResponseAsync <User>(response); if (result.IsSucceeded()) { await UpdateCookiesAsync(response); } await UpdateCurrentUserAsync(result.Value); return(result); } catch (Exception e) { Console.WriteLine(e); return(new Failable <User>(e)); } }
/// <inheritdoc /> public async Task <Failable> LogoutAsync() { const string settingsName = "LogoutClientBaseAddress"; try { var uri = AssemblyConfig <RegisterClient> .GetValue(settingsName); var message = await GetHttpMessageWithSessionCookie(uri, HttpMethod.Get); var response = await Client.SendAsync(message); var result = await HandleResponseAsync <NoReturnValue>(response); //Delete anyways -- even if result failed await UpdateCookiesAsync(null); await UpdateCurrentUserAsync(null); if (!result.IsSucceeded()) { throw new InvalidOperationException(result.ThrownException?.Message ?? "Logout rejected by backend"); } return(result); } catch (Exception e) { return(new Failable(e)); } }
public void GenerateSerializedFilenameTest() { AssemblyConfig target = new AssemblyConfig(); string objectFolder = null; // TODO: Initialize to an appropriate value target.GenerateSerializedFilename(objectFolder); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
void DeactivateAssembly(AssemblyConfig assemblyConfig) { var __types = assemblyConfig.scriptableObjectTypes; for (var __i = 0; __i < __types.Length; __i++) { var __type = __types[__i]; _activeTypes.Remove(__type); } }
/// <summary> /// Shows the weaving statistics. /// </summary> /// <param name="assembly">The assembly.</param> /// <param name="weaveStats">The weave stats.</param> private void ShowWeavingStats(AssemblyConfig assembly, WeaveStatistics weaveStats) { Log.LogMessageFromResources("WeavingStats", weaveStats.AverageWeaveTimePerMethod.TotalSeconds, weaveStats.AverageWeaveTimePerType.TotalSeconds, weaveStats.MaxWeaveTimePerMethod.TotalSeconds, weaveStats.MaxWeaveTimePerType.TotalSeconds, weaveStats.TotalMethodWeaveTime.TotalSeconds, weaveStats.TotalTypeWeaveTime.TotalSeconds, weaveStats.MethodsProcessed, weaveStats.TypesProcessed, assembly.FileName, weaveStats.InternalsAdded, weaveStats.ExternalsAdded, weaveStats.InputFiltersAdded, weaveStats.OutputFiltersAdded, weaveStats.TotalWeaveTime.TotalSeconds); }
public AssemblyConfig GetAssemblyConfig(Assembly assembly) { String assemblyName = assembly.GetName().Name; AssemblyConfig assemblyConfig; if (!assemblyMap.TryGetValue(assemblyName, out assemblyConfig)) { assemblyConfig = new AssemblyConfig(assemblyName, whitelist); assemblyMap.Add(assemblyName, assemblyConfig); } return(assemblyConfig); }
public void FilenameTest() { AssemblyConfig target = new AssemblyConfig(); string val = null; // TODO: Assign to an appropriate value for the property target.Filename = val; Assert.AreEqual(val, target.Filename, "Composestar.StarLight.Entities.Configuration.AssemblyConfig.Filename was not set " + "correctly."); Assert.Inconclusive("Verify the correctness of this test method."); }
protected void Application_Start() { log4net.Config.XmlConfigurator.Configure(); AssemblyConfig.InitWebAssembly(); ValueProviderFactories.Factories.Add(new QueryParamProviderFactory()); AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public UploadForm(AssemblyConfig config, string[] paths) { InitializeComponent(); Icon = Resources.icon; _friendlyShareName = paths.Length > 1 ? Path.GetFileName(Path.GetDirectoryName(paths[0])) : Path.GetFileName(paths[0]); Text = string.Format(Text, _friendlyShareName); _cancelationTokenSource = new CancellationTokenSource(); _client = new StackClient(config, _cancelationTokenSource.Token); _paths = paths; Load += (sender, e) => StartWork(); }
public void IsReferenceTest() { AssemblyConfig target = new AssemblyConfig(); bool val = false; // TODO: Assign to an appropriate value for the property target.IsReference = val; Assert.AreEqual(val, target.IsReference, "Composestar.StarLight.Entities.Configuration.AssemblyConfig.IsReference was not s" + "et correctly."); Assert.Inconclusive("Verify the correctness of this test method."); }
public void TimestampTest() { AssemblyConfig target = new AssemblyConfig(); long val = 0; // TODO: Assign to an appropriate value for the property target.Timestamp = val; Assert.AreEqual(val, target.Timestamp, "Composestar.StarLight.Entities.Configuration.AssemblyConfig.Timestamp was not set" + " correctly."); Assert.Inconclusive("Verify the correctness of this test method."); }
public async Task <string> GetUserNameAsync(string userId) { if (UsernameCache.TryGetValue(userId, out var userName)) { return(userName); } const string settingsName = "UserClientGetNameBaseAddress"; const string unknownUser = "******"; await Semaphore.WaitAsync(); try { //double check if (UsernameCache.TryGetValue(userId, out var username)) { return(username); } var uri = AssemblyConfig <RegisterClient> .GetValue(settingsName); var data = new RequestUsernameData { Id = userId }; var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri(uri), Content = data.ToJsonContent(), }; var response = await Client.SendAsync(request); var result = await HandleResponseAsync <RequestUsernameData>(response); //No errorhandling here (non vital action) UsernameCache.TryAdd(userId, result?.Value.Result ?? unknownUser); return(result?.Value.Result); } catch (Exception e) { Console.WriteLine(e); UsernameCache.TryAdd(userId, unknownUser); return(unknownUser); } finally { Semaphore.Release(); } }
public H5DotJson_AssemblySettings() { Dependencies = new List <IModuleDependency>(); Reflection = new ReflectionConfig(); ReflectionInternal = new ReflectionConfig(); Assembly = new AssemblyConfig(); Resources = new ResourceConfig(); Loader = new ModuleLoader(); Output = DEFAULT_OUTPUT; SourceMap = new SourceMapConfig(); Html = new HtmlConfig(); Rules = new CompilerRule(); IgnoreDuplicateTypes = false; }
//// private methods private async Task <Failable <T> > PerformBarrierRequest <T>(string settingsName, object requestData, HttpMethod method) { var uri = AssemblyConfig <BarrierClient> .GetValue(settingsName); var message = await GetHttpMessageWithSessionCookie(uri, method); message.Content = requestData.ToJsonContent(); var response = await Client.SendAsync(message); var result = await HandleResponseAsync <T>(response); return(result); }
public ConfigurationForm(AssemblyConfig config) { InitializeComponent(); Icon = Resources.icon; _config = config; if (!_config.IsDefault) { txtUri.Text = _config.StorageUri.ToString(); txtUserName.Text = _config.UserName; txtPassword.Text = _config.GetPassword(); txtRootFolder.Text = config.RootFolder; } }
public AssemblyInfo() { Dependencies = new List <IPluginDependency>(); DefineConstants = new List <string>(); Reflection = new ReflectionConfig(); ReflectionInternal = new ReflectionConfig(); Assembly = new AssemblyConfig(); Resources = new ResourceConfig(); Loader = new ModuleLoader(); Output = DEFAULT_OUTPUT; SourceMap = new SourceMapConfig(); Html = new HtmlConfig(); Console = new ConsoleConfig(); Rules = new CompilerRule(); IgnoreDuplicateTypes = false; }
/// <summary> /// Initializes a new instance of the <see cref="T:WeaverConfiguration"/> class. /// </summary> /// <param name="outputImagePath">The output image path.</param> /// <param name="inputImagePath">The input image path.</param> /// <param name="assemblyConfig">The assembly config.</param> /// <param name="weaveConfiguration">The weave configuration.</param> public CecilWeaverConfiguration(string outputImagePath, string inputImagePath, AssemblyConfig assemblyConfig, ConfigurationContainer weaveConfiguration) { if (assemblyConfig == null) { throw new ArgumentNullException("assemblyConfig"); } if (string.IsNullOrEmpty(inputImagePath)) { throw new ArgumentNullException("inputImagePath"); } _binfolder = System.IO.Path.GetDirectoryName(inputImagePath); _assemblyConfig = assemblyConfig; _outputImagePath = outputImagePath; _inputImagePath = inputImagePath; _weaveConfiguration = weaveConfiguration; }
public ConfigurationForm(AssemblyConfig config) { InitializeComponent(); Icon = Resources.icon; _config = config; if (!_config.IsDefault) { txtUri.Text = _config.StorageUri.ToString(); txtUserName.Text = _config.UserName; txtPassword.Text = _config.GetPassword(); } if (ShortcutManager.Exists()) { chkSendTo.Checked = true; } }
/// <summary> /// Initializes a new instance of the <see cref="T:CecilWeaverConfiguration"/> class. /// </summary> /// <param name="assemblyConfig">The assembly config.</param> /// <param name="weaveConfiguration">The weave configuration.</param> public CecilWeaverConfiguration(AssemblyConfig assemblyConfig, ConfigurationContainer weaveConfiguration, WeaveDebug weaveDebug) { if (assemblyConfig == null) { throw new ArgumentNullException("assemblyConfig"); } if (weaveConfiguration == null) { throw new ArgumentNullException("weaveConfiguration"); } _weaveConfiguration = weaveConfiguration; _binfolder = System.IO.Path.GetDirectoryName(assemblyConfig.FileName); _assemblyConfig = assemblyConfig; _outputImagePath = assemblyConfig.FileName; _inputImagePath = assemblyConfig.FileName; _weaveDebugLevel = weaveDebug; }
public SimpleLanguageModelMock(int assemblyCount, int typeCount, int fieldCount, int methodCount, int parameterCount) { randomizer = new Random(); model = new List <AssemblyConfig>(); int i = 0; List <AssemblyElement> assemblies = GenerateAssemblies(assemblyCount, typeCount, fieldCount, methodCount, parameterCount); foreach (AssemblyElement ae in assemblies) { AssemblyConfig ac = new AssemblyConfig(); ac.Name = ae.Name; //ac.Filename = String.Format("AssemblyFile_{0}", i); ac.Timestamp = DateTime.Now.Ticks; ac.Assembly = ae; ac.GenerateSerializedFileName(""); model.Add(ac); i++; } }
void DrawAssemblyOption(AssemblyConfig assemblyConfig) { var __wasEnabled = assemblyConfig.isEnabled; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField($"{assemblyConfig.assembly.GetName().Name}"); assemblyConfig.isEnabled = EditorGUILayout.Toggle($"[{assemblyConfig.scriptableObjectTypes.Length.ToString()}] SO derived types", assemblyConfig.isEnabled); GUILayout.EndHorizontal(); var __isEnabled = assemblyConfig.isEnabled; if (__wasEnabled != __isEnabled) { if (__isEnabled) { ActivateAssembly(assemblyConfig); } else { DeactivateAssembly(assemblyConfig); } } }
/// <summary> /// /// </summary> protected void Application_Start() { //log4net.Config.XmlConfigurator.Configure(); log.Info("Pxin Start"); AssemblyConfig.InitWebAssembly(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); CurrencyConfig.Register(); var TimeServiceStart = System.Configuration.ConfigurationManager.AppSettings["TimeServiceStart"]; if (string.IsNullOrEmpty(TimeServiceStart) || TimeServiceStart == "1") { PxinSerivce.Register(); } }
private AssemblyConfig DrawAssemblyConfig(AssemblyConfig config) { GUILayout.Label("Assembly Upload", EditorStyles.boldLabel); var copy = config.DeepCopy(); var error = config.GetError(); using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.HorizontalScope()) { copy.AssemblyName = EditorGUILayout.TextField("Assembly Name", config.AssemblyName); if (GUILayout.Button("Generate", GUILayout.ExpandWidth(false))) { copy.AssemblyName = $"{projectName}_{DateTime.Now:MMdd_HHmm}"; GUI.FocusControl(null); } } copy.ShouldForceUpload = EditorGUILayout.Toggle("Force Upload", config.ShouldForceUpload); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); using (new EditorGUILayout.HorizontalScope()) { var shouldBeVertical = EditorGUIUtility.currentViewWidth < 550; /* Responsive Layout, Intuitive API! */ if (shouldBeVertical) { EditorGUILayout.BeginVertical(); } else { GUILayout.FlexibleSpace(); } using (new EditorGUI.DisabledScope(error != null)) { if (GUILayout.Button("Assign assembly name to deployments")) { foreach (var deplConfig in launcherConfig.DeploymentConfigs) { deplConfig.AssemblyName = launcherConfig.AssemblyConfig.AssemblyName; } } using (new EditorGUI.DisabledScope(manager.IsActive)) { if (GUILayout.Button("Upload assembly")) { manager.Upload(config); } } } if (shouldBeVertical) { EditorGUILayout.EndVertical(); } } if (error != null) { EditorGUILayout.HelpBox(error, MessageType.Error); } } CommonUIElements.DrawHorizontalLine(3, style.HorizontalLineColor); return(copy); }
/// <summary> /// Initializes a new instance of the <see cref="T:CecilWeaverConfiguration"/> class. /// </summary> /// <param name="assemblyConfig">The assembly config.</param> /// <param name="weaveConfiguration">The weave configuration.</param> public CecilWeaverConfiguration(AssemblyConfig assemblyConfig, ConfigurationContainer weaveConfiguration) : this(assemblyConfig, weaveConfiguration, WeaveDebug.Statistics) { }
public MainForm(AssemblyConfig config) { _config = config; InitializeComponent(); Icon = Resources.icon; InitCancellationTokenSource(); _client = new MyWebDavClient(config); Func <ResourceItem, string, string> updateTitle = (resourceItem, action) => { string text = $"{action} : '{resourceItem.Parent.DisplayName}\\{resourceItem.DisplayName}' ({resourceItem.MediaDetails.Mode} {resourceItem.MediaDetails.BitrateKbps} kbps)"; Text = @"WebDAV-AudioPlayer " + text; return(text); }; _player = new Player(_client) { Log = Log, PlayStarted = (selectedIndex, resourceItem) => { string bitrate = $"{resourceItem.MediaDetails.BitrateKbps}"; string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; labelTotalTime.Text = $@"{_player.TotalTime:hh\:mm\:ss}"; trackBarSong.Maximum = (int)_player.TotalTime.TotalSeconds; trackBarSong.Enabled = _player.CanSeek; listView.SetCells(selectedIndex, $@"{_player.TotalTime:h\:mm\:ss}", bitrate); listView.SetSelectedIndex(selectedIndex); }, PlayContinue = resourceItem => { string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; }, PlayPaused = resourceItem => { string text = updateTitle(resourceItem, "Pausing"); textBoxSong.Text = text; }, PlayStopped = () => { trackBarSong.Value = 0; trackBarSong.Maximum = 1; labelCurrentTime.Text = labelTotalTime.Text = @"00:00:00"; Text = @"WebDAV-AudioPlayer"; }, DoubleClickFolderAndPlayFirstSong = async resourceItem => { var nodeToDoubleClick = treeView.Nodes.Find(resourceItem.DisplayName, true).FirstOrDefault(); if (nodeToDoubleClick != null) { await FetchChildResourcesAsync(nodeToDoubleClick, resourceItem); } } }; Log($"Using : '{_player.SoundOut}-SoundOut'"); }
public MainForm(AssemblyConfig config) { _config = config; InitializeComponent(); Icon = Resources.icon; InitCancellationTokenSource(); //_client = new DecaTecWebDavClient(config); _client = new MyWebDavClient(config); Func <ResourceItem, string, string> updateTitle = (resourceItem, action) => { string bitrate = resourceItem.MediaDetails.Bitrate != null ? $"{resourceItem.MediaDetails.Bitrate / 1000}" : "?"; string text = $"{action} : '{resourceItem.Parent.DisplayName}\\{resourceItem.DisplayName}' ({resourceItem.MediaDetails.Mode} {bitrate} kbps)"; Text = @"WebDAV-AudioPlayer " + text; return(text); }; _player = new Player(_client) { Log = Log, PlayStarted = (selectedIndex, resourceItem) => { string bitrate = resourceItem.MediaDetails.Bitrate != null ? $"{resourceItem.MediaDetails.Bitrate / 1000}" : "?"; string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; labelTotalTime.Text = $@"{_player.TotalTime:hh\:mm\:ss}"; trackBarSong.Maximum = (int)_player.TotalTime.TotalSeconds; listView.SetSelectedIndex(selectedIndex); listView.SetCells(selectedIndex, $@"{_player.TotalTime:h\:mm\:ss}", bitrate); }, PlayContinue = resourceItem => { string text = updateTitle(resourceItem, "Playing"); textBoxSong.Text = text; }, PlayPaused = resourceItem => { string text = updateTitle(resourceItem, "Pausing"); textBoxSong.Text = text; }, PlayStopped = () => { trackBarSong.Value = 0; trackBarSong.Maximum = 1; labelCurrentTime.Text = labelTotalTime.Text = @"00:00:00"; Text = @"WebDAV-AudioPlayer"; } }; Log($"Using : '{_player.SoundOut}-SoundOut'"); }
public static WrappedTask <RedirectedProcessResult, AssemblyConfig> UploadAsync(AssemblyConfig config) { var source = new CancellationTokenSource(); var token = source.Token; var args = new List <string> { config.AssemblyName, "--project_name", config.ProjectName, "--json_output", "--enable_pre_upload_check=false", }; if (config.ShouldForceUpload) { args.Add("--force"); } var task = Task.Run(async() => await RedirectedProcess .Spatial("cloud", "upload") .InDirectory(Tools.Common.SpatialProjectRootDir) .WithArgs(args.ToArray()) .RedirectOutputOptions(OutputRedirectBehaviour.RedirectStdOut | OutputRedirectBehaviour.RedirectStdErr | OutputRedirectBehaviour.ProcessSpatialOutput) .RunAsync(token)); return(new WrappedTask <RedirectedProcessResult, AssemblyConfig> { Task = task, CancelSource = source, Context = config.DeepCopy() }); }
void ActivateAssembly(AssemblyConfig assemblyConfig) { _activeTypes.AddRange(assemblyConfig.scriptableObjectTypes); }
public void ParseLine(String line) { String remaining = line; String directive = Peel(ref remaining); if (directive.Length == 0 || directive.StartsWith("#")) { return; } if (directive == "Assemblies") { if (config != null) { throw ParseException("found multiple 'Assemblies' directive"); } String optionalArg = Peel(ref remaining); Boolean whitelist; if (optionalArg.Length == 0) { whitelist = false; } else if (optionalArg.Equals("Whitelist", StringComparison.Ordinal)) { whitelist = true; } else { throw ParseException(String.Format( "invalid argument '{0}' for 'Assemblies' directive, expected 'Whitelist' or nothing", optionalArg)); } EnforceDirectiveDone(directive, remaining); config = new Config(filename, whitelist); } // TODO: implement ExcludeAssembly (only allow if Assemblies is not in Whitelist mode) else if (directive == "DlangKeepNamespaceCasing") { EnforceInAssembliesConfig(directive); EnforceDirectiveDone(directive, remaining); config.dlangKeepNamespaceCasing = true; } else if (directive == "Assembly") { EnforceHaveAssembliesConfig(directive); String name = Peel(ref remaining); if (name.Length == 0) { throw ParseException("the 'Assembly' directive requires a name"); } Boolean whitelist; String optionalArg = Peel(ref remaining); if (optionalArg.Length == 0) { whitelist = false; } else if (optionalArg.Equals("Whitelist", StringComparison.Ordinal)) { whitelist = true; } else { throw ParseException(String.Format( "invalid argument '{0}' for 'Assembly' directive, expected 'Whitelist' or nothing", optionalArg)); } EnforceDirectiveDone(directive, remaining); this.currentType = null; this.currentAssembly = new AssemblyConfig(name, whitelist); config.assemblyMap.Add(name, this.currentAssembly); } // TODO: implement ExcludeType (only allow if the assembly is not in Whitelist mode) else if (directive == "Type") { EnforceHaveAssembly(directive); String name = Peel(ref remaining); if (name.Length == 0) { throw ParseException("the 'Type' directive requires a name"); } EnforceDirectiveDone(directive, remaining); this.currentType = new TypeConfig(lineNumber, name); this.currentAssembly.typeMap.Add(name, this.currentType); } else if (directive == "ExcludeMethod") { EnforceHaveType(directive); String name = Peel(ref remaining); if (name.Length == 0) { throw ParseException(String.Format("the '{0}' directive requires a name", directive)); } EnforceDirectiveDone(directive, remaining); if (!this.currentType.AddExcludeMethod(name)) { throw ParseException(String.Format("method '{0}' has already been excluded", name)); } } else { throw ParseException(String.Format("Unknown directive '{0}'", directive)); } }