Exemplo n.º 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);
                });
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create edit that appends the argument.
 /// </summary>
 /// <param name="argIndex">Index of the argument.</param>
 /// <param name="editName">Name of the edit.</param>
 /// <param name="valueProvider">The value provider.</param>
 protected void AppendArg(int argIndex, string editName, ValueProvider valueProvider)
 {
     Edits.AppendArgument(CurrentArguments[0], argIndex, editName, valueProvider);
 }