public static string GetDisplayNameOnly(this MetadataDictionary metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (metadata.ContainsKey("DisplayName", true)) { object o = metadata["DisplayName", true]; if (o != null) { return(o.ToString()); } } else if (metadata.ContainsKey("long_name", true)) { object o = metadata["long_name", true]; if (o != null) { return(o.ToString()); } } else if (metadata.ContainsKey("longname", true)) { object o = metadata["longname", true]; if (o != null) { return(o.ToString()); } } return(null); }
private static string GetName(MetadataDictionary vm) { if (vm == null) { throw new ArgumentNullException("metadata"); } if (vm.ContainsKey(vm.KeyForName)) { return((string)vm[vm.KeyForName, SchemaVersion.Committed]); } else if (vm.ContainsKey(vm.KeyForName, SchemaVersion.Proposed)) { return((string)vm[vm.KeyForName, SchemaVersion.Proposed]); } return(""); }
/// <summary> /// Gets the value of "units" attribute, if exists; otherwise, returns null. /// </summary> /// <param name="metadata"></param> /// <returns></returns> public static string GetUnits(this MetadataDictionary metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (metadata.ContainsKey("units", true)) { return(metadata["units", true].ToString()); } return(null); }
/// <summary> /// Gets the value of the attribute with name "max" if it is presented; /// otherwise returns null. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="metadata"></param> /// <param name="default"></param> /// <returns></returns> public static object GetMax(this MetadataDictionary metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (metadata.ContainsKey("max")) { return(metadata["max"]); } return(null); }
/// <summary> /// Gets the value of the attribute with name "min" if it is presented; /// otherwise returns <paramref name="default"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="metadata"></param> /// <param name="default"></param> /// <returns></returns> public static T GetMax <T>(this MetadataDictionary metadata, T @default) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (metadata.ContainsKey("max")) { return((T)metadata["max"]); } return(@default); }
/// <summary> /// Returns the display name from the metadata, if exists. /// Otherwise, returns the name of the variable. /// If there is no name, returns empty string. /// </summary> /// <param name="metadata"></param> /// <returns></returns> public static string GetDisplayName(this MetadataDictionary metadata) { string dname = GetDisplayNameOnly(metadata); if (!String.IsNullOrEmpty(dname)) { return(dname); } if (metadata.ContainsKey(metadata.KeyForName)) { return((string)metadata[metadata.KeyForName]); } return(String.Empty); }