Пример #1
0
 public static InjectionPlanProto.InjectionPlan Serialize(InjectionPlan ip)
 {
     if (ip is Constructor)
     {
         Constructor     cons = (Constructor)ip;
         InjectionPlan[] args = cons.GetArgs();
         InjectionPlanProto.InjectionPlan[] protoArgs = new InjectionPlanProto.InjectionPlan[args.Length];
         for (int i = 0; i < args.Length; i++)
         {
             protoArgs[i] = Serialize(args[i]);
         }
         return(NewConstructor(ip.GetNode().GetFullName(), protoArgs.ToList <InjectionPlanProto.InjectionPlan>()));
     }
     if (ip is Subplan)
     {
         Subplan         sp   = (Subplan)ip;
         InjectionPlan[] args = sp.GetPlans();
         InjectionPlanProto.InjectionPlan[] subPlans = new InjectionPlanProto.InjectionPlan[args.Length];
         for (int i = 0; i < args.Length; i++)
         {
             subPlans[i] = Serialize(args[i]);
         }
         return(NewSubplan(ip.GetNode().GetFullName(), sp.GetSelectedIndex(), subPlans.ToList <InjectionPlanProto.InjectionPlan>()));
     }
     if (ip is CsInstance)
     {
         CsInstance ji = (CsInstance)ip;
         return(NewInstance(ip.GetNode().GetFullName(), ji.GetInstanceAsString()));
     }
     Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(
                                                                "Encountered unknown type of InjectionPlan: " + ip), LOGGER);
     return(null);
 }
Пример #2
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (Issuer != null)
            {
                result.AddRange(Issuer.Validate());
            }
            if (Period != null)
            {
                result.AddRange(Period.Validate());
            }
            if (Type != null)
            {
                result.AddRange(Type.Validate());
            }
            if (Identifier != null)
            {
                result.AddRange(Identifier.Validate());
            }
            if (Group != null)
            {
                result.AddRange(Group.Validate());
            }
            if (Plan != null)
            {
                result.AddRange(Plan.Validate());
            }
            if (Subplan != null)
            {
                result.AddRange(Subplan.Validate());
            }
            if (DependentElement != null)
            {
                result.AddRange(DependentElement.Validate());
            }
            if (SequenceElement != null)
            {
                result.AddRange(SequenceElement.Validate());
            }
            if (Subscriber != null)
            {
                result.AddRange(Subscriber.Validate());
            }

            return(result);
        }
Пример #3
0
        private static InjectionPlan NewSubplan(string fullName, int selectedPlan, List<InjectionPlan> plans) 
        {
            Subplan subPlan = new Subplan();

            subPlan.selected_plan = selectedPlan;
            foreach (InjectionPlan p in plans)
            {
                subPlan.plans.Add(p);
            }

            InjectionPlan plan = new InjectionPlan();
            plan.name = fullName;
            plan.subplan = subPlan;
            return plan;
        }