增强配置文件提供程序

Posted

技术标签:

【中文标题】增强配置文件提供程序【英文标题】:Enhancing Profile Provider 【发布时间】:2010-09-18 23:00:46 【问题描述】:

我想为我正在编写的自定义向导序列化和数组对象,但我在执行此操作时遇到了困难。有人可以帮助这是我正在使用的错误和代码 sn-ps。

我认为该错误与无法转换数组有关。

namespace Helios.Web.Framework

    /// <summary>
    /// Summary description for GlobalWizardMethods
    /// </summary>
    public class GlobalWizardsLibrary : Wizards
    
        public GlobalWizardsLibrary()  
        public WizardBase CreateWizardArray(Wizards wizards)
        
            WizardBase[] b = new WizardBase[wizards.IListWizardBase.Count];
            for (int i = 0; i < b.Length; i++)
            
                b[i] = (WizardBase)wizards.IListWizardBase[i];
            
            return b;
        
    

--

        wizards = new Wizards();
        wizards.IListWizardBase = new List<WizardBase>();

        //if (wizards.WizardBase[0] == null)
        //
            clientTakeOnWizardInfo = new ClientTakeOnWizardInfo();

            //Create any preset data to identify the client and wizard.
            CreatePresetWizardInfo();

            //Instantiate a new instance of the clientTakeOnWizard.organisationDetails.
            clientTakeOnWizardInfo.organisationDetails = new OrganisationDetails();

            //We update the Organisation Details with the new values from the form.
            clientTakeOnWizardInfo.organisationDetails.Guid = Profile.Wizards.WizardId.ToString();
            clientTakeOnWizardInfo.organisationDetails.OrganisationName = this.OrganisationName.Text;
            clientTakeOnWizardInfo.organisationDetails.PayrollSystem = this.PayrollSystem.SelectedValue;
            clientTakeOnWizardInfo.organisationDetails.Region = this.Region.SelectedValue;
            clientTakeOnWizardInfo.organisationDetails.RegistrationNumber = this.RegistrationNumber.Text;

            //Profile.Wizards.WizardData = clientTakeOnWizardInfo;

            Profile.Wizards.WizardStep = wizardClientTakeOnWizard.ActiveStepIndex;

            wizards.IListWizardBase.Add(clientTakeOnWizardInfo);
            GlobalWizardsLibrary s = new GlobalWizardsLibrary();
            s.CreateWizardArray(wizards);

Error 16 Cannot implicitly convert type 
    'Helios.Web.Framework.WizardBase[]' to 
    'Helios.Web.Framework.WizardBase'
    C:\...\GlobalWizardsLibrary.cs  34  20  
C:\...\HeliosWeb\

【问题讨论】:

【参考方案1】:

功能:

public WizardBase CreateWizardArray(Wizards wizards)

...返回的是局部变量 b,它被声明为 WizardBase[],而不是 WizardBase

据我所知,这里根本没有进行序列化。该函数应该是:

public WizardBase [] CreateWizardArray(Wizards wizards)

我还要指出,该函数实际上并没有做任何非常有用的事情,它只是将 List 的元素复制到 Array(通过引用)...

【讨论】:

以上是关于增强配置文件提供程序的主要内容,如果未能解决你的问题,请参考以下文章

关于xml配置实现AOP的小知识

配置SSH备份源

启用IE增强安全配置时,msSaveBlob,msSaveOrOpenBlob失败

Spring框架中的aop操作之二 通过配置文件实现增强

提供具有适当权利的配置文件可防止推送通知注册

Spring添加声明式事务