using reflection in CSLA 2.0

using reflection in CSLA 2.0

Old forum URL: forums.lhotka.net/forums/t/10169.aspx


prosarfraz posted on Wednesday, March 16, 2011

hi everyone.

i am using following  code with CSLA 2.0

[ Serializable ()]

public class WebLeadFilter : BusinessBase<WebLeadFilter>

{// Declare variables here to contain object state

private WebLeadFilters _webLeadFilter = WebLeadFilters.MyWebLeads;

private static ResourceManager _manager = new ResourceManager("IDS.G2.BusinessObjects.CRM.Enums.WebLeadFilter", System.Reflection.Assembly.GetExecutingAssembly());

#region Business Properties and Methods

// Implement properties and methods here so the UI or

// other client code can interact with the object

public int  ID

{ get {return (int)_webLeadFilter;}

   set{_webLeadFilter = (WebLeadFilters)value;}

}

public string Name

{

get{return _manager.GetString("WebLeadFilter-" + (int)_webLeadFilter);}

}

internal void SetName(string newValue)

{ for (int i = 0; i < 7; i++)

{

if (_manager.GetString("WebLeadFilter-" + i) == newValue)

{ID = i; break;}

}

}

protected override object GetIdValue()

{return ID;}

#endregion

#region Enum

public enum WebLeadFilters

{

[Description("All Web Leads")] AllWebLeads = 0,

[Description("My Web Leads")] MyWebLeads = 1

}

#endregion

#region Static Methods

public static WebLeadFilter NewWebLeadFilter()

{return new WebLeadFilter();}

#endregion

#region Constructors

private WebLeadFilter()

{// Prevent direct creation}

#endregion

}

 

 

while in the form code behind i use following code to retrieve enumeration values

WebLeadFilter lead = WebLeadFilter.NewWebLeadFilter();

Array enumValues = System.Enum.GetValues(typeof(WebLeadFilter.WebLeadFilters)); ;

foreach (object item in enumValues)

{ lead.ID = (int)item;

 cboView.Items.Add(lead));

}

but getting the the _manager object is NULL in the BOLD line of code, i dont know why. any clues?

 

Copyright (c) Marimer LLC