Ejemplo n.º 1
0
        public object Get(string Property)
        {
            Exception = null;

            CacheItemProperty pi = _ct.Property(Property);

            object res = null;

            if (_ct.Exception == null)
            {
                res = pi.Get(Handle, null);
                if (pi.Exception == null)
                {
                    if (res.GetType().IsArray)
                    {
                        object[,] p = null;
                        ParameterCleaner.Build2DOutput(string.Empty, res, out p);
                        res = p;
                    }
                }
                else
                {
                    Exception = pi.Exception;
                }
            }
            else
            {
                Exception = _ct.Exception;
            }

            return(res);
        }
Ejemplo n.º 2
0
        public object Get()
        {
            Exception = null;

            List <object[, ]> r = new List <object[, ]>();

            int x = 0, y = 0;

            foreach (CacheItemProperty k in _ct.Property())
            {
                object t = k.Get(Handle, null);
                if (k.Exception != null)
                {
                    Exception = k.Exception;
                    break;
                }
                else
                {
                    object[,] p = null;
                    ParameterCleaner.Build2DOutput(k.ExcelName, t, out p);
                    r.Add(p);

                    x += p.GetLength(0);
                    y  = Math.Max(y, p.GetLength(1));
                }
            }

            object[,] res = new object[x, y];
            for (int i = 0, z = 0; i < r.Count; i++)
            {
                for (int j = 0; j < r[i].GetLength(0); j++)
                {
                    for (int k = 0; k < r[i].GetLength(1); k++)
                    {
                        res[z + j, k] = r[i][j, k];
                    }

                    for (int k = r[i].GetLength(1); k < y; k++)
                    {
                        res[z + j, k] = string.Empty;
                    }
                }

                z += r[i].GetLength(0);
            }

            return(res);
        }
Ejemplo n.º 3
0
        public static object SetProperty(
            [ExcelArgument(Name = "ObjectHandle", Description = "Handle to an object.")] string h,
            [ExcelArgument(Name = "Property", Description = "Name of property to which data will be assigned.")] string p,
            [ExcelArgument(Name = "PropertyData", Description = "Data to be assiged.")] object o)
        {
            object res = ExcelError.ExcelErrorNA;

            if (_cache.ContainsKey(h))
            {
                ICacheItem handle = _cache.Lookup(h) as CacheItem;

                CacheItemProperty cip = handle.CacheType.Property(p);
                if (handle.CacheType.Exception == null)
                {
                    Exception e = null;
                    o = ParameterCleaner.Arg(o, cip.Type, out e);

                    if (e == null)
                    {
                        handle.Set(p, o);
                        if (handle.Exception != null)
                        {
                            res = handle.Exception.Message;
                        }
                        else
                        {
                            res = string.Format("SET {0}", p);
                        }
                    }
                    else
                    {
                        res = e.Message;
                    }
                }
                else
                {
                    res = handle.CacheType.Exception.Message;
                }
            }

            return(res);
        }
Ejemplo n.º 4
0
        public static object CallMethod(
            [ExcelArgument(Name = "ObjectHandle", Description = "Handle to an object.")] string h,
            [ExcelArgument(Name = "Method", Description = "Name of the method that will be called.")] string m,
            [ExcelArgument(Name = "[Args1]", Description = "Parameter to be passed to the specified function.")] 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 res = ExcelError.ExcelErrorNA;

            if (_cache.ContainsKey(h))
            {
                object    or     = null;
                CacheItem handle = _cache.Lookup(h) as CacheItem;

                CacheItemMethod cim = handle.CacheType.Method(m);
                Exception       e   = handle.CacheType.Exception;

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

                    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);
                    }

                    or = handle.Call(m, input);
                    e  = handle.Exception;

                    if (e != null)
                    {
                        string inner = (e.InnerException == null) ? string.Empty : e.InnerException.Message;
                        res = string.Format("{0} {1}", e.Message, inner);
                    }
                    else
                    {
                        res = or;
                    }
                }
                else
                {
                    res = e.Message;
                }
            }

            return(res);
        }
Ejemplo n.º 5
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);
        }