public ElementRuntime(IElement elementSave, Layer layerProvidedByContainer, NamedObjectSave namedObjectSave, EventHandler<VariableSetArgs> onBeforeVariableSet, EventHandler<VariableSetArgs> onAfterVariableSet)
{
CreationOptions = new CreationOptions();
CreationOptions.OnBeforeVariableSet = onBeforeVariableSet;
CreationOptions.OnAfterVariableSet = onAfterVariableSet;
CreationOptions.LayerProvidedByContainer = layerProvidedByContainer;
this.mLayer = CreationOptions.LayerProvidedByContainer;
if (CreationOptions.OnBeforeVariableSet != null)
{
this.BeforeVariableApply += CreationOptions.OnBeforeVariableSet;
}
if (CreationOptions.OnAfterVariableSet != null)
{
this.AfterVariableApply += CreationOptions.OnAfterVariableSet;
}
ContentManagerName = GluxManager.ContentManagerName;
mAssociatedIElement = elementSave;
mAssociatedNamedObjectSave = namedObjectSave;
InstantiateLists();
if (elementSave != null)
{
this.Name = elementSave.Name;
try
{
LoadReferencedFiles(elementSave);
}
catch(Exception e)
{
throw new Exception("Error loading referenced files for " + elementSave + ":\n\n" + e.ToString());
}
LoadNamedObjects(elementSave);
// October 6, 2011
// Victor Chelaru
// In the earlier days
// of GlueView, we would
// set variables defind at
// in the container before we
// set instance variables. Therefore
// the code would call LoadCustomVariables
// before SetInstanceVariablesOnNamedObjects.
// Now Glue forces both instance and custom variables
// to be the same so order doesn't matter; however, initial
// states are treated as variables and those should be set after
// instance variables are set. Therefore, I'm going to switch the
// order that the following two methods are called.
//LoadCustomVariables(elementSave);
//SetInstanceVariablesOnNamedObjects();
SetInstanceVariablesOnNamedObjects();
CreateCustomVariableContainers(elementSave);
SetCustomVariables(elementSave);
}
}