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


C# Hashtable.Cast方法代码示例

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


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

示例1: Cast_CastsParametersWithDotNotation

        public void Cast_CastsParametersWithDotNotation()
        {
            var parameters = new Hashtable { { "Octopus.Machine.Name", "some machine name" } };
            var sut = parameters.Cast<DotNotationParameter>();

            Assert.Equal("some machine name", sut.OctopusMachineName);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:7,代码来源:ParametersCastExtensionsTests.cs

示例2: Download

        private string Download(string uri, Hashtable vars)
        {
            // 1. format query string
            if (vars != null)
            {
                var query = vars.Cast<DictionaryEntry>().Aggregate("", (current, d) => current + ("&" + d.Key.ToString() + "=" + d.Value.ToString()));
                if (query.Length > 0)
                {
                    uri = uri + "?" + query.Substring(1);
                }
            }

            // 2. setup basic authenication
            var authstring = Convert.ToBase64String(
                Encoding.ASCII.GetBytes(String.Format("{0}:{1}",
                                                      _id, _token)));

            // 3. perform GET using WebClient
            var client = new WebClient();
            client.Headers.Add("Authorization",
                               String.Format("Basic {0}", authstring));
            var resp = client.DownloadData(uri);

            return Encoding.ASCII.GetString(resp);
        }
开发者ID:richardpilgrim,项目名称:twilio.clr,代码行数:25,代码来源:Account.cs

示例3: Cast_ConvertsDecimalParamCorrectly

        public void Cast_ConvertsDecimalParamCorrectly()
        {
            var parameters = new Hashtable {{"NetFramework", "4.5"}};
            var sut = parameters.Cast<SingleDecimalParameter>();

            Assert.Equal(4.5M, sut.NetFramework);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:7,代码来源:ParametersCastExtensionsTests.cs

示例4: Cast_DoesNotThrowWhenNotRequiredParamNotGiven

        public void Cast_DoesNotThrowWhenNotRequiredParamNotGiven()
        {
            var parameters = new Hashtable {{"SiteName", "MySite"}};
            var sut = parameters.Cast<RequiredParameters>();

            Assert.Equal("MySite", sut.SiteName);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:7,代码来源:ParametersCastExtensionsTests.cs

示例5: Cast_ConvertsShortParamCorrectly

        public void Cast_ConvertsShortParamCorrectly()
        {
            var parameters = new Hashtable {{"Port", "80"}};

            var sut = parameters.Cast<SingleShortParameter>();

            Assert.Equal(80, sut.Port);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:8,代码来源:ParametersCastExtensionsTests.cs

示例6: HashtableToDict

 public static Dictionary<string, object> HashtableToDict(Hashtable hashtable)
 {
     if (hashtable == null)
     {
         return new Dictionary<string, object>();
     }
     return hashtable.Cast<DictionaryEntry>().ToDictionary(
         kvp => (string) kvp.Key.ToString(), kvp => (object) kvp.Value
     );
 }
开发者ID:OpenDataSpace,项目名称:CmisCmdlets,代码行数:10,代码来源:Utilities.cs

示例7: CreateWebhook

        public Model.Webhook CreateWebhook(
            string resourceGroupName,
            string automationAccountName,
            string name,
            string runbookName,
            bool isEnabled,
            DateTimeOffset expiryTime,
            Hashtable runbookParameters)
        {
            Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("AutomationAccountName", automationAccountName).NotNull();
            using (var request = new RequestSettings(this.automationManagementClient))
            {
                var rbAssociationProperty = new RunbookAssociationProperty { Name = runbookName };
                var createOrUpdateProperties = new WebhookCreateOrUpdateProperties
                                                   {
                                                       IsEnabled = isEnabled,
                                                       ExpiryTime = expiryTime,
                                                       Runbook = rbAssociationProperty,
                                                       Uri =
                                                           this.automationManagementClient
                                                           .Webhooks.GenerateUri(
                                                               resourceGroupName,
                                                               automationAccountName).Uri
                                                   };
                if (runbookParameters != null)
                {
                    createOrUpdateProperties.Parameters =
                        runbookParameters.Cast<DictionaryEntry>()
                            .ToDictionary(kvp => (string)kvp.Key, kvp => (string)kvp.Value);
                }

                var webhookCreateOrUpdateParameters = new WebhookCreateOrUpdateParameters(
                    name,
                    createOrUpdateProperties);

                var webhook =
                    this.automationManagementClient.Webhooks.CreateOrUpdate(
                        resourceGroupName,
                        automationAccountName,
                        webhookCreateOrUpdateParameters).Webhook;

                return new Model.Webhook(
                    resourceGroupName,
                    automationAccountName,
                    webhook,
                    webhookCreateOrUpdateParameters.Properties.Uri);
            }
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:49,代码来源:AutomationClientWebhook.cs

示例8: Upload

        private string Upload(string uri, string method, Hashtable vars)
        {
            // 1. format body data
            var data = "";
            if (vars != null)
            {
                data = vars.Cast<DictionaryEntry>().Aggregate(data, (current, d) => current + (d.Key.ToString() + "=" + d.Value.ToString() + "&"));
            }

            // 2. setup basic authenication
            var authstring = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", _id, _token)));

            // 3. perform POST/PUT/DELETE using WebClient
            ServicePointManager.Expect100Continue = false;
            var postbytes = Encoding.ASCII.GetBytes(data);
            var client = new WebClient();

            client.Headers.Add("Authorization", String.Format("Basic {0}", authstring));
            client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            var resp = client.UploadData(uri, method, postbytes);

            return Encoding.ASCII.GetString(resp);
        }
开发者ID:azcoov,项目名称:twilio.clr,代码行数:24,代码来源:Account.cs

示例9: Cast_GivesParametersWhenSuppliedUsingCorrectCasing

        public void Cast_GivesParametersWhenSuppliedUsingCorrectCasing()
        {
            var parameters = new Hashtable {{"SiteName", "MySite"}};

            var sut = parameters.Cast<InstallerContextTests.SingleStringParameter>();

            Assert.Equal("MySite", sut.SiteName);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:8,代码来源:ParametersCastExtensionsTests.cs

示例10: SetTemplateMetadata

        public static void SetTemplateMetadata(ProvisioningTemplate template, string templateDisplayName, string templateImagePreviewUrl, Hashtable templateProperties)
        {
            if (!String.IsNullOrEmpty(templateDisplayName))
            {
                template.DisplayName = templateDisplayName;
            }

            if (!String.IsNullOrEmpty(templateImagePreviewUrl))
            {
                template.ImagePreviewUrl = templateImagePreviewUrl;
            }

            if (templateProperties != null && templateProperties.Count > 0)
            {
                var properties = templateProperties
                    .Cast<DictionaryEntry>()
                    .ToDictionary(i => (String)i.Key, i => (String)i.Value);

                foreach (var key in properties.Keys)
                {
                    if (!String.IsNullOrEmpty(key))
                    {
                        template.Properties[key] = properties[key];
                    }
                }
            }
        }
开发者ID:russgove,项目名称:PnP-PowerShell,代码行数:27,代码来源:GetProvisioningTemplate.cs

示例11: ConvertComplexSearchObjectToSQL

        /// <summary>
        /// VHSoft: Add function to handle complex searching; converting the json object from jqgrid to workable sql where string
        /// </summary>
        private void ConvertComplexSearchObjectToSQL(Hashtable searchObject, ref string where, ref string additionalSQL)
        {
            Dictionary<string, object> value2 = searchObject.Cast<DictionaryEntry> ().ToDictionary(kvp => (string)kvp.Key, kvp => (object)kvp.Value);

            this.ConvertComplexSearchObjectToSQL(value2, ref where, ref additionalSQL);
        }
开发者ID:ferrywlto,项目名称:Rec-System,代码行数:9,代码来源:Grid.cs

示例12: Cast_OnlySetsWritableProperties

        public void Cast_OnlySetsWritableProperties()
        {
            var parameters = new Hashtable { { "Port", 80 } };
            var sut = parameters.Cast<ReadonlyParameter>();

            Assert.Equal(90, sut.Port);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:7,代码来源:ParametersCastExtensionsTests.cs

示例13: Cast_IgnoresExtraNotRequiredParameters

        public void Cast_IgnoresExtraNotRequiredParameters()
        {
            var parameters = new Hashtable {{"SiteName", "MySite"}, {"ApplicationPoolName", "AppPool1"}};

            var sut = parameters.Cast<InstallerContextTests.SingleStringParameter>();

            Assert.Equal("MySite", sut.SiteName);
        }
开发者ID:modulexcite,项目名称:FluentInstallation,代码行数:8,代码来源:ParametersCastExtensionsTests.cs

示例14: GeraProjetoInterface

        private static void GeraProjetoInterface(ParametrosCriarProjetos parametros, string guidProjInterface, List<string> arquivosInterface, string templateAssembly)
        {
            var trocasInterface = new Hashtable
            {
                {"[guid]", guidProjInterface},
                {"[namespace]", parametros.NameSpace},
                {"[arquivos]", string.Join("\n", arquivosInterface.ToArray())}
            };

            var projInterface = Gerador.RetornaTextoBase("secafretnIetalpmeT");
            projInterface = trocasInterface.Cast<DictionaryEntry>().Aggregate(projInterface, (current, entry) => current.Replace(entry.Key.ToString(), entry.Value.ToString()));
            projInterface = projInterface.Replace("[versao]", parametros.VersaoFramework);

            var assemblyInterface = templateAssembly.Replace("[log]", "");
            assemblyInterface = assemblyInterface.Replace("[namespace]", parametros.NameSpace);
            assemblyInterface = assemblyInterface.Replace("[guid]", guidProjInterface);

            File.WriteAllText(string.Format("{0}\\Interfaces\\{1}Interfaces.csproj", parametros.CaminhoDestino, parametros.NameSpace), projInterface);
            File.WriteAllText(string.Format("{0}\\Interfaces\\Properties\\AssemblyInfo.cs", parametros.CaminhoDestino), assemblyInterface);
        }
开发者ID:RodrigoDotNet,项目名称:gerador-de-camadas,代码行数:20,代码来源:ArquivosProjeto.cs

示例15: GeraSoluction

        private static void GeraSoluction(ParametrosCriarProjetos parametros, string guidProjTO, string guidProjDAL, string guidProjInterface, string guidProjBLL, string guidProjWcf)
        {
            var trocasSolution = new Hashtable
            {
                {"[guid]", Guid.NewGuid().ToString().ToUpper().ToUpper()},
                {"[namespace]", parametros.NameSpace},
                {"[guidTO]", guidProjTO},
                {"[guidDAL]", guidProjDAL},
                {"[guidInterface]", guidProjInterface},
                {"[guidBLL]", guidProjBLL}
            };

            var projSolution = Gerador.RetornaTextoBase("noituloS");

            if (parametros.MapWcf)
            {
                projSolution = projSolution.Replace("[guidWcf]", string.Format("Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}Wcf\", \"{0}Wcf\\{0}Wcf.csproj\", \"{{53034ACE-081D-4CDA-8075-D3B158C7DAF9}}\"{1}EndProject", parametros.NameSpace, Environment.NewLine));
                projSolution = projSolution.Replace("[guidGlobalWcf]", string.Format("{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{1}{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU{1}{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU{1}{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU", guidProjWcf, Environment.NewLine));
            }
            else
            {
                projSolution = projSolution.Replace("[guidWcf]", "");
                projSolution = projSolution.Replace("[guidGlobalWcf]", "");
            }

            switch (parametros.VersaoFramework)
            {
                case "v2.0":
                    projSolution = projSolution.Replace("2010", "2008");
                    projSolution = projSolution.Replace("11.00", "10.00");
                    break;
                case "v4.5":
                    projSolution = projSolution.Replace("2010", "2012");
                    projSolution = projSolution.Replace("11.00", "12.00");
                    break;
            }

            projSolution = trocasSolution.Cast<DictionaryEntry>().Aggregate(projSolution, (current, entry) => current.Replace(entry.Key.ToString(), entry.Value.ToString()));

            File.WriteAllText(string.Format("{0}\\{1}.sln", parametros.CaminhoDestino, parametros.NameSpace), projSolution);
        }
开发者ID:RodrigoDotNet,项目名称:gerador-de-camadas,代码行数:41,代码来源:ArquivosProjeto.cs


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