Beispiel #1
0
            /// <summary>Instantiates an instance of an existing Type from cache.</summary>
            private static object CreateInstance(string name, object values1, object values2)
            {
                object newValues = null;

                // merge all values together into an array
                object[] allValues = TypeMerger.MergeValues(values1, values2);

                // check to see if type exists
                if (TypeMerger.kAnonymousTypes.ContainsKey(name))
                {
                    // get type
                    Type type = TypeMerger.kAnonymousTypes[name];

                    // make sure it isn't null for some reason
                    if (type != null)
                    { // create a new instance
                        newValues = Activator.CreateInstance(type, allValues);
                    }
                    else
                    { // remove null type entry
                        lock (_syncLock)
                        {
                            TypeMerger.kAnonymousTypes.Remove(name);
                        }
                    }
                }

                // return values (if any)
                return(newValues);
            }