public static Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan Deserialize(IClassHierarchy ch, Org.Apache.REEF.Tang.Protobuf.InjectionPlan ip) { string fullName = ip.name; if (ip.constructor != null) { Org.Apache.REEF.Tang.Protobuf.Constructor cons = ip.constructor; IClassNode cn = (IClassNode)ch.GetNode(fullName); Org.Apache.REEF.Tang.Protobuf.InjectionPlan[] protoBufArgs = cons.args.ToArray(); IClassNode[] cnArgs = new IClassNode[protoBufArgs.Length]; for (int i = 0; i < protoBufArgs.Length; i++) { INode no = ch.GetNode(protoBufArgs[i].name); if (no is IClassNode) { cnArgs[i] = (IClassNode)no; } else if (no is INamedParameterNode) { INamedParameterNode np = (INamedParameterNode)no; cnArgs[i] = (IClassNode)ch.GetNode(np.GetFullArgName()); } } Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan[] ipArgs = new Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan[protoBufArgs.Length]; for (int i = 0; i < protoBufArgs.Length; i++) { ipArgs[i] = (Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan)Deserialize(ch, protoBufArgs[i]); } IConstructorDef constructor = cn.GetConstructorDef(cnArgs); return(new Org.Apache.REEF.Tang.Implementations.InjectionPlan.Constructor(cn, constructor, ipArgs)); } if (ip.instance != null) { Org.Apache.REEF.Tang.Protobuf.Instance ins = ip.instance; object instance = Parse(ip.name, ins.value); return(new CsInstance(ch.GetNode(ip.name), instance)); } if (ip.subplan != null) { Org.Apache.REEF.Tang.Protobuf.Subplan subplan = ip.subplan; Org.Apache.REEF.Tang.Protobuf.InjectionPlan[] protoBufPlans = subplan.plans.ToArray(); Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan[] subPlans = new Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan[protoBufPlans.Length]; for (int i = 0; i < protoBufPlans.Length; i++) { subPlans[i] = (Org.Apache.REEF.Tang.Implementations.InjectionPlan.InjectionPlan)Deserialize(ch, protoBufPlans[i]); } INode n = ch.GetNode(fullName); return(new Org.Apache.REEF.Tang.Implementations.InjectionPlan.Subplan(n, subPlans)); } Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Encountered unknown type of InjectionPlan: " + ip), LOGGER); return(null); }
private static Org.Apache.REEF.Tang.Protobuf.InjectionPlan NewInstance(string fullName, string value) { Org.Apache.REEF.Tang.Protobuf.Instance instance = new Org.Apache.REEF.Tang.Protobuf.Instance(); instance.value = value; Org.Apache.REEF.Tang.Protobuf.InjectionPlan plan = new Org.Apache.REEF.Tang.Protobuf.InjectionPlan(); plan.name = fullName; plan.instance = instance; return(plan); }
private static Org.Apache.REEF.Tang.Protobuf.InjectionPlan NewInstance(string fullName, string value) { Org.Apache.REEF.Tang.Protobuf.Instance instance = new Org.Apache.REEF.Tang.Protobuf.Instance(); instance.value = value; Org.Apache.REEF.Tang.Protobuf.InjectionPlan plan = new Org.Apache.REEF.Tang.Protobuf.InjectionPlan(); plan.name = fullName; plan.instance = instance; return plan; }