public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) || commandLineArgs.Options.ContainsKey(Options.Preview.Long); var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); switch (operationType) { case "": case null: _cmdHelper.RunCmd("abp"); break; case "update": await UpdateCliAsync(version, preview); break; case "remove": RemoveCli(); break; } }
/// <summary> /// /// </summary> /// <param name="className">Class name with namespace</param> /// <returns></returns> public static Type GetType(string className) { string nameSpace = NamespaceHelper.GetNamespace(className); Assembly assembly = GetAssembly(nameSpace); return(assembly.GetType(className)); }
public ITextOutput Generate(ICodeSetup codeSetup, ICodeGeneratorSetup codeGeneratorSetup, IProject target, IQuantityModel model, ICodeRun run, long index) { return(new TextOutput($@" // -------------------------------------------------------------------------------------------------------------------- // <copyright file=""{run.FileName}"" company=""Hukano""> // Copyright (c) Hukano. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // </copyright> // -------------------------------------------------------------------------------------------------------------------- // <auto-generated /> namespace {NamespaceHelper.CombineNamespaces(target.RootNamespace, run.Namespace)} {{ {UsingsHelper.GetUsings(codeSetup.UseGlobalUsings | codeGeneratorSetup.UseGlobalUsings, 4, codeSetup.Usings, codeGeneratorSetup.Usings)} /// <summary> /// Interface for <see cref=""{model.Name}""/> unit selector. /// </summary> [GeneratedCode(""{this.GetType().FullName}"", ""{this.GetType().Assembly.GetName().Version}"")] public interface I{model.Name}UnitSelector : IUnitSelector {{ {this.GetUnits(model)} }} }} ")); }
public async Task Test_SendingRandomMessages <T>(T _) where T : IMessage, new() // be careful with this, if the test doesn't run it's because the T validation is broken { _.CheckInlineType(); // inline data check var sendCount = new Random().Next(1, 10); await NamespaceManager.CreateFromConnectionString(NamespaceHelper.GetConnectionString()).ScorchNamespace(); MessageQueue.LockTimers.Release(); MessageQueue.BrokeredMessages.Release(); var messages = new List <T>(); for (var i = 0; i < sendCount; i++) { messages.Add(new T()); } using (IMessenger msn = new Messenger(NamespaceHelper.GetConnectionString())) { foreach (var message in messages) { await msn.Send(message); } await Task.Delay(TimeSpan.FromSeconds(5)); // wait 5 seconds to flush out all the messages var qClient = QueueClient.CreateFromConnectionString(NamespaceHelper.GetConnectionString(), typeof(T).GetQueueName()); var rMessages = (await qClient.ReadBatchAsync <T>(sendCount)).ToList(); rMessages.Should().BeEquivalentTo(messages); qClient.Close(); } }
public List <GeneratedFile> GenerateCode(CodeGenerationConfig outputConfig) { var generator = new LiquidTemplateGenerator(_TemplatePath); var relativeNamespace = NamespaceHelper.GetNamespaceFromPath(FilePath); var fileObjectNamespace = NamespaceHelper.GetNamespaceFromFullTypeName(FileObjectType); var fileObjectTypeName = NamespaceHelper.GetTypeFromFullTypeName(FileObjectType); var fileContents = generator.Render(new { Namespace = outputConfig.ProjectRootNamespace + "." + relativeNamespace, ClassName = ClassName, FileName = FileName, FileObjectType = fileObjectTypeName, FileObjectName = fileObjectTypeName, FileObjectNamespace = fileObjectNamespace, }); var filePath = Path.Combine(outputConfig.CSharpRootPath, FilePath); return(new List <GeneratedFile>() { new GeneratedFile() { Path = $"{filePath}/{ClassName}.cs", Contents = fileContents } }); }
private object GetTemplateModelFromResourceModel() { return(new { RenderGroups = new object[] { new { Namespace = GetNamespace(), Resources = ResourceModelProvider .GetResourceModel() .GetAllResources() .Where( resource => !resource.IsAbstract() && TemplateContext.ShouldRenderResourceClass( resource)) .Select( resource => new { ResourceName = resource.Name, ResourceTypeName = NamespaceHelper.GetRelativeNamespace( GetNamespace(), GetResourceTypeName(resource)), EntityTypeName = NamespaceHelper.GetRelativeNamespace( GetNamespace(), GetEntityTypeName(resource)) }) } } }); }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) || commandLineArgs.Options.ContainsKey(Options.Preview.Long); var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); switch (operationType) { case "": case null: await InstallSuiteIfNotInstalledAsync(); RunSuite(); break; case "install": await InstallSuiteAsync(version, preview); break; case "update": await UpdateSuiteAsync(version, preview); break; case "remove": Logger.LogInformation("Removing ABP Suite..."); RemoveSuite(); break; } }
public AssetFile(XElement xml, Metadata parentMetadata, IMimeTypeProvider mimeTypeProvider) { _nsm = NamespaceHelper.CreateNamespaceManager(xml); _xml = xml; _parentMetadata = parentMetadata; _mimeTypeProvider = mimeTypeProvider; }
public async Task Test_LockMessage_ForFiveMinutes <T>(T _) where T : IMessage, new() // be careful with this, if the test doesn't run it's because the T validation is broken { _.CheckInlineType(); // inline data check await NamespaceManager.CreateFromConnectionString(NamespaceHelper.GetConnectionString()).ScorchNamespace(); MessageQueue.LockTimers.Release(); MessageQueue.BrokeredMessages.Release(); using (IMessenger msn = new Messenger(NamespaceHelper.GetConnectionString())) { await msn.Send(new T()); var message = default(T); msn.Receive <T>( async m => { message = m; await message.Lock(); }); await Task.Delay(TimeSpan.FromMinutes(5)); message.Should().NotBeNull(); await message.Complete(); // If this throws, Lock failed } }
private string GenerateDefaultConfigurationType(string baseTypeName) { IDictionaryService dictionaryService = (IDictionaryService)GetService <IDictionaryService>(); string configurationNamespace = dictionaryService.GetValue(configurationNamespaceArgumentName) as string; return(NamespaceHelper.GenerateTypeName(configurationNamespace, string.Concat(baseTypeName, configurationTypeSuffix))); }
private IEnumerable <MemberTracker <object> > GetMembersAndValues(object obj, int index = -1, int depth = 0) { var memberTrackers = new List <MemberTracker <object> >(); depth++; if (depth > Depth) { return(memberTrackers); } _cts.Token.ThrowIfCancellationRequested(); var objType = obj.GetRealType(_proxyNamespaces.ToArray()); if (obj.IsPrimitiveType()) { return new[] { CreateMemberTracker(obj, objType, obj, index, depth) } } ; foreach (var field in objType.GetRuntimeFields().Where(f => !f.Name.EndsWith("__BackingField") && !f.Name.EndsWith("__Field") && !NamespaceHelper.ContainsNamespace(f.DeclaringType, ExcludedNameSpaces.ToArray()))) { memberTrackers.Add(CreateMemberTracker(obj, field, field.GetValue(obj), index, depth)); } foreach (var prop in objType.GetRuntimeProperties().Where(f => !NamespaceHelper.ContainsNamespace(f.DeclaringType, ExcludedNameSpaces.ToArray()))) { memberTrackers.Add(CreateMemberTracker(obj, prop, prop.GetValue(obj, null), index, depth)); } return(memberTrackers); }
public async Task Test_LockComplete_MessageFlow <T>(T _) where T : IMessage, new() // be careful with this, if the test doesn't run it's because the T validation is broken { _.CheckInlineType(); // inline data check await NamespaceManager.CreateFromConnectionString(NamespaceHelper.GetConnectionString()).ScorchNamespace(); MessageQueue.LockTimers.Release(); MessageQueue.BrokeredMessages.Release(); using (var ts = new CancellationTokenSource()) using (IMessenger msn = new Messenger(NamespaceHelper.GetConnectionString())) { await msn.Send(new T()); msn.Receive <T>( async m => { await m.Lock(); await Task.Delay(TimeSpan.FromSeconds(5), ts.Token); await m.Complete(); ts.Cancel(); // kill switch }); try { await Task.Delay(TimeSpan.FromMinutes(2), ts.Token); } catch (TaskCanceledException) { /* soak the kill switch */ } MessageQueue.BrokeredMessages.Should().BeEmpty(); MessageQueue.LockTimers.Should().BeEmpty(); } }
/// <summary> /// Generates the list of "NamespaceModels" for the tree view "Namespace" for the specified document /// </summary> /// <param name="xmlDocument">The xml document that has the list of data</param> private void GenerateNamespaceTreeList(XmlDocument xmlDocument) { var namespaces = xmlDocument.GetElementsByTagName("Namespace"); var list = NamespaceHelper.SetupNamespaceList(namespaces, ref count); issueModelList.AddRange(list.Select(x => x.Issue)); }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); switch (operationType) { case "": case null: RunSuite(); break; case "install": Logger.LogInformation("Installing ABP Suite..."); await InstallSuiteAsync(); break; case "update": Logger.LogInformation("Updating ABP Suite..."); await UpdateSuiteAsync(); break; case "remove": Logger.LogInformation("Removing ABP Suite..."); RemoveSuite(); break; } }
public Metadata(XDocument xml, string privateLocatorUrl, string publicLocatorUrl, IMimeTypeProvider mimeTypeProvider) { _nsm = NamespaceHelper.CreateNamespaceManager(xml); _xml = xml; _privateLocatorUrl = privateLocatorUrl; _publicLocatorUrl = publicLocatorUrl; _mimeTypeProvider = mimeTypeProvider; }
void GetAvailableNamespaces() { Fx.Assert(this.availableNamespaces != null, "available namespace table should have been set before calling this method"); AssemblyContextControlItem assemblyItem = this.Context.Items.GetValue <AssemblyContextControlItem>(); if (assemblyItem != null) { IMultiTargetingSupportService multiTargetingService = this.Context.Services.GetService <IMultiTargetingSupportService>(); ////When ReferencedAssemblyNames is null, it's in rehost scenario. And we need to preload assemblies in ////TextExpression.ReferencesForImplementation/References if there is any. So that these assemblies will be returned ////by AssemblyContextControlItem.GetEnvironmentAssemblies and user can see namespaces defined in these assemlbies ////in the dropdown list of Import Designer. if ((assemblyItem.ReferencedAssemblyNames == null) && (this.targetFramework.Is45OrHigher())) { ModelTreeManager modelTreeManager = this.Context.Services.GetService <ModelTreeManager>(); object root = modelTreeManager.Root.GetCurrentValue(); IList <AssemblyReference> references; NamespaceHelper.GetTextExpressionNamespaces(root, out references); foreach (AssemblyReference reference in references) { reference.LoadAssembly(); } } IEnumerable <Assembly> allAssemblies = assemblyItem.GetEnvironmentAssemblies(multiTargetingService); if (assemblyItem.LocalAssemblyName != null) { allAssemblies = allAssemblies.Union <Assembly>(new Collection <Assembly> { AssemblyContextControlItem.GetAssembly(assemblyItem.LocalAssemblyName, multiTargetingService) }); } foreach (Assembly assembly in allAssemblies) { try { if (assembly != null) { Fx.Assert(!assembly.IsDynamic, "there should not be any dynamic assemblies in reference list"); this.UpdateAvailableNamespaces(assembly, assemblyItem); } } catch (ReflectionTypeLoadException) { } catch (FileNotFoundException) { } } if (assemblyItem.LocalAssemblyName == null) { AppDomain.CurrentDomain.AssemblyLoad += this.proxy.OnAssemblyLoad; } } }
public ServiceContractGenerator(CodeCompileUnit targetCompileUnit) { _compileUnit = targetCompileUnit ?? new CodeCompileUnit(); _namespaceManager = new NamespaceHelper(_compileUnit.Namespaces); AddReferencedAssembly(typeof(ServiceContractGenerator).GetTypeInfo().Assembly); _generatedTypes = new Dictionary <ContractDescription, ServiceContractGenerationContext>(); _generatedOperations = new Dictionary <OperationDescription, OperationContractGenerationContext>(); _referencedTypes = new Dictionary <ContractDescription, Type>(); }
public void WhenMapToDictionary_ShouldReturnDictionary() { INamespaceMapper nsMap = new NamespaceMapper(); nsMap.AddNamespace("ex", new Uri("http://www.example.org/ns#")); IDictionary <string, string> result = NamespaceHelper.ToStringDictionary(nsMap); Assert.That(result, Is.Not.Null); }
public void WhenMapToVDS_ShouldReturnVDSNamespaceMap() { IDictionary <string, string> nsMap = new Dictionary <string, string>() { { "ex", "http://www.example.org/ns#" }, }; INamespaceMapper result = NamespaceHelper.ToIGraphNamespaceMap(nsMap); Assert.That(result, Is.Not.Null); }
protected override string GenerateDefaultValueFormInterface(Type type) { if (type.Name.StartsWith(interfaceDefaultPrefix)) { return(NamespaceHelper.GenerateTypeName(type.Namespace, type.Name.Substring(interfaceDefaultPrefix.Length))); } else { return(type.FullName); } }
private object GetTemplateModelFromProfileResourceModel() { var profileResourceModels = GetProfileResourceModels(); return(new { RenderGroups = profileResourceModels .Select( model => new { Model = model, Namespace = GetNamespace(model.ProfileName) }) .Select( x => new { x.Namespace, Resources = x.Model.ResourceByName .OrderBy(resourceEntry => resourceEntry.Key) .Where( resource => !x.Model.GetResourceByName(resource.Key) .IsAbstract() && x.Model.ResourceByName.Any( resourceInProfile => x.Model.ResourceIsWritable( resourceInProfile .Key))) .Select( resource => new { ResourceName = resource.Key.Name, ResourceTypeName = NamespaceHelper .GetRelativeNamespace( x.Namespace, GetResourceTypeName( x.Model .GetResourceByName( resource.Key), x.Model.ProfileName)), EntityTypeName = NamespaceHelper .GetRelativeNamespace( x.Namespace, GetEntityTypeName( x.Model .GetResourceByName( resource.Key))) }) }) }); }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var projectName = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); if (projectName == null) { throw new CliUsageException( "Project name is missing!" + Environment.NewLine + Environment.NewLine + GetUsageInfo() ); } if (!ProjectNameValidator.IsValid(projectName)) { throw new CliUsageException("The project name is invalid! Please specify a different name."); } Logger.LogInformation("Creating your project..."); Logger.LogInformation("Project name: " + projectName); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long); if (template != null) { Logger.LogInformation("Template: " + template); } else { template = (await TemplateInfoProvider.GetDefaultAsync()).Name; } var isTiered = commandLineArgs.Options.ContainsKey(Options.Tiered.Long); if (isTiered) { Logger.LogInformation("Tiered: yes"); } var projectArgs = GetProjectBuildArgs(commandLineArgs, template, projectName); var result = await TemplateProjectBuilder.BuildAsync( projectArgs ); ExtractProjectZip(result, projectArgs.OutputFolder); Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'"); OpenRelatedWebPage(projectArgs, template, isTiered, commandLineArgs); }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var projectName = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); if (string.IsNullOrWhiteSpace(projectName)) { throw new CliUsageException("Project name is missing!" + Environment.NewLine + Environment.NewLine + GetUsageInfo()); } ProjectNameValidator.Validate(projectName); Logger.LogInformation("Creating your project..."); Logger.LogInformation("Project name: " + projectName); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long); if (template != null) { Logger.LogInformation("Template: " + template); } else { template = (await TemplateInfoProvider.GetDefaultAsync()).Name; } var isTiered = commandLineArgs.Options.ContainsKey(Options.Tiered.Long); if (isTiered) { Logger.LogInformation("Tiered: yes"); } var projectArgs = GetProjectBuildArgs(commandLineArgs, template, projectName); var result = await TemplateProjectBuilder.BuildAsync( projectArgs ); ExtractProjectZip(result, projectArgs.OutputFolder); Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'"); ConfigureNpmPackagesForTheme(projectArgs); await RunGraphBuildForMicroserviceServiceTemplate(projectArgs); await CreateInitialMigrationsAsync(projectArgs); await RunInstallLibsForWebTemplateAsync(projectArgs); await ConfigurePwaSupportForAngular(projectArgs); OpenRelatedWebPage(projectArgs, template, isTiered, commandLineArgs); }
/// <summary> /// Creates an <see cref="XmlDocument"/> representing the provided snapshot. /// </summary> /// <param name="snapshot">The snapshot to convert to XML.</param> /// <param name="indluceNullAndEmptyValues">Indicates whether null values should be included in the export or not. Set to true to include null values.</param> /// <param name="includeNameSpaces">Determines whether the full namespace of an element will be included or not. Set to false to only include the type name but not the namespace.</param> /// <returns>The <see cref="XmlDocument"/> representation of the object.</returns> public JsonObject CreateJsonObject(IElementSnapshot snapshot, bool indluceNullAndEmptyValues, bool includeNameSpaces) { if (snapshot is null) { throw new ArgumentNullException(nameof(snapshot)); } JsonObject jsonObject = new JsonObject(); if (includeNameSpaces) { jsonObject.Add("type", JsonValue.CreateStringValue(snapshot.FullTypeName)); } else { jsonObject.Add("type", JsonValue.CreateStringValue(NamespaceHelper.GetTypeName(snapshot.FullTypeName))); } // The XML export should be somewhat usable as XAML. // Because of that, the export will strip the Windows.UI.Xaml.Controls namespace. for (int i = 0; i < snapshot.PropertyNames.Count; i++) { if (indluceNullAndEmptyValues || !(snapshot.PropertyValues[i] is null)) { var name = snapshot.PropertyNames[i]; string stringValue; if (ObjectToStringConverter is null) { stringValue = snapshot.PropertyValues[i]?.ToString() ?? "[null]"; } else { stringValue = ObjectToStringConverter.GetStringRepresentation(snapshot.PropertyValues[i]) ?? "[null]"; } if (indluceNullAndEmptyValues || !string.IsNullOrEmpty(stringValue)) { jsonObject.Add(name, JsonValue.CreateStringValue(stringValue)); } } } var jsonArray = new JsonArray(); for (int i = 0; i < snapshot.Children.Count; i++) { jsonArray.Add(CreateJsonObject(snapshot.Children[i], indluceNullAndEmptyValues, includeNameSpaces)); } jsonObject.Add("children", jsonArray); return(jsonObject); }
protected virtual string GenerateBaseNodeFromConfigurationType(Type type, string namespaceValue) { string result = null; Type baseConfgiurationType = type.BaseType != null ? type.BaseType : type; if (baseConfgiurationType.Name.EndsWith(configurationTypeSuffix)) { result = NamespaceHelper.GenerateTypeName(namespaceValue, baseConfgiurationType.Name.Replace(configurationTypeSuffix, nodeTypeSuffix)); } else { result = NamespaceHelper.GenerateTypeName(namespaceValue, string.Concat(baseConfgiurationType.Name, nodeTypeSuffix)); } return(result); }
public ServiceContractGenerator(CodeCompileUnit targetCompileUnit, Configuration targetConfig) { this.compileUnit = targetCompileUnit ?? new CodeCompileUnit(); this.namespaceManager = new NamespaceHelper(this.compileUnit.Namespaces); AddReferencedAssembly(typeof(ServiceContractGenerator).Assembly); this.configuration = targetConfig; if (targetConfig != null) { this.configWriter = new ConfigWriter(targetConfig); } this.generatedTypes = new Dictionary <ContractDescription, ServiceContractGenerationContext>(); this.generatedOperations = new Dictionary <OperationDescription, OperationContractGenerationContext>(); this.referencedTypes = new Dictionary <ContractDescription, Type>(); }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { var operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) || commandLineArgs.Options.ContainsKey(Options.Preview.Long); var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); switch (operationType) { case "": case null: await InstallSuiteIfNotInstalledAsync(); RunSuite(); break; case "generate": await InstallSuiteIfNotInstalledAsync(); var suiteProcess = StartSuite(); System.Threading.Thread.Sleep(500); //wait for initialization of the app await GenerateCrudPageAsync(commandLineArgs); if (suiteProcess != null) { KillSuite(); } break; case "install": await InstallSuiteAsync(version, preview); break; case "update": await UpdateSuiteAsync(version, preview); break; case "remove": Logger.LogInformation("Removing ABP Suite..."); RemoveSuite(); break; } }
private bool GetNewValue(out object newValue) { IDictionaryService dictionaryService = (IDictionaryService)GetService <IDictionaryService>(); Type customConfigurationType = dictionaryService.GetValue(customConfigurationTypeAttribute) as Type; if (customConfigurationType != null) { string newTypeName = NamespaceHelper.GenerateFullTypeName(customConfigurationType.Namespace, string.Concat(customConfigurationTypePrefix, customConfigurationType.Name)); DTE vs = GetService <DTE>(); newValue = TypeHelper.GetType(vs, newTypeName); return(true); } newValue = null; return(false); }
public ServiceContractGenerator(CodeCompileUnit targetCompileUnit, System.Configuration.Configuration targetConfig) { this.options = new OptionsHelper(ServiceContractGenerationOptions.ClientClass | ServiceContractGenerationOptions.ChannelInterface); this.errors = new Collection <MetadataConversionError>(); this.compileUnit = targetCompileUnit ?? new CodeCompileUnit(); this.namespaceManager = new NamespaceHelper(this.compileUnit.Namespaces); this.AddReferencedAssembly(typeof(ServiceContractGenerator).Assembly); this.configuration = targetConfig; if (targetConfig != null) { this.configWriter = new ConfigWriter(targetConfig); } this.generatedTypes = new Dictionary <ContractDescription, ServiceContractGenerationContext>(); this.generatedOperations = new Dictionary <OperationDescription, OperationContractGenerationContext>(); this.referencedTypes = new Dictionary <ContractDescription, System.Type>(); }
protected void AddDefaultConstructor(CodeClass codeClass) { if (null == GetDefaultConstructor(codeClass)) { CodeFunction constructor = null; if (ReferenceUtil.IsCSharpProject(CustomProvider)) { constructor = codeClass.AddFunction(string.Empty, vsCMFunction.vsCMFunctionConstructor, vsCMTypeRef.vsCMTypeRefVoid, -1, vsCMAccess.vsCMAccessPublic, null); } else if (EntlibReferences.ReferenceUtil.IsVisualBasicProject(CustomProvider)) { constructor = codeClass.AddFunction(VisualBasicConstructorKeyWord, vsCMFunction.vsCMFunctionSub, vsCMTypeRef.vsCMTypeRefVoid, 0, vsCMAccess.vsCMAccessPublic, null); } constructor.AddParameter(ConfigurationParameterName, NamespaceHelper.GenerateFullTypeName(Namespace, ConfigurationNamespacePart, ConfigurationClassname), -1); } }