static internal string[] GetParts(string configPath) { Debug.Assert(IsValid(configPath), "IsValid(configPath)"); string[] parts = configPath.Split(SeparatorChar); return(parts); }
private bool CheckFilesStillValidInternal(string key, ICollection virtualPaths) { Debug.Trace("TimeStampChecker", "CheckFilesStillValidInternal (" + key + ")"); foreach (string virtualPath in virtualPaths) { if (!_timeStamps.Contains(virtualPath)) { continue; } string path = HostingEnvironment.MapPath(virtualPath); DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(path); DateTime storedValue = (DateTime)_timeStamps[virtualPath]; // If it changed, then it's not valid if (lastWriteTimeUtc != storedValue) { Debug.Trace("TimeStampChecker", "CheckFilesStillValidInternal: File (" + path + ") has changed!"); return(false); } } Debug.Trace("TimeStampChecker", "CheckFilesStillValidInternal (" + key + ") is still valid"); return(true); }
private List <HttpApplication.IExecutionStep> GetStepArray(RequestNotification notification, bool isPostEvent) { #if DBG Debug.Trace("PipelineRuntime", "GetStepArray for " + DebugModuleName + " for " + notification.ToString() + " and " + isPostEvent + "\r\n"); #endif List <HttpApplication.IExecutionStep>[] steps = _moduleSteps; if (isPostEvent) { steps = _modulePostSteps; } Debug.Assert(null != steps, "null != steps"); int index = EventToIndex(notification); Debug.Assert(index != -1, "index != -1"); Debug.Trace("PipelineRuntime", "GetStepArray: " + notification.ToString() + " mapped to index " + index.ToString(CultureInfo.InvariantCulture) + "\r\n"); List <HttpApplication.IExecutionStep> stepArray = steps[index]; // we shouldn't be asking for events that aren't mapped to this // module at all Debug.Assert(null != stepArray, "null != stepArray"); return(stepArray); }
private void AddFileInternal(string virtualPath, string path) { DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(path); if (_timeStamps.Contains(virtualPath)) { DateTime storedValue = (DateTime)_timeStamps[virtualPath]; // Already found to have changed before if (storedValue == DateTime.MaxValue) { Debug.Trace("TimeStampChecker", "AddFileInternal: Same time stamp (" + path + ")"); return; } // If it's different, set it to MaxValue as marker of being invalid if (storedValue != lastWriteTimeUtc) { _timeStamps[virtualPath] = DateTime.MaxValue; Debug.Trace("TimeStampChecker", "AddFileInternal: Changed time stamp (" + path + ")"); } } else { // New path: just add it _timeStamps[virtualPath] = lastWriteTimeUtc; Debug.Trace("TimeStampChecker", "AddFileInternal: New path (" + path + ")"); } }
// Convert an event code into a (x,y) coordinate. internal static void GetEventArrayIndexsFromEventCode(int eventCode, out int index0, out int index1) { index0 = eventCode / 1000 - 1; index1 = eventCode - (eventCode / 1000) * 1000 - 1; Debug.Assert(index0 >= 0 && index0 < GetEventArrayDimensionSize(0), "Index0 of system eventCode out of expected range: " + eventCode); Debug.Assert(index1 >= 0 && index1 < GetEventArrayDimensionSize(1), "Index1 of system eventCode out of expected range: " + eventCode); }
internal HttpApplication.IExecutionStep GetNextEvent(RequestNotification notification, bool isPostEvent, int eventIndex) { List <HttpApplication.IExecutionStep> stepArray = GetStepArray(notification, isPostEvent); Debug.Assert(eventIndex >= 0, "eventIndex >= 0"); Debug.Assert(eventIndex < stepArray.Count, "eventIndex < stepArray.Count"); return(stepArray[eventIndex]); }
public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string path) { Debug.Trace("PageHandlerFactory", "PageHandlerFactory: " + url); // We need to assert here since there may be user code on the stack, // and code may demand UnmanagedCode permission InternalSecurityPermissions.UnmanagedCode.Assert(); return(PageParser.GetCompiledPageInstanceInternal(url, path, context)); }
internal void CreateResourceFile(string resFileName) { using (Stream strm = new FileStream(resFileName, FileMode.Create)) { Encoding encoding = Encoding.UTF8; BinaryWriter writer = new BinaryWriter(strm, encoding); writer.Write(0x00000000); writer.Write(0x00000020); writer.Write(0x0000FFFF); writer.Write(0x0000FFFF); writer.Write(0x00000000); writer.Write(0x00000000); writer.Write(0x00000000); writer.Write(0x00000000); // Resource size writer.Write(_offset); // Resource header size writer.Write(0x00000020); // Type writer.Write(StringResourceManager.RESOURCE_TYPE << 16 | 0xFFFF); // Resource ID writer.Write(StringResourceManager.RESOURCE_ID << 16 | 0xFFFF); writer.Write(0x00000000); writer.Write(0x00000000); writer.Write(0x00000000); writer.Write(0x00000000); #if DEBUG long startPos = strm.Position; #endif foreach (string s in _literalStrings) { byte[] data = encoding.GetBytes(s); writer.Write(data); } // Make sure the stream has the size we expect #if DEBUG Debug.Assert(strm.Position - startPos == _offset, "strm.Position-startPos == _offset"); #endif } }
internal void AddEvent(RequestNotification notification, bool isPostEvent, HttpApplication.IExecutionStep step) { int index = EventToIndex(notification); #if DBG Debug.Trace("PipelineRuntime", "Adding event: " + DebugModuleName + " " + notification.ToString() + " " + isPostEvent.ToString() + "@ index " + index.ToString(CultureInfo.InvariantCulture) + "\r\n"); #endif Debug.Assert(index != -1, "index != -1"); List <HttpApplication.IExecutionStep>[] steps = null; if (isPostEvent) { if (null == _modulePostSteps) { _modulePostSteps = new List <HttpApplication.IExecutionStep> [32]; } steps = _modulePostSteps; } else { if (null == _moduleSteps) { _moduleSteps = new List <HttpApplication.IExecutionStep> [32]; } steps = _moduleSteps; } Debug.Assert(steps != null, "steps != null"); // retrieve the steps for this event (typically none at this point) // allocate a new container as necessary and add this step // in the event that a single module has registered more than once // for a given event, we'll have multiple steps here List <HttpApplication.IExecutionStep> stepArray = steps[index]; if (null == stepArray) { // first touch, instantiate and save it stepArray = new List <HttpApplication.IExecutionStep>(); steps[index] = stepArray; } stepArray.Add(step); }
static internal string Combine(string parentConfigPath, string childConfigPath) { Debug.Assert(String.IsNullOrEmpty(parentConfigPath) || IsValid(parentConfigPath), "String.IsNullOrEmpty(parentConfigPath) || IsValid(parentConfigPath)"); Debug.Assert(String.IsNullOrEmpty(childConfigPath) || IsValid(childConfigPath), "String.IsNullOrEmpty(childConfigPath) || IsValid(childConfigPath)"); if (String.IsNullOrEmpty(parentConfigPath)) { return(childConfigPath); } if (String.IsNullOrEmpty(childConfigPath)) { return(parentConfigPath); } return(parentConfigPath + "/" + childConfigPath); }
// // Return the last part of a config path, e.g. // GetName("MACHINE/WEBROOT/Default Web Site/app") == "app" // static internal string GetName(string configPath) { Debug.Assert(String.IsNullOrEmpty(configPath) || IsValid(configPath), "String.IsNullOrEmpty(configPath) || IsValid(configPath)"); if (String.IsNullOrEmpty(configPath)) { return(configPath); } int index = configPath.LastIndexOf('/'); if (index == -1) { return(configPath); } Debug.Assert(index != configPath.Length - 1); return(configPath.Substring(index + 1)); }
// Build the statement that assigns this property internal CodeStatement GetCodeStatement(BaseTemplateCodeDomTreeGenerator generator, CodeExpression ctrlRefExpr) { // If we don't have a type, use IAttributeAccessor.SetAttribute if (UseSetAttribute) { // e.g. ((IAttributeAccessor)__ctrl).SetAttribute("{{_name}}", "{{_value}}"); CodeMethodInvokeExpression methCallExpression = new CodeMethodInvokeExpression( new CodeCastExpression(typeof(IAttributeAccessor), ctrlRefExpr), "SetAttribute"); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Name)); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Value)); return(new CodeExpressionStatement(methCallExpression)); } CodeExpression leftExpr, rightExpr = null; if (PropertyInfo != null) { leftExpr = CodeDomUtility.BuildPropertyReferenceExpression(ctrlRefExpr, Name); } else { // In case of a field, there should only be one (unlike properties) Debug.Assert(Name.IndexOf('.') < 0, "_name.IndexOf('.') < 0"); leftExpr = new CodeFieldReferenceExpression(ctrlRefExpr, Name); } if (Type == typeof(string)) { rightExpr = generator.BuildStringPropertyExpression(this); } else { rightExpr = CodeDomUtility.GenerateExpressionForValue(PropertyInfo, Value, Type); } // Now that we have both side, add the assignment return(new CodeAssignStatement(leftExpr, rightExpr)); }
// Avoid unused code warning in System.Configuration by including functions in assembly-specific #defines #if CONFIGPATHUTILITY_SYSTEMWEB static internal string GetParent(string configPath) { Debug.Assert(String.IsNullOrEmpty(configPath) || IsValid(configPath), "String.IsNullOrEmpty(configPath) || IsValid(configPath)"); if (String.IsNullOrEmpty(configPath)) { return(null); } string parentConfigPath; int lastSlash = configPath.LastIndexOf(SeparatorChar); if (lastSlash == -1) { parentConfigPath = null; } else { parentConfigPath = configPath.Substring(0, lastSlash); } return(parentConfigPath); }
internal static string MessageFromEventCode(int eventCode, int eventDetailCode) { string msg = null; string detailMsg = null; if (eventDetailCode != 0) { switch (eventDetailCode) { case ApplicationShutdownUnknown: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownUnknown); break; case ApplicationShutdownHostingEnvironment: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownHostingEnvironment); break; case ApplicationShutdownChangeInGlobalAsax: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownChangeInGlobalAsax); break; case ApplicationShutdownConfigurationChange: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownConfigurationChange); break; case ApplicationShutdownUnloadAppDomainCalled: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownUnloadAppDomainCalled); break; case ApplicationShutdownChangeInSecurityPolicyFile: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownChangeInSecurityPolicyFile); break; case ApplicationShutdownBinDirChangeOrDirectoryRename: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBinDirChangeOrDirectoryRename); break; case ApplicationShutdownBrowsersDirChangeOrDirectoryRename: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBrowsersDirChangeOrDirectoryRename); break; case ApplicationShutdownCodeDirChangeOrDirectoryRename: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownCodeDirChangeOrDirectoryRename); break; case ApplicationShutdownResourcesDirChangeOrDirectoryRename: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownResourcesDirChangeOrDirectoryRename); break; case ApplicationShutdownIdleTimeout: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownIdleTimeout); break; case ApplicationShutdownPhysicalApplicationPathChanged: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownPhysicalApplicationPathChanged); break; case ApplicationShutdownHttpRuntimeClose: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownHttpRuntimeClose); break; case ApplicationShutdownInitializationError: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownInitializationError); break; case ApplicationShutdownMaxRecompilationsReached: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownMaxRecompilationsReached); break; case ApplicationShutdownBuildManagerChange: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ApplicationShutdownBuildManagerChange); break; case StateServerConnectionError: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_StateServerConnectionError); break; case InvalidTicketFailure: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidTicketFailure); break; case ExpiredTicketFailure: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_ExpiredTicketFailure); break; case InvalidViewStateMac: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidViewStateMac); break; case InvalidViewState: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_InvalidViewState); break; case SqlProviderEventsDropped: detailMsg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_detail_SqlProviderEventsDropped); break; default: break; } } switch (eventCode) { case ApplicationStart: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationStart); break; case ApplicationShutdown: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationShutdown); break; case ApplicationCompilationStart: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationCompilationStart); break; case ApplicationCompilationEnd: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationCompilationEnd); break; case ApplicationHeartbeat: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_ApplicationHeartbeat); break; case RequestTransactionComplete: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RequestTransactionComplete); break; case RequestTransactionAbort: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RequestTransactionAbort); break; case RuntimeErrorRequestAbort: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorRequestAbort); break; case RuntimeErrorViewStateFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorViewStateFailure); break; case RuntimeErrorValidationFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorValidationFailure); break; case RuntimeErrorPostTooLarge: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorPostTooLarge); break; case RuntimeErrorUnhandledException: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_RuntimeErrorUnhandledException); break; case WebErrorParserError: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorParserError); break; case WebErrorCompilationError: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorCompilationError); break; case WebErrorConfigurationError: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_WebErrorConfigurationError); break; case AuditUnhandledSecurityException: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUnhandledSecurityException); break; case AuditInvalidViewStateFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditInvalidViewStateFailure); break; case AuditFormsAuthenticationSuccess: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFormsAuthenticationSuccess); break; case AuditUrlAuthorizationSuccess: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUrlAuthorizationSuccess); break; case AuditFileAuthorizationFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFileAuthorizationFailure); break; case AuditFormsAuthenticationFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFormsAuthenticationFailure); break; case AuditFileAuthorizationSuccess: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditFileAuthorizationSuccess); break; case AuditMembershipAuthenticationSuccess: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditMembershipAuthenticationSuccess); break; case AuditMembershipAuthenticationFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditMembershipAuthenticationFailure); break; case AuditUrlAuthorizationFailure: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUrlAuthorizationFailure); break; case AuditUnhandledAccessException: msg = WebBaseEvent.FormatResourceStringWithCache(SR.Webevent_msg_AuditUnhandledAccessException); break; default: Debug.Assert(false, "ASP.NET event code " + eventCode.ToString(CultureInfo.InvariantCulture) + " doesn't have message string mapped to it"); return(String.Empty); } if (detailMsg != null) { msg += " " + detailMsg; } return(msg); }
// we have tried various techniques here for converting a request notification // into an index but a simple switch statement has so far performed the best // basically, the problem is converting a single on bit to its position // so 0x00000001 == 0, 0x00000002 == 1, etc. // Managed code doesn't support all the request flags so we only translate // the ones we deal with to keep the switch table as simple as possible private static int EventToIndex(RequestNotification notification) { int index = -1; switch (notification) { // 0x00000001 case RequestNotification.BeginRequest: return(0); // 0x00000002 case RequestNotification.AuthenticateRequest: return(1); // 0x00000004 case RequestNotification.AuthorizeRequest: return(2); // 0x00000008 case RequestNotification.ResolveRequestCache: return(3); // 0x00000010 case RequestNotification.MapRequestHandler: return(4); // 0x00000020 case RequestNotification.AcquireRequestState: return(5); // 0x00000040 case RequestNotification.PreExecuteRequestHandler: return(6); // 0x00000080 case RequestNotification.ExecuteRequestHandler: return(7); // 0x00000100 case RequestNotification.ReleaseRequestState: return(8); // 0x00000200 case RequestNotification.UpdateRequestCache: return(9); // 0x00000400 case RequestNotification.LogRequest: return(10); // 0x00000800 case RequestNotification.EndRequest: return(11); // 0x20000000 case RequestNotification.SendResponse: return(12); default: Debug.Assert(index != -1, "invalid request notification--need to update switch table?"); return(index); } }
private IDictionary <string, object> DeserializeDictionary(int depth) { IDictionary <string, object> dictionary = null; Nullable <Char> c = _s.MoveNext(); if (c != '{') { throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_ExpectedOpenBrace)); } // Loop through each JSON entry in the input object while ((c = _s.GetNextNonEmptyChar()) != null) { _s.MovePrev(); if (c == ':') { throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_InvalidMemberName)); } string memberName = null; if (c != '}') { // Find the member name memberName = DeserializeMemberName(); c = _s.GetNextNonEmptyChar(); if (c != ':') { throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_InvalidObject)); } } if (dictionary == null) { dictionary = new Dictionary <string, object>(); // If the object contains nothing (i.e. {}), we're done if (memberName == null) { // Move the cursor to the '}' character. c = _s.GetNextNonEmptyChar(); Debug.Assert(c == '}'); break; } } ThrowIfMaxJsonDeserializerMembersExceeded(dictionary.Count); // Deserialize the property value. Here, we don't know its type object propVal = DeserializeInternal(depth); dictionary[memberName] = propVal; c = _s.GetNextNonEmptyChar(); if (c == '}') { break; } if (c != ',') { throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_InvalidObject)); } } if (c != '}') { throw new ArgumentException(_s.GetDebugString(AtlasWeb.JSON_InvalidObject)); } return(dictionary); }
internal static int GetEventArrayDimensionSize(int dim) { Debug.Assert(dim == 0 || dim == 1, "dim == 0 || dim == 1"); return(s_eventArrayDimensionSizes[dim]); }