• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Optional类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Optional的典型用法代码示例。如果您正苦于以下问题:C# Optional类的具体用法?C# Optional怎么用?C# Optional使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Optional类属于命名空间,在下文中一共展示了Optional类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SelectFromQuery

		private SelectFromQuery(bool? restriction, TopExpression top, Sequence<ColumnItem> columnItems, Optional<DestinationRowset> intoClause, FromClause fromClause, Optional<Predicate> whereClause, Optional<Sequence<Expression>> groupByClause, Optional<Predicate> havingClause,
		                        Optional<Sequence<OrderExpression>> orderList, ForClause forClause, RowsetCombineClause unionClause): base(restriction, top, columnItems, intoClause, whereClause, forClause, unionClause) {
			this.fromClause = fromClause;
			this.groupByClause = groupByClause.ToList();
			this.havingClause = havingClause;
			this.orderList = orderList.ToList();
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:7,代码来源:SelectFromQuery.cs


示例2: ActiveContext

 internal ActiveContext(IActiveContextClr2Java clr2Java)
 {
     InstanceId = Guid.NewGuid().ToString("N");
     Clr2Java = clr2Java;
     _serializer = new AvroConfigurationSerializer();
     _parentId = Optional<string>.OfNullable(clr2Java.GetParentId());
 }
开发者ID:kumbhare,项目名称:reef,代码行数:7,代码来源:ActiveContext.cs


示例3: ServerSettings

 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerSettings"/> class.
 /// </summary>
 /// <param name="heartbeatInterval">The heartbeat interval.</param>
 /// <param name="heartbeatTimeout">The heartbeat timeout.</param>
 public ServerSettings(
     Optional<TimeSpan> heartbeatInterval = default(Optional<TimeSpan>),
     Optional<TimeSpan> heartbeatTimeout = default(Optional<TimeSpan>))
 {
     _heartbeatInterval = Ensure.IsInfiniteOrGreaterThanOrEqualToZero(heartbeatInterval.WithDefault(DefaultHeartbeatInterval), "heartbeatInterval");
     _heartbeatTimeout = Ensure.IsInfiniteOrGreaterThanOrEqualToZero(heartbeatTimeout.WithDefault(DefaultHeartbeatTimeout), "heartbeatTimeout");
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:13,代码来源:ServerSettings.cs


示例4: Deserialize

 public void Deserialize(Deserializer deserializer)
 {
     this.Unknown0 = deserializer.ReadInt16();
     this.Unknown1 = deserializer.ReadVarint();
     this.Unknown2 = deserializer.ReadByte();
     this.Unknown3 = deserializer.ReadVarint();
     byte unknown4Length = deserializer.ReadByte();
     if (unknown4Length > 81)
     {
         throw new InvalidDataException();
     }
     Unknown4 = new byte[unknown4Length];
     for (int i = 0; i < Unknown4.Length; i++)
     {
         Unknown4[i] = deserializer.ReadByte();
     }
     this.Unknown5 = deserializer.ReadVector4();
     this.Unknown6 = deserializer.ReadVarint();
     if (deserializer.ReadBoolean())
     {
         this.Unknown7 = new Optional<Vector4>(deserializer.ReadVector4());
     }
     else
     {
         this.Unknown7 = null;
     }
     this.Unknown8 = deserializer.ReadByte();
     this.Unknown9 = deserializer.ReadByte();
     this.Unknown10 = deserializer.ReadByte();
     this.Unknown11 = deserializer.ReadInt16();
     this.Unknown12 = deserializer.ReadInt16();
     this.Unknown13 = deserializer.ReadInt16();
 }
开发者ID:puppt,项目名称:GW2Emu,代码行数:33,代码来源:P006_UnknownMessage.cs


示例5: CommonTableExpression

		public CommonTableExpression(AliasName aliasName, Optional<Sequence<ColumnName>> columnNames, SelectQuery selectQuery) {
			Debug.Assert(aliasName != null);
			Debug.Assert(selectQuery != null);
			this.aliasName = aliasName;
			this.columnNames = columnNames.ToList();
			this.selectQuery = selectQuery;
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:7,代码来源:CommonTableExpression.cs


示例6: ContextRuntime

        /// <summary>
        /// Create a new ContextRuntime.
        /// </summary>
        /// <param name="serviceInjector"></param>
        /// <param name="contextConfiguration">the Configuration for this context.</param>
        /// <param name="parentContext"></param>
        public ContextRuntime(
                IInjector serviceInjector,
                IConfiguration contextConfiguration,
                Optional<ContextRuntime> parentContext)
        {
            ContextConfiguration config = contextConfiguration as ContextConfiguration;
            if (config == null)
            {
                var e = new ArgumentException("contextConfiguration is not of type ContextConfiguration");
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
            }
            _contextLifeCycle = new ContextLifeCycle(config.Id);
            _serviceInjector = serviceInjector;
            _parentContext = parentContext;
            try
            {
                _contextInjector = serviceInjector.ForkInjector();
            }
            catch (Exception e)
            {
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);

                Optional<string> parentId = ParentContext.IsPresent() ?
                    Optional<string>.Of(ParentContext.Value.Id) :
                    Optional<string>.Empty();
                ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(contextConfiguration), parentId, "Unable to spawn context", e);
                
                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
            }
            // Trigger the context start events on contextInjector.
            _contextLifeCycle.Start();
        }
开发者ID:kijungs,项目名称:incubator-reef,代码行数:38,代码来源:ContextRuntime.cs


示例7: With

        private CompletionRules With(
            Optional<bool> dismissIfEmpty = default(Optional<bool>),
            Optional<bool> dismissIfLastCharacterDeleted = default(Optional<bool>),
            Optional<ImmutableArray<char>> defaultCommitCharacters = default(Optional<ImmutableArray<char>>),
            Optional<EnterKeyRule> defaultEnterKeyRule = default(Optional<EnterKeyRule>))
        {
            var newDismissIfEmpty = dismissIfEmpty.HasValue ? dismissIfEmpty.Value : this.DismissIfEmpty;
            var newDismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted.HasValue ? dismissIfLastCharacterDeleted.Value : this.DismissIfLastCharacterDeleted;
            var newDefaultCommitCharacters = defaultCommitCharacters.HasValue ? defaultCommitCharacters.Value : this.DefaultCommitCharacters;
            var newDefaultEnterKeyRule = defaultEnterKeyRule.HasValue ? defaultEnterKeyRule.Value : this.DefaultEnterKeyRule;

            if (newDismissIfEmpty == this.DismissIfEmpty
                && newDismissIfLastCharacterDeleted == this.DismissIfLastCharacterDeleted
                && newDefaultCommitCharacters == this.DefaultCommitCharacters
                && newDefaultEnterKeyRule == this.DefaultEnterKeyRule)
            {
                return this;
            }
            else
            {
                return Create(
                    newDismissIfEmpty,
                    newDismissIfLastCharacterDeleted,
                    newDefaultCommitCharacters,
                    newDefaultEnterKeyRule);
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:27,代码来源:CompletionRules.cs


示例8: ContextException

 internal ContextException(
     string contextId, Optional<string> parentId, string message, Exception inner) :
     base(message, inner)
 {
     _contextId = contextId;
     _parentId = parentId;
 }
开发者ID:beomyeol,项目名称:reef,代码行数:7,代码来源:ContextException.cs


示例9: WhenOptionalIsSet

        public void WhenOptionalIsSet()
        {
            var optional = new Optional<Int32>(123);

            Assert.IsTrue(optional.IsSet);
            Assert.AreEqual(optional.Value, 123);
        }
开发者ID:AlexDenton,项目名称:Optional,代码行数:7,代码来源:OptionalTests.cs


示例10: TableForeignKeyConstraint

		public TableForeignKeyConstraint(ConstraintName constraintName, Sequence<ColumnName> columnNames, Qualified<SchemaName, TableName> refTableName, Optional<Sequence<ColumnName>> refColumnNames, Sequence<ForeignKeyAction> keyActions): base(constraintName) {
			Debug.Assert(refTableName != null);
			this.columnNames = columnNames.ToList();
			this.refTableName = refTableName;
			this.refColumnNames = refColumnNames.ToList();
			this.keyActions = keyActions.ToList();
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:7,代码来源:TableForeignKeyConstraint.cs


示例11: CreateBinaryNuspec

 static void CreateBinaryNuspec(
     string id, 
     string compiler, 
     IEnumerable<Targets.ItemDefinitionGroup> itemDefinitionGroupList,
     IEnumerable<Nuspec.File> fileList,
     IEnumerable<Nuspec.Dependency> dependencyList,
     Optional<string> name,
     IEnumerable<string> platformList)
 {
     var info = Config.CompilerMap[compiler];
     var description =
         id +
         ". Compiler: " +
         info.Name +
         ". Platforms: " +
         string.Join(", ", platformList) +
         ".";
     Nuspec.Create(
         id,
         id,
         Package.CompilerVersion(info),
         description,
         itemDefinitionGroupList,
         fileList,
         Enumerable.Empty<CompilationUnit>(),
         dependencyList,
         new[] { "binaries", compiler }.
             Concat(name.ToEnumerable()).
             Concat(platformList));
 }
开发者ID:AndreGleichner,项目名称:getboost,代码行数:30,代码来源:Program.cs


示例12: InjectServices

        private static IInjector InjectServices(Optional<ServiceConfiguration> serviceConfig)
        {
            // TODO[JIRA REEF-217]: Use base injector for the Evaluator here instead.
            IInjector rootServiceInjector;

            if (serviceConfig.IsPresent())
            {
                rootServiceInjector = TangFactory.GetTang().NewInjector(serviceConfig.Value.TangConfig);
                InjectedServices services = null;
                try
                {
                    services = rootServiceInjector.GetInstance<InjectedServices>();
                }
                catch (Exception e)
                {
                    Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Failed to instantiate service.", LOGGER);
                    InvalidOperationException ex = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Failed to inject service: encoutned error {1} with message [{0}] and stack trace:[{1}]", e, e.Message, e.StackTrace));
                    Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
                }
                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "injected {0} service(s)", services.Services.Count));
            }
            else
            {
                rootServiceInjector = TangFactory.GetTang().NewInjector();
                LOGGER.Log(Level.Info, "no service provided for injection.");
            }
            
            return rootServiceInjector;
        }
开发者ID:kumbhare,项目名称:reef,代码行数:29,代码来源:RootContextLauncher.cs


示例13: EvaluatorException

 internal EvaluatorException(string evaluatorId, string message, string javaStackTrace)
     : base(message)
 {
     _evaluatorId = evaluatorId;
     _javaStackTrace = string.IsNullOrWhiteSpace(javaStackTrace)
         ? Optional<string>.Empty()
         : Optional<string>.Of(javaStackTrace);
 }
开发者ID:shulmanb,项目名称:reef,代码行数:8,代码来源:EvaluatorException.cs


示例14: With

 // methods
 /// <summary>
 /// Returns a new ServerSettings instance with some settings changed.
 /// </summary>
 /// <param name="heartbeatInterval">The heartbeat interval.</param>
 /// <param name="heartbeatTimeout">The heartbeat timeout.</param>
 /// <returns>A new ServerSettings instance.</returns>
 public ServerSettings With(
     Optional<TimeSpan> heartbeatInterval = default(Optional<TimeSpan>),
     Optional<TimeSpan> heartbeatTimeout = default(Optional<TimeSpan>))
 {
     return new ServerSettings(
         heartbeatInterval: heartbeatInterval.WithDefault(_heartbeatInterval),
         heartbeatTimeout: heartbeatTimeout.WithDefault(_heartbeatTimeout));
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:15,代码来源:ServerSettings.cs


示例15: ResultCentricAggregateQueryTestResult

 /// <summary>
 /// Initializes a new instance of the <see cref="ResultCentricAggregateQueryTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualResult">The actual result.</param>
 /// <param name="actualException">The actual exception.</param>
 /// <param name="actualEvents">The actual events.</param>
 internal ResultCentricAggregateQueryTestResult(ResultCentricAggregateQueryTestSpecification specification, TestResultState state, Optional<object> actualResult, Optional<Exception> actualException, Optional<object[]> actualEvents)
 {
     _specification = specification;
     _state = state;
     _actualResult = actualResult;
     _actualException = actualException;
     _actualEvents = actualEvents;
 }
开发者ID:EsbenSkovPedersen,项目名称:AggregateSource,代码行数:16,代码来源:EventCentricAggregateQueryTestResult.cs


示例16: EventCentricTestResult

 /// <summary>
 /// Initializes a new instance of the <see cref="EventCentricTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualEvents">The actual events.</param>
 /// <param name="actualException">The actual exception.</param>
 internal EventCentricTestResult(EventCentricTestSpecification specification, TestResultState state,
                                 Optional<Fact[]> actualEvents, Optional<Exception> actualException)
 {
     _specification = specification;
     _state = state;
     _actualEvents = actualEvents;
     _actualException = actualException;
 }
开发者ID:EsbenSkovPedersen,项目名称:AggregateSource,代码行数:15,代码来源:EventCentricTestResult.cs


示例17: RootContextLauncher

 public RootContextLauncher(string id, IConfiguration contextConfiguration,
     Optional<ServiceConfiguration> rootServiceConfig, Optional<TaskConfiguration> rootTaskConfig)
 {
     Id = id;
     _rootContextConfiguration = contextConfiguration;
     _rootServiceInjector = InjectServices(rootServiceConfig);
     RootTaskConfig = rootTaskConfig;
 }
开发者ID:LastOne817,项目名称:reef,代码行数:8,代码来源:RootContextLauncher.cs


示例18: Parameter

		public Parameter(ParameterName parameterName, Qualified<SchemaName, TypeName> parameterTypeName, Optional<Literal> defaultValue, Optional<UnreservedKeyword> readOnly) {
			Debug.Assert(parameterName != null);
			Debug.Assert(parameterTypeName != null);
			this.parameterName = parameterName;
			this.parameterTypeName = parameterTypeName;
			this.defaultValue = defaultValue;
			this.readOnly = readOnly.HasValue();
		}
开发者ID:avonwyss,项目名称:bsn-modulestore,代码行数:8,代码来源:Parameter.cs


示例19: ContextClientCodeException

 /// <summary>
 /// construct the exception that caused the error
 /// </summary>
 /// <param name="contextId"> the id of the failed context.</param>
 /// <param name="parentId"> the id of the failed context's parent, if any.</param>
 /// <param name="message"> the error message </param>
 /// <param name="cause"> the exception that caused the error</param>
 public ContextClientCodeException(
         string contextId,
         Optional<string> parentId,
         string message,
         Exception cause)
     : base(contextId, parentId, "Failure in context '" + contextId + "': " + message, cause)
 {
 }
开发者ID:beomyeol,项目名称:reef,代码行数:15,代码来源:ContextClientCodeException.cs


示例20: ContextManager

 public ContextManager(HeartBeatManager heartBeatManager, Optional<ServiceConfiguration> rootServiceConfig, Optional<TaskConfiguration> rootTaskConfig)
 {
     using (LOGGER.LogFunction("ContextManager::ContextManager"))
     {
         _heartBeatManager = heartBeatManager;
         _rootContextLauncher = new RootContextLauncher(_heartBeatManager.EvaluatorSettings.RootContextConfig, rootServiceConfig, rootTaskConfig);
     }
 }
开发者ID:gyeongin,项目名称:reef,代码行数:8,代码来源:ContextManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Options类代码示例发布时间:2022-05-24
下一篇:
C# OptionType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap