Git.Core.ObjectStore.Get C# (CSharp) Method

Get() public method

public Get ( SHA1 key ) : Object
key SHA1
return Object
        public Object Get(SHA1 key)
        {
            if (cache == null)
                cache = new Dictionary<SHA1,Object>();

            if (cache.ContainsKey (key))
                return cache[key];

            if (ObjectExist (key)) {
                cache.Add (key, RetrieveObject (key));
            } else {
                throw new ArgumentException (String.Format ("The specified key {0} does not exist", key.ToHexString ()));
            }

            return cache[key];
        }

Same methods

ObjectStore::Get ( string hexstring ) : Object

Usage Example

Example #1
0
        public static void CheckoutTest(string hash, string objStorePath)
        {
            ObjectStore store = new ObjectStore (objStorePath);

            SHA1 id = new SHA1 (SHA1.FromHexString (hash), false);

            Console.WriteLine ("Hash: " + hash);
            Console.WriteLine ("Id:   " + id.ToHexString ());

            Console.WriteLine ("hash created");

            Tree tree = (Tree) store.Get (id);

            Console.WriteLine ("tree created No. entries: " + tree.Entries.Length);

            store.Checkout (Environment.CurrentDirectory, tree);

            Console.WriteLine ("Checkout done WIIIII!!!");
        }