public IClassHierarchy Merge(IClassHierarchy ch)
        {
            if (this == ch)
            {
                return(this);
            }

            if (!(ch is ProtocolBufferClassHierarchy))
            {
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException(
                                                                           "Cannot merge ExternalClassHierarchies yet!"), LOGGER);
            }

            ProtocolBufferClassHierarchy pch = (ProtocolBufferClassHierarchy)ch;

            foreach (var pair in pch.lookupTable)
            {
                if (!this.lookupTable.ContainsKey(pair.Key))
                {
                    this.lookupTable.Add(pair);
                }
            }

            foreach (INode n in ch.GetNamespace().GetChildren())
            {
                if (!rootNode.Contains(n.GetFullName()))
                {
                    if (n is INamedParameterNode)
                    {
                        INamedParameterNode np = (INamedParameterNode)n;
                        new NamedParameterNodeImpl(this.rootNode, np.GetName(),
                                                   np.GetFullName(), np.GetFullArgName(), np.GetSimpleArgName(),
                                                   np.IsSet(), np.IsList(), np.GetDocumentation(), np.GetShortName(),
                                                   np.GetDefaultInstanceAsStrings().ToArray());
                    }
                    else if (n is IClassNode)
                    {
                        IClassNode cn = (IClassNode)n;
                        new ClassNodeImpl(rootNode, cn.GetName(), cn.GetFullName(),
                                          cn.IsUnit(), cn.IsInjectionCandidate(),
                                          cn.IsExternalConstructor(), cn.GetInjectableConstructors(),
                                          cn.GetAllConstructors(), cn.GetDefaultImplementation());
                    }
                }
            }

            return(this);
        }
 /// <summary>
 /// Serialize a ClassHierarchy into AvroNode object
 /// </summary>
 /// <param name="ch"></param>
 /// <returns></returns>
 public AvroNode ToAvroNode(IClassHierarchy ch)
 {
     return NewAvroNode(ch.GetNamespace());
 }
 public static Org.Apache.REEF.Tang.Protobuf.Node Serialize(IClassHierarchy classHierarchy)
 {
     return(SerializeNode(classHierarchy.GetNamespace()));
 }
        /// <summary>
        /// Merge two Class Hierarchy 
        /// </summary>
        /// <param name="ch"></param>
        /// <returns></returns>
        public IClassHierarchy Merge(IClassHierarchy ch)
        {
            if (this == ch)
            {
                return this;
            }

            if (!(ch is AvroClassHierarchy))
            {
                Utilities.Diagnostics.Exceptions.Throw(new NotSupportedException(
                                                            "Cannot merge ExternalClassHierarchies yet!"), LOGGER);
            }

            AvroClassHierarchy ach = (AvroClassHierarchy)ch;
            foreach (var pair in ach._lookupTable)
            {
                if (!this._lookupTable.ContainsKey(pair.Key))
                {
                    this._lookupTable.Add(pair);
                }
            }

            foreach (INode n in ch.GetNamespace().GetChildren())
            {
                if (!_rootNode.Contains(n.GetFullName()))
                {
                    if (n is INamedParameterNode)
                    {
                        INamedParameterNode np = (INamedParameterNode)n;
                        new NamedParameterNodeImpl(this._rootNode, np.GetName(),
                                                   np.GetFullName(), np.GetFullArgName(), np.GetSimpleArgName(),
                                                   np.IsSet(), np.IsList(), np.GetDocumentation(), np.GetShortName(),
                                                   np.GetDefaultInstanceAsStrings().ToArray());
                    }
                    else if (n is IClassNode)
                    {
                        IClassNode cn = (IClassNode)n;
                        new ClassNodeImpl(_rootNode, cn.GetName(), cn.GetFullName(),
                                          cn.IsUnit(), cn.IsInjectionCandidate(),
                                          cn.IsExternalConstructor(), cn.GetInjectableConstructors(),
                                          cn.GetAllConstructors(), cn.GetDefaultImplementation());
                    }
                }
            }
            return this;
        }
示例#5
0
 /// <summary>
 /// Serialize a ClassHierarchy into AvroNode object
 /// </summary>
 /// <param name="ch"></param>
 /// <returns></returns>
 public AvroNode ToAvroNode(IClassHierarchy ch)
 {
     return(NewAvroNode(ch.GetNamespace()));
 }
 public static Node Serialize(IClassHierarchy classHierarchy)
 {
     return SerializeNode(classHierarchy.GetNamespace());
 }
示例#7
0
 public static Node Serialize(IClassHierarchy classHierarchy)
 {
     return(SerializeNode(classHierarchy.GetNamespace()));
 }
 public static Org.Apache.REEF.Tang.Protobuf.Node Serialize(IClassHierarchy classHierarchy)
 {
     return SerializeNode(classHierarchy.GetNamespace());
 }