コード例 #1
0
ファイル: AvroClassHierarchy.cs プロジェクト: shulmanb/reef
        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);
            }
        }
コード例 #2
0
        private static void ParseSubHierarchy(INode parent, Node n)
        {
            INode parsed = null;
            if (n.package_node != null)
            {
                parsed = new PackageNodeImpl(parent, n.name, n.full_name);
            }
            else if (n.named_parameter_node != null)
            {
                NamedParameterNode np = n.named_parameter_node;

                if (!string.IsNullOrWhiteSpace(np.alias_name) && !string.IsNullOrWhiteSpace(np.alias_language))
                {
                    Language language;
                    try
                    {                        
                        Enum.TryParse(np.alias_language, true, out language);
                    }
                    catch (Exception)
                    {
                        string msg = string.Format(CultureInfo.CurrentCulture, "Language {0} passed in is not supported", np.alias_language);
                        throw new ArgumentException(msg);
                    }

                    parsed = new NamedParameterNodeImpl(parent, n.name,
                        n.full_name, np.full_arg_class_name, np.simple_arg_class_name,
                        np.is_set, np.is_list, np.documentation, np.short_name,
                        np.instance_default.ToArray(), np.alias_name, language);
                }
                else
                {
                    parsed = new NamedParameterNodeImpl(parent, n.name,
                       n.full_name, np.full_arg_class_name, np.simple_arg_class_name,
                       np.is_set, np.is_list, np.documentation, np.short_name,
                       np.instance_default.ToArray());
                }
            }
            else if (n.class_node != null)
            {
                ClassNode cn = n.class_node;
                IList<IConstructorDef> injectableConstructors = new List<IConstructorDef>();
                IList<IConstructorDef> allConstructors = new List<IConstructorDef>();

                foreach (ConstructorDef injectable in cn.InjectableConstructors)
                {
                    IConstructorDef def = ParseConstructorDef(injectable, true);
                    injectableConstructors.Add(def);
                    allConstructors.Add(def);
                }
                foreach (ConstructorDef other in cn.OtherConstructors)
                {
                    IConstructorDef def = ParseConstructorDef(other, false);
                    allConstructors.Add(def);
                }

                IConstructorDef[] dummy = new ConstructorDefImpl[0];
                parsed = new ClassNodeImpl(parent, n.name, n.full_name,
                cn.is_unit, cn.is_injection_candidate,
                cn.is_external_constructor, injectableConstructors,
                allConstructors, cn.default_implementation);
            }
            else
            {
                Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Bad protocol buffer: got abstract node" + n), LOGGER); 
            }

            foreach (Node child in n.children)
            {
                ParseSubHierarchy(parsed, child);
            }
        }
コード例 #3
0
        private void ParseSubHierarchy(INode parent, AvroNode n)
        {
            INode parsed = null;
            if (n.packageNode != null && !n.packageNode.Equals(""))
            {
                parsed = new PackageNodeImpl(parent, n.name, n.fullName);
            }
            else if (n.namedParameterNode != null && !n.namedParameterNode.Equals(""))
            {
                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(""))
            {
                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);
            }
        }
コード例 #4
0
        private static void ParseSubHierarchy(INode parent, Org.Apache.REEF.Tang.Protobuf.Node n)
        {
            INode parsed = null;
            if (n.package_node != null)
            {
                parsed = new PackageNodeImpl(parent, n.name, n.full_name);
            }
            else if (n.named_parameter_node != null)
            {
                Org.Apache.REEF.Tang.Protobuf.NamedParameterNode np = n.named_parameter_node;

                if (np.alias_name != null && np.alias_language != null)
                {
                    parsed = new NamedParameterNodeImpl(parent, n.name,
                        n.full_name, np.full_arg_class_name, np.simple_arg_class_name,
                        np.is_set, np.is_list, np.documentation, np.short_name,
                        np.instance_default.ToArray(), np.alias_name, np.alias_language);
                }
                else
                {
                    parsed = new NamedParameterNodeImpl(parent, n.name,
                       n.full_name, np.full_arg_class_name, np.simple_arg_class_name,
                       np.is_set, np.is_list, np.documentation, np.short_name,
                       np.instance_default.ToArray());
                }
            }
            else if (n.class_node != null)
            {
                Org.Apache.REEF.Tang.Protobuf.ClassNode cn = n.class_node;
                IList<IConstructorDef> injectableConstructors = new List<IConstructorDef>();
                IList<IConstructorDef> allConstructors = new List<IConstructorDef>();

                foreach (Org.Apache.REEF.Tang.Protobuf.ConstructorDef injectable in cn.InjectableConstructors)
                {
                    IConstructorDef def = ParseConstructorDef(injectable, true);
                    injectableConstructors.Add(def);
                    allConstructors.Add(def);
                }
                foreach (Org.Apache.REEF.Tang.Protobuf.ConstructorDef other in cn.OtherConstructors)
                {
                    IConstructorDef def = ParseConstructorDef(other, false);
                    allConstructors.Add(def);

                }

                IConstructorDef[] dummy = new ConstructorDefImpl[0];
                parsed = new ClassNodeImpl(parent, n.name, n.full_name,
                cn.is_unit, cn.is_injection_candidate,
                cn.is_external_constructor, injectableConstructors,
                allConstructors, cn.default_implementation);
            }
            else
            {
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Bad protocol buffer: got abstract node" + n), LOGGER); 
            }

            foreach (Org.Apache.REEF.Tang.Protobuf.Node child in n.children)
            {
                ParseSubHierarchy(parsed, child);
            }
        }