protected void InitializeViewModelAttributes()
{
if (_areViewModelAttributesIntialized)
{
return;
}
_areViewModelAttributesIntialized = true;
SuspendValidation = true;
InitializePropertiesWithAttributes();
lock (_modelLock)
{
foreach (var modelInfo in _modelObjectsInfo)
{
_modelObjects.Add(modelInfo.Key, null);
}
}
if (SupportIEditableObject)
{
lock (_modelLock)
{
foreach (var modelKeyValuePair in _modelObjects)
{
if (_modelObjectsInfo[modelKeyValuePair.Key].SupportIEditableObject)
{
var modelKeyValuePairValueAsModelBaseBase = modelKeyValuePair.Value as IModel;
if ((modelKeyValuePairValueAsModelBaseBase == null) || !modelKeyValuePairValueAsModelBaseBase.IsInEditSession)
{
EditableObjectHelper.BeginEditObject(modelKeyValuePair.Value);
}
}
}
}
}
ValidateViewModelToModelMappings();
if (!_ignoreMultipleModelsWarning)
{
lock (_modelLock)
{
if (_modelObjects.Count > 1)
{
Log.Warning("The view model {0} implements {1} models.\n\n" +
"Normally, a view model only implements 1 model so make sure you are using the Model attribute correctly. If the Model attribute is used correctly (on models only), this warning can be ignored by using a constructor overload.",
GetType().Name, _modelObjects.Count);
}
}
}
SuspendValidation = false;
}