Example #1
0
 internal Profiler()
 {
     _requestsToProfile = 10;
     _outputMode        = TraceMode.SortByTime;
     _requestNum        = 0;
     _localOnly         = true;
 }
		public TraceManager ()
		{
			try {
#if NET_2_0
				mode = TraceMode.SortByTime;
				TraceSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/trace") as TraceSection;
				if (config == null)
					config = new TraceSection ();
#else
				TraceConfig config = (TraceConfig) HttpContext.GetAppConfig (traceConfigPath);
#endif

				if (config == null)
					return;
			
				enabled = config.Enabled;
				local_only = config.LocalOnly;
				page_output = config.PageOutput;
#if NET_2_0
				if (config.TraceMode == TraceDisplayMode.SortByTime)
					mode = TraceMode.SortByTime;
				else
					mode = TraceMode.SortByCategory;
#else
				mode = config.TraceMode;
#endif
				request_limit = config.RequestLimit;
			} catch (Exception ex) {
				initialException = ex;
			}
		}
        internal BuildResultNoCompilePage(Type baseType, TemplateParser parser) : base(baseType, parser)
        {
            PageParser parser2 = (PageParser)parser;

            this._traceEnabled = parser2.TraceEnabled;
            this._traceMode    = parser2.TraceMode;
            if (parser2.OutputCacheParameters != null)
            {
                this._outputCacheData = parser2.OutputCacheParameters;
                if ((this._outputCacheData.Duration == 0) || (this._outputCacheData.Location == OutputCacheLocation.None))
                {
                    this._outputCacheData = null;
                }
                else
                {
                    this._fileDependencies = new string[parser2.SourceDependencies.Count];
                    int num = 0;
                    foreach (string str in (IEnumerable)parser2.SourceDependencies)
                    {
                        this._fileDependencies[num++] = str;
                    }
                }
            }
            this._validateRequest = parser2.ValidateRequest;
            this._stylesheetTheme = parser2.StyleSheetTheme;
        }
Example #4
0
 internal Profiler() {
     _requestsToProfile = 10;
     _outputMode = TraceMode.SortByTime;
     _localOnly = true;
     _mostRecent = false;
     _requests = new Queue(_requestsToProfile);
 }
Example #5
0
        public TraceManager()
        {
            try {
                mode = TraceMode.SortByTime;
                TraceSection config = WebConfigurationManager.GetWebApplicationSection("system.web/trace") as TraceSection;
                if (config == null)
                {
                    config = new TraceSection();
                }

                if (config == null)
                {
                    return;
                }

                enabled     = config.Enabled;
                local_only  = config.LocalOnly;
                page_output = config.PageOutput;
                if (config.TraceMode == TraceDisplayMode.SortByTime)
                {
                    mode = TraceMode.SortByTime;
                }
                else
                {
                    mode = TraceMode.SortByCategory;
                }
                request_limit = config.RequestLimit;
            } catch (Exception ex) {
                initialException = ex;
            }
        }
Example #6
0
 internal Profiler()
 {
     _requestsToProfile = 10;
     _outputMode        = TraceMode.SortByTime;
     _localOnly         = true;
     _mostRecent        = false;
     _requests          = new Queue(_requestsToProfile);
 }
Example #7
0
        /// <summary>
        /// Traces the tracking derivation on the Shared State.
        /// </summary>
        /// <param name="derivation">The derivation to trace.</param>
        /// <param name="traceMode">The trace mode to use.</param>
        public static void Trace(this IDerivation derivation, TraceMode traceMode = TraceMode.Log)
        {
            if (derivation is null)
            {
                throw new ArgumentNullException(nameof(derivation));
            }

            derivation.IsTracing = traceMode;
        }
Example #8
0
        /// <summary>
        /// Traces the tracking derivation on the Shared State.
        /// </summary>
        /// <param name="sharedState">The Shared State to trace.</param>
        /// <param name="traceMode">The trace mode to use.</param>
        public static void Trace(this ISharedState sharedState, TraceMode traceMode = TraceMode.Log)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            sharedState.TrackingDerivation?.Trace(traceMode);
        }
Example #9
0
 /// <include file='doc\TraceContext.uex' path='docs/doc[@for="TraceContext.TraceContext"]/*' />
 /// <devdoc>
 /// <para>Initializes a new instance of the <see cref='System.Web.TraceContext'/> class.</para>
 /// </devdoc>
 public TraceContext(HttpContext context)
 {
     _traceMode        = TraceMode.Default;
     _isEnabled        = TraceEnable.Default;
     _context          = context;
     _firstTime        = -1;
     _lastTime         = -1;
     _endDataCollected = false;
 }
Example #10
0
        public static string TraceModeToJsonString(TraceMode traceMode)
        {
            switch (traceMode)
            {
            case TraceMode.Circular: return(JsonTraceModeCircular);

            case TraceMode.Sequential: return(JsonTraceModeSequential);
            }
            throw new Exception("Unknown TraceMode: " + traceMode);
        }
 /// <devdoc>
 /// <para>Initializes a new instance of the <see cref='System.Web.TraceContext'/> class.</para>
 /// </devdoc>
 public TraceContext(HttpContext context) {
     _traceMode = TraceMode.Default;
     // Always disable trace in retail deployment mode (DevDiv 36396)
     _isEnabled = DeploymentSection.RetailInternal ? TraceEnable.Disable : TraceEnable.Default;
     _context = context;
     _firstTime = -1;
     _lastTime = -1;
     _endDataCollected = false;
     _traceRecords = new ArrayList();
 }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DisposableStopwatch"/> class.
        /// </summary>
        /// <param name="startImmediately">if set to <c>true</c> [start immediately].</param>
        /// <param name="name">The name.</param>
        /// <param name="traceMode">The trace mode.</param>
        public DisposableStopwatch(bool startImmediately, string name, TraceMode traceMode)
        {
            _Stopwatch = new Stopwatch();
            _Name      = name ?? "undefined";
            _TraceMode = traceMode;

            if (startImmediately)
            {
                Start();
            }
        }
Example #13
0
 /// <devdoc>
 /// <para>Initializes a new instance of the <see cref='System.Web.TraceContext'/> class.</para>
 /// </devdoc>
 public TraceContext(HttpContext context)
 {
     _traceMode = TraceMode.Default;
     // Always disable trace in retail deployment mode (DevDiv 36396)
     _isEnabled        = DeploymentSection.RetailInternal ? TraceEnable.Disable : TraceEnable.Default;
     _context          = context;
     _firstTime        = -1;
     _lastTime         = -1;
     _endDataCollected = false;
     _traceRecords     = new ArrayList();
 }
 internal TraceConfig(TraceConfig parent)
 {
     if (parent != null)
     {
         _requestLimit = parent._requestLimit;
         _outputMode   = parent._outputMode;
         _isEnabled    = parent._isEnabled;
         _pageOutput   = parent._pageOutput;
         _localOnly    = parent._localOnly;
     }
 }
 public MissionWaypointTaskMsg(float velocity_range, float idle_velocity, ActionOnFinish finish_action, uint mission_exec_times, YawMode yaw_mode, TraceMode trace_mode, ActionOnRCLost rc_lost_action, GimbalPitchMode gimbal_pitch_mode, MissionWaypointMsg[] mission_waypoints)
 {
     _velocity_range     = velocity_range;
     _idle_velocity      = idle_velocity;
     _action_on_finish   = finish_action;
     _mission_exec_times = mission_exec_times;
     _yaw_mode           = yaw_mode;
     _trace_mode         = trace_mode;
     _action_on_rc_lost  = rc_lost_action;
     _gimbal_pitch_mode  = gimbal_pitch_mode;
     _mission_waypoints  = mission_waypoints;
 }
Example #16
0
    /// <summary>
    /// カメラモードのファクトリー
    /// </summary>
    /// <param name="mode">カメラモード</param>
    /// <returns></returns>
    private CameraMode ModeFactory(TraceMode mode)
    {
        switch (mode)
        {
        case TraceMode.TRACE_CHARACTER:
            return(new TraceCharacter(gameObject, target, relativePos, charaTraceSpeed, radius));        //キャラクターを追尾

        case TraceMode.TRACE_HINT:
            return(new TraceHint(target, gameObject, dampTime));                                         //指定オブジェクトを追尾
        }

        return(new TraceCharacter(gameObject, target, relativePos, charaTraceSpeed, radius));             //デフォルト
    }
		public TraceManager ()
		{
			TraceConfig config = (TraceConfig) HttpContext.GetAppConfig (traceConfigPath);

			if (config == null)
				return;
			
			enabled = config.Enabled;
			local_only = config.LocalOnly;
			page_output = config.PageOutput;
			mode = config.TraceMode;
			request_limit = config.RequestLimit;
		}
Example #18
0
		public CompilerOptions()
		{
			frame = 1;
			useMX = true;
			infer = false;
			strict = false;
			useMain = true;
			verbose = false;
			keep = true;
			groupClasses = false;
			warnUnusedImports = false;
			traceMode = TraceMode.FlashOut;
			excludeFile = "";
			traceFunction = "";
			libraryPrefix = "";
			includePackages = new string[0];
		}
Example #19
0
 public CompilerOptions()
 {
     frame             = 1;
     useMX             = true;
     infer             = false;
     strict            = false;
     useMain           = true;
     verbose           = false;
     keep              = true;
     groupClasses      = false;
     warnUnusedImports = false;
     traceMode         = TraceMode.FlashOut;
     excludeFile       = "";
     traceFunction     = "";
     libraryPrefix     = "";
     includePackages   = new string[0];
 }
            public MissionWaypointTaskMsg(JSONNode msg)
            {
                _velocity_range     = msg["velocity_range"].AsFloat;
                _idle_velocity      = msg["idle_velocity"].AsFloat;
                _action_on_finish   = (ActionOnFinish)msg["action_on_finish"].AsInt;
                _mission_exec_times = (uint)msg["mission_exec_times"].AsInt;
                _yaw_mode           = (YawMode)msg["yaw_mode"].AsInt;
                _trace_mode         = (TraceMode)msg["trace_mode"].AsInt;
                _action_on_rc_lost  = (ActionOnRCLost)msg["action_on_rc_lost"].AsInt;
                _gimbal_pitch_mode  = (GimbalPitchMode)msg["gimbal_pitch_mode"].AsInt;

                JSONArray waypoints = msg["mission_waypoint"].AsArray;

                _mission_waypoints = new MissionWaypointMsg[waypoints.Count];
                for (int i = 0; i < _mission_waypoints.Length; i++)
                {
                    _mission_waypoints[i] = new MissionWaypointMsg(waypoints[i]);
                }
            }
Example #21
0
 public static string ToJavaScriptString(this TraceMode traceMode)
 {
     if (traceMode == 0)
     {
         return("none");
     }
     else
     {
         List <string> result = new List <string>();
         foreach (TraceMode value in Enum.GetValues(typeof(TraceMode)))
         {
             if ((traceMode & value) != 0)
             {
                 result.Add(value.ToString());
             }
         }
         return(String.Join("+", result).ToLower());
     }
 }
Example #22
0
        public TraceManager()
        {
            try {
#if NET_2_0
                mode = TraceMode.SortByTime;
                TraceSection config = WebConfigurationManager.GetWebApplicationSection("system.web/trace") as TraceSection;
                if (config == null)
                {
                    config = new TraceSection();
                }
#else
                TraceConfig config = (TraceConfig)HttpContext.GetAppConfig(traceConfigPath);
#endif

                if (config == null)
                {
                    return;
                }

                enabled     = config.Enabled;
                local_only  = config.LocalOnly;
                page_output = config.PageOutput;
#if NET_2_0
                if (config.TraceMode == TraceDisplayMode.SortByTime)
                {
                    mode = TraceMode.SortByTime;
                }
                else
                {
                    mode = TraceMode.SortByCategory;
                }
#else
                mode = config.TraceMode;
#endif
                request_limit = config.RequestLimit;
            } catch (Exception ex) {
                initialException = ex;
            }
        }
        internal void LoadValuesFromConfigurationXml(XmlNode section)
        {
            HandlerBase.GetAndRemoveBooleanAttribute(section, "enabled", ref _isEnabled);
            HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(section, "requestLimit", ref _requestLimit);
            HandlerBase.GetAndRemoveBooleanAttribute(section, "pageOutput", ref _pageOutput);
            HandlerBase.GetAndRemoveBooleanAttribute(section, "localOnly", ref _localOnly);

            string [] values = { "SortByTime", "SortByCategory" };
            // TraceMode is in another file in a different namespace ... so lets have some protection if they change
            Debug.Assert(TraceMode.SortByTime == (TraceMode)0);
            Debug.Assert(TraceMode.SortByCategory == (TraceMode)1);
            int     iMode     = 0;
            XmlNode attribute = HandlerBase.GetAndRemoveEnumAttribute(section, "traceMode", values, ref iMode);

            if (attribute != null)
            {
                _outputMode = (TraceMode)iMode;
            }

            HandlerBase.CheckForUnrecognizedAttributes(section);
            // section can have no content
            HandlerBase.CheckForChildNodes(section);
        }
Example #24
0
		public TraceManager ()
		{
			try {
				mode = TraceMode.SortByTime;
				TraceSection config = WebConfigurationManager.GetWebApplicationSection ("system.web/trace") as TraceSection;
				if (config == null)
					config = new TraceSection ();

				if (config == null)
					return;
			
				enabled = config.Enabled;
				local_only = config.LocalOnly;
				page_output = config.PageOutput;
				if (config.TraceMode == TraceDisplayMode.SortByTime)
					mode = TraceMode.SortByTime;
				else
					mode = TraceMode.SortByCategory;
				request_limit = config.RequestLimit;
			} catch (Exception ex) {
				initialException = ex;
			}
		}
		internal override void ProcessMainAttributes (Hashtable atts)
		{
			// note: the 'enableSessionState' configuration property is
			// processed in a case-sensitive manner while the page-level
			// attribute is processed case-insensitive
			string enabless = GetString (atts, "EnableSessionState", null);
			if (enabless != null) {
				if (String.Compare (enabless, "readonly", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.ReadOnly;
				else if (String.Compare (enabless, "true", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.True;
				else if (String.Compare (enabless, "false", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.False;
				else
					ThrowParseException ("Invalid value for enableSessionState: " + enabless);
			}

			string cp = GetString (atts, "CodePage", null);
			if (cp != null) {
				if (responseEncoding != null)
					ThrowParseException ("CodePage and ResponseEncoding are " +
						"mutually exclusive.");

				int codepage = 0;
				try {
					codepage = (int) UInt32.Parse (cp);
				} catch {
					ThrowParseException ("Invalid value for CodePage: " + cp);
				}

				try {
					Encoding.GetEncoding (codepage);
				} catch {
					ThrowParseException ("Unsupported codepage: " + cp);
				}
			}
			
			responseEncoding = GetString (atts, "ResponseEncoding", null);
			if (responseEncoding != null) {
				if (codepage != -1)
					ThrowParseException ("CodePage and ResponseEncoding are " +
							     "mutually exclusive.");

				try {
					Encoding.GetEncoding (responseEncoding);
				} catch {
					ThrowParseException ("Unsupported encoding: " + responseEncoding);
				}
			}
			
			contentType = GetString (atts, "ContentType", null);

			string lcidStr = GetString (atts, "LCID", null);
			if (lcidStr != null) {
				try {
					lcid = (int) UInt32.Parse (lcidStr);
				} catch {
					ThrowParseException ("Invalid value for LCID: " + lcid);
				}

				CultureInfo ci = null;
				try {
					ci = new CultureInfo (lcid);
				} catch {
					ThrowParseException ("Unsupported LCID: " + lcid);
				}

				if (ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (ci.Name);
					string fmt = "LCID attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null) {
						ThrowParseException (fmt + " Please try one of these: " +
								     suggestedCulture);
					} else {
						ThrowParseException (fmt);
					}
				}
			}

			culture = GetString (atts, "Culture", null);
			if (culture != null) {
				if (lcidStr != null) 
					ThrowParseException ("Culture and LCID are mutually exclusive.");
				
				CultureInfo ci = null;
				try {
#if NET_2_0
					if (!culture.StartsWith ("auto"))
#endif
						ci = new CultureInfo (culture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + culture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (culture);
					string fmt = "Culture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			uiculture = GetString (atts, "UICulture", null);
			if (uiculture != null) {
				CultureInfo ci = null;
				try {
#if NET_2_0
					if (!uiculture.StartsWith ("auto"))
#endif
						ci = new CultureInfo (uiculture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + uiculture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (uiculture);
					string fmt = "UICulture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			string tracestr = GetString (atts, "Trace", null);
			if (tracestr != null) {
				haveTrace = true;
				atts ["Trace"] = tracestr;
				trace = GetBool (atts, "Trace", false);
			}

			string tracemodes = GetString (atts, "TraceMode", null);
			if (tracemodes != null) {
				bool valid = true;
				try {
					tracemode = (TraceMode) Enum.Parse (typeof (TraceMode), tracemodes, false);
				} catch {
					valid = false;
				}

				if (!valid || tracemode == TraceMode.Default)
					ThrowParseException ("The 'tracemode' attribute is case sensitive and must be " +
							"one of the following values: SortByTime, SortByCategory.");
			}

			errorPage = GetString (atts, "ErrorPage", null);
			validateRequest = GetBool (atts, "ValidateRequest", validateRequest);
			clientTarget = GetString (atts, "ClientTarget", null);
			if (clientTarget != null) {
				clientTarget = clientTarget.Trim ();
#if NET_2_0
				ClientTargetSection sec = GetConfigSection <ClientTargetSection> ("system.web/clientTarget");
				ClientTarget ct = null;
				
				if ((ct = sec.ClientTargets [clientTarget]) == null)
					clientTarget = clientTarget.ToLowerInvariant ();
				
				if (ct == null && (ct = sec.ClientTargets [clientTarget]) == null) {
					ThrowParseException (String.Format (
							"ClientTarget '{0}' is an invalid alias. See the " +
							"documentation for <clientTarget> config. section.",
							clientTarget));
				}
				clientTarget = ct.UserAgent;
#else
				NameValueCollection coll;
				coll = (NameValueCollection) HttpContext.GetAppConfig ("system.web/clientTarget");
				object ct = null;
				
				if (coll != null) {
					ct = coll [clientTarget];
					if (ct == null)
						ct = coll [clientTarget.ToLower (Helpers.InvariantCulture)];
				}
				
				if (ct == null) {
					ThrowParseException (String.Format (
							"ClientTarget '{0}' is an invalid alias. See the " +
							"documentation for <clientTarget> config. section.",
							clientTarget));
				}
				clientTarget = (string) ct;
#endif
			}

			notBuffer = !GetBool (atts, "Buffer", true);
			
#if NET_2_0
			async = GetBool (atts, "Async", false);
			string asyncTimeoutVal = GetString (atts, "AsyncTimeout", null);
			if (asyncTimeoutVal != null) {
				try {
					asyncTimeout = Int32.Parse (asyncTimeoutVal);
				} catch (Exception) {
					ThrowParseException ("AsyncTimeout must be an integer value");
				}
			}
			
			masterPage = GetString (atts, "MasterPageFile", masterPage);
			
			if (!String.IsNullOrEmpty (masterPage)) {
				if (!HostingEnvironment.VirtualPathProvider.FileExists (masterPage))
					ThrowParseFileNotFound (masterPage);
				AddDependency (masterPage);
			}
			
			title = GetString(atts, "Title", null);

			theme = GetString (atts, "Theme", theme);
			styleSheetTheme = GetString (atts, "StyleSheetTheme", styleSheetTheme);
			enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
			maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);
#endif
			// Ignored by now
			GetString (atts, "EnableViewStateMac", null);
			GetString (atts, "SmartNavigation", null);

			base.ProcessMainAttributes (atts);
		}
    internal override bool ProcessMainDirectiveAttribute(string deviceName, string name,
        string value, IDictionary parseData) {
        
        switch (name) {

        case "errorpage":
            _errorPage = Util.GetNonEmptyAttribute(name, value);

            // Return false to let the generic attribute processing continue
            return false;

        case "contenttype":
            // Check validity
            Util.GetNonEmptyAttribute(name, value);

            // Return false to let the generic attribute processing continue
            return false;

        case "theme":
            if (IsExpressionBuilderValue(value)) {
                return false;
            }

            // Check validity
            Util.CheckThemeAttribute(value);

            // Return false to let the generic attribute processing continue
            return false;

        case "stylesheettheme":
            // Make sure no device filter or expression builder was specified
            ValidateBuiltInAttribute(deviceName, name, value);

            // Check validity
            Util.CheckThemeAttribute(value);

            _styleSheetTheme = value;
            return true;

        case "enablesessionstate":
            flags[requiresSessionState] = true;
            flags[readOnlySessionState] = false;
            if (Util.IsFalseString(value)) {
                flags[requiresSessionState] = false;
            }
            else if (StringUtil.EqualsIgnoreCase(value, "readonly")) {
                flags[readOnlySessionState] = true;
            }
            else if (!Util.IsTrueString(value)) {
                ProcessError(SR.GetString(SR.Enablesessionstate_must_be_true_false_or_readonly));
            }

            if (flags[requiresSessionState]) {
                // Session state is only available for compiled pages
                OnFoundAttributeRequiringCompilation(name);
            }
            break;

        case "culture":
            _culture = Util.GetNonEmptyAttribute(name, value);

            // Setting culture requires medium permission
            if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium)) {
                throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "culture"));
            }

            //do not verify at parse time if potentially using browser AutoDetect
            if(StringUtil.EqualsIgnoreCase(value, HttpApplication.AutoCulture)) {
                return false;
            }


            // Create a CultureInfo just to verify validity
            CultureInfo cultureInfo;

            try {
                if(StringUtil.StringStartsWithIgnoreCase(value, HttpApplication.AutoCulture)) {
                    //safe to trim leading "auto:", string used elsewhere for null check
                    _culture = _culture.Substring(5);
                }
                cultureInfo = HttpServerUtility.CreateReadOnlyCultureInfo(_culture);
            }
            catch {
                ProcessError(SR.GetString(SR.Invalid_attribute_value, _culture, "culture"));
                return false;
            }

            // Don't allow neutral cultures (ASURT 77930)
            if (cultureInfo.IsNeutralCulture) {
                ProcessError(SR.GetString(SR.Invalid_culture_attribute,
                        Util.GetSpecificCulturesFormattedList(cultureInfo)));
            }

            // Return false to let the generic attribute processing continue
            return false;

        case "lcid":
            // Skip validity check for expression builder (e.g. <%$ ... %>)
            if (IsExpressionBuilderValue(value)) return false;

            _lcid = Util.GetNonNegativeIntegerAttribute(name, value);

            // Create a CultureInfo just to verify validity
            try {
                HttpServerUtility.CreateReadOnlyCultureInfo(_lcid);
            }
            catch {
                ProcessError(SR.GetString(SR.Invalid_attribute_value,
                    _lcid.ToString(CultureInfo.InvariantCulture), "lcid"));
            }

            // Return false to let the generic attribute processing continue
            return false;

        case "uiculture":
            // Check validity
            Util.GetNonEmptyAttribute(name, value);

            // Return false to let the generic attribute processing continue
            return false;

        case "responseencoding":
            // Skip validity check for expression builder (e.g. <%$ ... %>)
            if (IsExpressionBuilderValue(value)) return false;

            _responseEncoding = Util.GetNonEmptyAttribute(name, value);

            // Call Encoding.GetEncoding just to verify validity
            Encoding.GetEncoding(_responseEncoding);

            // Return false to let the generic attribute processing continue
            return false;

        case "codepage":
            // Skip validity check for expression builder (e.g. <%$ ... %>)
            if (IsExpressionBuilderValue(value)) return false;

            _codePage = Util.GetNonNegativeIntegerAttribute(name, value);

            // Call Encoding.GetEncoding just to verify validity
            Encoding.GetEncoding(_codePage);

            // Return false to let the generic attribute processing continue
            return false;

        case "transaction":
            // This only makes sense for compiled pages
            OnFoundAttributeRequiringCompilation(name);

            ParseTransactionAttribute(name, value);
            break;

        case "aspcompat":
            // This only makes sense for compiled pages
            OnFoundAttributeRequiringCompilation(name);

            flags[aspCompatMode] = Util.GetBooleanAttribute(name, value);

            // Only allow the use of aspcompat when we have UnmanagedCode access (ASURT 76694)
            if (flags[aspCompatMode] && !HttpRuntime.HasUnmanagedPermission()) {
                throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "AspCompat"));
            }

            break;

        case "async":
            // This only makes sense for compiled pages
            OnFoundAttributeRequiringCompilation(name);

            flags[asyncMode] = Util.GetBooleanAttribute(name, value);

            // Async requires Medium trust
            if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium)) {
                throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "async"));
            }

            break;

        case "tracemode":
            // We use TraceModeInternal instead of TraceMode to disallow the 'default' value (ASURT 75783)
            object tmpObj = Util.GetEnumAttribute(name, value, typeof(TraceModeInternal));
            _traceMode = (TraceMode) tmpObj;
            break;

        case "trace":
            bool traceEnabled = Util.GetBooleanAttribute(name, value);
            if (traceEnabled)
                _traceEnabled = TraceEnable.Enable;
            else
                _traceEnabled = TraceEnable.Disable;
            break;

        case "smartnavigation":
            // Make sure no device filter or expression builder was specified, since it doesn't make much
            // sense for smartnav (which only works on IE5.5+) (VSWhidbey 85876)
            ValidateBuiltInAttribute(deviceName, name, value);

            // Ignore it if it has default value.  Otherwise, let the generic
            // attribute processing continue
            bool smartNavigation = Util.GetBooleanAttribute(name, value);
            return (smartNavigation == Page.SmartNavigationDefault);

        case "maintainscrollpositiononpostback":
            bool maintainScrollPosition = Util.GetBooleanAttribute(name, value);
            return (maintainScrollPosition == Page.MaintainScrollPositionOnPostBackDefault);

        case "validaterequest":
            flags[validateRequest] = Util.GetBooleanAttribute(name, value);
            break;

        case "clienttarget":
            // Skip validity check for expression builder (e.g. <%$ ... %>)
            if (IsExpressionBuilderValue(value)) return false;

            // Check validity
            HttpCapabilitiesDefaultProvider.GetUserAgentFromClientTarget(CurrentVirtualPath, value);

            // Return false to let the generic attribute processing continue
            return false;

        case "masterpagefile":
            // Skip validity check for expression builder (e.g. <%$ ... %>)
            if (IsExpressionBuilderValue(value)) return false;

            if (value.Length > 0) {
                // Add dependency on the Type by calling this method
                Type type = GetReferencedType(value);

                // Make sure it has the correct base type
                if (!typeof(MasterPage).IsAssignableFrom(type)) {
                    ProcessError(SR.GetString(SR.Invalid_master_base, value));
                }

                if (deviceName.Length > 0) {
                    // Make sure the masterPageFile definition from config
                    // is applied before filtered masterPageFile attributes.
                    EnsureMasterPageFileFromConfigApplied();
                }
            }

            //VSWhidbey 479064 Remember the masterPageFile had been set even if it's empty string
            _mainDirectiveMasterPageSet = true;

            // Return false to let the generic attribute processing continue
            return false;

        default:
            // We didn't handle the attribute.  Try the base class
            return base.ProcessMainDirectiveAttribute(deviceName, name, value, parseData);
        }

        // The attribute was handled

        // Make sure no device filter or resource expression was specified
        ValidateBuiltInAttribute(deviceName, name, value);

        return true;
    }
		internal override void ProcessMainAttributes (Hashtable atts)
		{
			string enabless = GetString (atts, "EnableSessionState", PagesConfig.EnableSessionState);
			if (enabless != null) {
				readonlySessionState = (String.Compare (enabless, "readonly", true) == 0);
				if (readonlySessionState == true || String.Compare (enabless, "true", true) == 0) {
					enableSessionState = true;
				} else if (String.Compare (enabless, "false", true) == 0) {
					enableSessionState = false;
				} else {
					ThrowParseException ("Invalid value for EnableSessionState: " + enabless);
				}
			}

			string cp = GetString (atts, "CodePage", null);
			if (cp != null) {
				if (responseEncoding != null)
					ThrowParseException ("CodePage and ResponseEncoding are " +
							     "mutually exclusive.");

				int codepage = 0;
				try {
					codepage = (int) UInt32.Parse (cp);
				} catch {
					ThrowParseException ("Invalid value for CodePage: " + cp);
				}

				try {
					Encoding.GetEncoding (codepage);
				} catch {
					ThrowParseException ("Unsupported codepage: " + cp);
				}
			}
			
			responseEncoding = GetString (atts, "ResponseEncoding", null);
			if (responseEncoding != null) {
				if (codepage != -1)
					ThrowParseException ("CodePage and ResponseEncoding are " +
							     "mutually exclusive.");

				try {
					Encoding.GetEncoding (responseEncoding);
				} catch {
					ThrowParseException ("Unsupported encoding: " + responseEncoding);
				}
			}
			
			contentType = GetString (atts, "ContentType", null);

			string lcidStr = GetString (atts, "LCID", null);
			if (lcidStr != null) {
				try {
					lcid = (int) UInt32.Parse (lcidStr);
				} catch {
					ThrowParseException ("Invalid value for LCID: " + lcid);
				}

				CultureInfo ci = null;
				try {
					ci = new CultureInfo (lcid);
				} catch {
					ThrowParseException ("Unsupported LCID: " + lcid);
				}

				if (ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (ci.Name);
					string fmt = "LCID attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null) {
						ThrowParseException (fmt + " Please try one of these: " +
								     suggestedCulture);
					} else {
						ThrowParseException (fmt);
					}
				}
			}

			culture = GetString (atts, "Culture", null);
			if (culture != null) {
				if (lcidStr != null) 
					ThrowParseException ("Culture and LCID are mutually exclusive.");
				
				CultureInfo ci = null;
				try {
					ci = new CultureInfo (culture);					
				} catch {
					ThrowParseException ("Unsupported Culture: " + culture);
				}

				if (ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (culture);
					string fmt = "Culture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			uiculture = GetString (atts, "UICulture", null);
			if (uiculture != null) {
				CultureInfo ci = null;
				try {
					ci = new CultureInfo (uiculture);					
				} catch {
					ThrowParseException ("Unsupported Culture: " + uiculture);
				}

				if (ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (uiculture);
					string fmt = "UICulture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			string tracestr = GetString (atts, "Trace", null);
			if (tracestr != null) {
				haveTrace = true;
				atts ["Trace"] = tracestr;
				trace = GetBool (atts, "Trace", false);
			}

			string tracemodes = GetString (atts, "TraceMode", null);
			if (tracemodes != null) {
				bool valid = true;
				try {
					tracemode = (TraceMode) Enum.Parse (typeof (TraceMode), tracemodes, false);
				} catch {
					valid = false;
				}

				if (!valid || tracemode == TraceMode.Default)
					ThrowParseException ("The 'tracemode' attribute is case sensitive and must be " +
							"one of the following values: SortByTime, SortByCategory.");
			}

			errorPage = GetString (atts, "ErrorPage", null);
			validateRequest = GetBool (atts, "ValidateRequest", PagesConfig.ValidateRequest);
			clientTarget = GetString (atts, "ClientTarget", null);
			if (clientTarget != null) {
				NameValueCollection coll;
				coll = (NameValueCollection) Context.GetConfig ("system.web/clientTarget");
				if (coll == null || coll [clientTarget] == null) {
					ThrowParseException (String.Format (
							"ClientTarget '{0}' is an invalid alias. See the " +
							"documentation for <clientTarget> config. section.",
							clientTarget));
				}
				clientTarget = (string) coll [clientTarget];
			}

			notBuffer = !GetBool (atts, "Buffer", true);
			
#if NET_2_0
			masterPage = GetString (atts, "MasterPageFile", null);
			
			// Make sure the page exists
			if (masterPage != null)
				MasterPageParser.GetCompiledMasterType (masterPage, MapPath (masterPage), HttpContext.Current);
#endif
			// Ignored by now
			GetString (atts, "EnableViewStateMac", null);
			GetString (atts, "SmartNavigation", null);

			base.ProcessMainAttributes (atts);
		}
Example #28
0
		internal override void ProcessMainAttributes (IDictionary atts)
		{
			// note: the 'enableSessionState' configuration property is
			// processed in a case-sensitive manner while the page-level
			// attribute is processed case-insensitive
			string enabless = GetString (atts, "EnableSessionState", null);
			if (enabless != null) {
				if (String.Compare (enabless, "readonly", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.ReadOnly;
				else if (String.Compare (enabless, "true", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.True;
				else if (String.Compare (enabless, "false", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.False;
				else
					ThrowParseException ("Invalid value for enableSessionState: " + enabless);
			}

			string value = GetString (atts, "CodePage", null);
			if (value != null) {
				if (responseEncoding != null)
					ThrowParseException ("CodePage and ResponseEncoding are mutually exclusive.");
				
				if (!BaseParser.IsExpression (value)) {
					int cpval = -1;

					try {
						cpval = (int) UInt32.Parse (value);
					} catch {
						ThrowParseException ("Invalid value for CodePage: " + value);
					}

					try {
						Encoding.GetEncoding (cpval);
					} catch {
						ThrowParseException ("Unsupported codepage: " + value);
					}
					codepage = new MainDirectiveAttribute <int> (cpval, true);
				} else
					codepage = new MainDirectiveAttribute <int> (value);
			}
			
			value = GetString (atts, "ResponseEncoding", null);
			if (value != null) {
				if (codepage != null)
					ThrowParseException ("CodePage and ResponseEncoding are mutually exclusive.");

				if (!BaseParser.IsExpression (value)) {
					try {
						Encoding.GetEncoding (value);
					} catch {
						ThrowParseException ("Unsupported encoding: " + value);
					}
					responseEncoding = new MainDirectiveAttribute <string> (value, true);
				} else
					responseEncoding = new MainDirectiveAttribute <string> (value);
			}
			
			contentType = GetString (atts, "ContentType", null);

			value = GetString (atts, "LCID", null);
			if (value != null) {
				if (!BaseParser.IsExpression (value)) {
					int parsedLcid = -1;
					try {
						parsedLcid = (int) UInt32.Parse (value);
					} catch {
						ThrowParseException ("Invalid value for LCID: " + value);
					}

					CultureInfo ci = null;
					try {
						ci = new CultureInfo (parsedLcid);
					} catch {
						ThrowParseException ("Unsupported LCID: " + value);
					}

					if (ci.IsNeutralCulture) {
						string suggestedCulture = SuggestCulture (ci.Name);
						string fmt = "LCID attribute must be set to a non-neutral Culture.";
						if (suggestedCulture != null) {
							ThrowParseException (fmt + " Please try one of these: " +
									     suggestedCulture);
						} else {
							ThrowParseException (fmt);
						}
					}
					lcid = new MainDirectiveAttribute <int> (parsedLcid, true);
				} else
					lcid = new MainDirectiveAttribute <int> (value);
			}

			culture = GetString (atts, "Culture", null);
			if (culture != null) {
				if (lcid != null) 
					ThrowParseException ("Culture and LCID are mutually exclusive.");
				
				CultureInfo ci = null;
				try {
					if (!culture.StartsWith ("auto"))
						ci = new CultureInfo (culture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + culture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (culture);
					string fmt = "Culture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			uiculture = GetString (atts, "UICulture", null);
			if (uiculture != null) {
				CultureInfo ci = null;
				try {
					if (!uiculture.StartsWith ("auto"))
						ci = new CultureInfo (uiculture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + uiculture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (uiculture);
					string fmt = "UICulture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			string tracestr = GetString (atts, "Trace", null);
			if (tracestr != null) {
				haveTrace = true;
				atts ["Trace"] = tracestr;
				trace = GetBool (atts, "Trace", false);
			}

			string tracemodes = GetString (atts, "TraceMode", null);
			if (tracemodes != null) {
				bool valid = true;
				try {
					tracemode = (TraceMode) Enum.Parse (typeof (TraceMode), tracemodes, false);
				} catch {
					valid = false;
				}

				if (!valid || tracemode == TraceMode.Default)
					ThrowParseException ("The 'tracemode' attribute is case sensitive and must be " +
							"one of the following values: SortByTime, SortByCategory.");
			}

			errorPage = GetString (atts, "ErrorPage", null);
			validateRequest = GetBool (atts, "ValidateRequest", validateRequest);
			value = GetString (atts, "ClientTarget", null);
			if (value != null) {				
				if (!BaseParser.IsExpression (value)) {
					value = value.Trim ();
					
					ClientTargetSection sec = GetConfigSection <ClientTargetSection> ("system.web/clientTarget");
					ClientTarget ct = null;
				
					if ((ct = sec.ClientTargets [value]) == null)
						value = value.ToLowerInvariant ();
				
					if (ct == null && (ct = sec.ClientTargets [value]) == null) {
						ThrowParseException (String.Format (
									     "ClientTarget '{0}' is an invalid alias. See the " +
									     "documentation for <clientTarget> config. section.",
									     clientTarget));
					}
					value = ct.UserAgent;
					clientTarget = new MainDirectiveAttribute <string> (value, true);
				} else
					clientTarget = new MainDirectiveAttribute <string> (value);
			}

			notBuffer = !GetBool (atts, "Buffer", true);
			async = GetBool (atts, "Async", false);
			string asyncTimeoutVal = GetString (atts, "AsyncTimeout", null);
			if (asyncTimeoutVal != null) {
				try {
					asyncTimeout = Int32.Parse (asyncTimeoutVal);
				} catch (Exception) {
					ThrowParseException ("AsyncTimeout must be an integer value");
				}
			}
			
			value = GetString (atts, "MasterPageFile", masterPage != null ? masterPage.Value : null);
			if (!String.IsNullOrEmpty (value)) {
				if (!BaseParser.IsExpression (value)) {
					if (!HostingEnvironment.VirtualPathProvider.FileExists (value))
						ThrowParseFileNotFound (value);
					AddDependency (value);
					masterPage = new MainDirectiveAttribute <string> (value, true);
				} else
					masterPage = new MainDirectiveAttribute <string> (value);
			}
			
			value = GetString(atts, "Title", null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					title = new MainDirectiveAttribute <string> (value, true);
				else
					title = new MainDirectiveAttribute <string> (value);
			}
			
			value = GetString (atts, "Theme", theme != null ? theme.Value : null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					theme = new MainDirectiveAttribute <string> (value, true);
				else
					theme = new MainDirectiveAttribute <string> (value);
			}
			
			styleSheetTheme = GetString (atts, "StyleSheetTheme", styleSheetTheme);
			enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
			maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);

			if (atts.Contains ("EnableViewState")) {
				enableViewStateMac = GetBool (atts, "EnableViewStateMac", enableViewStateMac);
				enableViewStateMacSet = true;
			}
#if NET_4_0
			value = GetString (atts, "MetaDescription", null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					metaDescription = new MainDirectiveAttribute <string> (value, true);
				else
					metaDescription = new MainDirectiveAttribute <string> (value);
			}

			value = GetString (atts, "MetaKeywords", null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					metaKeywords = new MainDirectiveAttribute <string> (value, true);
				else
					metaKeywords = new MainDirectiveAttribute <string> (value);
			}
#endif
			// Ignored by now
			GetString (atts, "SmartNavigation", null);

			base.ProcessMainAttributes (atts);
		}
Example #29
0
		internal override void ProcessMainAttributes (IDictionary atts)
		{
			// note: the 'enableSessionState' configuration property is
			// processed in a case-sensitive manner while the page-level
			// attribute is processed case-insensitive
			string enabless = GetString (atts, "EnableSessionState", null);
			if (enabless != null) {
				if (String.Compare (enabless, "readonly", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.ReadOnly;
				else if (String.Compare (enabless, "true", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.True;
				else if (String.Compare (enabless, "false", true, Helpers.InvariantCulture) == 0)
					enableSessionState = PagesEnableSessionState.False;
				else
					ThrowParseException ("Invalid value for enableSessionState: " + enabless);
			}

			string value = GetString (atts, "CodePage", null);
			if (value != null) {
				if (responseEncoding != null)
					ThrowParseException ("CodePage and ResponseEncoding are mutually exclusive.");
#if NET_2_0
				if (!BaseParser.IsExpression (value)) {
#endif
					int cpval = -1;

					try {
						cpval = (int) UInt32.Parse (value);
					} catch {
						ThrowParseException ("Invalid value for CodePage: " + value);
					}

					try {
						Encoding.GetEncoding (cpval);
					} catch {
						ThrowParseException ("Unsupported codepage: " + value);
					}
#if NET_2_0
					codepage = new MainDirectiveAttribute <int> (cpval, true);
#else
					codepage = new MainDirectiveAttribute (cpval);
#endif

#if NET_2_0
				} else
					codepage = new MainDirectiveAttribute <int> (value);
#endif
			}
			
			value = GetString (atts, "ResponseEncoding", null);
			if (value != null) {
				if (codepage != null)
					ThrowParseException ("CodePage and ResponseEncoding are mutually exclusive.");
#if NET_2_0
				if (!BaseParser.IsExpression (value)) {
#endif
					try {
						Encoding.GetEncoding (value);
					} catch {
						ThrowParseException ("Unsupported encoding: " + value);
					}
#if NET_2_0
					responseEncoding = new MainDirectiveAttribute <string> (value, true);
#else
					responseEncoding = new MainDirectiveAttribute (value);
#endif

#if NET_2_0
				} else
					responseEncoding = new MainDirectiveAttribute <string> (value);
#endif
			}
			
			contentType = GetString (atts, "ContentType", null);

			value = GetString (atts, "LCID", null);
			if (value != null) {
#if NET_2_0
				if (!BaseParser.IsExpression (value)) {
#endif
					int parsedLcid = -1;
					try {
						parsedLcid = (int) UInt32.Parse (value);
					} catch {
						ThrowParseException ("Invalid value for LCID: " + value);
					}

					CultureInfo ci = null;
					try {
						ci = new CultureInfo (parsedLcid);
					} catch {
						ThrowParseException ("Unsupported LCID: " + value);
					}

					if (ci.IsNeutralCulture) {
						string suggestedCulture = SuggestCulture (ci.Name);
						string fmt = "LCID attribute must be set to a non-neutral Culture.";
						if (suggestedCulture != null) {
							ThrowParseException (fmt + " Please try one of these: " +
									     suggestedCulture);
						} else {
							ThrowParseException (fmt);
						}
					}
#if NET_2_0
					lcid = new MainDirectiveAttribute <int> (parsedLcid, true);
#else
					lcid = new MainDirectiveAttribute (parsedLcid);
#endif

#if NET_2_0
				} else
					lcid = new MainDirectiveAttribute <int> (value);
#endif
			}

			culture = GetString (atts, "Culture", null);
			if (culture != null) {
				if (lcid != null) 
					ThrowParseException ("Culture and LCID are mutually exclusive.");
				
				CultureInfo ci = null;
				try {
#if NET_2_0
					if (!culture.StartsWith ("auto"))
#endif
						ci = new CultureInfo (culture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + culture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (culture);
					string fmt = "Culture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			uiculture = GetString (atts, "UICulture", null);
			if (uiculture != null) {
				CultureInfo ci = null;
				try {
#if NET_2_0
					if (!uiculture.StartsWith ("auto"))
#endif
						ci = new CultureInfo (uiculture);
				} catch {
					ThrowParseException ("Unsupported Culture: " + uiculture);
				}

				if (ci != null && ci.IsNeutralCulture) {
					string suggestedCulture = SuggestCulture (uiculture);
					string fmt = "UICulture attribute must be set to a non-neutral Culture.";
					if (suggestedCulture != null)
						ThrowParseException (fmt +
								" Please try one of these: " + suggestedCulture);
					else
						ThrowParseException (fmt);
				}
			}

			string tracestr = GetString (atts, "Trace", null);
			if (tracestr != null) {
				haveTrace = true;
				atts ["Trace"] = tracestr;
				trace = GetBool (atts, "Trace", false);
			}

			string tracemodes = GetString (atts, "TraceMode", null);
			if (tracemodes != null) {
				bool valid = true;
				try {
					tracemode = (TraceMode) Enum.Parse (typeof (TraceMode), tracemodes, false);
				} catch {
					valid = false;
				}

				if (!valid || tracemode == TraceMode.Default)
					ThrowParseException ("The 'tracemode' attribute is case sensitive and must be " +
							"one of the following values: SortByTime, SortByCategory.");
			}

			errorPage = GetString (atts, "ErrorPage", null);
			validateRequest = GetBool (atts, "ValidateRequest", validateRequest);

			value = GetString (atts, "ClientTarget", null);
			if (value != null) {
#if NET_2_0
				if (!BaseParser.IsExpression (value)) {
					value = value.Trim ();
					
					ClientTargetSection sec = GetConfigSection <ClientTargetSection> ("system.web/clientTarget");
					ClientTarget ct = null;
				
					if ((ct = sec.ClientTargets [value]) == null)
						value = value.ToLowerInvariant ();
				
					if (ct == null && (ct = sec.ClientTargets [value]) == null) {
						ThrowParseException (String.Format (
									     "ClientTarget '{0}' is an invalid alias. See the " +
									     "documentation for <clientTarget> config. section.",
									     clientTarget));
					}
					value = ct.UserAgent;
					clientTarget = new MainDirectiveAttribute <string> (value, true);
#else
					NameValueCollection coll;
					coll = (NameValueCollection) HttpContext.GetAppConfig ("system.web/clientTarget");
					object ct = null;
				
					if (coll != null) {
						ct = coll [value];
						if (ct == null)
							ct = coll [value.ToLower (Helpers.InvariantCulture)];
					}
				
					if (ct == null) {
						ThrowParseException (String.Format (
									     "ClientTarget '{0}' is an invalid alias. See the " +
									     "documentation for <clientTarget> config. section.",
									     clientTarget));
					}
					clientTarget = new MainDirectiveAttribute (ct);
#endif
#if NET_2_0
				} else {
					clientTarget = new MainDirectiveAttribute <string> (value);
				}
#endif
			}

			notBuffer = !GetBool (atts, "Buffer", true);
			
#if NET_2_0
			async = GetBool (atts, "Async", false);
			string asyncTimeoutVal = GetString (atts, "AsyncTimeout", null);
			if (asyncTimeoutVal != null) {
				try {
					asyncTimeout = Int32.Parse (asyncTimeoutVal);
				} catch (Exception) {
					ThrowParseException ("AsyncTimeout must be an integer value");
				}
			}
			
			value = GetString (atts, "MasterPageFile", masterPage != null ? masterPage.Value : null);
			if (!String.IsNullOrEmpty (value)) {
				if (!BaseParser.IsExpression (value)) {
					if (!HostingEnvironment.VirtualPathProvider.FileExists (value))
						ThrowParseFileNotFound (value);
					AddDependency (value);
					masterPage = new MainDirectiveAttribute <string> (value, true);
				} else
					masterPage = new MainDirectiveAttribute <string> (value);
			}
			
			value = GetString(atts, "Title", null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					title = new MainDirectiveAttribute <string> (value, true);
				else
					title = new MainDirectiveAttribute <string> (value);
			}
			
			value = GetString (atts, "Theme", theme != null ? theme.Value : null);
			if (value != null) {
				if (!BaseParser.IsExpression (value))
					theme = new MainDirectiveAttribute <string> (value, true);
				else
					theme = new MainDirectiveAttribute <string> (value);
			}

			styleSheetTheme = GetString (atts, "StyleSheetTheme", styleSheetTheme);
			enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
			maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);
#endif
			if (atts.Contains ("EnableViewStateMac")) {
				enableViewStateMac = GetBool (atts, "EnableViewStateMac", enableViewStateMac);
				enableViewStateMacSet = true;
			}
			
			// Ignored by now
			GetString (atts, "SmartNavigation", null);

			base.ProcessMainAttributes (atts);
		}
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisposableStopwatch"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="traceMode">The trace mode.</param>
 public DisposableStopwatch(string name, TraceMode traceMode) : this(true, name, TraceMode.Milliseconds)
 {
 }
Example #31
0
        /// <summary>
        /// Traces the computed property given by the trace expression.
        /// </summary>
        /// <param name="toTrace">The object to trace.</param>
        /// <param name="expression">The member expression.</param>
        /// <param name="traceMode">The trace mode to use.</param>
        /// <typeparam name="TObject">The type of the object.</typeparam>
        /// <typeparam name="TMember">The property or method of the object.</typeparam>
        /// <exception cref="InvalidOperationException">When the provided expression is not a member expression.</exception>
        public static void Trace <TObject, TMember>(this TObject toTrace, Expression <Func <TObject, TMember> > expression, TraceMode traceMode = TraceMode.Log)
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            var observableObject = ObservableObject.GetFromObject(toTrace);

            if (observableObject == null)
            {
                throw new InvalidOperationException(Resources.CannotTraceNotObservable);
            }

            string key = expression.ExtractNameFromMemberExpression();

            var observableValue = observableObject[key];

            if (observableValue is IDerivation derivation)
            {
                derivation.Trace(traceMode);
                return;
            }

            throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ProvidedMemberNoDerivation, key));
        }
Example #32
0
 public TracePoint(Point point, TraceMode mode)
 {
     Point = point;
     Mode  = mode;
 }
    internal BuildResultNoCompilePage(Type baseType, TemplateParser parser)
        : base(baseType, parser) {

        PageParser pageParser = (PageParser) parser;

        //
        // Keep track of relevant info from the parser
        //

        _traceEnabled = pageParser.TraceEnabled;
        _traceMode = pageParser.TraceMode;

        if (pageParser.OutputCacheParameters != null) {
            _outputCacheData = pageParser.OutputCacheParameters;

            // If we're not supposed to cache it, clear out the field
            if (_outputCacheData.Duration == 0 || _outputCacheData.Location == OutputCacheLocation.None) {
                _outputCacheData = null;
            }
            else {
                // Since we're going to be output caching, remember all the dependencies
                _fileDependencies = new string[pageParser.SourceDependencies.Count];
                int i = 0;
                foreach (string dependency in pageParser.SourceDependencies) {
                    _fileDependencies[i++] = dependency;
                }
                Debug.Assert(i == pageParser.SourceDependencies.Count);
            }
        }

        _validateRequest = pageParser.ValidateRequest;
        _stylesheetTheme = pageParser.StyleSheetTheme;
    }
Example #34
0
        internal override void ProcessMainDirective(IDictionary mainDirective)
        {
            // Get the error page (if any).
            _errorPage = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "errorpage");

            // Get various attributes

            _clientTarget = Util.GetAndRemove(mainDirective, "clienttarget");

            _contentType = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "contenttype");

            Util.GetAndRemoveBooleanAttribute(mainDirective, "buffer",
                                              ref _fBuffer);

            if (!_fBuffer && _errorPage != null)
            {
                throw new HttpException(
                          HttpRuntime.FormatResourceString(SR.Error_page_not_supported_when_buffering_off));
            }

            string tmp = Util.GetAndRemove(mainDirective, "enablesessionstate");

            if (tmp != null)
            {
                _fRequiresSessionState = true;
                _fReadOnlySessionState = false;
                if (Util.IsFalseString(tmp))
                {
                    _fRequiresSessionState = false;
                }
                else if (string.Compare(tmp, "readonly", true, CultureInfo.InvariantCulture) == 0)
                {
                    _fReadOnlySessionState = true;
                }
                else if (!Util.IsTrueString(tmp))
                {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Enablesessionstate_must_be_true_false_or_readonly));
                }
            }

            _culture = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "culture");

            // If it was specified, create a CultureInfo just to verify validity
            if (_culture != null)
            {
                CultureInfo cultureInfo;

                try {
                    cultureInfo = HttpServerUtility.CreateReadOnlyCultureInfo(_culture);
                }
                catch {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_attribute_value, _culture, "culture"));
                }

                // Don't allow neutral cultures (ASURT 77930)
                if (cultureInfo.IsNeutralCulture)
                {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_culture_attribute,
                                                               Util.GetSpecificCulturesFormattedList(cultureInfo)));
                }
            }

            bool fHasLcid = Util.GetAndRemoveNonNegativeIntegerAttribute(mainDirective, "lcid", ref _lcid);

            // If it was specified, create a CultureInfo just to verify validity
            if (fHasLcid)
            {
                try {
                    HttpServerUtility.CreateReadOnlyCultureInfo(_lcid);
                }
                catch {
                    throw new HttpException(
                              HttpRuntime.FormatResourceString(SR.Invalid_attribute_value, _lcid.ToString(), "lcid"));
                }
            }

            if (_culture != null && fHasLcid)
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Attributes_mutually_exclusive, "Culture", "LCID"));
            }

            _uiCulture = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "uiculture");

            _responseEncoding = Util.GetAndRemoveNonEmptyAttribute(mainDirective, "responseencoding");
            // If it was specified, call Encoding.GetEncoding just to verify validity
            if (_responseEncoding != null)
            {
                Encoding.GetEncoding(_responseEncoding);
            }

            bool fHasCodePage = Util.GetAndRemoveNonNegativeIntegerAttribute(mainDirective, "codepage", ref _codePage);

            // If it was specified, call Encoding.GetEncoding just to verify validity
            if (fHasCodePage)
            {
                Encoding.GetEncoding(_codePage);
            }

            if (_responseEncoding != null && fHasCodePage)
            {
                throw new HttpException(
                          HttpRuntime.FormatResourceString(SR.Attributes_mutually_exclusive, "ResponseEncoding", "CodePage"));
            }

            if (mainDirective["transaction"] != null)
            {
                ParseTransactionAttribute(mainDirective);
            }

            if (Util.GetAndRemoveBooleanAttribute(mainDirective, "aspcompat", ref _aspCompatMode))
            {
                // Only allow the use of aspcompat when we have UnmanagedCode access (ASURT 76694)
                if (_aspCompatMode && !HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(HttpRuntime.FormatResourceString(SR.Insufficient_trust_for_attribute, "AspCompat"));
                }
            }

            // We use TraceModeInternal instead of TraceMode to disallow the 'default' value (ASURT 75783)
            object tmpObj = Util.GetAndRemoveEnumAttribute(
                mainDirective, typeof(TraceModeInternal), "tracemode");

            if (tmpObj != null)
            {
                _traceMode = (TraceMode)tmpObj;
            }

            bool traceEnabled = false;

            if (Util.GetAndRemoveBooleanAttribute(mainDirective, "trace", ref traceEnabled))
            {
                if (traceEnabled)
                {
                    _traceEnabled = TraceEnable.Enable;
                }
                else
                {
                    _traceEnabled = TraceEnable.Disable;
                }
            }

            Util.GetAndRemoveBooleanAttribute(mainDirective, "enableviewstatemac", ref _enableViewStateMac);

            Util.GetAndRemoveBooleanAttribute(mainDirective, "smartnavigation", ref _smartNavigation);

            Util.GetAndRemoveBooleanAttribute(mainDirective, "validaterequest", ref _validateRequest);

            base.ProcessMainDirective(mainDirective);
        }
Example #35
0
 /// <summary>
 /// 追尾モードを変更
 /// </summary>
 /// <param name="mode">モード</param>
 private void ChangeMode(TraceMode mode)
 {
     cameraMode = ModeFactory(mode);                         //ファクトリーから作成
 }
Example #36
0
 public static bool IsSlow(this TraceMode traceMode)
 {
     return
         (traceMode == TraceMode.Slow ||
          traceMode == TraceMode.ErrorSlow);
 }
Example #37
0
        internal override bool ProcessMainDirectiveAttribute(string deviceName, string name,
                                                             string value, IDictionary parseData)
        {
            switch (name)
            {
            case "errorpage":
                _errorPage = Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "contenttype":
                // Check validity
                Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "theme":
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                // Check validity
                Util.CheckThemeAttribute(value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "stylesheettheme":
                // Make sure no device filter or expression builder was specified
                ValidateBuiltInAttribute(deviceName, name, value);

                // Check validity
                Util.CheckThemeAttribute(value);

                _styleSheetTheme = value;
                return(true);

            case "enablesessionstate":
                flags[requiresSessionState] = true;
                flags[readOnlySessionState] = false;
                if (Util.IsFalseString(value))
                {
                    flags[requiresSessionState] = false;
                }
                else if (StringUtil.EqualsIgnoreCase(value, "readonly"))
                {
                    flags[readOnlySessionState] = true;
                }
                else if (!Util.IsTrueString(value))
                {
                    ProcessError(SR.GetString(SR.Enablesessionstate_must_be_true_false_or_readonly));
                }

                if (flags[requiresSessionState])
                {
                    // Session state is only available for compiled pages
                    OnFoundAttributeRequiringCompilation(name);
                }
                break;

            case "culture":
                _culture = Util.GetNonEmptyAttribute(name, value);

                // Setting culture requires medium permission
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "culture"));
                }

                //do not verify at parse time if potentially using browser AutoDetect
                if (StringUtil.EqualsIgnoreCase(value, HttpApplication.AutoCulture))
                {
                    return(false);
                }


                // Create a CultureInfo just to verify validity
                CultureInfo cultureInfo;

                try {
                    if (StringUtil.StringStartsWithIgnoreCase(value, HttpApplication.AutoCulture))
                    {
                        //safe to trim leading "auto:", string used elsewhere for null check
                        _culture = _culture.Substring(5);
                    }
                    cultureInfo = HttpServerUtility.CreateReadOnlyCultureInfo(_culture);
                }
                catch {
                    ProcessError(SR.GetString(SR.Invalid_attribute_value, _culture, "culture"));
                    return(false);
                }

                // Don't allow neutral cultures (ASURT 77930)
                if (cultureInfo.IsNeutralCulture)
                {
                    ProcessError(SR.GetString(SR.Invalid_culture_attribute,
                                              Util.GetSpecificCulturesFormattedList(cultureInfo)));
                }

                // Return false to let the generic attribute processing continue
                return(false);

            case "lcid":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _lcid = Util.GetNonNegativeIntegerAttribute(name, value);

                // Create a CultureInfo just to verify validity
                try {
                    HttpServerUtility.CreateReadOnlyCultureInfo(_lcid);
                }
                catch {
                    ProcessError(SR.GetString(SR.Invalid_attribute_value,
                                              _lcid.ToString(CultureInfo.InvariantCulture), "lcid"));
                }

                // Return false to let the generic attribute processing continue
                return(false);

            case "uiculture":
                // Check validity
                Util.GetNonEmptyAttribute(name, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "responseencoding":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _responseEncoding = Util.GetNonEmptyAttribute(name, value);

                // Call Encoding.GetEncoding just to verify validity
                Encoding.GetEncoding(_responseEncoding);

                // Return false to let the generic attribute processing continue
                return(false);

            case "codepage":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                _codePage = Util.GetNonNegativeIntegerAttribute(name, value);

                // Call Encoding.GetEncoding just to verify validity
                Encoding.GetEncoding(_codePage);

                // Return false to let the generic attribute processing continue
                return(false);

            case "transaction":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                ParseTransactionAttribute(name, value);
                break;

            case "aspcompat":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                flags[aspCompatMode] = Util.GetBooleanAttribute(name, value);

                // Only allow the use of aspcompat when we have UnmanagedCode access (ASURT 76694)
                if (flags[aspCompatMode] && !HttpRuntime.HasUnmanagedPermission())
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "AspCompat"));
                }

                break;

            case "async":
                // This only makes sense for compiled pages
                OnFoundAttributeRequiringCompilation(name);

                flags[asyncMode] = Util.GetBooleanAttribute(name, value);

                // Async requires Medium trust
                if (!HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium))
                {
                    throw new HttpException(SR.GetString(SR.Insufficient_trust_for_attribute, "async"));
                }

                break;

            case "tracemode":
                // We use TraceModeInternal instead of TraceMode to disallow the 'default' value (ASURT 75783)
                object tmpObj = Util.GetEnumAttribute(name, value, typeof(TraceModeInternal));
                _traceMode = (TraceMode)tmpObj;
                break;

            case "trace":
                bool traceEnabled = Util.GetBooleanAttribute(name, value);
                if (traceEnabled)
                {
                    _traceEnabled = TraceEnable.Enable;
                }
                else
                {
                    _traceEnabled = TraceEnable.Disable;
                }
                break;

            case "smartnavigation":
                // Make sure no device filter or expression builder was specified, since it doesn't make much
                // sense for smartnav (which only works on IE5.5+) (VSWhidbey 85876)
                ValidateBuiltInAttribute(deviceName, name, value);

                // Ignore it if it has default value.  Otherwise, let the generic
                // attribute processing continue
                bool smartNavigation = Util.GetBooleanAttribute(name, value);
                return(smartNavigation == Page.SmartNavigationDefault);

            case "maintainscrollpositiononpostback":
                bool maintainScrollPosition = Util.GetBooleanAttribute(name, value);
                return(maintainScrollPosition == Page.MaintainScrollPositionOnPostBackDefault);

            case "validaterequest":
                flags[validateRequest] = Util.GetBooleanAttribute(name, value);
                break;

            case "clienttarget":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                // Check validity
                HttpCapabilitiesDefaultProvider.GetUserAgentFromClientTarget(CurrentVirtualPath, value);

                // Return false to let the generic attribute processing continue
                return(false);

            case "masterpagefile":
                // Skip validity check for expression builder (e.g. <%$ ... %>)
                if (IsExpressionBuilderValue(value))
                {
                    return(false);
                }

                if (value.Length > 0)
                {
                    // Add dependency on the Type by calling this method
                    Type type = GetReferencedType(value);

                    // Make sure it has the correct base type
                    if (!typeof(MasterPage).IsAssignableFrom(type))
                    {
                        ProcessError(SR.GetString(SR.Invalid_master_base, value));
                    }

                    if (deviceName.Length > 0)
                    {
                        // Make sure the masterPageFile definition from config
                        // is applied before filtered masterPageFile attributes.
                        EnsureMasterPageFileFromConfigApplied();
                    }
                }

                //VSWhidbey 479064 Remember the masterPageFile had been set even if it's empty string
                _mainDirectiveMasterPageSet = true;

                // Return false to let the generic attribute processing continue
                return(false);

            default:
                // We didn't handle the attribute.  Try the base class
                return(base.ProcessMainDirectiveAttribute(deviceName, name, value, parseData));
            }

            // The attribute was handled

            // Make sure no device filter or resource expression was specified
            ValidateBuiltInAttribute(deviceName, name, value);

            return(true);
        }