当前位置: 首页>>代码示例>>C#>>正文


C# ControlBuilder.EnsureEntriesSorted方法代码示例

本文整理汇总了C#中System.Web.UI.ControlBuilder.EnsureEntriesSorted方法的典型用法代码示例。如果您正苦于以下问题:C# ControlBuilder.EnsureEntriesSorted方法的具体用法?C# ControlBuilder.EnsureEntriesSorted怎么用?C# ControlBuilder.EnsureEntriesSorted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.ControlBuilder的用法示例。


在下文中一共展示了ControlBuilder.EnsureEntriesSorted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildBuildMethod

        /*
         * Build the data tree for a control's build method
         */
        protected CodeMemberMethod BuildBuildMethod(ControlBuilder builder, bool fTemplate,
            bool fInTemplate, bool topLevelControlInTemplate, PropertyEntry pse, bool fControlSkin) {

            Debug.Assert(builder.ServiceProvider == null);

            ServiceContainer container = new ServiceContainer();
            container.AddService(typeof(IFilterResolutionService), HttpCapabilitiesBase.EmptyHttpCapabilitiesBase);

            try {
                builder.SetServiceProvider(container);
                builder.EnsureEntriesSorted();
            }
            finally {
                builder.SetServiceProvider(null);
            }

            string methodName = GetMethodNameForBuilder(buildMethodPrefix, builder);
            Type ctrlType = GetCtrlTypeForBuilder(builder, fTemplate);
            bool fStandardControl = false;
            bool fControlFieldDeclared = false;

            CodeMemberMethod method = new CodeMemberMethod();
            AddDebuggerNonUserCodeAttribute(method);
            method.Name = methodName;
            method.Attributes = MemberAttributes.Private | MemberAttributes.Final;

            _sourceDataClass.Members.Add(method);

            // If it's for a template or a r/o complex prop, pass a parameter of the control's type
            ComplexPropertyEntry cpse = pse as ComplexPropertyEntry;
            if (fTemplate || (cpse != null && cpse.ReadOnly)) {
                if (builder is RootBuilder)
                    method.Parameters.Add(new CodeParameterDeclarationExpression(_sourceDataClass.Name, "__ctrl"));
                else
                    method.Parameters.Add(new CodeParameterDeclarationExpression(ctrlType, "__ctrl"));
            }
            else {
                // If it's a standard control, return it from the method
                if (typeof(Control).IsAssignableFrom(builder.ControlType)) {
                    fStandardControl = true;
                }

                Debug.Assert(builder.ControlType != null);
                if (builder.ControlType != null) {
                    if (fControlSkin) {
                        // ReturnType needs to be of type Control in a skin file to match
                        // the controlskin delegate.
                        if (fStandardControl) {
                            method.ReturnType = new CodeTypeReference(typeof(Control));
                        }
                    }
                    else {
                        PartialCachingAttribute cacheAttrib = (PartialCachingAttribute)
                            TypeDescriptor.GetAttributes(builder.ControlType)[typeof(PartialCachingAttribute)];
                        if (cacheAttrib != null) {
                            method.ReturnType = new CodeTypeReference(typeof(Control));
                        }
                        else {
                            // Otherwise the return type is always the actual component type.
                            method.ReturnType = CodeDomUtility.BuildGlobalCodeTypeReference(builder.ControlType);
                        }
                    }
                }

                // A control field declaration is required, this field will be returned
                // in the method.
                fControlFieldDeclared = true;
            }

            // Add a control parameter if it's a ControlSkin
            if (fControlSkin) {
                method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(Control).FullName, "ctrl"));
            }

            BuildBuildMethodInternal(builder, builder.ControlType, fInTemplate, topLevelControlInTemplate, pse,
                method.Statements, fStandardControl, fControlFieldDeclared, null, fControlSkin);

            return method;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:82,代码来源:BaseTemplateCodeDomTreeGenerator.cs

示例2: BuildBuildMethod

 protected CodeMemberMethod BuildBuildMethod(ControlBuilder builder, bool fTemplate, bool fInTemplate, bool topLevelControlInTemplate, PropertyEntry pse, bool fControlSkin)
 {
     ServiceContainer serviceProvider = new ServiceContainer();
     serviceProvider.AddService(typeof(IFilterResolutionService), HttpCapabilitiesBase.EmptyHttpCapabilitiesBase);
     try
     {
         builder.SetServiceProvider(serviceProvider);
         builder.EnsureEntriesSorted();
     }
     finally
     {
         builder.SetServiceProvider(null);
     }
     string methodNameForBuilder = this.GetMethodNameForBuilder(buildMethodPrefix, builder);
     Type ctrlTypeForBuilder = this.GetCtrlTypeForBuilder(builder, fTemplate);
     bool fStandardControl = false;
     bool fControlFieldDeclared = false;
     CodeMemberMethod method = new CodeMemberMethod();
     base.AddDebuggerNonUserCodeAttribute(method);
     method.Name = methodNameForBuilder;
     method.Attributes = MemberAttributes.Private | MemberAttributes.Final;
     base._sourceDataClass.Members.Add(method);
     ComplexPropertyEntry entry = pse as ComplexPropertyEntry;
     if (fTemplate || ((entry != null) && entry.ReadOnly))
     {
         if (builder is RootBuilder)
         {
             method.Parameters.Add(new CodeParameterDeclarationExpression(base._sourceDataClass.Name, "__ctrl"));
         }
         else
         {
             method.Parameters.Add(new CodeParameterDeclarationExpression(ctrlTypeForBuilder, "__ctrl"));
         }
     }
     else
     {
         if (typeof(Control).IsAssignableFrom(builder.ControlType))
         {
             fStandardControl = true;
         }
         if (builder.ControlType != null)
         {
             if (fControlSkin)
             {
                 if (fStandardControl)
                 {
                     method.ReturnType = new CodeTypeReference(typeof(Control));
                 }
             }
             else if (((PartialCachingAttribute) TypeDescriptor.GetAttributes(builder.ControlType)[typeof(PartialCachingAttribute)]) != null)
             {
                 method.ReturnType = new CodeTypeReference(typeof(Control));
             }
             else
             {
                 method.ReturnType = CodeDomUtility.BuildGlobalCodeTypeReference(builder.ControlType);
             }
         }
         fControlFieldDeclared = true;
     }
     if (fControlSkin)
     {
         method.Parameters.Add(new CodeParameterDeclarationExpression(typeof(Control).FullName, "ctrl"));
     }
     this.BuildBuildMethodInternal(builder, builder.ControlType, fInTemplate, topLevelControlInTemplate, pse, method.Statements, fStandardControl, fControlFieldDeclared, null, fControlSkin);
     return method;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:67,代码来源:BaseTemplateCodeDomTreeGenerator.cs


注:本文中的System.Web.UI.ControlBuilder.EnsureEntriesSorted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。