private void CreateCustomVariableContainer(CustomVariable cv)
{
bool isCustomVariable = true;
if(!string.IsNullOrEmpty(cv.SourceObject))
{
isCustomVariable = false;
}
if (isCustomVariable)
{
Type positionedObjectType = typeof(PositionedObject);
PropertyInfo property = positionedObjectType.GetProperty(cv.Name);
FieldInfo field = positionedObjectType.GetField(cv.Name);
if (property != null || field != null)
{
isCustomVariable = false;
}
}
if (isCustomVariable)
{
EntitySave baseEntitySave = ObjectFinder.Self.GetEntitySave(this.AssociatedIElement.BaseElement);
if (baseEntitySave != null && baseEntitySave.GetCustomVariable(cv.Name) != null)
{
isCustomVariable = false;
}
}
if (isCustomVariable)
{
object defaultValue = null;
if (cv.GetIsFile())
{
defaultValue = null;
}
else if (cv.GetIsCsv())
{
defaultValue = null;
}
else if (cv.GetIsVariableState())
{
defaultValue = null;
}
else
{
try
{
defaultValue = TypeManager.GetDefaultForTypeAsType(cv.Type);
}
catch
{
throw new Exception("Could not get the default value for variable " + cv);
}
}
mCustomVariables.Add(new PropertyValuePair(cv.Name, defaultValue));
}
}