DogSimWeb.Areas.HelpPage.ObjectGenerator.GenerateArray C# (CSharp) 메소드

GenerateArray() 개인적인 정적인 메소드

private static GenerateArray ( Type arrayType, int size, object>.Dictionary createdObjectReferences ) : object
arrayType System.Type
size int
createdObjectReferences object>.Dictionary
리턴 object
        private static object GenerateArray(Type arrayType, int size, Dictionary<Type, object> createdObjectReferences)
        {
            Type type = arrayType.GetElementType();
            Array result = Array.CreateInstance(type, size);
            bool areAllElementsNull = true;
            ObjectGenerator objectGenerator = new ObjectGenerator();
            for (int i = 0; i < size; i++)
            {
                object element = objectGenerator.GenerateObject(type, createdObjectReferences);
                result.SetValue(element, i);
                areAllElementsNull &= element == null;
            }

            if (areAllElementsNull)
            {
                return null;
            }

            return result;
        }