Ewl » Canonical The canonical version of EWL Read More
Clone URL:  
Pushed to 3 repositories · View In Graph Contained in tip and canonical

Created AllowsSearchEngineIndexing properties to enable EWF resources to prevent
themselves from being indexed.

Changeset 187bd3fbffce

Parent 6db69c8e83bc

by Profile picture of William GrossWilliam Gross

Changes to 3 files · Browse files at 187bd3fbffce Showing diff from parent 6db69c8e83bc Diff from another changeset...

 
49
50
51
52
 
53
54
55
 
59
60
61
62
 
63
64
65
66
67
 
68
69
70
 
84
85
86
87
 
88
89
90
 
96
97
98
99
100
101
 
 
 
102
103
 
 
49
50
51
 
52
53
54
55
 
59
60
61
 
62
63
64
65
66
 
67
68
69
70
 
84
85
86
 
87
88
89
90
 
96
97
98
 
 
 
99
100
101
102
103
 
@@ -49,7 +49,7 @@
  /// <summary>   /// Gets the list of resource info objects for the resources that are part of this entity setup.   /// </summary> - public ReadOnlyCollection<ResourceGroup> Resources { get { return resources ?? ( resources = createResourceInfos().AsReadOnly() ); } } + public ReadOnlyCollection<ResourceGroup> Resources => resources ?? ( resources = createResourceInfos().AsReadOnly() );     /// <summary>   /// Returns the name of the entity setup. @@ -59,12 +59,12 @@
  /// <summary>   /// Returns true if the authenticated user passes entity setup authorization checks.   /// </summary> - protected internal virtual bool UserCanAccessEntitySetup { get { return true; } } + protected internal virtual bool UserCanAccessEntitySetup => true;     /// <summary>   /// Gets the log in page to use for resources that are part of this entity setup if the system supports forms authentication.   /// </summary> - protected internal virtual PageInfo LogInPage { get { return ParentResource != null ? ParentResource.LogInPage : null; } } + protected internal virtual PageInfo LogInPage => ParentResource?.LogInPage;     /// <summary>   /// Gets the alternative mode for this entity setup or null if it is in normal mode. Do not call this from the createAlternativeMode method of an ancestor; @@ -84,7 +84,7 @@
  /// e.g. when implementing a parent that should have new content when one or more children have new content. When calling this property take care to meet   /// any preconditions that would normally be handled by ancestor logic.   /// </summary> - public AlternativeResourceMode AlternativeModeDirect { get { return alternativeMode.Value; } } + public AlternativeResourceMode AlternativeModeDirect => alternativeMode.Value;     /// <summary>   /// Creates the alternative mode for this entity setup or returns null if it is in normal mode. @@ -96,8 +96,8 @@
  /// <summary>   /// Gets the desired security setting for requests to resources that are part of this entity setup.   /// </summary> - protected internal virtual ConnectionSecurity ConnectionSecurity { - get { return ParentResource != null ? ParentResource.ConnectionSecurity : ConnectionSecurity.SecureIfPossible; } - } + protected internal virtual ConnectionSecurity ConnectionSecurity => ParentResource?.ConnectionSecurity ?? ConnectionSecurity.SecureIfPossible; + + protected internal virtual bool? AllowsSearchEngineIndexing => ParentResource?.AllowsSearchEngineIndexing;   }  } \ No newline at end of file
 
76
77
78
79
 
80
81
82
 
93
94
95
96
 
97
98
99
 
100
101
102
 
105
106
107
108
 
109
110
111
112
113
114
115
116
117
118
119
120
 
 
 
 
 
121
122
123
 
165
166
167
168
 
169
170
171
172
173
 
174
175
176
 
205
206
207
208
 
209
210
211
 
243
244
245
246
247
248
 
249
250
251
 
260
261
262
 
 
 
 
 
 
 
 
 
 
263
264
265
 
76
77
78
 
79
80
81
82
 
93
94
95
 
96
97
 
 
98
99
100
101
 
104
105
106
 
107
108
109
110
111
 
 
 
 
 
 
 
 
112
113
114
115
116
117
118
119
 
161
162
163
 
164
165
166
167
168
 
169
170
171
172
 
201
202
203
 
204
205
206
207
 
239
240
241
 
 
 
242
243
244
245
 
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
@@ -76,7 +76,7 @@
  /// <summary>   /// Gets the resource info object for the parent resource of this resource. Returns null if there is no parent resource.   /// </summary> - public ResourceInfo ParentResource { get { return parentResource.Value; } } + public ResourceInfo ParentResource => parentResource.Value;     /// <summary>   /// Creates a resource info object for the parent resource of this resource. Returns null if there is no parent resource. @@ -93,10 +93,9 @@
  // NOTE: If we used recursion this would be much simpler.   var path = new List<ResourceInfo>();   var resource = this; - do { + do   path.Add( resource ); - } - while( ( resource = resource.ParentResource ?? ( resource.EsInfoAsBaseType != null ? resource.EsInfoAsBaseType.ParentResource : null ) ) != null ); + while( ( resource = resource.ParentResource ?? resource.EsInfoAsBaseType?.ParentResource ) != null );   path.Reverse();   return path;   } @@ -105,19 +104,16 @@
  /// <summary>   /// Returns the name of the resource.   /// </summary> - public virtual string ResourceName { get { return GetType().DeclaringType.Name.CamelToEnglish(); } } + public virtual string ResourceName => GetType().DeclaringType.Name.CamelToEnglish();     /// <summary>   /// Returns the name of the resource, including the entity setup name if an entity setup exists.   /// </summary> - public string ResourceFullName { - get { - return CombineResourcePathStrings( - EntityResourceSeparator, - EsInfoAsBaseType != null && ParentResource == null ? EsInfoAsBaseType.EntitySetupName : "", - ResourceName ); - } - } + public string ResourceFullName => + CombineResourcePathStrings( + EntityResourceSeparator, + EsInfoAsBaseType != null && ParentResource == null ? EsInfoAsBaseType.EntitySetupName : "", + ResourceName );     /// <summary>   /// Returns the string representing the parent resource's path within the entity. @@ -165,12 +161,12 @@
  /// <summary>   /// Gets whether the resource is public in intermediate installations.   /// </summary> - protected internal virtual bool IsIntermediateInstallationPublicResource { get { return false; } } + protected internal virtual bool IsIntermediateInstallationPublicResource => false;     /// <summary>   /// Returns true if the authenticated user passes resource-level authorization checks.   /// </summary> - protected virtual bool userCanAccessResource { get { return true; } } + protected virtual bool userCanAccessResource => true;     /// <summary>   /// Gets the log in page to use for this resource if the system supports forms authentication. @@ -205,7 +201,7 @@
  /// when implementing a parent that should have new content when one or more children have new content. When calling this property take care to meet any   /// preconditions that would normally be handled by ancestor logic.   /// </summary> - public AlternativeResourceMode AlternativeModeDirect { get { return alternativeMode.Value; } } + public AlternativeResourceMode AlternativeModeDirect => alternativeMode.Value;     /// <summary>   /// Creates the alternative mode for this resource or returns null if it is in normal mode. @@ -243,9 +239,7 @@
  /// </summary>   protected abstract string buildUrl();   - internal bool ShouldBeSecureGivenCurrentRequest { - get { return ConnectionSecurity.ShouldBeSecureGivenCurrentRequest( IsIntermediateInstallationPublicResource ); } - } + internal bool ShouldBeSecureGivenCurrentRequest => ConnectionSecurity.ShouldBeSecureGivenCurrentRequest( IsIntermediateInstallationPublicResource );     /// <summary>   /// Gets the desired security setting for requests to the resource. @@ -260,6 +254,16 @@
  }   }   + protected internal virtual bool? AllowsSearchEngineIndexing { + get { + if( ParentResource != null ) + return ParentResource.AllowsSearchEngineIndexing; + if( EsInfoAsBaseType != null ) + return EsInfoAsBaseType.AllowsSearchEngineIndexing; + return null; + } + } +   /// <summary>   /// Returns true if this resource info object is identical to the current resource info object. The comparison excludes optional parameters that haven't   /// been explicitly set.
 
47
48
49
50
 
 
51
52
53
54
55
56
 
 
57
58
59
 
90
91
92
93
 
 
 
 
94
95
96
 
309
310
311
312
313
 
 
 
314
315
316
 
463
464
465
466
 
 
467
468
469
 
482
483
484
485
486
487
 
488
489
490
 
606
607
608
609
 
 
610
611
612
 
627
628
629
630
631
 
632
633
634
 
853
854
855
856
 
 
 
857
858
859
 
1023
1024
1025
 
 
1026
1027
1028
 
1099
1100
1101
1102
1103
1104
1105
 
 
 
 
 
1106
1107
1108
 
47
48
49
 
50
51
52
53
54
55
56
 
57
58
59
60
61
 
92
93
94
 
95
96
97
98
99
100
101
 
314
315
316
 
 
317
318
319
320
321
322
 
469
470
471
 
472
473
474
475
476
 
489
490
491
 
 
 
492
493
494
495
 
611
612
613
 
614
615
616
617
618
 
633
634
635
 
 
636
637
638
639
 
858
859
860
 
861
862
863
864
865
866
 
1030
1031
1032
1033
1034
1035
1036
1037
 
1108
1109
1110
 
 
 
 
1111
1112
1113
1114
1115
1116
1117
1118
@@ -47,13 +47,15 @@
  postBack => {   if( Instance.GetPostBack( postBack.Id ) != postBack )   throw new ApplicationException( "The post-back must have been added to the page." ); - if( ( postBack as ActionPostBack )?.ValidationDm is PostBack validationPostBack && Instance.GetPostBack( validationPostBack.Id ) != validationPostBack ) + if( ( postBack as ActionPostBack )?.ValidationDm is PostBack validationPostBack && + Instance.GetPostBack( validationPostBack.Id ) != validationPostBack )   throw new ApplicationException( "The post-back's validation data-modification, if it is a post-back, must have been added to the page." );   } );   FormState.Init(   () => Instance.formState,   dataModifications => { - if( dataModifications.Contains( Instance.dataUpdate ) && dataModifications.Any( i => i != Instance.dataUpdate && !( (ActionPostBack)i ).IsIntermediate ) ) + if( dataModifications.Contains( Instance.dataUpdate ) && + dataModifications.Any( i => i != Instance.dataUpdate && !( (ActionPostBack)i ).IsIntermediate ) )   throw new ApplicationException(   "If the data-update modification is included, it is meaningless to include any full post-backs since these inherently update the page's data." );   }, @@ -90,7 +92,10 @@
  internal readonly ModalBoxId BrowsingModalBoxId = new ModalBoxId();   private readonly BasicDataModification dataUpdate = new BasicDataModification();   private readonly PostBack dataUpdatePostBack = PostBack.CreateDataUpdate(); - internal readonly Dictionary<PageComponent, IReadOnlyCollection<Control>> ControlsByComponent = new Dictionary<PageComponent, IReadOnlyCollection<Control>>(); + + internal readonly Dictionary<PageComponent, IReadOnlyCollection<Control>> ControlsByComponent = + new Dictionary<PageComponent, IReadOnlyCollection<Control>>(); +   private readonly Dictionary<Control, List<EtherealControl>> etherealControlsByControl = new Dictionary<Control, List<EtherealControl>>();   private readonly Dictionary<string, PostBack> postBacksById = new Dictionary<string, PostBack>();   private readonly List<FormValue> formValues = new List<FormValue>(); @@ -309,8 +314,9 @@
  formValues.Any( i => i.GetPostBackValueKey().Any() && i.PostBackValueIsInvalid( requestState.PostBackValues ) ) )   throw getPossibleDeveloperMistakeException(   requestState.ModificationErrorsExist - ? "Form controls, modification-error-display keys, and post-back IDs may not change if modification errors exist." + - " (IMPORTANT: This exception may have been thrown because EWL Goal 588 hasn't been completed. See the note in the goal about the EwfPage bug and disregard the rest of this error message.)" + ? + "Form controls, modification-error-display keys, and post-back IDs may not change if modification errors exist." + + " (IMPORTANT: This exception may have been thrown because EWL Goal 588 hasn't been completed. See the note in the goal about the EwfPage bug and disregard the rest of this error message.)"   : new[] { SecondaryPostBackOperation.Validate, SecondaryPostBackOperation.ValidateChangesOnly }.Contains( dmIdAndSecondaryOp.Item2 )   ? "Form controls outside of update regions may not change on an intermediate post-back."   : "Form controls and post-back IDs may not change during the validation stage of an intermediate post-back." ); @@ -463,7 +469,8 @@
  Response.StatusCode = 400;   Response.TrySkipIisCustomErrors = true;   AppRequestState.Instance.EwfPageRequestState.FocusKey = ""; - AppRequestState.Instance.EwfPageRequestState.GeneralModificationErrors = Translation.ApplicationHasBeenUpdatedAndWeCouldNotInterpretAction.ToCollection(); + AppRequestState.Instance.EwfPageRequestState.GeneralModificationErrors = + Translation.ApplicationHasBeenUpdatedAndWeCouldNotInterpretAction.ToCollection();   resetPage();   }   @@ -482,9 +489,7 @@
  if( postBack == null )   throw new DataModificationException( Translation.AnotherUserHasModifiedPageAndWeCouldNotInterpretAction );   var lastPostBackFailingDm = postBack.IsIntermediate && lastPostBackFailingDmId != null - ? lastPostBackFailingDmId.Any() - ? GetPostBack( lastPostBackFailingDmId ) as DataModification - : dataUpdate + ? lastPostBackFailingDmId.Any() ? GetPostBack( lastPostBackFailingDmId ) as DataModification : dataUpdate   : null;   if( postBack.IsIntermediate && lastPostBackFailingDmId != null && lastPostBackFailingDm == null )   throw new DataModificationException( Translation.AnotherUserHasModifiedPageAndWeCouldNotInterpretAction ); @@ -606,7 +611,8 @@
    var duplicatePostBackValueKeys = formValues.Select( i => i.GetPostBackValueKey() ).Where( i => i.Any() ).GetDuplicates().ToArray();   if( duplicatePostBackValueKeys.Any() ) - throw new ApplicationException( "Duplicate post-back-value keys exist: " + StringTools.ConcatenateWithDelimiter( ", ", duplicatePostBackValueKeys ) + "." ); + throw new ApplicationException( + "Duplicate post-back-value keys exist: " + StringTools.ConcatenateWithDelimiter( ", ", duplicatePostBackValueKeys ) + "." );     ClientScript.RegisterHiddenField( postBackHiddenFieldName, "" );   @@ -627,8 +633,7 @@
  Header.Controls.Add(   new HtmlMeta   { - Name = "application-name", - Content = EwfApp.Instance.AppDisplayName.Length > 0 ? EwfApp.Instance.AppDisplayName : ConfigurationStatics.SystemName + Name = "application-name", Content = EwfApp.Instance.AppDisplayName.Length > 0 ? EwfApp.Instance.AppDisplayName : ConfigurationStatics.SystemName   } );     // Chrome start URL @@ -853,7 +858,9 @@
  var requestState = AppRequestState.Instance.EwfPageRequestState;     var webFormsHiddenFields = new[] - { "__EVENTTARGET", "__EVENTARGUMENT", "__LASTFOCUS", "__VIEWSTATE", "__SCROLLPOSITIONX", "__SCROLLPOSITIONY", "__VIEWSTATEGENERATOR" }; + { + "__EVENTTARGET", "__EVENTARGUMENT", "__LASTFOCUS", "__VIEWSTATE", "__SCROLLPOSITIONX", "__SCROLLPOSITIONY", "__VIEWSTATEGENERATOR" + };   var activeFormValues = formValues.Where( i => i.GetPostBackValueKey().Any() ).ToArray();   var postBackValueKeys = new HashSet<string>( activeFormValues.Select( i => i.GetPostBackValueKey() ) );   requestState.PostBackValues = new PostBackValueDictionary(); @@ -1023,6 +1030,8 @@
  // Direct response object modifications. These should happen once per page view; they are not needed in redirect responses.     FormsAuthStatics.UpdateFormsAuthCookieIfNecessary(); + if( InfoAsBaseType.AllowsSearchEngineIndexing == false ) + Response.AppendHeader( "X-Robots-Tag", "noindex" );     // Without this header, certain sites could be forced into compatibility mode due to the Compatibility View Blacklist maintained by Microsoft.   Response.AppendHeader( "X-UA-Compatible", "IE=edge" ); @@ -1099,10 +1108,11 @@
  "$( document ).ready( function() { " + StringTools.ConcatenateWithDelimiter(   " ",   "OnDocumentReady();", - "$( '#aspnetForm' ).submit( function( e, postBackId ) {{ postBackRequestStarting( e, postBackId !== undefined ? postBackId : '{0}' ); }} );".FormatWith( - SubmitButtonPostBack != null - ? SubmitButtonPostBack.Id - : "" /* This empty string we're using when no submit button exists is arbitrary and meaningless; it should never actually be submitted. */ ), + "$( '#aspnetForm' ).submit( function( e, postBackId ) {{ postBackRequestStarting( e, postBackId !== undefined ? postBackId : '{0}' ); }} );" + .FormatWith( + SubmitButtonPostBack != null + ? SubmitButtonPostBack.Id + : "" /* This empty string we're using when no submit button exists is arbitrary and meaningless; it should never actually be submitted. */ ),   controlInitStatements,   EwfApp.Instance.JavaScriptDocumentReadyFunctionCall.AppendDelimiter( ";" ),   javaScriptDocumentReadyFunctionCall.AppendDelimiter( ";" ),