示例#1
0
        private object ReadMethod(MethodResultBox mbox, object[] arguments)
        {
            string path = mbox.GetValuePath(arguments);

            path = OptionPath.Combine(_basePath, path);

            return(_ioHandler.Read(mbox.ResultBaseType, path, mbox.DefaultResult, mbox.ShouldEncrypt));
        }
示例#2
0
        private object ReadProxy(ProxyResultBox xbox, int index)
        {
            if (!xbox.IsInitialisedAt(index))
            {
                string prefix = OptionPath.Combine(index, _basePath, xbox.StoreByName);

                xbox.InitialiseAt(index, _ioHandler, prefix);
            }

            return(xbox.GetInstanceAt(index));
        }
示例#3
0
        private object ReadCollection(CollectionResultBox cbox, int index)
        {
            string lengthPath = OptionPath.Combine(index, _basePath, cbox.StoreByName);

            lengthPath = OptionPath.AddLength(lengthPath);

            if (!cbox.IsInitialised)
            {
                int length = (int)_ioHandler.Read(typeof(int), lengthPath, 0, cbox.ShouldEncrypt);

                cbox.Initialise(_basePath, length, this);
            }

            return(cbox.CollectionInstance);
        }
示例#4
0
        public static bool IsArrayLength(string key, Func <string, string> getValue, out int length)
        {
            if (!OptionPath.TryStripLength(key, out key))
            {
                length = 0;
                return(false);
            }

            string value = getValue(key);

            if (value == null)
            {
                length = 0;
                return(false);
            }

            if (!StringArrayParser.TryParse(value, out string[] ar))
示例#5
0
        public void Intercept(IInvocation invocation)
        {
            if (PropertyResultBox.IsProperty(invocation.Method, out bool isGetProperty, out string propertyName))
            {
                ResultBox rbox = _boxes[propertyName];

                if (rbox is ProxyResultBox proxy)
                {
                    if (!proxy.IsInitialised)
                    {
                        proxy.Initialise(_ioHandler, OptionPath.Combine(_prefix, proxy.StoreByName));
                    }

                    if (!isGetProperty)
                    {
                        throw new NotSupportedException("cannot assign values to interface properties");
                    }

                    //return a proxy interface
                    invocation.ReturnValue = proxy.ProxyInstance;
                }
                else
                {
                    PropertyResultBox pbox = (PropertyResultBox)rbox;
                    string            path = OptionPath.Combine(_prefix, pbox.StoreByName);

                    if (isGetProperty)
                    {
                        invocation.ReturnValue = _ioHandler.Read(pbox.ResultBaseType, path, pbox.DefaultResult);
                    }
                    else
                    {
                        _ioHandler.Write(pbox.ResultBaseType, path, invocation.Arguments[0]);
                    }
                }
            }
示例#6
0
        private object ReadProperty(PropertyResultBox pbox, int index)
        {
            string path = OptionPath.Combine(index, _basePath, pbox.StoreByName);

            return(_ioHandler.Read(pbox.ResultBaseType, path, pbox.DefaultResult, pbox.ShouldEncrypt));
        }
示例#7
0
        private void WriteProperty(PropertyResultBox pbox, object[] arguments)
        {
            string path = OptionPath.Combine(_basePath, pbox.StoreByName);

            _ioHandler.Write(pbox.ResultBaseType, path, arguments[0]);
        }