static private CanUseQuickCache ( |
||
group | ||
리턴 | bool |
internal static void EncodeLevel(PolicyLevel level) { if (level.Path == null) { throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)Environment.GetResourceString("Policy_SaveNotFileBased"))); } SecurityElement securityElement1 = new SecurityElement("configuration"); SecurityElement child1 = new SecurityElement("mscorlib"); SecurityElement child2 = new SecurityElement("security"); SecurityElement child3 = new SecurityElement("policy"); securityElement1.AddChild(child1); child1.AddChild(child2); child2.AddChild(child3); child3.AddChild(level.ToXml()); try { StringBuilder stringBuilder = new StringBuilder(); Encoding utF8 = Encoding.UTF8; SecurityElement securityElement2 = new SecurityElement("xml"); securityElement2.m_type = SecurityElementType.Format; securityElement2.AddAttribute("version", "1.0"); securityElement2.AddAttribute("encoding", utF8.WebName); stringBuilder.Append(securityElement2.ToString()); stringBuilder.Append(securityElement1.ToString()); byte[] bytes = utF8.GetBytes(stringBuilder.ToString()); string path = level.Path; byte[] data = bytes; int length = data.Length; Exception exceptionForHr = Marshal.GetExceptionForHR(Config.SaveDataByte(path, data, length)); if (exceptionForHr != null) { string str = exceptionForHr != null ? exceptionForHr.Message : string.Empty; throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)str), exceptionForHr); } } catch (Exception ex) { if (ex is PolicyException) { throw ex; } throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", (object)level.Label, (object)ex.Message), ex); } Config.ResetCacheData(level.ConfigId); if (!PolicyManager.CanUseQuickCache(level.RootCodeGroup)) { return; } Config.SetQuickCache(level.ConfigId, PolicyManager.GenerateQuickCache(level)); }
internal static void EncodeLevel(PolicyLevel level) { if (level.Path == null) { string resourceString = Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, Environment.GetResourceString("Policy_SaveNotFileBased") }); throw new PolicyException(resourceString); } SecurityElement securityElement = new SecurityElement("configuration"); SecurityElement securityElement2 = new SecurityElement("mscorlib"); SecurityElement securityElement3 = new SecurityElement("security"); SecurityElement securityElement4 = new SecurityElement("policy"); securityElement.AddChild(securityElement2); securityElement2.AddChild(securityElement3); securityElement3.AddChild(securityElement4); securityElement4.AddChild(level.ToXml()); try { StringBuilder stringBuilder = new StringBuilder(); Encoding utf = Encoding.UTF8; SecurityElement securityElement5 = new SecurityElement("xml"); securityElement5.m_type = SecurityElementType.Format; securityElement5.AddAttribute("version", "1.0"); securityElement5.AddAttribute("encoding", utf.WebName); stringBuilder.Append(securityElement5.ToString()); stringBuilder.Append(securityElement.ToString()); byte[] bytes = utf.GetBytes(stringBuilder.ToString()); int errorCode = Config.SaveDataByte(level.Path, bytes, bytes.Length); Exception exceptionForHR = Marshal.GetExceptionForHR(errorCode); if (exceptionForHR != null) { string text = (exceptionForHR != null) ? exceptionForHR.Message : string.Empty; throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, text }), exceptionForHR); } } catch (Exception ex) { if (ex is PolicyException) { throw ex; } throw new PolicyException(Environment.GetResourceString("Policy_UnableToSave", new object[] { level.Label, ex.Message }), ex); } Config.ResetCacheData(level.ConfigId); if (PolicyManager.CanUseQuickCache(level.RootCodeGroup)) { Config.SetQuickCache(level.ConfigId, PolicyManager.GenerateQuickCache(level)); } }