当前位置: 首页>>代码示例>>C#>>正文


C# IComponent.AddOutput方法代码示例

本文整理汇总了C#中IComponent.AddOutput方法的典型用法代码示例。如果您正苦于以下问题:C# IComponent.AddOutput方法的具体用法?C# IComponent.AddOutput怎么用?C# IComponent.AddOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IComponent的用法示例。


在下文中一共展示了IComponent.AddOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OptimizeAwayFalse

        //TODO: Create a version with just a set of components that we can share with post-optimizations
        private static void OptimizeAwayFalse(IDictionary<Fact, IComponent> components, Dictionary<Fact, IComponent> negations,
            PropNet pn, IComponent trueComponent, IComponent falseComponent)
        {
            Debug.Assert((components != null && negations != null) || pn != null);
            Debug.Assert((components == null && negations == null) || pn == null);
            foreach (IComponent output in falseComponent.Outputs.ToList())
            {
                if (IsEssentialProposition(output) || output is ITransition)
                {
                    //Since this is the false constant, there are a few "essential" types we don't actually want to keep around.
                    if (!IsLegalOrGoalProposition(output))
                        continue;
                }
                var prop = output as IProposition;
                if (prop != null)
                {
                    //Move its outputs to be outputs of false
                    foreach (IComponent child in prop.Outputs)
                    {
                        //Disconnect
                        child.RemoveInput(prop);
                        //output.removeOutput(child); //do at end
                        //Reconnect; will get children before returning, if nonessential
                        falseComponent.AddOutput(child);
                        child.AddInput(falseComponent);
                    }
                    prop.RemoveAllOutputs();

                    if (!IsEssentialProposition(prop))
                    {
                        //Remove the proposition entirely
                        falseComponent.RemoveOutput(prop);
                        output.RemoveInput(falseComponent);
                        //Update its location to the trueComponent in our map
                        if (components != null)
                        {
                            components[prop.Name] = falseComponent;
                            negations[prop.Name] = trueComponent;
                        }
                        else
                            pn.RemoveComponent(prop);
                    }
                }
                else
                {
                    var and = output as IAnd;
                    if (and != null)
                    {
                        //Attach children of and to falseComponent
                        foreach (IComponent child in and.Outputs)
                        {
                            child.AddInput(falseComponent);
                            falseComponent.AddOutput(child);
                            child.RemoveInput(and);
                        }
                        //Disconnect and completely
                        and.RemoveAllOutputs();
                        foreach (IComponent parent in and.Inputs)
                            parent.RemoveOutput(and);
                        and.RemoveAllInputs();
                        if (pn != null)
                            pn.RemoveComponent(and);
                    }
                    else
                    {
                        var or = output as IOr;
                        if (or != null)
                        {
                            //Remove as input from or
                            or.RemoveInput(falseComponent);
                            falseComponent.RemoveOutput(or);
                            //If or has only one input, remove it
                            if (or.Inputs.Count == 1)
                            {
                                IComponent input = or.GetSingleInput();
                                or.RemoveInput(input);
                                input.RemoveOutput(or);
                                foreach (IComponent output1 in or.Outputs)
                                {
                                    //Disconnect from and
                                    output1.RemoveInput(or);
                                    //or.removeOutput(out); //do at end
                                    //Connect directly to the new input
                                    output1.AddInput(input);
                                    input.AddOutput(output1);
                                }
                                or.RemoveAllOutputs();
                                if (pn != null)
                                {
                                    pn.RemoveComponent(or);
                                }
                            }
                            else if (!or.Inputs.Any())
                            {
                                if (pn != null)
                                {
                                    pn.RemoveComponent(or);
                                }
                            }
//.........这里部分代码省略.........
开发者ID:druzil,项目名称:nggp-base,代码行数:101,代码来源:OptimizingPropNetFactory.cs

示例2: OptimizeAwayTrue

        private static void OptimizeAwayTrue(IDictionary<Fact, IComponent> components, IDictionary<Fact, IComponent> negations,
            PropNet pn, IComponent trueComponent, IComponent falseComponent)
        {
            Debug.Assert((components != null && negations != null) || pn != null);
            foreach (IComponent output in trueComponent.Outputs.ToList())
            {
                if (IsEssentialProposition(output) || output is ITransition)
                    continue;
                var prop = output as IProposition;
                if (prop != null)
                {
                    //Move its outputs to be outputs of true
                    foreach (IComponent child in prop.Outputs)
                    {
                        //Disconnect
                        child.RemoveInput(prop);
                        //output.removeOutput(child); //do at end
                        //Reconnect; will get children before returning, if nonessential
                        trueComponent.AddOutput(child);
                        child.AddInput(trueComponent);
                    }
                    prop.RemoveAllOutputs();

                    if (!IsEssentialProposition(prop))
                    {
                        //Remove the proposition entirely
                        trueComponent.RemoveOutput(prop);
                        output.RemoveInput(trueComponent);
                        //Update its location to the trueComponent in our map
                        if (components != null)
                        {
                            components[prop.Name] = trueComponent;
                            Debug.Assert(negations != null, "negations != null");
                            negations[prop.Name] = falseComponent;
                        }
                        else
                            pn.RemoveComponent(prop);
                    }
                }
                else
                {
                    var or = output as IOr;
                    if (or != null)
                    {
                        //Attach children of or to trueComponent
                        foreach (IComponent child in or.Outputs)
                        {
                            child.AddInput(trueComponent);
                            trueComponent.AddOutput(child);
                            child.RemoveInput(or);
                        }
                        //Disconnect or completely
                        or.RemoveAllOutputs();
                        foreach (IComponent parent in or.Inputs)
                            parent.RemoveOutput(or);
                        or.RemoveAllInputs();
                        if (pn != null)
                            pn.RemoveComponent(or);
                    }
                    else
                    {
                        var and = output as IAnd;
                        if (and != null)
                        {
                            //Remove as input from and
                            and.RemoveInput(trueComponent);
                            trueComponent.RemoveOutput(and);
                            //If and has only one input, remove it
                            if (and.Inputs.Count == 1)
                            {
                                IComponent input = and.GetSingleInput();
                                and.RemoveInput(input);
                                input.RemoveOutput(and);
                                foreach (IComponent output1 in and.Outputs)
                                {
                                    //Disconnect from and
                                    output1.RemoveInput(and);
                                    //and.removeOutput(out); //do at end
                                    //Connect directly to the new input
                                    output1.AddInput(input);
                                    input.AddOutput(output1);
                                }
                                and.RemoveAllOutputs();
                                if (pn != null)
                                    pn.RemoveComponent(and);
                            }
                            else if (and.Inputs.Any())
                                if (pn != null)
                                    pn.RemoveComponent(and);
                        }
                        else
                        {
                            var not = output as INot;
                            if (not != null)
                            {
                                //Disconnect from trueComponent
                                not.RemoveInput(trueComponent);
                                trueComponent.RemoveOutput(not);
                                //Connect all children of the not to falseComponent
                                foreach (IComponent child in not.Outputs)
//.........这里部分代码省略.........
开发者ID:druzil,项目名称:nggp-base,代码行数:101,代码来源:OptimizingPropNetFactory.cs

示例3: Link

 /// <summary>
 /// Adds inputs and outputs to <tt>source</tt> and <tt>target</tt> such
 /// that <tt>source</tt> becomes an input to <tt>target</tt>.
 /// </summary>
 /// <param name="source">A component.</param>
 /// <param name="target">A second component.</param>
 private static void Link(IComponent source, IComponent target)
 {
     source.AddOutput(target);
     target.AddInput(source);
 }
开发者ID:druzil,项目名称:nggp-base,代码行数:11,代码来源:PropNetConverter.cs


注:本文中的IComponent.AddOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。