Пример #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]);
        }