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

C# IParameterCollection类代码示例

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

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



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

示例1: NewToken

        object NewToken(RestVerbs verbs, IParameterCollection parameters)
        {
            var user = verbs["username"];
            var pass = verbs["password"];

            RestObject obj = null;
            if (Verify != null)
                obj = Verify(user, pass);

            if (obj == null)
                obj = new RestObject("401") { Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair." };

            if (obj.Error != null)
                return obj;

            string hash;
            var rand = new Random();
            var randbytes = new byte[32];
            do
            {
                rand.NextBytes(randbytes);
                hash = randbytes.Aggregate("", (s, b) => s + b.ToString("X2"));
            } while (Tokens.ContainsKey(hash));

            Tokens.Add(hash, user);

            obj["token"] = hash;
            return obj;
        }
开发者ID:pfchrono,项目名称:Toaria,代码行数:29,代码来源:SecureRest.cs


示例2: Assign

        /// <summary>
        /// Assign properties in the specified object.
        /// </summary>
        /// <param name="instance">Object to fill.</param>
        /// <param name="parameters">Contains all parameters that should be assigned to the properties.</param>
        /// <exception cref="PropertyException">Properties was not found or value could not be converted.</exception>
        /// <exception cref="ArgumentNullException">Any parameter is <c>null</c>.</exception>
        public static void Assign(object instance, IParameterCollection parameters)
        {
            if (instance == null)
                throw new ArgumentNullException("instance");
            if (parameters == null)
                throw new ArgumentNullException("parameters");
            var errors = new Dictionary<string, Exception>();
            ICachedType type = PropertyProvider.Get(instance.GetType());
            foreach (IParameter parameter in parameters)
            {
                try
                {
                    object value = parameter.Value;
                    if (_handler != null && !_handler(instance, parameter.Name, ref value))
                        continue;

                    type.SetConvertedValue(instance, parameter.Name, value);
                }
                catch (Exception err)
                {
                    errors[parameter.Name] = err;
                }
            }

            if (errors.Count != 0)
                throw new PropertyException(errors);
        }
开发者ID:rafavg77,项目名称:MissVenom,代码行数:34,代码来源:PropertyAssigner.cs


示例3: Parse

        /// <summary>
        /// Parse a query string
        /// </summary>
        /// <param name="reader">string to parse</param>
        /// <param name="parameters">Parameter collection to fill</param>
        /// <returns>A collection</returns>
        /// <exception cref="ArgumentNullException"><c>reader</c> is <c>null</c>.</exception>
        public void Parse(TextReader reader, IParameterCollection parameters)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var canRun = true;
            while (canRun)
            {
                var result = reader.ReadToEnd("&=");
                var name = Uri.UnescapeDataString(result.Value);
                switch (result.Delimiter)
                {
                    case '&':
                        parameters.Add(name, string.Empty);
                        break;
                    case '=':
                        result = reader.ReadToEnd("&");
                        parameters.Add(name, Uri.UnescapeDataString(result.Value));
                        break;
                    case char.MinValue:
                        // EOF = no delimiter && no value
                        if (!string.IsNullOrEmpty(name))
                            parameters.Add(name, string.Empty);
                        break;
                }

                canRun = result.Delimiter != char.MinValue;
            }
        }
开发者ID:2594636985,项目名称:griffin.networking,代码行数:36,代码来源:UrlDecoder.cs


示例4: Parse

        public void Parse(string value, IParameterCollection target)
        {
            int index = 0;
            var lastCh = char.MinValue;

            var name = "";
            int oldPos = 0;
            while (index < value.Length)
            {
                var ch = value[index];
                switch (ch)
                {
                    case '=':
                        if (lastCh != '\\')
                        {
                            name = value.Substring(oldPos, index - oldPos).Trim(' ');
                            oldPos = index + 1;
                        }
                        break;
                    case ',':
                        if (lastCh != '\\')
                        {
                            target.Add(name, value.Substring(oldPos, index - oldPos).Trim(' ', '"'));
                            oldPos = index + 1;
                        }
                        break;
                }
                lastCh = value[index];
                ++index;
            }
        }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:31,代码来源:NameValueParser.cs


示例5: DataConverter

 public DataConverter(IParameterCollection queryString, IParameterCollection form)
 {
     _queryString = queryString;
     _form = form;
     _formArray = new ArrayParameterCollection(form);
     _queryStringArray = new ArrayParameterCollection(_queryString);
 }
开发者ID:oblivious,项目名称:Oblivious,代码行数:7,代码来源:DataConverter.cs


示例6: RestRequestArgs

		public RestRequestArgs(RestVerbs verbs, IParameterCollection param, IRequest request, SecureRest.TokenData tokenData, IHttpContext context)
		{
			Verbs = verbs;
			Parameters = param;
			Request = request;
			TokenData = tokenData;
			Context = context;
		}
开发者ID:sliekasirdis79,项目名称:TShock,代码行数:8,代码来源:Rest.cs


示例7: ArrayParameterCollection

 /// <summary>
 /// Initializes a new instance of the <see cref="ArrayParameterCollection"/> class.
 /// </summary>
 /// <param name="collection">Parse parameters from the this collection.</param>
 public ArrayParameterCollection(IParameterCollection collection)
     : base("root", string.Empty)
 {
     foreach (var item in collection)
     {
         foreach (var value in item)
             Add(item.Name, value);
     }
 }
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:13,代码来源:ArrayParameterCollection.cs


示例8: ProcessBefore

        // TODO: Break in to Supporting Objects, User, Object, and Field Level Security Processing
        public void ProcessBefore(IParameterCollection inputs, IList<CustomAttributeNamedArgument> customAttributeNamedArguments)
        {
            if (_validationContext.EnableValidation)
            {
                var parameters = customAttributeNamedArguments.FirstOrDefault(x => x.MemberName == "Parameters").TypedValue.Value as string;
                if (parameters == null)
                {
                    parameters = string.Empty;
                }
                var parameterList = parameters.Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries);
                var validationMessages = new List<string>();
                var isValid = true;
                if (parameterList.Length == 0 && inputs.Count > 0)
                {
                    var flaggedInput = inputs[0];
                    if (flaggedInput != null)
                    {
                        var response = Validate(flaggedInput);
                        isValid = response.IsValid;
                        validationMessages.AddRange(response.ValidationErrors);
                    }
                }
                else
                {
                    foreach (var parameter in parameterList)
                    {
                        if (!String.IsNullOrWhiteSpace(parameter) && inputs.ContainsParameter(parameter))
                        {
                            var flaggedInput = inputs[parameter];
                            if (flaggedInput != null)
                            {
                                var response = Validate(flaggedInput);
                                isValid = isValid && response.IsValid;
                                validationMessages.AddRange(response.ValidationErrors);
                            }
                        }
                        else
                        {
                            throw new ConfigurationErrorsException(string.Format("Incorrect Parameter Specified {0}, Parameter Does Not Exist!", parameter));
                        }
                    }
                }

                if (!isValid)
                {
                    var validationMessageStringBuilder = new StringBuilder();
                    foreach (var validationMessage in validationMessages)
                    {
                        validationMessageStringBuilder.Append(validationMessage);
                        validationMessageStringBuilder.Append(" ");
                    }
                    throw new ValidationException(validationMessageStringBuilder.ToString());
                }
            }
        }
开发者ID:johnbrunnings,项目名称:Neat,代码行数:56,代码来源:ValidationApplicationProcessingRule.cs


示例9: ProcessBefore

 public void ProcessBefore(IParameterCollection inputs, IEnumerable<CustomAttributeData> customAttributeDatas)
 {
     InitializeDictionary();
     foreach (var customAttributeData in customAttributeDatas)
     {
         if (_strategyHash.ContainsKey(customAttributeData.AttributeType))
         {
             _strategyHash[customAttributeData.AttributeType].ProcessBefore(inputs, customAttributeData.NamedArguments);
         }
     }
 }
开发者ID:johnbrunnings,项目名称:Neat,代码行数:11,代码来源:ApplicationProcessor.cs


示例10: Create

		/*----------------------------------------------------------------------------------------*/
		/// <summary>
		/// Creates a new root context.
		/// </summary>
		/// <param name="service">The type that was requested.</param>
		/// <param name="scope">The scope in which the activation is occurring.</param>
		/// <param name="parameters">A collection of transient parameters to apply to the context.</param>
		/// <returns>The root context.</returns>
		public IContext Create(Type service, IScope scope, IParameterCollection parameters)
		{
			Ensure.ArgumentNotNull(service, "service");
			Ensure.ArgumentNotNull(scope, "scope");
			Ensure.ArgumentNotNull(parameters, "parameters");

			IContext context = CreateRootContext(service, scope);
			context.Parameters = parameters;

			return context;
		}
开发者ID:jamarlthomas,项目名称:ninject1,代码行数:19,代码来源:ContextFactoryBase.cs


示例11: DestroyToken

 object DestroyToken(RestVerbs verbs, IParameterCollection parameters)
 {
     var token = verbs["token"];
     try
     {
         Tokens.Remove(token);
     }
     catch (Exception)
     {
         return new Dictionary<string, string> { { "status", "400" }, { "error", "The specified token queued for destruction failed to be deleted." } };
     }
     return new Dictionary<string, string> { { "status", "200" }, { "response", "Requested token was successfully destroyed." } };
 }
开发者ID:pfchrono,项目名称:Toaria,代码行数:13,代码来源:SecureRest.cs


示例12: GetUserNameFromInputs

        public string GetUserNameFromInputs(IParameterCollection inputs)
        {
            foreach (var requestInput in inputs)
            {
                Request = requestInput as RequestBase;

                if (Request != null)
                {
                    UserName = Request.UserName;
                    break;
                }
            }
            return UserName;
        }
开发者ID:jbavari,项目名称:WCF-Unity,代码行数:14,代码来源:CallHandlerBase.cs


示例13: ExecuteCommand

        protected override object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms)
        {
            if (cmd.RequiresToken)
            {
                var strtoken = parms["token"];
                if (strtoken == null)
                    return new Dictionary<string, string> { { "status", "401" }, { "error", "Not authorized. The specified API endpoint requires a token." } };

                object token;
                if (!Tokens.TryGetValue(strtoken, out token))
                    return new Dictionary<string, string> { { "status", "403" }, { "error", "Not authorized. The specified API endpoint requires a token, but the provided token was not valid." } };
            }
            return base.ExecuteCommand(cmd, verbs, parms);
        }
开发者ID:pfchrono,项目名称:Toaria,代码行数:14,代码来源:SecureRest.cs


示例14: GetInventory

        private object GetInventory(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
        {
            List<TSPlayer> players = TShock.Utils.FindPlayer(verbs["user"]);
            if (players.Count > 1)
            {
                return new RestObject("400") {Response = "Found more than one match."};
            }
            else if (players.Count < 1)
            {
                return new RestObject("400") {Response = "Found no matches."};
            }

            string inventory = players[0].PlayerData.inventory.ToString();
            return new RestObject{{"inventory", inventory}};
        }
开发者ID:NyxStudios,项目名称:serverside-terraria,代码行数:15,代码来源:ServerSideExtensions.cs


示例15: Post

 public string Post(IParameterCollection form)
 {
     if (form["page"] == "settings.htm")
     {
         if (!Persistance.API.ContainsKey(form["var"]))
         {
             Persistance.API.Add(form["var"], form["value"]);
         }
         else
         {
             Persistance.API[form["var"]] = form["value"];
         }
         return "Return to <a href='settings.htm'>settings.htm</a>";
     }
     return "";
 }
开发者ID:seaboy1234,项目名称:MCAdmin,代码行数:16,代码来源:PageProcesser.cs


示例16: PrintInputParameters

        private static string PrintInputParameters(IParameterCollection parameters)
        {
            if (0 == parameters.Count)
            {
                return " without parameters ";
            }

            var parameterString = new StringBuilder();
            parameterString.Append("(");
            for (int i = 0; i < parameters.Count; i++)
            {
                ParameterInfo parameter = parameters.GetParameterInfo(i);

                parameterString.Append(parameter.Name + " = " + parameters[i]);
            }
            parameterString.Append(")");
            return parameterString.ToString();
        }
开发者ID:thor3,项目名称:CodeSamples,代码行数:18,代码来源:LoggingInterceptor.cs


示例17: BanCreate

        object BanCreate(RestVerbs verbs, IParameterCollection parameters)
        {
            var returnBlock = new Dictionary<string, string>();
            var ip = parameters["ip"];
            var name = parameters["name"];
            var reason = parameters["reason"];

            if (ip == null && name == null)
            {
                returnBlock.Add("status", "400");
                returnBlock.Add("error", "Required parameters were missing from this API endpoint.");
                return returnBlock;
            }

            if (ip == null)
            {
                ip = "";
            }

            if (name == null)
            {
                name = "";
            }

            if (reason == null)
            {
                reason = "";
            }

            try
            {
                TShock.Bans.AddBan(ip, name, reason);
            }
            catch (Exception)
            {
                returnBlock.Add("status", "400");
                returnBlock.Add("error", "The specified ban was unable to be created.");
                return returnBlock;
            }
            returnBlock.Add("status", "200");
            returnBlock.Add("response", "Ban created successfully.");
            return returnBlock;
        }
开发者ID:pfchrono,项目名称:Toaria,代码行数:43,代码来源:RestManager.cs


示例18: Parse

        /// <summary>
        /// Parse string
        /// </summary>
        /// <param name="value">contains "a=b,c=d" etc</param>
        /// <param name="target">Collection to fill with the values</param>
        public void Parse(string value, IParameterCollection target)
        {
            if (value == null) throw new ArgumentNullException("value");
            if (target == null) throw new ArgumentNullException("target");

            var index = 0;
            var lastCh = char.MinValue;

            var name = "";
            var oldPos = 0;
            while (index < value.Length)
            {
                var ch = value[index];
                switch (ch)
                {
                    case '=':
                        if (lastCh != '\\')
                        {
                            name = value.Substring(oldPos, index - oldPos).Trim(' ');
                            oldPos = index + 1;
                        }
                        break;
                    case ',':
                        if (lastCh != '\\')
                        {
                            target.Add(name, value.Substring(oldPos, index - oldPos).Trim(' ', '"'));
                            name = "";
                            oldPos = index + 1;
                        }
                        break;
                }
                lastCh = value[index];
                ++index;
            }

            if (name != "")
            {
                target.Add(name, value.Substring(oldPos).Trim(' ', '"'));
            }
        }
开发者ID:2594636985,项目名称:griffin.networking,代码行数:45,代码来源:NameValueParser.cs


示例19: TryPopulateModel

        public void TryPopulateModel(object model, IParameterCollection parameterCollection)
        {
            if (parameterCollection == null)
                throw new ArgumentNullException("parameterCollection");
            var errors = new Dictionary<string, Exception>();
            ICachedType type = PropertyProvider.Get(model.GetType());
            foreach (IParameter parameter in parameterCollection)
            {
                try
                {
                    object value = parameter.Value;
                    type.SetConvertedValue(model, parameter.Name, value);
                }
                catch (Exception err)
                {
                    errors[parameter.Name] = err;
                }
            }

            if (errors.Count != 0)
                throw new PropertyException(errors);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:22,代码来源:DataConverter.cs


示例20: WorldSave

        private object WorldSave(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
        {
            SaveManager.Instance.SaveWorld();

            return RestResponse("World saved");
        }
开发者ID:CoderCow,项目名称:TShock,代码行数:6,代码来源:RestManager.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IParameterData类代码示例发布时间:2022-05-24
下一篇:
C# IParameter类代码示例发布时间: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