예제 #1
0
 /// <summary>
 /// Creates a display setup object for display that depends on this page-modification-value condition.
 /// </summary>
 public static DisplaySetup ToDisplaySetup(this PageModificationValueCondition pageModificationValueCondition) =>
 new DisplaySetup(
     Tuple.Create <Action <string>, Action <string> >(
         statements => pageModificationValueCondition.AddJsModificationStatement(
             expression => "if( {0} )".FormatWith(expression) + " { " + statements + " }"),
         statements => pageModificationValueCondition.AddJsModificationStatement(
             expression => "if( !( {0} ) )".FormatWith(expression) + " { " + statements + " }")),
     () => pageModificationValueCondition.IsTrue);
        // Web Forms compatibility. Remove when EnduraCode goal 790 is complete.
        public static void AddDisplayLink(this PageModificationValueCondition pageModificationValueCondition, IEnumerable <WebControl> controls)
        {
            controls = controls.ToImmutableArray();

            foreach (var control in controls)
            {
                pageModificationValueCondition.AddJsModificationStatement(expression => "setElementDisplay( '{0}', {1} );".FormatWith(control.ClientID, expression));
            }

            EwfPage.Instance.AddDisplayLink(new DisplayLinkAdapter(controls, () => pageModificationValueCondition.IsTrue));
        }