本文整理汇总了C#中Components.TryGetComponentDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# Components.TryGetComponentDefinition方法的具体用法?C# Components.TryGetComponentDefinition怎么用?C# Components.TryGetComponentDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Components
的用法示例。
在下文中一共展示了Components.TryGetComponentDefinition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDefinitionAndSet
/// <summary>
/// Gets the definition for this Metadata and sets up the configuration based on it.
/// </summary>
/// <param name="library">The library.</param>
/// <param name="experimentLocationRoot">The experiment location root.</param>
private void GetDefinitionAndSet(Components.IComponentsLibrary library, string experimentLocationRoot)
{
m_experimentLocationRoot = experimentLocationRoot;
//reload component metadata definition
MetadataDefinition metadataDefinition;
if (library.TryGetComponentDefinition(ComponentMetadataDefinitionID, out metadataDefinition))
{
ComponentMetadataDefinition = metadataDefinition as CompositeComponentMetadataDefinition;
}
//if definition has been found override matching parameters (but don't override definition)
if (ComponentMetadataDefinition != null)
{
InitDefaultComponentMetadata(true);
IOSpec.UpdateMappingsBasedOn(m_tempIoSpec);
ConfigWrapper.UpdateConfigValuesBasedOn(m_tempConfigWrapper);
Label = m_tempLabel;
WaitsForAllPredecessors = m_tempWaitsForAllPredecessors;
//clear error - there might have been errors regarding existence of composite component, but referencing new package might fix this problem.
DeserializationErrorMessage = null;
HasDeserializationError = false;
}
else
{
//otherwise set values to temporary IOSpec and configWrapper (just not to lose data in case user resave experiment), and rethrow exception
IOSpec = m_tempIoSpec;
ConfigWrapper = m_tempConfigWrapper;
HasDeserializationError = true;
Label = m_tempLabel;
WaitsForAllPredecessors = m_tempWaitsForAllPredecessors;
DeserializationErrorMessage = String.Format(System.Globalization.CultureInfo.CurrentCulture, "Component library does not contain any Composite Component of the given ID {0}", ComponentMetadataDefinitionID);
}
if (experimentLocationRoot != null) //it may be null if it is a component residing in the graph of composite component that is the library (was not added to any experiment)
{
ConfigWrapper.SetExperimentLocationRoot(experimentLocationRoot, true);
}
m_tempConfigWrapper = null;
m_tempIoSpec = null;
m_tempLabel = null;
}