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


C# Walker.WalkProperties方法代码示例

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


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

示例1: ValidateProperties

        public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (obj == null)
                throw new ArgumentNullException("obj");

            ValidationErrorCollection errors = new ValidationErrorCollection();

            Activity activity = manager.Context[typeof(Activity)] as Activity;

            // Validate all members that support validations.
            Walker walker = new Walker(true);
            walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
            {
                //If we find dynamic property of the same name then we do not invoke the validator associated with the property
                //Attached dependency properties will not be found by FromName().

                // args.CurrentProperty can be null if the property is of type IList.  The walker would go into each item in the
                // list, but we don't need to validate these items.
                if (args.CurrentProperty != null)
                {
                    DependencyProperty dependencyProperty = DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType);
                    if (dependencyProperty == null)
                    {
                        object[] validationVisibilityAtrributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
                        ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
                        if (validationVisibility != ValidationOption.None)
                        {
                            errors.AddRange(ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
                            // don't probe into subproperties as validate object inside the ValidateProperties call does it for us
                            args.Action = WalkerAction.Skip;
                        }
                    }
                }
            };

            walker.WalkProperties(activity, obj);

            return errors;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:41,代码来源:Validator.cs

示例2: GenerateCode

        public virtual void GenerateCode(CodeGenerationManager manager, object obj)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (obj == null)
                throw new ArgumentNullException("obj");

            Activity activity = obj as Activity;
            if (activity == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj");

            manager.Context.Push(activity);

            // Generate code for all the member Binds.
            Walker walker = new Walker();
            walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
            {
                //
                ActivityBind bindBase = args.CurrentValue as ActivityBind;
                if (bindBase != null)
                {
                    // push
                    if (args.CurrentProperty != null)
                        manager.Context.Push(args.CurrentProperty);
                    manager.Context.Push(args.CurrentPropertyOwner);

                    // call generate code
                    foreach (ActivityCodeGenerator codeGenerator in manager.GetCodeGenerators(bindBase.GetType()))
                        codeGenerator.GenerateCode(manager, args.CurrentValue);

                    // pops
                    manager.Context.Pop();
                    if (args.CurrentProperty != null)
                        manager.Context.Pop();
                }
            };
            walker.WalkProperties(activity, obj);
            manager.Context.Pop();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:39,代码来源:ActivityCodeGenerator.cs

示例3: OnRefreshTypes

        private void OnRefreshTypes(object sender, EventArgs e)
        {
            if (this.refreshTypesHandler != null)
            {
                WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
                if (workflowView != null)
                    workflowView.Idle -= this.refreshTypesHandler;
                this.refreshTypesHandler = null;
            }

            IDesignerHost designerHost = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
            Activity rootActivity = (designerHost != null) ? designerHost.RootComponent as Activity : null;
            if (rootActivity == null)
                return;

            //Now Refresh the types as well as the designer actions
            ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
            if (typeProvider != null)
            {
                Walker walker = new Walker();
                walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
                {
                    if (args.CurrentValue != null &&
                        args.CurrentProperty != null &&
                        args.CurrentProperty.PropertyType == typeof(System.Type) &&
                        args.CurrentValue is System.Type)
                    {
                        Type updatedType = typeProvider.GetType(((Type)args.CurrentValue).FullName);
                        if (updatedType != null)
                        {
                            args.CurrentProperty.SetValue(args.CurrentPropertyOwner, updatedType, null);

                            if (args.CurrentActivity != null)
                                TypeDescriptor.Refresh(args.CurrentActivity);
                        }
                    }
                    else if (args.CurrentProperty == null && args.CurrentValue is DependencyObject && !(args.CurrentValue is Activity))
                    {
                        walker.WalkProperties(args.CurrentActivity, args.CurrentValue);
                    }
                };
                walker.FoundActivity += delegate(Walker w, WalkerEventArgs args)
                {
                    if (args.CurrentActivity != null)
                    {
                        TypeDescriptor.Refresh(args.CurrentActivity);

                        ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(args.CurrentActivity);
                        if (activityDesigner != null)
                            activityDesigner.RefreshDesignerActions();

                        InvokeWorkflowDesigner invokeWorkflowDesigner = activityDesigner as InvokeWorkflowDesigner;
                        if (invokeWorkflowDesigner != null)
                            invokeWorkflowDesigner.RefreshTargetWorkflowType();
                    }
                };

                walker.Walk(rootActivity);
            }

            IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;
            if (propertyValueService != null)
                propertyValueService.NotifyPropertyValueUIItemsChanged();

            RefreshTasks();
            RefreshDesignerActions();
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:67,代码来源:XomlDesignerLoader.cs


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