public void Convert() { FigureContainer.ClearContainer(); IColor color = null; Container = new ObjectsContainer(); _container.MifAtlases.Where(a => !(a is MultiAtlas)).ToList().ForEach(atlas => { var graphic = AddGraphic(atlas, color); Container.Add(new SpintronicsObject(atlas, graphic)); }); _container.MifAtlases.Where(a => a is MultiAtlas).ToList().ForEach(m => ((MultiAtlas)m).MifAtlas.ForEach(atlas => { var graphic = AddGraphic(atlas, color); Container.Add(new SpintronicsObject(atlas, graphic, m.Name)); })); _container.MifEnergies.ForEach(energy => { Container.Add(CreateEnergy(energy, color)); }); _container.MifScripts.ForEach(script => { Container.Add(new MifScript(script)); }); Container.UnprocessedText = _container.UnprocessedText.Text;//TODO:rework }
/// <summary>添加单实例,指定实例工厂</summary> /// <param name="container"></param> /// <param name="serviceType"></param> /// <param name="factory"></param> /// <returns></returns> public static IObjectContainer AddSingleton(this IObjectContainer container, Type serviceType, Func <IServiceProvider, Object> factory) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } if (factory == null) { throw new ArgumentNullException(nameof(factory)); } var item = new ObjectMap { ServiceType = serviceType, Factory = factory, Lifttime = ObjectLifetime.Singleton, }; container.Add(item); return(container); }
/// <summary>添加瞬态实例,指定实现类型</summary> /// <param name="container"></param> /// <param name="serviceType"></param> /// <param name="implementationType"></param> /// <returns></returns> public static IObjectContainer AddTransient(this IObjectContainer container, Type serviceType, Type implementationType) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } if (implementationType == null) { throw new ArgumentNullException(nameof(implementationType)); } var item = new ObjectMap { ServiceType = serviceType, ImplementationType = implementationType, Lifttime = ObjectLifetime.Transient, }; container.Add(item); return(container); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var inputText = InputText.Get(context); //Add Dummy last line to InputText //inputText = inputText + //Environment.NewLine + "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; //inputText = inputText + Environment.NewLine; inputText += Environment.NewLine; //////Get Data from Text File ////string source = System.IO.File.ReadAllText(inputText); //Read Text //========================================== //Pass the filepath to the Child Activity _objectContainer.Add <string>(inputText); //========================================== return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }
/// <summary>添加单实例,指定实例</summary> /// <param name="container"></param> /// <param name="serviceType"></param> /// <param name="instance"></param> /// <returns></returns> public static IObjectContainer AddSingleton(this IObjectContainer container, Type serviceType, Object instance) { if (container == null) { throw new ArgumentNullException(nameof(container)); } if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } if (instance == null) { throw new ArgumentNullException(nameof(instance)); } var item = new ObjectMap { ServiceType = serviceType, Instance = instance, Lifttime = ObjectLifetime.Singleton, }; container.Add(item); return(container); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var username = AccountUsername.Get(context); var password = AppPassword.Get(context); var passwordString = new System.Net.NetworkCredential(string.Empty, password).Password; //Prepare default header var authHeaderString = username + ":" + passwordString; // This is the format used in the HTTP request header. var base64EncodedCredentials = Base64Encode(authHeaderString); // Create client and assign default request header var defaultHttpClient = new HttpClient(); defaultHttpClient.DefaultRequestHeaders .Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", base64EncodedCredentials); var client = new FluentClient("https://api.bitbucket.org/2.0/", defaultHttpClient); // Send to child activities _objectContainer.Add(client); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var hostName = HostName.Get(context); var portNumber = PortNumber.Get(context); var userName = UserName.Get(context); var password = Password.Get(context); var sftp_session = new SftpClient(hostName, portNumber, userName, password); sftp_session.Connect(); sftp_Session_Var = sftp_session; _objectContainer.Add <SftpClient>(sftp_session); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var activityTimeout = TimeoutMS.Get(context); var host = Host.Get(context); var port = Port.Get(context); var username = Username.Get(context); var password = Password.Get(context); var shellExpectedPrompt = ShellExpectedPrompt.Get(context); var proxyHost = ProxyHost.Get(context); var proxyPort = ProxyPort.Get(context); var proxyUsername = ProxyUsername.Get(context); var proxyPassword = ProxyPassword.Get(context); // Set a timeout on the execution var task = ExecuteWithTimeout(context, cancellationToken); if (await Task.WhenAny(task, Task.Delay(activityTimeout, cancellationToken)) != task) { throw new TimeoutException(Resources.Timeout_Error); } if (task.Exception != null) { throw task.Exception; } _objectContainer.Add(sshClient); _objectContainer.Add(currentShellStream); _objectContainer.Add(expectedPromptRegex); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } }); }
protected override void Execute(NativeActivityContext context) { // Inputs string host = Host.Get(context); string token = Token.Get(context); Application application = new Application(token, host); _objectContainer.Add(application); if (Body != null) { context.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs string host = Host.Get(context); string token = Token.Get(context); Application application = new Application(token, host); _objectContainer.Add(application); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }
protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken cancellationToken) { // Inputs var accountsid = AccountSid.Get(context); var authtoken = AuthToken.Get(context); var region = Region.Get(context); var timeout = Timeout.Get(context); _objectContainer.Add(TwilioWrappers.GetTwilioRestClient(accountsid, authtoken, region, timeout)); return((ctx) => { // Schedule child activities if (Body != null) { ctx.ScheduleAction <IObjectContainer>(Body, _objectContainer, OnCompleted, OnFaulted); } // Outputs }); }