public void ReadXml(System.Xml.XmlReader reader) { if (reader == null) { throw new ArgumentNullException("reader"); } XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/ConfigDefinition/IsJava"); string isJavaString = iter.Value; bool tmpIsJava; if (isJavaString != null && bool.TryParse(isJavaString, out tmpIsJava)) { IsJava = tmpIsJava; } XPathNodeIterator propertyObjectsIterator = nav.Select("/ConfigDefinition//PropertyObject"); while (propertyObjectsIterator.MoveNext()) { ConfigPropertyObject propertyObject = new ConfigPropertyObject(); propertyObject.ReadXml(propertyObjectsIterator.Current.ReadSubtree()); Properties.Add(propertyObject.Name, propertyObject); } }
private void AttachListenerToIOSpecHighlights(ExperimentNode node) { // HERZUM SPRINT 4: TLAB-238 ComponentMetadata meta = ExperimentNode.Data.Metadata as ComponentMetadata; if (meta != null) { TraceLab.Core.Components.ConfigWrapper configWrapper = meta.ConfigWrapper as TraceLab.Core.Components.ConfigWrapper; if (configWrapper != null){ TraceLab.Core.Components.ConfigPropertyObject value = new TraceLab.Core.Components.ConfigPropertyObject(); // HERZUM SPRINT 4.3: TLAB-238 TLAB-243 // ADD configWrapper.ConfigValues.TryGetValue ("ConfigurationFile", out value) if (configWrapper.ConfigValues.TryGetValue ("Directory", out value) || configWrapper.ConfigValues.TryGetValue ("ConfigurationFile", out value)) if (value!=null){ value.SetExperimentLocationRoot (System.IO.Path.GetDirectoryName(m_applicationContext.Application.Experiment.ExperimentInfo.FilePath), true); } // END HERZUM SPRINT 4.2: TLAB-202 } } // HERZUM SPRINT 4: TLAB-238 //set convenience metadata field m_componentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if(m_componentMetadata != null) { m_componentMetadata.IOSpec.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if(e.PropertyName.Equals("IsInputHighlighted") || e.PropertyName.Equals("IsOutputHighlighted")) { //redraw component Invalidate(); } }; } }
internal void AddProperty(ConfigPropertyObject propertyObject) { if (ConfigValues.ContainsKey(propertyObject.Name) == false) { //add Property to ConfigValues ConfigValues.Add(propertyObject.Name, propertyObject); //update also definition just for consistency if (m_configWrapperDefinition != null) { m_configWrapperDefinition.AddProperty(propertyObject); } } }
internal void Merge(string idPrefix, ConfigWrapper configWrapper) { foreach (KeyValuePair <string, ConfigPropertyObject> pair in configWrapper.m_configValues) { string extendedParameterName = String.Format("{0}:{1}", idPrefix, pair.Key); if (ConfigValues.ContainsKey(extendedParameterName) == false) { var configValue = pair.Value; var property = new ConfigPropertyObject(extendedParameterName, configValue.Value, configValue.Type, configValue.AssemblyQualifiedName, configValue.IsEnum, configValue.DisplayName, configValue.Description); ConfigValues.Add(extendedParameterName, property); property.PropertyChanged += property_PropertyChanged; } } }
protected ConfigWrapper(ConfigWrapper other) { if (other == null) throw new ArgumentNullException(); m_configWrapperDefinition = other.m_configWrapperDefinition; InitDefaultConfigWrapper(); foreach (KeyValuePair<string, ConfigPropertyObject> pair in other.m_configValues) { var property = new ConfigPropertyObject(pair.Value); m_configValues[pair.Key] = property; property.PropertyChanged += property_PropertyChanged; } }
private void InitDefaultConfigWrapper() { ConfigValues.Clear(); if (m_configWrapperDefinition != null && m_configWrapperDefinition.Properties.Count > 0) { //init config values foreach (string propertyName in m_configWrapperDefinition.Properties.Keys) { var property = new ConfigPropertyObject(m_configWrapperDefinition.Properties[propertyName]); ConfigValues.Add(propertyName, property); property.PropertyChanged += property_PropertyChanged; } IsJava = m_configWrapperDefinition.IsJava; } }
protected ConfigWrapper(ConfigWrapper other) { if (other == null) { throw new ArgumentNullException(); } m_configWrapperDefinition = other.m_configWrapperDefinition; InitDefaultConfigWrapper(); foreach (KeyValuePair <string, ConfigPropertyObject> pair in other.m_configValues) { var property = new ConfigPropertyObject(pair.Value); m_configValues[pair.Key] = property; property.PropertyChanged += property_PropertyChanged; } }
public ConfigPropertyObject(ConfigPropertyObject propertyObject) { Name = String.Copy(propertyObject.Name); Value = ObjectCopier.Clone(propertyObject.Value); Type = String.Copy(propertyObject.Type); AssemblyQualifiedName = String.Copy(propertyObject.AssemblyQualifiedName); DisplayName = String.Copy(propertyObject.DisplayName); Description = String.Copy(propertyObject.Description); Visible = propertyObject.Visible; IsEnum = propertyObject.IsEnum; if (IsEnum) { var enumInfo = new EnumValueCollection(propertyObject.EnumInfo); EnumInfo = enumInfo; TypeDescriptor.AddProvider(new EnumValueDescriptionProvider(EnumInfo), EnumInfo); Value = propertyObject.Value.ToString(); } }
public ConfigPropertyObject(ConfigPropertyObject propertyObject) { Name = String.Copy(propertyObject.Name); Value = ObjectCopier.Clone(propertyObject.Value); Type = String.Copy(propertyObject.Type); AssemblyQualifiedName = String.Copy(propertyObject.AssemblyQualifiedName); DisplayName = String.Copy(propertyObject.DisplayName); Description = String.Copy(propertyObject.Description); Visible = propertyObject.Visible; IsEnum = propertyObject.IsEnum; if (IsEnum) { var enumInfo = new EnumValueCollection(propertyObject.EnumInfo); EnumInfo = enumInfo; TypeDescriptor.AddProvider(new EnumValueDescriptionProvider(EnumInfo), EnumInfo); Value = propertyObject.Value.ToString(); } }
public override bool Equals(object obj) { ConfigPropertyObject other = obj as ConfigPropertyObject; if (other == null) { return(false); } bool isEqual = true; isEqual &= object.Equals(Name, other.Name); isEqual &= object.Equals(DisplayName, other.DisplayName); isEqual &= object.Equals(Description, other.Description); isEqual &= object.Equals(Value, other.Value); isEqual &= object.Equals(Type, other.Type); return(isEqual); }
private void ReadVersionOne(XPathNavigator nav) { XPathNavigator iter = nav.SelectSingleNode("/Metadata/ConfigWrapper"); string isJavaString = iter.GetAttribute("IsJava", String.Empty); bool tmpIsJava; if (isJavaString != null && bool.TryParse(isJavaString, out tmpIsJava)) { IsJava = tmpIsJava; } XPathNodeIterator propertyObjectsIterator = nav.Select("/Metadata/ConfigWrapper//PropertyObject"); while (propertyObjectsIterator.MoveNext()) { ConfigPropertyObject propertyObject = new ConfigPropertyObject(); propertyObject.ReadXml(propertyObjectsIterator.Current.ReadSubtree()); propertyObject.PropertyChanged += property_PropertyChanged; ConfigValues.Add(propertyObject.Name, propertyObject); } }
private void AttachListenerToIOSpecHighlights(ExperimentNode node) { // HERZUM SPRINT 4: TLAB-238 ComponentMetadata meta = ExperimentNode.Data.Metadata as ComponentMetadata; if (meta != null) { TraceLab.Core.Components.ConfigWrapper configWrapper = meta.ConfigWrapper as TraceLab.Core.Components.ConfigWrapper; if (configWrapper != null) { TraceLab.Core.Components.ConfigPropertyObject value = new TraceLab.Core.Components.ConfigPropertyObject(); // HERZUM SPRINT 4.3: TLAB-238 TLAB-243 // ADD configWrapper.ConfigValues.TryGetValue ("ConfigurationFile", out value) if (configWrapper.ConfigValues.TryGetValue("Directory", out value) || configWrapper.ConfigValues.TryGetValue("ConfigurationFile", out value)) { if (value != null) { value.SetExperimentLocationRoot(System.IO.Path.GetDirectoryName(m_applicationContext.Application.Experiment.ExperimentInfo.FilePath), true); } } // END HERZUM SPRINT 4.2: TLAB-202 } } // HERZUM SPRINT 4: TLAB-238 //set convenience metadata field m_componentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable; if (m_componentMetadata != null) { m_componentMetadata.IOSpec.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if (e.PropertyName.Equals("IsInputHighlighted") || e.PropertyName.Equals("IsOutputHighlighted")) { //redraw component Invalidate(); } }; } }
private void InitDefaultConfigWrapper() { ConfigValues.Clear(); if (m_configWrapperDefinition != null && m_configWrapperDefinition.Properties.Count > 0) { //init config values foreach (string propertyName in m_configWrapperDefinition.Properties.Keys) { var property = new ConfigPropertyObject(m_configWrapperDefinition.Properties[propertyName]); ConfigValues.Add(propertyName, property); property.PropertyChanged += property_PropertyChanged; } IsJava = m_configWrapperDefinition.IsJava; } }
internal void Merge(string idPrefix, ConfigWrapper configWrapper) { foreach (KeyValuePair<string, ConfigPropertyObject> pair in configWrapper.m_configValues) { string extendedParameterName = String.Format("{0}:{1}", idPrefix, pair.Key); if (ConfigValues.ContainsKey(extendedParameterName) == false) { var configValue = pair.Value; var property = new ConfigPropertyObject(extendedParameterName, configValue.Value, configValue.Type, configValue.AssemblyQualifiedName, configValue.IsEnum, configValue.DisplayName, configValue.Description); ConfigValues.Add(extendedParameterName, property); property.PropertyChanged += property_PropertyChanged; } } }
public ConfigPropertyConverter(ConfigPropertyObject instance) { m_instance = instance; }
private void ReadVersionOne(XPathNavigator nav) { XPathNavigator iter = nav.SelectSingleNode("/Metadata/ConfigWrapper"); string isJavaString = iter.GetAttribute("IsJava", String.Empty); bool tmpIsJava; if (isJavaString != null && bool.TryParse(isJavaString, out tmpIsJava)) { IsJava = tmpIsJava; } XPathNodeIterator propertyObjectsIterator = nav.Select("/Metadata/ConfigWrapper//PropertyObject"); while (propertyObjectsIterator.MoveNext()) { ConfigPropertyObject propertyObject = new ConfigPropertyObject(); propertyObject.ReadXml(propertyObjectsIterator.Current.ReadSubtree()); propertyObject.PropertyChanged += property_PropertyChanged; ConfigValues.Add(propertyObject.Name, propertyObject); } }
internal void AddProperty(ConfigPropertyObject propertyObject) { if (ConfigValues.ContainsKey(propertyObject.Name) == false) { //add Property to ConfigValues ConfigValues.Add(propertyObject.Name, propertyObject); //update also definition just for consistency if (m_configWrapperDefinition != null) { m_configWrapperDefinition.AddProperty(propertyObject); } } }
/// <summary> /// Retrieves the config values from component's config wrapper. /// </summary> /// <param name="currentNode">The current node.</param> private void RetrieveConfigValuesFromComponent(string nodeIdentifier, IConfigurableAndIOSpecifiable metadata) { foreach (ConfigPropertyObject configParameter in metadata.ConfigWrapper.ConfigValues.Values) { string displayParameterName = String.Format("{0} {1}", metadata.Label, configParameter.DisplayName); string extendedParameterName = String.Format("{0}:{1}", nodeIdentifier, configParameter.Name); //create property object based on the component's property object ConfigPropertyObject propertyObject = new ConfigPropertyObject(configParameter); //but change the name - it will be resolved in Nodes factory based on extended parameter name which retNode config parameter is supposed to be overridden propertyObject.DisplayName = displayParameterName; propertyObject.Name = extendedParameterName; //add it to the compound configWrapperDefinition displayParameterName = GetUniqueDisplayName(displayParameterName); ConfigSettings.Add(displayParameterName, new ConfigItemSetting(displayParameterName, configParameter.Type, propertyObject)); } }
internal void AddProperty(ConfigPropertyObject propertyObject) { Properties.Add(propertyObject.Name, propertyObject); }
/// <summary> /// Copies the referenced files by FilePath configs. /// Also it creates referenced directories, but don't copy files in the directories. /// Note, that method will update FilePaths and DirectoryPaths of config values. /// Relative properties won't change. /// Absolue properties will be updated to new location. /// Dataroot will be updated to new location. /// </summary> /// <param name="newExperimentLocation">The new experiment location.</param> /// <param name="oldExperimentLocation">The old experiment location.</param> /// <param name="overwrite">if set to <c>true</c> [overwrite] the method will attempt to overwrite files. If not successful it will report failure of copying, but will continue to copy rest of files.</param> /// <exception cref="TraceLab.Core.Exceptions.FilesCopyFailuresException">Throws exception if there were any errors during copying process. The exception contains all reported errors during copy process.</exception> internal void CopyReferencedFiles(string newExperimentLocation, string oldExperimentLocation, bool overwrite) { List <string> copyErrors = new List <string>(); foreach (KeyValuePair <string, ConfigPropertyObject> pair in m_configValues) { ConfigPropertyObject configObj = pair.Value; pair.Value.SetExperimentLocationRoot(newExperimentLocation, false); //change file path root and absolute path, but don't transform relative paths TraceLabSDK.Component.Config.FilePath filePath = configObj.Value as TraceLabSDK.Component.Config.FilePath; TraceLabSDK.Component.Config.DirectoryPath dirPath = configObj.Value as TraceLabSDK.Component.Config.DirectoryPath; if (filePath != null) { //if new directories do not exists create them if (System.IO.Directory.Exists(oldExperimentLocation) == false) { System.IO.Directory.CreateDirectory(oldExperimentLocation); } //old absolute path to the referenced file string oldAbsolute = System.IO.Path.GetFullPath(System.IO.Path.Combine(oldExperimentLocation, filePath.Relative)); //copy from old location to new location try { if (System.IO.File.Exists(filePath.Absolute)) { //don't copy file if overwrite is false and file at new location already exists if (overwrite) { System.IO.File.Copy(oldAbsolute, filePath.Absolute, overwrite); } } else { //if file at new location does not exists always copy System.IO.File.Copy(oldAbsolute, filePath.Absolute, overwrite); } } catch (System.UnauthorizedAccessException ex) { //if the file at the new location already existed and was readonly var message = string.Format("Unable to copy file '{0}' to the new location. {1}", oldAbsolute, ex.Message); copyErrors.Add(message); } catch (System.IO.IOException ex) { //for example if original file was locked (used by another process) var message = string.Format("Unable to copy file '{0}' to the new location. {1}", oldAbsolute, ex.Message); copyErrors.Add(message); } } else if (dirPath != null) { //if new directories do not exists create them if (System.IO.Directory.Exists(dirPath) == false) { System.IO.Directory.CreateDirectory(dirPath); } } } if (copyErrors.Count > 0) { throw new TraceLab.Core.Exceptions.FilesCopyFailuresException(Messages.FailedToCopyFiles, copyErrors); } }
/// <summary> /// /// base could potential hold custom attributes for the property /// currently passing null /// </summary> /// <param name="property"></param> public ConfigPropertyDescriptor(ConfigPropertyObject property, Attribute[] attrs) : base(property.Name, attrs) { ConfigProperty = property; }
/// <summary> /// /// base could potential hold custom attributes for the property /// currently passing null /// </summary> /// <param name="property"></param> public ConfigPropertyDescriptor(ConfigPropertyObject property, Attribute[] attrs) : base(property.Name, attrs) { ConfigProperty = property; }
public ConfigPropertyConverter(ConfigPropertyObject instance) { m_instance = instance; }
internal void AddProperty(ConfigPropertyObject propertyObject) { Properties.Add(propertyObject.Name, propertyObject); }
public ConfigItemSetting(string alias, string type, ConfigPropertyObject propertyObject) : base(alias, type) { PropertyObject = propertyObject; Alias = alias; }
public void ReadXml(System.Xml.XmlReader reader) { if (reader == null) throw new ArgumentNullException("reader"); XPathDocument doc = new XPathDocument(reader); XPathNavigator nav = doc.CreateNavigator(); XPathNavigator iter = nav.SelectSingleNode("/ConfigDefinition/IsJava"); string isJavaString = iter.Value; bool tmpIsJava; if (isJavaString != null && bool.TryParse(isJavaString, out tmpIsJava)) { IsJava = tmpIsJava; } XPathNodeIterator propertyObjectsIterator = nav.Select("/ConfigDefinition//PropertyObject"); while (propertyObjectsIterator.MoveNext()) { ConfigPropertyObject propertyObject = new ConfigPropertyObject(); propertyObject.ReadXml(propertyObjectsIterator.Current.ReadSubtree()); Properties.Add(propertyObject.Name, propertyObject); } }