private void WireUpInheritanceRelationships(AvroNode n) { if (n.classNode != null && !n.classNode.Equals(string.Empty)) { AvroClassNode cn = (AvroClassNode)n.classNode; IClassNode iface = null; try { iface = (IClassNode)GetNode(n.fullName); } catch (NameResolutionException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new IllegalStateException("When reading protocol buffer node " + n.fullName + " does not exist. Full record is " + n, e); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } foreach (string impl in cn.implFullNames) { try { iface.PutImpl((IClassNode)GetNode(impl)); } catch (NameResolutionException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new IllegalStateException("When reading protocol buffer node " + n + " refers to non-existent implementation:" + impl); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (InvalidCastException e) { Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); try { var ex = new IllegalStateException( "When reading protocol buffer node " + n + " found implementation" + GetNode(impl) + " which is not a ClassNode!"); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (NameResolutionException ne) { Utilities.Diagnostics.Exceptions.Caught(ne, Level.Error, LOGGER); var ex = new IllegalStateException( "Got 'cant happen' exception when producing error message for " + e); Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } } } }
private void ParseSubHierarchy(INode parent, AvroNode n) { INode parsed = null; if (n.packageNode != null && !n.packageNode.Equals(string.Empty)) { parsed = new PackageNodeImpl(parent, n.name, n.fullName); } else if (n.namedParameterNode != null && !n.namedParameterNode.Equals(string.Empty)) { AvroNamedParameterNode np = (AvroNamedParameterNode)n.namedParameterNode; parsed = new NamedParameterNodeImpl(parent, n.name, n.fullName, np.fullArgClassName, np.simpleArgClassName, np.isSet, np.isList, np.documentation, np.shortName, np.instanceDefault.ToArray()); } else if (n.classNode != null && !n.classNode.Equals(string.Empty)) { AvroClassNode cn = (AvroClassNode)n.classNode; IList <IConstructorDef> injectableConstructors = new List <IConstructorDef>(); IList <IConstructorDef> allConstructors = new List <IConstructorDef>(); foreach (AvroConstructorDef injectable in cn.injectableConstructors) { IConstructorDef def = ParseConstructorDef(injectable, true); injectableConstructors.Add(def); allConstructors.Add(def); } foreach (AvroConstructorDef other in cn.otherConstructors) { IConstructorDef def = ParseConstructorDef(other, false); allConstructors.Add(def); } parsed = new ClassNodeImpl(parent, n.name, n.fullName, cn.isUnit, cn.isInjectionCandidate, cn.isExternalConstructor, injectableConstructors, allConstructors, cn.defaultImplementation); } else { Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Bad protocol buffer: got abstract node" + n), LOGGER); } foreach (AvroNode child in n.children) { ParseSubHierarchy(parsed, child); } }
private AvroNode NewClassNode(string name, string fullName, bool isInjectionCandidate, bool isExternalConstructor, bool isUnit, IList <AvroConstructorDef> injectableConstructors, IList <AvroConstructorDef> otherConstructors, IList <string> implFullNames, IList <AvroNode> children) { AvroClassNode classNode = new AvroClassNode(); classNode.isInjectionCandidate = isInjectionCandidate; classNode.injectableConstructors = new List <AvroConstructorDef>(); foreach (var ic in injectableConstructors) { classNode.injectableConstructors.Add(ic); } classNode.otherConstructors = new List <AvroConstructorDef>(); foreach (var oc in otherConstructors) { classNode.otherConstructors.Add(oc); } classNode.implFullNames = new List <string>(); foreach (var implFullName in implFullNames) { classNode.implFullNames.Add(implFullName); } AvroNode n = new AvroNode(); n.name = name; n.fullName = fullName; n.classNode = classNode; n.children = new List <AvroNode>(); foreach (var c in children) { n.children.Add(c); } return(n); }