Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / ui / RoleServiceManager.cs / 1 / RoleServiceManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Security.Permissions; using System.Text; using System.Web.Script.Serialization; using System.Web; using System.Web.ApplicationServices; using System.Web.Resources; using System.Web.Security; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Path"), TypeConverter(typeof(EmptyStringExpandableObjectConverter)) ] public class RoleServiceManager { private bool _loadRoles; private string _path; internal static void ConfigureRoleService(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, Listproxies) { string roleServiceUrl = null; bool loadRoles = false; RoleServiceManager roleManager; if(scriptManager.HasRoleServiceManager) { roleManager = scriptManager.RoleService; // load roles? loadRoles = roleManager.LoadRoles; // get ScriptManager.Path roleServiceUrl = roleManager.Path.Trim(); if(roleServiceUrl.Length > 0) { roleServiceUrl = scriptManager.ResolveClientUrl(roleServiceUrl); } } // combine proxy ServiceUrls (find the first one that has specified one) if(proxies != null) { foreach(ScriptManagerProxy proxy in proxies) { if(proxy.HasRoleServiceManager) { roleManager = proxy.RoleService; // combine load roles if (roleManager.LoadRoles) { loadRoles = true; } // combine urls roleServiceUrl = ApplicationServiceManager.MergeServiceUrls(roleManager.Path, roleServiceUrl, proxy); } } } RoleServiceManager.GenerateInitializationScript(ref sb, context, scriptManager, roleServiceUrl, loadRoles); } private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl, bool loadRoles) { bool enabled = ApplicationServiceHelper.RoleServiceEnabled; string defaultServicePath = null; if (enabled) { if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } // The default path points to the built-in service (if it is enabled) // Note that the client can't default to this path because it doesn't know what the app root is, we must tell it. // We must specify the default path to the proxy even if a custom path is provided, because on the client they could // reset the path back to the default if they want. defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName); sb.Append("Sys.Services._RoleService.DefaultWebServicePath = '"); sb.Append(JavaScriptString.QuoteString(defaultServicePath)); sb.Append("';\n"); } bool pathSpecified = !String.IsNullOrEmpty(serviceUrl); if (pathSpecified) { // DevDiv Bug 71954:When loadRoles="true" and the path is set, we should not load the roles from the default path // loadRoles script always retrieves the roles from default role provider, which is not correct if RolesService // points to non default path. Hence throw when non default path and loadRoles both are specified. if (defaultServicePath == null){ defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName); } if (loadRoles && !String.Equals(serviceUrl, defaultServicePath, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException(AtlasWeb.RoleServiceManager_LoadRolesWithNonDefaultPath); } if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } sb.Append("Sys.Services.RoleService.set_path('"); sb.Append(JavaScriptString.QuoteString(serviceUrl)); sb.Append("');\n"); } if(loadRoles) { string[] roles = Roles.GetRolesForUser(); if(roles != null && roles.Length > 0) { if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } sb.Append("Sys.Services.RoleService._roles = Sys.Serialization.JavaScriptSerializer.deserialize('"); sb.Append(JavaScriptString.QuoteString(JavaScriptSerializer.SerializeInternal(roles))); sb.Append("');\n"); } } } [ DefaultValue(false), Category("Behavior"), NotifyParentProperty(true), ResourceDescription("RoleServiceManager_LoadRoles") ] public bool LoadRoles { get { return _loadRoles; } set { _loadRoles = value; } } [ DefaultValue(""), Category("Behavior"), NotifyParentProperty(true), ResourceDescription("ApplicationServiceManager_Path"), UrlProperty() ] public string Path { get { return _path ?? String.Empty; } set { _path = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Security.Permissions; using System.Text; using System.Web.Script.Serialization; using System.Web; using System.Web.ApplicationServices; using System.Web.Resources; using System.Web.Security; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Path"), TypeConverter(typeof(EmptyStringExpandableObjectConverter)) ] public class RoleServiceManager { private bool _loadRoles; private string _path; internal static void ConfigureRoleService(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, Listproxies) { string roleServiceUrl = null; bool loadRoles = false; RoleServiceManager roleManager; if(scriptManager.HasRoleServiceManager) { roleManager = scriptManager.RoleService; // load roles? loadRoles = roleManager.LoadRoles; // get ScriptManager.Path roleServiceUrl = roleManager.Path.Trim(); if(roleServiceUrl.Length > 0) { roleServiceUrl = scriptManager.ResolveClientUrl(roleServiceUrl); } } // combine proxy ServiceUrls (find the first one that has specified one) if(proxies != null) { foreach(ScriptManagerProxy proxy in proxies) { if(proxy.HasRoleServiceManager) { roleManager = proxy.RoleService; // combine load roles if (roleManager.LoadRoles) { loadRoles = true; } // combine urls roleServiceUrl = ApplicationServiceManager.MergeServiceUrls(roleManager.Path, roleServiceUrl, proxy); } } } RoleServiceManager.GenerateInitializationScript(ref sb, context, scriptManager, roleServiceUrl, loadRoles); } private static void GenerateInitializationScript(ref StringBuilder sb, HttpContext context, ScriptManager scriptManager, string serviceUrl, bool loadRoles) { bool enabled = ApplicationServiceHelper.RoleServiceEnabled; string defaultServicePath = null; if (enabled) { if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } // The default path points to the built-in service (if it is enabled) // Note that the client can't default to this path because it doesn't know what the app root is, we must tell it. // We must specify the default path to the proxy even if a custom path is provided, because on the client they could // reset the path back to the default if they want. defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName); sb.Append("Sys.Services._RoleService.DefaultWebServicePath = '"); sb.Append(JavaScriptString.QuoteString(defaultServicePath)); sb.Append("';\n"); } bool pathSpecified = !String.IsNullOrEmpty(serviceUrl); if (pathSpecified) { // DevDiv Bug 71954:When loadRoles="true" and the path is set, we should not load the roles from the default path // loadRoles script always retrieves the roles from default role provider, which is not correct if RolesService // points to non default path. Hence throw when non default path and loadRoles both are specified. if (defaultServicePath == null){ defaultServicePath = scriptManager.ResolveClientUrl("~/" + System.Web.Script.Services.WebServiceData._roleServiceFileName); } if (loadRoles && !String.Equals(serviceUrl, defaultServicePath, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException(AtlasWeb.RoleServiceManager_LoadRolesWithNonDefaultPath); } if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } sb.Append("Sys.Services.RoleService.set_path('"); sb.Append(JavaScriptString.QuoteString(serviceUrl)); sb.Append("');\n"); } if(loadRoles) { string[] roles = Roles.GetRolesForUser(); if(roles != null && roles.Length > 0) { if (sb == null) { sb = new StringBuilder(ApplicationServiceManager.StringBuilderCapacity); } sb.Append("Sys.Services.RoleService._roles = Sys.Serialization.JavaScriptSerializer.deserialize('"); sb.Append(JavaScriptString.QuoteString(JavaScriptSerializer.SerializeInternal(roles))); sb.Append("');\n"); } } } [ DefaultValue(false), Category("Behavior"), NotifyParentProperty(true), ResourceDescription("RoleServiceManager_LoadRoles") ] public bool LoadRoles { get { return _loadRoles; } set { _loadRoles = value; } } [ DefaultValue(""), Category("Behavior"), NotifyParentProperty(true), ResourceDescription("ApplicationServiceManager_Path"), UrlProperty() ] public string Path { get { return _path ?? String.Empty; } set { _path = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QilInvokeEarlyBound.cs
- PropertySourceInfo.cs
- IPAddress.cs
- ColorContextHelper.cs
- CryptographicAttribute.cs
- TraceFilter.cs
- ScanQueryOperator.cs
- DataGridViewCheckBoxColumn.cs
- OdbcRowUpdatingEvent.cs
- TextServicesPropertyRanges.cs
- ExtensionFile.cs
- CustomAssemblyResolver.cs
- SimpleType.cs
- BufferedStream2.cs
- TablePatternIdentifiers.cs
- WindowsFormsEditorServiceHelper.cs
- DictionaryManager.cs
- TripleDESCryptoServiceProvider.cs
- ImmutableCollection.cs
- HandleCollector.cs
- RowParagraph.cs
- RuleRef.cs
- Stylus.cs
- TriggerBase.cs
- InputEventArgs.cs
- FontEmbeddingManager.cs
- XmlArrayItemAttribute.cs
- Delay.cs
- SessionState.cs
- CategoryList.cs
- SchemaExporter.cs
- TypedTableBase.cs
- UniqueIdentifierService.cs
- InsufficientMemoryException.cs
- RoutedPropertyChangedEventArgs.cs
- Operand.cs
- DefaultTraceListener.cs
- ProxyAttribute.cs
- CachedPathData.cs
- MatrixKeyFrameCollection.cs
- WebRequestModuleElementCollection.cs
- SqlVisitor.cs
- ArrangedElement.cs
- TabRenderer.cs
- SettingsPropertyIsReadOnlyException.cs
- CrossSiteScriptingValidation.cs
- ISAPIRuntime.cs
- Component.cs
- AssociationType.cs
- ValueConversionAttribute.cs
- SendingRequestEventArgs.cs
- NamedPipeChannelListener.cs
- InlineUIContainer.cs
- XslException.cs
- TogglePattern.cs
- DesignerObjectListAdapter.cs
- BasicBrowserDialog.designer.cs
- Subordinate.cs
- TransformCryptoHandle.cs
- CodeStatementCollection.cs
- PermissionAttributes.cs
- KeyNotFoundException.cs
- XmlNamespaceDeclarationsAttribute.cs
- listitem.cs
- ParagraphResult.cs
- EntityDataSourceMemberPath.cs
- SiteMapPath.cs
- PaintValueEventArgs.cs
- StateItem.cs
- CodeDelegateInvokeExpression.cs
- ProgressBarBrushConverter.cs
- AssemblyHelper.cs
- AmbientProperties.cs
- StaticDataManager.cs
- GrammarBuilderDictation.cs
- IBuiltInEvidence.cs
- PixelShader.cs
- LogExtent.cs
- Authorization.cs
- Application.cs
- VisualCollection.cs
- AsymmetricSignatureFormatter.cs
- TransformerInfoCollection.cs
- GridViewColumnCollectionChangedEventArgs.cs
- Debugger.cs
- Menu.cs
- SQLBinary.cs
- OneOfElement.cs
- CodeAssignStatement.cs
- ControlParameter.cs
- FieldMetadata.cs
- GroupStyle.cs
- EncodingTable.cs
- TextEditor.cs
- ContentType.cs
- GeometryHitTestResult.cs
- FormatConvertedBitmap.cs
- JoinElimination.cs
- RSAPKCS1SignatureFormatter.cs
- ControlCollection.cs