Ejemplo n.º 1
0
            public ILabel NewLabel(ILabel oldLabel)
            {
                if (oldLabel is CoreLabel)
                {
                    return(new CoreLabel((CoreLabel)oldLabel));
                }
                else
                {
                    //Map the old interfaces to the correct key/value pairs
                    //Don't need to worry about HasIndex, which doesn't appear in any legacy code
                    var label = new CoreLabel();
                    if (oldLabel is IHasWord)
                    {
                        label.SetWord(((IHasWord)oldLabel).GetWord());
                    }
                    if (oldLabel is IHasTag)
                    {
                        label.SetTag(((IHasTag)oldLabel).Tag());
                    }
                    if (oldLabel is IHasOffset)
                    {
                        label.SetBeginPosition(((IHasOffset)oldLabel).BeginPosition());
                        label.SetEndPosition(((IHasOffset)oldLabel).EndPosition());
                    }
                    if (oldLabel is IHasCategory)
                    {
                        label.SetCategory(((IHasCategory)oldLabel).Category());
                    }
                    if (oldLabel is IHasIndex)
                    {
                        label.SetIndex(((IHasIndex)oldLabel).Index());
                    }

                    label.SetValue(oldLabel.Value());

                    return(label);
                }
            }