Click here to Skip to main content
       

C#

 
Questionhelp PinmemberAMIR ESLAMI17-Nov-12 10:08 
AnswerRe: help PinmemberEddy Vluggen17-Nov-12 10:25 
AnswerRe: help PinmvpAbhinav S18-Nov-12 21:58 
QuestionAccess to created control PinmemberKKW_acd17-Nov-12 6:18 
AnswerRe: Access to created control PinmentorDaveyM6917-Nov-12 8:30 
QuestionHow do you programatically open a file in c# to append? PinmemberXarzu17-Nov-12 2:05 
AnswerRe: How do you programatically open a file in c# to append? PinmentorDaveyM6917-Nov-12 2:35 
AnswerRe: How do you programatically open a file in c# to append? PinmemberEddy Vluggen17-Nov-12 10:32 
QuestionC# noob: Making Textbox entry a percentage, and Help with loops Pinmembermaul5916-Nov-12 19:46 
AnswerRe: C# noob: Making Textbox entry a percentage, and Help with loops PinmvpRichard MacCutchan16-Nov-12 21:43 
AnswerRe: C# noob: Making Textbox entry a percentage, and Help with loops PinmvpOriginalGriff16-Nov-12 22:40 
GeneralRe: C# noob: Making Textbox entry a percentage, and Help with loops Pinmembermaul5916-Nov-12 23:20 
GeneralRe: C# noob: Making Textbox entry a percentage, and Help with loops PinmvpOriginalGriff16-Nov-12 23:26 
QuestionInterface issue when implementing Factory pattern PinmemberMichCl16-Nov-12 9:36 
I'm having trouble with the interface for the Factory Design Pattern. I've looked at
http://dotnet.dzone.com/articles/design-patterns-c-factory,
which follows my design very closely since it was the first good example I found a while back.
I took a look at
http://stackoverflow.com/questions/27294/abstract-factory-design-pattern,
but my design is very different.
 
Right now, this is what it looks like. I have included a lot of code because I have a feeling the problem has to do with the visual studio project breakdown. It used to be more simple, with my CR5, interface, factory, CB_spec, El, etc in the same visual studio project. I had to move things around as shown per design discussions and the need for CR6, etc to be separate. Now I'm getting some compilation problems I'm not sure what to do with. See ** below for the first and worst. My question is regarding the compilation issue below.
 
My iCR Visual Studio project which is the interface:
 
public interface iCR
        {
            int CB_IO_Init(int slaveIndex);
            int WritePortReady();
            int WritePortBusy();
            void initCRData(byte[] writeBuffer, byte[] statusBuffer, int SlaveIndex, USB_Comm.CB cb, int cr_Type);
            int ProcessTWriting(ref Byte[] writeDat, ref Byte[] statusDat, ref Byte[] dataDumpWriteCheck);
            void Failure(String message);
            void Success(String message);
 
        }
 
My CR_Factory Visual Studio project
 
namespace CR_Factory
    {
 
    public class Cr
    {
         
    }  
 
    public class CRFactory
    {
        public enum CRType
        {
            CR0,
            CR1,
            CR3,
            CR4,
            CR5,
            CR6
        }
 
        public CRFactory()
        {
        }
 
        public iCR GetCR(CRType type) 
        {
            iCR cr = null;
            switch (type)
            {
                case CRType.CR5:
                    cr = new CR5(); 
                    break;
                case CRType.CR6:
                    //not done yet
                    break;
                default:
                    throw new ArgumentException(string.Format("A CR of type {0} cannot be found", Enum.GetName(typeof(CRType), type)));
            }
            return cr;
        }
 
        public CRType DetermineCR_Type(int type)
        {
            switch (type)
            {
                case 0:
                    return CRType.CR0;
                //break;
                case 1:
                    return CRType.CR1;
                case 3:
                    return CRType.CR3;
                case 4:
                    return CRType.CR4;
                case 5:
                    return CRType.CR5;
                case 6:
                    return CRType.CR6;
                default:
                    throw new ArgumentException(string.Format("A type of type {0} cannot be found", type));
 
            }
        }
 
        }
    }
 
My CR5 Visual Studio Project has a lot of classes in it, but right now I’m just showing you the part referred to in the factory. Later I’ll create a CR6 VS project, etc. As you can see, the compiler doesn't think I implemented initCRData but it's right there, and curly brackets are fine.
 
public class CR5 : iCR **compile error CR5_new.CR5 does not implement interface member iCR.initCRData(byte[],byte[],int,USB_Comm.CB,int)
    {        
        CB_703 cb_specific = null;
		
        //constructor
        public CR5()
        {
            cb_specific = new CB_703(SlaveIndex);
        }
 
        public void initCRData(byte[] writeBuffer, byte[] statusBuffer, int slaveIndex, USB_Comm.CB cb_specificInstance, int crType)
        {...
        }
 
        public int CB_IO_Init(int SlaveIndex)
        {
            int result = -534;
            result = cb_specific.IO_Init(SlaveIndex);
            return result;
        }
    .
    .
    .
    }
 
I have another Visual Studio Project (actually several) that instantiates the factory and gets the appropriate type. We’ll call it El:
 
namespace CrWr
    {
    
    public partial class PControl : UserControl
    {
        //setup 
	
        //constructor
        public PControl()
        {
            
        }
 
        /// <summary>
        /// Get the P Control for chosen dll
        /// </summary>
        public Control GetPControl(USB_Comm.CB cbInstance, string dllSelected, THandlerApplication.Temp.TEMP[] temp, string dll, SC.SC.S_C c0)
        {
            cb = cbInstance;
            createControls();
            itsDll = dll;
            tArr = temp;
            cert = c0;
      
            CR_Factory.CRFactory factory = new CR_Factory.CRFactory();
            CRFactory.CRType type = factory.DetermineCR_Type(cr_Type);
            try
            {
                cr = factory.GetCR(type);             }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }
            return this;
        }
 
    private void OnP()
        {
            int result = -536;
            
            while (rL)
            {
                result = cr.CB_IO_Init(SlaveIndex); 
                if (result == 0)
                {
                    …
                }
            }
 
    .
    .
    .
    }

AnswerRe: Interface issue when implementing Factory pattern PinmemberEddy Vluggen16-Nov-12 10:01 
GeneralRe: Interface issue when implementing Factory pattern PinmemberMichCl16-Nov-12 10:18 
GeneralRe: Interface issue when implementing Factory pattern PinmemberEddy Vluggen16-Nov-12 14:46 
GeneralRe: Interface issue when implementing Factory pattern PinmemberMichCl19-Nov-12 3:20 
AnswerRe: Interface issue when implementing Factory pattern PinmemberEddy Vluggen19-Nov-12 3:32 
GeneralRe: Interface issue when implementing Factory pattern PinmemberMichCl19-Nov-12 4:51 
GeneralRe: Interface issue when implementing Factory pattern PinmemberEddy Vluggen19-Nov-12 5:46 
GeneralRe: Interface issue when implementing Factory pattern PinmemberMichCl19-Nov-12 10:38 
GeneralRe: Interface issue when implementing Factory pattern PinmemberEddy Vluggen19-Nov-12 10:53 
QuestionIssue in accessing 32 bit C++ DLL in Windows Server 2008 PinmemberKumaran Poongavanam16-Nov-12 9:32 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 PinmemberEddy Vluggen16-Nov-12 10:04 
GeneralRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 PinmemberKumaran Poongavanam16-Nov-12 11:09 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 PinmvpDave Kreskowiak16-Nov-12 12:55 
AnswerRe: Issue in accessing 32 bit C++ DLL in Windows Server 2008 Pinmemberjschell17-Nov-12 7:11 
QuestionOutlook 2010 / C# - Hide or Remove item from ContextMenuContactItem + add custom item into it Pinmembercsharpcomeintome16-Nov-12 6:20 
QuestionException Handling PinmemberPhanindra26116-Nov-12 4:21 
AnswerRe: Exception Handling PinmemberBobJanova16-Nov-12 4:41 
GeneralRe: Exception Handling PinmemberPhanindra26116-Nov-12 9:03 
AnswerRe: Exception Handling PinmemberClifford Nelson16-Nov-12 10:49 
GeneralRe: Exception Handling PinmvpDave Kreskowiak16-Nov-12 12:49 
AnswerRe: Exception Handling PinmemberOrjan Westin16-Nov-12 5:37 
AnswerRe: Exception Handling PinmemberSledgeHammer0116-Nov-12 10:55 
JokeRe: Exception Handling PinmemberMycroft Holmes16-Nov-12 16:42 
AnswerRe: Exception Handling Pinmemberjschell17-Nov-12 7:20 
QuestionManual Coding vs Code Generation PinmemberPhanindra26116-Nov-12 1:22 
AnswerRe: Manual Coding vs Code Generation PinmentorDaveyM6916-Nov-12 1:46 
GeneralRe: Manual Coding vs Code Generation Pinmembern.podbielski16-Nov-12 2:06 
GeneralRe: Manual Coding vs Code Generation PinmentorDaveyM6916-Nov-12 3:37 
GeneralRe: Manual Coding vs Code Generation Pinmembern.podbielski16-Nov-12 3:47 
GeneralRe: Manual Coding vs Code Generation PinmemberBobJanova16-Nov-12 4:22 
GeneralRe: Manual Coding vs Code Generation Pinmembern.podbielski16-Nov-12 4:43 
AnswerRe: Manual Coding vs Code Generation PinmemberOrjan Westin16-Nov-12 3:17 
GeneralRe: Manual Coding vs Code Generation PinmemberPhanindra26116-Nov-12 4:09 
GeneralRe: Manual Coding vs Code Generation PinmemberOrjan Westin16-Nov-12 4:25 
AnswerRe: Manual Coding vs Code Generation PinmemberBobJanova16-Nov-12 4:25 
AnswerRe: Manual Coding vs Code Generation PinmemberMarcus Kramer16-Nov-12 8:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 20 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid