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


C# Option类代码示例

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


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

示例1: ParseFromPlaceholder

        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {

            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            string val = string.Empty;

            foreach (OptionItem o in baseOption.Items)
            {
                
                if (!o.IsLabel)
                {
                    string checkId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                    if (cb != null)
                    {
                        if (cb.Checked)
                        {                                                     
                                string temp = "";
                                if (val.Length > 0)
                                {
                                    temp += ",";
                                }
                                temp += o.Bvin;
                                val += temp;                         
                        }
                    }
                }
            }

            result.SelectionData = val;
     
            return result;
        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:35,代码来源:CheckBoxes.cs

示例2: ToInt64

 /// <summary>
 /// Converts the string representation of a number to its 64-bit signed integer equivalent. The return value indicates whether the conversion succeeded.
 /// </summary>
 /// <inheritdoc cref="ToInt32(Option{string})" source="param[name='value']"/>
 /// <returns>
 /// 64-bit signed integer value equivalent to the number contained in the <paramref name="value"/> if the conversion succeeded.
 /// <br/>-or-<br/>Null if the <paramref name="value"/> is None option.
 /// <br/>-or-<br/>Null if the conversion failed.
 /// </returns>
 public static long? ToInt64(Option<string> value)
 {
     // The TryParse() fails if the string parameter is null.
     // That means we don't need additional check if the value is None.
     long result;
     return long.TryParse(value.ValueOrNull, out result) ? result : (long?)null;
 }
开发者ID:hudo,项目名称:SwissKnife,代码行数:16,代码来源:StringConvert.cs

示例3: ToOptions

        public static IList<Option> ToOptions(this string[] args)
        {
            var options = new List<Option>();

            var parser = new Parser
                             {
                                 OnShortOption = name => options.Add(new Option {ShortName = name}),
                                 OnLongOption = name => options.Add(new Option {LongName = name}),
                                 OnValue = value =>
                                               {
                                                   if (options.Count > 0)
                                                   {
                                                       var last = options[options.Count - 1];
                                                       last.AddValue(value);
                                                   }
                                                   else
                                                   {
                                                       var option = new Option();
                                                       option.AddValue(value);
                                                       options.Add(option);
                                                   }
                                               }
                             };
            parser.Parse(args);

            return options;
        }
开发者ID:rh,项目名称:optional,代码行数:27,代码来源:Options.cs

示例4: LoadData

 protected override void LoadData()
 {
     if (Items.Count == 0)
         return;
     string maxId = Items[Items.Count - 1].Id;
     var option = new Option();
     option.Add(Const.MAX_ID, maxId);
     tweetService.GetMentions(option,
         tweets =>
         {
             if (!tweets.HasError)
             {
                 #region no more tweets
                 if (tweets.Count == 0)
                 {
                     toastMessageService.HandleMessage(languageHelper.GetString("Toast_Msg_NoMoreMentions"));
                 }
                 #endregion
                 #region add
                 else
                 {
     #if !LOCAL
                     if (maxId == tweets[0].Id)
                         tweets.RemoveAt(0);
     #endif
                     foreach (var tweet in tweets)
                     {
                         Items.Add(tweet);
                     }
                 }
                 #endregion
             }
             base.LoadDataCompleted();
         });
 }
开发者ID:Chicken4WP8,项目名称:Chicken4WP,代码行数:35,代码来源:MentionViewModel.cs

示例5: GetOpt

        /// <summary>
        /// Initializes a new instance of the <see cref="GetOpt"/> class.
        /// </summary>
        /// <param name="options">Array of all possible options</param>
        public GetOpt(Option[] options)
        {
            int idCount = 1;

            this.shortOptions = new Dictionary<char, int>();
            this.longOptions = new Dictionary<string, int>();
            this.shortOptionMap = new Dictionary<int, char>();
            this.Description = string.Empty;

            foreach (Option option in options)
            {
                if (option.HasArgument == false)
                {
                    idCount = -idCount;
                }

                try
                {
                    this.shortOptions.Add(option.ShortOption, idCount);
                    this.longOptions.Add(option.LongOption, idCount);
                }
                catch (ArgumentException e)
                {
                    throw new DuplicateOptionException("Duplicate option found", e);
                }

                this.shortOptionMap.Add(idCount, option.ShortOption);

                // FIXME make this a stringbuilder
                this.Description += "-" + option.ShortOption + ", --" + option.LongOption + "\t" + option.Description + "\n";

                idCount = idCount < 0 ? -idCount : idCount;
                idCount++;
            }
        }
开发者ID:codito,项目名称:oshell,代码行数:39,代码来源:GetOpt.cs

示例6: MyOptions

            public MyOptions()
            {
                RunMe = new Action("runme");
                RunMeToo = new Action("RunMeToo");
                DoWalk = new Option("walk", OptionValueType.None);
                FilePath = new Option("file", OptionValueType.Single);
                Names = new Option("names", OptionValueType.List);

                // help text
                RunMe.HelpText("Run me");
                RunMeToo.HelpText("Run me aswell");
                DoWalk.HelpText("Walk, don't run");
                FilePath.HelpText("");
                Names.HelpText("");

                // examples
                FilePath.ExampleText("C:\\Path\file.txt");
                Names.ExampleText("John");

                // ... or inline
                Sport = new Option("sport", OptionValueType.Single, SportDefault)
                    .HelpText("")
                    .ExampleText("Cricket");

            }
开发者ID:GianLorenzetto,项目名称:LineCommander,代码行数:25,代码来源:LineCommanderTest.cs

示例7: RenderAsControl

        public void RenderAsControl(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            System.Web.UI.WebControls.TextBox result = new System.Web.UI.WebControls.TextBox();
            result.ID = "opt" + baseOption.Bvin.Replace("-", "");
            result.ClientIDMode = System.Web.UI.ClientIDMode.Static;

            string c = this.GetColumns(baseOption);
            if (c == "") c = "20";
            string r = this.GetRows(baseOption);
            if (r == "") r = "1";

            int rint = 1;
            int.TryParse(r,out rint);
            int cint = 20;
            int.TryParse(c,out  cint);
            int mint = 255;
            int.TryParse(this.GetMaxLength(baseOption),out mint);

            result.Rows = rint;
            result.Columns = cint;
            result.MaxLength = mint;

            if (r != "1")
            {
                result.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine;            
            }

            ph.Controls.Add(result);                    
        }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:29,代码来源:TextInput.cs

示例8: Write

        /// <summary>
        /// Writes dump file with the specified options and exception info.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="exceptionInfo">The exception information.</param>
        /// <returns></returns>
        public static bool Write(Option options, ExceptionInfo exceptionInfo)
        {
            Process currentProcess = Process.GetCurrentProcess();
            IntPtr currentProcessHandle = currentProcess.Handle;
            uint currentProcessId = (uint) currentProcess.Id;
            MiniDumpExceptionInformation exp;
            exp.ThreadId = GetCurrentThreadId();
            exp.ClientPointers = false;
            exp.ExceptionPointers = IntPtr.Zero;
            if (exceptionInfo == ExceptionInfo.Present)
            {
                exp.ExceptionPointers = System.Runtime.InteropServices.Marshal.GetExceptionPointers();
            }

            bool bRet = false;
            using (var fs = new FileStream(GenerateDumpFilename(), FileMode.Create, FileAccess.ReadWrite, FileShare.Write))
            {
                if (exp.ExceptionPointers == IntPtr.Zero)
                {
                    bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fs.SafeFileHandle, (uint) options,
                                             IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                else
                {
                    bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fs.SafeFileHandle, (uint) options,
                                             ref exp,
                                             IntPtr.Zero, IntPtr.Zero);
                }
            }
            return bRet;
        }
开发者ID:udbeeq5566,项目名称:ESB,代码行数:37,代码来源:MiniDump.cs

示例9: ProcessLogItem

 public ProcessLogItem(ProcessLogItemType type, string message, Exception exception)
 {
     When = DateTime.UtcNow;
     Type = type;
     Message = Optional(message);
     Exception = Optional(exception);
 }
开发者ID:ricardopieper,项目名称:language-ext,代码行数:7,代码来源:ProcessLogItem.cs

示例10: StrategyContext

        StrategyContext(
            StrategyState global,
            Exception exception,
            object message,
            ProcessId sender,
            ProcessId failedProcess,
            ProcessId parentProcess,
            IEnumerable<ProcessId> siblings,
            IEnumerable<ProcessId> affects,
            Time pause,
            Option<Directive> directive,
            Option<MessageDirective> messageDirective
            )
        {
            bool isStop = directive == LanguageExt.Directive.Stop;

            Global = isStop ? StrategyState.Empty : global;
            Exception = exception;
            Message = message;
            Sender = sender;
            Self = failedProcess;
            ParentProcess = parentProcess;
            Siblings = siblings ?? Siblings;
            Affects = affects ?? Affects;
            Pause = isStop ? 0 * s : pause;
            Directive = directive;
            MessageDirective = messageDirective;
        }
开发者ID:OlduwanSteve,项目名称:language-ext,代码行数:28,代码来源:StrategyContext.cs

示例11: AddListElementRequest

 public AddListElementRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue listOfElements)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ListOfElements = listOfElements;
 }
开发者ID:LorenVS,项目名称:bacstack,代码行数:7,代码来源:AddListElementRequest.cs

示例12: Deserialize

        public virtual Message Deserialize(byte[] bytes)
        {
            var reader = new DatagramReader(bytes);
            var factory = new MessageFactory();
            var version = reader.Read(Message.VersionBits);

            if (version != Message.Version) {
                throw new SerializationException("incorrect version");
            }

            var type = (MessageType) reader.Read(Message.TypeBits);
            var optionCount = reader.Read(Message.OptionCountBits);
            var code = (CodeRegistry) reader.Read(Message.CodeBits);
            var id = reader.Read(Message.IdBits);
            var message = factory.Create(type, code, id);
            var currentOption = 0;

            for (var i = 0; i < optionCount; i++) {
                var delta = reader.Read(Message.OptionDeltaBits);
                var length = reader.Read(Message.OptionLengthBits);
                currentOption += delta;
                var option = new Option((OptionNumber) currentOption) { Value = reader.ReadBytes(length) };
                message.AddOption(option);
            }

            message.Payload = reader.ReadAllBytes();
            return message;
        }
开发者ID:marcelcastilho,项目名称:Catarinum,代码行数:28,代码来源:MessageSerializer.cs

示例13:

        int IOleCommandTarget.Exec(ref Guid commandGroup, uint commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            try
            {
                KeyInput ki;
                if (TryConvert(commandGroup, commandId, pvaIn, out ki))
                {
                    // Swallow the input if it's been flagged by a previous QueryStatus
                    if (SwallowIfNextExecMatches.IsSome && SwallowIfNextExecMatches.Value == ki)
                    {
                        return NativeMethods.S_OK;
                    }

                    if (_buffer.CanProcess(ki) && _buffer.Process(ki))
                    {
                        return NativeMethods.S_OK;
                    }
                }
            }
            finally
            {
                SwallowIfNextExecMatches = Option.None;
            }

            return _nextTarget.Exec(commandGroup, commandId, nCmdexecopt, pvaIn, pvaOut);
        }
开发者ID:rride,项目名称:VsVim,代码行数:26,代码来源:VsCommandTarget.cs

示例14: UnconfirmedTextMessageRequest

 public UnconfirmedTextMessageRequest(ObjectId textMessageSourceDevice, Option<MessageClassType> messageClass, MessagePriorityType messagePriority, string message)
 {
     this.TextMessageSourceDevice = textMessageSourceDevice;
     this.MessageClass = messageClass;
     this.MessagePriority = messagePriority;
     this.Message = message;
 }
开发者ID:LorenVS,项目名称:bacstack,代码行数:7,代码来源:UnconfirmedTextMessageRequest.cs

示例15: GetDefault

    public void GetDefault([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option)
    {
        Option o = Option.GetDefault(option);

        Option expected;

        switch (option)
        {
            case OptionName.Controls:
                expected = new Option() { Name = OptionName.Controls, Value = ControlOption.Arrows };
                break;
            case OptionName.Music:
                expected = new Option() { Name = OptionName.Music, Value = OnOffOption.On };
                break;
            case OptionName.Sound:
                expected = new Option() { Name = OptionName.Sound, Value = OnOffOption.On };
                break;
            case OptionName.UnlockedLevel:
                expected = new Option() { Name = OptionName.UnlockedLevel, Value = UnlockedLevelOption.Level_1 };
                break;
            default:
                expected = null;
                break;
        }

        Assert.AreEqual(expected.Name, o.Name);
        Assert.AreEqual(expected.Value, o.Value);
    }
开发者ID:sweetlee,项目名称:Breakout_AMSI,代码行数:28,代码来源:OptionControllerTest.cs


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