本文整理汇总了C#中IHttpRequest.IsUpdateAllowed方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpRequest.IsUpdateAllowed方法的具体用法?C# IHttpRequest.IsUpdateAllowed怎么用?C# IHttpRequest.IsUpdateAllowed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpRequest
的用法示例。
在下文中一共展示了IHttpRequest.IsUpdateAllowed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRequest
//.........这里部分代码省略.........
else
_SetSecurityError(out status, out message);
break;
}
}
}
break;
case "PUT":
case "PATCH":
Logger.Trace("Handling Put request");
if (_Loads.ContainsKey(request.URL.Host + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))))
{
if (request.IsLoadAllowed(_Loads[request.URL.Host + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))].DeclaringType, Uri.UnescapeDataString(request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf("/") + 1)), out status, out message))
{
message = null;
ret = _Loads[request.URL.Host + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))].Invoke(null, new object[] { Uri.UnescapeDataString(request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf("/") + 1)) });
}
else
_SetSecurityError(out status, out message);
}
else if (_Loads.ContainsKey("*" + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))))
{
if (request.IsLoadAllowed(_Loads["*" + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))].DeclaringType, Uri.UnescapeDataString(request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf("/") + 1)), out status, out message))
{
message = null;
ret = _Loads["*" + request.URL.AbsolutePath.Substring(0, request.URL.AbsolutePath.LastIndexOf("/"))].Invoke(null, new object[] { Uri.UnescapeDataString(request.URL.AbsolutePath.Substring(request.URL.AbsolutePath.LastIndexOf("/") + 1)) });
}
else
_SetSecurityError(out status, out message);
}
if (ret != null)
{
Hashtable ht = (Hashtable)JSON.JsonDecode(request.ParameterContent);
if (request.IsUpdateAllowed((IModel)ret, ht, out status, out message))
{
message = null;
Hashtable IModelTypes = new Hashtable();
foreach (string str in ht.Keys)
{
if (str != "id")
{
if (ret.GetType().GetProperty(str).GetCustomAttributes(typeof(ReadOnlyModelProperty), true).Length == 0)
{
Type propType = ret.GetType().GetProperty(str).PropertyType;
if (propType.IsArray)
propType = propType.GetElementType();
else if (propType.IsGenericType)
{
if (propType.GetGenericTypeDefinition() == typeof(List<>))
propType = propType.GetGenericArguments()[0];
}
var obj = _ConvertObjectToType(ht[str], ret.GetType().GetProperty(str).PropertyType);
if (new List<Type>(propType.GetInterfaces()).Contains(typeof(IModel)))
IModelTypes.Add(str, obj);
ret.GetType().GetProperty(str).SetValue(ret, obj, new object[0]);
}
}
}
if (_UpdateMethods.ContainsKey(ret.GetType()))
ret = _UpdateMethods[ret.GetType()].Invoke(ret, new object[0]);
else
ret = false;
if ((bool)ret && IModelTypes.Count > 0)
ret = IModelTypes;
else if (!(bool)ret)
ret = null;