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


C# IParameters.Add方法代码示例

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


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

示例1: Create

        public IOperation Create(Field field, TflTransform element, IParameters parameters) {

            if (_isInitMode)
                return new EmptyOperation();

            Func<Row, bool> shouldRun = row => true;
            var toTimeZone = string.IsNullOrEmpty(element.ToTimeZone) ? _process.TimeZone : element.ToTimeZone;
            var hasParameters = parameters.Count > 0;
            var inKey = hasParameters ? parameters[0].Name : field.Alias;
            var inType = hasParameters ? parameters[0].SimpleType : field.SimpleType;
            var outKey = field.Alias;
            var outType = field.SimpleType;
            var scripts = new Dictionary<string, Script>();

            if (!hasParameters) {
                parameters.Add(field.Alias, field.Alias, null, field.SimpleType);
            }

            if (!element.RunField.Equals(string.Empty)) {
                var op = (ComparisonOperator)Enum.Parse(typeof(ComparisonOperator), element.RunOperator, true);
                var simpleType = Common.ToSimpleType(element.RunType.Equals(Common.DefaultValue) ? "boolean" : element.RunType);
                var runValue = simpleType.StartsWith("bool") && element.RunValue.Equals(Common.DefaultValue) ? "true" : element.RunValue;
                var value = Common.ConversionMap[simpleType](runValue);
                shouldRun = row => Common.CompareMap[op](row[element.RunField], value);
            }

            var templates = ComposeTemplates(field, element);

            switch (element.Method.ToLower()) {
                case "convert":
                    return new ConvertOperation(
                        inKey,
                        inType,
                        outKey,
                        element.To.Equals(Common.DefaultValue) ? outType : element.To,
                        element.Encoding,
                        element.Format
                    ) { ShouldRun = shouldRun, EntityName = _entityName };

                case "copy":
                    if (parameters.Count > 1)
                        return new CopyMultipleOperation(outKey, parameters) { ShouldRun = shouldRun, EntityName = _entityName };

                    return new CopyOperation(inKey, outKey) { ShouldRun = shouldRun, EntityName = _entityName };

                case "collapse":
                    var partial = new PartialProcessOperation(_process);
                    partial.Register(new RegexReplaceOperation(inKey, outKey, "[\r\n]{2,}", "\r\n", 0) { ShouldRun = shouldRun, EntityName = _entityName });
                    partial.Register(new RegexReplaceOperation(inKey, outKey, " {2,}", " ", 0) { ShouldRun = shouldRun, EntityName = _entityName });
                    partial.Register(new TrimOperation(inKey, outKey, " ") { ShouldRun = shouldRun, EntityName = _entityName });
                    return partial;

                case "compress":
                    return new CompressOperation(inKey, outKey) { ShouldRun = shouldRun, EntityName = _entityName };

                case "toyesno":
                    return new ToYesNoOperation(inKey, outKey) { ShouldRun = shouldRun, EntityName =  _entityName};

                case "decompress":
                    return new DecompressOperation(inKey, outKey) { ShouldRun = shouldRun, EntityName = _entityName };

                case "elipse":
                    return new ElipseOperation(inKey, outKey, element.Length, element.Elipse) { ShouldRun = shouldRun, EntityName = _entityName };

                case "replace":
                    return new ReplaceOperation(
                        inKey,
                        outKey,
                        element.OldValue,
                        element.NewValue
                    ) { ShouldRun = shouldRun, EntityName = _entityName };

                case "regexreplace":
                    return new RegexReplaceOperation(
                        inKey,
                        outKey,
                        element.Pattern,
                        element.Replacement,
                        element.Count
                    ) { ShouldRun = shouldRun, EntityName = _entityName };

                case "striphtml":
                    return new RegexReplaceOperation(
                        inKey,
                        outKey,
                        @"<[^>]+>|&nbsp;",
                        string.Empty,
                        0
                    ) { ShouldRun = shouldRun, EntityName = _entityName };

                case "insert":
                    return new InsertOperation(
                        inKey,
                        outKey,
                        element.StartIndex,
                        element.Value,
                        parameters[0].Name.Equals(outKey) ? null : GetParameter(_entityName, parameters[0].Name)
                    ) { ShouldRun = shouldRun, EntityName = _entityName };

                case "insertinterval":
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:Transformalize,代码行数:101,代码来源:TransformOperationFactory.cs


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