public INode BuildPathToNode(Type type) { INode parent = GetParentNode(type); Type argType = ReflectionUtilities.GetNamedParameterTargetOrNull(type); if (argType == null) { return(NodeFactory.CreateClassNode(parent, type)); } INamedParameterNode np = NodeFactory.CreateNamedParameterNode(parent, type, argType); if (Parameterparser.CanParse(ReflectionUtilities.GetAssemblyQualifiedName(argType))) { if (type.GetCustomAttribute <NamedParameterAttribute>().DefaultClass != null) { var e = new ClassHierarchyException("Named parameter " + ReflectionUtilities.GetAssemblyQualifiedName(type) + " defines default implementation for parsable type " + ReflectionUtilities.GetAssemblyQualifiedName(argType)); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } string shortName = np.GetShortName(); if (shortName != null && !shortName.Equals("")) { INamedParameterNode oldNode = null; shortNames.TryGetValue(shortName, out oldNode); if (oldNode != null) { if (oldNode.GetFullName().Equals(np.GetFullName())) { var ex = new IllegalStateException("Tried to double bind " + oldNode.GetFullName() + " to short name " + shortName); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } var e = new ClassHierarchyException("Named parameters " + oldNode.GetFullName() + " and " + np.GetFullName() + " have the same short name: " + shortName); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } shortNames.Add(shortName, np); } return(np); }
public INode BuildPathToNode(Type type) { INode parent = GetParentNode(type); Type argType = ReflectionUtilities.GetNamedParameterTargetOrNull(type); if (argType == null) { return(NodeFactory.CreateClassNode(parent, type)); } INamedParameterNode np = NodeFactory.CreateNamedParameterNode(parent, type, argType); if (Parameterparser.CanParse(ReflectionUtilities.GetAssemblyQualifiedName(argType))) { if (type.GetCustomAttribute <NamedParameterAttribute>().DefaultClass != null) { var e = new ClassHierarchyException("Named parameter " + ReflectionUtilities.GetAssemblyQualifiedName(type) + " defines default implementation for parsable type " + ReflectionUtilities.GetAssemblyQualifiedName(argType)); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } if (!string.IsNullOrEmpty(np.GetAlias())) { IDictionary <string, string> mapping = null; _aliasLookupTable.TryGetValue(np.GetAliasLanguage().ToString(), out mapping); if (null == mapping) { mapping = new Dictionary <string, string>(); _aliasLookupTable.Add(np.GetAliasLanguage().ToString(), mapping); } try { mapping.Add(np.GetAlias(), np.GetFullName()); } catch (Exception) { var e = new ApplicationException(string.Format(CultureInfo.CurrentCulture, "Duplicated alias {0} on named parameter {1}.", np.GetAlias(), np.GetFullName())); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } string shortName = np.GetShortName(); if (shortName != null && !shortName.Equals(string.Empty)) { INamedParameterNode oldNode = null; shortNames.TryGetValue(shortName, out oldNode); if (oldNode != null) { if (oldNode.GetFullName().Equals(np.GetFullName())) { var ex = new IllegalStateException("Tried to double bind " + oldNode.GetFullName() + " to short name " + shortName); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } var e = new ClassHierarchyException("Named parameters " + oldNode.GetFullName() + " and " + np.GetFullName() + " have the same short name: " + shortName); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } shortNames.Add(shortName, np); } return(np); }