System.Xml.Serialization.ReflectionAwareCodeGen.WriteDefaultIndexerInit C# (CSharp) Method

WriteDefaultIndexerInit() private method

private WriteDefaultIndexerInit ( Type type, string escapedName, bool collectionUseReflection, bool elementUseReflection ) : string
type System.Type
escapedName string
collectionUseReflection bool
elementUseReflection bool
return string
        private string WriteDefaultIndexerInit(Type type, string escapedName, bool collectionUseReflection, bool elementUseReflection)
        {
            string itemVariable = GenerateVariableName("item", escapedName);
            PropertyInfo defaultIndexer = TypeScope.GetDefaultIndexer(type, null);
            _writer.Write("static XSArrayInfo ");
            _writer.Write(itemVariable);
            _writer.Write("= new XSArrayInfo(");
            _writer.Write(GetStringForTypeof(CodeIdentifier.GetCSharpName(type), collectionUseReflection));
            _writer.Write(".GetProperty(");
            WriteQuotedCSharpString(defaultIndexer.Name);
            _writer.Write(",");
            //defaultIndexer.PropertyType is same as TypeDesc.ElementTypeDesc
            _writer.Write(GetStringForTypeof(CodeIdentifier.GetCSharpName(defaultIndexer.PropertyType), elementUseReflection));
            _writer.Write(",new ");
            _writer.Write(typeof(Type[]).FullName);
            _writer.WriteLine("{typeof(int)}));");
            _reflectionVariables.Add(arrayMemberKey + ":" + escapedName, itemVariable);
            return itemVariable;
        }