Beispiel #1
0
        public void SetData(string name, object data)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            Contract.EndContractBlock();

            // SetData should only be used to set values that don't already exist.
            object currentVal;

            lock (((ICollection)LocalStore).SyncRoot)
            {
                LocalStore.TryGetValue(name, out currentVal);
            }
            if (currentVal != null)
            {
                throw new InvalidOperationException(SR.InvalidOperation_SetData_OnlyOnce);
            }

            lock (((ICollection)LocalStore).SyncRoot)
            {
                LocalStore[name] = data;
            }
        }
Beispiel #2
0
        public Object GetData(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            Contract.EndContractBlock();

            int key = AppDomainSetup.Locate(name);

            if (key == -1)
            {
                if (name.Equals(AppDomainSetup.LoaderOptimizationKey))
                {
                    return(FusionStore.LoaderOptimization);
                }
                else
                {
                    object data;
                    lock (((ICollection)LocalStore).SyncRoot)
                    {
                        LocalStore.TryGetValue(name, out data);
                    }
                    if (data == null)
                    {
                        return(null);
                    }
                    return(data);
                }
            }
            else
            {
                // Be sure to call these properties, not Value, so
                // that the appropriate permission demand will be done
                switch (key)
                {
                case (int)AppDomainSetup.LoaderInformation.ApplicationBaseValue:
                    return(FusionStore.ApplicationBase);

                case (int)AppDomainSetup.LoaderInformation.ApplicationNameValue:
                    return(FusionStore.ApplicationName);

                default:
                    Debug.Assert(false, "Need to handle new LoaderInformation value in AppDomain.GetData()");
                    return(null);
                }
            }
        }
Beispiel #3
0
        public object GetData(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            object data;

            lock (((ICollection)LocalStore).SyncRoot)
            {
                LocalStore.TryGetValue(name, out data);
            }

            return(data);
        }