J
John Haigh
I have the need to create an array of objects. Now this sound fairly trivial
but I can't figure this out.
I have one class called PostingObjectService that has a method GetPostings
where the problem begins (class is below) where in the foreach loop I need
to add Postings to the PostingObject[] array which will be returned by this
method. Then I have the class PostingObject where I am unsure how to create
the array or add to the array of PostingObjects.
Please help.
Thanks, John
PostingObjectService.cs
using System;
using System.Collections;
using Microsoft.ContentManagement.Publishing;
namespace test.CMS.library
{
/// <summary>
/// Summary description for PostingService.
/// </summary>
public class PostingObjectService
{
public PostingObjectService()
{
//
// TODO: Add constructor logic here
//
}
public PostingObject[] GetPostings(string sChannelGuid, DateTime
dtStartDate, DateTime dtEndDate)
{
PostingObject[] oReturnedCol = null;
//Get the current channel (News channel) based on the passed GUID to the
method
Channel aChannel = CMSAPI.GetChannel(sChannelGuid);
PostingCollection oPostCol = aChannel.Postings;
oPostCol.SortByStartDate( false );
foreach ( Posting oPost in oPostCol )
{
// If month has changed
PostingObject oNewMonth = new PostingObject( dtStartDate, dtEndDate );
//oNewMonth.objPosting[0].
//oNewMonth
//oPost.StartDate
}
return oReturnedCol;
}
}
}
PostingObject.cs
using System;
using System.Collections;
using Microsoft.ContentManagement.Publishing;
namespace test.CMS.library
{
/// <summary>
/// Summary description for PostingObject.
/// </summary>
public class PostingObject
{
#region Instance variables
internal Posting[] objPosting = null;
#endregion
#region Constructor
public PostingObject()
{
}
// start date
public PostingObject(DateTime StartDate)
{
// Do I add to the array of Postings here?
objPosting.
}
// start date, end date
public PostingObject(DateTime StartDate, DateTime EndDate)
{
// Do I add to the array of Postings here?
}
#endregion
public String StartDate
{
get
{
if(objPosting != null)
{
return objPosting.StartDate.ToString();
}
else
{
return null;
}
}
}
public String EndDate
{
get
{
if(objPosting != null)
{
return objPosting.ToString();
}
else
{
return null;
}
}
}
} //END class
}// END namespace
but I can't figure this out.
I have one class called PostingObjectService that has a method GetPostings
where the problem begins (class is below) where in the foreach loop I need
to add Postings to the PostingObject[] array which will be returned by this
method. Then I have the class PostingObject where I am unsure how to create
the array or add to the array of PostingObjects.
Please help.
Thanks, John
PostingObjectService.cs
using System;
using System.Collections;
using Microsoft.ContentManagement.Publishing;
namespace test.CMS.library
{
/// <summary>
/// Summary description for PostingService.
/// </summary>
public class PostingObjectService
{
public PostingObjectService()
{
//
// TODO: Add constructor logic here
//
}
public PostingObject[] GetPostings(string sChannelGuid, DateTime
dtStartDate, DateTime dtEndDate)
{
PostingObject[] oReturnedCol = null;
//Get the current channel (News channel) based on the passed GUID to the
method
Channel aChannel = CMSAPI.GetChannel(sChannelGuid);
PostingCollection oPostCol = aChannel.Postings;
oPostCol.SortByStartDate( false );
foreach ( Posting oPost in oPostCol )
{
// If month has changed
PostingObject oNewMonth = new PostingObject( dtStartDate, dtEndDate );
//oNewMonth.objPosting[0].
//oNewMonth
//oPost.StartDate
}
return oReturnedCol;
}
}
}
PostingObject.cs
using System;
using System.Collections;
using Microsoft.ContentManagement.Publishing;
namespace test.CMS.library
{
/// <summary>
/// Summary description for PostingObject.
/// </summary>
public class PostingObject
{
#region Instance variables
internal Posting[] objPosting = null;
#endregion
#region Constructor
public PostingObject()
{
}
// start date
public PostingObject(DateTime StartDate)
{
// Do I add to the array of Postings here?
objPosting.
}
// start date, end date
public PostingObject(DateTime StartDate, DateTime EndDate)
{
// Do I add to the array of Postings here?
}
#endregion
public String StartDate
{
get
{
if(objPosting != null)
{
return objPosting.StartDate.ToString();
}
else
{
return null;
}
}
}
public String EndDate
{
get
{
if(objPosting != null)
{
return objPosting.ToString();
}
else
{
return null;
}
}
}
} //END class
}// END namespace