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


C# Hashtable.Get方法代码示例

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


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

示例1: can_get_timespan_with_custom_converter

        public void can_get_timespan_with_custom_converter()
        {
            var collection = new Hashtable { { "length", "1:10:10" } };

            var value = collection.Get("length", TimeSpan.Parse);

            Expect(value, Is.EqualTo(TimeSpan.FromSeconds(4210)));
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:8,代码来源:WeakDictionaryExtensionTests.cs

示例2: can_get_bool_from_hashtable

        public void can_get_bool_from_hashtable()
        {
            var table = new Hashtable { { "app id", "true" } };

            var value = table.Get<bool>("app id");

            Expect(value, Is.True);
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:8,代码来源:WeakDictionaryExtensionTests.cs

示例3: can_get_string_from_hashtable

        public void can_get_string_from_hashtable()
        {
            var table = new Hashtable { { "app id", "abc123" } };

            var value = table.Get<string>("app id");

            Expect(value, Is.EqualTo("abc123"));
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:8,代码来源:WeakDictionaryExtensionTests.cs

示例4: get_bool_with_custom_converter_from_hashtable

        public void get_bool_with_custom_converter_from_hashtable()
        {
            var table = new Hashtable { { "allow", "on" } };

            var value = table.Get(
                "allow",
                v =>
                {
                    bool allowed;
                    if (!bool.TryParse(v, out allowed))
                    {
                        allowed = v.Equals("on", StringComparison.Ordinal);
                    }

                    return allowed;
                });

            Expect(value, Is.True);
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:19,代码来源:WeakDictionaryExtensionTests.cs

示例5: get_null_string_from_hashtable_for_missing_value

        public void get_null_string_from_hashtable_for_missing_value()
        {
            var table = new Hashtable { { "app id", "abc123" } };

            var value = table.Get<string>("cat id");

            Expect(value, Is.Null);
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:8,代码来源:WeakDictionaryExtensionTests.cs

示例6: get_false_from_hashtable_for_missing_value

        public void get_false_from_hashtable_for_missing_value()
        {
            var table = new Hashtable { { "app id", "abc123" } };

            var value = table.Get<bool>("Allow Windows Live Writer");

            Expect(value, Is.False);
        }
开发者ID:bdukes,项目名称:DotNetNuke-Prototype-CollectionExtensions,代码行数:8,代码来源:WeakDictionaryExtensionTests.cs

示例7: GetLocalGroupsMap

        /// <summary>
        /// This specialized method returns a Map of users and local groups for the
        /// target server where keys are SIDs representing an account and each value
        /// is an List<object> of SIDs represents the local groups that the account is
        /// a member of.
        /// </summary>
        /// <remarks>
        /// This specialized method returns a Map of users and local groups for the
        /// target server where keys are SIDs representing an account and each value
        /// is an List<object> of SIDs represents the local groups that the account is
        /// a member of.
        /// <p/>
        /// This method is designed to assist with computing access control for a
        /// given user when the target object's ACL has local groups. Local groups
        /// are not listed in a user's group membership (e.g. as represented by the
        /// tokenGroups constructed attribute retrived via LDAP).
        /// <p/>
        /// Domain groups nested inside a local group are currently not expanded. In
        /// this case the key (SID) type will be SID_TYPE_DOM_GRP rather than
        /// SID_TYPE_USER.
        /// </remarks>
        /// <param name="authorityServerName">The server from which the local groups will be queried.
        /// 	</param>
        /// <param name="auth">The credentials required to query groups and group members.</param>
        /// <param name="flags">
        /// Flags that control the behavior of the operation. When all
        /// name associated with SIDs will be required, the SID_FLAG_RESOLVE_SIDS
        /// flag should be used which causes all group member SIDs to be resolved
        /// together in a single more efficient operation.
        /// </param>
        /// <exception cref="System.IO.IOException"></exception>
        internal static Hashtable GetLocalGroupsMap(string authorityServerName, NtlmPasswordAuthentication
			 auth, int flags)
        {
            Sid domsid = GetServerSid(authorityServerName, auth);
            DcerpcHandle handle = null;
            SamrPolicyHandle policyHandle = null;
            SamrDomainHandle domainHandle = null;
            Samr.SamrSamArray sam = new Samr.SamrSamArray();
            MsrpcEnumerateAliasesInDomain rpc;
            lock (SidCache)
            {
                try
                {
                    handle = DcerpcHandle.GetHandle("ncacn_np:" + authorityServerName + "[\\PIPE\\samr]"
                        , auth);
                    policyHandle = new SamrPolicyHandle(handle, authorityServerName, unchecked(0x02000000));
                    domainHandle = new SamrDomainHandle(handle, policyHandle, unchecked(0x02000000), domsid);
                    rpc = new MsrpcEnumerateAliasesInDomain(domainHandle, unchecked(0xFFFF), sam
                        );
                    handle.Sendrecv(rpc);
                    if (rpc.Retval != 0)
                    {
                        throw new SmbException(rpc.Retval, false);
                    }
                    Hashtable map = new Hashtable();
                    for (int ei = 0; ei < rpc.Sam.Count; ei++)
                    {
                        Samr.SamrSamEntry entry = rpc.Sam.Entries[ei];
                        Sid[] mems = GetGroupMemberSids0(handle, domainHandle, domsid
                            , entry.Idx, flags);
                        Sid groupSid = new Sid(domsid, entry.Idx);
                        groupSid.Type = SidTypeAlias;
                        groupSid.DomainName = domsid.GetDomainName();
                        groupSid.AcctName = (new UnicodeString(entry.Name, false)).ToString();
                        for (int mi = 0; mi < mems.Length; mi++)
                        {
                            List<object> groups = (List<object>)map.Get(mems[mi]);
                            if (groups == null)
                            {
                                groups = new List<object>();
                                map.Put(mems[mi], groups);
                            }
                            if (!groups.Contains(groupSid))
                            {
                                groups.Add(groupSid);
                            }
                        }
                    }
                    return map;
                }
                finally
                {
                    if (handle != null)
                    {
                        if (policyHandle != null)
                        {
                            if (domainHandle != null)
                            {
                                domainHandle.Close();
                            }
                            policyHandle.Close();
                        }
                        handle.Close();
                    }
                }
            }
        }
开发者ID:kztao,项目名称:SharpCifs,代码行数:98,代码来源:SID.cs

示例8: Run

 public bool Run()
 {
     for (int j = 0; j < numberOfDocuments; j++)
     {
         Document doc = docs[j];
         SavedRevision lastSavedRevision = null;
         for (int k = 0; k < numberOfUpdates; k++)
         {
             if (lastSavedRevision != null)
             {
                 NUnit.Framework.Assert.AreEqual(lastSavedRevision.GetId(), doc.GetCurrentRevisionId
                     ());
             }
             IDictionary<string, object> contents = new Hashtable(doc.GetProperties());
             Document docLatest = this._enclosing.database.GetDocument(doc.GetId());
             bool wasChecked = (bool)contents.Get("toogle");
             contents.Put("toogle", !wasChecked);
             try
             {
                 lastSavedRevision = doc.PutProperties(contents);
                 numDocsUpdated.IncrementAndGet();
             }
             catch (CouchbaseLiteException cblex)
             {
                 Log.E(LiteTestCase.Tag, "Document update failed", cblex);
                 numExceptions.IncrementAndGet();
             }
         }
     }
     return true;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:31,代码来源:ApiTest.cs

示例9: TestMultiDocumentUpdate

 /// <summary>https://github.com/couchbase/couchbase-lite-android/issues/220</summary>
 /// <exception cref="System.Exception"></exception>
 public virtual void TestMultiDocumentUpdate()
 {
     int numberOfDocuments = 10;
     int numberOfUpdates = 10;
     Document[] docs = new Document[numberOfDocuments];
     for (int j = 0; j < numberOfDocuments; j++)
     {
         IDictionary<string, object> prop = new Dictionary<string, object>();
         prop.Put("foo", "bar");
         prop.Put("toogle", true);
         Document document = CreateDocumentWithProperties(database, prop);
         docs[j] = document;
     }
     AtomicInteger numDocsUpdated = new AtomicInteger(0);
     AtomicInteger numExceptions = new AtomicInteger(0);
     for (int j_1 = 0; j_1 < numberOfDocuments; j_1++)
     {
         Document doc = docs[j_1];
         for (int k = 0; k < numberOfUpdates; k++)
         {
             IDictionary<string, object> contents = new Hashtable(doc.GetProperties());
             bool wasChecked = (bool)contents.Get("toogle");
             //toggle value of check property
             contents.Put("toogle", !wasChecked);
             try
             {
                 doc.PutProperties(contents);
                 numDocsUpdated.IncrementAndGet();
             }
             catch (CouchbaseLiteException cblex)
             {
                 Log.E(Tag, "Document update failed", cblex);
                 numExceptions.IncrementAndGet();
             }
         }
     }
     NUnit.Framework.Assert.AreEqual(numberOfDocuments * numberOfUpdates, numDocsUpdated
         .Get());
     NUnit.Framework.Assert.AreEqual(0, numExceptions.Get());
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:42,代码来源:ApiTest.cs


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