/// <summary> /// Iterates through inputs, outputs, in given IOSpec and for matching items in current IOSpec updates mappings /// </summary> /// <param name="temporaryIOSpec"></param> public void UpdateMappingsBasedOn(IOSpec temporaryIOSpec) { foreach (IOItem tmpInputItem in temporaryIOSpec.Input.Values) { IOItem inputItem; if (Input.TryGetValue(tmpInputItem.IOItemDefinition.Name, out inputItem)) { //check if definitions are the same if (inputItem.IOItemDefinition.Equals(tmpInputItem.IOItemDefinition)) { inputItem.MappedTo = tmpInputItem.MappedTo; } } } foreach (IOItem tmpOutputItem in temporaryIOSpec.Output.Values) { IOItem outputItem; if (Output.TryGetValue(tmpOutputItem.IOItemDefinition.Name, out outputItem)) { //check if definitions are the same if (outputItem.IOItemDefinition.Equals(tmpOutputItem.IOItemDefinition)) { outputItem.MappedTo = tmpOutputItem.MappedTo; } } } }
public override void ReadXml(System.Xml.XmlReader reader) { IsInitialized = false; XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/Metadata"); //read component metadata definition id ComponentMetadataDefinitionID = iter.GetAttribute("ComponentMetadataDefinitionID", String.Empty); m_tempLabel = iter.GetAttribute("Label", String.Empty); //read attribute indicating if component should wait for all predecessors var wait = iter.GetAttribute("WaitsForAllPredecessors", String.Empty); if (String.IsNullOrEmpty(wait) || (wait != Boolean.TrueString && wait != Boolean.FalseString)) //if value has not been found set it to true { m_tempWaitsForAllPredecessors = true; //default value } else { m_tempWaitsForAllPredecessors = Convert.ToBoolean(wait); } //read iospec and config wrapper from xml m_tempIoSpec = IOSpec.ReadIOSpec(nav.SelectSingleNode("/Metadata/IOSpec")); m_tempConfigWrapper = ConfigWrapper.ReadConfig(nav); }
public override void WriteXml(System.Xml.XmlWriter writer) { writer.WriteAttributeString("type", this.GetType().GetTraceLabQualifiedName()); writer.WriteAttributeString("Label", Label); writer.WriteAttributeString("WaitsForAllPredecessors", WaitsForAllPredecessors.ToString()); IOSpec.WriteXml(writer); }
/// <summary> /// Performs a deep copy of the data in this object to another instance of the Metadata. /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(Metadata other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); CompositeComponentMetadata metadata = (CompositeComponentMetadata)other; m_IOSpec = metadata.m_IOSpec.Clone(); m_configWrapper = metadata.m_configWrapper.Clone(); m_experimentLocationRoot = metadata.m_experimentLocationRoot; m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition; m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID; HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } // if composite component was not present in the library, then corresponding component graph may be null. // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null) { m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone()); } m_tempConfigWrapper = metadata.m_tempConfigWrapper; m_tempIoSpec = metadata.m_tempIoSpec; m_tempLabel = metadata.m_tempLabel; }
/// <summary> /// Initializes a new instance of the <see cref="ComponentMetadata"/> class. /// </summary> /// <param name="info">The info.</param> /// <param name="context">The context.</param> protected ComponentMetadata(SerializationInfo info, StreamingContext context) : base(info, context) { m_IOSpec = (IOSpec)info.GetValue("m_IOSpec", typeof(IOSpec)); m_configWrapper = (ConfigWrapper)info.GetValue("m_configWrapper", typeof(ConfigWrapper)); m_componentMetadataDefinitionID = (string)info.GetValue("m_componentMetadataDefinitionID", typeof(string)); m_componentMetadataDefinition = (ComponentMetadataDefinition)info.GetValue("m_componentMetadataDefinition", typeof(ComponentMetadataDefinition)); }
/// <summary> /// Writes the XML. /// </summary> /// <param name="writer">The writer.</param> public override void WriteXml(System.Xml.XmlWriter writer) { writer.WriteAttributeString("type", this.GetType().GetTraceLabQualifiedName()); writer.WriteAttributeString("Label", Label); writer.WriteAttributeString("ComponentMetadataDefinitionID", ComponentMetadataDefinitionID); writer.WriteAttributeString("WaitsForAllPredecessors", WaitsForAllPredecessors.ToString()); IOSpec.WriteXml(writer); ConfigWrapper.WriteXml(writer); }
/// <summary> /// Returns a hash code for this s_instance. /// </summary> /// <returns> /// A hash code for this s_instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { int iospecHash = IOSpec.GetHashCode(); int componentMetadataDefinitionIDHash = ComponentMetadataDefinitionID.GetHashCode(); int configWrapperHash = ConfigWrapper.GetHashCode(); int labelHash = Label.GetHashCode(); int componentMetadataDefinitionHash = ComponentMetadataDefinition.GetHashCode(); return(iospecHash ^ componentMetadataDefinitionIDHash ^ configWrapperHash ^ labelHash ^ componentMetadataDefinitionHash); }
public override void UpdateFromDefinition(IComponentsLibrary library) { HasDeserializationError = false; m_tempConfigWrapper = ConfigWrapper; m_tempIoSpec = IOSpec; m_tempLabel = Label; m_tempWaitsForAllPredecessors = WaitsForAllPredecessors; ComponentMetadataDefinition = null; GetDefinitionAndSet(library, m_experimentLocationRoot); }
/// <summary> /// Reads the IO spec. /// </summary> /// <param name="nav">A cursor in the xml data</param> /// <returns></returns> internal static IOSpec ReadIOSpec(XPathNavigator nav) { IOSpec temporaryIOSpec = new IOSpec(); if (nav != null) { var reader = nav.ReadSubtree(); reader.Read(); temporaryIOSpec.ReadXml(reader); } return(temporaryIOSpec); }
protected IOSpec(IOSpec other) : this() { if (other == null) throw new ArgumentNullException("other"); foreach(KeyValuePair<string,IOItem> pair in other.m_input) { m_input[pair.Key] = new IOItem(pair.Value.IOItemDefinition, pair.Value.MappedTo); } foreach (KeyValuePair<string, IOItem> pair in other.m_output) { m_output[pair.Key] = new IOItem(pair.Value.IOItemDefinition, pair.Value.MappedTo); } }
/// <summary> /// Inits the default component metadata based on its component metadata definition /// </summary> /// <param name="enforce">if set to <c>true</c> [enforce].</param> private void InitDefaultComponentMetadata(bool enforce) { if (IOSpec == null || enforce) { IOSpec = new IOSpec(ComponentMetadataDefinition.IOSpecDefinition); } if (Label == null || enforce) { Label = ComponentMetadataDefinition.Label; } if (ConfigWrapper == null || enforce) { ConfigWrapper = new ConfigWrapper(ComponentMetadataDefinition.ConfigurationWrapperDefinition); ConfigWrapper.SetExperimentLocationRoot(m_experimentLocationRoot, true); } }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { IOSpec other = obj as IOSpec; if (other == null) { return(false); } bool isEqual = true; isEqual &= CollectionsHelper.DictionaryContentEquals <string, IOItem>(Output, other.Output); isEqual &= CollectionsHelper.DictionaryContentEquals <string, IOItem>(Input, other.Input); return(isEqual); }
protected IOSpec(IOSpec other) : this() { if (other == null) { throw new ArgumentNullException("other"); } foreach (KeyValuePair <string, IOItem> pair in other.m_input) { m_input[pair.Key] = new IOItem(pair.Value.IOItemDefinition, pair.Value.MappedTo); } foreach (KeyValuePair <string, IOItem> pair in other.m_output) { m_output[pair.Key] = new IOItem(pair.Value.IOItemDefinition, pair.Value.MappedTo); } }
/// <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; }
/// <summary> /// Inits the default component metadata based on its definition /// </summary> /// <param name="enforce">if set to <c>true</c> [enforce].</param> private void InitDefaultComponentMetadata(bool enforce) { if (IOSpec == null || enforce) { IOSpec = new IOSpec(ComponentMetadataDefinition.IOSpecDefinition); } if (Label == null || enforce) { Label = ComponentMetadataDefinition.Label; } if (ConfigWrapper == null || enforce) { ConfigWrapper = new ConfigWrapper(ComponentMetadataDefinition.ConfigurationWrapperDefinition); if (m_experimentLocationRoot != null) //location may be null if metadata definition does not belong to any graph { ConfigWrapper.SetExperimentLocationRoot(m_experimentLocationRoot, true); } } }
protected override void CopyFrom(Metadata other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); ComponentTemplateMetadata metadata = (ComponentTemplateMetadata)other; m_IOSpec = metadata.m_IOSpec.Clone(); HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } }
public override void ReadXml(System.Xml.XmlReader reader) { XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/Metadata"); Label = iter.GetAttribute("Label", String.Empty); //read attribute indicating if component should wait for all predecessors var wait = iter.GetAttribute("WaitsForAllPredecessors", String.Empty); if (String.IsNullOrEmpty(wait) || (wait != Boolean.TrueString && wait != Boolean.FalseString)) //if value has not been found set it to true { WaitsForAllPredecessors = true; //default value } else { WaitsForAllPredecessors = Convert.ToBoolean(wait); } //read iospec m_IOSpec = IOSpec.ReadIOSpec(nav.SelectSingleNode("/Metadata/IOSpec")); }
public override void ReadXml(System.Xml.XmlReader reader) { XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/Metadata"); Label = iter.GetAttribute("Label", String.Empty); //read attribute indicating if component should wait for all predecessors var wait = iter.GetAttribute("WaitsForAllPredecessors", String.Empty); if (String.IsNullOrEmpty(wait) || (wait != Boolean.TrueString && wait != Boolean.FalseString)) //if value has not been found set it to true WaitsForAllPredecessors = true; //default value else WaitsForAllPredecessors = Convert.ToBoolean(wait); //read iospec m_IOSpec = IOSpec.ReadIOSpec(nav.SelectSingleNode("/Metadata/IOSpec")); }
public ComponentTemplateMetadata(IOSpec ioSpec, string label) { IOSpec = ioSpec; Label = label; }
/// <summary> /// Initializes a new instance of the <see cref="WorkspaceWrapper"/> class. /// </summary> /// <param name="iospec">The iospec.</param> /// <param name="workspaceInstance">The workspace instance.</param> public WorkspaceWrapper(IOSpec iospec, IWorkspaceInternal workspaceInstance) { IOSpec = iospec; m_workspace = workspaceInstance; }
/// <summary> /// Reads the IO spec. /// </summary> /// <param name="nav">A cursor in the xml data</param> /// <returns></returns> internal static IOSpec ReadIOSpec(XPathNavigator nav) { IOSpec temporaryIOSpec = new IOSpec(); if (nav != null) { var reader = nav.ReadSubtree(); reader.Read(); temporaryIOSpec.ReadXml(reader); } return temporaryIOSpec; }
/// <summary> /// Performs a deep copy of the data in this object to another instance of the Metadata. /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(Metadata other) { if (other == null) throw new ArgumentNullException("other"); base.CopyFrom(other); CompositeComponentMetadata metadata = (CompositeComponentMetadata)other; m_IOSpec = metadata.m_IOSpec.Clone(); m_configWrapper = metadata.m_configWrapper.Clone(); m_experimentLocationRoot = metadata.m_experimentLocationRoot; m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition; m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID; HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } // if composite component was not present in the library, then corresponding component graph may be null. // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null) { m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone()); } m_tempConfigWrapper = metadata.m_tempConfigWrapper; m_tempIoSpec = metadata.m_tempIoSpec; m_tempLabel = metadata.m_tempLabel; }
private void ResetWorkspaceWrapper() { AppContext.WorkspaceInstance.Reset(); AppContext.WorkspaceInstance.RegisterType(typeof(TestObject)); IOSpec mockIoSpec = new IOSpec(); mockIoSpec.Input.Add(Unitname, new IOItem(new IOItemDefinition(Unitname, typeof(TestObject).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), Unitname)); mockIoSpec.Output.Add(Unitname, new IOItem(new IOItemDefinition(Unitname, typeof(TestObject).FullName, "mockdescription", TraceLabSDK.IOSpecType.Output), Unitname)); mockIoSpec.Input.Add(Unitname2, new IOItem(new IOItemDefinition(Unitname2, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), Unitname2)); mockIoSpec.Output.Add(Unitname2, new IOItem(new IOItemDefinition(Unitname2, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Output), Unitname2)); TestWorkspaceWrapper = new WorkspaceWrapper(mockIoSpec, AppContext.WorkspaceInstance); }
public override void ReadXml(System.Xml.XmlReader reader) { IsInitialized = false; XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/Metadata"); //read component metadata definition id ComponentMetadataDefinitionID = iter.GetAttribute("ComponentMetadataDefinitionID", String.Empty); m_tempLabel = iter.GetAttribute("Label", String.Empty); //read attribute indicating if component should wait for all predecessors var wait = iter.GetAttribute("WaitsForAllPredecessors", String.Empty); if (String.IsNullOrEmpty(wait) || (wait != Boolean.TrueString && wait != Boolean.FalseString)) //if value has not been found set it to true m_tempWaitsForAllPredecessors = true; //default value else m_tempWaitsForAllPredecessors = Convert.ToBoolean(wait); //read iospec and config wrapper from xml m_tempIoSpec = IOSpec.ReadIOSpec(nav.SelectSingleNode("/Metadata/IOSpec")); m_tempConfigWrapper = ConfigWrapper.ReadConfig(nav); }
protected override void CopyFrom(Metadata other) { if (other == null) throw new ArgumentNullException("other"); base.CopyFrom(other); ComponentTemplateMetadata metadata = (ComponentTemplateMetadata)other; m_IOSpec = metadata.m_IOSpec.Clone(); HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } }
private static ComponentTemplateMetadata FindTemplateComponentMetadata(XPathNavigator nav) { ComponentTemplateMetadata template = null; //search for all references for template components metadata string templateType = typeof(ComponentTemplateMetadata).ToString(); XPathExpression expression = nav.Compile("//Metadata[starts-with(@type, '" + templateType + "')]"); XPathNavigator templateXmlNode = nav.SelectSingleNode(expression); if (templateXmlNode != null) { string label = templateXmlNode.GetAttribute("Label", String.Empty); IOSpec ioSpec = new IOSpec(); XPathNavigator ioSpecNav = templateXmlNode.SelectSingleNode("IOSpec"); ioSpec.ReadXml(ioSpecNav.ReadSubtree()); template = new ComponentTemplateMetadata(ioSpec, label); } return template; }
public void NestedWorkspaceWrapperSetupAndTearDownTest() { string experimentNamespace = "experiment_namespace"; ExperimentWorkspaceWrapper experimentWorkspaceWrapper = new ExperimentWorkspaceWrapper(AppContext.WorkspaceInstance, experimentNamespace); // let store some objects in the workspace using experiment wrapper // note that experiment wrapper does not have any restriction and can store anything in workspace - it has direct access to Workspace string unitname1 = "testunitname1"; string unitname2 = "testunitname2"; TestObject object1 = new TestObject(); object1.Value = "some value"; Assert.IsFalse(AppContext.WorkspaceInstance.Exists(unitname1)); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname1)); experimentWorkspaceWrapper.Store(unitname1, object1); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname1)); int testInt = 5; Assert.IsFalse(AppContext.WorkspaceInstance.Exists(unitname2)); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname2)); experimentWorkspaceWrapper.Store(unitname2, testInt); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(unitname2)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname2)); //prepare io spec for first nested workspace IOSpec mockIoSpec1 = new IOSpec(); string nest1unitname1 = "nest1unitname1"; //input nest1unitname1 from unitname1 string nest1unitname2 = "nest1unitname2"; //input nest1unitname2 from unitname2 mockIoSpec1.Input.Add(nest1unitname1, new IOItem(new IOItemDefinition(nest1unitname1, typeof(TestObject).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), unitname1)); mockIoSpec1.Input.Add(nest1unitname2, new IOItem(new IOItemDefinition(nest1unitname2, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), unitname2)); string nestedWorkspace1Namespace = "nested_workspace1"; NestedWorkspaceWrapper nestedWorkspace1 = new NestedWorkspaceWrapper(mockIoSpec1, experimentWorkspaceWrapper, nestedWorkspace1Namespace); //prepare io spec for 2nd nested workspace IOSpec mockIoSpec2 = new IOSpec(); string nest2unitname1 = "nest2unitname1"; //input nest2unitname1 from nest1unitname1 string nest2unitname2 = "nest2unitname2"; //input nest2unitname2 from nest1unitname2 //output matters only in teardown string unitname3 = "unitname3"; string unitname3_OutputAS = "nest2unitname3"; string localScopeUnitname = "localScope"; mockIoSpec2.Input.Add(nest2unitname1, new IOItem(new IOItemDefinition(nest2unitname1, typeof(TestObject).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), nest1unitname1)); mockIoSpec2.Input.Add(nest2unitname2, new IOItem(new IOItemDefinition(nest2unitname2, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Input), nest1unitname2)); mockIoSpec2.Output.Add(unitname3, new IOItem(new IOItemDefinition(unitname3, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Output), unitname3_OutputAS)); string nestedWorkspace2Namespace = "nested_workspace2"; NestedWorkspaceWrapper nestedWorkspace2 = new NestedWorkspaceWrapper(mockIoSpec2, nestedWorkspace1, nestedWorkspace2Namespace); IOSpec mockIoSpec3 = new IOSpec(); mockIoSpec3.Output.Add(unitname3, new IOItem(new IOItemDefinition(unitname3, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Output), unitname3)); mockIoSpec3.Output.Add(localScopeUnitname, new IOItem(new IOItemDefinition(localScopeUnitname, typeof(int).FullName, "mockdescription", TraceLabSDK.IOSpecType.Output), localScopeUnitname)); WorkspaceWrapper workspaceWrapper = new WorkspaceWrapper(mockIoSpec3, nestedWorkspace2); // call in order // 1. setup nested workspace 1 // 2. setup nested workspace 2 // 3. store a object with unitname3 using workspace wrapper, that is output to the higher level scope // 4. store another object, that is NOT output to higher level scope and should be discarded in teardown // 4. tear down workspace 2 // 5. tear down workspace 1 nestedWorkspace1.Setup(); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname1)); //it actually should stay in experiment scope Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname2)); Assert.IsTrue(experimentWorkspaceWrapper.Exists(unitname1)); Assert.IsTrue(experimentWorkspaceWrapper.Exists(unitname2)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname2)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname1)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname2)); nestedWorkspace2.Setup(); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname2)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname1)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname2)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + nest2unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + nest2unitname2)); Assert.IsTrue(nestedWorkspace2.Exists(nest2unitname1)); Assert.IsTrue(nestedWorkspace2.Exists(nest2unitname2)); //store unit 3 int unit3 = 10; workspaceWrapper.Store(unitname3, unit3); //it should store it with namespace Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + unitname3)); //store localscope variable int localScopeUnit = 25; workspaceWrapper.Store(localScopeUnitname, localScopeUnit); //it should store it with namespace Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + localScopeUnitname)); nestedWorkspace2.TearDown(); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + nest2unitname1)); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + nest2unitname2)); Assert.IsFalse(nestedWorkspace2.Exists(nest2unitname1)); Assert.IsFalse(nestedWorkspace2.Exists(nest2unitname2)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname2)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname1)); Assert.IsTrue(nestedWorkspace1.Exists(nest1unitname2)); //unitname 3 should be tear down and renamed to unitnameOutpusAs with proper namespace Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + unitname3)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + unitname3_OutputAS)); //local scope should also be cleared, although it was not output to higher level scope Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nestedWorkspace2Namespace + DOT + localScopeUnitname)); nestedWorkspace1.TearDown(); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname1)); Assert.IsFalse(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + nestedWorkspace1Namespace + DOT + nest1unitname2)); Assert.IsFalse(nestedWorkspace1.Exists(nest1unitname1)); Assert.IsFalse(nestedWorkspace1.Exists(nest1unitname2)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname1)); Assert.IsTrue(AppContext.WorkspaceInstance.Exists(experimentNamespace + DOT + unitname2)); Assert.IsTrue(experimentWorkspaceWrapper.Exists(unitname1)); Assert.IsTrue(experimentWorkspaceWrapper.Exists(unitname2)); }
/// <summary> /// Initializes a new instance of the <see cref="NestedWorkspaceWrapper"/> class. /// </summary> /// <param name="iospec">The iospec.</param> /// <param name="parentWorkspace">The parent workspace instance or parent workspace wrapper.</param> /// <param name="workspaceNamespaceId">The workspace namespace id.</param> public NestedWorkspaceWrapper(IOSpec iospec, IWorkspaceInternal parentWorkspace, string workspaceNamespaceId) : this(parentWorkspace, workspaceNamespaceId) { IOSpec = iospec; }