예제 #1
0
        public static object ShowCtorParams(
            [ExcelArgument(Name = "ObjectType", Description = "Name of an object type.")] string Object,
            [ExcelArgument(Name = "Constructor",
                           Description = "Name of the Constructor whose parameter data will be shown.")] string p)
        {
            object res = ExcelError.ExcelErrorNA;

            if (_regObj.ContainsKey(Object))
            {
                ICacheType ctype = _regObj[Object];

                CacheItemCtor c = ctype.Constructor(p);

                if (ctype.Exception == null)
                {
                    res = c.Summary();

                    if (c.Exception != null)
                    {
                        res = c.Exception.Message;
                    }
                }
                else
                {
                    res = ctype.Exception.Message;
                }
            }

            return(res);
        }
예제 #2
0
        public static object CreateObject(
            [ExcelArgument(Name = "ObjectType", Description = "Name of an object type.")] string Object,
            [ExcelArgument(Name = "[Constructor]", Description = "Name of the constructor that will be called.")] object c,
            [ExcelArgument(Name = "[Args1]", Description = "Parameter to be passed to the constructor.")] object o1,
            #region optional args 2 - 28
            [ExcelArgument(Name = "[Args2]", Description = "Parameter to be passed to the specified function.")] object o2,
            [ExcelArgument(Name = "[Args3]", Description = "Parameter to be passed to the specified function.")] object o3,
            [ExcelArgument(Name = "[Args4]", Description = "Parameter to be passed to the specified function.")] object o4,
            [ExcelArgument(Name = "[Args5]", Description = "Parameter to be passed to the specified function.")] object o5,
            [ExcelArgument(Name = "[Args6]", Description = "Parameter to be passed to the specified function.")] object o6,
            [ExcelArgument(Name = "[Args7]", Description = "Parameter to be passed to the specified function.")] object o7,
            [ExcelArgument(Name = "[Args8]", Description = "Parameter to be passed to the specified function.")] object o8,
            [ExcelArgument(Name = "[Args9]", Description = "Parameter to be passed to the specified function.")] object o9,
            [ExcelArgument(Name = "[Args10]", Description = "Parameter to be passed to the specified function.")] object o10,
            [ExcelArgument(Name = "[Args11]", Description = "Parameter to be passed to the specified function.")] object o11,
            [ExcelArgument(Name = "[Args12]", Description = "Parameter to be passed to the specified function.")] object o12,
            [ExcelArgument(Name = "[Args13]", Description = "Parameter to be passed to the specified function.")] object o13,
            [ExcelArgument(Name = "[Args14]", Description = "Parameter to be passed to the specified function.")] object o14,
            [ExcelArgument(Name = "[Args15]", Description = "Parameter to be passed to the specified function.")] object o15,
            [ExcelArgument(Name = "[Args16]", Description = "Parameter to be passed to the specified function.")] object o16,
            [ExcelArgument(Name = "[Args17]", Description = "Parameter to be passed to the specified function.")] object o17,
            [ExcelArgument(Name = "[Args18]", Description = "Parameter to be passed to the specified function.")] object o18,
            [ExcelArgument(Name = "[Args19]", Description = "Parameter to be passed to the specified function.")] object o19,
            [ExcelArgument(Name = "[Args20]", Description = "Parameter to be passed to the specified function.")] object o20,
            [ExcelArgument(Name = "[Args21]", Description = "Parameter to be passed to the specified function.")] object o21,
            [ExcelArgument(Name = "[Args22]", Description = "Parameter to be passed to the specified function.")] object o22,
            [ExcelArgument(Name = "[Args23]", Description = "Parameter to be passed to the specified function.")] object o23,
            [ExcelArgument(Name = "[Args24]", Description = "Parameter to be passed to the specified function.")] object o24,
            [ExcelArgument(Name = "[Args25]", Description = "Parameter to be passed to the specified function.")] object o25,
            [ExcelArgument(Name = "[Args26]", Description = "Parameter to be passed to the specified function.")] object o26,
            [ExcelArgument(Name = "[Args27]", Description = "Parameter to be passed to the specified function.")] object o27,
            [ExcelArgument(Name = "[Args28]", Description = "Parameter to be passed to the specified function.")] object o28
            #endregion
            )
        {
            object newHandle = ExcelError.ExcelErrorNA;

            if (_regObj.ContainsKey(Object))
            {
                newHandle = _cache.Register(new CacheItem(_regObj[Object] as CacheType));

                Exception  e   = null;
                ICacheItem ici = _cache.Lookup(newHandle.ToString()) as CacheItem;

                if (!(c is ExcelMissing))
                {
                    CacheItemCtor ctor = _regObj[Object].Constructor(c.ToString());
                    e = _regObj[Object].Exception;

                    if (e == null)
                    {
                        Type[] parTypes = ctor.Parameters.Select(s => s.ParameterType).ToArray();

                        object[] input = null;
                        if (parTypes.GetLength(0) > 0)
                        {
                            input = ParameterCleaner.MultArgs(parTypes, out e, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10,
                                                              o11, o12, o13, o14, o15, o16, o17, o18, o19, o20, o21, o22, o23, o24, o25, o26, o27, o28);
                        }

                        ici.New(c.ToString(), input);
                        e = ici.Exception;
                    }
                }
                else
                {
                    ici.New();
                    e = ici.Exception;
                }

                if (e != null)
                {
                    _cache.Remove(newHandle.ToString());
                    newHandle = e.Message;
                }
            }

            return(newHandle);
        }