コード例 #1
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            var routedata = filterContext.RouteData;
            var ritem     = routedata.Values["id"];

            if (ritem == null)
            {
                throw new InvalidOperationException("Hiányzó Id");
            }
            routedata.Values.Remove("id"); //Lecseréljük

            var    provided      = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
            var    decoded       = StringEncoderHelper.GetDecoded((string)ritem);
            string rootinputname = string.Empty;

            if (!(decoded is IEnumerable))
            {
                rootinputname = "id";
            }
            EncryptedValueProviderFactoryBase.AddToProvidedList(provided, rootinputname, decoded);
            foreach (KeyValuePair <string, object> keyValuePair in provided)
            {
                routedata.Values.Add(keyValuePair.Key, keyValuePair.Value);
            }
        }
コード例 #2
0
        public override IValueProvider GetValueProvider(ControllerContext controllerContext)
        {
            var provided = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);

            try
            {
                //Megkeressük a hobj- karakterekkel kezdodő input elemeket
                foreach (string inputname in
                         controllerContext.HttpContext.Request.Form.Keys.Cast <string>()
                         .Where(inputname =>
                                inputname.StartsWith(SecurityHtmlExtension.SecurityHiddenFieldNamePrefix)))
                {
                    //levágjuk az input név elejéről a hobj- -et
                    string rootinputname = inputname.Substring(SecurityHtmlExtension.SecurityHiddenFieldNamePrefix.Length);
                    //Visszaalakítjuk a szöveges adatot objektummá
                    var decoded = StringEncoderHelper.GetDecoded(controllerContext.HttpContext.Request.Form[inputname]);
                    //Rekurzívan bejárva az objektumot feltöltjük a szótárat azokkal
                    //a property path-okkal, amikhez tudunk értéket szolgáltatni
                    AddToProvidedList(provided, rootinputname, decoded);
                }

                if (provided.Count == 0)
                {
                    return(null);
                }
                return(new DictionaryValueProvider <object>(provided, System.Globalization.CultureInfo.CurrentCulture));
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Hibás adat", ex);
            }
        }