private static object CreateInstance(ClassDataContract dataContract)
        {
            if (dataContract.IsNonAttributedType && !Globals.TypeOfScriptObject_IsAssignableFrom(dataContract.UnderlyingType))
            {
                try
                {
                    return(Activator.CreateInstance(dataContract.UnderlyingType));
                }
                catch (MemberAccessException e)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new SecurityException(SR.Format(
                                                        SR.PartialTrustNonAttributedSerializableTypeNoPublicConstructor,
                                                        DataContract.GetClrTypeFullName(dataContract.UnderlyingType)),
                                                    e));
                }
            }

            if (dataContract.UnderlyingType == Globals.TypeOfDBNull)
            {
                return(Globals.ValueOfDBNull);
            }

            return(XmlFormatReaderGenerator.UnsafeGetUninitializedObject(DataContract.GetIdForInitialization(dataContract)));
        }
        void CreateObject(ClassDataContract classContract)
        {
            Type type = objectType = classContract.UnderlyingType;

            if (type.IsValueType && !classContract.IsNonAttributedType)
            {
                type = Globals.TypeOfValueType;
            }

            if (classContract.UnderlyingType == Globals.TypeOfDBNull)
            {
                objectLocal = DBNull.Value;
            }
            else if (classContract.IsNonAttributedType)
            {
                if (type.IsValueType)
                {
                    objectLocal = FormatterServices.GetUninitializedObject(type);
                }
                else
                {
                    objectLocal = classContract.GetNonAttributedTypeConstructor().Invoke(new object [0]);
                }
            }
            else
            {
                objectLocal = CodeInterpreter.ConvertValue(XmlFormatReaderGenerator.UnsafeGetUninitializedObject(DataContract.GetIdForInitialization(classContract)), Globals.TypeOfObject, type);
            }
        }