Пример #1
0
        public void _method_ctor(params Instance[] types)
        {
            var parts = new List <Instance>();

            Parts.Set(parts);

            //offer components available in place of calling - they can be added to ctor
            TypeAssembly callerAssembly = GetCallerAssembly();

            Edits.AppendArgument(This, types.Length + 1, "Add component type", (v) => addComponentTypeProvider(callerAssembly, v));

            //keeping in closure
            var edits    = Edits;
            var thisInst = This;

            //collect names of types
            for (var i = 0; i < types.Length; ++i)
            {
                //because of keeping values in closure
                var index = i;
                var type  = types[index];

                AsyncCall <string>(type, "get_FullName", (fullname) =>
                {
                    var info = TypeDescriptor.Create(fullname);
                    var part = Context.Machine.CreateInstance(info);

                    edits.SetOptional(index + 1);
                    edits.AttachRemoveArgument(thisInst, part, index + 1, "Remove component type");

                    parts.Add(part);
                });
            }
        }
 /// <summary>
 /// Fills the list with components from given assembly.
 /// </summary>
 /// <param name="result">The result list.</param>
 /// <param name="assembly">The assembly with components</param>
 private void fillWithComponents(List <Instance> result, TypeAssembly assembly)
 {
     foreach (var componentInfo in assembly.GetComponents())
     {
         var component = Context.Machine.CreateInstance(componentInfo.ComponentType);
         result.Add(component);
     }
 }
Пример #3
0
        /// <summary>
        /// Create <see cref="Instance" /> representation of given <see cref="TypeAssembly" />.
        /// </summary>
        /// <param name="assembly">assembly to be represented.</param>
        /// <returns>Created <see cref="Instance" />.</returns>
        private Instance constructAssemblyRepresentation(TypeAssembly assembly)
        {
            var resultAssembly = Context.Machine.CreateInstance(TypeInfo);

            RunInContextOf(resultAssembly, () =>
            {
                AssemblyFullPath.Value = assembly.FullPathMapping;
            });
            return(resultAssembly);
        }
Пример #4
0
        /// <summary>
        /// Gets components defined in given assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <returns>IEnumerable&lt;ComponentInfo&gt;.</returns>
        private IEnumerable <ComponentInfo> getComponents(TypeAssembly assembly)
        {
            var result = new List <ComponentInfo>(assembly.GetReferencedComponents());

            //runtime is implicitly referenced from every assembly
            var runtimeComponents = Services.GetComponents(ContainingAssembly);

            result.AddRange(runtimeComponents);

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Dialog for adding component type.
        /// </summary>
        /// <param name="callerAssembly">The caller assembly.</param>
        /// <param name="v">View where component type will be added.</param>
        /// <returns>System.Object.</returns>
        private object addComponentTypeProvider(TypeAssembly callerAssembly, ExecutionView v)
        {
            var components = getComponents(callerAssembly);
            var dialog     = new ComponentType(components);

            if (dialog.ShowDialog() == true)
            {
                return(dialog.SelectedComponent);
            }
            else
            {
                v.Abort("No component has been selected");
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// Register given assembly if needed into storage.
        /// </summary>
        /// <param name="assembly">Registered assembly.</param>
        private void registerAssembly(AssemblyProvider assembly)
        {
            //assembly could be already registered
            if (!_assemblies.ContainsKey(assembly))
            {
                _assemblyPathIndex[assembly.FullPath] = assembly;
                _assemblyKeyIndex[assembly.Key]       = assembly;

                var typeAssembly = new TypeAssembly(_manager, assembly);
                _assemblies.Add(assembly, typeAssembly);

                if (OnRegistered != null)
                {
                    OnRegistered(assembly);
                }
            }
        }