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


C# IComponent.AddInput方法代码示例

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


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

示例1: 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

示例2: Orify

        /// <summary>
        /// Adds an or gate connecting the inputs to produce the output.
        /// Handles special optimization cases like a true/false input.
        /// </summary>
        private static void Orify(ICollection<IComponent> inputs, IComponent output, IConstant falseProp)
        {
            //TODO: Look for already-existing ors with the same inputs?
            //Or can this be handled with a GDL transformation?

            //Special case: An input is the true constant
            IEnumerable<IComponent> trueConstants = inputs.Where(input => input is IConstant && input.Value);
            foreach (IComponent input in trueConstants)
            {
                //True constant: connect that to the component, done
                input.AddOutput(output);
                output.AddInput(input);
                return;
            }

            //Special case: An input is "or"
            //I'm honestly not sure how to handle special cases here...
            //What if that "or" gate has multiple outputs? Could that happen?

            //For reals... just skip over any false constants
            var or = _componentFactory.CreateOr();
            IEnumerable<IComponent> nonConstants = inputs.Where(input => !(input is IConstant));
            foreach (IComponent input in nonConstants)
            {
                input.AddOutput(or);
                or.AddInput(input);
            }

            //What if they're all false? (Or inputs is empty?) Then no inputs at this point...
            if (!or.Inputs.Any())
            {
                //Hook up to "false"
                falseProp.AddOutput(output);
                output.AddInput(falseProp);
                return;
            }
            //If there's just one, on the other hand, don't use the or gate
            if (or.Inputs.Count == 1)
            {
                IComponent input = or.GetSingleInput();
                input.RemoveOutput(or);
                or.RemoveInput(input);
                input.AddOutput(output);
                output.AddInput(input);
                return;
            }
            or.AddOutput(output);
            output.AddInput(or);
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:53,代码来源:OptimizingPropNetFactory.cs

示例3: Andify

        private void Andify(List<IComponent> inputs, IComponent output, IConstant trueProp)
        {
            //Special case: If the inputs include false, connect false to thisComponent
            IEnumerable<IComponent> falseConstants = inputs.Where(c => c is IConstant && !c.Value);
            foreach (IComponent c in falseConstants)
            {
                //Connect false (c) to the output
                output.AddInput(c);
                c.AddOutput(output);
                return;
            }

            //For reals... just skip over any true constants
            var and = _componentFactory.CreateAnd();
            IEnumerable<IComponent> nonConstants = inputs.Where(input => !(input is IConstant));
            foreach (IComponent input in nonConstants)
            {
                input.AddOutput(and);
                and.AddInput(input);
            }

            //What if they're all true? (Or inputs is empty?) Then no inputs at this point...
            if (!and.Inputs.Any())
            {
                //Hook up to "true"
                trueProp.AddOutput(output);
                output.AddInput(trueProp);
                return;
            }
            //If there's just one, on the other hand, don't use the and gate
            if (and.Inputs.Count == 1)
            {
                IComponent input = and.GetSingleInput();
                input.RemoveOutput(and);
                and.RemoveInput(input);
                input.AddOutput(output);
                output.AddInput(input);
                return;
            }
            and.AddOutput(output);
            output.AddInput(and);
        }
开发者ID:druzil,项目名称:nggp-base,代码行数:42,代码来源:SentenceFormAdder.cs


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