public void Configure(IModuleDefinition module, AttributeSet attributes) { if (ReferenceEquals(module, null)) { return; } var validationErrros = _attributeMatrix.Validate <IModuleDefinition>(attributes); if (validationErrros != null) { var message = "There are invalid attributes on module of type " + module.GetType().DisplayName(); if (attributes.IsModule != null && string.IsNullOrEmpty(attributes.IsModule.Name)) { message += " called '" + attributes.IsModule.Name + "'."; } foreach (var error in validationErrros) { message += Environment.NewLine + error; } throw new ModuleBuilderException(message); } if (!ReferenceEquals(attributes.IsModule, null)) { module .Name(attributes.IsModule.Name) .AssetDeployment(attributes.IsModule.AssetDeployment); } }
/// <summary> /// Initialize using the definition, instance, and settings. /// </summary> /// <param name="def"></param> /// <param name="instance"></param> /// <param name="settings"></param> public Module(string id, IModuleDefinition def, IModuleInstance instance, IModuleSettings settings) { Definition = def; Instance = instance; Settings = settings; Id = id; }
public PairType() { var pairTypeNumber = InterfaceType.CreateAndBuild( new List <IMemberDefinition> { MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), false), MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), false) }); var inputKey = new NameKey("input"); var input = MemberDefinition.CreateAndBuild(inputKey, new NumberType(), false); var methodScope = Scope.CreateAndBuild(new List <Scope.IsStatic> { new Scope.IsStatic(input, false) }); var localX = MemberDefinition.CreateAndBuild(new NameKey("x"), new NumberType(), false); var localY = MemberDefinition.CreateAndBuild(new NameKey("y"), new NumberType(), false); var pairifyKey = new NameKey("pairify"); var pairify = MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), false); Module = ModuleDefinition.CreateAndBuild( Scope.CreateAndBuild( new List <Scope.IsStatic> { new Scope.IsStatic(MemberDefinition.CreateAndBuild(pairifyKey, MethodType.CreateAndBuild(new NumberType(), pairTypeNumber), false), false) }), new ICodeElement[] { AssignOperation.CreateAndBuild( MethodDefinition.CreateAndBuild( new NumberType(), pairTypeNumber, input, methodScope, new ICodeElement[] { ReturnOperation.CreateAndBuild( ObjectDefiniton.CreateAndBuild( Scope.CreateAndBuild( new List <Scope.IsStatic> { new Scope.IsStatic(localX, false), new Scope.IsStatic(localY, false) }), new IAssignOperation[] { AssignOperation.CreateAndBuild( MemberReference.CreateAndBuild(input), MemberReference.CreateAndBuild(localX)), AssignOperation.CreateAndBuild( MemberReference.CreateAndBuild(input), MemberReference.CreateAndBuild(localY)) })) }, new ICodeElement[0], false), MemberReference.CreateAndBuild(pairify)) }, new NameKey("pair-type")); }
private void LoadInheritedTypes() { Task.Factory.StartNew(() => { var searchAssemblies = new Dictionary <IAssemblyDefinitionTreeViewItem, List <string> >(); int typesCount = 0; foreach (IAssemblyDefinitionTreeViewItem assemblyDefinitionTreeViewItem in this.treeViewItems.OfType <IAssemblyDefinitionTreeViewItem>()) { IModuleDefinition moduleDefinition = assemblyDefinitionTreeViewItem.AssemblyDefinition.MainModule; if (moduleDefinition.AssemblyReferences.Any(a => a.FullName == selectedTypeDefinition.Module.Assembly.FullName) || moduleDefinition.FilePath == selectedTypeDefinition.Module.FilePath) { foreach (ITypeDefinition typeDefinition in moduleDefinition.Types) { if (HasMatchingType(typeDefinition)) { typesCount++; if (searchAssemblies.ContainsKey(assemblyDefinitionTreeViewItem)) { searchAssemblies[assemblyDefinitionTreeViewItem].Add(typeDefinition.Namespace); } else { searchAssemblies.Add(assemblyDefinitionTreeViewItem, new List <string> { typeDefinition.Namespace }); } } } } } var treeViewItemsBag = new TreeViewItemsBag(OnItemsLoaded, typesCount); if (typesCount == 0) { treeViewItemsBag.Completed(); } foreach (KeyValuePair <IAssemblyDefinitionTreeViewItem, List <string> > item in searchAssemblies) { IList <string> namespaces = item.Value; item.Key.Expand(t => OnItemsLoaded(namespaces, t, treeViewItemsBag)); } }); progressWindow = new ProgressWindow(); progressWindow.ShowDialog(); }
public IInterpetedOperation <IInterpetedAnyType> ModuleDefinition(IModuleDefinition codeElement) { if (backing.TryGetValue(codeElement, out var res)) { return(res); } else { var op = new InterpetedModuleDefinition(); backing.Add(codeElement, op); op.Init(new InterpetedScopeTemplate(codeElement.Scope, codeElement.Scope.ToVerifiableType()), codeElement.StaticInitialization.Select(x => x.Convert(this)).ToArray() ); return(op); } }
public Project(IModuleDefinition moduleDefinition, IReadOnlyList <IAssembly <TBacking> > references) { ModuleDefinition = moduleDefinition ?? throw new ArgumentNullException(nameof(moduleDefinition)); References = references ?? throw new ArgumentNullException(nameof(references)); }