From 73056b1b02f3e1341b293fa2d6f3109fa3f000d9 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:40:07 -0700 Subject: [PATCH 1/2] Delete C++ snippets from System.Reflection (and System.Numerics) (#11402) --- .../Assembly.FullName/CPP/Example.cpp | 23 - .../Assembly.GetExportedTypes/CPP/source.cpp | 78 - .../Assembly.Load1/CPP/load1.cpp | 23 - .../CPP/assemblybuilder_defineresource.cpp | 54 - .../AssemblyBuilderClass/cpp/24895.cpp | 222 - .../cpp/AssemblyBuilderClass.vcxproj | 147 - .../cpp/snippets.5000.json | 3 - ...ssemblybuilder_defineunmanagedresource.cpp | 66 - ...semblybuilder_defineunmanagedresource2.cpp | 66 - ...emblybuilder_defineversioninforesource.cpp | 167 - .../assemblybuilder_setcustomattribute1.cpp | 62 - .../assemblybuilder_setcustomattribute2.cpp | 59 - .../AssemblyClass/cpp/source.cpp | 75 - .../AssemblyDelaySignAttribute/cpp/source.cpp | 13 - .../AssemblyFlagsAttribute/CPP/source.cpp | 79 - .../AssemblyName.Version/cpp/Example.cpp | 21 - .../CPP/assemblyname_codebase.cpp | 99 - .../CPP/assemblyname_constructor.cpp | 84 - .../AssemblyName_Constructor_2/CPP/source.cpp | 24 - .../CPP/assemblyname_getassemblyname.cpp | 30 - .../CPP/assemblyname_keypair.cpp | 123 - .../CPP/assemblyname_setpublickey.cpp | 125 - .../VS_Snippets_CLR/Binder_1/CPP/binder.cpp | 449 - .../BindingFlags/CPP/bindingflagssample.cpp | 365 - .../CPP/constructorbuilder_attributes_4.cpp | 155 - .../CPP/constructorbuilder_getmodule_4.cpp | 127 - .../CPP/constructorbuilder_name_5.cpp | 123 - ...constructorbuilder_setcustomattribute1.cpp | 91 - ...constructorbuilder_setcustomattribute2.cpp | 86 - ...structorbuilder_setimplementationflags.cpp | 128 - ...nstructorbuilder_setsymcustomattribute.cpp | 106 - .../CustomAttributeData/CPP/source.cpp | 234 - .../Emit.ArgIterator/cpp/source.cpp | 111 - .../EmitGenericType/CPP/source.cpp | 300 - .../CPP/enumbuilder_properties_4.cpp | 87 - .../CPP/enumbuilder_properties_5.cpp | 92 - .../CPP/enumbuilder_setcustomattribute1.cpp | 107 - .../CPP/enumbuilder_setcustomattribute2.cpp | 93 - .../VS_Snippets_CLR/EventArg/CPP/eventarg.cpp | 29 - .../CPP/fieldbuilder_reflectedtype.cpp | 84 - .../CPP/fieldbuilder_setcustomattributes.cpp | 132 - .../CPP/fieldbuilder_setoffset.cpp | 74 - .../FieldInfo/CPP/fieldinfo.cpp | 34 - .../CPP/fieldinfo_fieldhandle.cpp | 50 - .../CPP/fieldinfo_getfieldfromhandle.cpp | 36 - .../CPP/fieldinfo_getvalue.cpp | 40 - .../CPP/fieldinfo_isnotserialized.cpp | 34 - .../CPP/fieldinfo_ispinvokeimpl.cpp | 29 - .../CPP/fieldinfo_isprivate.cpp | 53 - .../CPP/fieldinfo_isspecialname.cpp | 34 - .../CPP/fieldinfo_setvalue.cpp | 51 - .../GenericMethodBuilder/cpp/source.cpp | 114 - .../GetFldVal/CPP/getfldval.cpp | 22 - .../CPP/ilgenerator_beginfaultblock.cpp | 102 - .../CPP/ILGenerator_BeginFinallyBlock_2.cpp | 114 - .../CPP/ilgenerator_begin_endscope.cpp | 97 - .../IndentedTextWriterExample/CPP/form1.cpp | 120 - .../CPP/localbuilder_sample_4.cpp | 92 - .../cpp/source.cpp | 71 - ...emberinfo_getcustomattribute_isdefined.cpp | 68 - .../CPP/memberinfo_getcustomattributes1.cpp | 67 - .../VS_Snippets_CLR/MethodBody/cpp/source.cpp | 157 - .../cpp/source.cpp | 41 - .../CPP/methodbuilderclass.cpp | 67 - .../MethodInfo.Generics/cpp/source.cpp | 132 - .../ModuleBuilder_Class/CPP/modulebuilder.cpp | 80 - .../modulebuilder_createglobalfunctions.cpp | 79 - .../CPP/modulebuilder_defineenum.cpp | 46 - .../modulebuilder_defineinitializeddata.cpp | 67 - .../modulebuilder_definepinvokemethod1.cpp | 68 - .../CPP/modulebuilder_defineresource1.cpp | 50 - .../CPP/modulebuilder_defineresource2.cpp | 50 - .../CPP/modulebuilder_getarraymethod.cpp | 110 - .../CPP/parameterinfo_attributes1.cpp | 38 - ...meterInfo_GetCustomAttribute_IsDefined.cpp | 87 - .../CPP/source.cpp | 82 - .../ParameterInfo_IsIn_IsOut_IsOptional.cpp | 103 - .../CPP/propertybuilder_setgetmethod_4.cpp | 130 - .../PropertyInfo.SetValue/cpp/Example.cpp | 132 - .../PropertyInfo.SetValue/cpp/example2.cpp | 65 - .../cpp/source.cpp | 253 - .../cpp/source.cpp | 81 - .../Reflection/CPP/reflection.cpp | 172 - .../cpp/strongnamekeypairx.cpp | 49 - .../cpp/source.cpp | 104 - .../typebuilder_adddeclarativesecurity.cpp | 47 - .../CPP/typebuilder_definenestedtype1.cpp | 94 - .../cpp/100656_fix.cpp | 64 - .../typebuilder_defineuninitializeddata.cpp | 98 - .../CPP/typebuilder_getevents1.cpp | 64 - .../CPP/typebuilder_properties.cpp | 66 - .../CPP/typebuilder_sample_4.cpp | 103 - .../CPP/type_getconstructor3.cpp | 50 - .../CPP/type_getdefaultmembers.cpp | 58 - .../type_getevent1/CPP/type_getevent1.cpp | 44 - .../CPP/source.cpp | 75 - .../classic Array Example/CPP/source.cpp | 74 - .../classic Array Example/CPP/source3.cpp | 68 - .../CPP/source.cpp | 80 - .../CPP/source.cpp | 72 - .../CPP/source.cpp | 67 - .../CPP/source2.cpp | 61 - .../CPP/source.cpp | 46 - .../CPP/source.cpp | 48 - .../CPP/source.cpp | 53 - .../CPP/source.cpp | 77 - .../CPP/source.cpp | 63 - .../CPP/source.cpp | 51 - .../CPP/source.cpp | 68 - .../CPP/source.cpp | 61 - .../CPP/source.cpp | 61 - .../CPP/source.cpp | 15 - .../CPP/source.cpp | 32 - .../CPP/source.cpp | 80 - .../CPP/source.cpp | 41 - .../classic Delegate Example/CPP/source.cpp | 63 - .../CPP/source.cpp | 30 - .../CPP/source.cpp | 62 - .../CPP/source.cpp | 46 - .../CPP/source.cpp | 50 - .../CPP/source.cpp | 83 - .../CPP/source.cpp | 78 - .../CPP/source.cpp | 87 - .../CPP/source.cpp | 47 - .../CPP/source.cpp | 17 - .../classic Math.Round Example/CPP/source.cpp | 12 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 24 - .../CPP/source.cpp | 28 - .../CPP/source.cpp | 27 - .../CPP/source.cpp | 55 - .../CPP/source.cpp | 54 - .../CPP/source.cpp | 53 - .../CPP/source.cpp | 31 - .../CPP/source.cpp | 53 - .../CPP/source.cpp | 37 - .../CPP/source.cpp | 18 - .../CPP/source.cpp | 60 - .../CPP/source.cpp | 19 - .../CPP/source.cpp | 73 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 19 - .../CPP/source.cpp | 22 - .../CPP/source.cpp | 36 - .../CPP/source.cpp | 52 - .../CPP/source.cpp | 53 - .../CPP/source.cpp | 52 - .../CPP/source.cpp | 161 - .../CPP/source.cpp | 85 - .../CPP/source.cpp | 92 - .../CPP/source.cpp | 59 - .../CPP/source.cpp | 92 - .../CPP/source.cpp | 55 - .../CPP/source.cpp | 18 - .../CPP/source.cpp | 67 - .../CPP/source.cpp | 29 - .../CPP/source.cpp | 16 - .../CPP/source.cpp | 15 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 19 - .../CPP/source.cpp | 26 - .../CPP/source.cpp | 17 - .../CPP/source.cpp | 26 - .../CPP/source1.cpp | 26 - .../CPP/source2.cpp | 25 - .../CPP/source.cpp | 37 - .../CPP/source.cpp | 70 - .../CPP/source.cpp | 15 - .../cpp/source.cpp | 64 - .../CPP/source.cpp | 21 - .../cpp/source.cpp | 54 - .../cpp/equals.cpp | 76 - .../cpp/equals2.cpp | 43 - .../CPP/source.cpp | 56 - .../CPP/GetAssembly1.cpp | 19 - .../CPP/assembly.cpp | 182 - .../CPP/codebase1.cpp | 16 - .../CPP/getcallingassembly1.cpp | 18 - .../CPP/source.cpp | 137 - .../CPP/source.cpp | 65 - .../CPP/source.cpp | 71 - .../CPP/source.cpp | 236 - .../CPP/source.cpp | 150 - .../CPP/source.cpp | 118 - .../CPP/source.cpp | 89 - .../CPP/source.cpp | 42 - .../CPP/source.cpp | 116 - .../CPP/source.cpp | 159 - .../CPP/source.cpp | 81 - .../CPP/source.cpp | 105 - .../CPP/source.cpp | 33 - .../CPP/source3.cpp | 34 - .../CPP/source4.cpp | 29 - .../CPP/source.cpp | 31 - .../CPP/source.cpp | 28 - .../CPP/source2.cpp | 28 - .../CPP/source.cpp | 27 - .../CPP/source.cpp | 90 - .../CPP/source.cpp | 107 - .../CPP/nestedenum.cpp | 121 - .../cpp/source.cpp | 32 - .../cpp/hide.cpp | 90 - .../CPP/class1.cpp | 17 - .../CPP/class1.cpp | 30 - .../CPP/class1.cpp | 32 - .../CPP/class1.cpp | 16 - .../CPP/class1.cpp | 51 - .../CPP/class1.cpp | 52 - .../CPP/class1.cpp | 25 - .../CPP/class1.cpp | 25 - .../CPP/class1.cpp | 25 - .../CPP/class1.cpp | 44 - .../CPP/class1.cpp | 16 - .../CPP/class1.cpp | 16 - .../CPP/source.cpp | 126 - .../cpp/source.cpp | 37 - .../cpp/source.cpp | 32 - .../cpp/source.cpp | 48 - .../cpp/source.cpp | 39 - .../cpp/getexecutingassembly1.cpp | 32 - .../cpp/remarks.cpp | 43 - .../cpp/remarks.cpp | 32 - .../cpp/source.cpp | 46 - .../XPathValidation/CPP/XPathValidation.cpp | 68 - .../CPP/docresolver.cpp | 27 - .../CPP/valid_xsd2.cpp | 64 - .../CPP/readdefattr.cpp | 31 - .../CPP/schematype.cpp | 51 - .../CPP/vrdr_resolver.cpp | 59 - .../Classic Uri Example/CPP/source.cpp | 34 - .../CPP/source.cpp | 30 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 18 - .../Classic Uri.Host Example/CPP/source.cpp | 20 - .../CPP/source.cpp | 29 - .../Classic Uri.Port Example/CPP/source.cpp | 20 - .../Classic Uri.Scheme Example/CPP/source.cpp | 20 - .../Classic Uri.Uri Example/CPP/source.cpp | 18 - .../Classic Uri.Uri1 Example/CPP/source.cpp | 18 - .../Classic Uri.Uri3 Example/CPP/source.cpp | 20 - .../Classic Uri.Uri4 Example/CPP/source.cpp | 12 - .../CPP/source.cpp | 21 - .../CPP/source.cpp | 18 - .../CPP/source.cpp | 18 - .../CPP/source.cpp | 18 - .../CPP/source.cpp | 18 - .../CPP/httpwebrequest_begingetresponse.cpp | 158 - .../CPP/nclurienhancements.cpp | 150 - .../NCLUriExamples/CPP/uriexamples.cpp | 271 - .../SerializationAttributes/CPP/s.cpp | 77 - .../UriBuilderSample/cpp/main.cpp | 27 - .../CPP/source.cpp | 69 - .../CPP/source.cpp | 40 - .../CPP/source.cpp | 34 - xml/System.Numerics/BigInteger.xml | 3 - .../AssemblyBuilder.xml | 15 - .../ConstructorBuilder.xml | 14 - .../CustomAttributeBuilder.xml | 1 - xml/System.Reflection.Emit/DynamicMethod.xml | 18 - xml/System.Reflection.Emit/EnumBuilder.xml | 12 - xml/System.Reflection.Emit/FieldBuilder.xml | 6 - .../GenericTypeParameterBuilder.xml | 8 - xml/System.Reflection.Emit/ILGenerator.xml | 19 - xml/System.Reflection.Emit/LocalBuilder.xml | 4 - xml/System.Reflection.Emit/MethodBuilder.xml | 19 - xml/System.Reflection.Emit/MethodRental.xml | 59 +- xml/System.Reflection.Emit/ModuleBuilder.xml | 20 - xml/System.Reflection.Emit/OpCodes.xml | 12057 ++++++++-------- .../ParameterBuilder.xml | 1 - .../PropertyBuilder.xml | 3 - xml/System.Reflection.Emit/TypeBuilder.xml | 21 - .../AmbiguousMatchException.xml | 1 - xml/System.Reflection/Assembly.xml | 13 - .../AssemblyCompanyAttribute.xml | 13 +- .../AssemblyCopyrightAttribute.xml | 13 +- .../AssemblyDelaySignAttribute.xml | 1 - .../AssemblyFlagsAttribute.xml | 3 - .../AssemblyKeyFileAttribute.xml | 1 - xml/System.Reflection/AssemblyName.xml | 18 - .../AssemblyTitleAttribute.xml | 47 +- xml/System.Reflection/Binder.xml | 177 +- xml/System.Reflection/BindingFlags.xml | 181 +- xml/System.Reflection/CallingConventions.xml | 19 +- xml/System.Reflection/ConstructorInfo.xml | 2 - xml/System.Reflection/CustomAttributeData.xml | 8 - .../CustomAttributeNamedArgument.xml | 2 - .../CustomAttributeTypedArgument.xml | 3 - .../DefaultMemberAttribute.xml | 37 +- xml/System.Reflection/EventAttributes.xml | 27 +- xml/System.Reflection/EventInfo.xml | 2 - .../ExceptionHandlingClause.xml | 280 +- .../ExceptionHandlingClauseOptions.xml | 36 +- xml/System.Reflection/FieldAttributes.xml | 36 +- xml/System.Reflection/FieldInfo.xml | 20 - .../GenericParameterAttributes.xml | 23 +- xml/System.Reflection/IReflect.xml | 109 +- xml/System.Reflection/LocalVariableInfo.xml | 70 +- xml/System.Reflection/MemberInfo.xml | 7 - xml/System.Reflection/MemberTypes.xml | 83 +- xml/System.Reflection/MethodAttributes.xml | 13 +- xml/System.Reflection/MethodBase.xml | 16 - xml/System.Reflection/MethodBody.xml | 211 +- xml/System.Reflection/MethodInfo.xml | 7 - xml/System.Reflection/Module.xml | 15 - xml/System.Reflection/ParameterAttributes.xml | 27 +- xml/System.Reflection/ParameterInfo.xml | 9 - xml/System.Reflection/ParameterModifier.xml | 33 +- xml/System.Reflection/PropertyAttributes.xml | 27 +- xml/System.Reflection/PropertyInfo.xml | 10 - xml/System.Reflection/StrongNameKeyPair.xml | 33 +- 311 files changed, 6770 insertions(+), 24312 deletions(-) delete mode 100644 snippets/cpp/VS_Snippets_CLR/Assembly.FullName/CPP/Example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Assembly.GetExportedTypes/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Assembly.Load1/CPP/load1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/CPP/assemblybuilder_defineresource.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/24895.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/AssemblyBuilderClass.vcxproj delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/snippets.5000.json delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/CPP/assemblybuilder_defineunmanagedresource.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/CPP/assemblybuilder_defineunmanagedresource2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/CPP/assemblybuilder_setcustomattribute1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/CPP/assemblybuilder_setcustomattribute2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyClass/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName.Version/cpp/Example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor_2/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/BindingFlags/CPP/bindingflagssample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Name_5/CPP/constructorbuilder_name_5.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/CPP/constructorbuilder_setcustomattribute1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/CPP/constructorbuilder_setcustomattribute2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/CPP/constructorbuilder_setimplementationflags.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/CPP/constructorbuilder_setsymcustomattribute.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Emit.ArgIterator/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/CPP/enumbuilder_properties_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/CPP/enumbuilder_setcustomattribute1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/EventArg/CPP/eventarg.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo/CPP/fieldinfo.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_FieldHandle/CPP/fieldinfo_fieldhandle.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/CPP/fieldinfo_getfieldfromhandle.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_GetValue/CPP/fieldinfo_getvalue.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_IsNotSerialized/CPP/fieldinfo_isnotserialized.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/CPP/fieldinfo_ispinvokeimpl.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPrivate/CPP/fieldinfo_isprivate.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_IsSpecialName/CPP/fieldinfo_isspecialname.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/FieldInfo_SetValue/CPP/fieldinfo_setvalue.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/GetFldVal/CPP/getfldval.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/CPP/ilgenerator_beginfaultblock.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/CPP/ILGenerator_BeginFinallyBlock_2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/CPP/memberinfo_getcustomattribute_isdefined.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/CPP/memberinfo_getcustomattributes1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MethodBuilderClass_TypeSample/CPP/methodbuilderclass.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_Class/CPP/modulebuilder.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/CPP/modulebuilder_defineinitializeddata.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource1/CPP/modulebuilder_defineresource1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource2/CPP/modulebuilder_defineresource2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ParameterInfo_Attributes1/CPP/parameterinfo_attributes1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/CPP/ParameterInfo_GetCustomAttribute_IsDefined.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/Example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/example2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/StrongNameKeyPairX/cpp/strongnamekeypairx.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/CPP/typebuilder_adddeclarativesecurity.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/CPP/typebuilder_defineuninitializeddata.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_GetEvents1/CPP/typebuilder_getevents1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_Properties1/CPP/typebuilder_properties.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Type_GetDefaultMembers/CPP/type_getdefaultmembers.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldAttributes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodAttributes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic MethodRental.SwapMethodBody Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Module.Name Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterAttributes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.SetValue1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.FilterName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.MemberType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.Missing Example/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/System.Reflection.MemberTypes/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/GetAssembly1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/codebase1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/getcallingassembly1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.AddResourceFile Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.DefineDynamicModule Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/CPP/source4.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/CPP/nestedenum.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/cpp/hide.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/cpp/getexecutingassembly1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/cpp/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.reflection.fieldattributes/cpp/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.reflection.parametermodifier/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XPathValidation/CPP/XPathValidation.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XmlDocument.XmlResolver/CPP/docresolver.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XmlValidatingReader.Cctor/CPP/valid_xsd2.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XmlValidatingReader.IsDefault/CPP/readdefattr.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XmlValidatingReader.SchemaType/CPP/schematype.cpp delete mode 100644 snippets/cpp/VS_Snippets_Data/XmlValidatingReader.XmlResolver/CPP/vrdr_resolver.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp delete mode 100644 snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurable Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurableAttribute Example/CPP/source.cpp diff --git a/snippets/cpp/VS_Snippets_CLR/Assembly.FullName/CPP/Example.cpp b/snippets/cpp/VS_Snippets_CLR/Assembly.FullName/CPP/Example.cpp deleted file mode 100644 index 54654202f49..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Assembly.FullName/CPP/Example.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - Console::WriteLine("The FullName property (also called the display name) of..."); - Console::WriteLine("...the currently executing assembly:"); - Console::WriteLine(Assembly::GetExecutingAssembly()->FullName); - - Console::WriteLine("...the assembly that contains the Int32 type:"); - Console::WriteLine(int::typeid->Assembly->FullName); -} - -/* This example produces output similar to the following: - -The FullName property (also called the display name) of... -...the currently executing assembly: -ExampleAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -...the assembly that contains the Int32 type: -mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Assembly.GetExportedTypes/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Assembly.GetExportedTypes/CPP/source.cpp deleted file mode 100644 index 85c7081e152..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Assembly.GetExportedTypes/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -namespace ExportedClassExample -{ - public ref class Example sealed - { - private: - Example() - { - } - - public: - void static EnumerateExportedTypes() - { - for each (Type^ exportedType in - Example::typeid->Assembly->GetExportedTypes()) - { - Console::WriteLine(exportedType); - } - } - }; - - public ref class PublicClass - { - public: - ref class PublicNestedClass - { - }; - - protected: - ref class ProtectedNestedClass - { - }; - - internal: - ref class FriendNestedClass - { - }; - - private: - ref class PrivateNestedClass - { - }; - }; - - ref class FriendClass - { - public: - ref class PublicNestedClass - { - }; - - protected: - ref class ProtectedNestedClass - { - }; - - internal: - ref class FriendNestedClass - { - }; - - private: - ref class PrivateNestedClass - { - }; - }; -} - -int main() -{ - ExportedClassExample::Example::EnumerateExportedTypes(); - - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Assembly.Load1/CPP/load1.cpp b/snippets/cpp/VS_Snippets_CLR/Assembly.Load1/CPP/load1.cpp deleted file mode 100644 index 8735dfb6dac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Assembly.Load1/CPP/load1.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; -int main() -{ - // You must supply a valid fully qualified assembly name. - Assembly^ SampleAssembly = Assembly::Load - ( "SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3" ); - array^ Types = SampleAssembly->GetTypes(); - - // Display all the types contained in the specified assembly. - IEnumerator^ myEnum = Types->GetEnumerator(); - Type^ oType; - while ( myEnum->MoveNext() ) - { - oType = safe_cast(myEnum->Current); - Console::WriteLine( oType->Name ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/CPP/assemblybuilder_defineresource.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/CPP/assemblybuilder_defineresource.cpp deleted file mode 100644 index d5ff911a579..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/CPP/assemblybuilder_defineresource.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; - -/* - The following program demonstrates the 'DefineResource' and 'DefineVersionInfoResource' - methods of 'AssemblyBuilder' class. It builds an assembly and a resource file at runtime. - The unmanaged version information like product, product version, Company, Copyright, - trademark are defined with 'DefineVersionInfoResource' method. -*/ -static Type^ CreateAssembly( AppDomain^ appDomain ); - -int main() -{ - AssemblyBuilder^ myAssembly; - IResourceWriter^ myResourceWriter; - myAssembly = safe_cast(CreateAssembly( Thread::GetDomain() )->Assembly); - myResourceWriter = myAssembly->DefineResource( "myResourceFile", "A sample Resource File", "MyEmitAssembly.MyResource.resources" ); - myResourceWriter->AddResource( "AddResource 1", "First added resource" ); - myResourceWriter->AddResource( "AddResource 2", "Second added resource" ); - myResourceWriter->AddResource( "AddResource 3", "Third added resource" ); - myAssembly->DefineVersionInfoResource( "AssemblySample", "2:0:0:1", "Microsoft Corporation", "@Copyright Microsoft Corp. 1990-2001", ".NET is a trademark of Microsoft Corporation" ); - myAssembly->Save( "MyEmitAssembly.dll" ); -} - -// Create the callee transient dynamic assembly. -static Type^ CreateAssembly( AppDomain^ appDomain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "MyEmitAssembly"; - AssemblyBuilder^ myAssembly = appDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save ); - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - - // Define a public class named "HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define the Display method. - MethodBuilder^ myMethod = helloWorldClass->DefineMethod( "Display", MethodAttributes::Public, String::typeid, nullptr ); - - // Generate IL for GetGreeting. - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldstr, "Display method get called." ); - methodIL->Emit( OpCodes::Ret ); - - // Returns the type HelloWorld. - return (helloWorldClass->CreateType()); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/24895.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/24895.cpp deleted file mode 100644 index 28daac1e840..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/24895.cpp +++ /dev/null @@ -1,222 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -void main() -{ - // This code creates an assembly that contains one type, - // named "MyDynamicType", that has a private field, a property - // that gets and sets the private field, constructors that - // initialize the private field, and a method that multiplies - // a user-supplied number by the private field value and returns - // the result. In Visual C++ the type might look like this: - /* - public ref class MyDynamicType - { - private: - int m_number; - - public: - MyDynamicType() : m_number(42) {}; - MyDynamicType(int initNumber) : m_number(initNumber) {}; - - property int Number - { - int get() { return m_number; } - void set(int value) { m_number = value; } - } - - int MyMethod(int multiplier) - { - return m_number * multiplier; - } - }; - */ - - AssemblyName^ aName = gcnew AssemblyName("DynamicAssemblyExample"); - AssemblyBuilder^ ab = - AssemblyBuilder::DefineDynamicAssembly( - aName, - AssemblyBuilderAccess::Run); - - // The module name is usually the same as the assembly name - ModuleBuilder^ mb = - ab->DefineDynamicModule(aName->Name); - - TypeBuilder^ tb = mb->DefineType( - "MyDynamicType", - TypeAttributes::Public); - - // Add a private field of type int (Int32). - FieldBuilder^ fbNumber = tb->DefineField( - "m_number", - int::typeid, - FieldAttributes::Private); - - // Define a constructor that takes an integer argument and - // stores it in the private field. - array^ parameterTypes = { int::typeid }; - ConstructorBuilder^ ctor1 = tb->DefineConstructor( - MethodAttributes::Public, - CallingConventions::Standard, - parameterTypes); - - ILGenerator^ ctor1IL = ctor1->GetILGenerator(); - // For a constructor, argument zero is a reference to the new - // instance. Push it on the stack before calling the base - // class constructor. Specify the default constructor of the - // base class (System::Object) by passing an empty array of - // types (Type::EmptyTypes) to GetConstructor. - ctor1IL->Emit(OpCodes::Ldarg_0); - ctor1IL->Emit(OpCodes::Call, - Object::typeid->GetConstructor(Type::EmptyTypes)); - // Push the instance on the stack before pushing the argument - // that is to be assigned to the private field m_number. - ctor1IL->Emit(OpCodes::Ldarg_0); - ctor1IL->Emit(OpCodes::Ldarg_1); - ctor1IL->Emit(OpCodes::Stfld, fbNumber); - ctor1IL->Emit(OpCodes::Ret); - - // Define a default constructor that supplies a default value - // for the private field. For parameter types, pass the empty - // array of types or pass nullptr. - ConstructorBuilder^ ctor0 = tb->DefineConstructor( - MethodAttributes::Public, - CallingConventions::Standard, - Type::EmptyTypes); - - ILGenerator^ ctor0IL = ctor0->GetILGenerator(); - ctor0IL->Emit(OpCodes::Ldarg_0); - ctor0IL->Emit(OpCodes::Call, - Object::typeid->GetConstructor(Type::EmptyTypes)); - // For a constructor, argument zero is a reference to the new - // instance. Push it on the stack before pushing the default - // value on the stack. - ctor0IL->Emit(OpCodes::Ldarg_0); - ctor0IL->Emit(OpCodes::Ldc_I4_S, 42); - ctor0IL->Emit(OpCodes::Stfld, fbNumber); - ctor0IL->Emit(OpCodes::Ret); - - // Define a property named Number that gets and sets the private - // field. - // - // The last argument of DefineProperty is nullptr, because the - // property has no parameters. (If you don't specify nullptr, you must - // specify an array of Type objects. For a parameterless property, - // use the built-in array with no elements: Type::EmptyTypes) - PropertyBuilder^ pbNumber = tb->DefineProperty( - "Number", - PropertyAttributes::HasDefault, - int::typeid, - nullptr); - - // The property "set" and property "get" methods require a special - // set of attributes. - MethodAttributes getSetAttr = MethodAttributes::Public | - MethodAttributes::SpecialName | MethodAttributes::HideBySig; - - // Define the "get" accessor method for Number. The method returns - // an integer and has no arguments. (Note that nullptr could be - // used instead of Types::EmptyTypes) - MethodBuilder^ mbNumberGetAccessor = tb->DefineMethod( - "get_Number", - getSetAttr, - int::typeid, - Type::EmptyTypes); - - ILGenerator^ numberGetIL = mbNumberGetAccessor->GetILGenerator(); - // For an instance property, argument zero is the instance. Load the - // instance, then load the private field and return, leaving the - // field value on the stack. - numberGetIL->Emit(OpCodes::Ldarg_0); - numberGetIL->Emit(OpCodes::Ldfld, fbNumber); - numberGetIL->Emit(OpCodes::Ret); - - // Define the "set" accessor method for Number, which has no return - // type and takes one argument of type int (Int32). - MethodBuilder^ mbNumberSetAccessor = tb->DefineMethod( - "set_Number", - getSetAttr, - nullptr, - gcnew array { int::typeid }); - - ILGenerator^ numberSetIL = mbNumberSetAccessor->GetILGenerator(); - // Load the instance and then the numeric argument, then store the - // argument in the field. - numberSetIL->Emit(OpCodes::Ldarg_0); - numberSetIL->Emit(OpCodes::Ldarg_1); - numberSetIL->Emit(OpCodes::Stfld, fbNumber); - numberSetIL->Emit(OpCodes::Ret); - - // Last, map the "get" and "set" accessor methods to the - // PropertyBuilder. The property is now complete. - pbNumber->SetGetMethod(mbNumberGetAccessor); - pbNumber->SetSetMethod(mbNumberSetAccessor); - - // Define a method that accepts an integer argument and returns - // the product of that integer and the private field m_number. This - // time, the array of parameter types is created on the fly. - MethodBuilder^ meth = tb->DefineMethod( - "MyMethod", - MethodAttributes::Public, - int::typeid, - gcnew array { int::typeid }); - - ILGenerator^ methIL = meth->GetILGenerator(); - // To retrieve the private instance field, load the instance it - // belongs to (argument zero). After loading the field, load the - // argument one and then multiply. Return from the method with - // the return value (the product of the two numbers) on the - // execution stack. - methIL->Emit(OpCodes::Ldarg_0); - methIL->Emit(OpCodes::Ldfld, fbNumber); - methIL->Emit(OpCodes::Ldarg_1); - methIL->Emit(OpCodes::Mul); - methIL->Emit(OpCodes::Ret); - - // Finish the type-> - Type^ t = tb->CreateType(); - - // Because AssemblyBuilderAccess includes Run, the code can be - // executed immediately. Start by getting reflection objects for - // the method and the property. - MethodInfo^ mi = t->GetMethod("MyMethod"); - PropertyInfo^ pi = t->GetProperty("Number"); - - // Create an instance of MyDynamicType using the default - // constructor. - Object^ o1 = Activator::CreateInstance(t); - - // Display the value of the property, then change it to 127 and - // display it again. Use nullptr to indicate that the property - // has no index. - Console::WriteLine("o1->Number: {0}", pi->GetValue(o1, nullptr)); - pi->SetValue(o1, 127, nullptr); - Console::WriteLine("o1->Number: {0}", pi->GetValue(o1, nullptr)); - - // Call MyMethod, passing 22, and display the return value, 22 - // times 127. Arguments must be passed as an array, even when - // there is only one. - array^ arguments = { 22 }; - Console::WriteLine("o1->MyMethod(22): {0}", - mi->Invoke(o1, arguments)); - - // Create an instance of MyDynamicType using the constructor - // that specifies m_Number. The constructor is identified by - // matching the types in the argument array. In this case, - // the argument array is created on the fly. Display the - // property value. - Object^ o2 = Activator::CreateInstance(t, - gcnew array { 5280 }); - Console::WriteLine("o2->Number: {0}", pi->GetValue(o2, nullptr)); -}; - -/* This code produces the following output: - -o1->Number: 42 -o1->Number: 127 -o1->MyMethod(22): 2794 -o2->Number: 5280 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/AssemblyBuilderClass.vcxproj b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/AssemblyBuilderClass.vcxproj deleted file mode 100644 index f0b6e04f882..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/AssemblyBuilderClass.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {2C2BE6AE-166F-4B41-8A58-5A6088ED4869} - v4.7.2 - ManagedCProj - AssemblyBuilderClass - 10.0.17134.0 - - - - Application - true - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - - - - Console - - - - - NotUsing - Level3 - Disabled - _DEBUG;%(PreprocessorDefinitions) - - - - Console - - - - - NotUsing - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - - - - Console - - - - - NotUsing - Level3 - NDEBUG;%(PreprocessorDefinitions) - - - - Console - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/snippets.5000.json b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/snippets.5000.json deleted file mode 100644 index da9ebf8da2f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilderClass/cpp/snippets.5000.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "host": "visualstudio" -} diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/CPP/assemblybuilder_defineunmanagedresource.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/CPP/assemblybuilder_defineunmanagedresource.cpp deleted file mode 100644 index be95d74e2dc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/CPP/assemblybuilder_defineunmanagedresource.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -/* - The following program demonstrates the 'DefineResource' and 'DefineUnmanagedResource' - methods of 'AssemblyBuilder' class. It builds an assembly and a resource file at runtime. - An unmanaged resource file is also defined for the same resource file. The EmittedTest2.cpp file - calls the methods of "MyEmitAssembly.dll" assembly and the message is displayed to console. -*/ -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; - - static AssemblyBuilder^ CreateAssembly( String^ name ) - { - AssemblyName^ aName = gcnew AssemblyName(name); - AssemblyBuilder^ myAssembly = - AppDomain::CurrentDomain->DefineDynamicAssembly( aName, - AssemblyBuilderAccess::Save ); - - // Define a dynamic module. - ModuleBuilder^ myModule = - myAssembly->DefineDynamicModule( aName->Name, aName->Name + ".dll" ); - - // Define a public class named "EmitClass" in the assembly. - TypeBuilder^ myEmitClass = - myModule->DefineType( "EmitClass", TypeAttributes::Public ); - - // Define the Display method. - MethodBuilder^ myMethod = - myEmitClass->DefineMethod( "Display", MethodAttributes::Public, - String::typeid, nullptr ); - - // Generate IL for Display method. - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldstr, "Display method gets called." ); - methodIL->Emit( OpCodes::Ret ); - - myEmitClass->CreateType(); - - return (myAssembly); - }; - - // - // - void main() - { - AssemblyBuilder^ myAssembly = CreateAssembly("MyEmitTestAssembly"); - - // Defines a standalone managed resource for this assembly. - IResourceWriter^ myResourceWriter = - myAssembly->DefineResource( "myResourceFile", "A sample Resource File", - "MyAssemblyResource.resources", ResourceAttributes::Private ); - - myResourceWriter->AddResource( "AddResource Test", "Testing for the added resource" ); - - myAssembly->Save(myAssembly->GetName()->Name + ".dll" ); - - // Defines an unmanaged resource file for this assembly. - myAssembly->DefineUnmanagedResource( "MyAssemblyResource.resources" ); - }; - -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/CPP/assemblybuilder_defineunmanagedresource2.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/CPP/assemblybuilder_defineunmanagedresource2.cpp deleted file mode 100644 index 6f099f1d8c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/CPP/assemblybuilder_defineunmanagedresource2.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -/* - The following program demonstrates the 'DefineResource' and 'DefineUnmanagedResource' - methods of 'AssemblyBuilder' class. It builds an assembly and a resource file at runtime. - An unmanaged resource file is also defined for the same resource file. The EmittedTest2.cpp file - calls the methods of "MyEmitAssembly.dll" assembly and the message is displayed to console. -*/ -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; - - static AssemblyBuilder^ CreateAssembly( String^ name ) - { - AssemblyName^ aName = gcnew AssemblyName(name); - AssemblyBuilder^ myAssembly = - AppDomain::CurrentDomain->DefineDynamicAssembly( aName, - AssemblyBuilderAccess::Save ); - - // Define a dynamic module. - ModuleBuilder^ myModule = - myAssembly->DefineDynamicModule( aName->Name, aName->Name + ".dll" ); - - // Define a public class named "EmitClass" in the assembly. - TypeBuilder^ myEmitClass = - myModule->DefineType( "EmitClass", TypeAttributes::Public ); - - // Define the Display method. - MethodBuilder^ myMethod = - myEmitClass->DefineMethod( "Display", MethodAttributes::Public, - String::typeid, nullptr ); - - // Generate IL for Display method. - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldstr, "Display method gets called." ); - methodIL->Emit( OpCodes::Ret ); - - myEmitClass->CreateType(); - - return (myAssembly); - }; - - // - // - void main() - { - AssemblyBuilder^ myAssembly = CreateAssembly("MyEmitTestAssembly"); - - // Defines a standalone managed resource for this assembly. - IResourceWriter^ myResourceWriter = - myAssembly->DefineResource( "myResourceFile", "A sample Resource File", - "MyAssemblyResource.resources", ResourceAttributes::Private ); - - myResourceWriter->AddResource( "AddResource Test", "Testing for the added resource" ); - - myAssembly->Save(myAssembly->GetName()->Name + ".dll" ); - - // Defines an unmanaged resource file for this assembly. - myAssembly->DefineUnmanagedResource( gcnew array{01, 00, 01} ); - }; - -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp deleted file mode 100644 index 8b17c3f5d4f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// System::Reflection::Emit::AssemblyBuilder.DefineVersionInfoResource() - -// This code example shows how to use the AssemblyBuilder::DefineVersionInfoResource method -// to add Windows version information to a dynamic assembly. The code example builds an -// assembly with one module and no types. Several attributes are applied to the assembly, -// DefineVersionInfoResource is used to create the Windows version information resource, -// and then the assembly is saved as EmittedAssembly.exe. The Windows Explorer can be used -// to examine the version information for the assembly. - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - - -/* -// Create the callee transient dynamic assembly. -static Type^ CreateAssembly( AppDomain^ myDomain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "MyEmittedAssembly"; - AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save ); - - // Set Company Attribute to the assembly. - Type^ companyAttribute = AssemblyCompanyAttribute::typeid; - array^types1 = {String::typeid}; - ConstructorInfo^ myConstructorInfo1 = companyAttribute->GetConstructor( types1 ); - array^obj1 = {"Microsoft Corporation"}; - CustomAttributeBuilder^ attributeBuilder1 = gcnew CustomAttributeBuilder( myConstructorInfo1,obj1 ); - myAssembly->SetCustomAttribute( attributeBuilder1 ); - - // Set Copyright Attribute to the assembly. - Type^ copyrightAttribute = AssemblyCopyrightAttribute::typeid; - array^types2 = {String::typeid}; - ConstructorInfo^ myConstructorInfo2 = copyrightAttribute->GetConstructor( types2 ); - array^obj2 = {"@Copyright Microsoft Corp. 1990-2001"}; - CustomAttributeBuilder^ attributeBuilder2 = gcnew CustomAttributeBuilder( myConstructorInfo2,obj2 ); - myAssembly->SetCustomAttribute( attributeBuilder2 ); - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - - // Define a public class named S"HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define the Display method. - MethodBuilder^ myMethod = helloWorldClass->DefineMethod( "Display", MethodAttributes::Public, String::typeid, nullptr ); - - // Generate IL for GetGreeting. - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldstr, "Display method get called." ); - methodIL->Emit( OpCodes::Ret ); - - // Returns the type HelloWorld. - return (helloWorldClass->CreateType()); -} -*/ - -int main() -{ - AssemblyName^ assemName = gcnew AssemblyName(); - assemName->Name = "EmittedAssembly"; - - // Create a dynamic assembly in the current application domain, - // specifying that the assembly is to be saved. - // - AssemblyBuilder^ myAssembly = - AppDomain::CurrentDomain->DefineDynamicAssembly(assemName, - AssemblyBuilderAccess::Save); - - - // To apply an attribute to a dynamic assembly, first get the - // attribute type. The AssemblyFileVersionAttribute sets the - // File Version field on the Version tab of the Windows file - // properties dialog. - // - Type^ attributeType = AssemblyFileVersionAttribute::typeid; - - // To identify the constructor, use an array of types representing - // the constructor's parameter types. This ctor takes a string. - // - array^ ctorParameters = { String::typeid }; - - // Get the constructor for the attribute. - // - ConstructorInfo^ ctor = attributeType->GetConstructor(ctorParameters); - - // Pass the constructor and an array of arguments (in this case, - // an array containing a single string) to the - // CustomAttributeBuilder constructor. - // - array^ ctorArgs = { "2.0.3033.0" }; - CustomAttributeBuilder^ attribute = - gcnew CustomAttributeBuilder(ctor, ctorArgs); - - // Finally, apply the attribute to the assembly. - // - myAssembly->SetCustomAttribute(attribute); - - - // The pattern described above is used to create and apply - // several more attributes. As it happens, all these attributes - // have a constructor that takes a string, so the same ctorArgs - // variable works for all of them. - - - // The AssemblyTitleAttribute sets the Description field on - // the General tab and the Version tab of the Windows file - // properties dialog. - // - attributeType = AssemblyTitleAttribute::typeid; - ctor = attributeType->GetConstructor(ctorParameters); - ctorArgs = gcnew array { "The Application Title" }; - attribute = gcnew CustomAttributeBuilder(ctor, ctorArgs); - myAssembly->SetCustomAttribute(attribute); - - // The AssemblyCopyrightAttribute sets the Copyright field on - // the Version tab. - // - attributeType = AssemblyCopyrightAttribute::typeid; - ctor = attributeType->GetConstructor(ctorParameters); - ctorArgs = gcnew array { "� My Example Company 1991-2005" }; - attribute = gcnew CustomAttributeBuilder(ctor, ctorArgs); - myAssembly->SetCustomAttribute(attribute); - - // The AssemblyDescriptionAttribute sets the Comment item. - // - attributeType = AssemblyDescriptionAttribute::typeid; - ctor = attributeType->GetConstructor(ctorParameters); - attribute = gcnew CustomAttributeBuilder(ctor, - gcnew array { "This is a comment." }); - myAssembly->SetCustomAttribute(attribute); - - // The AssemblyCompanyAttribute sets the Company item. - // - attributeType = AssemblyCompanyAttribute::typeid; - ctor = attributeType->GetConstructor(ctorParameters); - attribute = gcnew CustomAttributeBuilder(ctor, - gcnew array { "My Example Company" }); - myAssembly->SetCustomAttribute(attribute); - - // The AssemblyProductAttribute sets the Product Name item. - // - attributeType = AssemblyProductAttribute::typeid; - ctor = attributeType->GetConstructor(ctorParameters); - attribute = gcnew CustomAttributeBuilder(ctor, - gcnew array { "My Product Name" }); - myAssembly->SetCustomAttribute(attribute); - - - // Define the assembly's only module. For a single-file assembly, - // the module name is the assembly name. - // - ModuleBuilder^ myModule = - myAssembly->DefineDynamicModule(assemName->Name, - assemName->Name + ".exe"); - - // No types or methods are created for this example. - - - // Define the unmanaged version information resource, which - // contains the attribute informaion applied earlier, and save - // the assembly. Use the Windows Explorer to examine the properties - // of the .exe file. - // - myAssembly->DefineVersionInfoResource(); - myAssembly->Save(assemName->Name + ".exe"); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/CPP/assemblybuilder_setcustomattribute1.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/CPP/assemblybuilder_setcustomattribute1.cpp deleted file mode 100644 index 668ee141f99..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/CPP/assemblybuilder_setcustomattribute1.cpp +++ /dev/null @@ -1,62 +0,0 @@ - -// System.Reflection.Emit.SetCustomAttribute(CustomAttributeBuilder) -/* -The following program demonstrates the 'SetCustomAttribute(CustomAttributeBuilder)' -method of 'AssemblyBuilder' class. It defines a 'MyAttribute' class which is derived -from 'Attribute' class. It builds an assembly by setting 'MyAttribute' custom attribute -and defines 'HelloWorld' type. Then it gets the custom attributes of 'HelloWorld' type -and displays its contents to the console. -*/ -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - String^ s; - int x; - MyAttribute( String^ s, int x ) - { - this->s = s; - this->x = x; - } -}; - -Type^ CreateCallee( AppDomain^ domain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - AssemblyBuilder^ myAssembly = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - Type^ myType = MyAttribute::typeid; - array^temp0 = {String::typeid,int::typeid}; - ConstructorInfo^ infoConstructor = myType->GetConstructor( temp0 ); - array^temp1 = {"Hello",2}; - CustomAttributeBuilder^ attributeBuilder = gcnew CustomAttributeBuilder( infoConstructor,temp1 ); - myAssembly->SetCustomAttribute( attributeBuilder ); - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - return (helloWorldClass->CreateType()); -} - -int main() -{ - Type^ customAttribute = CreateCallee( Thread::GetDomain() ); - array^attributes = customAttribute->Assembly->GetCustomAttributes( true ); - Console::WriteLine( "MyAttribute custom attribute contains : " ); - for ( int index = 0; index < attributes->Length; index++ ) - { - if ( dynamic_cast(attributes[ index ]) ) - { - Console::WriteLine( "s : {0}", (dynamic_cast(attributes[ index ]))->s ); - Console::WriteLine( "x : {0}", (dynamic_cast(attributes[ index ]))->x ); - break; - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/CPP/assemblybuilder_setcustomattribute2.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/CPP/assemblybuilder_setcustomattribute2.cpp deleted file mode 100644 index 008090d756e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/CPP/assemblybuilder_setcustomattribute2.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// System.Reflection.Emit.SetCustomAttribute(ConstructorInfo, byte[]) -/* -The following program demonstrates the 'SetCustomAttribute(ConstructorInfo, byte[])' -method of 'AssemblyBuilder' class. It defines a 'MyAttribute' class which is derived -from 'Attribute' class. It builds an assembly by setting 'MyAttribute' custom attribute -and defines 'HelloWorld' type. Then it gets the custom attributes of 'HelloWorld' type -and displays its contents to the console. -*/ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - bool s; - MyAttribute( bool s ) - { - this->s = s; - } -}; - -Type^ CreateCallee( AppDomain^ domain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - AssemblyBuilder^ myAssembly = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - Type^ myType = MyAttribute::typeid; - array^temp0 = {bool::typeid}; - ConstructorInfo^ infoConstructor = myType->GetConstructor( temp0 ); - array^temp1 = {01,00,01}; - myAssembly->SetCustomAttribute( infoConstructor, temp1 ); - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - return (helloWorldClass->CreateType()); -} - -int main() -{ - Type^ customAttribute = CreateCallee( Thread::GetDomain() ); - array^attributes = customAttribute->Assembly->GetCustomAttributes( true ); - Console::WriteLine( "MyAttribute custom attribute contains : " ); - for ( int index = 0; index < attributes->Length; index++ ) - { - if ( dynamic_cast(attributes[ index ]) ) - { - Console::WriteLine( "s : {0}", (dynamic_cast(attributes[ index ]))->s ); - break; - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyClass/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyClass/cpp/source.cpp deleted file mode 100644 index 2384a6c6a11..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyClass/cpp/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security::Permissions; - -[assembly:AssemblyVersionAttribute("1.0.2000.0")]; - -public ref class Example -{ -private: - int factor; - -public: - Example(int f) - { - factor = f; - } - - int SampleMethod(int x) - { - Console::WriteLine("\nExample->SampleMethod({0}) executes.", x); - return x * factor; - } -}; - -void main() -{ - Assembly^ assem = Example::typeid->Assembly; - - Console::WriteLine("Assembly Full Name:"); - Console::WriteLine(assem->FullName); - - // The AssemblyName type can be used to parse the full name. - AssemblyName^ assemName = assem->GetName(); - Console::WriteLine("\nName: {0}", assemName->Name); - Console::WriteLine("Version: {0}.{1}", - assemName->Version->Major, assemName->Version->Minor); - - Console::WriteLine("\nAssembly CodeBase:"); - Console::WriteLine(assem->CodeBase); - - // Create an object from the assembly, passing in the correct number and - // type of arguments for the constructor. - Object^ o = assem->CreateInstance("Example", false, - BindingFlags::ExactBinding, - nullptr, gcnew array { 2 }, nullptr, nullptr); - - // Make a late-bound call to an instance method of the object. - MethodInfo^ m = assem->GetType("Example")->GetMethod("SampleMethod"); - Object^ ret = m->Invoke(o, gcnew array { 42 }); - Console::WriteLine("SampleMethod returned {0}.", ret); - - Console::WriteLine("\nAssembly entry point:"); - Console::WriteLine(assem->EntryPoint); -} - -/* This code example produces output similar to the following: - -Assembly Full Name: -source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null - -Name: source -Version: 1.0 - -Assembly CodeBase: -file:///C:/sdtree/AssemblyClass/cpp/source.exe - -Example->SampleMethod(42) executes. -SampleMethod returned 84. - -Assembly entry point: -UInt32 _mainCRTStartup() - */ -// - diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp deleted file mode 100644 index 9ec81948d79..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// Per Kitg, from cut QuickStart (vswhidbey 160832) -// -using namespace System; -using namespace System::Reflection; - -[assembly:AssemblyKeyFileAttribute("TestPublicKey.snk")]; -[assembly:AssemblyDelaySignAttribute(true)]; - -namespace DelaySign -{ - public ref class Test { }; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp deleted file mode 100644 index 28ca23085e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Specify a combination of AssemblyNameFlags for this -// assembly. -[assembly:AssemblyFlagsAttribute( - AssemblyNameFlags::EnableJITcompileOptimizer - | AssemblyNameFlags::Retargetable)]; - -public ref class Example -{ -public: - static void Main() - { - // Get this assembly. - Assembly^ thisAsm = Example::typeid->Assembly; - - // Get the AssemblyName for this assembly. - AssemblyName^ thisAsmName = thisAsm->GetName( false ); - - // Display the flags that were set for this assembly. - ListFlags( thisAsmName->Flags ); - - // Create an instance of AssemblyFlagsAttribute with the - // same combination of flags that was specified for this - // assembly. Note that PublicKey is included automatically - // for the assembly, but not for this instance of - // AssemblyFlagsAttribute. - AssemblyFlagsAttribute^ afa = gcnew AssemblyFlagsAttribute( - static_cast (AssemblyNameFlags::EnableJITcompileOptimizer - | AssemblyNameFlags::Retargetable) ); - - // Get the flags. The property returns an integer, so - // the return value must be cast to AssemblyNameFlags. - AssemblyNameFlags anf = static_cast(afa->AssemblyFlags); - - // Display the flags. - Console::WriteLine(); - ListFlags( anf ); - } - -private: - static void ListFlags( AssemblyNameFlags anf ) - { - if ( anf == AssemblyNameFlags::None ) - { - Console::WriteLine( L"AssemblyNameFlags.None" ); - } - else - { - if ( 0 != static_cast(anf & AssemblyNameFlags::Retargetable) ) - Console::WriteLine( L"AssemblyNameFlags.Retargetable" ); - if ( 0 != static_cast(anf & AssemblyNameFlags::PublicKey) ) - Console::WriteLine( L"AssemblyNameFlags.PublicKey" ); - if ( 0 != static_cast(anf & AssemblyNameFlags::EnableJITcompileOptimizer) ) - Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileOptimizer" ); - if ( 0 != static_cast(anf & AssemblyNameFlags::EnableJITcompileTracking) ) - Console::WriteLine( L"AssemblyNameFlags.EnableJITcompileTracking" ); - } - } - -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces the following output: - -AssemblyNameFlags.Retargetable -AssemblyNameFlags.PublicKey -AssemblyNameFlags.EnableJITcompileOptimizer - -AssemblyNameFlags.Retargetable -AssemblyNameFlags.EnableJITcompileOptimizer -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName.Version/cpp/Example.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName.Version/cpp/Example.cpp deleted file mode 100644 index 7a72383a28c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName.Version/cpp/Example.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -[assembly:AssemblyVersion("1.1.0.0")]; - -void main() -{ - Console::WriteLine("The version of the currently executing assembly is: {0}", - Assembly::GetExecutingAssembly()->GetName()->Version); - - Console::WriteLine("The version of mscorlib.dll is: {0}", - String::typeid->Assembly->GetName()->Version); -} - -/* This example produces output similar to the following: - -The version of the currently executing assembly is: 1.1.0.0 -The version of mscorlib.dll is: 2.0.0.0 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp deleted file mode 100644 index 1879b4dc9fd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp +++ /dev/null @@ -1,99 +0,0 @@ - -// System::Reflection::AssemblyName::CodeBase -// System::Reflection::AssemblyName::CultureInfo -// System::Reflection::AssemblyName::HashAlgorithm -// System::Reflection::AssemblyName::FullName -/* - The following example demonstrates the 'CodeBase', 'CultureInfo' - 'HashAlgorithm' and 'FullName' properties of the 'AssemblyName' class. Creates - a dynamic assembly named 'MyAssembly' with a module named 'MyModule' and - a type within the module named 'MyType'. The type 'MyType' has a single - method called 'Main' which is also the entry point to the assembly. The - creation of the dynamic assembly is carried out by the method called - 'MakeAssembly'. After the assembly is created with the help of 'MakeAssembly' - the assemblies currently loaded are found and the dynamic assembly that we - have created is searched for, which is displayed to the console. The dynamic - assembly is also saved to a file named 'MyAssembly.exe'. - - Note : Run 'MyAssembly.exe' which this example has created for a simple - 'Hello World!' display. -*/ -// -// -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Threading; -using namespace System::IO; -using namespace System::Globalization; -using namespace System::Reflection::Emit; -using namespace System::Configuration::Assemblies; -static void MakeAssembly( AssemblyName^ myAssemblyName, String^ fileName ) -{ - // Get the assembly builder from the application domain associated with the current thread. - AssemblyBuilder^ myAssemblyBuilder = Thread::GetDomain()->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in the assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyModule", fileName ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyType" ); - - // Create a method called 'Main'. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "Main", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::Static), void::typeid, nullptr ); - - // Get the Intermediate Language generator for the method. - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - - // Use the utility method to generate the IL instructions that print a String* to the console. - myILGenerator->EmitWriteLine( "Hello World!" ); - - // Generate the 'ret' IL instruction. - myILGenerator->Emit( OpCodes::Ret ); - - // End the creation of the type. - myTypeBuilder->CreateType(); - - // Set the method with name 'Main' as the entry point in the assembly. - myAssemblyBuilder->SetEntryPoint( myMethodBuilder ); - myAssemblyBuilder->Save( fileName ); -} - -int main() -{ - // Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - - // Set the codebase to the physical directory were the assembly resides. - myAssemblyName->CodeBase = Directory::GetCurrentDirectory(); - - // Set the culture information of the assembly to 'English-American'. - myAssemblyName->CultureInfo = gcnew CultureInfo( "en-US" ); - - // Set the hash algorithm to 'SHA256'. - myAssemblyName->HashAlgorithm = AssemblyHashAlgorithm::SHA256; - myAssemblyName->Name = "MyAssembly"; - myAssemblyName->Version = gcnew Version( "1.0.0.2001" ); - MakeAssembly( myAssemblyName, "MyAssembly.exe" ); - - // Get all the assemblies currently loaded in the application domain. - array^myAssemblies = Thread::GetDomain()->GetAssemblies(); - - // Get the dynamic assembly named 'MyAssembly'. - Assembly^ myAssembly = nullptr; - for ( int i = 0; i < myAssemblies->Length; i++ ) - { - if ( String::Compare( myAssemblies[ i ]->GetName()->Name, "MyAssembly" ) == 0 ) - myAssembly = myAssemblies[ i ]; - } - if ( myAssembly != nullptr ) - { - Console::WriteLine( "\nDisplaying the full assembly name\n" ); - Console::WriteLine( myAssembly->GetName()->FullName ); - } -} -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp deleted file mode 100644 index 21eae3f4c19..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp +++ /dev/null @@ -1,84 +0,0 @@ - -// System::Reflection::AssemblyName::AssemblyName() -// System::Reflection::AssemblyName::Name -// System::Reflection::AssemblyName::Version -/* - The following example demonstrates the constructor 'AssemblyName()' and - the 'Name' and 'Version' properties of the 'AssemblyName' class. Creates - a dynamic assembly named 'MyAssembly' with a module named 'MyModule' and - a type within the module named 'MyType'. The type 'MyType' has a single - method called 'Main' which is also the entry point to the assembly. The - creation of the dynamic assembly is carried out by the method called - 'MakeAssembly'. After the assembly is created with the help of 'MakeAssembly' - the assemblies currently loaded are found and the dynamic assembly that we - have created is searched for, which is displayed to the console. The dynamic - assembly is also saved to a file named 'MyAssembly.exe'. - - Note : Run 'MyAssembly.exe' which this example has created for a simple - 'Hello World!' display. -*/ -// -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Threading; -using namespace System::Reflection::Emit; -static void MakeAssembly( AssemblyName^ myAssemblyName, String^ fileName ) -{ - // Get the assembly builder from the application domain associated with the current thread. - AssemblyBuilder^ myAssemblyBuilder = Thread::GetDomain()->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in the assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyModule", fileName ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyType" ); - - // Create a method called 'Main'. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "Main", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::Static), void::typeid, nullptr ); - - // Get the Intermediate Language generator for the method. - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - - // Use the utility method to generate the IL instructions that print a String* to the console. - myILGenerator->EmitWriteLine( "Hello World!" ); - - // Generate the 'ret' IL instruction. - myILGenerator->Emit( OpCodes::Ret ); - - // End the creation of the type. - myTypeBuilder->CreateType(); - - // Set the method with name 'Main' as the entry point in the assembly. - myAssemblyBuilder->SetEntryPoint( myMethodBuilder ); - myAssemblyBuilder->Save( fileName ); -} - -int main() -{ - // Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "MyAssembly"; - myAssemblyName->Version = gcnew Version( "1.0.0.2001" ); - MakeAssembly( myAssemblyName, "MyAssembly.exe" ); - - // Get all the assemblies currently loaded in the application domain. - array^myAssemblies = Thread::GetDomain()->GetAssemblies(); - - // Get the dynamic assembly named 'MyAssembly'. - Assembly^ myAssembly = nullptr; - for ( int i = 0; i < myAssemblies->Length; i++ ) - { - if ( String::Compare( myAssemblies[ i ]->GetName()->Name, "MyAssembly" ) == 0 ) - myAssembly = myAssemblies[ i ]; - } - if ( myAssembly != nullptr ) - { - Console::WriteLine( "\nDisplaying the assembly name\n" ); - Console::WriteLine( myAssembly ); - } -} -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor_2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor_2/CPP/source.cpp deleted file mode 100644 index 7bd4f7d79f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor_2/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Simplified snippet per SuzCook tech review. -// -using namespace System; -using namespace System::Reflection; - -int main() -{ - // Create an AssemblyName, specifying the display name, and then - // print the properties. - AssemblyName^ myAssemblyName = - gcnew AssemblyName("Example, Version=1.0.0.2001, Culture=en-US, PublicKeyToken=null"); - Console::WriteLine("Name: {0}", myAssemblyName->Name); - Console::WriteLine("Version: {0}", myAssemblyName->Version); - Console::WriteLine("CultureInfo: {0}", myAssemblyName->CultureInfo); - Console::WriteLine("FullName: {0}", myAssemblyName->FullName); -} -/* This code example produces output similar to the following: - -Name: Example -Version: 1.0.0.2001 -CultureInfo: en-US -FullName: Example, Version=1.0.0.2001, Culture=en-US, PublicKeyToken=null - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp deleted file mode 100644 index 2f372084604..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// System::Reflection::AssemblyName::GetAssemblyName(String*) -// System::Reflection::AssemblyName -/* - This example demonstrates the 'GetAssemblyName(String*)' and 'ToString()' - methods of the 'AssemblyName' class. Get the path of 'System.dll' from - the path of 'mscorlib.dll'. Get the assembly information from 'System.dll' - and display the information to the console. - */ -// -// -#using - -using namespace System; -using namespace System::Reflection; -int main() -{ - - // Replace the string "MyAssembly.exe" with the name of an assembly, - // including a path if necessary. If you do not have another assembly - // to use, you can use whatever name you give to this assembly. - // - AssemblyName^ myAssemblyName = AssemblyName::GetAssemblyName( "MyAssembly.exe" ); - Console::WriteLine( "\nDisplaying assembly information:\n" ); - Console::WriteLine( myAssemblyName ); -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp deleted file mode 100644 index ce82c90bc54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp +++ /dev/null @@ -1,123 +0,0 @@ - -// System::Reflection::AssemblyName::KeyPair -// System::Reflection::AssemblyName::GetPublicKey() -// System::Reflection::AssemblyName::GetPublicKeyToken() -// System::Reflection::AssemblyName::Flags -// System::Reflection::AssemblyName::VersionCompatibility -/* - The following example demonstrates the 'GetPublicKey()' and - 'GetPublicKeyToken()' methods and the 'KeyPair', 'Flags' and 'VersionCompatibility' - properties of the 'AssemblyName' class. Creates a dynamic assembly named 'MyAssembly' - with a module named 'MyModule' and a type within the module named 'MyType'. - The type 'MyType' has a single method called 'Main' which is also the entry - point to the assembly. The creation of the dynamic assembly is carried out - by the method called 'MakeAssembly'. After the assembly is created with the - help of 'MakeAssembly' the assemblies currently loaded are found and the - dynamic assembly that we have created is searched for, which is displayed - to the console. Moreover the public key and the public key token are displayed - The dynamic assembly is also saved to a file named 'MyAssembly.exe'. The - dynamic assembly that has been created has a strong name containing a private - and a public key which is generated by a tool named 'Sn.exe'. The key pair - is stored in a file named 'KeyPair.snk'. - - Note : Run 'MyAssembly.exe' which this example has created for a simple - 'Hello World!' display. -*/ -// -// -// -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Threading; -using namespace System::IO; -using namespace System::Globalization; -using namespace System::Reflection::Emit; -using namespace System::Configuration::Assemblies; -using namespace System::Text; -static void MakeAssembly( AssemblyName^ myAssemblyName, String^ fileName ) -{ - // Get the assembly builder from the application domain associated with the current thread. - AssemblyBuilder^ myAssemblyBuilder = Thread::GetDomain()->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in the assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyModule", fileName ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyType" ); - - // Create a method called 'Main'. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "Main", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::Static), void::typeid, nullptr ); - - // Get the Intermediate Language generator for the method. - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - - // Use the utility method to generate the IL instructions that print a String* to the console. - myILGenerator->EmitWriteLine( "Hello World!" ); - - // Generate the 'ret' IL instruction. - myILGenerator->Emit( OpCodes::Ret ); - - // End the creation of the type. - myTypeBuilder->CreateType(); - - // Set the method with name 'Main' as the entry point in the assembly. - myAssemblyBuilder->SetEntryPoint( myMethodBuilder ); - myAssemblyBuilder->Save( fileName ); -} - -int main() -{ - // Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - - // Set the codebase to the physical directory were the assembly resides. - myAssemblyName->CodeBase = Directory::GetCurrentDirectory(); - - // Set the culture information of the assembly to 'English-American'. - myAssemblyName->CultureInfo = gcnew CultureInfo( "en-US" ); - - // Set the hash algorithm to 'SHA256'. - myAssemblyName->HashAlgorithm = AssemblyHashAlgorithm::SHA256; - myAssemblyName->VersionCompatibility = AssemblyVersionCompatibility::SameProcess; - myAssemblyName->Flags = AssemblyNameFlags::PublicKey; - - // Provide this assembly with a strong name. - myAssemblyName->KeyPair = gcnew StrongNameKeyPair( File::Open( "KeyPair.snk", FileMode::Open, FileAccess::Read ) ); - myAssemblyName->Name = "MyAssembly"; - myAssemblyName->Version = gcnew Version( "1.0.0.2001" ); - MakeAssembly( myAssemblyName, "MyAssembly.exe" ); - - // Get the assemblies loaded in the current application domain. - array^myAssemblies = Thread::GetDomain()->GetAssemblies(); - - // Get the dynamic assembly named 'MyAssembly'. - Assembly^ myAssembly = nullptr; - for ( int i = 0; i < myAssemblies->Length; i++ ) - if ( String::Compare( myAssemblies[ i ]->GetName()->Name, "MyAssembly" ) == 0 ) - myAssembly = myAssemblies[ i ]; - - // Display the full assembly information to the console. - if ( myAssembly != nullptr ) - { - Console::WriteLine( "\nDisplaying the full assembly name.\n" ); - Console::WriteLine( myAssembly->GetName()->FullName ); - Console::WriteLine( "\nDisplaying the public key.\n" ); - array^pk; - pk = myAssembly->GetName()->GetPublicKey(); - for ( int i = 0; i < pk->GetLength( 0 ); i++ ) - Console::Write( " {0:x2}", pk[ i ] ); - Console::WriteLine(); - Console::WriteLine( "\nDisplaying the public key token.\n" ); - array^pt; - pt = myAssembly->GetName()->GetPublicKeyToken(); - for ( int i = 0; i < pt->GetLength( 0 ); i++ ) - Console::Write( " {0:x2}", pt[ i ] ); - } -} -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp b/snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp deleted file mode 100644 index 105e762cd75..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp +++ /dev/null @@ -1,125 +0,0 @@ - -// System::Reflection::AssemblyName::SetPublicKey(Byte->Item[]) -// System::Reflection::AssemblyName::SetPublicKeyToken(Byte->Item[]) -/* - The following example demonstrates the 'SetPublicKey(Byte->Item[])' and the - 'SetPublicKeyToken(Byte->Item[])' methods of the 'AssemblyName' class. Creates - a dynamic assembly named 'MyAssembly' with a module named 'MyModule' and - a type within the module named 'MyType'. The type 'MyType' has a single - method called 'Main' which is also the entry point to the assembly. The - creation of the dynamic assembly is carried out by the method called - 'MakeAssembly'. After the assembly is created with the help of 'MakeAssembly' - the assemblies currently loaded are found and the dynamic assembly that we - have created is searched for, which is displayed to the console. The dynamic - assembly is also saved to a file named 'MyAssembly.exe'. The assembly is - provided with a strong name. This is done by getting the public key and - the public key token from the 'KeyPair.snk' (private and public key file). - The public key is stored in 'PublicKey.snk' and the public key token is - stored in 'PublicKeyToken.snk' with the help of the tool named 'sn.exe'. - - Note : Running 'MyAssembly.exe' with this example does not display 'Hello World!' - since this assembly has been stongly signed. -*/ - -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Threading; -using namespace System::IO; -using namespace System::Globalization; -using namespace System::Reflection::Emit; -using namespace System::Configuration::Assemblies; -using namespace System::Text; - -static void MakeAssembly( AssemblyName^ myAssemblyName, String^ fileName ) -{ - // Get the assembly builder from the application domain associated with the current thread. - AssemblyBuilder^ myAssemblyBuilder = Thread::GetDomain()->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in the assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyModule", fileName ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyType" ); - - // Create a method called 'Main'. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "Main", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::Static), void::typeid, nullptr ); - - // Get the Intermediate Language generator for the method. - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - - // Use the utility method to generate the IL instructions that print a String* to the console. - myILGenerator->EmitWriteLine( "Hello World!" ); - - // Generate the 'ret' IL instruction. - myILGenerator->Emit( OpCodes::Ret ); - - // End the creation of the type. - myTypeBuilder->CreateType(); - - // Set the method with name 'Main' as the entry point in the assembly. - myAssemblyBuilder->SetEntryPoint( myMethodBuilder ); - myAssemblyBuilder->Save( fileName ); -} - -int main() -{ - // Create a dynamic assembly with name 'MyAssembly' and build version '1.0.0.2001'. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - - // Set the codebase to the physical directory were the assembly resides. - myAssemblyName->CodeBase = Directory::GetCurrentDirectory(); - - // Set the culture information of the assembly to 'English-American'. - myAssemblyName->CultureInfo = gcnew CultureInfo( "en-US" ); - - // Set the hash algorithm to 'SHA256'. - myAssemblyName->HashAlgorithm = AssemblyHashAlgorithm::SHA256; - myAssemblyName->VersionCompatibility = AssemblyVersionCompatibility::SameProcess; - myAssemblyName->Flags = AssemblyNameFlags::PublicKey; - - // Get the whole contents of the 'PublicKey.snk' into a Byte array. - FileStream^ publicKeyStream = File::Open( "PublicKey.snk", FileMode::Open ); - array^publicKey = gcnew array(publicKeyStream->Length); - publicKeyStream->Read( publicKey, 0, (int)publicKeyStream->Length ); - - // Provide the assembly with a public key. - myAssemblyName->SetPublicKey( publicKey ); - - // Get the whole contents of the 'PublicKeyToken.snk' into a Byte array. - FileStream^ publicKeyTokenStream = File::Open( "PublicKeyToken.snk", FileMode::Open ); - array^publicKeyToken = gcnew array(publicKeyTokenStream->Length); - publicKeyTokenStream->Read( publicKeyToken, 0, (int)publicKeyToken->Length ); - - // Provide the assembly with a public key token. - myAssemblyName->SetPublicKeyToken( publicKeyToken ); - myAssemblyName->Name = "MyAssembly"; - myAssemblyName->Version = gcnew Version( "1.0.0.2001" ); - MakeAssembly( myAssemblyName, "MyAssembly.exe" ); - - // Get the assemblies loaded in the current application domain. - array^myAssemblies = Thread::GetDomain()->GetAssemblies(); - - // Get the dynamic assembly named 'MyAssembly'. - Assembly^ myAssembly = nullptr; - for ( int i = 0; i < myAssemblies->Length; i++ ) - if ( String::Compare( myAssemblies[ i ]->GetName()->Name, "MyAssembly" ) == 0 ) - myAssembly = myAssemblies[ i ]; - - // Display the full assembly information to the console. - if ( myAssembly != nullptr ) - { - Console::WriteLine( "\nDisplaying the full assembly name\n" ); - String^ assemblyName = myAssembly->GetName()->FullName; - Console::WriteLine( assemblyName ); - Console::WriteLine( "\nDisplaying the public key for the assembly\n" ); - array^publicKeyBytes = myAssembly->GetName()->GetPublicKey(); - Console::WriteLine( Encoding::ASCII->GetString( publicKeyBytes ) ); - Console::WriteLine( "\nDisplaying the public key token for the assembly\n" ); - array^publicKeyTokenBytes = myAssembly->GetName()->GetPublicKeyToken(); - Console::WriteLine( Encoding::ASCII->GetString( publicKeyTokenBytes ) ); - } -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp b/snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp deleted file mode 100644 index 382e0b264dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp +++ /dev/null @@ -1,449 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Globalization; -using namespace System::Runtime::InteropServices; -public ref class MyBinder: public Binder -{ -public: - MyBinder() - : Binder() - {} - -private: - ref class BinderState - { - public: - array^args; - }; - -public: - virtual FieldInfo^ BindToField( BindingFlags bindingAttr, array^match, Object^ value, CultureInfo^ culture ) override - { - if ( match == nullptr ) - throw gcnew ArgumentNullException( "match" ); - - // Get a field for which the value parameter can be converted to the specified field type. - for ( int i = 0; i < match->Length; i++ ) - if ( ChangeType( value, match[ i ]->FieldType, culture ) != nullptr ) - return match[ i ]; - - return nullptr; - } - - virtual MethodBase^ BindToMethod( BindingFlags bindingAttr, array^match, array^%args, array^ modifiers, CultureInfo^ culture, array^names, [Out]Object^% state ) override - { - // Store the arguments to the method in a state Object*. - BinderState^ myBinderState = gcnew BinderState; - array^arguments = gcnew array(args->Length); - args->CopyTo( arguments, 0 ); - myBinderState->args = arguments; - state = myBinderState; - if ( match == nullptr ) - throw gcnew ArgumentNullException; - - // Find a method that has the same parameters as those of the args parameter. - for ( int i = 0; i < match->Length; i++ ) - { - // Count the number of parameters that match. - int count = 0; - array^parameters = match[ i ]->GetParameters(); - - // Go on to the next method if the number of parameters do not match. - if ( args->Length != parameters->Length ) - continue; - - // Match each of the parameters that the user expects the method to have. - for ( int j = 0; j < args->Length; j++ ) - { - // If the names parameter is not 0, then reorder args. - if ( names != nullptr ) - { - if ( names->Length != args->Length ) - throw gcnew ArgumentException( "names and args must have the same number of elements." ); - - for ( int k = 0; k < names->Length; k++ ) - if ( String::Compare( parameters[ j ]->Name, names[ k ] ) == 0 ) - args[ j ] = myBinderState->args[ k ]; - } - - // Determine whether the types specified by the user can be converted to the parameter type. - if ( ChangeType( args[ j ], parameters[ j ]->ParameterType, culture ) != nullptr ) - count += 1; - else - break; - } - if ( count == args->Length ) - return match[ i ]; - } - return nullptr; - } - - virtual Object^ ChangeType( Object^ value, Type^ myChangeType, CultureInfo^ culture ) override - { - // Determine whether the value parameter can be converted to a value of type myType. - if ( CanConvertFrom( value->GetType(), myChangeType ) ) - // Return the converted Object*. - return Convert::ChangeType( value, myChangeType ); - else - return nullptr; - } - - virtual void ReorderArgumentArray( array^%args, Object^ state ) override - { - // Return the args that had been reordered by BindToMethod. - (safe_cast(state))->args->CopyTo( args, 0 ); - } - - virtual MethodBase^ SelectMethod( BindingFlags bindingAttr, array^match, array^types, array^ modifiers ) override - { - if ( match == nullptr ) - throw gcnew ArgumentNullException( "match" ); - - for ( int i = 0; i < match->Length; i++ ) - { - // Count the number of parameters that match. - int count = 0; - array^parameters = match[ i ]->GetParameters(); - - // Go on to the next method if the number of parameters do not match. - if ( types->Length != parameters->Length ) - continue; - - // Match each of the parameters that the user expects the method to have. - for ( int j = 0; j < types->Length; j++ ) - { - // Determine whether the types specified by the user can be converted to parameter type. - if ( CanConvertFrom( types[ j ], parameters[ j ]->ParameterType ) ) - count += 1; - else - break; - } - // Determine whether the method has been found. - if ( count == types->Length ) - return match[ i ]; - } - return nullptr; - } - - virtual PropertyInfo^ SelectProperty( BindingFlags bindingAttr, array^match, Type^ returnType, array^indexes, array^ modifiers ) override - { - if ( match == nullptr ) - throw gcnew ArgumentNullException( "match" ); - - for ( int i = 0; i < match->Length; i++ ) - { - // Count the number of indexes that match. - int count = 0; - array^parameters = match[ i ]->GetIndexParameters(); - - // Go on to the next property if the number of indexes do not match. - if ( indexes->Length != parameters->Length ) - continue; - - // Match each of the indexes that the user expects the property to have. - for ( int j = 0; j < indexes->Length; j++ ) - // Determine whether the types specified by the user can be converted to index type. - if ( CanConvertFrom( indexes[ j ], parameters[ j ]->ParameterType ) ) - count += 1; - else - break; - - // Determine whether the property has been found. - if ( count == indexes->Length ) - { - // Determine whether the return type can be converted to the properties type. - if ( CanConvertFrom( returnType, match[ i ]->PropertyType ) ) - return match[ i ]; - else - continue; - } - } - return nullptr; - } - -private: - - // Determines whether type1 can be converted to type2. Check only for primitive types. - bool CanConvertFrom( Type^ type1, Type^ type2 ) - { - if ( type1->IsPrimitive && type2->IsPrimitive ) - { - TypeCode typeCode1 = Type::GetTypeCode( type1 ); - TypeCode typeCode2 = Type::GetTypeCode( type2 ); - - // If both type1 and type2 have the same type, return true. - if ( typeCode1 == typeCode2 ) - return true; - - // Possible conversions from Char follow. - if ( typeCode1 == TypeCode::Char ) - { - switch ( typeCode2 ) - { - case TypeCode::UInt16: - return true; - - case TypeCode::UInt32: - return true; - - case TypeCode::Int32: - return true; - - case TypeCode::UInt64: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from Byte follow. - if ( typeCode1 == TypeCode::Byte ) - { - switch ( typeCode2 ) - { - case TypeCode::Char: - return true; - - case TypeCode::UInt16: - return true; - - case TypeCode::Int16: - return true; - - case TypeCode::UInt32: - return true; - - case TypeCode::Int32: - return true; - - case TypeCode::UInt64: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from SByte follow. - if ( typeCode1 == TypeCode::SByte ) - { - switch ( typeCode2 ) - { - case TypeCode::Int16: - return true; - - case TypeCode::Int32: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from UInt16 follow. - if ( typeCode1 == TypeCode::UInt16 ) - { - switch ( typeCode2 ) - { - case TypeCode::UInt32: - return true; - - case TypeCode::Int32: - return true; - - case TypeCode::UInt64: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from Int16 follow. - if ( typeCode1 == TypeCode::Int16 ) - { - switch ( typeCode2 ) - { - case TypeCode::Int32: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from UInt32 follow. - if ( typeCode1 == TypeCode::UInt32 ) - { - switch ( typeCode2 ) - { - case TypeCode::UInt64: - return true; - - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from Int32 follow. - if ( typeCode1 == TypeCode::Int32 ) - { - switch ( typeCode2 ) - { - case TypeCode::Int64: - return true; - - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from UInt64 follow. - if ( typeCode1 == TypeCode::UInt64 ) - { - switch ( typeCode2 ) - { - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from Int64 follow. - if ( typeCode1 == TypeCode::Int64 ) - { - switch ( typeCode2 ) - { - case TypeCode::Single: - return true; - - case TypeCode::Double: - return true; - - default: - return false; - } - } - - // Possible conversions from Single follow. - if ( typeCode1 == TypeCode::Single ) - { - switch ( typeCode2 ) - { - case TypeCode::Double: - return true; - - default: - return false; - } - } - } - - return false; - } - -}; - -public ref class MyClass1 -{ -public: - short myFieldB; - int myFieldA; - void MyMethod( long i, char k ) - { - Console::WriteLine( "\nThis is MyMethod(long i, char k)" ); - } - - void MyMethod( long i, long j ) - { - Console::WriteLine( "\nThis is MyMethod(long i, long j)" ); - } -}; - -int main() -{ - // Get the type of MyClass1. - Type^ myType = MyClass1::typeid; - - // Get the instance of MyClass1. - MyClass1^ myInstance = gcnew MyClass1; - Console::WriteLine( "\nDisplaying the results of using the MyBinder binder.\n" ); - - // Get the method information for MyMethod. - array^types = {short::typeid,short::typeid}; - MethodInfo^ myMethod = myType->GetMethod( "MyMethod", static_cast(BindingFlags::Public | BindingFlags::Instance), gcnew MyBinder, types, nullptr ); - Console::WriteLine( myMethod ); - - // Invoke MyMethod. - array^obj = {32,32}; - myMethod->Invoke( myInstance, BindingFlags::InvokeMethod, gcnew MyBinder, obj, CultureInfo::CurrentCulture ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/BindingFlags/CPP/bindingflagssample.cpp b/snippets/cpp/VS_Snippets_CLR/BindingFlags/CPP/bindingflagssample.cpp deleted file mode 100644 index 9657b10660c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/BindingFlags/CPP/bindingflagssample.cpp +++ /dev/null @@ -1,365 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; -using namespace System::IO; - -//namespace BindingFlagsSnippet { -public ref class TestClass -{ -public: - String^ Name; - -private: - array^ values; - int methodCalled; - -public: - - property Object^ Item [int] - { - Object^ get( int index ) - { - return values[ index ]; - } - - void set( int index, Object^ value ) - { - values[ index ] = value; - } - } - - property Object^ Value - { - Object^ get() - { - return "the value"; - } - } - - TestClass() - { - Name = "initialName"; - values = gcnew array {(int^)0,1,2,3,4,5,6,7,8,9}; - methodCalled = 0; - } - - TestClass(String^ initName) - { - Name = initName; - values = gcnew array {(int^)0,1,2,3,4,5,6,7,8,9}; - methodCalled = 0; - } - - static void SayHello() - { - Console::WriteLine( "Hello" ); - } - - void AddUp() - { - methodCalled++; - Console::WriteLine( "AddUp Called {0} times", methodCalled ); - } - - static double ComputeSum( double d1, double d2 ) - { - return d1 + d2; - } - - static void PrintName( String^ firstName, String^ lastName ) - { - Console::WriteLine( "{0},{1}", lastName, firstName ); - } - - void PrintTime() - { - Console::WriteLine( DateTime::Now ); - } - - void Swap( interior_ptr a, interior_ptr b ) - { - int x = *a; - *a = *b; - *b = x; - } -}; - - -[DefaultMemberAttribute("PrintTime")] -public ref class TestClass2 -{ -public: - void PrintTime() - { - Console::WriteLine( DateTime::Now ); - } - -}; - -public ref class Base -{ -private: - static int BaseOnlyPrivate = 0; -protected: - static int BaseOnly = 0; -}; - -public ref class Derived : Base -{ -public: - static int DerivedOnly = 0; -}; - -public ref class MostDerived : Derived {}; - -void main() -{ - array^ noArguments; - - // BindingFlags::InvokeMethod - // Call a static method. - Type^ t = TestClass::typeid; - Console::WriteLine(); - Console::WriteLine( "Invoking a static method." ); - Console::WriteLine( "-------------------------" ); - t->InvokeMember( "SayHello", BindingFlags::InvokeMethod | BindingFlags::Public | BindingFlags::Static, - nullptr, nullptr, noArguments ); - - // BindingFlags::InvokeMethod - // Call an instance method. - TestClass^ c = gcnew TestClass; - Console::WriteLine(); - Console::WriteLine( "Invoking an instance method." ); - Console::WriteLine( "----------------------------" ); - c->GetType()->InvokeMember( "AddUp", BindingFlags::InvokeMethod, nullptr, c, noArguments ); - c->GetType()->InvokeMember( "AddUp", BindingFlags::InvokeMethod, nullptr, c, noArguments ); - - // BindingFlags::InvokeMethod - // Call a method with parameters. - array^args = {100.09,184.45}; - Object^ result; - Console::WriteLine(); - Console::WriteLine( "Invoking a method with parameters." ); - Console::WriteLine( "---------------------------------" ); - result = t->InvokeMember( "ComputeSum", BindingFlags::InvokeMethod, nullptr, nullptr, args ); - Console::WriteLine( " {0} + {1} = {2}", args[ 0 ], args[ 1 ], result ); - - // BindingFlags::GetField, SetField - Console::WriteLine(); - Console::WriteLine( "Invoking a field (getting and setting.)" ); - Console::WriteLine( "--------------------------------------" ); - - // Get a field value. - result = t->InvokeMember( "Name", BindingFlags::GetField, nullptr, c, noArguments ); - Console::WriteLine( "Name == {0}", result ); - - // Set a field. - array^obj2 = {"NewName"}; - t->InvokeMember( "Name", BindingFlags::SetField, nullptr, c, obj2 ); - result = t->InvokeMember( "Name", BindingFlags::GetField, nullptr, c, noArguments ); - Console::WriteLine( "Name == {0}", result ); - Console::WriteLine(); - Console::WriteLine( "Invoking an indexed property (getting and setting.)" ); - Console::WriteLine( "--------------------------------------------------" ); - - // BindingFlags::GetProperty - // Get an indexed property value. - int index = 3; - array^obj3 = {index}; - result = t->InvokeMember( "Item", BindingFlags::GetProperty, nullptr, c, obj3 ); - Console::WriteLine( "Item->Item[ {0}] == {1}", index, result ); - - // BindingFlags::SetProperty - // Set an indexed property value. - index = 3; - array^obj4 = {index,"NewValue"}; - t->InvokeMember( "Item", BindingFlags::SetProperty, nullptr, c, obj4 ); - result = t->InvokeMember( "Item", BindingFlags::GetProperty, nullptr, c, obj3 ); - Console::WriteLine( "Item->Item[ {0}] == {1}", index, result ); - Console::WriteLine(); - Console::WriteLine( "Getting a field or property." ); - Console::WriteLine( "----------------------------" ); - - // BindingFlags::GetField - // Get a field or property. - result = t->InvokeMember( "Name", static_cast(BindingFlags::GetField | - BindingFlags::GetProperty), nullptr, c, noArguments ); - Console::WriteLine( "Name == {0}", result ); - - // BindingFlags::GetProperty - result = t->InvokeMember( "Value", static_cast(BindingFlags::GetField | - BindingFlags::GetProperty), nullptr, c, noArguments ); - Console::WriteLine( "Value == {0}", result ); - Console::WriteLine(); - Console::WriteLine( "Invoking a method with named parameters." ); - Console::WriteLine( "---------------------------------------" ); - - // BindingFlags::InvokeMethod - // Call a method using named parameters. - array^argValues = {"Mouse","Micky"}; - array^argNames = {"lastName","firstName"}; - t->InvokeMember( "PrintName", BindingFlags::InvokeMethod, nullptr, nullptr, argValues, nullptr, - nullptr, argNames ); - Console::WriteLine(); - Console::WriteLine( "Invoking a default member of a type." ); - Console::WriteLine( "------------------------------------" ); - - // BindingFlags::Default - // Call the default member of a type. - Type^ t3 = TestClass2::typeid; - t3->InvokeMember( "", static_cast(BindingFlags::InvokeMethod | BindingFlags::Default), - nullptr, gcnew TestClass2, noArguments ); - - // BindingFlags::Static, NonPublic, and Public - // Invoking a member with ref parameters. - Console::WriteLine(); - Console::WriteLine( "Invoking a method with ref parameters." ); - Console::WriteLine( "--------------------------------------" ); - MethodInfo^ m = t->GetMethod( "Swap" ); - args = gcnew array(2); - args[ 0 ] = 1; - args[ 1 ] = 2; - m->Invoke( gcnew TestClass, args ); - Console::WriteLine( "{0}, {1}", args[ 0 ], args[ 1 ] ); - - // BindingFlags::CreateInstance - // Creating an instance with a parameterless constructor. - Console::WriteLine(); - Console::WriteLine( "Creating an instance with a parameterless constructor." ); - Console::WriteLine( "------------------------------------------------------" ); - Object^ obj = t->InvokeMember( "TestClass", static_cast(BindingFlags::Public | - BindingFlags::Instance | BindingFlags::CreateInstance), nullptr, nullptr, noArguments ); - Console::WriteLine("Instance of {0} created.", obj->GetType()->Name); - - // Creating an instance with a constructor that has parameters. - Console::WriteLine(); - Console::WriteLine( "Creating an instance with a constructor that has parameters." ); - Console::WriteLine( "------------------------------------------------------------" ); - obj = t->InvokeMember( "TestClass", static_cast(BindingFlags::Public | - BindingFlags::Instance | BindingFlags::CreateInstance), nullptr, nullptr, - gcnew array { "Hello, World!" } ); - Console::WriteLine("Instance of {0} created with initial value '{1}'.", obj->GetType()->Name, - obj->GetType()->InvokeMember("Name", BindingFlags::GetField, nullptr, obj, noArguments)); - - // BindingFlags::DeclaredOnly - Console::WriteLine(); - Console::WriteLine( "DeclaredOnly instance members." ); - Console::WriteLine( "------------------------------" ); - array^memInfo = t->GetMembers( BindingFlags::DeclaredOnly | - BindingFlags::Instance | BindingFlags::Public); - for ( int i = 0; i < memInfo->Length; i++ ) - { - Console::WriteLine( memInfo[ i ]->Name ); - - } - - // BindingFlags::IgnoreCase - Console::WriteLine(); - Console::WriteLine( "Using IgnoreCase and invoking the PrintName method." ); - Console::WriteLine( "---------------------------------------------------" ); - t->InvokeMember( "printname", static_cast(BindingFlags::IgnoreCase | - BindingFlags::Static | BindingFlags::Public | BindingFlags::InvokeMethod), - nullptr, nullptr, gcnew array {"Brad","Smith"}); - - // BindingFlags::FlattenHierarchy - Console::WriteLine(); - Console::WriteLine( "Using FlattenHierarchy to get inherited static protected and public members." ); - Console::WriteLine( "----------------------------------------------------------------------------" ); - array^ finfos = MostDerived::typeid->GetFields(BindingFlags::NonPublic | - BindingFlags::Public | BindingFlags::Static | BindingFlags::FlattenHierarchy); - for each (FieldInfo^ finfo in finfos) - { - Console::WriteLine("{0} defined in {1}.", finfo->Name, finfo->DeclaringType->Name); - } - - Console::WriteLine(); - Console::WriteLine("Without FlattenHierarchy." ); - Console::WriteLine("-------------------------"); - finfos = MostDerived::typeid->GetFields(BindingFlags::NonPublic | BindingFlags::Public | - BindingFlags::Static); - for each (FieldInfo^ finfo in finfos) - { - Console::WriteLine("{0} defined in {1}.", finfo->Name, finfo->DeclaringType->Name); - } -}; - -/* This example produces output similar to the following: - -Invoking a static method. -------------------------- -Hello - -Invoking an instance method. ----------------------------- -AddUp Called 1 times -AddUp Called 2 times - -Invoking a method with parameters. ---------------------------------- - 100.09 + 184.45 = 284.54 - -Invoking a field (getting and setting.) --------------------------------------- -Name == initialName -Name == NewName - -Invoking an indexed property (getting and setting.) --------------------------------------------------- -Item->Item[ 3] == 3 -Item->Item[ 3] == NewValue - -Getting a field or property. ----------------------------- -Name == NewName -Value == the value - -Invoking a method with named parameters. ---------------------------------------- -Mouse,Micky - -Invoking a default member of a type. ------------------------------------- -12/23/2009 4:19:06 PM - -Invoking a method with ref parameters. --------------------------------------- -2, 1 - -Creating an instance with a parameterless constructor. ------------------------------------------------------- -Instance of TestClass created. - -Creating an instance with a constructor that has parameters. ------------------------------------------------------------- -Instance of TestClass created with initial value 'Hello, World!'. - -DeclaredOnly instance members. ------------------------------- -get_Item -set_Item -get_Value -AddUp -PrintTime -Swap -.ctor -.ctor -Value -Item -Name -methodCalled - -Using IgnoreCase and invoking the PrintName method. ---------------------------------------------------- -Smith,Brad - -Using FlattenHierarchy to get inherited static protected and public members. ----------------------------------------------------------------------------- -DerivedOnly defined in Derived. -BaseOnly defined in Base. - -Without FlattenHierarchy. -------------------------- - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp deleted file mode 100644 index da26b213429..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// System.Reflection.Emit.ConstructorBuilder.AddDeclarativeSecurity() -// System.Reflection.Emit.ConstructorBuilder.Attributes -// System.Reflection.Emit.ConstructorBuilder.DeclaringType -// System.Reflection.Emit.ConstructorBuilder.DefineParameter() - -/* The following program demonstrates the 'AddDeclarativeSecurity', -'DefineParameter' methods, and 'Attributes', 'DeclaringType' properties -of the ConstructorBuilder class. Create the assembly in the current domain -with dynamic module in the assembly. Constructor builder is used in -conjunction with the 'TypeBuilder' class to create constructor at run time. -Add declarative security to the constructor. Display the 'Attributes', -'DeclaringType' and 'DefineParameter'. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Security::Permissions; -using namespace System::Security; - -public ref class MyConstructorBuilder -{ -private: - Type^ myType1; - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - MyConstructorBuilder() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; - -// -// -// - MethodBuilder^ myMethodBuilder = nullptr; - - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - // Create assembly in current CurrentDomain - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - // Create a dynamic assembly - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - // Create a dynamic module in the assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - FieldInfo^ myFieldInfo = - myModuleBuilder->DefineUninitializedData( "myField", 2, FieldAttributes::Public ); - // Create a type in the module - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", - String::typeid, FieldAttributes::Public ); - array^myConstructorArgs = {String::typeid}; - // Define a constructor of the dynamic class. - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( - MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - PermissionSet^ myPset = gcnew PermissionSet( PermissionState::Unrestricted ); - // Add declarative security to the constructor. - Console::WriteLine( "Adding declarative security to the constructor....." ); - Console::WriteLine( "The Security action to be taken is \"DENY\" and" + - " Permission set is \"UNRESTRICTED\"." ); - myConstructor->AddDeclarativeSecurity( SecurityAction::Deny, myPset ); -// - MethodAttributes myMethodAttributes = myConstructor->Attributes; - Type^ myAttributeType = MethodAttributes::typeid; - int myAttribValue = (int)myMethodAttributes; - if ( !myAttributeType->IsEnum ) - { - Console::WriteLine( "This is not an Enum" ); - } - array^myFieldInfo1 = myAttributeType->GetFields( static_cast(BindingFlags::Public | BindingFlags::Static) ); - Console::WriteLine( "The Field info names of the Attributes for the constructor are:" ); - for ( int i = 0; i < myFieldInfo1->Length; i++ ) - { - int myFieldValue = *dynamic_cast(myFieldInfo1[ i ]->GetValue( nullptr )); - if ( (myFieldValue & myAttribValue) == myFieldValue ) - { - Console::WriteLine( " {0}", myFieldInfo1[ i ]->Name ); - } - } - - Type^ myType2 = myConstructor->DeclaringType; - Console::WriteLine( "The declaring type is : {0}", myType2 ); -// - ParameterBuilder^ myParameterBuilder1 = - myConstructor->DefineParameter( 1, ParameterAttributes::Out, "My Parameter Name1" ); - Console::WriteLine( "The name of the parameter is : {0}", - myParameterBuilder1->Name ); - if ( myParameterBuilder1->IsIn ) - Console::WriteLine( "{0} is Input parameter.", myParameterBuilder1->Name ); - else - Console::WriteLine( "{0} is not Input Parameter.", myParameterBuilder1->Name ); - ParameterBuilder^ myParameterBuilder2 = - myConstructor->DefineParameter( 1, ParameterAttributes::In, "My Parameter Name2" ); - Console::WriteLine( "The Parameter name is : {0}", - myParameterBuilder2->Name ); - if ( myParameterBuilder2->IsIn ) - Console::WriteLine( "{0} is Input parameter.", myParameterBuilder2->Name ); - else - Console::WriteLine( "{0} is not Input Parameter.", myParameterBuilder2->Name ); -// - // Generate MSIL for the method, call its base class constructor and store the arguments - // in the private field. - ILGenerator^ myILGenerator3 = myConstructor->GetILGenerator(); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ myConstructorInfo = Object::typeid->GetConstructor( gcnew array(0) ); - myILGenerator3->Emit( OpCodes::Call, myConstructorInfo ); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - myILGenerator3->Emit( OpCodes::Ldarg_1 ); - myILGenerator3->Emit( OpCodes::Stfld, myGreetingField ); - myILGenerator3->Emit( OpCodes::Ret ); - // Add a method to the type. - myMethodBuilder = myTypeBuilder->DefineMethod( - "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); - // Generate MSIL for the method. - ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); - myILGenerator2->EmitWriteLine( "Hello World from global" ); - myILGenerator2->Emit( OpCodes::Ret ); - myModuleBuilder->CreateGlobalFunctions(); - myType1 = myTypeBuilder->CreateType(); - } - property Type^ MyTypeProperty - { - Type^ get() - { - return this->myType1; - } - } -}; -int main() -{ - MyConstructorBuilder^ myConstructorBuilder = gcnew MyConstructorBuilder; - Type^ myType1 = myConstructorBuilder->MyTypeProperty; - if ( nullptr != myType1 ) - { - Console::WriteLine( "Instantiating the new type..." ); - array^myObject = {"hello"}; - Object^ myObject1 = Activator::CreateInstance( myType1, myObject, nullptr ); - MethodInfo^ myMethodInfo = myType1->GetMethod( "HelloWorld" ); - if ( nullptr != myMethodInfo ) - { - Console::WriteLine( "Invoking dynamically created HelloWorld method..." ); - myMethodInfo->Invoke( myObject1, nullptr ); - } - else - { - Console::WriteLine( "Could not locate HelloWorld method" ); - } - } - else - { - Console::WriteLine( "Could not access Type." ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp deleted file mode 100644 index 6bc0d5da26e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// System.Reflection.Emit.ConstructorBuilder.GetModule() -// System.Reflection.Emit.ConstructorBuilder.GetToken() -// System.Reflection.Emit.ConstructorBuilder.GetMethodImplementationFlags() -// System.Reflection.Emit.ConstructorBuilder.GetParameters() - -/* The following program demonstrates the 'GetModule','GetToken', -'GetMethodImplementationFlags' and 'GetParameters' -methods of 'ConstructorBuilder' class. Create the assembly -in the current domain with dynamic module in the assembly. Constructor -builder is used in conjunction with the 'TypeBuilder' class to create -constructor at run time. Set a custom attribute using a custom attribute -builder and displays module name, Token id and parameter info of this class. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Security; -using namespace System::Security::Permissions; - -public ref class MyConstructorBuilder -{ -private: - Type^ myType1; - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - MyConstructorBuilder() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; -// -// - - MethodBuilder^ myMethodBuilder = nullptr; - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - // Create assembly in current CurrentDomain. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - // Create a dynamic assembly. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - // Create a dynamic module in the assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", - String::typeid, FieldAttributes::Public ); - array^myConstructorArgs = {String::typeid}; -// -// - // Define a constructor of the dynamic class. - ConstructorBuilder^ myConstructorBuilder = myTypeBuilder->DefineConstructor( - MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - // Get a reference to the module that contains this constructor. - Module^ myModule = myConstructorBuilder->GetModule(); - Console::WriteLine( "Module Name : {0}", myModule->Name ); - // Get the 'MethodToken' that represents the token for this constructor. - MethodToken myMethodToken = myConstructorBuilder->GetToken(); - Console::WriteLine( "Constructor Token is : {0}", myMethodToken.Token ); - // Get the method implementation flags for this constructor. - MethodImplAttributes myMethodImplAttributes = myConstructorBuilder->GetMethodImplementationFlags(); - Console::WriteLine( "MethodImplAttributes : {0}", myMethodImplAttributes ); -// -// -// - // Generate IL for the method, call its base class constructor and store the arguments - // in the private field. - ILGenerator^ myILGenerator3 = myConstructorBuilder->GetILGenerator(); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ myConstructorInfo = Object::typeid->GetConstructor( gcnew array(0) ); - myILGenerator3->Emit( OpCodes::Call, myConstructorInfo ); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - myILGenerator3->Emit( OpCodes::Ldarg_1 ); - myILGenerator3->Emit( OpCodes::Stfld, myGreetingField ); - myILGenerator3->Emit( OpCodes::Ret ); - // Add a method to the type. - myMethodBuilder = myTypeBuilder->DefineMethod( - "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); - // Generate IL for the method. - ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); - myILGenerator2->EmitWriteLine( "Hello World from global" ); - myILGenerator2->Emit( OpCodes::Ret ); - myModuleBuilder->CreateGlobalFunctions(); - myType1 = myTypeBuilder->CreateType(); - - // Get the parameters of this constructor. - array^myParameterInfo = myConstructorBuilder->GetParameters(); - for ( int i = 0; i < myParameterInfo->Length; i++ ) - { - Console::WriteLine( "Declaration type : {0}", myParameterInfo[ i ]->Member->DeclaringType ); - } -// - } - property Type^ MyTypeProperty - { - Type^ get() - { - return this->myType1; - } - } -}; - -int main() -{ - MyConstructorBuilder^ myConstructorBuilder1 = gcnew MyConstructorBuilder; - Type^ myTypeProperty = myConstructorBuilder1->MyTypeProperty; - if ( nullptr != myTypeProperty ) - { - array^myObject = {"Hello"}; - Object^ myObject1 = Activator::CreateInstance( myTypeProperty, myObject, (Object^) 0 ); - MethodInfo^ myMethodInfo = myTypeProperty->GetMethod( "HelloWorld" ); - - if ( nullptr != myMethodInfo ) - { - myMethodInfo->Invoke( myObject1, nullptr ); - } - else - { - Console::WriteLine( "Could not locate HelloWorld method" ); - } - } - else - { - Console::WriteLine( "Could not access Type." ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Name_5/CPP/constructorbuilder_name_5.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Name_5/CPP/constructorbuilder_name_5.cpp deleted file mode 100644 index 90448fc379b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Name_5/CPP/constructorbuilder_name_5.cpp +++ /dev/null @@ -1,123 +0,0 @@ - -// System.Reflection.Emit.ConstructorBuilder -// System.Reflection.Emit.ConstructorBuilder.Name -// System.Reflection.Emit.ConstructorBuilder.ReflectedType -// System.Reflection.Emit.ConstructorBuilder.Signature -// System.Reflection.Emit.ConstructorBuilder.ToString() -/* The following program demonstrates the 'ConstructorBuilder' class, -its 'Name', 'ReflectedType', 'Signature' properties and 'ToString' -method. Create the assembly in the current domain with dynamic module -in the assembly. ConstructorBuilder is used in conjunction with the -'TypeBuilder' class to create constructor at run time. Display the -'Name', 'Signature' and 'ReflectedType' to the console. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -public ref class MyConstructorBuilder -{ -private: - Type^ myType1; - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - MyConstructorBuilder() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; - - // - MethodBuilder^ myMethodBuilder = nullptr; - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - - // Create assembly in current CurrentDomain. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Create a dynamic assembly. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module in the assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - FieldInfo^ myFieldInfo = myModuleBuilder->DefineUninitializedData( "myField", 2, FieldAttributes::Public ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", String::typeid, FieldAttributes::Public ); - array^myConstructorArgs = {String::typeid}; - - // Define a constructor of the dynamic class. - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - - // Display the name of the constructor. - Console::WriteLine( "The constructor name is : {0}", myConstructor->Name ); - - // Display the 'Type' object from which this object was obtained. - Console::WriteLine( "The reflected type is : {0}", myConstructor->ReflectedType ); - - // Display the signature of the field. - Console::WriteLine( myConstructor->Signature ); - - // Display the constructor builder instance as a string. - Console::WriteLine( myConstructor ); - // - - // Generate IL for the method, call its superclass constructor and store the arguments - // in the private field. - ILGenerator^ myILGenerator3 = myConstructor->GetILGenerator(); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ myConstructorInfo = Object::typeid->GetConstructor( gcnew array(0) ); - myILGenerator3->Emit( OpCodes::Call, myConstructorInfo ); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - myILGenerator3->Emit( OpCodes::Ldarg_1 ); - myILGenerator3->Emit( OpCodes::Stfld, myGreetingField ); - myILGenerator3->Emit( OpCodes::Ret ); - - // Add a method to the type. - myMethodBuilder = myTypeBuilder->DefineMethod( "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); - - // Generate IL for the method. - ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); - myILGenerator2->EmitWriteLine( "Hello World from global" ); - myILGenerator2->Emit( OpCodes::Ret ); - myModuleBuilder->CreateGlobalFunctions(); - myType1 = myTypeBuilder->CreateType(); - } - - property Type^ MyTypeProperty - { - Type^ get() - { - return this->myType1; - } - } -}; - -int main() -{ - MyConstructorBuilder^ myConstructorBuilder = gcnew MyConstructorBuilder; - Type^ myType1 = myConstructorBuilder->MyTypeProperty; - if ( nullptr != myType1 ) - { - Console::WriteLine( "Instantiating the new type..." ); - array^myObject = {"hello"}; - Object^ myObject1 = Activator::CreateInstance( myType1, myObject, nullptr ); - MethodInfo^ myMethodInfo = myType1->GetMethod( "HelloWorld" ); - if ( nullptr != myMethodInfo ) - { - Console::WriteLine( "Invoking dynamically created HelloWorld method..." ); - myMethodInfo->Invoke( myObject1, nullptr ); - } - else - { - Console::WriteLine( "Could not locate HelloWorld method" ); - } - } - else - { - Console::WriteLine( "Could not access Type." ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/CPP/constructorbuilder_setcustomattribute1.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/CPP/constructorbuilder_setcustomattribute1.cpp deleted file mode 100644 index df97697cd2e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/CPP/constructorbuilder_setcustomattribute1.cpp +++ /dev/null @@ -1,91 +0,0 @@ - -// System::Reflection::Emit::ConstructorBuilder.SetCustomAttribute(CustomAttributeBuilder) -/* - The following program demonstrates the 'SetCustomAttribute(CustomAttributeBuilder)' - method of 'ConstructorBuilder' class. It defines a 'MyAttribute' class which is derived - from 'Attribute' class. It builds a constructor by setting 'MyAttribute' custom attribute - and defines 'Helloworld' type. Then it gets the custom attributes of 'HelloWorld' type - and displays its contents to the console. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - String^ myString; - int myInteger; - MyAttribute( String^ myString, int myInteger ) - { - this->myString = myString; - this->myInteger = myInteger; - } - -}; - -static Type^ MyCreateCallee( AppDomain^ domain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Define a dynamic assembly in the current application domain-> - AssemblyBuilder^ myAssembly = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Define a dynamic module in this assembly-> - ModuleBuilder^ myModuleBuilder = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Construct a 'TypeBuilder' given the name and attributes. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define a constructor of the dynamic class. - array^type1 = {String::typeid}; - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, type1 ); - ILGenerator^ myILGenerator = myConstructor->GetILGenerator(); - myILGenerator->Emit( OpCodes::Ldstr, "Constructor is invoked" ); - myILGenerator->Emit( OpCodes::Ldarg_1 ); - array^type2 = {String::typeid}; - MethodInfo^ myMethodInfo = Console::typeid->GetMethod( "WriteLine", type2 ); - myILGenerator->Emit( OpCodes::Call, myMethodInfo ); - myILGenerator->Emit( OpCodes::Ret ); - Type^ myType = MyAttribute::typeid; - array^type3 = {String::typeid,int::typeid}; - ConstructorInfo^ myConstructorInfo = myType->GetConstructor( type3 ); - array^obj1 = {"Hello",2}; - CustomAttributeBuilder^ attributeBuilder = gcnew CustomAttributeBuilder( myConstructorInfo,obj1 ); - try - { - myConstructor->SetCustomAttribute( attributeBuilder ); - } - catch ( ArgumentNullException^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - - return myTypeBuilder->CreateType(); -} - -int main() -{ - Type^ myHelloworld = MyCreateCallee( Thread::GetDomain() ); - array^type1 = {String::typeid}; - ConstructorInfo^ myConstructor = myHelloworld->GetConstructor( type1 ); - array^myAttributes1 = myConstructor->GetCustomAttributes( true ); - Console::WriteLine( "MyAttribute custom attribute contains " ); - for ( int index = 0; index < myAttributes1->Length; index++ ) - { - if ( dynamic_cast(myAttributes1[ index ]) ) - { - Console::WriteLine( "The value of myString is : {0}", (safe_cast(myAttributes1[ index ]))->myString ); - Console::WriteLine( "The value of myInteger is : {0}", (safe_cast(myAttributes1[ index ]))->myInteger ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/CPP/constructorbuilder_setcustomattribute2.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/CPP/constructorbuilder_setcustomattribute2.cpp deleted file mode 100644 index 7c6ae9bf4cb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/CPP/constructorbuilder_setcustomattribute2.cpp +++ /dev/null @@ -1,86 +0,0 @@ - -// System::Reflection::Emit::ConstructorBuilder.SetCustomAttribute(ConstructorInfo, Byte->Item[]) -/* - The following program demonstrates the 'SetCustomAttribute(ConstructorInfo, Byte[])' - method of 'ConstructorBuilder' class. It defines a 'MyAttribute' class which is derived - from 'Attribute' class. It builds a constructor by setting 'MyAttribute' custom attribute - and defines 'Helloworld' type. Then it gets the custom attributes of 'HelloWorld' type - and displays its contents to the console. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - bool myBoolean; - MyAttribute( bool myBoolean ) - { - this->myBoolean = myBoolean; - } -}; - -static Type^ MyCreateCallee( AppDomain^ domain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Define a dynamic assembly in the current application domain. - AssemblyBuilder^ myAssembly = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Define a dynamic module in this assembly. - ModuleBuilder^ myModuleBuilder = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Construct a 'TypeBuilder' given the name and attributes. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define a constructor of the dynamic class. - array^type1 = {String::typeid}; - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, type1 ); - ILGenerator^ myILGenerator = myConstructor->GetILGenerator(); - myILGenerator->Emit( OpCodes::Ldstr, "Constructor is invoked" ); - myILGenerator->Emit( OpCodes::Ldarg_1 ); - array^type2 = {String::typeid}; - MethodInfo^ myMethodInfo = Console::typeid->GetMethod( "WriteLine", type2 ); - myILGenerator->Emit( OpCodes::Call, myMethodInfo ); - myILGenerator->Emit( OpCodes::Ret ); - Type^ myType = MyAttribute::typeid; - array^type3 = {bool::typeid}; - ConstructorInfo^ myConstructorInfo = myType->GetConstructor( type3 ); - try - { - array^bytes = {01,00,01}; - myConstructor->SetCustomAttribute( myConstructorInfo, bytes ); - } - catch ( ArgumentNullException^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - - return myTypeBuilder->CreateType(); -} - -int main() -{ - Type^ myHelloworld = MyCreateCallee( Thread::GetDomain() ); - array^type1 = {String::typeid}; - ConstructorInfo^ myConstructor = myHelloworld->GetConstructor( type1 ); - array^myAttributes1 = myConstructor->GetCustomAttributes( true ); - Console::WriteLine( "MyAttribute custom attribute contains " ); - for ( int index = 0; index < myAttributes1->Length; index++ ) - { - if ( dynamic_cast(myAttributes1[ index ]) ) - { - Console::WriteLine( "myBoolean : {0}", safe_cast(myAttributes1[ index ])->myBoolean ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/CPP/constructorbuilder_setimplementationflags.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/CPP/constructorbuilder_setimplementationflags.cpp deleted file mode 100644 index 9ff254e4a6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/CPP/constructorbuilder_setimplementationflags.cpp +++ /dev/null @@ -1,128 +0,0 @@ - -// System::Reflection::Emit::ConstructorBuilder.SetImplementationFlags() -/* The following program demonstrates the 'SetImplementationFlags' - method of ConstructorBuilder class. It creates an assembly in the - current domain with a dynamic module in the assembly. Constructor - builder is used in conjunction with the 'TypeBuilder' class to create - constructor at run time. It then sets the method implementation flags - for the constructor and displays the same. -*/ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -public ref class MyConstructorBuilder -{ -private: - Type^ myType1; - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - MyConstructorBuilder() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; - try - { - // - MethodBuilder^ myMethodBuilder = nullptr; - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - - // Create assembly in current CurrentDomain. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Create a dynamic assembly. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module in the assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", true ); - FieldInfo^ myFieldInfo2 = myModuleBuilder->DefineUninitializedData( "myField", 2, FieldAttributes::Public ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", String::typeid, FieldAttributes::Public ); - array^myConstructorArgs = {String::typeid}; - - // Define a constructor of the dynamic class. - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - - // Set the method implementation flags for the constructor. - myConstructor->SetImplementationFlags( static_cast(MethodImplAttributes::PreserveSig | MethodImplAttributes::Runtime) ); - - // Get the method implementation flags for the constructor. - MethodImplAttributes myMethodAttributes = myConstructor->GetMethodImplementationFlags(); - Type^ myAttributeType = MethodImplAttributes::typeid; - int myAttribValue = (int)myMethodAttributes; - if ( !myAttributeType->IsEnum ) - { - Console::WriteLine( "This is not an Enum" ); - } - - // Display the field info names of the retrieved method implementation flags. - array^myFieldInfo = myAttributeType->GetFields( static_cast(BindingFlags::Public | BindingFlags::Static) ); - Console::WriteLine( "The Field info names of the MethodImplAttributes for the constructor are:" ); - for ( int i = 0; i < myFieldInfo->Length; i++ ) - { - int myFieldValue = *safe_cast(myFieldInfo[ i ]->GetValue( nullptr )); - if ( (myFieldValue & myAttribValue) == myFieldValue ) - { - Console::WriteLine( " {0}", myFieldInfo[ i ]->Name ); - } - } - // - - // Add a method to the type. - myMethodBuilder = myTypeBuilder->DefineMethod( "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); - - // Generate IL for the method. - ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); - myILGenerator2->EmitWriteLine( "Hello World from global" ); - myILGenerator2->Emit( OpCodes::Ret ); - myModuleBuilder->CreateGlobalFunctions(); - myType1 = myTypeBuilder->CreateType(); - } - catch ( InvalidOperationException^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "The following exception has occurred : {0}", ex->Message ); - } - } - - property Type^ MyTypeProperty - { - Type^ get() - { - return this->myType1; - } - } -}; - -void main() -{ - MyConstructorBuilder^ myConstructorBuilder = gcnew MyConstructorBuilder; - Type^ myType1 = myConstructorBuilder->MyTypeProperty; - if ( nullptr != myType1 ) - { - Console::WriteLine( "Instantiating the new type..." ); - array^myObject = {"hello"}; - Object^ myObject1 = Activator::CreateInstance( myType1, myObject, nullptr ); - MethodInfo^ myMethodInfo = myType1->GetMethod( "HelloWorld" ); - if ( nullptr != myMethodInfo ) - { - Console::WriteLine( "Invoking dynamically created HelloWorld method..." ); - myMethodInfo->Invoke( myObject1, nullptr ); - } - else - { - Console::WriteLine( "Could not locate HelloWorld method" ); - } - } - else - { - Console::WriteLine( "Could not access Type." ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/CPP/constructorbuilder_setsymcustomattribute.cpp b/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/CPP/constructorbuilder_setsymcustomattribute.cpp deleted file mode 100644 index 16aca594b6f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/CPP/constructorbuilder_setsymcustomattribute.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// System.Reflection.Emit.ConstructorBuilder.SetSymCustomAttribute() - -/* The following program demonstrates the 'SetSymCustomAttribute' method -of ConstructorBuilder class. It creates an assembly in the current -domain with dynamic module in the assembly. Constructor builder is -used in conjunction with the 'TypeBuilder' class to create constructor -at run time. It then sets this constructor's custom attribute associated -with symbolic information. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class MyConstructorBuilder -{ -private: - Type^ myType1; - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - MyConstructorBuilder() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; - -// - MethodBuilder^ myMethodBuilder = nullptr; - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - // Create assembly in current CurrentDomain. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - // Create a dynamic assembly. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::Run ); - // Create a dynamic module in the assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", true ); - FieldInfo^ myFieldInfo = - myModuleBuilder->DefineUninitializedData( "myField", 2, FieldAttributes::Public ); - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", - String::typeid, FieldAttributes::Public ); - array^ myConstructorArgs = {String::typeid}; - // Define a constructor of the dynamic class. - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - // Display the name of the constructor. - Console::WriteLine( "The constructor name is : {0}", myConstructor->Name ); - array^ temp0 = {01,00,00}; - myConstructor->SetSymCustomAttribute( "MySimAttribute", temp0 ); -// - // Generate the IL for the method and call its superclass constructor. - ILGenerator^ myILGenerator3 = myConstructor->GetILGenerator(); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ myConstructorInfo = Object::typeid->GetConstructor( gcnew array(0) ); - myILGenerator3->Emit( OpCodes::Call, myConstructorInfo ); - myILGenerator3->Emit( OpCodes::Ldarg_0 ); - myILGenerator3->Emit( OpCodes::Ldarg_1 ); - myILGenerator3->Emit( OpCodes::Stfld, myGreetingField ); - myILGenerator3->Emit( OpCodes::Ret ); - // Add a method to the type. - myMethodBuilder = myTypeBuilder->DefineMethod( - "HelloWorld", MethodAttributes::Public, nullptr, nullptr ); - // Generate IL for the method. - ILGenerator^ myILGenerator2 = myMethodBuilder->GetILGenerator(); - myILGenerator2->EmitWriteLine( "Hello World from global" ); - myILGenerator2->Emit( OpCodes::Ret ); - myModuleBuilder->CreateGlobalFunctions(); - myType1 = myTypeBuilder->CreateType(); - } - - property Type^ MyTypeProperty - { - Type^ get() - { - return this->myType1; - } - } -}; - -int main() -{ - MyConstructorBuilder^ myConstructorBuilder = gcnew MyConstructorBuilder; - Type^ myType1 = myConstructorBuilder->MyTypeProperty; - if ( nullptr != myType1 ) - { - Console::WriteLine( "Instantiating the new type..." ); - array^ myObject = {"hello"}; - Object^ myObject1 = Activator::CreateInstance( myType1, myObject, nullptr ); - MethodInfo^ myMethodInfo = myType1->GetMethod( "HelloWorld" ); - if ( nullptr != myMethodInfo ) - { - Console::WriteLine( "Invoking dynamically created HelloWorld method..." ); - myMethodInfo->Invoke( myObject1, nullptr ); - } - else - { - Console::WriteLine( "Could not locate HelloWorld method" ); - } - } - else - { - Console::WriteLine( "Could not access Type." ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp deleted file mode 100644 index 95a1012b1d2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; -using namespace System::Collections::ObjectModel; - -// An enumeration used by the ExampleAttribute class. -public enum class ExampleKind -{ - FirstKind, SecondKind, ThirdKind, FourthKind -}; - -// An example attribute. The attribute can be applied to all -// targets, from assemblies to parameters. -// -[AttributeUsage(AttributeTargets::All)] -public ref class ExampleAttribute: public Attribute -{ -private: - // Data for properties. - ExampleKind kindValue; - String^ noteValue; - array^ arrayStrings; - array^ arrayNumbers; - - // Constructors. - void ExampleAttributeInitialize( ExampleKind initKind, array^ initStrings ) - { - kindValue = initKind; - arrayStrings = initStrings; - } -public: - ExampleAttribute() - { - ExampleAttributeInitialize( ExampleKind::FirstKind, nullptr ); - } - ExampleAttribute( ExampleKind initKind ) - { - ExampleAttributeInitialize( initKind, nullptr ); - } - ExampleAttribute( ExampleKind initKind, array^ initStrings ) - { - ExampleAttributeInitialize( initKind, initStrings ); - } - - // Properties. The Note and Numbers properties must be read/write, so they - // can be used as named parameters. - // - property ExampleKind Kind - { - ExampleKind get() - { - return kindValue; - } - } - property array^ Strings - { - array^ get() - { - return arrayStrings; - } - } - property String^ Note - { - String^ get() - { - return noteValue; - } - - void set( String^ value ) - { - noteValue = value; - } - } - property array^ Numbers - { - array^ get() - { - return arrayNumbers; - } - - void set( array^ value ) - { - arrayNumbers = value; - } - } -}; - -// The example attribute is applied to the assembly. -[assembly:Example(ExampleKind::ThirdKind,Note="This is a note on the assembly.")]; - -// The example attribute is applied to the test class. -// -[Example(ExampleKind::SecondKind, - gcnew array { "String array argument, line 1", - "String array argument, line 2", - "String array argument, line 3" }, - Note="This is a note on the class.", - Numbers = gcnew array { 53, 57, 59 })] -public ref class Test -{ -public: - // The example attribute is applied to a method, using the - // parameterless constructor and supplying a named argument. - // The attribute is also applied to the method parameter. - // - [Example(Note="This is a note on a method.")] - void TestMethod( [Example] Object^ arg ){} - - // Main() gets objects representing the assembly, the test - // type, the test method, and the method parameter. Custom - // attribute data is displayed for each of these. - // - static void Main() - { - Assembly^ assembly = Assembly::ReflectionOnlyLoad( "Source" ); - Type^ t = assembly->GetType( "Test" ); - MethodInfo^ m = t->GetMethod( "TestMethod" ); - array^p = m->GetParameters(); - - Console::WriteLine( "\r\nAttributes for assembly: '{0}'", assembly ); - ShowAttributeData( CustomAttributeData::GetCustomAttributes( assembly ) ); - Console::WriteLine( "\r\nAttributes for type: '{0}'", t ); - ShowAttributeData( CustomAttributeData::GetCustomAttributes( t ) ); - Console::WriteLine( "\r\nAttributes for member: '{0}'", m ); - ShowAttributeData( CustomAttributeData::GetCustomAttributes( m ) ); - Console::WriteLine( "\r\nAttributes for parameter: '{0}'", p ); - ShowAttributeData( CustomAttributeData::GetCustomAttributes( p[ 0 ] ) ); - } - -private: - static void ShowValueOrArray(CustomAttributeTypedArgument^ cata) - { - if (cata->Value->GetType() == ReadOnlyCollection::typeid) - { - Console::WriteLine(" Array of '{0}':", cata->ArgumentType); - - for each (CustomAttributeTypedArgument^ cataElement in - (ReadOnlyCollection^) cata->Value) - { - Console::WriteLine(" Type: '{0}' Value: '{1}'", - cataElement->ArgumentType, cataElement->Value); - } - } - else - { - Console::WriteLine( " Type: '{0}' Value: '{1}'", - cata->ArgumentType, cata->Value ); - } - } - - static void ShowAttributeData( IList< CustomAttributeData^ >^ attributes ) - { - for each ( CustomAttributeData^ cad in attributes ) - { - Console::WriteLine( " {0}", cad ); - Console::WriteLine( " Constructor: '{0}'", cad->Constructor ); - - Console::WriteLine( " Constructor arguments:" ); - for each ( CustomAttributeTypedArgument^ cata in cad->ConstructorArguments ) - { - ShowValueOrArray(cata); - } - - Console::WriteLine( " Named arguments:" ); - for each ( CustomAttributeNamedArgument cana in cad->NamedArguments ) - { - Console::WriteLine( " MemberInfo: '{0}'", cana.MemberInfo ); - ShowValueOrArray(cana.TypedValue); - } - } - } -}; - -int main() -{ - Test::Main(); -} - -/* This code example produces output similar to the following: - -Attributes for assembly: 'source, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' - [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)] - Constructor: 'Void .ctor(Int32)' - Constructor arguments: - Type: 'System.Int32' Value: '8' - Named arguments: - [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)] - Constructor: 'Void .ctor()' - Constructor arguments: - Named arguments: - MemberInfo: 'Boolean WrapNonExceptionThrows' - Type: 'System.Boolean' Value: 'True' - [ExampleAttribute((ExampleKind)2, Note = "This is a note on the assembly.")] - Constructor: 'Void .ctor(ExampleKind)' - Constructor arguments: - Type: 'ExampleKind' Value: '2' - Named arguments: - MemberInfo: 'System.String Note' - Type: 'System.String' Value: 'This is a note on the assembly.' - -Attributes for type: 'Test' - [ExampleAttribute((ExampleKind)1, new String[3] { "String array argument, line 1", "String array argument, line 2", "String array argument, line 3" }, Note = "This is a note on the class.", Numbers = new Int32[3] { 53, 57, 59 })] - Constructor: 'Void .ctor(ExampleKind, System.String[])' - Constructor arguments: - Type: 'ExampleKind' Value: '1' - Array of 'System.String[]': - Type: 'System.String' Value: 'String array argument, line 1' - Type: 'System.String' Value: 'String array argument, line 2' - Type: 'System.String' Value: 'String array argument, line 3' - Named arguments: - MemberInfo: 'System.String Note' - Type: 'System.String' Value: 'This is a note on the class.' - MemberInfo: 'Int32[] Numbers' - Array of 'System.Int32[]': - Type: 'System.Int32' Value: '53' - Type: 'System.Int32' Value: '57' - Type: 'System.Int32' Value: '59' - -Attributes for member: 'Void TestMethod(System.Object)' - [ExampleAttribute(Note = "This is a note on a method.")] - Constructor: 'Void .ctor()' - Constructor arguments: - Named arguments: - MemberInfo: 'System.String Note' - Type: 'System.String' Value: 'This is a note on a method.' - -Attributes for parameter: 'System.Object arg' - [ExampleAttribute()] - Constructor: 'Void .ctor()' - Constructor arguments: - Named arguments: -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Emit.ArgIterator/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Emit.ArgIterator/cpp/source.cpp deleted file mode 100644 index 0ee3bf8e579..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Emit.ArgIterator/cpp/source.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -void main() -{ - String^ name = "InMemory"; - - AssemblyBuilder^ asmBldr = - AppDomain::CurrentDomain->DefineDynamicAssembly(gcnew AssemblyName(name), - AssemblyBuilderAccess::Run); - ModuleBuilder^ modBldr = asmBldr->DefineDynamicModule(name); - - TypeBuilder^ tb = modBldr->DefineType("DemoVararg"); - - // Create a vararg method with no return value and one - // string argument. (The string argument type is the only - // element of an array of Type objects.) - // - MethodBuilder^ mb1 = tb->DefineMethod("VarargMethod", - MethodAttributes::Public | MethodAttributes::Static, - CallingConventions::VarArgs, - nullptr, - gcnew array { String::typeid }); - - ILGenerator^ il1 = mb1->GetILGenerator(); - - LocalBuilder^ locAi = il1->DeclareLocal(ArgIterator::typeid); - LocalBuilder^ locNext = il1->DeclareLocal(bool::typeid); - - Label labelCheckCondition = il1->DefineLabel(); - Label labelNext = il1->DefineLabel(); - - // Load the fixed argument and print it. - il1->Emit(OpCodes::Ldarg_0); - il1->Emit(OpCodes::Call, Console::typeid->GetMethod("Write", - gcnew array { String::typeid })); - - // Load the address of the local variable represented by - // locAi, which will hold the ArgIterator. - il1->Emit(OpCodes::Ldloca_S, locAi); - - // Load the address of the argument list, and call the - // ArgIterator constructor that takes an array of runtime - // argument handles. - il1->Emit(OpCodes::Arglist); - il1->Emit(OpCodes::Call, ArgIterator::typeid->GetConstructor( - gcnew array { RuntimeArgumentHandle::typeid })); - - // Enter the loop at the point where the remaining argument - // count is tested. - il1->Emit(OpCodes::Br_S, labelCheckCondition); - - // At the top of the loop, call GetNextArg to get the next - // argument from the ArgIterator. Convert the typed reference - // to an object reference and write the object to the console. - il1->MarkLabel(labelNext); - il1->Emit(OpCodes::Ldloca_S, locAi); - il1->Emit(OpCodes::Call, ArgIterator::typeid->GetMethod("GetNextArg", Type::EmptyTypes)); - il1->Emit(OpCodes::Call, TypedReference::typeid->GetMethod("ToObject")); - il1->Emit(OpCodes::Call, Console::typeid->GetMethod("Write", - gcnew array { Object::typeid })); - - il1->MarkLabel(labelCheckCondition); - il1->Emit(OpCodes::Ldloca_S, locAi); - il1->Emit(OpCodes::Call, ArgIterator::typeid->GetMethod("GetRemainingCount")); - - // If the remaining count is greater than zero, go to - // the top of the loop. - il1->Emit(OpCodes::Ldc_I4_0); - il1->Emit(OpCodes::Cgt); - il1->Emit(OpCodes::Stloc_1); - il1->Emit(OpCodes::Ldloc_1); - il1->Emit(OpCodes::Brtrue_S, labelNext); - - il1->Emit(OpCodes::Ret); - - // Create a method that contains a call to the vararg - // method. - MethodBuilder^ mb2 = tb->DefineMethod("CallVarargMethod", - MethodAttributes::Public | MethodAttributes::Static, - CallingConventions::Standard, - nullptr, Type::EmptyTypes); - - ILGenerator^ il2 = mb2->GetILGenerator(); - - // Push arguments on the stack: one for the fixed string - // parameter, and two for the list. - il2->Emit(OpCodes::Ldstr, "Hello "); - il2->Emit(OpCodes::Ldstr, "world "); - il2->Emit(OpCodes::Ldc_I4, 2006); - - // Call the vararg method, specifying the types of the - // arguments in the list. - il2->EmitCall(OpCodes::Call, mb1, - gcnew array { String::typeid, int::typeid }); - - il2->Emit(OpCodes::Ret); - - Type^ type = tb->CreateType(); - type->GetMethod("CallVarargMethod")->Invoke(nullptr, nullptr); -} - -/* This code example produces the following output: - -Hello world 2006 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp deleted file mode 100644 index e0695468622..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp +++ /dev/null @@ -1,300 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Collections::Generic; - -// Dummy class to satisfy TFirst constraints. -// -public ref class Example {}; - -// Define a trivial base class and two trivial interfaces -// to use when demonstrating constraints. -// -public ref class ExampleBase {}; -public interface class IExampleA {}; -public interface class IExampleB {}; - -// Define a trivial type that can substitute for type parameter -// TSecond. -// -public ref class ExampleDerived : ExampleBase, IExampleA, IExampleB {}; - -// List the constraint flags. The GenericParameterAttributes -// enumeration contains two sets of attributes, variance and -// constraints. For this example, only constraints are used. -// -static void ListConstraintAttributes( Type^ t ) -{ - // Mask off the constraint flags. - GenericParameterAttributes constraints = - t->GenericParameterAttributes & - GenericParameterAttributes::SpecialConstraintMask; - - if ((constraints & GenericParameterAttributes::ReferenceTypeConstraint) - != GenericParameterAttributes::None) - Console::WriteLine( L" ReferenceTypeConstraint"); - - if ((constraints & GenericParameterAttributes::NotNullableValueTypeConstraint) - != GenericParameterAttributes::None) - Console::WriteLine( L" NotNullableValueTypeConstraint"); - - if ((constraints & GenericParameterAttributes::DefaultConstructorConstraint) - != GenericParameterAttributes::None) - Console::WriteLine( L" DefaultConstructorConstraint"); -} - -static void DisplayGenericParameters( Type^ t ) -{ - if (!t->IsGenericType) - { - Console::WriteLine( L"Type '{0}' is not generic." ); - return; - } - if (!t->IsGenericTypeDefinition) - t = t->GetGenericTypeDefinition(); - - array^ typeParameters = t->GetGenericArguments(); - Console::WriteLine( L"\r\nListing {0} type parameters for type '{1}'.", - typeParameters->Length, t ); - - for each ( Type^ tParam in typeParameters ) - { - Console::WriteLine( L"\r\nType parameter {0}:", - tParam->ToString() ); - - for each (Type^ c in tParam->GetGenericParameterConstraints()) - { - if (c->IsInterface) - Console::WriteLine( L" Interface constraint: {0}", c); - else - Console::WriteLine( L" Base type constraint: {0}", c); - } - ListConstraintAttributes(tParam); - } -} - -void main() -{ - // Define a dynamic assembly to contain the sample type. The - // assembly will be run and also saved to disk, so - // AssemblyBuilderAccess.RunAndSave is specified. - // - // - AppDomain^ myDomain = AppDomain::CurrentDomain; - AssemblyName^ myAsmName = gcnew AssemblyName( L"GenericEmitExample1" ); - AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( - myAsmName, AssemblyBuilderAccess::RunAndSave ); - // - - // An assembly is made up of executable modules. For a single- - // module assembly, the module name and file name are the same - // as the assembly name. - // - // - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( - myAsmName->Name, String::Concat( myAsmName->Name, L".dll" ) ); - // - - // Get type objects for the base class trivial interfaces to - // be used as constraints. - // - Type^ baseType = ExampleBase::typeid; - Type^ interfaceA = IExampleA::typeid; - Type^ interfaceB = IExampleB::typeid; - - // Define the sample type. - // - // - TypeBuilder^ myType = myModule->DefineType( L"Sample", - TypeAttributes::Public ); - // - - Console::WriteLine( L"Type 'Sample' is generic: {0}", - myType->IsGenericType ); - - // Define type parameters for the type. Until you do this, - // the type is not generic, as the preceding and following - // WriteLine statements show. The type parameter names are - // specified as an array of strings. To make the code - // easier to read, each GenericTypeParameterBuilder is placed - // in a variable with the same name as the type parameter. - // - // - array^typeParamNames = {L"TFirst",L"TSecond"}; - array^typeParams = - myType->DefineGenericParameters( typeParamNames ); - - GenericTypeParameterBuilder^ TFirst = typeParams[0]; - GenericTypeParameterBuilder^ TSecond = typeParams[1]; - // - - Console::WriteLine( L"Type 'Sample' is generic: {0}", - myType->IsGenericType ); - - // Apply constraints to the type parameters. - // - // A type that is substituted for the first parameter, TFirst, - // must be a reference type and must have a parameterless - // constructor. - // - TFirst->SetGenericParameterAttributes( - GenericParameterAttributes::DefaultConstructorConstraint | - GenericParameterAttributes::ReferenceTypeConstraint - ); - // - - // A type that is substituted for the second type - // parameter must implement IExampleA and IExampleB, and - // inherit from the trivial test class ExampleBase. The - // interface constraints are specified as an array - // containing the interface types. - // - array^interfaceTypes = { interfaceA, interfaceB }; - TSecond->SetInterfaceConstraints( interfaceTypes ); - TSecond->SetBaseTypeConstraint( baseType ); - // - - // The following code adds a private field named ExampleField, - // of type TFirst. - // - FieldBuilder^ exField = - myType->DefineField("ExampleField", TFirst, - FieldAttributes::Private); - // - - // Define a static method that takes an array of TFirst and - // returns a List containing all the elements of - // the array. To define this method it is necessary to create - // the type List by calling MakeGenericType on the - // generic type definition, generic List. - // The parameter type is created by using the - // MakeArrayType method. - // - // - Type^ listOf = List::typeid; - Type^ listOfTFirst = listOf->MakeGenericType(TFirst); - array^ mParamTypes = { TFirst->MakeArrayType() }; - - MethodBuilder^ exMethod = - myType->DefineMethod("ExampleMethod", - MethodAttributes::Public | MethodAttributes::Static, - listOfTFirst, - mParamTypes); - // - - // Emit the method body. - // The method body consists of just three opcodes, to load - // the input array onto the execution stack, to call the - // List constructor that takes IEnumerable, - // which does all the work of putting the input elements into - // the list, and to return, leaving the list on the stack. The - // hard work is getting the constructor. - // - // The GetConstructor method is not supported on a - // GenericTypeParameterBuilder, so it is not possible to get - // the constructor of List directly. There are two - // steps, first getting the constructor of generic List and then - // calling a method that converts it to the corresponding - // constructor of List. - // - // The constructor needed here is the one that takes an - // IEnumerable. Note, however, that this is not the - // generic type definition of generic IEnumerable; instead, the - // T from generic List must be substituted for the T of - // generic IEnumerable. (This seems confusing only because both - // types have type parameters named T. That is why this example - // uses the somewhat silly names TFirst and TSecond.) To get - // the type of the constructor argument, take the generic - // type definition generic IEnumerable and - // call MakeGenericType with the first generic type parameter - // of generic List. The constructor argument list must be passed - // as an array, with just one argument in this case. - // - // Now it is possible to get the constructor of generic List, - // using GetConstructor on the generic type definition. To get - // the constructor of List, pass List and - // the constructor from generic List to the static - // TypeBuilder.GetConstructor method. - // - // - ILGenerator^ ilgen = exMethod->GetILGenerator(); - - Type^ ienumOf = IEnumerable::typeid; - Type^ TfromListOf = listOf->GetGenericArguments()[0]; - Type^ ienumOfT = ienumOf->MakeGenericType(TfromListOf); - array^ ctorArgs = {ienumOfT}; - - ConstructorInfo^ ctorPrep = listOf->GetConstructor(ctorArgs); - ConstructorInfo^ ctor = - TypeBuilder::GetConstructor(listOfTFirst, ctorPrep); - - ilgen->Emit(OpCodes::Ldarg_0); - ilgen->Emit(OpCodes::Newobj, ctor); - ilgen->Emit(OpCodes::Ret); - // - - // Create the type and save the assembly. - // - Type^ finished = myType->CreateType(); - myAssembly->Save( String::Concat( myAsmName->Name, L".dll" ) ); - // - - // Invoke the method. - // ExampleMethod is not generic, but the type it belongs to is - // generic, so in order to get a MethodInfo that can be invoked - // it is necessary to create a constructed type. The Example - // class satisfies the constraints on TFirst, because it is a - // reference type and has a default constructor. In order to - // have a class that satisfies the constraints on TSecond, - // this code example defines the ExampleDerived type. These - // two types are passed to MakeGenericMethod to create the - // constructed type. - // - // - array^ typeArgs = - { Example::typeid, ExampleDerived::typeid }; - Type^ constructed = finished->MakeGenericType(typeArgs); - MethodInfo^ mi = constructed->GetMethod("ExampleMethod"); - // - - // Create an array of Example objects, as input to the generic - // method. This array must be passed as the only element of an - // array of arguments. The first argument of Invoke is - // null, because ExampleMethod is static. Display the count - // on the resulting List. - // - // - array^ input = { gcnew Example(), gcnew Example() }; - array^ arguments = { input }; - - List^ listX = - (List^) mi->Invoke(nullptr, arguments); - - Console::WriteLine( - "\nThere are {0} elements in the List.", - listX->Count); - // - - DisplayGenericParameters(finished); -} - -/* This code example produces the following output: - -Type 'Sample' is generic: False -Type 'Sample' is generic: True - -There are 2 elements in the List. - -Listing 2 type parameters for type 'Sample[TFirst,TSecond]'. - -Type parameter TFirst: - ReferenceTypeConstraint - DefaultConstructorConstraint - -Type parameter TSecond: - Interface constraint: IExampleA - Interface constraint: IExampleB - Base type constraint: ExampleBase - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/CPP/enumbuilder_properties_4.cpp b/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/CPP/enumbuilder_properties_4.cpp deleted file mode 100644 index 47c3f438a04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/CPP/enumbuilder_properties_4.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -// System.Reflection.Emit.EnumBuilder.TypeToken -// System.Reflection.Emit.EnumBuilder.UnderlyingField -// System.Reflection.Emit.EnumBuilder.UnderlyingSystemType -// System.Reflection.Emit.EnumBuilder.GUID -/* The following program demonstrates 'TypeToken', 'UnderlyingField', - 'UnderlyingSystemType' and ''GUID' properties of - 'System.Reflection.Emit.EnumBuilder' class. This example defines - a class 'MyEnumBuilderSample'. The main function calls the CreateCalle - method in which the 'EnumBuilder' class and its fields are constructed. - The output of the 'EnumBuilder' properties are displayed on the console - in the main method. */ -// -// -// -// -using namespace System; -using namespace System::Collections; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -public ref class MyEnumBuilderSample -{ -private: - static AssemblyBuilder^ myAssemblyBuilder; - static ModuleBuilder^ myModuleBuilder; - static EnumBuilder^ myEnumBuilder; - -public: - static void Main() - { - try - { - CreateCallee( Thread::GetDomain(), AssemblyBuilderAccess::Save ); - array^myTypeArray = myModuleBuilder->GetTypes(); - IEnumerator^ myEnum = myTypeArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ myType = safe_cast(myEnum->Current); - Console::WriteLine( "Enum Builder defined in the module builder is: {0}", myType->Name ); - } - Console::WriteLine( "Enum TypeToken is :{0}", myEnumBuilder->TypeToken ); - Console::WriteLine( "Enum UnderLyingField is :{0}", myEnumBuilder->UnderlyingField ); - Console::WriteLine( "Enum UnderLyingSystemType is :{0}", myEnumBuilder->UnderlyingSystemType ); - Console::WriteLine( "Enum GUID is :{0}", myEnumBuilder->GUID ); - myAssemblyBuilder->Save( "EmittedAssembly.dll" ); - } - catch ( NotSupportedException^ ex ) - { - Console::WriteLine( "The following is the exception is raised: {0}", ex->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following is the exception raised: {0}", e->Message ); - } - } - - -private: - static void CreateCallee( AppDomain^ myAppDomain, AssemblyBuilderAccess /*access*/ ) - { - // Create a name for the assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the dynamic assembly. - myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save ); - - // Create a dynamic module. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - - // Create a dynamic Enum. - myEnumBuilder = myModuleBuilder->DefineEnum( "MyNamespace.MyEnum", TypeAttributes::Public, Int32::typeid ); - FieldBuilder^ myFieldBuilder1 = myEnumBuilder->DefineLiteral( "FieldOne", 1 ); - FieldBuilder^ myFieldBuilder2 = myEnumBuilder->DefineLiteral( "FieldTwo", 2 ); - myEnumBuilder->CreateType(); - } -}; - -int main() -{ - MyEnumBuilderSample::Main(); -} -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp b/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp deleted file mode 100644 index e210b66486f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -// System.Reflection.Emit.EnumBuilder.Assembly -// System.Reflection.Emit.EnumBuilder.AssemblyQualifiedName -// System.Reflection.Emit.EnumBuilder.Module -// System.Reflection.Emit.EnumBuilder.Name -// System.Reflection.Emit.EnumBuilder.Namespace -/* The following program demonstrates 'Assembly', 'AssemblyQualifiedName', - 'Module', 'Name' and 'Namespace' properties of - 'System.Reflection.Emit.EnumBuilder' class. This example defines a - class 'MyEnumBuilderSample'. The main function calls the CreateCalle - method in which the 'EnumBuilder' class and its fields are constructed. - The output of the 'EnumBuilder' properties are displayed on the console - in the main method. */ -// -// -// -// -// -using namespace System; -using namespace System::Collections; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class MyEnumBuilderSample -{ -private: - static AssemblyBuilder^ myAssemblyBuilder; - static ModuleBuilder^ myModuleBuilder; - static EnumBuilder^ myEnumBuilder; - -public: - static void Main() - { - try - { - CreateCallee( Thread::GetDomain(), AssemblyBuilderAccess::Save ); - array^myTypeArray = myModuleBuilder->GetTypes(); - IEnumerator^ myEnum = myTypeArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ myType = safe_cast(myEnum->Current); - Console::WriteLine( "Enum Builder defined in the module builder is: {0}", myType->Name ); - } - Console::WriteLine( "Properties of EnumBuilder : " ); - Console::WriteLine( "Enum Assembly is :{0}", myEnumBuilder->Assembly ); - Console::WriteLine( "Enum AssemblyQualifiedName is :{0}", myEnumBuilder->AssemblyQualifiedName ); - Console::WriteLine( "Enum Module is :{0}", myEnumBuilder->Module ); - Console::WriteLine( "Enum Name is :{0}", myEnumBuilder->Name ); - Console::WriteLine( "Enum NameSpace is :{0}", myEnumBuilder->Namespace ); - myAssemblyBuilder->Save( "EmittedAssembly.dll" ); - } - catch ( NotSupportedException^ ex ) - { - Console::WriteLine( "The following is the exception is raised: {0}", ex->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following is the exception raised: {0}", e->Message ); - } - } - -private: - static void CreateCallee( AppDomain^ myAppDomain, AssemblyBuilderAccess /*access*/ ) - { - // Create a name for the assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the dynamic assembly. - myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save ); - - // Create a dynamic module. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - - // Create a dynamic Enum. - myEnumBuilder = myModuleBuilder->DefineEnum( "MyNamespace.MyEnum", TypeAttributes::Public, Int32::typeid ); - FieldBuilder^ myFieldBuilder1 = myEnumBuilder->DefineLiteral( "FieldOne", 1 ); - FieldBuilder^ myFieldBuilder2 = myEnumBuilder->DefineLiteral( "FieldTwo", 2 ); - myEnumBuilder->CreateType(); - } -}; - -int main() -{ - MyEnumBuilderSample::Main(); -} -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/CPP/enumbuilder_setcustomattribute1.cpp b/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/CPP/enumbuilder_setcustomattribute1.cpp deleted file mode 100644 index 6fa6db382ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/CPP/enumbuilder_setcustomattribute1.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// System.Reflection.Emit.EnumBuilder -// System.Reflection.Emit.EnumBuilder.IsDefined() -// System.Reflection.Emit.EnumBuilder.GetCustomAttributes(Type, bool) -// System.Reflection.Emit.EnumBuilder.SetCustomAttribute(CustomAttributeBuilder) -/* - The following program demonstrates the EnumBuilder class and - its methods 'IsDefined', 'GetCustomAttributes(Type, bool)' and - 'SetCustomAttribute(CustomAttributeBuilder)'. It defines a 'MyAttribute' - class which is derived from 'System.Attribute' class. It builds an Enum - and sets 'MyAttribute' as custom attribute to the Enum. It gets the - custom attributes of the Enum type and displays its contents on the console. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - String^ myString; - int myInteger; - MyAttribute( String^ myString1, int myInteger1 ) - { - this->myString = myString1; - this->myInteger = myInteger1; - } - -}; - -ref class MyApplication -{ -private: - static AssemblyBuilder^ myAssemblyBuilder; - static EnumBuilder^ myEnumBuilder; - -public: - static void Main() - { - try - { - CreateCallee( Thread::GetDomain() ); - if ( myEnumBuilder->IsDefined( MyAttribute::typeid, false ) ) - { - array^myAttributesArray = myEnumBuilder->GetCustomAttributes( MyAttribute::typeid, false ); - Console::WriteLine( "Custom attribute contains: " ); - - // Read the attributes and display them on the console. - for ( int index = 0; index < myAttributesArray->Length; index++ ) - { - if ( dynamic_cast(myAttributesArray[ index ]) ) - { - Console::WriteLine( "The value of myString is: {0}", (dynamic_cast(myAttributesArray[ index ]))->myString ); - Console::WriteLine( "The value of myInteger is: {0}", (dynamic_cast(myAttributesArray[ index ]))->myInteger ); - } - } - } - else - { - Console::WriteLine( "Custom Attributes are not set for the EnumBuilder" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception is raised:{0}", e->Message ); - } - - } - -private: - static void CreateCallee( AppDomain^ domain ) - { - // Create a name for the assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the dynamic assembly. - myAssemblyBuilder = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - Type^ myType = MyAttribute::typeid; - array^temp0 = {String::typeid,int::typeid}; - ConstructorInfo^ myInfo = myType->GetConstructor( temp0 ); - array^temp1 = {"Hello",2}; - CustomAttributeBuilder^ myCustomAttributeBuilder = gcnew CustomAttributeBuilder( myInfo,temp1 ); - - // Create a dynamic module. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule" ); - - // Create a dynamic Enum. - myEnumBuilder = myModuleBuilder->DefineEnum( "MyNamespace.MyEnum", TypeAttributes::Public, Int32::typeid ); - FieldBuilder^ myFieldBuilder1 = myEnumBuilder->DefineLiteral( "FieldOne", 1 ); - FieldBuilder^ myFieldBuilder2 = myEnumBuilder->DefineLiteral( "FieldTwo", 2 ); - myEnumBuilder->CreateType(); - myEnumBuilder->SetCustomAttribute( myCustomAttributeBuilder ); - } -}; - -int main() -{ - MyApplication::Main(); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp b/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp deleted file mode 100644 index 2e1b90bdfc9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -// System.Reflection.Emit.EnumBuilder.GetCustomAttributes(bool) -// System.Reflection.Emit.EnumBuilder.SetCustomAttribute(ConstructorInfo, byte[]) -/* - The following program demonstrates 'GetCustomAttributes(bool)' - and 'SetCustomAttribute(ConstructorInfo, byte[])' methods of - 'System.Reflection.Emit.EnumBuilder' class. It defines 'MyAttribute' - class which is derived from 'System.Attribute' class. It builds an - Enum and sets 'MyAttribute' as custom attribute to the Enum. - It gets the custom attributes of the Enum type and displays its contents - on the console. -*/ -// -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute: public Attribute -{ -public: - bool myBoolValue; - MyAttribute( bool myBool ) - { - this->myBoolValue = myBool; - } -}; - -ref class MyApplication -{ -private: - static EnumBuilder^ myEnumBuilder; - -public: - static void Main() - { - try - { - CreateCallee( Thread::GetDomain() ); - array^myAttributesArray = myEnumBuilder->GetCustomAttributes( true ); - - // Read the attributes and display them on the console. - Console::WriteLine( "Custom attribute contains: " ); - for ( int index = 0; index < myAttributesArray->Length; index++ ) - { - if ( dynamic_cast(myAttributesArray[ index ]) ) - { - Console::WriteLine( "myBoolValue: {0}", (dynamic_cast(myAttributesArray[ index ]))->myBoolValue ); - } - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception is raised:{0}", e->Message ); - } - - } - -private: - static void CreateCallee( AppDomain^ domain ) - { - AssemblyName^ myAssemblyName = gcnew AssemblyName; - - // Create a name for the assembly. - myAssemblyName->Name = "EmittedAssembly"; - - // Create the dynamic assembly. - AssemblyBuilder^ myAssemblyBuilder = domain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - Type^ myType = MyAttribute::typeid; - array^temp0 = {bool::typeid}; - ConstructorInfo^ myInfo = myType->GetConstructor( temp0 ); - - // Create a dynamic module. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule" ); - - // Create a dynamic Enum. - myEnumBuilder = myModuleBuilder->DefineEnum( "MyNamespace.MyEnum", TypeAttributes::Public, Int32::typeid ); - FieldBuilder^ myFieldBuilder1 = myEnumBuilder->DefineLiteral( "FieldOne", 1 ); - FieldBuilder^ myFieldBuilder2 = myEnumBuilder->DefineLiteral( "FieldTwo", 2 ); - myEnumBuilder->CreateType(); - array^temp1 = {01,00,01}; - myEnumBuilder->SetCustomAttribute( myInfo, temp1 ); - } -}; - -int main() -{ - MyApplication::Main(); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventArg/CPP/eventarg.cpp b/snippets/cpp/VS_Snippets_CLR/EventArg/CPP/eventarg.cpp deleted file mode 100644 index 1b826c1f2bc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventArg/CPP/eventarg.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -// The following example uses instances of classes in -// the System::Reflection namespace to discover an event argument type. -using namespace System; -using namespace System::Reflection; - -public delegate void MyDelegate( int i ); -public ref class MainClass -{ -public: - event MyDelegate^ ev; -}; - -int main() -{ - Type^ delegateType = MainClass::typeid->GetEvent( "ev" )->EventHandlerType; - MethodInfo^ invoke = delegateType->GetMethod( "Invoke" ); - array^pars = invoke->GetParameters(); - System::Collections::IEnumerator^ myEnum = pars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - ParameterInfo^ p = safe_cast(myEnum->Current); - Console::WriteLine( p->ParameterType ); - } -} -// The example displays the following output: -// System.Int32 -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp b/snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp deleted file mode 100644 index 8b038438f4b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp +++ /dev/null @@ -1,84 +0,0 @@ - -// System::Reflection::Emit::FieldBuilder.ReflectedType -// System::Reflection::Emit::FieldBuilder.Attributes -/* - The following example demonstrates 'ReflectedType' and 'Attributes' - properties of 'FieldBuilder' class.A new class 'MyClass' is created. - A Field and a method are defined in the class.In the constructor of the class - the field is initialized.Method of the class gets the value of the Field. - An instance of the class is created and method is invoked. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ CreateType( AppDomain^ currentDomain ) -{ - // Create an assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "DynamicAssembly"; - AssemblyBuilder^ myAssembly = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module in Dynamic Assembly. - ModuleBuilder^ myModuleBuilder = myAssembly->DefineDynamicModule( "MyModule" ); - - // Define a public class named S"MyClass" in the assembly. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyClass", TypeAttributes::Public ); - - // Define a private String field named S"MyField" in the type. - FieldBuilder^ myFieldBuilder = myTypeBuilder->DefineField( "MyField", String::typeid, static_cast(FieldAttributes::Private | FieldAttributes::Static) ); - - // Create the constructor. - array^constructorArgs = {String::typeid}; - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, constructorArgs ); - ILGenerator^ constructorIL = myConstructor->GetILGenerator(); - constructorIL->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ superConstructor = Object::typeid->GetConstructor( gcnew array(0) ); - constructorIL->Emit( OpCodes::Call, superConstructor ); - constructorIL->Emit( OpCodes::Ldarg_0 ); - constructorIL->Emit( OpCodes::Ldarg_1 ); - constructorIL->Emit( OpCodes::Stfld, myFieldBuilder ); - constructorIL->Emit( OpCodes::Ret ); - - // Create the MyMethod method. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "MyMethod", MethodAttributes::Public, String::typeid, nullptr ); - ILGenerator^ methodIL = myMethodBuilder->GetILGenerator(); - methodIL->Emit( OpCodes::Ldarg_0 ); - methodIL->Emit( OpCodes::Ldfld, myFieldBuilder ); - methodIL->Emit( OpCodes::Ret ); - if ( myFieldBuilder->Attributes.Equals( FieldAttributes::Static ) ) - { - Console::WriteLine( "Field attribute defined as Static" ); - } - else - if ( myFieldBuilder->Attributes.Equals( FieldAttributes::Static | FieldAttributes::Private ) ) - { - Console::WriteLine( "Field attributes are Static and Private" ); - } - - - Console::WriteLine( "ReflectedType of Field is : {0}", myFieldBuilder->ReflectedType ); - return myTypeBuilder->CreateType(); -} - -int main() -{ - try - { - Type^ myType = CreateType( Thread::GetDomain() ); - - // Create an instance of the S"HelloWorld" class. - array^type = {"HelloWorld"}; - Object^ helloWorld = Activator::CreateInstance( myType, type ); - - // Invoke the S"MyMethod" of the S"MyClass". - Object^ myObject = myType->InvokeMember( "MyMethod", BindingFlags::InvokeMethod, nullptr, helloWorld, nullptr ); - Console::WriteLine( "MyClass::MyMethod returned: \"{0}\"", myObject ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp b/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp deleted file mode 100644 index fab865dd934..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp +++ /dev/null @@ -1,132 +0,0 @@ - -// System::Reflection::Emit::FieldBuilder.SetCustomAttribute(ConstructorInfo, Byte->Item[]) -// System::Reflection::Emit::FieldBuilder.SetCustomAttribute(CustomAttributeBuilder) -/* - The following program demonstrates 'SetCustomAttribute(ConstructorInfo, Byte[])' - and 'SetCustomAttribute(CustomAttributeBuilder)' methods of 'FieldBuilder' class. - A dynamic assembly is created. A new class of type 'MyClass' is created. - A 'Method' and a 'Field are defined in the class.Two 'CustomAttributes' are - set to the field. The method initializes a value to 'Field'.Value of the field - is displayed to console.Values of Attributes applied to field are retrieved and - displayed to console. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute1: public Attribute -{ -public: - String^ myCustomAttributeValue; - MyAttribute1( String^ myString ) - { - myCustomAttributeValue = myString; - } -}; - - -[AttributeUsage(AttributeTargets::All,AllowMultiple=false)] -public ref class MyAttribute2: public Attribute -{ -public: - bool myCustomAttributeValue; - MyAttribute2( bool myBool ) - { - myCustomAttributeValue = myBool; - } -}; - -Type^ CreateCallee( AppDomain^ currentDomain ) -{ - // Create a simple name for the assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the called dynamic assembly. - AssemblyBuilder^ myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - - // Define a public class named 'CustomClass' in the assembly. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "CustomClass", TypeAttributes::Public ); - - // Define a private String field named 'MyField' in the type. - FieldBuilder^ myFieldBuilder = myTypeBuilder->DefineField( "MyField", String::typeid, FieldAttributes::Public ); - Type^ myAttributeType1 = MyAttribute1::typeid; - - // Create a Constructorinfo Object* for attribute 'MyAttribute1'. - array^type1 = {String::typeid}; - ConstructorInfo^ myConstructorInfo = myAttributeType1->GetConstructor( type1 ); - - // Create the CustomAttribute instance of attribute of type 'MyAttribute1'. - array^obj1 = {"Test"}; - CustomAttributeBuilder^ attributeBuilder = gcnew CustomAttributeBuilder( myConstructorInfo,obj1 ); - - // Set the CustomAttribute 'MyAttribute1' to the Field. - myFieldBuilder->SetCustomAttribute( attributeBuilder ); - Type^ myAttributeType2 = MyAttribute2::typeid; - - // Create a Constructorinfo Object* for attribute 'MyAttribute2'. - array^type2 = {bool::typeid}; - ConstructorInfo^ myConstructorInfo2 = myAttributeType2->GetConstructor( type2 ); - - // Set the CustomAttribute 'MyAttribute2' to the Field. - array^bytes = {01,00,01,00,00}; - myFieldBuilder->SetCustomAttribute( myConstructorInfo2, bytes ); - - // Create a method. - array^type3 = {String::typeid,int::typeid}; - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "MyMethod", MethodAttributes::Public, nullptr, type3 ); - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - myILGenerator->Emit( OpCodes::Ldarg_0 ); - myILGenerator->Emit( OpCodes::Ldarg_1 ); - myILGenerator->Emit( OpCodes::Stfld, myFieldBuilder ); - myILGenerator->EmitWriteLine( "Value of the Field is :" ); - myILGenerator->EmitWriteLine( myFieldBuilder ); - myILGenerator->Emit( OpCodes::Ret ); - return myTypeBuilder->CreateType(); -} - -int main() -{ - try - { - Type^ myCustomClass = CreateCallee( Thread::GetDomain() ); - - // Construct an instance of a type. - Object^ myObject = Activator::CreateInstance( myCustomClass ); - Console::WriteLine( "FieldBuilder Sample" ); - - // Find a method in this type and call it on this Object*. - MethodInfo^ myMethodInfo = myCustomClass->GetMethod( "MyMethod" ); - array^obj1 = {"Sample string",3}; - myMethodInfo->Invoke( myObject, obj1 ); - - // Retrieve the values of Attributes applied to field and display to console. - array^myFieldInfo = myCustomClass->GetFields(); - for ( int i = 0; i < myFieldInfo->Length; i++ ) - { - array^attributes = myFieldInfo[ i ]->GetCustomAttributes( true ); - for ( int index = 0; index < attributes->Length; index++ ) - { - if ( dynamic_cast(attributes[ index ]) ) - { - MyAttribute1^ myCustomAttribute = safe_cast(attributes[ index ]); - Console::WriteLine( "Attribute Value of (MyAttribute1): {0}", myCustomAttribute->myCustomAttributeValue ); - } - if ( dynamic_cast(attributes[ index ]) ) - { - MyAttribute2^ myCustomAttribute = safe_cast(attributes[ index ]); - Console::WriteLine( "Attribute Value of (MyAttribute2): {0}", myCustomAttribute->myCustomAttributeValue ); - } - } - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp b/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp deleted file mode 100644 index 0fe41fc175c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp +++ /dev/null @@ -1,74 +0,0 @@ - -// System::Reflection::Emit::FieldBuilder.SetOffset -// System::Reflection::Emit::FieldBuilder.SetMarshal -/* - The following program demonstrates 'SetOffset' and 'SetMarshal' - methods of 'FieldBuilder' class.A new Class is defined and a - 'PInvoke' method 'OpenFile' method of 'Kernel32.dll' is defined - in the class.Instance of the class is created and the method is invoked. - To execute this program, make sure a file named 'MyFile.txt' should be there - in the current directory. -*/ -// -using namespace System; -using namespace System::Runtime::InteropServices; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::CompilerServices; -Type^ CreateType( AppDomain^ currentDomain ) -{ - // Create an assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "DynamicAssembly"; - AssemblyBuilder^ myAssembly = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in Dynamic Assembly. - ModuleBuilder^ myModuleBuilder = myAssembly->DefineDynamicModule( "MyModule", "MyModule.mod" ); - - // Define a public class named S"MyClass" in the assembly. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyClass", TypeAttributes::Public ); - TypeBuilder^ myTypeBuilder2 = myModuleBuilder->DefineType( "MyClass2", static_cast(TypeAttributes::Public | TypeAttributes::BeforeFieldInit | TypeAttributes::SequentialLayout | TypeAttributes::AnsiClass | TypeAttributes::Sealed) ); - FieldBuilder^ myFieldBuilder1 = myTypeBuilder2->DefineField( "myBytes1", Byte::typeid, FieldAttributes::Public ); - FieldBuilder^ myFieldBuilder2 = myTypeBuilder2->DefineField( "myBytes2", Byte::typeid, FieldAttributes::Public ); - FieldBuilder^ myFieldBuilder3 = myTypeBuilder2->DefineField( "myErrorCode", short::typeid, FieldAttributes::Public ); - FieldBuilder^ myFieldBuilder4 = myTypeBuilder2->DefineField( "myReserved1", short::typeid, FieldAttributes::Public ); - FieldBuilder^ myFieldBuilder5 = myTypeBuilder2->DefineField( "myReserved2", short::typeid, FieldAttributes::Public ); - FieldBuilder^ myFieldBuilder6 = myTypeBuilder2->DefineField( "myPathName", array::typeid,FieldAttributes::Public ); - myFieldBuilder6->SetMarshal( UnmanagedMarshal::DefineByValArray( 128 ) ); - myFieldBuilder6->SetOffset( 4 ); - Type^ myType1 = myTypeBuilder2->CreateType(); - - // Create the PInvoke method for 'OpenFile' method of 'Kernel32.dll'. - array^myParameters = {String::typeid,myType1,UInt32::typeid}; - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefinePInvokeMethod( "OpenFile", "kernel32.dll", static_cast(MethodAttributes::Public | MethodAttributes::Static | MethodAttributes::HideBySig), CallingConventions::Standard, IntPtr::typeid, myParameters, CallingConvention::Winapi, CharSet::None ); - Type^ myAttributeType = MethodImplAttribute::typeid; - array^type1 = {MethodImplOptions::typeid}; - ConstructorInfo^ myConstructorInfo = myAttributeType->GetConstructor( type1 ); - array^obj1 = {MethodImplOptions::PreserveSig}; - CustomAttributeBuilder^ myAttributeBuilder = gcnew CustomAttributeBuilder( myConstructorInfo,obj1 ); - myMethodBuilder->SetCustomAttribute( myAttributeBuilder ); - ParameterBuilder^ myParameterBuilder2 = myMethodBuilder->DefineParameter( 2, ParameterAttributes::Out, "myClass2" ); - Type^ myType = myTypeBuilder->CreateType(); - myAssembly->Save( "EmittedAssembly.dll" ); - return myType; -} - -int main() -{ - try - { - Type^ myType = CreateType( Thread::GetDomain() ); - Type^ myClass2 = myType->Module->GetType( "MyClass2" ); - Object^ myParam2 = Activator::CreateInstance( myClass2 ); - UInt32 myUint = 0x00000800; - array^myArgs = {"MyFile.Txt",myParam2,myUint}; - Object^ myObject = myType->InvokeMember( "OpenFile", static_cast(BindingFlags::Public | BindingFlags::InvokeMethod | BindingFlags::Static), nullptr, nullptr, myArgs ); - Console::WriteLine( "MyClass::OpenFile method returned: \"{0}\"", myObject ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo/CPP/fieldinfo.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo/CPP/fieldinfo.cpp deleted file mode 100644 index 58a29d2bc11..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo/CPP/fieldinfo.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class FieldInfoClass -{ -public: - int myField1; - -protected: - String^ myField2; -}; - -int main() -{ - array^myFieldInfo; - Type^ myType = FieldInfoClass::typeid; - - // Get the type and fields of FieldInfoClass. - myFieldInfo = myType->GetFields( static_cast(BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::Public) ); - Console::WriteLine( "\nThe fields of FieldInfoClass are \n" ); - - // Display the field information of FieldInfoClass. - for ( int i = 0; i < myFieldInfo->Length; i++ ) - { - Console::WriteLine( "\nName : {0}", myFieldInfo[ i ]->Name ); - Console::WriteLine( "Declaring Type : {0}", myFieldInfo[ i ]->DeclaringType ); - Console::WriteLine( "IsPublic : {0}", myFieldInfo[ i ]->IsPublic ); - Console::WriteLine( "MemberType : {0}", myFieldInfo[ i ]->MemberType ); - Console::WriteLine( "FieldType : {0}", myFieldInfo[ i ]->FieldType ); - Console::WriteLine( "IsFamily : {0}", myFieldInfo[ i ]->IsFamily ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_FieldHandle/CPP/fieldinfo_fieldhandle.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_FieldHandle/CPP/fieldinfo_fieldhandle.cpp deleted file mode 100644 index 8d70ea8d553..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_FieldHandle/CPP/fieldinfo_fieldhandle.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class MyClass -{ -public: - String^ MyField; -}; - -void DisplayFieldHandle( RuntimeFieldHandle myFieldHandle ) -{ - // Get the type from the handle. - FieldInfo^ myField = FieldInfo::GetFieldFromHandle( myFieldHandle ); - - // Display the type. - Console::WriteLine( "\nDisplaying the field from the handle.\n" ); - Console::WriteLine( "The type is {0}.", myField ); -} - -int main() -{ - MyClass^ myClass = gcnew MyClass; - - // Get the type of MyClass. - Type^ myType = MyClass::typeid; - try - { - // Get the field information of MyField. - FieldInfo^ myFieldInfo = myType->GetField( "MyField", static_cast(BindingFlags::Public | BindingFlags::Instance) ); - - // Determine whether or not the FieldInfo Object* is 0. - if ( myFieldInfo != nullptr ) - { - // Get the handle for the field. - RuntimeFieldHandle myFieldHandle = myFieldInfo->FieldHandle; - DisplayFieldHandle( myFieldHandle ); - } - else - { - Console::WriteLine( "The myFieldInfo Object* is 0." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/CPP/fieldinfo_getfieldfromhandle.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/CPP/fieldinfo_getfieldfromhandle.cpp deleted file mode 100644 index 558c1eaa9ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/CPP/fieldinfo_getfieldfromhandle.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class FieldInfo_GetFieldFromHandle -{ -public: - String^ x; - Char y; - float a; - int b; -}; - -int main() -{ - // Get the type of the FieldInfo_GetFieldFromHandle class. - Type^ myType = FieldInfo_GetFieldFromHandle::typeid; - - // Get the fields of the FieldInfo_GetFieldFromHandle class. - array^myFieldInfoArray = myType->GetFields(); - Console::WriteLine( "\nThe field information of the declared fields x, y, a, and b is:\n" ); - RuntimeFieldHandle myRuntimeFieldHandle; - for ( int i = 0; i < myFieldInfoArray->Length; i++ ) - { - // Get the RuntimeFieldHandle of myFieldInfoArray. - myRuntimeFieldHandle = myFieldInfoArray[ i ]->FieldHandle; - - // Call the GetFieldFromHandle method. - FieldInfo^ myFieldInfo = FieldInfo::GetFieldFromHandle( myRuntimeFieldHandle ); - - // Display the FieldInfo of myFieldInfo. - Console::WriteLine( " {0}", myFieldInfo ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetValue/CPP/fieldinfo_getvalue.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetValue/CPP/fieldinfo_getvalue.cpp deleted file mode 100644 index b4d9d357a06..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetValue/CPP/fieldinfo_getvalue.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class FieldsClass -{ - public: - String^ fieldA; - String^ fieldB; - - FieldsClass() - { - fieldA = "A public field"; - fieldB = "Another public field"; - } -}; - -int main() -{ - FieldsClass^ fieldsInst = gcnew FieldsClass; - - // Get the type of FieldsClass. - Type^ fieldsType = FieldsClass::typeid; - - // Get the FieldInfo of FieldsClass. - array^ fields = fieldsType->GetFields(static_cast(BindingFlags::Public | BindingFlags::Instance)); - - // Display the values of the fields. - Console::WriteLine("Displaying the values of the fields of {0}:", fieldsType); - for (int i = 0; i < fields->Length; i++) - { - Console::WriteLine(" {0}:\t'{1}'", - fields[i]->Name, fields[i]->GetValue(fieldsInst)); - } -} -// The example displays the following output: -// Displaying the values of the fields of FieldsClass: -// fieldA: 'A public field' -// fieldB: 'Another public field' -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsNotSerialized/CPP/fieldinfo_isnotserialized.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsNotSerialized/CPP/fieldinfo_isnotserialized.cpp deleted file mode 100644 index 49b86026b86..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsNotSerialized/CPP/fieldinfo_isnotserialized.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::Serialization; - -public ref class MyClass -{ -public: - short myShort; - - // The following field will not be serialized. - - [NonSerialized] - int myInt; -}; - -int main() -{ - // Get the type of MyClass. - Type^ myType = MyClass::typeid; - - // Get the fields of MyClass. - array^myFields = myType->GetFields( static_cast(BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::Static) ); - Console::WriteLine( "\nDisplaying whether or not the field is serializable.\n" ); - - // Display whether or not the field is serializable. - for ( int i = 0; i < myFields->Length; i++ ) - if ( myFields[ i ]->IsNotSerialized ) - Console::WriteLine( "The {0} field is not serializable.", myFields[ i ] ); - else - Console::WriteLine( "The {0} field is serializable.", myFields[ i ] ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/CPP/fieldinfo_ispinvokeimpl.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/CPP/fieldinfo_ispinvokeimpl.cpp deleted file mode 100644 index 5d8ebfb8a80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/CPP/fieldinfo_ispinvokeimpl.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class Fieldinfo_IsPinvoke -{ -public: - String^ myField; - Fieldinfo_IsPinvoke() - { - myField = "A public field"; - } -}; - -int main() -{ - Fieldinfo_IsPinvoke^ myObject = gcnew Fieldinfo_IsPinvoke; - - // Get the Type and FieldInfo. - Type^ myType1 = Fieldinfo_IsPinvoke::typeid; - FieldInfo^ myFieldInfo = myType1->GetField( "myField", static_cast(BindingFlags::Public | BindingFlags::Instance) ); - - // Display the name, field and the PInvokeImpl attribute for the field. - Console::Write( "\n Name of class: {0}", myType1->FullName ); - Console::Write( "\n Value of field: {0}", myFieldInfo->GetValue( myObject ) ); - Console::Write( "\n IsPinvokeImpl: {0}", myFieldInfo->IsPinvokeImpl ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPrivate/CPP/fieldinfo_isprivate.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPrivate/CPP/fieldinfo_isprivate.cpp deleted file mode 100644 index 19e2ca9f358..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPrivate/CPP/fieldinfo_isprivate.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -ref class MyClass -{ -private: - String^ myField; - -public: - array^myArray; - MyClass() - { - myField = "Microsoft"; - array^s = {"New York","New Jersey"}; - myArray = s; - } - - property String^ GetField - { - String^ get() - { - return myField; - } - } -}; - -int main() -{ - try - { - // Gets the type of MyClass. - Type^ myType = MyClass::typeid; - - // Gets the field information of MyClass. - array^myFields = myType->GetFields( static_cast(BindingFlags::NonPublic | BindingFlags::Public | BindingFlags::Instance) ); - Console::WriteLine( "\nDisplaying whether the fields of {0} are private or not:\n", myType ); - for ( int i = 0; i < myFields->Length; i++ ) - { - // Check whether the field is private or not. - if ( myFields[ i ]->IsPrivate ) - Console::WriteLine( " {0} is a private field.", myFields[ i ]->Name ); - else - Console::WriteLine( " {0} is not a private field.", myFields[ i ]->Name ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0} ", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsSpecialName/CPP/fieldinfo_isspecialname.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsSpecialName/CPP/fieldinfo_isspecialname.cpp deleted file mode 100644 index 0e31a95a459..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsSpecialName/CPP/fieldinfo_isspecialname.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::ComponentModel::Design; - -int main() -{ - try - { - // Get the type handle of a specified class. - Type^ myType = ViewTechnology::typeid; - - // Get the fields of the specified class. - array^myField = myType->GetFields(); - Console::WriteLine( "\nDisplaying fields that have SpecialName attributes:\n" ); - for ( int i = 0; i < myField->Length; i++ ) - { - // Determine whether or not each field is a special name. - if ( myField[ i ]->IsSpecialName ) - { - Console::WriteLine( "The field {0} has a SpecialName attribute.", myField[ i ]->Name ); - } - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0} ", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FieldInfo_SetValue/CPP/fieldinfo_setvalue.cpp b/snippets/cpp/VS_Snippets_CLR/FieldInfo_SetValue/CPP/fieldinfo_setvalue.cpp deleted file mode 100644 index 5ba37dacd8a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FieldInfo_SetValue/CPP/fieldinfo_setvalue.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Globalization; - -public ref class Example -{ -private: - String^ myString; - -public: - Example() - { - myString = "Old value"; - } - - property String^ StringProperty - { - String^ get() - { - return myString; - } - } -}; - -int main() -{ - Example^ myObject = gcnew Example; - Type^ myType = Example::typeid; - FieldInfo^ myFieldInfo = myType->GetField( "myString", - BindingFlags::NonPublic | BindingFlags::Instance); - - // Display the string before applying SetValue to the field. - Console::WriteLine( "\nThe field value of myString is \"{0}\".", - myFieldInfo->GetValue( myObject ) ); - // Display the SetValue signature used to set the value of a field. - Console::WriteLine( "Applying SetValue(Object, Object)." ); - - // Change the field value using the SetValue method. - myFieldInfo->SetValue( myObject, "New value" ); - // Display the string after applying SetValue to the field. - Console::WriteLine( "The field value of mystring is \"{0}\".", - myFieldInfo->GetValue(myObject)); -} -/* This code produces the following output: - -The field value of myString is "Old value". -Applying SetValue(Object, Object). -The field value of mystring is "New value". - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp deleted file mode 100644 index 9f909725077..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class GenericReflectionSample -{ -}; - -int main() -{ - // Creating a dynamic assembly requires an AssemblyName - // object, and the current application domain. - // - AssemblyName^ asmName = - gcnew AssemblyName("EmittedAssembly"); - AppDomain^ domain = AppDomain::CurrentDomain; - AssemblyBuilder^ sampleAssemblyBuilder = - domain->DefineDynamicAssembly(asmName, - AssemblyBuilderAccess::RunAndSave); - - // Define the module that contains the code. For an - // assembly with one module, the module name is the - // assembly name plus a file extension. - ModuleBuilder^ sampleModuleBuilder = - sampleAssemblyBuilder->DefineDynamicModule(asmName->Name, - asmName->Name + ".dll"); - - TypeBuilder^ sampleTypeBuilder = - sampleModuleBuilder->DefineType("SampleType", - TypeAttributes::Public | TypeAttributes::Abstract); - - // - // Define a Shared, Public method with standard calling - // conventions. Do not specify the parameter types or the - // return type, because type parameters will be used for - // those types, and the type parameters have not been - // defined yet. - MethodBuilder^ sampleMethodBuilder = - sampleTypeBuilder->DefineMethod("SampleMethod", - MethodAttributes::Public | MethodAttributes::Static); - // - - // - // Defining generic parameters for the method makes it a - // generic method. By convention, type parameters are - // single alphabetic characters. T and U are used here. - // - array^ genericTypeNames = {"T", "U"}; - array^ genericTypes = - sampleMethodBuilder->DefineGenericParameters( - genericTypeNames); - // - - // - // Use the IsGenericMethod property to find out if a - // dynamic method is generic, and IsGenericMethodDefinition - // to find out if it defines a generic method. - Console::WriteLine("Is SampleMethod generic? {0}", - sampleMethodBuilder->IsGenericMethod); - Console::WriteLine( - "Is SampleMethod a generic method definition? {0}", - sampleMethodBuilder->IsGenericMethodDefinition); - // - - // - // Set parameter types for the method. The method takes - // one parameter, and its type is specified by the first - // type parameter, T. - array^ parameterTypes = {genericTypes[0]}; - sampleMethodBuilder->SetParameters(parameterTypes); - - // Set the return type for the method. The return type is - // specified by the second type parameter, U. - sampleMethodBuilder->SetReturnType(genericTypes[1]); - // - - // Generate a code body for the method. The method doesn't - // do anything except return null. - // - ILGenerator^ ilgen = sampleMethodBuilder->GetILGenerator(); - ilgen->Emit(OpCodes::Ldnull); - ilgen->Emit(OpCodes::Ret); - - // - // Complete the type. - Type^ sampleType = sampleTypeBuilder->CreateType(); - - // To bind types to a dynamic generic method, you must - // first call the GetMethod method on the completed type. - // You can then define an array of types, and bind them - // to the method. - MethodInfo^ sampleMethodInfo = sampleType->GetMethod("SampleMethod"); - array^ boundParameters = - {String::typeid, GenericReflectionSample::typeid}; - MethodInfo^ boundMethodInfo = - sampleMethodInfo->MakeGenericMethod(boundParameters); - // Display a string representing the bound method. - Console::WriteLine(boundMethodInfo); - // - - // Save the assembly, so it can be examined with Ildasm.exe. - sampleAssemblyBuilder->Save(asmName->Name + ".dll"); -} - -/* This code example produces the following output: -Is SampleMethod generic? True -Is SampleMethod a generic method definition? True -GenericReflectionSample SampleMethod[String,GenericReflectionSample](System.String) -*/ -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR/GetFldVal/CPP/getfldval.cpp b/snippets/cpp/VS_Snippets_CLR/GetFldVal/CPP/getfldval.cpp deleted file mode 100644 index 4fd14cbab59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/GetFldVal/CPP/getfldval.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -ref class Example -{ - public: - static String^ val = "test"; -}; - -int main() -{ - FieldInfo^ fld = Example::typeid->GetField( "val" ); - Console::WriteLine(fld->GetValue(nullptr) ); - Example::val = "hi"; - Console::WriteLine(fld->GetValue(nullptr) ); -} -// The example displays the following output: -// test -// hi -// diff --git a/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/CPP/ilgenerator_beginfaultblock.cpp b/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/CPP/ilgenerator_beginfaultblock.cpp deleted file mode 100644 index 59545a35ced..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/CPP/ilgenerator_beginfaultblock.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -// System.Reflection.Emit.ILGenerator.BeginFaultBlock() -/* -The following program demonstrates the 'BeginFaultBlock()' method of 'ILGenerator' -class. Exception is raised by passing two integer values which are out of range, -the same is caught in the 'BeginExceptionBlock' which is non-filtered. First it -checks for the exception thrown in the 'BeginFaultBlock' and then emits the MSIL -instructions in 'BeginExceptFilterBlock'. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -Type^ AddType() -{ - // Create an assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "AdderExceptionAsm"; - - // Create dynamic assembly. - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyBuilder^ myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "AdderExceptionMod" ); - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "Adder" ); - array^myAdderParams = {int::typeid,int::typeid}; - - // Method to add two numbers. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "DoAdd", static_cast(MethodAttributes::Public | MethodAttributes::Static), int::typeid, myAdderParams ); - ILGenerator^ myAdderIL = myMethodBuilder->GetILGenerator(); - - // Create constructor. - array^temp0 = {String::typeid}; - ConstructorInfo^ myConstructorInfo = OverflowException::typeid->GetConstructor( temp0 ); - MethodInfo^ myExToStrMI = OverflowException::typeid->GetMethod( "ToString" ); - array^temp1 = {String::typeid,Object::typeid}; - MethodInfo^ myWriteLineMI = Console::typeid->GetMethod( "WriteLine", temp1 ); - - // Declare local variable. - LocalBuilder^ myLocalBuilder1 = myAdderIL->DeclareLocal( int::typeid ); - LocalBuilder^ myLocalBuilder2 = myAdderIL->DeclareLocal( OverflowException::typeid ); - - // Define label. - Label myFailedLabel = myAdderIL->DefineLabel(); - Label myEndOfMethodLabel = myAdderIL->DefineLabel(); - - // Begin exception block. - Label myLabel = myAdderIL->BeginExceptionBlock(); - myAdderIL->Emit( OpCodes::Ldarg_0 ); - myAdderIL->Emit( OpCodes::Ldc_I4_S, 10 ); - myAdderIL->Emit( OpCodes::Bgt_S, myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldarg_1 ); - myAdderIL->Emit( OpCodes::Ldc_I4_S, 10 ); - myAdderIL->Emit( OpCodes::Bgt_S, myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldarg_0 ); - myAdderIL->Emit( OpCodes::Ldarg_1 ); - myAdderIL->Emit( OpCodes::Add_Ovf_Un ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder1 ); - myAdderIL->Emit( OpCodes::Br_S, myEndOfMethodLabel ); - myAdderIL->MarkLabel( myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldstr, "Cannot accept values over 10 for addition." ); - myAdderIL->Emit( OpCodes::Newobj, myConstructorInfo ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder2 ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder2 ); - - // Call fault block. - myAdderIL->BeginFaultBlock(); - Console::WriteLine( "Fault block called." ); - - //Throw exception. - myAdderIL->ThrowException( NotSupportedException::typeid ); - - // Call finally block. - myAdderIL->BeginFinallyBlock(); - myAdderIL->Emit( OpCodes::Ldstr, "{0}" ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder2 ); - myAdderIL->EmitCall( OpCodes::Callvirt, myExToStrMI, nullptr ); - myAdderIL->EmitCall( OpCodes::Call, myWriteLineMI, nullptr ); - myAdderIL->Emit( OpCodes::Ldc_I4_M1 ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder1 ); - - // End exception block. - myAdderIL->EndExceptionBlock(); - myAdderIL->MarkLabel( myEndOfMethodLabel ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder1 ); - myAdderIL->Emit( OpCodes::Ret ); - return myTypeBuilder->CreateType(); -} - -int main() -{ - Type^ myAddType = AddType(); - Object^ myObject1 = Activator::CreateInstance( myAddType ); - array^myObject2 = {11,12}; - - // Invoke member. - myAddType->InvokeMember( "DoAdd", BindingFlags::InvokeMethod, nullptr, myObject1, myObject2 ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/CPP/ILGenerator_BeginFinallyBlock_2.cpp b/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/CPP/ILGenerator_BeginFinallyBlock_2.cpp deleted file mode 100644 index bc0c0c8e893..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/CPP/ILGenerator_BeginFinallyBlock_2.cpp +++ /dev/null @@ -1,114 +0,0 @@ - -// System::Reflection::Emit::ILGenerator.BeginExceptFilterBlock() -// System::Reflection::Emit::ILGenerator.BeginFinallyBlock() -/* - The following program demonstrates the 'BeginExceptFilterBlock()' method and - 'BeginFinallyBlock()' of 'ILGenerator' class. Exception is raised by passing - two integer values which are out of range, the same is caught in the - 'BeginExceptionBlock' which is non-filtered and then emits the MSIL - instructions in 'BeginExceptFilterBlock' and 'BeginFinallyBlock'. -*/ -// -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class ILGenerator_BeginFinallyBlock -{ -public: - static Type^ AddType() - { - // Create an assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "AdderExceptionAsm"; - - // Create dynamic assembly. - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyBuilder^ myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "AdderExceptionMod" ); - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "Adder" ); - array^adderParams = {int::typeid,int::typeid}; - - // Define method to add two numbers. - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "DoAdd", static_cast(MethodAttributes::Public | MethodAttributes::Static), int::typeid, adderParams ); - ILGenerator^ myAdderIL = myMethodBuilder->GetILGenerator(); - - // Create constructor. - array^type1 = {String::typeid}; - ConstructorInfo^ myConstructorInfo = OverflowException::typeid->GetConstructor( type1 ); - MethodInfo^ myExToStrMI = OverflowException::typeid->GetMethod( "ToString" ); - array^type2 = {String::typeid,Object::typeid}; - MethodInfo^ myWriteLineMI = Console::typeid->GetMethod( "WriteLine", type2 ); - - // Declare local variable. - LocalBuilder^ myLocalBuilder1 = myAdderIL->DeclareLocal( int::typeid ); - LocalBuilder^ myLocalBuilder2 = myAdderIL->DeclareLocal( OverflowException::typeid ); - - // Define label. - Label myFailedLabel = myAdderIL->DefineLabel(); - Label myEndOfMethodLabel = myAdderIL->DefineLabel(); - - // Begin exception block. - Label myLabel = myAdderIL->BeginExceptionBlock(); - myAdderIL->Emit( OpCodes::Ldarg_0 ); - myAdderIL->Emit( OpCodes::Ldc_I4_S, 10 ); - myAdderIL->Emit( OpCodes::Bgt_S, myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldarg_1 ); - myAdderIL->Emit( OpCodes::Ldc_I4_S, 10 ); - myAdderIL->Emit( OpCodes::Bgt_S, myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldarg_0 ); - myAdderIL->Emit( OpCodes::Ldarg_1 ); - myAdderIL->Emit( OpCodes::Add_Ovf_Un ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder1 ); - myAdderIL->Emit( OpCodes::Br_S, myEndOfMethodLabel ); - myAdderIL->MarkLabel( myFailedLabel ); - myAdderIL->Emit( OpCodes::Ldstr, "Cannot accept values over 10 for add." ); - myAdderIL->Emit( OpCodes::Newobj, myConstructorInfo ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder2 ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder2 ); - - // Throw the exception. - myAdderIL->ThrowException( OverflowException::typeid ); - - // Call 'BeginExceptFilterBlock'. - myAdderIL->BeginExceptFilterBlock(); - myAdderIL->EmitWriteLine( "Except filter block called." ); - - // Call catch block. - myAdderIL->BeginCatchBlock( nullptr ); - - // Call other catch block. - myAdderIL->BeginCatchBlock( OverflowException::typeid ); - myAdderIL->Emit( OpCodes::Ldstr, "{0}" ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder2 ); - myAdderIL->EmitCall( OpCodes::Callvirt, myExToStrMI, nullptr ); - myAdderIL->EmitCall( OpCodes::Call, myWriteLineMI, nullptr ); - myAdderIL->Emit( OpCodes::Ldc_I4_M1 ); - myAdderIL->Emit( OpCodes::Stloc_S, myLocalBuilder1 ); - - // Call finally block. - myAdderIL->BeginFinallyBlock(); - myAdderIL->EmitWriteLine( "Finally block called." ); - - // End the exception block. - myAdderIL->EndExceptionBlock(); - myAdderIL->MarkLabel( myEndOfMethodLabel ); - myAdderIL->Emit( OpCodes::Ldloc_S, myLocalBuilder1 ); - myAdderIL->Emit( OpCodes::Ret ); - return myTypeBuilder->CreateType(); - } -}; - -int main() -{ - Type^ myAddType = ILGenerator_BeginFinallyBlock::AddType(); - Object^ myObject1 = Activator::CreateInstance( myAddType ); - array^myObject2 = {15,15}; - myAddType->InvokeMember( "DoAdd", BindingFlags::InvokeMethod, nullptr, myObject1, myObject2 ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp b/snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp deleted file mode 100644 index 125264cb896..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp +++ /dev/null @@ -1,97 +0,0 @@ - -// System.Reflection.Emit.ILGenerator -// System.Reflection.Emit.ILGenerator.BeginScope() -// System.Reflection.Emit.ILGenerator.EndScope() -/* -This program demonstrates the 'BeginScope()', 'EndScope()' methods and the class -'ILGenerator'. A dynamic class 'myTypeBuilder' is created in which a -constructor 'myConstructor' and a method 'myMethod' are created dynamically. Their IL's -are generated. A local variable 'myLocalBuilder' is declared using 'DeclareLocal' property -of 'myMethodIL'. The scope of 'myLocalBuilder' is specified using 'BeginScope' and -'EndScope' methods. Respective messages related to scope are printed on the console. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -int main() -{ - try - { - // - // - // Get the current AppDomain. - AppDomain^ myAppDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "SampleAssembly"; - - // Create a dynamic assembly 'myAssembly' with access mode 'Run'. - AssemblyBuilder^ myAssembly = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module 'myModule' in 'myAssembly'. - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "MyDynamicModule", true ); - - // Define a public class 'MyDynamicClass'. - TypeBuilder^ myTypeBuilder = myModule->DefineType( "MyDynamicClass", TypeAttributes::Public ); - - // Define a public string field. - FieldBuilder^ myField = myTypeBuilder->DefineField( "MyDynamicField", String::typeid, FieldAttributes::Public ); - - // Create the constructor. - array^myConstructorArgs = {String::typeid}; - ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs ); - - // Generate IL for 'myConstructor'. - ILGenerator^ myConstructorIL = myConstructor->GetILGenerator(); - - // Emit the necessary opcodes. - myConstructorIL->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ mySuperConstructor = Object::typeid->GetConstructor( gcnew array(0) ); - myConstructorIL->Emit( OpCodes::Call, mySuperConstructor ); - myConstructorIL->Emit( OpCodes::Ldarg_0 ); - myConstructorIL->Emit( OpCodes::Ldarg_1 ); - myConstructorIL->Emit( OpCodes::Stfld, myField ); - myConstructorIL->Emit( OpCodes::Ret ); - - // Define a dynamic method named 'MyDynamicMethod'. - MethodBuilder^ myMethod = myTypeBuilder->DefineMethod( "MyDynamicMethod", MethodAttributes::Public, String::typeid, nullptr ); - - // Generate IL for 'myMethod'. - ILGenerator^ myMethodIL = myMethod->GetILGenerator(); - - // Begin the scope for a local variable. - myMethodIL->BeginScope(); - LocalBuilder^ myLocalBuilder = myMethodIL->DeclareLocal( int::typeid ); - Console::WriteLine( "\nTrying to access the local variable within the scope." ); - Console::WriteLine( "'myLocalBuilder' type is :{0}", myLocalBuilder->LocalType ); - myMethodIL->Emit( OpCodes::Ldstr, "Local value" ); - myMethodIL->Emit( OpCodes::Stloc_0, myLocalBuilder ); - - // End the scope of 'myLocalBuilder'. - myMethodIL->EndScope(); - - // Access the local variable outside the scope. - Console::WriteLine( "\nTrying to access the local variable outside the scope:\n" ); - myMethodIL->Emit( OpCodes::Stloc_0, myLocalBuilder ); - myMethodIL->Emit( OpCodes::Ldloc_0 ); - myMethodIL->Emit( OpCodes::Ret ); - - // Create 'MyDynamicClass' class. - Type^ myType1 = myTypeBuilder->CreateType(); - // - // - - // Create an instance of the 'MyDynamicClass'. - array^temp0 = {"HelloWorld"}; - Object^ myObject1 = Activator::CreateInstance( myType1, temp0 ); - - // Invoke 'MyDynamicMethod' method of 'MyDynamicClass'. - Object^ myObject2 = myType1->InvokeMember( "MyDynamicMethod", BindingFlags::InvokeMethod, nullptr, myObject1, nullptr ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception :{0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp b/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp deleted file mode 100644 index 4c29bcd1705..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp +++ /dev/null @@ -1,120 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::ComponentModel; -using namespace System::IO; -using namespace System::Windows::Forms; -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::Windows::Forms::TextBox^ textBox1; - - // - String^ CreateMultilevelIndentString() - { - - // - // Creates a TextWriter to use as the base output writer. - System::IO::StringWriter^ baseTextWriter = gcnew System::IO::StringWriter; - - // Create an IndentedTextWriter and set the tab string to use - // as the indentation string for each indentation level. - System::CodeDom::Compiler::IndentedTextWriter^ indentWriter = gcnew IndentedTextWriter( baseTextWriter," " ); - - // - // - // Sets the indentation level. - indentWriter->Indent = 0; - - // - // Output test strings at stepped indentations through a recursive loop method. - WriteLevel( indentWriter, 0, 5 ); - - // Return the resulting string from the base StringWriter. - return baseTextWriter->ToString(); - } - - - // - void WriteLevel( IndentedTextWriter^ indentWriter, int level, int totalLevels ) - { - - // Output a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - - // If not yet at the highest recursion level, call this output method for the next level of indentation. - if ( level < totalLevels ) - { - - // Increase the indentation count for the next level of indented output. - indentWriter->Indent++; - - // Call the WriteLevel method to write test output for the next level of indentation. - WriteLevel( indentWriter, level + 1, totalLevels ); - - // Restores the indentation count for this level after the recursive branch method has returned. - indentWriter->Indent--; - } - else - // - // Outputs a string using the WriteLineNoTabs method. - indentWriter->WriteLineNoTabs( "This is a test phrase written with the IndentTextWriter.WriteLineNoTabs method." ); - // - // Outputs a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - } - - - // - // - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - textBox1->Text = CreateMultilevelIndentString(); - } - - -public: - Form1() - { - System::Windows::Forms::Button^ button1 = gcnew System::Windows::Forms::Button; - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->SuspendLayout(); - this->textBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left | System::Windows::Forms::AnchorStyles::Right); - this->textBox1->Location = System::Drawing::Point( 8, 40 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 391, 242 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - button1->Location = System::Drawing::Point( 11, 8 ); - button1->Name = "button1"; - button1->Size = System::Drawing::Size( 229, 23 ); - button1->TabIndex = 1; - button1->Text = "Generate string using IndentedTextWriter"; - button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 407, 287 ); - this->Controls->Add( button1 ); - this->Controls->Add( this->textBox1 ); - this->Name = "Form1"; - this->Text = "IndentedTextWriter example"; - this->ResumeLayout( false ); - } - -}; - - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp b/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp deleted file mode 100644 index 75e16a96906..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -// System.Reflection.Emit.LocalBuilder -// System.Reflection.Emit.ILGenerator.DeclareLocal(Type) -// System.Reflection.Emit.LocalBuilder.SetLocalSymInfo(String) -// System.Reflection.Emit.LocalBuilder.LocalType() -// System.Reflection.Emit.LocalBuilder.SetLocalSymInfo(String, Int32, Int32) -/* - -This program demonstrates 'LocalType' property, 'SetLocalSymInfo(String)', -'SetLocalSymInfo(String, Int32,Int32)' methods, class level for 'LocalBuilder' and -'DeclareLocal(Type)' method of ILGenerator class. An assembly 'myClass' is created using -AssemblyBuilder, ModuleBuilder, FieldBuilder, TypeBuilder, ConstructorBuilder classes. -Localbuilder class is used to create local variables of the specified type. - -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Threading; -int main() -{ - // Create an assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "SampleAssembly"; - AssemblyBuilder^ myAssembly = Thread::GetDomain()->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a module. For a single-file assembly the module - // name is usually the same as the assembly name. - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( - myAssemblyName->Name, myAssemblyName->Name + ".dll", true ); - - // Define a public class 'Example'. - TypeBuilder^ myTypeBuilder = myModule->DefineType( "Example", TypeAttributes::Public ); - - // Create the 'Function1' public method, which takes an integer - // and returns a string. - MethodBuilder^ myMethod = myTypeBuilder->DefineMethod( "Function1", - MethodAttributes::Public | MethodAttributes::Static, String::typeid, - gcnew array { int::typeid } ); - - // Generate IL for 'Function1'. The function body demonstrates - // assigning an argument to a local variable, assigning a - // constant string to a local variable, and putting the contents - // of local variables on the stack. - ILGenerator^ myMethodIL = myMethod->GetILGenerator(); - - // - // Create local variables named myString and myInt. - LocalBuilder^ myLB1 = myMethodIL->DeclareLocal( String::typeid ); - myLB1->SetLocalSymInfo( "myString" ); - Console::WriteLine( "local 'myString' type is: {0}", myLB1->LocalType ); - - LocalBuilder^ myLB2 = myMethodIL->DeclareLocal( int::typeid ); - myLB2->SetLocalSymInfo( "myInt", 1, 2 ); - Console::WriteLine( "local 'myInt' type is: {0}", myLB2->LocalType ); - // - - // Store the function argument in myInt. - myMethodIL->Emit( OpCodes::Ldarg_0 ); - myMethodIL->Emit( OpCodes::Stloc_1 ); - - // Store a literal value in myString, and return the value. - myMethodIL->Emit( OpCodes::Ldstr, "string value" ); - myMethodIL->Emit( OpCodes::Stloc_0 ); - myMethodIL->Emit( OpCodes::Ldloc_0 ); - myMethodIL->Emit( OpCodes::Ret ); - - // Create "Example" class. - Type^ myType1 = myTypeBuilder->CreateType(); - Console::WriteLine( "'Example' is created." ); - - myAssembly->Save(myAssemblyName->Name + ".dll"); - Console::WriteLine( "'{0}' is created.", myAssemblyName->Name + ".dll" ); - - // Invoke 'Function1' method of 'Example', passing the value 42. - Object^ myObject2 = myType1->InvokeMember( "Function1", - BindingFlags::InvokeMethod, nullptr, nullptr, - gcnew array { 42 } ); - - Console::WriteLine( "Example::Function1 returned: {0}", myObject2 ); -} -/* This code example produces the following output: - -local 'myString' type is: System.String -local 'myInt' type is: System.Int32 -'Example' is created. -'SampleAssembly.dll' is created. -Example::Function1 returned: string value - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp deleted file mode 100644 index e978a2ab18b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -int main() -{ - // Define a dynamic assembly to contain the sample type. The - // assembly will not be run, but only saved to disk, so - // AssemblyBuilderAccess.Save is specified. - // - AppDomain^ appDomain = AppDomain::CurrentDomain; - AssemblyName^ assemblyName = gcnew - AssemblyName("MakeXxxGenericTypeParameterExample"); - AssemblyBuilder^ assemblyBuilder = appDomain->DefineDynamicAssembly - (assemblyName, AssemblyBuilderAccess::Save); - - // An assembly is made up of executable modules. For a single - // module assembly, the module name and file name are the - // same as the assembly name. - ModuleBuilder^ moduleBuilder = assemblyBuilder->DefineDynamicModule - (assemblyName->Name, assemblyName->Name + ".dll"); - - // Define the sample type. - TypeBuilder^ typeBuilder = moduleBuilder->DefineType("Sample", - TypeAttributes::Public | TypeAttributes::Abstract); - - // Make the sample type a generic type, by defining a type - // parameter T. All type parameters are defined at the same - // time, by passing an array containing the type parameter - // names. - array^ typeParamNames = {"T"}; - array^ typeParams = - typeBuilder->DefineGenericParameters(typeParamNames); - - // Define a method that takes a ByRef argument of type T, a - // pointer to type T, and one-dimensional array of type T. - // The method returns a two-dimensional array of type T. - // - // To create this method, you need Type objects that repre- - // sent the parameter types and the return type. Use the - // MakeByRefType, MakePointerType, and MakeArrayType methods - // to create the Type objects, using the generic type para- - // meter T. - // - Type^ byRefType = typeParams[0]->MakeByRefType(); - Type^ pointerType = typeParams[0]->MakePointerType(); - Type^ arrayType = typeParams[0]->MakeArrayType(); - Type^ twoDimArrayType = typeParams[0]->MakeArrayType(2); - - // Create the array of parameter types. - array^ parameterTypes = {byRefType, pointerType, arrayType}; - - // Define the abstract Test method. After you have compiled - // and run this example code, you can use ildasm.exe to open - // MakeXxxGenericTypeParameterExample.dll, examine the Sample - // type, and verify the parameter types and return type of - // the TestMethod method. - // - MethodBuilder^ methodBuilder = typeBuilder->DefineMethod("TestMethod", - MethodAttributes::Abstract | MethodAttributes::Virtual - | MethodAttributes::Public, twoDimArrayType, parameterTypes); - - // Create the type and save the assembly. For a single-file - // assembly, there is only one module to store the manifest - // information in. - // - typeBuilder->CreateType(); - assemblyBuilder->Save(assemblyName->Name + ".dll"); -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/CPP/memberinfo_getcustomattribute_isdefined.cpp b/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/CPP/memberinfo_getcustomattribute_isdefined.cpp deleted file mode 100644 index 3586a67f36a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/CPP/memberinfo_getcustomattribute_isdefined.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Define a custom attribute with one named parameter. - -[AttributeUsage(AttributeTargets::All)] -public ref class MyAttribute: public Attribute -{ -private: - String^ myName; - -public: - MyAttribute( String^ name ) - { - myName = name; - } - - property String^ Name - { - String^ get() - { - return myName; - } - } -}; - -// Define a class that has the custom attribute associated with one of its members. -public ref class MyClass1 -{ -public: - - [MyAttribute("This is an example attribute.")] - void MyMethod( int i ){} -}; - -int main() -{ - try - { - // Get the type of MyClass1. - Type^ myType = MyClass1::typeid; - - // Get the members associated with MyClass1. - array^myMembers = myType->GetMembers(); - - // Display the attributes for each of the members of MyClass1. - for ( int i = 0; i < myMembers->Length; i++ ) - { - // Display the attribute if it is of type MyAttribute. - if ( myMembers[ i ]->IsDefined( MyAttribute::typeid, false ) ) - { - array^myAttributes = myMembers[ i ]->GetCustomAttributes( MyAttribute::typeid, false ); - Console::WriteLine( "\nThe attributes of type MyAttribute for the member {0} are: \n", myMembers[ i ] ); - for ( int j = 0; j < myAttributes->Length; j++ ) - - // Display the value associated with the attribute. - Console::WriteLine( "The value of the attribute is : \"{0}\"", - (safe_cast(myAttributes[ j ]))->Name ); - } - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/CPP/memberinfo_getcustomattributes1.cpp b/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/CPP/memberinfo_getcustomattributes1.cpp deleted file mode 100644 index 6153b2ffb03..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/CPP/memberinfo_getcustomattributes1.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Define a custom attribute with one named parameter. - -[AttributeUsage(AttributeTargets::All)] -public ref class MyAttribute: public Attribute -{ -private: - String^ myName; - -public: - MyAttribute( String^ name ) - { - myName = name; - } - - property String^ Name - { - String^ get() - { - return myName; - } - } -}; - -// Define a class that has the custom attribute associated with one of its members. -public ref class MyClass1 -{ -public: - - [MyAttribute("This is an example attribute.")] - void MyMethod( int i ) - { - return; - } -}; - -int main() -{ - try - { - // Get the type of MyClass1. - Type^ myType = MyClass1::typeid; - - // Get the members associated with MyClass1. - array^myMembers = myType->GetMembers(); - - // Display the attributes for each of the members of MyClass1. - for ( int i = 0; i < myMembers->Length; i++ ) - { - array^myAttributes = myMembers[ i ]->GetCustomAttributes( true ); - if ( myAttributes->Length > 0 ) - { - Console::WriteLine( "\nThe attributes for the member {0} are: \n", myMembers[ i ] ); - for ( int j = 0; j < myAttributes->Length; j++ ) - Console::WriteLine( "The type of the attribute is {0}.", myAttributes[ j ] ); - } - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp deleted file mode 100644 index 44d2576e6eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// 1 - (entire sample) MethodBody class -// 2 - (everything through GetMethodBody and displaying InitLocals & MaxStackSize) -// 3 - (displaying locals) -// 4 - (displaying exception clauses) -// 5 - (end of Main, example method, beginning of output through output for snippet 2) -// 6 - (output for snippet 3 (locals)) -// 7 - (output for snippet 4 (clauses)) -// 2,5 - InitLocals, MaxStackSize -// 2,3,5,6 - lvis property, lviInfo class -// 2,4,5,7 - ExceptionHandlingClauses property, ExceptionHandlingClause class, ExceptionHandlingClauseFlags enum -// -// -// -#using - -using namespace System; -using namespace System::Reflection; - -public ref class Example -{ - // - // The Main method contains code to analyze this method, using - // the properties and methods of the MethodBody class. -public: - void MethodBodyExample(Object^ arg) - { - // Define some local variables. In addition to these variables, - // the local variable list includes the variables scoped to - // the catch clauses. - int var1 = 42; - String^ var2 = "Forty-two"; - - try - { - // Depending on the input value, throw an ArgumentException or - // an ArgumentNullException to test the Catch clauses. - if (arg == nullptr) - { - throw gcnew ArgumentNullException("The argument cannot " + - "be null."); - } - if (arg->GetType() == String::typeid) - { - throw gcnew ArgumentException("The argument cannot " + - "be a string."); - } - } - - // There is no Filter clause in this code example. See the Visual - // Basic code for an example of a Filter clause. - - // This catch clause handles the ArgumentException class, and - // any other class derived from Exception. - catch (ArgumentException^ ex) - { - Console::WriteLine("Ordinary exception-handling clause caught:" + - " {0}", ex->GetType()); - } - finally - { - var1 = 3033; - var2 = "Another string."; - } - } - // -}; - -int main() -{ - // Get method body information. - MethodInfo^ mi = - Example::typeid->GetMethod("MethodBodyExample"); - - MethodBody^ mb = mi->GetMethodBody(); - Console::WriteLine("\r\nMethod: {0}", mi); - - // Display the general information included in the - // MethodBody object. - Console::WriteLine(" Local variables are initialized: {0}", - mb->InitLocals); - Console::WriteLine(" Maximum number of items on the operand " + - "stack: {0}", mb->MaxStackSize); - // - // - - // Display information about the local variables in the - // method body. - Console::WriteLine(); - for each (LocalVariableInfo^ lvi in mb->LocalVariables) - { - Console::WriteLine("Local variable: {0}", lvi); - } - // - // - - // Display exception handling clauses. - Console::WriteLine(); - for each(ExceptionHandlingClause^ exhc in mb->ExceptionHandlingClauses) - { - Console::WriteLine(exhc->Flags.ToString()); - - // The FilterOffset property is meaningful only for Filter - // clauses. The CatchType property is not meaningful for - // Filter or Finally clauses. - switch(exhc->Flags) - { - case ExceptionHandlingClauseOptions::Filter: - Console::WriteLine(" Filter Offset: {0}", - exhc->FilterOffset); - break; - case ExceptionHandlingClauseOptions::Finally: - break; - default: - Console::WriteLine(" Type of exception: {0}", - exhc->CatchType); - break; - } - - Console::WriteLine(" Handler Length: {0}", - exhc->HandlerLength); - Console::WriteLine(" Handler Offset: {0}", - exhc->HandlerOffset); - Console::WriteLine(" Try Block Length: {0}", exhc->TryLength); - Console::WriteLine(" Try Block Offset: {0}", exhc->TryOffset); - } - // -} - -//This code example produces output similar to the following: -// -//Method: Void MethodBodyExample(System.Object) -// Local variables are initialized: False -// Maximum number of items on the operand stack: 4 -// -// -//Local variable: System.ArgumentException (0) -//Local variable: System.String (1) -//Local variable: System.Int32 (2) -// -// -//Clause -// Type of exception: System.ArgumentException -// Handler Length: 29 -// Handler Offset: 78 -// Try Block Length: 65 -// Try Block Offset: 13 -//Finally -// Handler Length: 13 -// Handler Offset: 113 -// Try Block Length: 100 -// Try Block Offset: 13 -// -// - - - - diff --git a/snippets/cpp/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/cpp/source.cpp deleted file mode 100644 index 546d0961119..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/cpp/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -void main() -{ - // Define a transient dynamic assembly (only to run, not - // to save) with one module and a type "Test". - // - AssemblyName^ aName = gcnew AssemblyName("MyDynamic"); - AssemblyBuilder^ ab = - AppDomain::CurrentDomain->DefineDynamicAssembly( - aName, - AssemblyBuilderAccess::Run); - ModuleBuilder^ mb = ab->DefineDynamicModule(aName->Name); - TypeBuilder^ tb = mb->DefineType("Test"); - - // Add a public static method "M" to Test, and make it a - // generic method with one type parameter named "T"). - // - MethodBuilder^ meb = tb->DefineMethod("M", - MethodAttributes::Public | MethodAttributes::Static); - array^ typeParams = - meb->DefineGenericParameters(gcnew array { "T" }); - - // Give the method one parameter, of type T, and a - // return type of T. - meb->SetParameters(typeParams); - meb->SetReturnType(typeParams[0]); - - // Create a MethodInfo for M, which can be used in - // emitted code. This is possible even though the method - // does not yet have a body, and the enclosing type is not - // created. - MethodInfo^ mi = meb->MakeGenericMethod(String::typeid); - // Note that this is actually a subclass of MethodInfo, - // which has rather limited capabilities -- for - // example, you cannot reflect on its parameters. -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/MethodBuilderClass_TypeSample/CPP/methodbuilderclass.cpp b/snippets/cpp/VS_Snippets_CLR/MethodBuilderClass_TypeSample/CPP/methodbuilderclass.cpp deleted file mode 100644 index f43a09ff0c7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MethodBuilderClass_TypeSample/CPP/methodbuilderclass.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// System.Reflection.Emit.MethodBuilder -/* -This program demonstrates 'MethodBuilder' class. A dynamic class 'myTypeBuilder' -is created in which a constructor 'myConstructorBuilder' and a method 'myMethodBuilder' -are created dynamically. Their IL's are generated. The Non-Public methods of the class -are printed on the console. The attributes and signature of 'MyDynamicMethod' are displayed -on the console using 'Attributes' and 'Signature' properties of the 'MethodBuilder' class. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -int main() -{ - try - { - // Get the current AppDomain. - AppDomain^ myAppDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "MyDynamicAssembly"; - - // Create the dynamic assembly and set its access mode to 'Save'. - AssemblyBuilder^ myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Save ); - - // Create a dynamic module 'myModuleBuilder'. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyDynamicModule", true ); - - // Define a public class 'MyDynamicClass'. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyDynamicClass", TypeAttributes::Public ); - - // Define a public string field named 'myField'. - FieldBuilder^ myField = myTypeBuilder->DefineField( "MyDynamicField", String::typeid, FieldAttributes::Public ); - - // Define the dynamic method 'MyDynamicMethod'. - array^temp0 = gcnew array(0); - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "MyDynamicMethod", MethodAttributes::Private, int::typeid, temp0 ); - - // Generate the IL for 'myMethodBuilder'. - ILGenerator^ myMethodIL = myMethodBuilder->GetILGenerator(); - - // Emit the necessary opcodes. - myMethodIL->Emit( OpCodes::Ldarg_0 ); - myMethodIL->Emit( OpCodes::Ldfld, myField ); - myMethodIL->Emit( OpCodes::Ret ); - - // Create 'myTypeBuilder' class. - Type^ myType1 = myTypeBuilder->CreateType(); - - // Get the method information of 'myTypeBuilder'. - array^myInfo = myType1->GetMethods( static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - - // Print non-public methods present of 'myType1'. - Console::WriteLine( "\nThe Non-Public methods present in 'myType1' are:\n" ); - for ( int i = 0; i < myInfo->Length; i++ ) - { - Console::WriteLine( myInfo[ i ]->Name ); - } - Console::WriteLine( "\nThe Attribute of 'MyDynamicMethod' is :{0}", myMethodBuilder->Attributes ); - Console::WriteLine( "\nThe Signature of 'MyDynamicMethod' is : \n{0}", myMethodBuilder->Signature ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception :{0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp deleted file mode 100644 index f2e621d6748..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// -// Define a class with a generic method. -ref class Example -{ -public: - generic static void Generic(T toDisplay) - { - Console::WriteLine("\r\nHere it is: {0}", toDisplay); - } -}; -// - -void DisplayGenericMethodInfo(MethodInfo^ mi) -{ - Console::WriteLine("\r\n{0}", mi); - - // - Console::WriteLine("\tIs this a generic method definition? {0}", - mi->IsGenericMethodDefinition); - // - - // - Console::WriteLine("\tIs it a generic method? {0}", - mi->IsGenericMethod); - // - - // - Console::WriteLine("\tDoes it have unassigned generic parameters? {0}", - mi->ContainsGenericParameters); - // - - // - // If this is a generic method, display its type arguments. - // - if (mi->IsGenericMethod) - { - array^ typeArguments = mi->GetGenericArguments(); - - Console::WriteLine("\tList type arguments ({0}):", - typeArguments->Length); - - for each (Type^ tParam in typeArguments) - { - // IsGenericParameter is true only for generic type - // parameters. - // - if (tParam->IsGenericParameter) - { - Console::WriteLine("\t\t{0} parameter position {1}" + - "\n\t\t declaring method: {2}", - tParam, - tParam->GenericParameterPosition, - tParam->DeclaringMethod); - } - else - { - Console::WriteLine("\t\t{0}", tParam); - } - } - } - // -}; - -void main() -{ - Console::WriteLine("\r\n--- Examine a generic method."); - - // - // Create a Type object representing class Example, and - // get a MethodInfo representing the generic method. - // - Type^ ex = Example::typeid; - MethodInfo^ mi = ex->GetMethod("Generic"); - - DisplayGenericMethodInfo(mi); - - // Assign the int type to the type parameter of the Example - // method. - // - MethodInfo^ miConstructed = mi->MakeGenericMethod(int::typeid); - - DisplayGenericMethodInfo(miConstructed); - // - - // Invoke the method. - array^ args = { 42 }; - miConstructed->Invoke((Object^) 0, args); - - // Invoke the method normally. - Example::Generic(42); - - // - // Get the generic type definition from the closed method, - // and show it's the same as the original definition. - // - MethodInfo^ miDef = miConstructed->GetGenericMethodDefinition(); - Console::WriteLine("\r\nThe definition is the same: {0}", - miDef == mi); - // -}; - -/* This example produces the following output: - ---- Examine a generic method. - -Void Generic[T](T) - Is this a generic method definition? True - Is it a generic method? True - Does it have unassigned generic parameters? True - List type arguments (1): - T parameter position 0 - declaring method: Void Generic[T](T) - -Void Generic[Int32](Int32) - Is this a generic method definition? False - Is it a generic method? True - Does it have unassigned generic parameters? False - List type arguments (1): - System.Int32 - -Here it is: 42 - -Here it is: 42 - -The definition is the same: True - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_Class/CPP/modulebuilder.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_Class/CPP/modulebuilder.cpp deleted file mode 100644 index f498738331b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_Class/CPP/modulebuilder.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -// System.Reflection.Emit.ModuleBuilder -/* -The following example demonstrates the 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -A run time class having a method and a field is created using the 'ModuleBuilder' -class and created class is called from the 'TestClass'. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -public ref class CodeGenerator -{ -private: - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - // Get the current application domain for the current thread. - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the current application domain. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Define a dynamic module in this assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - - // Define a runtime class with specified name and attributes. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public ); - - // Add 'Greeting' field to the class, with the specified attribute and type. - FieldBuilder^ greetingField = myTypeBuilder->DefineField( "Greeting", String::typeid, FieldAttributes::Public ); - array^myMethodArgs = {String::typeid}; - - // Add 'MyMethod' method to the class, with the specified attribute and signature. - MethodBuilder^ myMethod = myTypeBuilder->DefineMethod( "MyMethod", MethodAttributes::Public, CallingConventions::Standard, nullptr, myMethodArgs ); - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->EmitWriteLine( "In the method..." ); - methodIL->Emit( OpCodes::Ldarg_0 ); - methodIL->Emit( OpCodes::Ldarg_1 ); - methodIL->Emit( OpCodes::Stfld, greetingField ); - methodIL->Emit( OpCodes::Ret ); - myTypeBuilder->CreateType(); - } - - property AssemblyBuilder^ MyAssembly - { - AssemblyBuilder^ get() - { - return this->myAssemblyBuilder; - } - } -}; - -int main() -{ - CodeGenerator^ myCodeGenerator = gcnew CodeGenerator; - - // Get the assembly builder for 'myCodeGenerator' object. - AssemblyBuilder^ myAssemblyBuilder = myCodeGenerator->MyAssembly; - - // Get the module builder for the above assembly builder object . - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->GetDynamicModule( "TempModule" ); - Console::WriteLine( "The fully qualified name and path to this module is :{0}", myModuleBuilder->FullyQualifiedName ); - Type^ myType = myModuleBuilder->GetType( "TempClass" ); - MethodInfo^ myMethodInfo = myType->GetMethod( "MyMethod" ); - - // Get the token used to identify the method within this module. - MethodToken myMethodToken = myModuleBuilder->GetMethodToken( myMethodInfo ); - Console::WriteLine( "Token used to identify the method of 'myType'" - " within the module is {0:x}", myMethodToken.Token ); - array^args = {"Hello."}; - Object^ myObject = Activator::CreateInstance( myType, nullptr, nullptr ); - myMethodInfo->Invoke( myObject, args ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp deleted file mode 100644 index 3979e2356e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// System.Reflection.Emit.ModuleBuilder.DefineGlobalMethod(String,MethodAttributes,Type,Type[]) -// System.Reflection.Emit.ModuleBuilder.CreateGlobalFunctions - -/* -The following example demonstrates the 'DefineGlobalMethod(String,MethodAttributes,Type,Type[])' -and 'CreateGlobalFunctions' methods of 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. Then a global method -is created in the module using the 'DefineGlobalMethod' method. The global method is called from -the 'CallerClass'. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class CodeGenerator -{ -private: - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - myModuleBuilder = nullptr; - myAssemblyBuilder = nullptr; - - // - // - AppDomain^ currentDomain; - AssemblyName^ myAssemblyName; - MethodBuilder^ myMethodBuilder = nullptr; - ILGenerator^ myILGenerator; - - // Get the current application domain for the current thread. - currentDomain = AppDomain::CurrentDomain; - myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the 'currentDomain'. - myAssemblyBuilder = - currentDomain->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Define a dynamic module in "TempAssembly" assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - - // Define a global method in the 'TempModule' module. - myMethodBuilder = myModuleBuilder->DefineGlobalMethod( - "MyMethod1", (MethodAttributes)(MethodAttributes::Static | MethodAttributes::Public), - nullptr, nullptr ); - myILGenerator = myMethodBuilder->GetILGenerator(); - myILGenerator->EmitWriteLine( "Hello World from global method." ); - myILGenerator->Emit( OpCodes::Ret ); - - // Fix up the 'TempModule' module . - myModuleBuilder->CreateGlobalFunctions(); - // - // - } - - property AssemblyBuilder^ MyAssembly - { - AssemblyBuilder^ get() - { - return this->myAssemblyBuilder; - } - } -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; - AssemblyBuilder^ myAssembly = myGenerator->MyAssembly; - ModuleBuilder^ myBuilder = myAssembly->GetDynamicModule( "TempModule" ); - Console::WriteLine( "Invoking the global method..." ); - MethodInfo^ myMethodInfo = myBuilder->GetMethod( "MyMethod1" ); - myMethodInfo->Invoke( nullptr, nullptr ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp deleted file mode 100644 index b40b5fe22cc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -void main() -{ - // Get the current application domain for the current thread. - AppDomain^ currentDomain = AppDomain::CurrentDomain; - - // Create a dynamic assembly in the current application domain, - // and allow it to be executed and saved to disk. - AssemblyName^ aName = gcnew AssemblyName("TempAssembly"); - AssemblyBuilder^ ab = currentDomain->DefineDynamicAssembly( - aName, AssemblyBuilderAccess::RunAndSave); - - // Define a dynamic module in "TempAssembly" assembly. For a single- - // module assembly, the module has the same name as the assembly. - ModuleBuilder^ mb = - ab->DefineDynamicModule(aName->Name, aName->Name + ".dll"); - - // Define a public enumeration with the name "Elevation" and an - // underlying type of Int32. - EnumBuilder^ eb = - mb->DefineEnum("Elevation", TypeAttributes::Public, int::typeid); - - // Define two members, "High" and "Low". - eb->DefineLiteral("Low", (Object^) 0); - eb->DefineLiteral("High", 1); - - // Create the type and save the assembly. - Type^ finished = eb->CreateType(); - ab->Save(aName->Name + ".dll"); - - for each (Object^ o in Enum::GetValues(finished)) - { - Console::WriteLine("{0}.{1} = {2}", finished, o, (int)o); - } -} - -/* This code example produces the following output: - -Elevation.Low = 0 -Elevation.High = 1 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/CPP/modulebuilder_defineinitializeddata.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/CPP/modulebuilder_defineinitializeddata.cpp deleted file mode 100644 index d87da81e582..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/CPP/modulebuilder_defineinitializeddata.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System.Reflection.Emit.ModuleBuilder.DefineInitializedData - -/* -The following example demonstrates the 'DefineInitializedData' method of -'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -A initialized data field is created using 'DefineInitializedData' -method for creating the initialized data. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class CodeGenerator -{ -private: - ModuleBuilder^ myModuleBuilder; - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - // - AppDomain^ currentDomain; - AssemblyName^ myAssemblyName; - - // Get the current application domain for the current thread. - currentDomain = AppDomain::CurrentDomain; - myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the 'currentDomain'. - myAssemblyBuilder = - currentDomain->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::Run ); - - // Define a dynamic module in "TempAssembly" assembly. - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" ); - - // Define the initialized data field in the .sdata section of the PE file. - array^ temp0 = {01,00,01}; - FieldBuilder^ myFieldBuilder = - myModuleBuilder->DefineInitializedData( "MyField", temp0, - (FieldAttributes)(FieldAttributes::Static | FieldAttributes::Public) ); - myModuleBuilder->CreateGlobalFunctions(); - // - } - - property AssemblyBuilder^ MyAssembly - { - AssemblyBuilder^ get() - { - return this->myAssemblyBuilder; - } - } -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; - AssemblyBuilder^ myAssembly = myGenerator->MyAssembly; - ModuleBuilder^ myBuilder = myAssembly->GetDynamicModule( "TempModule" ); - FieldInfo^ myInfo = myBuilder->GetField( "MyField" ); - Console::WriteLine( "The name of the initialized data field is :" + myInfo->Name ); - Console::WriteLine( "The object having the field value is :" + myInfo->GetValue( myBuilder ) ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp deleted file mode 100644 index 3e81dcf0345..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// System.Reflection.Emit.ModuleBuilder.DefinePInvokeMethod(String,String,MethodAttributes, -// CallingConventions,Type,Type[],CallingConvention,CharSet) -/* - The following example demonstrates that DefinePInvokeMethod doesn't work unless you - add a DLLImportAttribute...which you can do just as well with DefineGlobalMethod. - -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; - -const int MB_RETRYCANCEL = 5; - -void main() -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName("TempAssembly"); - - // Define a dynamic assembly in the current application domain. - AssemblyBuilder^ myAssemblyBuilder = - AppDomain::CurrentDomain->DefineDynamicAssembly( - myAssemblyName, AssemblyBuilderAccess::Run); - - // Define a dynamic module in "TempAssembly" assembly. - ModuleBuilder^ myModuleBuilder = - myAssemblyBuilder->DefineDynamicModule("TempModule"); - - array^ paramTypes = - { int::typeid, String::typeid, String::typeid, int::typeid }; - - // Define a PInvoke method. - MethodBuilder^ piMethodBuilder = myModuleBuilder->DefinePInvokeMethod( - "MessageBoxA", - "user32.dll", - MethodAttributes::Public | MethodAttributes::Static | MethodAttributes::PinvokeImpl, - CallingConventions::Standard, - int::typeid, - paramTypes, - CallingConvention::Winapi, - CharSet::Ansi); - - // Add PreserveSig to the method implementation flags. NOTE: If this line - // is commented out, the return value will be zero when the method is - // invoked. - piMethodBuilder->SetImplementationFlags( - piMethodBuilder->GetMethodImplementationFlags() | MethodImplAttributes::PreserveSig); - - // Create global methods. - myModuleBuilder->CreateGlobalFunctions(); - - // Arguments for calling the method. - array^ arguments = - { (Object^)(int) 0, "Hello World", "Title", MB_RETRYCANCEL }; - - MethodInfo^ pinvokeMethod = myModuleBuilder->GetMethod("MessageBoxA"); - Console::WriteLine("Testing module-level PInvoke method created with DefinePInvokeMethod..."); - Console::WriteLine("Message box returned: {0}", - pinvokeMethod->Invoke(nullptr, arguments)); -}; - - -/* This code example produces input similar to the following: - -Testing module-level PInvoke method created with DefinePInvokeMethod... -Message box returned: 4 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource1/CPP/modulebuilder_defineresource1.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource1/CPP/modulebuilder_defineresource1.cpp deleted file mode 100644 index 8cbc472c421..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource1/CPP/modulebuilder_defineresource1.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// System::Reflection::Emit::ModuleBuilder.DefineResource(String, String) -/* -The following example demonstrates the 'DefineResource(String, String)' method -of 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -Then a managed resource is defined in the module using the 'DefineResource' -method. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; -public ref class CodeGenerator -{ -public: - CodeGenerator() - { - - // Get the current application domain for the current thread. - AppDomain^ currentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define 'TempAssembly' assembly in the current application domain. - AssemblyBuilder^ myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Define 'TempModule' module in 'TempAssembly' assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", "TempModule.netmodule", true ); - - // Define the managed embedded resource, 'MyResource' in 'TempModule'. - IResourceWriter^ myResourceWriter = myModuleBuilder->DefineResource( "MyResource.resource", "Description" ); - - // Add resources to the resource writer. - myResourceWriter->AddResource( "String 1", "First String" ); - myResourceWriter->AddResource( "String 2", "Second String" ); - myResourceWriter->AddResource( "String 3", "Third String" ); - myAssemblyBuilder->Save( "MyAssembly.dll" ); - } - -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; - Console::WriteLine( "A resource named 'MyResource.resource' has been created and can be viewed in the 'MyAssembly.dll'" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource2/CPP/modulebuilder_defineresource2.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource2/CPP/modulebuilder_defineresource2.cpp deleted file mode 100644 index 5caa523989d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource2/CPP/modulebuilder_defineresource2.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// System::Reflection::Emit::ModuleBuilder.DefineResource(String, String, ResourceAttributes) -/* -The following example demonstrates the 'DefineResource(String, String, ResourceAttributes)' -method of 'ModuleBuilder' class. -A dynamic assembly with a module in it is created in 'CodeGenerator' class. -Then a managed resource is defined in the module using the 'DefineResource' method. -*/ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Resources; -public ref class CodeGenerator -{ -public: - CodeGenerator() - { - - // Get the current application domain for the current thread. - AppDomain^ currentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define 'TempAssembly' assembly in the current application domain. - AssemblyBuilder^ myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Define 'TempModule' module in 'TempAssembly' assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule", "TempModule.netmodule", true ); - - // Define the managed embedded resource, 'MyResource' in 'TempModule' - // with the specified attribute. - IResourceWriter^ writer = myModuleBuilder->DefineResource( "MyResource.resource", "Description", ResourceAttributes::Public ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - myAssemblyBuilder->Save( "MyAssembly.dll" ); - } - -}; - -int main() -{ - CodeGenerator^ myGenerator = gcnew CodeGenerator; - Console::WriteLine( "A resource named 'MyResource::resource' has been created and can be viewed in the 'MyAssembly.dll'" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp b/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp deleted file mode 100644 index 574e5fa1686..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// System.Reflection.Emit.ModuleBuilder.GetArrayMethod -// System.Reflection.Emit.ModuleBuilder.GetArrayMethodToken - -/* -The following example demonstrates 'GetArrayMethod' and 'GetArrayMethodToken' -methods of 'ModuleBuilder' class. -A dynamic assembly with a module having a runtime class, 'TempClass' is created. -This class defines a method, 'SortArray', which sorts the elements of the array -passed to it. The 'GetArrayMethod' method is used to obtain the 'MethodInfo' object -corresponding to the 'Sort' method of the 'Array'. The token used to identify the 'Sort' -method in dynamic module is displayed using 'GetArrayMethodToken' method. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class CodeGenerator -{ -private: - AssemblyBuilder^ myAssemblyBuilder; - -public: - CodeGenerator() - { - AppDomain^ myCurrentDomain = AppDomain::CurrentDomain; - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "TempAssembly"; - - // Define a dynamic assembly in the current application domain. - myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - -// -// - // Define a dynamic module in "TempAssembly" assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder-> - DefineDynamicModule( "TempModule" ); - - // Define a runtime class with specified name and attributes. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( - "TempClass", TypeAttributes::Public ); - array^ paramArray = { Array::typeid }; - // Add 'SortArray' method to the class, with the given signature. - MethodBuilder^ myMethod = myTypeBuilder->DefineMethod( "SortArray", - MethodAttributes::Public, Array::typeid, paramArray ); - - array^ myArrayClass = gcnew array( 1 ); - array^ parameterTypes = { Array::typeid }; - // Get the 'MethodInfo' object corresponding to 'Sort' method of 'Array' class. - MethodInfo^ myMethodInfo = myModuleBuilder->GetArrayMethod( - myArrayClass->GetType(), "Sort", CallingConventions::Standard, - nullptr, parameterTypes ); - - // Get the token corresponding to 'Sort' method of 'Array' class. - MethodToken myMethodToken = myModuleBuilder->GetArrayMethodToken( - myArrayClass->GetType(), "Sort", CallingConventions::Standard, - nullptr, parameterTypes ); - Console::WriteLine( "Token used by module to identify the 'Sort' method" - + " of 'Array' class is : {0:x} ", myMethodToken.Token ); - - ILGenerator^ methodIL = myMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldarg_1 ); - methodIL->Emit( OpCodes::Call, myMethodInfo ); - methodIL->Emit( OpCodes::Ldarg_1 ); - methodIL->Emit( OpCodes::Ret ); - - // Complete the creation of type. - myTypeBuilder->CreateType(); - // - // - } - - property AssemblyBuilder^ MyBuilder - { - AssemblyBuilder^ get() - { - return this->myAssemblyBuilder; - } - } -}; - -int main() -{ - CodeGenerator^ myCodeGenerator = gcnew CodeGenerator; - AssemblyBuilder^ myAssemblyBuilder = myCodeGenerator->MyBuilder; - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder-> - GetDynamicModule( "TempModule" ); - Type^ myType = myModuleBuilder->GetType( "TempClass" ); - Object^ myObject = Activator::CreateInstance( myType ); - MethodInfo^ sortArray = myType->GetMethod( "SortArray" ); - if ( nullptr != sortArray ) - { - array^ arrayToSort = {"I","am","not","sorted"}; - Console::WriteLine( "Array elements before sorting " ); - for ( int i = 0; i < arrayToSort->Length; i++ ) - { - Console::WriteLine( "Array element {0} : {1} ", i, arrayToSort[ i ] ); - } - array^arguments = {arrayToSort}; - Console::WriteLine( "Invoking our dynamically " - + "created SortArray method..." ); - Object^ myOutput = sortArray->Invoke( myObject, arguments ); - array^ mySortedArray = ( array^ )myOutput; - Console::WriteLine( "Array elements after sorting " ); - for ( int i = 0; i < mySortedArray->Length; i++ ) - { - Console::WriteLine( "Array element {0} : {1} ", i, mySortedArray[ i ] ); - } - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_Attributes1/CPP/parameterinfo_attributes1.cpp b/snippets/cpp/VS_Snippets_CLR/ParameterInfo_Attributes1/CPP/parameterinfo_attributes1.cpp deleted file mode 100644 index a0934b9b3d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_Attributes1/CPP/parameterinfo_attributes1.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// System::Reflection::ParameterInfo::Attributes -/* - The following example displays the attributes associated with the - parameters of the method called 'MyMethod' of class 'ParameterInfo_Example'. - */ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class MyClass1 -{ -public: - int MyMethod( int i, [Out]short * j, long * k ) - { - *j = 2; - return 0; - } - -}; - -void main() -{ - // Get the type. - Type^ myType = MyClass1::typeid; - - // Get the method named 'MyMethod' from the type. - MethodBase^ myMethodBase = myType->GetMethod( "MyMethod" ); - - // Get the parameters associated with the method. - array^myParameters = myMethodBase->GetParameters(); - Console::WriteLine( "\nThe method {0} has the {1} parameters :", "ParameterInfo_Example::MyMethod", myParameters->Length ); - - // Print the attributes associated with each of the parameters. - for ( int i = 0; i < myParameters->Length; i++ ) - Console::WriteLine( "\tThe {0} parameter has the attribute : {1}", i + 1, myParameters[ i ]->Attributes ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/CPP/ParameterInfo_GetCustomAttribute_IsDefined.cpp b/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/CPP/ParameterInfo_GetCustomAttribute_IsDefined.cpp deleted file mode 100644 index 06e6497934c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/CPP/ParameterInfo_GetCustomAttribute_IsDefined.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// -// System::Reflection::ParameterInfo::GetCustomAttributes(Type, bool) -// System::Reflection::ParameterInfo::IsDefined(Type, bool) -using namespace System; -using namespace System::Reflection; - -// Define a custom attribute with one named parameter. -[AttributeUsage(AttributeTargets::Parameter)] -public ref class MyAttribute: public Attribute -{ -private: - String^ myName; - -public: - MyAttribute( String^ name ) - { - myName = name; - } - - property String^ Name - { - String^ get() - { - return myName; - } - } -}; - -// Derive another custom attribute from MyAttribute. -[AttributeUsage(AttributeTargets::Parameter)] -public ref class MyDerivedAttribute: public MyAttribute -{ -public: - MyDerivedAttribute( String^ name ) : MyAttribute( name ) {} -}; - -// Define a class with a method that has three parameters. Apply -// MyAttribute to one parameter, MyDerivedAttribute to another, and -// no attributes to the third. -public ref class MyClass1 -{ -public: - void MyMethod( [MyAttribute("This is an example parameter attribute")] - int i, - [MyDerivedAttribute("This is another parameter attribute")] - int j, - int k ){} -}; - -void main() -{ - // Get the type of the class 'MyClass1'. - Type^ myType = MyClass1::typeid; - - // Get the members associated with the class 'MyClass1'. - array^myMethods = myType->GetMethods(); - - // For each method of the class 'MyClass1', display all the parameters - // to which MyAttribute or its derived types have been applied. - for each ( MethodInfo^ mi in myMethods ) - { - // Get the parameters for the method. - array^ myParameters = mi->GetParameters(); - if ( myParameters->Length > 0 ) - { - Console::WriteLine("\nThe following parameters of {0} have MyAttribute or a derived type:", mi); - for each ( ParameterInfo^ pi in myParameters) - { - if (pi->IsDefined(MyAttribute::typeid, false)) - { - Console::WriteLine("Parameter {0}, name = {1}, type = {2}", - pi->Position, pi->Name, pi->ParameterType); - } - } - } - } -} - -/* This code example produces the following output: - -The following parameters of Void MyMethod(Int32, Int32, Int32) have MyAttribute or a derived type: -Parameter 0, name = i, type = System.Int32 -Parameter 1, name = j, type = System.Int32 - -The following parameters of Boolean Equals(System.Object) have MyAttribute or a derived type: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/CPP/source.cpp deleted file mode 100644 index f864dfbd878..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Define a custom attribute with one named parameter. -[AttributeUsage(AttributeTargets::Parameter)] -public ref class MyAttribute: public Attribute -{ -private: - String^ myName; - -public: - MyAttribute( String^ name ) - { - myName = name; - } - - property String^ Name - { - String^ get() - { - return myName; - } - } -}; - -// Define a class which has a custom attribute associated with one of the -// parameters of a method. -public ref class MyClass1 -{ -public: - void MyMethod( - [MyAttribute("This is an example parameter attribute")] - int i ) {} -}; - -void main() -{ - // Get the type of the class 'MyClass1'. - Type^ myType = MyClass1::typeid; - - // Get the members associated with the class 'MyClass1'. - array^myMethods = myType->GetMethods(); - - // Display the attributes for each of the parameters of each method of the class 'MyClass1'. - for ( int i = 0; i < myMethods->Length; i++ ) - { - // Get the parameters for the method. - array^myParameters = myMethods[ i ]->GetParameters(); - - if ( myParameters->Length > 0 ) - { - Console::WriteLine( "\nThe parameters for the method \"{0}\" that have custom attributes are:", myMethods[ i ] ); - for ( int j = 0; j < myParameters->Length; j++ ) - { - // Get the attributes of type 'MyAttribute' for each parameter. - array^myAttributes = myParameters[ j ]->GetCustomAttributes( MyAttribute::typeid, false ); - - if ( myAttributes->Length > 0 ) - { - Console::WriteLine( "Parameter {0}, name = {1}, type = {2} has attributes:", - myParameters[ j ]->Position, - myParameters[ j ]->Name, - myParameters[ j ]->ParameterType ); - for ( int k = 0; k < myAttributes->Length; k++ ) - { - Console::WriteLine( "\t{0}", myAttributes[ k ] ); - } - } - } - } - } -} -/* This code example produces the following output: - -The parameters for the method Void MyMethod(Int32) that have custom attributes are : -Parameter 0, name = i, type = System.Int32 has attributes: - MyAttribute - -The parameters for the method Boolean Equals(System.Object) that have custom attributes are : - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp b/snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp deleted file mode 100644 index c568d6441a6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -// System::Reflection::ParameterInfo::IsIn -// System::Reflection::ParameterInfo::IsOptional -// System::Reflection::ParameterInfo::IsOut -/* -The following program creates a dynamic assembly named 'MyAssembly', defines a -module named 'MyModule' within the assembly. It defines a type called 'MyType' -within the module and also defines a static method named 'MyMethod' for the -type. This dynamic assembly is then queried for the type defined within it and -then the attributes of all the parameters of the method named 'MyMethod' is -displayed. -*/ -// -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Threading; -using namespace System::Reflection::Emit; -void DefineMethod() -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "MyAssembly"; - - // Get the assembly builder from the application domain associated with the current thread. - AssemblyBuilder^ myAssemblyBuilder = Thread::GetDomain()->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - - // Create a dynamic module in the assembly. - ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "MyModule", "MyAssembly.dll" ); - - // Create a type in the module. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyType" ); - - // Create a method called MyMethod. - array^type1 = {int::typeid,short::typeid,long::typeid}; - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "MyMethod", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::Static), String::typeid, type1 ); - - // Set the attributes for the parameters of the method. - // Set the attribute for the first parameter to IN. - ParameterBuilder^ myParameterBuilder = myMethodBuilder->DefineParameter( 1, ParameterAttributes::In, "MyIntParameter" ); - - // Set the attribute for the second parameter to OUT. - myParameterBuilder = myMethodBuilder->DefineParameter( 2, ParameterAttributes::Out, "MyShortParameter" ); - - // Set the attribute for the third parameter to OPTIONAL. - myParameterBuilder = myMethodBuilder->DefineParameter( 3, static_cast(ParameterAttributes::Optional | ParameterAttributes::HasDefault), "MyLongParameter" ); - - // Get the Microsoft Intermediate Language generator for the method. - ILGenerator^ myILGenerator = myMethodBuilder->GetILGenerator(); - - // Use the utility method to generate the MSIL instructions that print a String* to the console. - myILGenerator->EmitWriteLine( "Hello World!" ); - - // Generate the S"ret" MSIL instruction. - myILGenerator->Emit( OpCodes::Ret ); - - // End the creation of the type. - myTypeBuilder->CreateType(); -} - -int main() -{ - // Create a dynamic assembly with a type named MyType. - DefineMethod(); - - // Get the assemblies currently loaded in the application domain. - array^myAssemblies = Thread::GetDomain()->GetAssemblies(); - Assembly^ myAssembly = nullptr; - - // Get the assembly named MyAssembly. - for ( int i = 0; i < myAssemblies->Length; i++ ) - if ( String::Compare( myAssemblies[ i ]->GetName( false )->Name, "MyAssembly" ) == 0 ) - myAssembly = myAssemblies[ i ]; - - if ( myAssembly != nullptr ) - { - // Get a type named MyType. - Type^ myType = myAssembly->GetType( "MyType" ); - - // Get a method named MyMethod from the type. - MethodBase^ myMethodBase = myType->GetMethod( "MyMethod" ); - - // Get the parameters associated with the method. - array^myParameters = myMethodBase->GetParameters(); - Console::WriteLine( "\nThe method {0} has the {1} parameters :", myMethodBase, myParameters->Length ); - - // Print the IN, OUT and OPTIONAL attributes associated with each of the parameters. - for ( int i = 0; i < myParameters->Length; i++ ) - { - if ( myParameters[ i ]->IsIn ) - Console::WriteLine( "\tThe {0} parameter has the In attribute", i + 1 ); - if ( myParameters[ i ]->IsOptional ) - Console::WriteLine( "\tThe {0} parameter has the Optional attribute", i + 1 ); - if ( myParameters[ i ]->IsOut ) - Console::WriteLine( "\tThe {0} parameter has the Out attribute", i + 1 ); - } - } - else - Console::WriteLine( "Could not find a assembly named 'MyAssembly' for the current application domain" ); -} -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp b/snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp deleted file mode 100644 index f64e0f64c9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp +++ /dev/null @@ -1,130 +0,0 @@ - -// System.Reflection.Emit.PropertyBuilder.SetGetMethod -// System.Reflection.Emit.PropertyBuilder.SetSetMethod -// System.Reflection.Emit.PropertyBuilder.AddOtherMethod -// System.Reflection.Emit.PropertyBuilder -/* -This following program demonstrates methods 'SetGetMethod','SetSetMethod' and -'AddOtherMethod' of class 'PropertyBuilder'. - -A dynamic assembly is generated with a class having a property 'Greeting'. -Its 'get' and 'set' method are created by returning and setting a string respectively. -This property value is reset with default string using othermethod. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// Create the callee transient dynamic assembly. -Type^ CreateCallee( AppDomain^ myAppDomain, AssemblyBuilderAccess access ) -{ - // Create a simple name for the callee assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the callee dynamic assembly. - AssemblyBuilder^ myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, access ); - - // Create a dynamic module named "EmittedModule" in the callee assembly. - ModuleBuilder^ myModule; - if ( access == AssemblyBuilderAccess::Run ) - { - myModule = myAssemblyBuilder->DefineDynamicModule( "EmittedModule" ); - } - else - { - myModule = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", "EmittedModule.mod" ); - } - - // - TypeBuilder^ helloWorldTypeBuilder = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define a private String field named "m_greeting" in "HelloWorld" class. - FieldBuilder^ greetingFieldBuilder = helloWorldTypeBuilder->DefineField( "m_greeting", String::typeid, FieldAttributes::Private ); - - // Create constructor args and define constructor. - array^constructorArgs = {String::typeid}; - ConstructorBuilder^ constructor = helloWorldTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, constructorArgs ); - - // Generate IL code for the method. The constructor stores its argument in the private field. - ILGenerator^ constructorIL = constructor->GetILGenerator(); - constructorIL->Emit( OpCodes::Ldarg_0 ); - constructorIL->Emit( OpCodes::Ldarg_1 ); - constructorIL->Emit( OpCodes::Stfld, greetingFieldBuilder ); - constructorIL->Emit( OpCodes::Ret ); - - // - // Define property Greeting. - PropertyBuilder^ greetingPropertyBuilder = helloWorldTypeBuilder->DefineProperty( "Greeting", PropertyAttributes::None, String::typeid, nullptr ); - - // Define the 'get_Greeting' method. - MethodBuilder^ getGreetingMethod = helloWorldTypeBuilder->DefineMethod( "get_Greeting", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::SpecialName), String::typeid, nullptr ); - - // Generate IL code for 'get_Greeting' method. - ILGenerator^ methodIL = getGreetingMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldarg_0 ); - methodIL->Emit( OpCodes::Ldfld, greetingFieldBuilder ); - methodIL->Emit( OpCodes::Ret ); - greetingPropertyBuilder->SetGetMethod( getGreetingMethod ); - // - - - // Define the set_Greeting method. - array^methodArgs = {String::typeid}; - MethodBuilder^ setGreetingMethod = helloWorldTypeBuilder->DefineMethod( "set_Greeting", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig | MethodAttributes::SpecialName), void::typeid, methodArgs ); - - // Generate IL code for set_Greeting method. - methodIL = setGreetingMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldarg_0 ); - methodIL->Emit( OpCodes::Ldarg_1 ); - methodIL->Emit( OpCodes::Stfld, greetingFieldBuilder ); - methodIL->Emit( OpCodes::Ret ); - greetingPropertyBuilder->SetSetMethod( setGreetingMethod ); - // - - // - // Define the reset_Greeting method. - MethodBuilder^ otherGreetingMethod = helloWorldTypeBuilder->DefineMethod( "reset_Greeting", static_cast(MethodAttributes::Public | MethodAttributes::HideBySig), void::typeid, nullptr ); - - // Generate IL code for reset_Greeting method. - methodIL = otherGreetingMethod->GetILGenerator(); - methodIL->Emit( OpCodes::Ldarg_0 ); - methodIL->Emit( OpCodes::Ldstr, "Default String." ); - methodIL->Emit( OpCodes::Stfld, greetingFieldBuilder ); - methodIL->Emit( OpCodes::Ret ); - greetingPropertyBuilder->AddOtherMethod( otherGreetingMethod ); - // - - // Create the class HelloWorld. - return (helloWorldTypeBuilder->CreateType()); -} - -int main() -{ - // Create the "HelloWorld" type in an assembly with mode 'RunAndSave'. - Type^ helloWorldType = CreateCallee( Thread::GetDomain(), AssemblyBuilderAccess::RunAndSave ); - - // Create an instance of the "HelloWorld" class. - array^temp0 = {"HelloWorld"}; - Object^ helloWorld = Activator::CreateInstance( helloWorldType, temp0 ); - Object^ returnValue = helloWorldType->InvokeMember( "Greeting", static_cast(BindingFlags::Default | BindingFlags::GetProperty), nullptr, helloWorld, nullptr ); - Console::WriteLine( "HelloWorld.GetGreeting returned: \"{0}\"", returnValue ); - - // Set 'Greeting' property with 'NewMessage!!!'. - array^temp1 = {"New Message !!!"}; - helloWorldType->InvokeMember( "Greeting", static_cast(BindingFlags::Default | BindingFlags::SetProperty), nullptr, helloWorld, temp1 ); - returnValue = helloWorldType->InvokeMember( "Greeting", static_cast(BindingFlags::Default | BindingFlags::GetProperty), nullptr, helloWorld, nullptr ); - Console::WriteLine( "After Set operation HelloWorld.GetGreeting returned: \"{0}\"", returnValue ); - - // Reset 'Greeting' property to 'Default String'. - helloWorldType->InvokeMember( "reset_Greeting", static_cast(BindingFlags::Default | BindingFlags::InvokeMethod), nullptr, helloWorld, nullptr ); - returnValue = helloWorldType->InvokeMember( "Greeting", static_cast(BindingFlags::Default | BindingFlags::GetProperty), nullptr, helloWorld, nullptr ); - Console::WriteLine( "After Reset operation HelloWorld.GetGreeting returned: \"{0}\"", returnValue ); - AssemblyBuilder^ myAssembly = dynamic_cast(helloWorldType->Assembly); - - // Save to disk. - myAssembly->Save( "EmittedAssembly.dll" ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/Example.cpp b/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/Example.cpp deleted file mode 100644 index 3ec2d28a977..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/Example.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -ref class Example -{ -private: - int static _sharedProperty = 41; - int _instanceProperty; - Dictionary^ _indexedInstanceProperty; - -public: - Example() - { - _instanceProperty = 42; - _indexedInstanceProperty = gcnew Dictionary(); - }; - - static property int SharedProperty - { - int get() { return _sharedProperty; } - void set(int value) { _sharedProperty = value; } - }; - - property int InstanceProperty - { - int get() { return _instanceProperty; } - void set(int value) { _instanceProperty = value; } - }; - - // By default, the name of the default indexed property (class - // indexer) is Item, and that name must be used to search for the - // property with reflection. The property can be given a different - // name by using the IndexerNameAttribute attribute. - property String^ default[int] - { - String^ get(int key) - { - String^ returnValue; - if (_indexedInstanceProperty->TryGetValue(key, returnValue)) - { - return returnValue; - } - else - { - return nullptr; - } - } - void set(int key, String^ value) - { - if (value == nullptr) - { - throw gcnew ArgumentNullException( - "IndexedInstanceProperty value can be an empty string, but it cannot be null."); - } - else - { - if (_indexedInstanceProperty->ContainsKey(key)) - { - _indexedInstanceProperty[key] = value; - } - else - { - _indexedInstanceProperty->Add(key, value); - } - } - } - }; -}; - -void main() -{ - Console::WriteLine("Initial value of class-level property: {0}", - Example::SharedProperty); - - PropertyInfo^ piShared = - Example::typeid->GetProperty("SharedProperty"); - piShared->SetValue(nullptr, 76, nullptr); - - Console::WriteLine("Final value of class-level property: {0}", - Example::SharedProperty); - - - Example^ exam = gcnew Example(); - - Console::WriteLine("\nInitial value of instance property: {0}", - exam->InstanceProperty); - - PropertyInfo^ piInstance = - Example::typeid->GetProperty("InstanceProperty"); - piInstance->SetValue(exam, 37, nullptr); - - Console::WriteLine("Final value of instance property: {0}", - exam->InstanceProperty); - - - exam[17] = "String number 17"; - exam[46] = "String number 46"; - exam[9] = "String number 9"; - - Console::WriteLine( - "\nInitial value of indexed instance property(17): '{0}'", - exam[17]); - - // By default, the name of the default indexed property (class - // indexer) is Item, and that name must be used to search for the - // property with reflection. The property can be given a different - // name by using the IndexerNameAttribute attribute. - PropertyInfo^ piIndexedInstance = - Example::typeid->GetProperty("Item"); - piIndexedInstance->SetValue( - exam, - "New value for string number 17", - gcnew array { 17 }); - - Console::WriteLine("Final value of indexed instance property(17): '{0}'", - exam[17]); -}; - -/* This example produces the following output: - -Initial value of class-level property: 41 -Final value of class-level property: 76 - -Initial value of instance property: 42 -Final value of instance property: 37 - -Initial value of indexed instance property(17): 'String number 17' -Final value of indexed instance property(17): 'New value for string number 17' - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/example2.cpp b/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/example2.cpp deleted file mode 100644 index f6ea3e649aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/example2.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -ref class Example -{ -private: - int static _sharedProperty = 41; - int _instanceProperty; - - -public: - Example() - { - _instanceProperty = 42; - }; - - static property int SharedProperty - { - int get() { return _sharedProperty; } - void set(int value) { _sharedProperty = value; } - }; - - property int InstanceProperty - { - int get() { return _instanceProperty; } - void set(int value) { _instanceProperty = value; } - }; - -}; - -void main() -{ - Console::WriteLine("Initial value of static property: {0}", - Example::SharedProperty); - - PropertyInfo^ piShared = - Example::typeid->GetProperty("SharedProperty"); - piShared->SetValue(nullptr, 76, nullptr); - - Console::WriteLine("New value of static property: {0}", - Example::SharedProperty); - - - Example^ exam = gcnew Example(); - - Console::WriteLine("\nInitial value of instance property: {0}", - exam->InstanceProperty); - - PropertyInfo^ piInstance = - Example::typeid->GetProperty("InstanceProperty"); - piInstance->SetValue(exam, 37, nullptr); - - Console::WriteLine("New value of instance property: {0}", - exam->InstanceProperty); -}; - -/* The example displays the following output: - Initial value of static property: 41 - New value of static property: 76 - - Initial value of instance property: 42 - New value of instance property: 37 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp deleted file mode 100644 index 28a75c1bc29..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Globalization; - -// Declare a delegate type that can be used to execute the completed -// dynamic method. -private delegate int HelloDelegate(String^ msg, int ret); - -void main() -{ - // Create an array that specifies the types of the parameters - // of the dynamic method. This dynamic method has a String - // parameter and an Integer parameter. - array^ helloArgs = { String::typeid, int::typeid }; - - // Create a dynamic method with the name "Hello", a return type - // of Integer, and two parameters whose types are specified by - // the array helloArgs. Create the method in the module that - // defines the String class. - DynamicMethod^ hello = gcnew DynamicMethod("Hello", - int::typeid, - helloArgs, - String::typeid->Module); - - // - // Create an array that specifies the parameter types of the - // overload of Console::WriteLine to be used in Hello. - array^ writeStringArgs = { String::typeid }; - // Get the overload of Console::WriteLine that has one - // String parameter. - MethodInfo^ writeString = Console::typeid->GetMethod("WriteLine", - writeStringArgs); - - // Get an ILGenerator and emit a body for the dynamic method, - // using a stream size larger than the IL that will be - // emitted. - ILGenerator^ il = hello->GetILGenerator(256); - // Load the first argument, which is a string, onto the stack. - il->Emit(OpCodes::Ldarg_0); - // Call the overload of Console::WriteLine that prints a string. - il->EmitCall(OpCodes::Call, writeString, nullptr); - // The Hello method returns the value of the second argument; - // to do this, load the onto the stack and return. - il->Emit(OpCodes::Ldarg_1); - il->Emit(OpCodes::Ret); - // - - // - // Add parameter information to the dynamic method. (This is not - // necessary, but can be useful for debugging.) For each parameter, - // identified by position, supply the parameter attributes and a - // parameter name. - hello->DefineParameter(1, ParameterAttributes::In, "message"); - hello->DefineParameter(2, ParameterAttributes::In, "valueToReturn"); - // - - // - // Create a delegate that represents the dynamic method. This - // action completes the method. Any further attempts to - // change the method are ignored. - HelloDelegate^ hi = - (HelloDelegate^) hello->CreateDelegate(HelloDelegate::typeid); - - // Use the delegate to execute the dynamic method. - Console::WriteLine("\r\nUse the delegate to execute the dynamic method:"); - int retval = hi("\r\nHello, World!", 42); - Console::WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval); - - // Execute it again, with different arguments. - retval = hi("\r\nHi, Mom!", 5280); - Console::WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval); - // - - // - Console::WriteLine("\r\nUse the Invoke method to execute the dynamic method:"); - // Create an array of arguments to use with the Invoke method. - array^ invokeArgs = { "\r\nHello, World!", 42 }; - // Invoke the dynamic method using the arguments. This is much - // slower than using the delegate, because you must create an - // array to contain the arguments, and value-type arguments - // must be boxed. - Object^ objRet = hello->Invoke(nullptr, BindingFlags::ExactBinding, nullptr, invokeArgs, gcnew CultureInfo("en-us")); - Console::WriteLine("hello.Invoke returned: " + objRet); - // - - Console::WriteLine("\r\n ----- Display information about the dynamic method -----"); - // - // Display MethodAttributes for the dynamic method, set when - // the dynamic method was created. - Console::WriteLine("\r\nMethod Attributes: {0}", hello->Attributes); - // - - // - // Display the calling convention of the dynamic method, set when the - // dynamic method was created. - Console::WriteLine("\r\nCalling convention: {0}", hello->CallingConvention); - // - - // - // Display the declaring type, which is always null for dynamic - // methods. - if (hello->DeclaringType == nullptr) - { - Console::WriteLine("\r\nDeclaringType is always null for dynamic methods."); - } - else - { - Console::WriteLine("DeclaringType: {0}", hello->DeclaringType); - } - // - - // - // Display the default value for InitLocals. - if (hello->InitLocals) - { - Console::Write("\r\nThis method contains verifiable code."); - } - else - { - Console::Write("\r\nThis method contains unverifiable code."); - } - Console::WriteLine(" (InitLocals = {0})", hello->InitLocals); - // - - // - // Display the module specified when the dynamic method was created. - Console::WriteLine("\r\nModule: {0}", hello->Module); - // - - // - // Display the name specified when the dynamic method was created. - // Note that the name can be blank. - Console::WriteLine("\r\nName: {0}", hello->Name); - // - - // - // For dynamic methods, the reflected type is always null. - if (hello->ReflectedType == nullptr) - { - Console::WriteLine("\r\nReflectedType is null."); - } - else - { - Console::WriteLine("\r\nReflectedType: {0}", hello->ReflectedType); - } - // - - // - if (hello->ReturnParameter == nullptr) - { - Console::WriteLine("\r\nMethod has no return parameter."); - } - else - { - Console::WriteLine("\r\nReturn parameter: {0}", hello->ReturnParameter); - } - // - - // - // If the method has no return type, ReturnType is System.Void. - Console::WriteLine("\r\nReturn type: {0}", hello->ReturnType); - // - - // - // ReturnTypeCustomAttributes returns an ICustomeAttributeProvider - // that can be used to enumerate the custom attributes of the - // return value. At present, there is no way to set such custom - // attributes, so the list is empty. - if (hello->ReturnType == Void::typeid) - { - Console::WriteLine("The method has no return type."); - } - else - { - ICustomAttributeProvider^ caProvider = hello->ReturnTypeCustomAttributes; - array^ returnAttributes = caProvider->GetCustomAttributes(true); - if (returnAttributes->Length == 0) - { - Console::WriteLine("\r\nThe return type has no custom attributes."); - } - else - { - Console::WriteLine("\r\nThe return type has the following custom attributes:"); - for each (Object^ attr in returnAttributes) - { - Console::WriteLine("\t{0}", attr->ToString()); - } - } - } - // - - // - Console::WriteLine("\r\nToString: {0}", hello->ToString()); - // - - // - // Display parameter information. - array^ parameters = hello->GetParameters(); - Console::WriteLine("\r\nParameters: name, type, ParameterAttributes"); - for each (ParameterInfo^ p in parameters) - { - Console::WriteLine("\t{0}, {1}, {2}", - p->Name, p->ParameterType, p->Attributes); - } - // -} - -/* This code example produces the following output: - -Use the delegate to execute the dynamic method: - -Hello, World! -Invoking delegate hi("Hello, World!", 42) returned: 42 - -Hi, Mom! -Invoking delegate hi("Hi, Mom!", 5280) returned: 5280 - -Use the Invoke method to execute the dynamic method: - -Hello, World! -hello.Invoke returned: 42 - - ----- Display information about the dynamic method ----- - -Method Attributes: PrivateScope, Public, Static - -Calling convention: Standard - -DeclaringType is always null for dynamic methods. - -This method contains verifiable code. (InitLocals = True) - -Module: CommonLanguageRuntimeLibrary - -Name: Hello - -ReflectedType is null. - -Method has no return parameter. - -Return type: System.Int32 - -The return type has no custom attributes. - -ToString: Int32 Hello(System.String, Int32) - -Parameters: name, type, ParameterAttributes - message, System.String, In - valueToReturn, System.Int32, In - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp deleted file mode 100644 index 86d3112fd26..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class Test -{ -}; - -// Declare a delegate that will be used to execute the completed -// dynamic method. -delegate int HelloInvoker(String^ msg, int ret); - -int main() -{ - // Create an array that specifies the types of the parameters - // of the dynamic method. This method has a string parameter - // and an int parameter. - array^ helloArgs = {String::typeid, int::typeid}; - - // Create a dynamic method with the name "Hello", a return type - // of int, and two parameters whose types are specified by the - // array helloArgs. Create the method in the module that - // defines the Test class. - DynamicMethod^ hello = gcnew DynamicMethod("Hello", - int::typeid, - helloArgs, - Test::typeid->Module); - - // - // Create an array that specifies the parameter types of the - // overload of Console.WriteLine to be used in Hello. - array^ writeStringArgs = {String::typeid}; - // Get the overload of Console.WriteLine that has one - // String parameter. - MethodInfo^ writeString = - Console::typeid->GetMethod("WriteLine", writeStringArgs); - - // Get an ILGenerator and emit a body for the dynamic method. - ILGenerator^ ilgen = hello->GetILGenerator(); - // Load the first argument, which is a string, onto the stack. - ilgen->Emit(OpCodes::Ldarg_0); - // Call the overload of Console.WriteLine that prints a string. - ilgen->EmitCall(OpCodes::Call, writeString, nullptr); - // The Hello method returns the value of the second argument; - // to do this, load the onto the stack and return. - ilgen->Emit(OpCodes::Ldarg_1); - ilgen->Emit(OpCodes::Ret); - // - - // - // Create a delegate that represents the dynamic method. This - // action completes the method, and any further attempts to - // change the method will cause an exception. - HelloInvoker^ helloDelegate = - (HelloInvoker^) hello->CreateDelegate(HelloInvoker::typeid); - // - - // Use the delegate to execute the dynamic method. Save and - // print the return value. - int returnValue = helloDelegate("\r\nHello, World!", 42); - Console::WriteLine("helloDelegate(\"Hello, World!\", 42) returned {0}", - returnValue); - - // Do it again, with different arguments. - returnValue = helloDelegate("\r\nHi, Mom!", 5280); - Console::WriteLine("helloDelegate(\"Hi, Mom!\", 5280) returned {0}", - returnValue); - - // - // Create an array of arguments to use with the Invoke method. - array^ delegateArgs = {"\r\nHello, World!", 42}; - // Invoke the dynamic method using the arguments. This is much - // slower than using the delegate, because you must create an - // array to contain the arguments, and ValueType arguments - // must be boxed. - Object^ returnValueObject = hello->Invoke(nullptr, delegateArgs); - Console::WriteLine("hello.Invoke returned {0}", returnValueObject); - // -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp b/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp deleted file mode 100644 index f6f2d74c1e0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -static void Display(Int32 indent, String^ format, ... array^param) -{ - Console::Write("{0}", gcnew String (' ', indent)); - Console::WriteLine(format, param); -} - -// Displays the custom attributes applied to the specified member. -static void DisplayAttributes(Int32 indent, MemberInfo^ mi) -{ - // Get the set of custom attributes; if none exist, just return. - array^attrs = mi->GetCustomAttributes(false); - - if (attrs->Length==0) - { - return; - } - - // Display the custom attributes applied to this member. - Display(indent+1, "Attributes:"); - for each ( Object^ o in attrs ) - { - Display(indent*2, "{0}", o); - } -} - -void main() -{ - try - { - // This variable holds the amount of indenting that - // should be used when displaying each line of information. - Int32 indent = 0; - // Display information about the EXE assembly. - // - Assembly^ a = System::Reflection::Assembly::GetExecutingAssembly(); - - Display(indent, "Assembly identity={0}", gcnew array {a->FullName}); - Display(indent+1, "Codebase={0}", gcnew array {a->CodeBase}); - - // Display the set of assemblies our assemblies reference. - - Display(indent, "Referenced assemblies:"); - - for each ( AssemblyName^ an in a->GetReferencedAssemblies() ) - { - Display(indent + 1, "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", gcnew array {an->Name, an->Version, an->CultureInfo, (BitConverter::ToString(an->GetPublicKeyToken()))}); - } - // - Display(indent, ""); - // Display information about each assembly loading into this AppDomain. - for each ( Assembly^ b in AppDomain::CurrentDomain->GetAssemblies()) - { - Display(indent, "Assembly: {0}", gcnew array {b}); - // Display information about each module of this assembly. - - for each ( Module^ m in b->GetModules(true) ) - { - Display(indent+1, "Module: {0}", gcnew array {m->Name}); - } - // Display information about each type exported from this assembly. - - indent += 1; - for each ( Type^ t in b->GetExportedTypes() ) - { - Display(0, ""); - Display(indent, "Type: {0}", gcnew array {t}); - - // For each type, show its members & their custom attributes. - - indent += 1; - for each (MemberInfo^ mi in t->GetMembers() ) - { - Display(indent, "Member: {0}", gcnew array {mi->Name}); - DisplayAttributes(indent, mi); - - // If the member is a method, display information about its parameters. - if (mi->MemberType==MemberTypes::Method) - { - - for each ( ParameterInfo^ pi in (((MethodInfo^) mi)->GetParameters())) - { - Display(indent+1, "Parameter: Type={0}, Name={1}", gcnew array {pi->ParameterType, pi->Name}); - } - } - - // If the member is a property, display information about the property's accessor methods. - if (mi->MemberType==MemberTypes::Property) - { - for each ( MethodInfo^ am in (((PropertyInfo^) mi)->GetAccessors()) ) - { - Display(indent+1, "Accessor method: {0}", gcnew array {am}); - } - } - } - // Display a formatted string indented by the specified amount. - indent -= 1; - } - indent -= 1; - } - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -// The output shown below is abbreviated. -// -//Assembly identity=Reflection, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -// Codebase=file:///C:/Reflection.exe -//Referenced assemblies: -// Name=mscorlib, Version=1.0.5000.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89 -// Name=Microsoft.VisualBasic, Version=7.0.5000.0, Culture=, PublicKey token=B0-3F-5F-7F-11-D5-0A-3A -// -//Assembly: mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 -// Module: mscorlib.dll -// Module: prc.nlp -// Module: prcp.nlp -// Module: ksc.nlp -// Module: ctype.nlp -// Module: xjis.nlp -// Module: bopomofo.nlp -// Module: culture.nlp -// Module: region.nlp -// Module: sortkey.nlp -// Module: charinfo.nlp -// Module: big5.nlp -// Module: sorttbls.nlp -// Module: l_intl.nlp -// Module: l_except.nlp -// -// Type: System.Object -// Member: GetHashCode -// Member: Equals -// Parameter: Type=System.Object, Name=obj -// Member: ToString -// Member: Equals -// Parameter: Type=System.Object, Name=objA -// Parameter: Type=System.Object, Name=objB -// Member: ReferenceEquals -// Parameter: Type=System.Object, Name=objA -// Parameter: Type=System.Object, Name=objB -// Member: GetType -// Member: .ctor -// -// Type: System.ICloneable -// Member: Clone -// -// Type: System.Collections.IEnumerable -// Member: GetEnumerator -// Attributes: -// System.Runtime.InteropServices.DispIdAttribute -// -// Type: System.Collections.ICollection -// Member: get_IsSynchronized -// Member: get_SyncRoot -// Member: get_Count -// Member: CopyTo -// Parameter: Type=System.Array, Name=array -// Parameter: Type=System.Int32, Name=index -// Member: Count -// Accessor method: Int32 get_Count() -// Member: SyncRoot -// Accessor method: System.Object get_SyncRoot() -// Member: IsSynchronized -// Accessor method: Boolean get_IsSynchronized() -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrongNameKeyPairX/cpp/strongnamekeypairx.cpp b/snippets/cpp/VS_Snippets_CLR/StrongNameKeyPairX/cpp/strongnamekeypairx.cpp deleted file mode 100644 index 97c560511ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrongNameKeyPairX/cpp/strongnamekeypairx.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//Types:System.Reflection.StrongNameKeyPair -// -using namespace System; -using namespace System::IO; -using namespace System::Reflection; - -ref class snkX -{ -public: - static void Main() - { - // Open a file that contains a public key value. The line below - // assumes that the Strong Name tool (SN.exe) was executed from - // a command prompt as follows: - // SN.exe -k C:\Company.keys - FileStream^ fs = File::Open("C:\\Company.keys", FileMode::Open); - - // - // Construct a StrongNameKeyPair object. This object should obtain - // the public key from the Company.keys file. - StrongNameKeyPair^ k = gcnew StrongNameKeyPair(fs); - // - - // - // Display the bytes that make up the public key. - Console::WriteLine(BitConverter::ToString(k->PublicKey)); - // - - // Close the file. - fs->Close(); - } -}; - -int main() -{ - snkX::Main(); -} - -// Output will vary by user. -// -// 00-24-00-00-04-80-00-00-94-69-89-78-BB-F1-F2-71-00-00-00-34-26- -// 69-89-78-BB-F1-F2-71-00-F1-FA-F2-F9-4A-A8-5E-82-55-AB-49-4D-A6- -// ED-AB-5F-CE-DE-59-49-8D-63-01-B0-E1-BF-43-07-FA-55-D4-36-75-EE- -// 8B-83-32-39-B7-02-DE-3D-81-29-7B-E8-EA-F0-2E-78-94-96-F1-73-79- -// 69-89-78-BB-F1-F2-71-0E-4E-F4-5D-DD-A4-7F-11-54-DF-65-DE-89-23- -// 91-AD-53-E1-C0-DA-9E-0C-88-BE-AA-7B-39-20-9C-9B-55-34-26-3B-1A- -// 53-41-31-00-04-00-00-01-00-01-00-9D-F1-EA-14-4C-88-34-26-3B-1A- -// 2D-D7-A0-AB-F6-7E-B7-24-7F-87-DF-3E-97 -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/cpp/source.cpp deleted file mode 100644 index c9151536fe5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/cpp/source.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public interface class I -{ - void M(); -}; - -public ref class A -{ -public: - virtual void M() { Console::WriteLine("In method A.M"); } -}; - -// The object of this code example is to emit code equivalent to -// the following C++ code: -// -public ref class C : A, I -{ -public: - virtual void M() override - { - Console::WriteLine("Overriding A.M from C.M"); - } - -private: - // In order to provide a different implementation from C.M when - // emitting the following explicit interface implementation, - // it is necessary to use a MethodImpl. - // - virtual void IM() sealed = I::M - { - Console::WriteLine("The I::M implementation of C"); - } -}; - -void main() -{ - String^ name = "DefineMethodOverrideExample"; - AssemblyName^ asmName = gcnew AssemblyName(name); - AssemblyBuilder^ ab = - AppDomain::CurrentDomain->DefineDynamicAssembly( - asmName, AssemblyBuilderAccess::RunAndSave); - ModuleBuilder^ mb = ab->DefineDynamicModule(name, name + ".dll"); - - TypeBuilder^ tb = - mb->DefineType("C", TypeAttributes::Public, A::typeid); - tb->AddInterfaceImplementation(I::typeid); - - // Build the method body for the explicit interface - // implementation. The name used for the method body - // can be anything. Here, it is the name of the method, - // qualified by the interface name. - // - MethodBuilder^ mbIM = tb->DefineMethod("I.M", - MethodAttributes::Private | MethodAttributes::HideBySig | - MethodAttributes::NewSlot | MethodAttributes::Virtual | - MethodAttributes::Final, - nullptr, - Type::EmptyTypes); - ILGenerator^ il = mbIM->GetILGenerator(); - il->Emit(OpCodes::Ldstr, "The I.M implementation of C"); - il->Emit(OpCodes::Call, Console::typeid->GetMethod("WriteLine", - gcnew array { String::typeid })); - il->Emit(OpCodes::Ret); - - // DefineMethodOverride is used to associate the method - // body with the interface method that is being implemented. - // - tb->DefineMethodOverride(mbIM, I::typeid->GetMethod("M")); - - MethodBuilder^ mbM = tb->DefineMethod("M", - MethodAttributes::Public | MethodAttributes::ReuseSlot | - MethodAttributes::Virtual | MethodAttributes::HideBySig, - nullptr, - Type::EmptyTypes); - il = mbM->GetILGenerator(); - il->Emit(OpCodes::Ldstr, "Overriding A.M from C.M"); - il->Emit(OpCodes::Call, Console::typeid->GetMethod("WriteLine", - gcnew array { String::typeid })); - il->Emit(OpCodes::Ret); - - Type^ tc = tb->CreateType(); - - // Save the emitted assembly, to examine with Ildasm.exe. - ab->Save(name + ".dll"); - - Object^ test = Activator::CreateInstance(tc); - - MethodInfo^ mi = I::typeid->GetMethod("M"); - mi->Invoke(test, nullptr); - - mi = A::typeid->GetMethod("M"); - mi->Invoke(test, nullptr); -} - -/* This code example produces the following output: - -The I.M implementation of C -Overriding A.M from C.M - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/CPP/typebuilder_adddeclarativesecurity.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/CPP/typebuilder_adddeclarativesecurity.cpp deleted file mode 100644 index 6ea81968d31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/CPP/typebuilder_adddeclarativesecurity.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// System::Reflection::Emit::TypeBuilder.AddDeclarativeSecurity -/* The following example demonstrates method AddDeclarativeSecurity -of 'TypeBuilder' class. -The program creates a dynamic assembly and a type in it having support for declarative security. -It demands an Environmentpermission read access on 'TEMP'. -Caller (main) is able to create an instance successfully with -default permission(as local machine executes with full trust permission set). -*/ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Security; -using namespace System::Security::Permissions; - -int main() -{ - // Create a simple name for the assembly; create the assembly and module. - AssemblyName^ myAssemblyName = gcnew AssemblyName("EmittedAssembly"); - AssemblyBuilder^ myAssemblyBuilder = - AppDomain::CurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ myModuleBuilder = - myAssemblyBuilder->DefineDynamicModule( "EmittedAssembly", "EmittedAssembly.dll"); - - // Define a public class named "MyDynamicClass" in the assembly. - TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "MyDynamicClass", TypeAttributes::Public ); - - - // Create a permission set and add a security permission - // with the ControlEvidence flag. - // - PermissionSet^ myPermissionSet = gcnew PermissionSet(PermissionState::None); - myPermissionSet->AddPermission( - gcnew SecurityPermission(SecurityPermissionFlag::ControlEvidence)); - - // Add the permission set to the MyDynamicClass type, - // as a declarative security demand. - // - myTypeBuilder->AddDeclarativeSecurity(SecurityAction::Demand, myPermissionSet); - - - Type^ myType = myTypeBuilder->CreateType(); - myAssemblyBuilder->Save("EmittedAssembly.dll"); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp deleted file mode 100644 index c19e9adcb71..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// System.Reflection.Emit.TypeBuilder.DefineNestedType(string, TypeAttributes, Type, Type[]) -// System.Reflection.Emit.TypeBuilder.DefineMethodOverride(MethodInfo, MethodInfo) -// System.Reflection.Emit.TypeBuilder.DefineMethod(string, MethodAttributes,Type,Type[]) -/* -The following program demonstrates the 'DefineNestedType', 'DefineMethodOverride' and -'DefineMethod' methods of 'TypeBuilder' class. It builds an assembly by defining -'MyHelloWorld' type. 'MyHelloWorld' class has a nested class 'MyNestedClass' which extends -'EmittedClass' and implements 'IMyInterface' interface. Then it creates and instance of -'MyNestedClass' type and calls the 'HelloMethod' using 'IMyInterface' object and -results are displayed to the console. -*/ -// -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -public interface class IMyInterface -{ - String^ HelloMethod( String^ parameter ); -}; - -public ref class EmittedClass -{ -public: - // Because this method calls Activator::CreateInstance, - // it requires full trust. - [System::Security::Permissions::PermissionSetAttribute - (System::Security::Permissions::SecurityAction::Demand, Name = "FullTrust")] - static void Main() - { - Type^ myNestedClassType = CreateCallee( Thread::GetDomain() ); - - // Create an instance of 'MyNestedClass'. - IMyInterface^ myInterface = dynamic_cast(Activator::CreateInstance( myNestedClassType )); - Console::WriteLine( myInterface->HelloMethod( "Bill" ) ); - } - -private: - - // Create the callee transient dynamic assembly. - static Type^ CreateCallee( AppDomain^ myAppDomain ) - { - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedClass"; - - // Create the callee dynamic assembly. - AssemblyBuilder^ myAssembly = myAppDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module in the callee assembly. - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "MyHelloWorld". - TypeBuilder^ myHelloWorldType = myModule->DefineType( "MyHelloWorld", TypeAttributes::Public ); - - // Define a public nested class named 'MyNestedClass'. - array^temp0 = {IMyInterface::typeid}; - TypeBuilder^ myNestedClassType = myHelloWorldType->DefineNestedType( "MyNestedClass", TypeAttributes::NestedPublic, EmittedClass::typeid, temp0 ); - - // Implement 'IMyInterface' interface. - myNestedClassType->AddInterfaceImplementation( IMyInterface::typeid ); - - // Define 'HelloMethod' of 'IMyInterface'. - array^temp1 = {String::typeid}; - MethodBuilder^ myHelloMethod = myNestedClassType->DefineMethod( "HelloMethod", static_cast(MethodAttributes::Public | MethodAttributes::Virtual), String::typeid, temp1 ); - - // Generate IL for 'GetGreeting' method. - ILGenerator^ myMethodIL = myHelloMethod->GetILGenerator(); - myMethodIL->Emit( OpCodes::Ldstr, "Hi! " ); - myMethodIL->Emit( OpCodes::Ldarg_1 ); - array^temp2 = {String::typeid,String::typeid}; - MethodInfo^ infoMethod = String::typeid->GetMethod( "Concat", temp2 ); - myMethodIL->Emit( OpCodes::Call, infoMethod ); - myMethodIL->Emit( OpCodes::Ret ); - MethodInfo^ myHelloMethodInfo = IMyInterface::typeid->GetMethod( "HelloMethod" ); - - // Implement 'HelloMethod' of 'IMyInterface'. - myNestedClassType->DefineMethodOverride( myHelloMethod, myHelloMethodInfo ); - - // Create 'MyHelloWorld' type. - Type^ myType = myHelloWorldType->CreateType(); - - // Create 'MyNestedClass' type. - return myNestedClassType->CreateType(); - } -}; - -int main() -{ - EmittedClass::Main(); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp deleted file mode 100644 index 15212e47056..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -using namespace System; -using namespace System::Text; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; - - void main() - { - // Create the AssemblyBuilder. - AssemblyName^ asmName = gcnew AssemblyName("PInvokeTest"); - AssemblyBuilder^ dynamicAsm = AppDomain::CurrentDomain->DefineDynamicAssembly( - asmName, - AssemblyBuilderAccess::RunAndSave - ); - - // Create the module. - ModuleBuilder^ dynamicMod = - dynamicAsm->DefineDynamicModule(asmName->Name, asmName->Name + ".dll"); - - // Create the TypeBuilder for the class that will contain the - // signature for the PInvoke call. - TypeBuilder^ tb = dynamicMod->DefineType( - "MyType", - TypeAttributes::Public | TypeAttributes::UnicodeClass - ); - - MethodBuilder^ mb = tb->DefinePInvokeMethod( - "GetTickCount", - "Kernel32.dll", - MethodAttributes::Public | MethodAttributes::Static | MethodAttributes::PinvokeImpl, - CallingConventions::Standard, - int::typeid, - Type::EmptyTypes, - CallingConvention::Winapi, - CharSet::Ansi); - - // Add PreserveSig to the method implementation flags. NOTE: If this line - // is commented out, the return value will be zero when the method is - // invoked. - mb->SetImplementationFlags( - mb->GetMethodImplementationFlags() | MethodImplAttributes::PreserveSig); - - // The PInvoke method does not have a method body. - - // Create the class and test the method. - Type^ t = tb->CreateType(); - - MethodInfo^ mi = t->GetMethod("GetTickCount"); - Console::WriteLine("Testing PInvoke method..."); - Console::WriteLine("GetTickCount returned: {0}", mi->Invoke(nullptr, nullptr)); - - // Produce the .dll file. - Console::WriteLine("Saving: " + asmName->Name + ".dll"); - dynamicAsm->Save(asmName->Name + ".dll"); - }; - -/* This example produces output similar to the following: - -Testing PInvoke method... -GetTickCount returned: 1314410994 -Saving: PInvokeTest.dll - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/CPP/typebuilder_defineuninitializeddata.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/CPP/typebuilder_defineuninitializeddata.cpp deleted file mode 100644 index ad88d21ef91..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/CPP/typebuilder_defineuninitializeddata.cpp +++ /dev/null @@ -1,98 +0,0 @@ - - -// System::Reflection::Emit::TypeBuilder::DefineUninitializedData(string,int,FieldAttributes) -/* -The following program demonstrates the 'DefineUninitializedData' -method of 'TypeBuilder' class. It builds an assembly by defining 'MyHelloWorld' type and -it has 'MyGreeting' field. Then it displays the initial value of 'MyGreeting' -field to the console. -*/ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] - static void Main() - { - Type^ myHelloWorldType = CreateCallee( Thread::GetDomain() ); - Object^ myHelloWorldInstance = Activator::CreateInstance( myHelloWorldType ); - FieldInfo^ myGreetingFieldInfo = myHelloWorldType->GetField( "MyGreeting" ); - Object^ oval = Activator::CreateInstance( myGreetingFieldInfo->FieldType ); - IntPtr myIntPtr = Marshal::AllocHGlobal( 4 ); - Random^ rand = gcnew Random; - int iTempSeed = rand->Next(); - array^bINITBYTE = GetRandBytes( iTempSeed, 4 ); - IntPtr intptrTemp = myIntPtr; - for ( int j = 0; j < 4; j++ ) - { - Marshal::WriteByte( myIntPtr, bINITBYTE[ j ] ); - myIntPtr = (IntPtr)((int)myIntPtr + 1); - - } - myIntPtr = intptrTemp; - Object^ oValNew = Marshal::PtrToStructure( myIntPtr, myGreetingFieldInfo->FieldType ); - Marshal::FreeHGlobal( myIntPtr ); - myIntPtr = Marshal::AllocHGlobal( 4 ); - Object^ myObj = myGreetingFieldInfo->GetValue( myHelloWorldInstance ); - Marshal::StructureToPtr( myObj, myIntPtr, true ); - intptrTemp = myIntPtr; - Console::WriteLine( "The value of 'MyGreeting' field : " ); - for ( int j = 0; j < 4; j++ ) - { - Marshal::WriteByte( myIntPtr, bINITBYTE[ j ] ); - Console::WriteLine( bINITBYTE[ j ] ); - myIntPtr = (IntPtr)((int)myIntPtr + 1); - - } - } - - -private: - static array^ GetRandBytes( int iRandSeed, int iSize ) - { - array^barr = gcnew array(iSize); - Random^ randTemp = gcnew Random( iRandSeed ); - randTemp->NextBytes( barr ); - return barr; - } - - - // Create the callee transient dynamic assembly. - static Type^ CreateCallee( AppDomain^ myDomain ) - { - - // Create a simple name for the callee assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedClass"; - - // Create the callee dynamic assembly. - AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module in the callee assembly. - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "MyHelloWorld" - TypeBuilder^ myHelloWorldType = myModule->DefineType( "MyHelloWorld", TypeAttributes::Public ); - - // Define a 'MyGreeting' field and initialize it. - FieldBuilder^ myFieldBuilder = myHelloWorldType->DefineUninitializedData( "MyGreeting", 4, FieldAttributes::Public ); - - // Create the 'MyHelloWorld' class. - return (myHelloWorldType->CreateType()); - } - -}; - -int main() -{ - Example::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_GetEvents1/CPP/typebuilder_getevents1.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_GetEvents1/CPP/typebuilder_getevents1.cpp deleted file mode 100644 index e35e284ec04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_GetEvents1/CPP/typebuilder_getevents1.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// System::Reflection::Emit::TypeBuilder.GetEvents(BindingFlags) -/* -The program demonstrates the 'GetEvents' method of the 'TypeBuilder' class. -It builds an assembly by defining 'HelloWorld' type and creates a 'Click' and -'MouseUp' events on the type. Then displays all events to the Console. -*/ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -ref class MyApplication -{ -private: - delegate void MyEvent( Object^ temp ); - -public: - - // Create the callee transient dynamic assembly. - static TypeBuilder^ CreateCallee( AppDomain^ myDomain ) - { - AssemblyName^ assemblyName = gcnew AssemblyName; - assemblyName->Name = "EmittedAssembly"; - - // Create the callee dynamic assembly. - AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( assemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - array^typeArray = gcnew array(1); - typeArray[ 0 ] = Object::typeid; - MethodBuilder^ myMethod1 = helloWorldClass->DefineMethod( "OnClick", MethodAttributes::Public, void::typeid, typeArray ); - ILGenerator^ methodIL1 = myMethod1->GetILGenerator(); - methodIL1->Emit( OpCodes::Ret ); - MethodBuilder^ myMethod2 = helloWorldClass->DefineMethod( "OnMouseUp", MethodAttributes::Public, void::typeid, typeArray ); - ILGenerator^ methodIL2 = myMethod2->GetILGenerator(); - methodIL2->Emit( OpCodes::Ret ); - - // Create the events. - EventBuilder^ myEvent1 = helloWorldClass->DefineEvent( "Click", EventAttributes::None, MyEvent::typeid ); - myEvent1->SetRaiseMethod( myMethod1 ); - EventBuilder^ myEvent2 = helloWorldClass->DefineEvent( "MouseUp", EventAttributes::None, MyEvent::typeid ); - myEvent2->SetRaiseMethod( myMethod2 ); - helloWorldClass->CreateType(); - return (helloWorldClass); - } -}; - -int main() -{ - TypeBuilder^ helloWorldClass = MyApplication::CreateCallee( Thread::GetDomain() ); - array^info = helloWorldClass->GetEvents( static_cast(BindingFlags::Public | BindingFlags::Instance) ); - Console::WriteLine( "'HelloWorld' type has following events :" ); - for ( int i = 0; i < info->Length; i++ ) - Console::WriteLine( info[ i ]->Name ); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Properties1/CPP/typebuilder_properties.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Properties1/CPP/typebuilder_properties.cpp deleted file mode 100644 index a6d8a10bd75..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Properties1/CPP/typebuilder_properties.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// System.Reflection.Emit.TypeBuilder.FullName -// System.Reflection.Emit.TypeBuilder.GetConstructors -// System.Reflection.Emit.TypeBuilder.DefineTypeInitializer -/* -The following program demonstrates DefineTypeInitializer and 'GetConstructors' methods and -the 'FullName' property of 'TypeBuilder' class. It builds an assembly by defining 'HelloWorld' -type. It also defines a constructor for 'HelloWorld' type. Then it displays the -full name of type and its constructors to the console. -*/ -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// -// -// -// Create the callee transient dynamic assembly. -TypeBuilder^ CreateCallee( AppDomain^ myDomain ) -{ - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - - // Create the callee dynamic assembly. - AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module named "CalleeModule" in the callee assembly. - ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( "EmittedModule" ); - - // Define a public class named "HelloWorld" in the assembly. - TypeBuilder^ helloWorldClass = myModule->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Define a private String field named "Greeting" in the type. - FieldBuilder^ greetingField = helloWorldClass->DefineField( "Greeting", String::typeid, FieldAttributes::Private ); - - // Create the constructor. - ConstructorBuilder^ constructor = helloWorldClass->DefineTypeInitializer(); - - // Generate IL for the method. The constructor calls its base class - // constructor. The constructor stores its argument in the private field. - ILGenerator^ constructorIL = constructor->GetILGenerator(); - constructorIL->Emit( OpCodes::Ldarg_0 ); - ConstructorInfo^ superConstructor = Object::typeid->GetConstructor( gcnew array(0) ); - constructorIL->Emit( OpCodes::Call, superConstructor ); - constructorIL->Emit( OpCodes::Ldarg_0 ); - constructorIL->Emit( OpCodes::Ldarg_1 ); - constructorIL->Emit( OpCodes::Stfld, greetingField ); - constructorIL->Emit( OpCodes::Ret ); - helloWorldClass->CreateType(); - return (helloWorldClass); -} - -int main() -{ - // Create the "HelloWorld" class - TypeBuilder^ helloWorldClass = CreateCallee( Thread::GetDomain() ); - Console::WriteLine( "Full Name : {0}", helloWorldClass->FullName ); - Console::WriteLine( "Constructors :" ); - array^info = helloWorldClass->GetConstructors( static_cast(BindingFlags::Public | BindingFlags::Instance) ); - for ( int index = 0; index < info->Length; index++ ) - Console::WriteLine( info[ index ] ); -} -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp b/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp deleted file mode 100644 index 073d9d96852..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// System.Reflection.Emit.TypeBuilder.DefineField() -// System.Reflection.Emit.TypeBuilder.DefineConstructor() -// System.Reflection.Emit.TypeBuilder.AddInterfaceImplementation() -// System.Reflection.Emit.TypeBuilder.BaseType - -/* The following program demonstrates the property 'BaseType' and methods - 'DefineField','DefineConstructor','AddInterfaceImplementation' of the - class 'TypeBuilder'. - The program creates a dynamic assembly and a type within it called as - 'HelloWorld' This defines a field and implements an interface. -*/ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Threading; - -// Declare the interface. -interface class IHello -{ - void SayHello(); -}; - -// Create the transient dynamic assembly. -Type^ CreateDynamicAssembly( AppDomain^ myAppDomain, AssemblyBuilderAccess myAccess ) -{ - // Create a simple name for assembly. - AssemblyName^ myAssemblyName = gcnew AssemblyName; - myAssemblyName->Name = "EmittedAssembly"; - // Create the dynamic assembly. - AssemblyBuilder^ myAssemblyBuilder = myAppDomain->DefineDynamicAssembly( myAssemblyName, myAccess ); - // Create a dynamic module named 'CalleeModule' in the assembly. - ModuleBuilder^ myModuleBuilder; - myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "EmittedModule", - "EmittedModule.mod" ); -// -// - // Define a public class named 'myHelloWorld' in the assembly. - TypeBuilder^ helloWorldTypeBuilder = - myModuleBuilder->DefineType( "HelloWorld", TypeAttributes::Public ); - - // Get base type. - Console::WriteLine( "Base Type :{0}", helloWorldTypeBuilder->BaseType->Name ); -// - - // Define 'myGreetingField' field. - FieldBuilder^ myGreetingField = - helloWorldTypeBuilder->DefineField( "myGreeting", String::typeid, - FieldAttributes::Public ); -// - -// - // Define the constructor. - array^ constructorArgs = {String::typeid}; - ConstructorBuilder^ myConstructorBuilder = - helloWorldTypeBuilder->DefineConstructor( MethodAttributes::Public, - CallingConventions::Standard, constructorArgs ); - // Generate IL for the method. The constructor stores its argument in the private field. - ILGenerator^ myConstructorIL = myConstructorBuilder->GetILGenerator(); - myConstructorIL->Emit( OpCodes::Ldarg_0 ); - myConstructorIL->Emit( OpCodes::Ldarg_1 ); - myConstructorIL->Emit( OpCodes::Stfld, myGreetingField ); - myConstructorIL->Emit( OpCodes::Ret ); -// - -// - // Mark the class as implementing 'IHello' interface. - helloWorldTypeBuilder->AddInterfaceImplementation( IHello::typeid ); - MethodBuilder^ myMethodBuilder = - helloWorldTypeBuilder->DefineMethod( "SayHello", - (MethodAttributes)(MethodAttributes::Public | MethodAttributes::Virtual), - nullptr, - nullptr ); - // Generate IL for 'SayHello' method. - ILGenerator^ myMethodIL = myMethodBuilder->GetILGenerator(); - myMethodIL->EmitWriteLine( myGreetingField ); - myMethodIL->Emit( OpCodes::Ret ); - MethodInfo^ sayHelloMethod = IHello::typeid->GetMethod( "SayHello" ); - helloWorldTypeBuilder->DefineMethodOverride( myMethodBuilder, sayHelloMethod ); -// - return (helloWorldTypeBuilder->CreateType()); -} - -int main() -{ - Console::WriteLine( "TypeBuilder Sample" ); - Console::WriteLine( "----------------------" ); - - // Create 'helloWorldType' . - Type^ helloWorldType = CreateDynamicAssembly( Thread::GetDomain(), AssemblyBuilderAccess::RunAndSave ); - - // Create an instance of 'HelloWorld' class. - array^ temp0 = {"Called HelloWorld"}; - Object^ helloWorld = Activator::CreateInstance( helloWorldType, temp0 ); - - // Invoke 'SayHello' method. - helloWorldType->InvokeMember( "SayHello", static_cast(BindingFlags::Default | BindingFlags::InvokeMethod), nullptr, helloWorld, nullptr ); - - // Get defined field in the class. - Console::WriteLine( "Defined Field :{0}", helloWorldType->GetField( "myGreeting" )->Name ); - AssemblyBuilder^ myAssemblyBuilder = dynamic_cast(helloWorldType->Assembly); - myAssemblyBuilder->Save( "EmittedAssembly.dll" ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp deleted file mode 100644 index 6d911a7f1cd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -public ref class MyClass1 -{ -public: - MyClass1( int i ){} - -}; - -int main() -{ - try - { - Type^ myType = MyClass1::typeid; - array^types = gcnew array(1); - types[ 0 ] = int::typeid; - - // Get the public instance constructor that takes an integer parameter. - ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr ); - if ( constructorInfoObj != nullptr ) - { - Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " ); - Console::WriteLine( constructorInfoObj ); - } - else - { - Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." ); - } - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e->Message ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "ArgumentException: {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetDefaultMembers/CPP/type_getdefaultmembers.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetDefaultMembers/CPP/type_getdefaultmembers.cpp deleted file mode 100644 index b924dff4307..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetDefaultMembers/CPP/type_getdefaultmembers.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::IO; - -[DefaultMemberAttribute("Age")] -public ref class MyClass -{ -public: - void Name( String^ s ){} - - - property int Age - { - int get() - { - return 20; - } - - } - -}; - -int main() -{ - try - { - Type^ myType = MyClass::typeid; - array^memberInfoArray = myType->GetDefaultMembers(); - if ( memberInfoArray->Length > 0 ) - { - System::Collections::IEnumerator^ myEnum = memberInfoArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MemberInfo^ memberInfoObj = safe_cast(myEnum->Current); - Console::WriteLine( "The default member name is: {0}", memberInfoObj ); - } - } - else - { - Console::WriteLine( "No default members are available." ); - } - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "InvalidOperationException: {0}", e->Message ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "IOException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp b/snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp deleted file mode 100644 index 552ea842e18..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -using namespace System::Windows::Forms; - -int main() -{ - try - { - // Creates a bitmask based on BindingFlags. - BindingFlags myBindingFlags = static_cast(BindingFlags::Instance | BindingFlags::Public | BindingFlags::NonPublic); - Type^ myTypeBindingFlags = System::Windows::Forms::Button::typeid; - EventInfo^ myEventBindingFlags = myTypeBindingFlags->GetEvent( "Click", myBindingFlags ); - if ( myEventBindingFlags != nullptr ) - { - Console::WriteLine( "Looking for the Click event in the Button class with the specified BindingFlags." ); - Console::WriteLine( myEventBindingFlags ); - } - else - Console::WriteLine( "The Click event is not available with the Button class." ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised : {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/CPP/source.cpp deleted file mode 100644 index 2b2375d4317..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -namespace Ambiguity -{ - ref class Myambiguous - { - public: - - //The first overload is typed to an Int32 - static void Mymethod(Int32 number) - { - Console::WriteLine("I am from 'Int32' method"); - } - - //The second overload is typed to a String^ - static void Mymethod(String^ alpha) - { - Console::WriteLine("I am from 'String^' method."); - } - - static void Main() - { - try - { - //The following does not cause as exception - Mymethod(2); // goes to Mymethod (Int32) - Mymethod("3"); // goes to Mymethod (String*) - Type^ Mytype = Type::GetType("Ambiguity.Myambiguous"); - array^temp0 = {Int32::typeid}; - MethodInfo^ Mymethodinfo32 = Mytype->GetMethod("Mymethod", temp0); - array^temp1 = {System::String::typeid}; - MethodInfo^ Mymethodinfostr = Mytype->GetMethod("Mymethod", temp1); - - //Invoke a method, utilizing a Int32 integer - array^temp2 = {2}; - Mymethodinfo32->Invoke(nullptr, temp2); - - //Invoke the method utilizing a String^ - array^temp3 = {"1"}; - Mymethodinfostr->Invoke(nullptr, temp3); - - //The following line causes an ambiguous exception - MethodInfo^ Mymethodinfo = Mytype->GetMethod("Mymethod"); - } - catch (AmbiguousMatchException^ ex) - { - Console::WriteLine("\n{0}\n{1}", ex->GetType()->FullName, ex->Message); - } - catch (...) - { - Console::WriteLine("\nSome other exception."); - } - - return; - } - }; -} - -int main() -{ - Ambiguity::Myambiguous::Main(); -} - -//This code produces the following output: -// -// I am from 'Int32' method -// I am from 'String^' method. -// I am from 'Int32' method -// I am from 'String^' method. -// -// System.Reflection.AmbiguousMatchException -// Ambiguous match found. -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp deleted file mode 100644 index bc8df83efca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -using namespace System; - -void PrintValues(array^myArr); -void PrintValues(array^myArr); -void main() -{ - // Creates and initializes a new int array and a new Object array. - array^myIntArray = { 1,2,3,4,5 }; - array^myObjArray = { 26,27,28,29,30 }; - - // Prints the initial values of both arrays. - Console::WriteLine("Initially:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); - - // Copies the first two elements from the int array to the Object array. - System::Array::Copy(myIntArray, myObjArray, 2); - - // Prints the values of the modified arrays. - Console::WriteLine("\nAfter copying the first two elements of the int array to the Object array:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); - - // Copies the last two elements from the Object array to the int array. - System::Array::Copy(myObjArray, myObjArray->GetUpperBound(0) - 1, myIntArray, myIntArray->GetUpperBound(0) - 1, 2); - - // Prints the values of the modified arrays. - Console::WriteLine("\nAfter copying the last two elements of the Object array to the int array:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); -} - -void PrintValues(array^myArr) -{ - for (int i = 0; i < myArr->Length; i++) - { - Console::Write("\t{0}", myArr[i]); - - } - Console::WriteLine(); -} - -void PrintValues(array^myArr) -{ - for (int i = 0; i < myArr->Length; i++) - { - Console::Write("\t{0}", myArr[i]); - - } - Console::WriteLine(); -} - - -/* -This code produces the following output. - -Initially: -int array: 1 2 3 4 5 -Object array: 26 27 28 29 30 -After copying the first two elements of the int array to the Object array: -int array: 1 2 3 4 5 -Object array: 1 2 28 29 30 -After copying the last two elements of the Object array to the int array: -int array: 1 2 3 29 30 -Object array: 1 2 28 29 30 -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp deleted file mode 100644 index 10f90aa8ae1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -void PrintValues(Array^ myArr); -void main() -{ - // Creates and initializes a new three-dimensional Array instance of type Int32. - Array^ myArr = Array::CreateInstance( Int32::typeid, 2, 3, 4 ); - for ( int i = myArr->GetLowerBound( 0 ); i <= myArr->GetUpperBound( 0 ); i++ ) - { - for ( int j = myArr->GetLowerBound( 1 ); j <= myArr->GetUpperBound( 1 ); j++ ) - { - for ( int k = myArr->GetLowerBound( 2 ); k <= myArr->GetUpperBound( 2 ); k++ ) - myArr->SetValue( (i * 100) + (j * 10) + k, i, j, k ); - - } - } - - // Displays the properties of the Array. - Console::WriteLine( "The Array instance has {0} dimension(s) and a total of {1} elements.", myArr->Rank, myArr->Length ); - Console::WriteLine( "\tLength\tLower\tUpper" ); - for ( int i = 0; i < myArr->Rank; i++ ) - { - Console::Write( "{0}:\t{1}", i, myArr->GetLength( i ) ); - Console::WriteLine( "\t{0}\t{1}", myArr->GetLowerBound( i ), myArr->GetUpperBound( i ) ); - - } - Console::WriteLine( "The Array instance contains the following values:" ); - PrintValues( myArr ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - i++; - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Array instance has 3 dimension(s) and a total of 24 elements. - Length Lower Upper - 0: 2 0 1 - 1: 3 0 2 - 2: 4 0 3 - The Array instance contains the following values: - 0 1 2 3 - 10 11 12 13 - 20 21 22 23 - 100 101 102 103 - 110 111 112 113 - 120 121 122 123 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp deleted file mode 100644 index 40db20d5eb6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -using namespace System; - -public ref class SamplesArray -{ -public: - static void Main() - { - // Creates and initializes a new Array. - Array^ myIntArray = Array::CreateInstance(Int32::typeid, 5); - - myIntArray->SetValue(8, 0); - myIntArray->SetValue(2, 1); - myIntArray->SetValue(6, 2); - myIntArray->SetValue(3, 3); - myIntArray->SetValue(7, 4); - - // Do the required sort first - Array::Sort(myIntArray); - - // Displays the values of the Array. - Console::WriteLine("The Int32 array contains the following:"); - PrintValues(myIntArray); - - // Locates a specific object that does not exist in the Array. - Object^ myObjectOdd = 1; - FindMyObject(myIntArray, myObjectOdd); - - // Locates an object that exists in the Array. - Object^ myObjectEven = 6; - FindMyObject(myIntArray, myObjectEven); - } - - static void FindMyObject(Array^ myArr, Object^ myObject) - { - int myIndex = Array::BinarySearch(myArr, myObject); - if (myIndex < 0) - { - Console::WriteLine("The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex); - } - else - { - Console::WriteLine("The object to search for ({0}) is at index {1}.", myObject, myIndex); - } - } - - static void PrintValues(Array^ myArr) - { - int i = 0; - int cols = myArr->GetLength(myArr->Rank - 1); - for each (Object^ o in myArr) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - Console::Write("\t{0}", o); - } - Console::WriteLine(); - } -}; - -int main() -{ - SamplesArray::Main(); -} -// This code produces the following output. -// -//The Int32 array contains the following: -// 2 3 6 7 8 -//The object to search for (1) is not found. The next larger object is at index 0 -// -//The object to search for (6) is at index 2. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp deleted file mode 100644 index 16882781c33..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - - // Creates and initializes a new Array instance of type Int32. - Array^ myIntArray = Array::CreateInstance( Type::GetType( "System.Int32" ), 5 ); - for ( int i = myIntArray->GetLowerBound( 0 ); i <= myIntArray->GetUpperBound( 0 ); i++ ) - myIntArray->SetValue( i + 1, i ); - - // Creates and initializes a new Array instance of type Object. - Array^ myObjArray = Array::CreateInstance( Type::GetType( "System.Object" ), 5 ); - for ( int i = myObjArray->GetLowerBound( 0 ); i <= myObjArray->GetUpperBound( 0 ); i++ ) - myObjArray->SetValue( i + 26, i ); - - // Displays the initial values of both arrays. - Console::WriteLine( "Int32 array:" ); - PrintValues( myIntArray ); - Console::WriteLine( "Object array:" ); - PrintValues( myObjArray ); - - // Copies the first element from the Int32 array to the Object array. - Array::Copy( myIntArray, myIntArray->GetLowerBound( 0 ), myObjArray, myObjArray->GetLowerBound( 0 ), 1 ); - - // Copies the last two elements from the Object array to the Int32 array. - Array::Copy( myObjArray, myObjArray->GetUpperBound( 0 ) - 1, myIntArray, myIntArray->GetUpperBound( 0 ) - 1, 2 ); - - // Displays the values of the modified arrays. - Console::WriteLine( "Int32 array - Last two elements should now be the same as Object array:" ); - PrintValues( myIntArray ); - Console::WriteLine( "Object array - First element should now be the same as Int32 array:" ); - PrintValues( myObjArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Int32 array: - 1 2 3 4 5 - Object array: - 26 27 28 29 30 - Int32 array - Last two elements should now be the same as Object array: - 1 2 3 29 30 - Object array - First element should now be the same as Int32 array: - 1 27 28 29 30 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 2caab9082ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -using namespace System; - -void main() -{ - // Creates and initializes two new Array instances. - Array^ mySourceArray = Array::CreateInstance(String::typeid, 6); - mySourceArray->SetValue("three", 0); - mySourceArray->SetValue("napping", 1); - mySourceArray->SetValue("cats", 2); - mySourceArray->SetValue("in", 3); - mySourceArray->SetValue("the", 4); - mySourceArray->SetValue("barn", 5); - Array^ myTargetArray = Array::CreateInstance(String::typeid, 15); - myTargetArray->SetValue("The", 0); - myTargetArray->SetValue("quick", 1); - myTargetArray->SetValue("brown", 2); - myTargetArray->SetValue("fox", 3); - myTargetArray->SetValue("jumps", 4); - myTargetArray->SetValue("over", 5); - myTargetArray->SetValue("the", 6); - myTargetArray->SetValue("lazy", 7); - myTargetArray->SetValue("dog", 8); - - // Displays the values of the Array. - Console::WriteLine( "The target Array instance contains the following (before and after copying):"); - PrintValues(myTargetArray); - - // Copies the source Array to the target Array, starting at index 6. - mySourceArray->CopyTo(myTargetArray, 6); - - // Displays the values of the Array. - PrintValues(myTargetArray); -} - -void PrintValues(Array^ myArr) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength(myArr->Rank - 1); - while (myEnumerator->MoveNext()) - { - if (i < cols) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( " {0}", myEnumerator->Current); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array instance contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp deleted file mode 100644 index ca74d220df4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -using namespace System; - -void main() -{ - // Creates and initializes the source Array. - Array^ myArrayZero = Array::CreateInstance(String::typeid, 3); - myArrayZero->SetValue("zero", 0); - myArrayZero->SetValue("one", 1); - - // Displays the source Array. - Console::WriteLine("The array with lowbound=0 contains:"); - PrintIndexAndValues(myArrayZero); - - // Creates and initializes the target Array. - array^myArrLen = {4}; - array^myArrLow = {2}; - Array^ myArrayTwo = Array::CreateInstance(String::typeid, myArrLen, myArrLow); - myArrayTwo->SetValue("two", 2); - myArrayTwo->SetValue("three", 3); - myArrayTwo->SetValue("four", 4); - myArrayTwo->SetValue("five", 5); - - // Displays the target Array. - Console::WriteLine("The array with lowbound=2 contains:"); - PrintIndexAndValues(myArrayTwo); - - // Copy from the array with lowbound=0 to the array with lowbound=2. - myArrayZero->CopyTo(myArrayTwo, 3); - - // Displays the modified target Array. - Console::WriteLine("\nAfter copying at relative index 1:"); - PrintIndexAndValues(myArrayTwo); -} - -void PrintIndexAndValues(Array^ myArray) -{ - for (int i = myArray->GetLowerBound(0); i <= myArray->GetUpperBound(0); i++) - Console::WriteLine("\t[{0}]:\t{1}", i, myArray->GetValue(i)); -} - -/* - This code produces the following output. - - The array with lowbound=0 contains: - [0]: zero - [1]: one - [2]: - The array with lowbound=2 contains: - [2]: two - [3]: three - [4]: four - [5]: five - - After copying at relative index 1: - [2]: two - [3]: zero - [4]: one - [5]: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp deleted file mode 100644 index 6fb07cb3bf1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a one-dimensional Array instance of type Int32. - Array^ my1DArray = Array::CreateInstance( Int32::typeid, 5 ); - for ( int i = my1DArray->GetLowerBound( 0 ); i <= my1DArray->GetUpperBound( 0 ); i++ ) - my1DArray->SetValue( i + 1, i ); - - // Displays the values of the Array. - Console::WriteLine( "The one-dimensional Array instance contains the following values:" ); - PrintValues( my1DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The one-dimensional Array instance contains the following values: - 1 2 3 4 5 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp deleted file mode 100644 index 782e95f0280..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a two-dimensional Array instance of type String. - Array^ my2DArray = Array::CreateInstance( String::typeid, 2, 3 ); - for ( int i = my2DArray->GetLowerBound( 0 ); i <= my2DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my2DArray->GetLowerBound( 1 ); j <= my2DArray->GetUpperBound( 1 ); j++ ) - my2DArray->SetValue( String::Concat( "abc", i, j ), i, j ); - - // Displays the values of the Array. - Console::WriteLine( "The two-dimensional Array instance contains the following values:" ); - PrintValues( my2DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The two-dimensional Array instance contains the following values: - abc00 abc01 abc02 - abc10 abc11 abc12 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp deleted file mode 100644 index dfc52829993..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a three-dimensional Array instance of type Object. - Array^ my3DArray = Array::CreateInstance( Object::typeid, 2, 3, 4 ); - for ( int i = my3DArray->GetLowerBound( 0 ); i <= my3DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my3DArray->GetLowerBound( 1 ); j <= my3DArray->GetUpperBound( 1 ); j++ ) - for ( int k = my3DArray->GetLowerBound( 2 ); k <= my3DArray->GetUpperBound( 2 ); k++ ) - my3DArray->SetValue( String::Concat( "abc", i, j, k ), i, j, k ); - - // Displays the values of the Array. - Console::WriteLine( "The three-dimensional Array instance contains the following values:" ); - PrintValues( my3DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The three-dimensional Array instance contains the following values: - abc000 abc001 abc002 abc003 - abc010 abc011 abc012 abc013 - abc020 abc021 abc022 abc023 - abc100 abc101 abc102 abc103 - abc110 abc111 abc112 abc113 - abc120 abc121 abc122 abc123 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp deleted file mode 100644 index cf5aac93295..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a multidimensional Array instance of type String. - array^myLengthsArray = {2,3,4,5}; - Array^ my4DArray = Array::CreateInstance( String::typeid, myLengthsArray ); - for ( int i = my4DArray->GetLowerBound( 0 ); i <= my4DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my4DArray->GetLowerBound( 1 ); j <= my4DArray->GetUpperBound( 1 ); j++ ) - for ( int k = my4DArray->GetLowerBound( 2 ); k <= my4DArray->GetUpperBound( 2 ); k++ ) - for ( int l = my4DArray->GetLowerBound( 3 ); l <= my4DArray->GetUpperBound( 3 ); l++ ) - { - array^myIndicesArray = {i,j,k,l}; - my4DArray->SetValue( String::Concat( Convert::ToString( i ), j, k, l ), myIndicesArray ); - - } - - // Displays the values of the Array. - Console::WriteLine( "The four-dimensional Array instance contains the following values:" ); - PrintValues( my4DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The four-dimensional Array instance contains the following values: - 0000 0001 0002 0003 0004 - 0010 0011 0012 0013 0014 - 0020 0021 0022 0023 0024 - 0030 0031 0032 0033 0034 - 0100 0101 0102 0103 0104 - 0110 0111 0112 0113 0114 - 0120 0121 0122 0123 0124 - 0130 0131 0132 0133 0134 - 0200 0201 0202 0203 0204 - 0210 0211 0212 0213 0214 - 0220 0221 0222 0223 0224 - 0230 0231 0232 0233 0234 - 1000 1001 1002 1003 1004 - 1010 1011 1012 1013 1014 - 1020 1021 1022 1023 1024 - 1030 1031 1032 1033 1034 - 1100 1101 1102 1103 1104 - 1110 1111 1112 1113 1114 - 1120 1121 1122 1123 1124 - 1130 1131 1132 1133 1134 - 1200 1201 1202 1203 1204 - 1210 1211 1212 1213 1214 - 1220 1221 1222 1223 1224 - 1230 1231 1232 1233 1234 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp deleted file mode 100644 index cc1ff6dbbc9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a multidimensional Array instance of type String. - array^myLengthsArray = {3,5}; - array^myBoundsArray = {2,3}; - Array^ myArray = Array::CreateInstance( String::typeid, myLengthsArray, myBoundsArray ); - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - for ( int j = myArray->GetLowerBound( 1 ); j <= myArray->GetUpperBound( 1 ); j++ ) - { - array^myIndicesArray = {i,j}; - myArray->SetValue( String::Concat( Convert::ToString( i ), j ), myIndicesArray ); - - } - - // Displays the lower bounds and the upper bounds of each dimension. - Console::WriteLine( "Bounds:\tLower\tUpper" ); - for ( int i = 0; i < myArray->Rank; i++ ) - Console::WriteLine( "{0}:\t{1}\t{2}", i, myArray->GetLowerBound( i ), myArray->GetUpperBound( i ) ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance contains the following values:" ); - PrintValues( myArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Bounds: Lower Upper - 0: 2 4 - 1: 3 7 - The Array instance contains the following values: - 23 24 25 26 27 - 33 34 35 36 37 - 43 44 45 46 47 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp deleted file mode 100644 index 18923bcbb6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; - -void main() -{ - // Create a string array with 3 elements having the same value. - array^ strings = { "the", "quick", "brown", "fox", - "jumps", "over", "the", "lazy", "dog", - "in", "the", "barn" }; - - // Display the elements of the array. - Console::WriteLine("The array contains the following values:"); - for (int i = strings->GetLowerBound(0); i <= strings->GetUpperBound(0); i++) - Console::WriteLine(" [{0,2}]: {1}", i, strings[i]); - - // Search for the first occurrence of the duplicated value. - String^ searchString = "the"; - int index = Array::IndexOf(strings, searchString); - Console::WriteLine("The first occurrence of \"{0}\" is at index {1}.", - searchString, index); - - // Search for the first occurrence of the duplicated value in the last section of the array. - index = Array::IndexOf( strings, searchString, 4); - Console::WriteLine("The first occurrence of \"{0}\" between index 4 and the end is at index {1}.", - searchString, index); - - // Search for the first occurrence of the duplicated value in a section of the array. - int position = index + 1; - index = Array::IndexOf(strings, searchString, position, strings->GetUpperBound(0) - position + 1); - Console::WriteLine("The first occurrence of \"{0}\" between index {1} and index {2} is at index {3}.", - searchString, position, strings->GetUpperBound(0), index); -} -// The example displays the following output: -// The array contains the following values: -// [ 0]: the -// [ 1]: quick -// [ 2]: brown -// [ 3]: fox -// [ 4]: jumps -// [ 5]: over -// [ 6]: the -// [ 7]: lazy -// [ 8]: dog -// [ 9]: in -// [10]: the -// [11]: barn -// The first occurrence of "the" is at index 0. -// The first occurrence of "the" between index 4 and the end is at index 6. -// The first occurrence of "the" between index 7 and index 11 is at index 10. -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp deleted file mode 100644 index 1b8d7459315..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); - -void main() -{ - // Creates and initializes a new Array instance with three elements of the same value. - Array^ myArray = Array::CreateInstance( String::typeid, 12 ); - myArray->SetValue( "the", 0 ); - myArray->SetValue( "quick", 1 ); - myArray->SetValue( "brown", 2 ); - myArray->SetValue( "fox", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - myArray->SetValue( "in", 9 ); - myArray->SetValue( "the", 10 ); - myArray->SetValue( "barn", 11 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Searches for the last occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = Array::LastIndexOf( myArray, myString ); - Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in the first section of the Array. - myIndex = Array::LastIndexOf( myArray, myString, 8 ); - Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in a section of the Array. - // Note that the start index is greater than the end index because the search is done backward. - myIndex = Array::LastIndexOf( myArray, myString, 10, 6 ); - Console::WriteLine( "The last occurrence of \"{0}\" between index 5 and index 10 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - The last occurrence of "the" is at index 10. - The last occurrence of "the" between the start and index 8 is at index 6. - The last occurrence of "the" between index 5 and index 10 is at index 10. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp deleted file mode 100644 index 097d0727938..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); -void main() -{ - // Creates and initializes a new Array instance. - Array^ myArray = Array::CreateInstance( String::typeid, 9 ); - myArray->SetValue( "The", 0 ); - myArray->SetValue( "quick", 1 ); - myArray->SetValue( "brown", 2 ); - myArray->SetValue( "fox", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance initially contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Reverses the sort of the values of the Array. - Array::Reverse( myArray ); - - // Displays the values of the Array. - Console::WriteLine( "After reversing:" ); - PrintIndexAndValues( myArray ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance initially contains the following values: - [0]: The - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - After reversing: - [0]: dog - [1]: lazy - [2]: the - [3]: over - [4]: jumps - [5]: fox - [6]: brown - [7]: quick - [8]: The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp deleted file mode 100644 index 1f394ab0ee6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); -void main() -{ - // Creates and initializes a new Array instance. - Array^ myArray = Array::CreateInstance( String::typeid, 9 ); - myArray->SetValue( "The", 0 ); - myArray->SetValue( "QUICK", 1 ); - myArray->SetValue( "BROWN", 2 ); - myArray->SetValue( "FOX", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance initially contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Reverses the sort of the values of the Array. - Array::Reverse( myArray, 1, 3 ); - - // Displays the values of the Array. - Console::WriteLine( "After reversing:" ); - PrintIndexAndValues( myArray ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance initially contains the following values: - [0]: The - [1]: QUICK - [2]: BROWN - [3]: FOX - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - After reversing: - [0]: The - [1]: FOX - [2]: BROWN - [3]: QUICK - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/CPP/source.cpp deleted file mode 100644 index ecaba9d9d0b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Assembly^ mainAssembly = Assembly::GetExecutingAssembly(); - Console::WriteLine( "The executing assembly is {0}.", mainAssembly ); - array^mods = mainAssembly->GetModules(); - Console::WriteLine( "\tModules in the assembly:" ); - for ( int i = 0; i < mods->Length; i++ ) - Console::WriteLine( "\t{0}", mods[ i ] ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp deleted file mode 100644 index 2aa6055f25c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -#using - -using namespace System; - -// -namespace InteropServices -{ - [AttributeUsage(AttributeTargets::Method| - AttributeTargets::Field| - AttributeTargets::Property) - ] - public ref class DispIdAttribute: public Attribute - { - public: - DispIdAttribute( int value ) - { - // . . . - } - - property int Value - { - int get() - { - // . . . - return 0; - } - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp deleted file mode 100644 index b9c151ae5a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace Microsoft::CSharp; -CodeCompileUnit^ GetCompileUnit() -{ - - // Create a compile unit to contain a CodeDOM graph. - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // Create a namespace named TestSpace. - CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); - - // Declare a new type named TestClass. - CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); - - // Declare a new member string field named TestField. - CodeMemberField^ cmf = gcnew CodeMemberField( "System.String","TestField" ); - - // Add the field to the type. - cd->Members->Add( cmf ); - - // Declare a new member method named TestMethod. - CodeMemberMethod^ cm = gcnew CodeMemberMethod; - cm->Name = "TestMethod"; - - // Declare a string variable named TestVariable. - CodeVariableDeclarationStatement^ cvd = gcnew CodeVariableDeclarationStatement( "System.String1","TestVariable" ); - cm->Statements->Add( cvd ); - - // Cast the TestField reference expression to string and assign it to the TestVariable. - CodeAssignStatement^ ca = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "TestVariable" ),gcnew CodeCastExpression( "System.String2",gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestField" ) ) ); - - // This code can be used to generate the following code in C#: - // TestVariable = ((string)(this.TestField)); - cm->Statements->Add( ca ); - - // Add the TestMethod member to the TestClass type. - cd->Members->Add( cm ); - - // Add the TestClass type to the namespace. - cn->Types->Add( cd ); - - // Add the TestSpace namespace to the compile unit. - cu->Namespaces->Add( cn ); - return cu; -} - -int main() -{ - - // Output some program information using Console.WriteLine. - Console::WriteLine( "This program compiles a CodeDOM program that incorrectly declares multiple data" ); - Console::WriteLine( "types to demonstrate handling compiler errors programmatically." ); - Console::WriteLine( "" ); - - // Compile the CodeCompileUnit retrieved from the GetCompileUnit() method. - //CSharpCodeProvider ^ provider = gcnew Microsoft::CSharp::CSharpCodeProvider; - CodeDomProvider ^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Initialize a CompilerParameters with the options for compilation. - array^assemblies = {"System.dll"}; - CompilerParameters^ options = gcnew CompilerParameters( assemblies,"output.exe" ); - - // Compile the CodeDOM graph and store the results in a CompilerResults. - CompilerResults^ results = provider->CompileAssemblyFromDom( options, GetCompileUnit() ); - - // Compilation produces errors. Print out each error. - Console::WriteLine( "Listing errors from compilation: " ); - Console::WriteLine( "" ); - for ( int i = 0; i < results->Errors->Count; i++ ) - Console::WriteLine( results->Errors[ i ] ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp deleted file mode 100644 index 494de16ea1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -void main() -{ - DateTime dt = DateTime::Now; - array^format = {L"d",L"D",L"f",L"F",L"g",L"G",L"m",L"r",L"s",L"t",L"T",L"u",L"U",L"y",L"dddd, MMMM dd yyyy",L"ddd, MMM d \"'\"yy",L"dddd, MMMM dd",L"M/yy",L"dd-MM-yy"}; - String^ date; - for ( int i = 0; i < format->Length; i++ ) - { - date = dt.ToString( format[ i ], DateTimeFormatInfo::InvariantInfo ); - Console::WriteLine( String::Concat( format[ i ], L" :", date ) ); - - } - - /** Output. - * - * d :08/17/2000 - * D :Thursday, August 17, 2000 - * f :Thursday, August 17, 2000 16:32 - * F :Thursday, August 17, 2000 16:32:32 - * g :08/17/2000 16:32 - * G :08/17/2000 16:32:32 - * m :August 17 - * r :Thu, 17 Aug 2000 23:32:32 GMT - * s :2000-08-17T16:32:32 - * t :16:32 - * T :16:32:32 - * u :2000-08-17 23:32:32Z - * U :Thursday, August 17, 2000 23:32:32 - * y :August, 2000 - * dddd, MMMM dd yyyy :Thursday, August 17 2000 - * ddd, MMM d "'"yy :Thu, Aug 17 '00 - * dddd, MMMM dd :Thursday, August 17 - * M/yy :8/00 - * dd-MM-yy :17-08-00 - */ -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp deleted file mode 100644 index ec2ce96c984..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -using namespace System; -delegate String^ myMethodDelegate( // Declares a delegate for a method that takes in an int and returns a String. -int myInt ); - -// Defines some methods to which the delegate can point. -ref class mySampleClass -{ -public: - - // Defines an instance method. - String^ myStringMethod( int myInt ) - { - if ( myInt > 0 ) - return ("positive"); - - if ( myInt < 0 ) - return ("negative"); - - return ("zero"); - } - - - // Defines a static method. - static String^ mySignMethod( int myInt ) - { - if ( myInt > 0 ) - return ("+"); - - if ( myInt < 0 ) - return ("-"); - - return (""); - } - -}; - -int main() -{ - - // Creates one delegate for each method. For the instance method, an - // instance (mySC) must be supplied. For the static method, only the - // method name is needed. - mySampleClass^ mySC = gcnew mySampleClass; - myMethodDelegate^ myD1 = gcnew myMethodDelegate( mySC, &mySampleClass::myStringMethod ); - myMethodDelegate^ myD2 = gcnew myMethodDelegate( mySampleClass::mySignMethod ); - - // Invokes the delegates. - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", 5, myD1( 5 ), myD2( 5 ) ); - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", -3, myD1( -3 ), myD2( -3 ) ); - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", 0, myD1( 0 ), myD2( 0 ) ); -} - -/* -This code produces the following output: - -5 is positive; use the sign "+". --3 is negative; use the sign "-". -0 is zero; use the sign "". -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp deleted file mode 100644 index f3f215111a7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -public ref class EnumSample -{ -public: - enum class Colors - { - Red = 1, - Blue = 2 - }; - - static void main() - { - Enum ^ myColors = Colors::Red; - Console::WriteLine( "The value of this instance is '{0}'", myColors ); - } - -}; - -int main() -{ - EnumSample::main(); -} - -/* -Output. -The value of this instance is 'Red'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldAttributes Example/CPP/source.cpp deleted file mode 100644 index 2c4a0747c4a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security::Permissions; - -public ref class Demo -{ -private: - // Make three fields: - // The first field is private. - String^ m_field; - - // The second field is public. -public: - String^ Field; - - // The third field is public and literal. - literal String^ FieldC = "String C"; - - Demo() { m_field = "String A"; Field = "String B"; } -}; - -static void DisplayField(Object^ obj, FieldInfo^ f) -{ - // Display the field name, value, and attributes. - // - Console::WriteLine("{0} = \"{1}\"; attributes: {2}", - f->Name, f->GetValue(obj), f->Attributes); -}; - -void main() -{ - Console::WriteLine ("\nReflection.FieldAttributes"); - Demo^ d = gcnew Demo(); - - // Get a Type object for Demo, and a FieldInfo for each of - // the three fields. Use the FieldInfo to display field - // name, value for the Demo object in d, and attributes. - // - Type^ myType = Demo::typeid; - - FieldInfo^ fiPrivate = myType->GetField("m_field", - BindingFlags::NonPublic | BindingFlags::Instance); - DisplayField(d, fiPrivate); - - FieldInfo^ fiPublic = myType->GetField("Field", - BindingFlags::Public | BindingFlags::Instance); - DisplayField(d, fiPublic); - - FieldInfo^ fiConstant = myType->GetField("FieldC", - BindingFlags::Public | BindingFlags::Static); - DisplayField(d, fiConstant); -} - -/* This code example produces the following output: - -Reflection.FieldAttributes -m_field = "String A"; attributes: Private -Field = "String B"; attributes: Public -FieldC = "String C"; attributes: Public, Static, Literal, HasDefault - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/CPP/source.cpp deleted file mode 100644 index d04993ffecd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class TestClass -{ - // Define a field. - private: - String^ field = "private field" ; - -// public: -// Myfield() -// : field( "private field" ) -// {} -// -// -// property String^ Field -// { -// String^ get() -// { -// return field; -// } -// -// } -}; - -void main() -{ - TestClass^ cl = gcnew TestClass; - - // Get the type and FieldInfo. - Type^ t = cl->GetType(); - FieldInfo^ fi = t->GetField("field", - static_cast(BindingFlags::Instance | BindingFlags::NonPublic)); - - // Get and display the Ftype s ieldType. - Console::WriteLine("Field Name: {0}.{1}", t->FullName, fi->Name ); - Console::WriteLine("Field Value: '{0}'", fi->GetValue(cl)); - Console::WriteLine("Field Type: {0}", fi->FieldType); -} -// The example displays the following output: -// Field Name: TestClass.field -// Field Value: 'private field' -// Field Type: System.String -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp deleted file mode 100644 index 11c0acbac47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Example -{ -public: - int f_public; -internal: - int f_internal; -protected: - int f_protected; -protected public: - int f_protected_public; -protected private: - int f_protected_private; -}; - -void main() -{ - Console::WriteLine("\n{0,-30}{1,-18}{2}", "", "IsAssembly", "IsFamilyOrAssembly"); - Console::WriteLine("{0,-21}{1,-18}{2,-18}{3}\n", - "", "IsPublic", "IsFamily", "IsFamilyAndAssembly"); - - for each (FieldInfo^ f in Example::typeid->GetFields( - BindingFlags::Instance | BindingFlags::NonPublic | BindingFlags::Public)) - { - Console::WriteLine("{0,-21}{1,-9}{2,-9}{3,-9}{4,-9}{5,-9}", - f->Name, - f->IsPublic, - f->IsAssembly, - f->IsFamily, - f->IsFamilyOrAssembly, - f->IsFamilyAndAssembly - ); - } -} - -/* This code example produces output similar to the following: - - IsAssembly IsFamilyOrAssembly - IsPublic IsFamily IsFamilyAndAssembly - -f_public True False False False False -f_internal False True False False False -f_protected False False True False False -f_protected_public False False False True False -f_protected_private False False False False True - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/CPP/source.cpp deleted file mode 100644 index e4ab406d1aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/CPP/source.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -//Make two fields, one public and one read-only. -public ref class Myfielda -{ -public: - String^ field; - Myfielda() - : field( "A - public field" ) - {} - - - property String^ Field - { - String^ get() - { - return field; - } - - void set( String^ value ) - { - if ( field != value ) - { - field = value; - } - } - - } - -}; - -public ref class Myfieldb -{ -private: - String^ const field; - -public: - Myfieldb() - : field( "B - readonly field" ) - {} - - - property String^ Field - { - String^ get() - { - return field; - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.FieldInfo" ); - Myfielda^ myfielda = gcnew Myfielda; - Myfieldb^ myfieldb = gcnew Myfieldb; - - //Get the Type and FieldInfo. - Type^ MyTypea = Type::GetType( "Myfielda" ); - FieldInfo^ Myfieldinfoa = MyTypea->GetField( "field", static_cast(BindingFlags::Public | BindingFlags::Instance) ); - Type^ MyTypeb = Type::GetType( "Myfieldb" ); - FieldInfo^ Myfieldinfob = MyTypeb->GetField( "field", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - - //Modify the fields. - //Note that Myfieldb is not modified, as it is - //read-only (IsInitOnly is True). - myfielda->field = "A- modified"; - - //Myfieldb.field = "B- modified"; - //For the first field, get and display the name, field, and IsInitOnly state. - Console::Write( "\n{0} - {1}, IsInitOnly = {2} ", MyTypea->FullName, Myfieldinfoa->GetValue( myfielda ), Myfieldinfoa->IsInitOnly ); - - //For the second field get and display the name, field, and IsInitOnly state. - Console::Write( "\n{0} - {1}, IsInitOnly = {2} ", MyTypeb->FullName, Myfieldinfob->GetValue( myfieldb ), Myfieldinfob->IsInitOnly ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/CPP/source.cpp deleted file mode 100644 index 622ef650283..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Make two fields. -// private -public ref class Myfielda -{ -private: - String^ SomeField; - -public: - Myfielda() - : SomeField( "private field" ) - {} - - - property String^ Field - { - String^ get() - { - return SomeField; - } - - } - -}; - - -// public -public ref class Myfieldb -{ -public: - String^ SomeField; - Myfieldb() - : SomeField( "public field" ) - {} - - - property String^ Field - { - String^ get() - { - return SomeField; - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.FieldInfo" ); - Myfielda^ myfielda = gcnew Myfielda; - Myfieldb^ myfieldb = gcnew Myfieldb; - - // Get the Type and FieldInfo. - Type^ MyTypea = Type::GetType( "Myfielda" ); - FieldInfo^ Myfieldinfoa = MyTypea->GetField( "SomeField", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - Type^ MyTypeb = Type::GetType( "Myfieldb" ); - FieldInfo^ Myfieldinfob = MyTypeb->GetField( "SomeField" ); - - // Get and display the IsPublic and IsPrivate property values. - Console::Write( "\n{0}.", MyTypea->FullName ); - Console::Write( "{0} - ", Myfieldinfoa->Name ); - Console::Write( "{0}", myfielda->Field ); - Console::Write( "\n IsPublic = {0}", Myfieldinfoa->IsPublic ); - Console::Write( "\n IsPrivate = {0}", Myfieldinfoa->IsPrivate ); - Console::Write( "\n{0}.", MyTypeb->FullName ); - Console::Write( "{0} - ", Myfieldinfob->Name ); - Console::Write( "{0};", myfieldb->Field ); - Console::Write( "\n IsPublic = {0}", Myfieldinfob->IsPublic ); - Console::Write( "\n IsPrivate = {0}", Myfieldinfob->IsPrivate ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/CPP/source.cpp deleted file mode 100644 index cac0b79e4d2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/CPP/source.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Make two fields. -public ref class Myfielda -{ -private: - String^ field; - -public: - Myfielda() - : field( "A private field" ) - {} - - - property String^ Field - { - String^ get() - { - return field; - } - - void set( String^ value ) - { - if ( field != value ) - { - field = value; - } - } - - } - -}; - -public ref class Myfieldb -{ -private: - static String^ field = "B static field"; - -public: - - property String^ Field - { - String^ get() - { - return field; - } - - void set( String^ value ) - { - if ( field != value ) - { - field = value; - } - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.FieldInfo" ); - Myfielda^ myfielda = gcnew Myfielda; - Myfieldb^ myfieldb = gcnew Myfieldb; - - // Get the Type and FieldInfo. - Type^ MyTypea = Type::GetType( "Myfielda" ); - FieldInfo^ Myfieldinfoa = MyTypea->GetField( "field", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - Type^ MyTypeb = Type::GetType( "Myfieldb" ); - FieldInfo^ Myfieldinfob = MyTypeb->GetField( "field", static_cast(BindingFlags::NonPublic | BindingFlags::Static) ); - - // For the first field, get and display the name, field, and IsStatic property value. - Console::Write( "\n{0} - ", MyTypea->FullName ); - Console::Write( "{0}; ", Myfieldinfoa->GetValue( myfielda ) ); - Console::Write( "IsStatic - {0}", Myfieldinfoa->IsStatic ); - - // For the second field get and display the name, field, and IsStatic property value. - Console::Write( "\n{0} - ", MyTypeb->FullName ); - Console::Write( "{0}; ", Myfieldinfob->GetValue( myfieldb ) ); - Console::Write( "IsStatic - {0}", Myfieldinfob->IsStatic ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/CPP/source.cpp deleted file mode 100644 index 0daa04b49b6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Make a field. -public ref class Myfield -{ -private: - String^ field; - -public: - Myfield() - : field( "a private field" ) - {} - - - property String^ Field - { - String^ get() - { - return field; - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.FieldInfo" ); - Myfield^ myfield = gcnew Myfield; - - // Get the Type and FieldInfo. - Type^ MyType = Type::GetType( "Myfield" ); - FieldInfo^ Myfieldinfo = MyType->GetField( "field", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - - // Get and display the MemberType. - Console::Write( "\n{0}.", MyType->FullName ); - Console::Write( "{0} - ", Myfieldinfo->Name ); - Console::Write( "{0};", myfield->Field ); - MemberTypes Mymembertypes = Myfieldinfo->MemberType; - Console::Write( "MemberType is a {0}.", Mymembertypes ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/CPP/source.cpp deleted file mode 100644 index adbeb6fbeac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Reflection; - -#define NULL 0 -void main() -{ - Type^ tDate = Type::GetType( L"System.DateTime" ); - Object^ result = tDate->InvokeMember( L"Now", BindingFlags::GetProperty, nullptr, NULL, gcnew array(0) ); - Console::WriteLine( result->ToString() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round Example/CPP/source.cpp deleted file mode 100644 index 13ab6a90a87..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round Example/CPP/source.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// -using namespace System; - -void main() -{ - Console::WriteLine("Classic Math.Round in CPP"); - Console::WriteLine(Math::Round(4.4)); // 4 - Console::WriteLine(Math::Round(4.5)); // 4 - Console::WriteLine(Math::Round(4.6)); // 5 - Console::WriteLine(Math::Round(5.5)); // 6 -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round2 Example/CPP/source.cpp deleted file mode 100644 index e9c1085e6f1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round2 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; - -ref class Sample -{ -private: - void Method() - { - // - Math::Round(3.44, 1); //Returns 3.4. - Math::Round(3.45, 1); //Returns 3.4. - Math::Round(3.46, 1); //Returns 3.5. - - Math::Round(4.34, 1); // Returns 4.3 - Math::Round(4.35, 1); // Returns 4.4 - Math::Round(4.36, 1); // Returns 4.4 - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp deleted file mode 100644 index fca76263e2b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Console::WriteLine( "\nReflection.MemberInfo" ); - - // Get the Type and MemberInfo. - Type^ MyType = Type::GetType( "System.Reflection.PropertyInfo" ); - array^Mymemberinfoarray = MyType->GetMembers(); - - // Get the MemberType method and display the elements. - Console::Write( "\nThere are {0} members in ", Mymemberinfoarray->GetLength( 0 ) ); - Console::Write( "{0}.", MyType->FullName ); - for ( int counter = 0; counter < Mymemberinfoarray->Length; counter++ ) - { - Console::Write( "\n{0}. {1} Member type - {2}", counter, Mymemberinfoarray[ counter ]->Name, Mymemberinfoarray[ counter ]->MemberType ); - - } - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/CPP/source.cpp deleted file mode 100644 index f4a7d06c3ce..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Get the Type and MemberInfo. - Type^ t = Type::GetType("System.Empty"); - array^ memberArray = t->GetMembers(); - - // Get and display the type that declares the member. - Console::WriteLine("There are {0} members in {1}", - memberArray->Length, t->FullName); - for each (MemberInfo^ member in memberArray) { - Console::WriteLine("Member {0} declared by {1}", - member->Name, member->DeclaringType); - } -} -// The example displays the following output: -// There are 6 members in System.Empty -// Member ToString declared by System.Empty -// Member GetObjectData declared by System.Empty -// Member Equals declared by System.Object -// Member GetHashCode declared by System.Object -// Member GetType declared by System.Object -// Member Value declared by System.Empty -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/CPP/source.cpp deleted file mode 100644 index 04e9498bfd7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -int main() -{ - MemberInfo^ m1 = Object::typeid->GetMethod("ToString"); - MemberInfo^ m2 = MemberInfo::typeid->GetMethod("ToString"); - - Console::WriteLine("m1.DeclaringType: {0}", m1->DeclaringType); - Console::WriteLine("m1.ReflectedType: {0}", m1->ReflectedType); - Console::WriteLine(); - Console::WriteLine("m2.DeclaringType: {0}", m2->DeclaringType); - Console::WriteLine("m2.ReflectedType: {0}", m2->ReflectedType); - - //Console::ReadLine(); -} - -/* This code example produces the following output: - -m1.DeclaringType: System.Object -m1.ReflectedType: System.Object - -m2.DeclaringType: System.Object -m2.ReflectedType: System.Reflection.MemberInfo - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodAttributes Example/CPP/source.cpp deleted file mode 100644 index d9f1db69a7b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; - -public ref class AttributesSample -{ -public: - void Mymethod( int int1m, [Out]interior_ptr str2m, interior_ptr str3m ) - { - *str2m = "in Mymethod"; - } -}; - -void PrintAttributes( Type^ attribType, int iAttribValue ) -{ - if ( !attribType->IsEnum ) - { - Console::WriteLine( "This type is not an enum." ); - return; - } - - array^fields = attribType->GetFields( static_cast(BindingFlags::Public | BindingFlags::Static) ); - for ( int i = 0; i < fields->Length; i++ ) - { - int fieldvalue = safe_cast(fields[ i ]->GetValue( nullptr )); - if ( (fieldvalue & iAttribValue) == fieldvalue ) - { - Console::WriteLine( fields[ i ]->Name ); - } - } -} - -int main() -{ - Console::WriteLine( "Reflection.MethodBase.Attributes Sample" ); - - // Get the type of the chosen class. - Type^ MyType = Type::GetType( "AttributesSample" ); - - // Get the method Mymethod on the type. - MethodBase^ Mymethodbase = MyType->GetMethod( "Mymethod" ); - - // Display the method name and signature. - Console::WriteLine( "Mymethodbase = {0}", Mymethodbase ); - - // Get the MethodAttribute enumerated value. - MethodAttributes Myattributes = Mymethodbase->Attributes; - - // Display the flags that are set. - PrintAttributes( System::Reflection::MethodAttributes::typeid, (int)Myattributes ); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp deleted file mode 100644 index b803afb891b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class AttributesSample -{ -public: - void Mymethod( int int1m, [Out]interior_ptr str2m, interior_ptr str3m ) - { - *str2m = "in Mymethod"; - } -}; - -void PrintAttributes( Type^ attribType, int iAttribValue ) -{ - if ( !attribType->IsEnum ) - { - Console::WriteLine( "This type is not an enum." ); - return; - } - - array^fields = attribType->GetFields( static_cast(BindingFlags::Public | BindingFlags::Static) ); - for ( int i = 0; i < fields->Length; i++ ) - { - int fieldvalue = safe_cast(fields[ i ]->GetValue( nullptr )); - if ( (fieldvalue & iAttribValue) == fieldvalue ) - { - Console::WriteLine( fields[ i ]->Name ); - } - } -} - -int main() -{ - Console::WriteLine( "Reflection.MethodBase.Attributes Sample" ); - - // Get the type. - Type^ MyType = Type::GetType( "AttributesSample" ); - - // Get the method Mymethod on the type. - MethodBase^ Mymethodbase = MyType->GetMethod( "Mymethod" ); - - // Display the method name. - Console::WriteLine( "Mymethodbase = {0}", Mymethodbase ); - - // Get the MethodAttribute enumerated value. - MethodAttributes Myattributes = Mymethodbase->Attributes; - - // Display the flags that are set. - PrintAttributes( System::Reflection::MethodAttributes::typeid, (int)Myattributes ); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/CPP/source.cpp deleted file mode 100644 index 945399096dc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class MagicClass -{ -private: - int magicBaseValue; - -public: - MagicClass() - { - magicBaseValue = 9; - } - - int ItsMagic(int preMagic) - { - return preMagic * magicBaseValue; - } -}; - -public ref class TestMethodInfo -{ -public: - static void Main() - { - // Get the constructor and create an instance of MagicClass - - Type^ magicType = Type::GetType("MagicClass"); - ConstructorInfo^ magicConstructor = magicType->GetConstructor(Type::EmptyTypes); - Object^ magicClassObject = magicConstructor->Invoke(gcnew array(0)); - - // Get the ItsMagic method and invoke with a parameter value of 100 - - MethodInfo^ magicMethod = magicType->GetMethod("ItsMagic"); - Object^ magicValue = magicMethod->Invoke(magicClassObject, gcnew array(1){100}); - - Console::WriteLine("MethodInfo.Invoke() Example\n"); - Console::WriteLine("MagicClass.ItsMagic() returned: {0}", magicValue); - } -}; - -int main() -{ - TestMethodInfo::Main(); -} - -// The example program gives the following output: -// -// MethodInfo.Invoke() Example -// -// MagicClass.ItsMagic() returned: 900 -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/CPP/source.cpp deleted file mode 100644 index a8d47e52181..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Console::WriteLine( "\nReflection.MethodBase" ); - - // Get the types. - Type^ MyType1 = Type::GetType( "System.Runtime.Serialization.Formatter" ); - Type^ MyType2 = Type::GetType( "System.Reflection.MethodBase" ); - - // Get and display the methods. - MethodBase^ Mymethodbase1 = MyType1->GetMethod( "WriteInt32", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - MethodBase^ Mymethodbase2 = MyType2->GetMethod( "GetCurrentMethod", static_cast(BindingFlags::Public | BindingFlags::Static) ); - Console::Write( "\nMymethodbase = {0}", Mymethodbase1 ); - if ( Mymethodbase1->IsAbstract ) - Console::Write( "\nMymethodbase is an abstract method." ); - else - Console::Write( "\nMymethodbase is not an abstract method." ); - - Console::Write( "\n\nMymethodbase = {0}", Mymethodbase2 ); - if ( Mymethodbase2->IsAbstract ) - Console::Write( "\nMymethodbase is an abstract method." ); - else - Console::Write( "\nMymethodbase is not an abstract method." ); - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp deleted file mode 100644 index 72f077ad3a4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Example -{ -public: - void m_public() {}; -internal: - void m_internal() {}; -protected: - void m_protected() {}; -protected public: - void m_protected_public() {}; -protected private: - void m_protected_private() {}; -}; - -void main() -{ - Console::WriteLine("\n{0,-30}{1,-18}{2}", "", "IsAssembly", "IsFamilyOrAssembly"); - Console::WriteLine("{0,-21}{1,-18}{2,-18}{3}\n", - "", "IsPublic", "IsFamily", "IsFamilyAndAssembly"); - - for each (MethodBase^ m in Example::typeid->GetMethods( - BindingFlags::Instance | BindingFlags::NonPublic | BindingFlags::Public)) - { - if (m->Name->Substring(0, 1) == "m") - { - Console::WriteLine("{0,-21}{1,-9}{2,-9}{3,-9}{4,-9}{5,-9}", - m->Name, - m->IsPublic, - m->IsAssembly, - m->IsFamily, - m->IsFamilyOrAssembly, - m->IsFamilyAndAssembly - ); - } - } -} - -/* This code example produces output similar to the following: - - IsAssembly IsFamilyOrAssembly - IsPublic IsFamily IsFamilyAndAssembly - -m_public True False False False False -m_internal False True False False False -m_protected False False True False False -m_protected_public False False False True False -m_protected_private False False False False True - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/CPP/source.cpp deleted file mode 100644 index a7ea8cf252b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Windows::Forms; - -// -int main() -{ - Console::WriteLine( "\nReflection.MethodBase" ); - - //Get the MethodBase of a method. - //Get the type - Type^ MyType = Type::GetType( "System.MulticastDelegate" ); - - //Get and display the method - MethodBase^ Mymethodbase = MyType->GetMethod( "RemoveImpl", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - Console::Write( "\nMymethodbase = {0}", Mymethodbase ); - bool Myispublic = Mymethodbase->IsPublic; - if ( Myispublic ) - Console::Write( "\nMymethodbase is a public method" ); - else - Console::Write( "\nMymethodbase is not a public method" ); - - return 0; -} - -/* -Produces the following output - -Reflection.MethodBase -Mymethodbase = System.Delegate RemoveImpl (System.Delegate) -Mymethodbase is not a public method -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp deleted file mode 100644 index f96f32346d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class MyClass -{ -public: - void MyMethod(){} -}; - -int main() -{ - MethodBase^ m = MyClass::typeid->GetMethod( "MyMethod" ); - Console::WriteLine( "The IsFinal property value of MyMethod is {0}.", m->IsFinal ); - Console::WriteLine( "The IsVirtual property value of MyMethod is {0}.", m->IsVirtual ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/CPP/source.cpp deleted file mode 100644 index b878d322184..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Console::WriteLine( "Reflection.MethodInfo" ); - - // Get the Type and MethodInfo. - Type^ MyType = Type::GetType( "System.Reflection.FieldInfo" ); - MethodInfo^ Mymethodinfo = MyType->GetMethod( "GetValue" ); - Console::WriteLine( "{0}.{1}", MyType->FullName, Mymethodinfo->Name ); - - // Get and display the MemberType property. - MemberTypes Mymembertypes = Mymethodinfo->MemberType; - if ( MemberTypes::Constructor == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type All." ); - } - else - if ( MemberTypes::Custom == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type Custom." ); - } - else - if ( MemberTypes::Event == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type Event." ); - } - else - if ( MemberTypes::Field == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type Field." ); - } - else - if ( MemberTypes::Method == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type Method." ); - } - else - if ( MemberTypes::Property == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type Property." ); - } - else - if ( MemberTypes::TypeInfo == Mymembertypes ) - { - Console::WriteLine( "MemberType is of type TypeInfo." ); - } - - - - - - - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/CPP/source.cpp deleted file mode 100644 index 9e122d5e99d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Console::WriteLine( "\nReflection.MethodInfo" ); - - // Get the Type and MethodInfo. - Type^ MyType = Type::GetType( "System.Reflection.FieldInfo" ); - MethodInfo^ Mymethodinfo = MyType->GetMethod( "GetValue" ); - Console::Write( "\n{0}.{1}", MyType->FullName, Mymethodinfo->Name ); - - // Get and display the ReturnType. - Console::Write( "\nReturnType = {0}", Mymethodinfo->ReturnType ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodRental.SwapMethodBody Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodRental.SwapMethodBody Example/CPP/source.cpp deleted file mode 100644 index 744eed074a9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodRental.SwapMethodBody Example/CPP/source.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Runtime::InteropServices; - -// First make a method that returns 0. -// Then swap the method body with a body that returns 1. -int main() -{ - // Construct a dynamic assembly - Guid g = Guid::NewGuid(); - AssemblyName^ asmname = gcnew AssemblyName; - asmname->Name = String::Concat( "tempfile", g ); - AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->DefineDynamicAssembly( asmname, AssemblyBuilderAccess::Run ); - - // Add a dynamic module that contains one type that has one method that - // has no arguments. - ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "test" ); - TypeBuilder^ tb = modbuild->DefineType( "name of the Type" ); - array^temp2; - MethodBuilder^ somemethod = tb->DefineMethod( "My method Name", static_cast(MethodAttributes::Public | MethodAttributes::Static), int::typeid, temp2 ); - - // Define the body of the method to return 0. - ILGenerator^ ilg = somemethod->GetILGenerator(); - ilg->Emit( OpCodes::Ldc_I4_0 ); - ilg->Emit( OpCodes::Ret ); - - // Complete the type and verify that it returns 0. - Type^ tbBaked = tb->CreateType(); - array^temp0; - int res1 = safe_cast(tbBaked->GetMethod( "My method Name" )->Invoke( nullptr, temp0 )); - if ( res1 != 0 ) - { - Console::WriteLine( "Err_001a, should have returned 0" ); - } - else - { - Console::WriteLine( "Original method returned 0" ); - } - - // Define a new method body that will return a 1 instead. - - // code size - // ldc_i4_1 - // ret - array^methodBytes = {0x03,0x30,0x0A,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x2a}; - - // Get the token for the method whose body you are replacing. - MethodToken somemethodToken = somemethod->GetToken(); - - // Get the pointer to the method body. - GCHandle hmem = GCHandle::Alloc( (Object^)methodBytes, GCHandleType::Pinned ); - IntPtr addr = hmem.AddrOfPinnedObject(); - int cbSize = methodBytes->Length; - - // Swap the old method body with the new body. - MethodRental::SwapMethodBody( tbBaked, somemethodToken.Token, addr, cbSize, MethodRental::JitImmediate ); - - // Verify that the modified method returns 1. - array^temp1; - int res2 = safe_cast(tbBaked->GetMethod( "My method Name" )->Invoke( nullptr, temp1 )); - if ( res2 != 1 ) - { - Console::WriteLine( "Err_001b, should have returned 1" ); - } - else - { - Console::WriteLine( "Swapped method body returned 1" ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.Name Example/CPP/source.cpp deleted file mode 100644 index d2aa22fa155..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.Name Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Module^ mod = Assembly::GetExecutingAssembly()->GetModules()[ 0 ]; - Console::WriteLine( "Module Name is {0}", mod->Name ); - Console::WriteLine( "Module FullyQualifiedName is {0}", mod->FullyQualifiedName ); - Console::WriteLine( "Module ScopeName is {0}", mod->ScopeName ); -} - -/* -This code produces the following output: - -Module Name is modname.exe -Module FullyQualifiedName is C:\Bin\modname.exe -Module ScopeName is modname.exe -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/CPP/source.cpp deleted file mode 100644 index 591da3b46bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Module^ mod = Assembly::GetExecutingAssembly()->GetModules()[ 0 ]; - Console::WriteLine( "Module Name is {0}", mod->Name ); - Console::WriteLine( "Module FullyQualifiedName is {0}", mod->FullyQualifiedName ); - Console::WriteLine( "Module ScopeName is {0}", mod->ScopeName ); -} - -/* -Produces this output: -Module Name is modname.exe -Module FullyQualifiedName is C:\Bin\modname.exe -Module ScopeName is modname.exe -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp deleted file mode 100644 index 009ddd456c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class Sample -{ -public: - void Method() - { - // - AssemblyName^ asmname = gcnew AssemblyName; - asmname->Name = "assemfilename.exe"; - AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()-> - DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename", - "assemfilename.exe" ); - TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" ); - typebuild1->CreateType(); - asmbuild->Save( "assemfilename.exe" ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterAttributes Example/CPP/source.cpp deleted file mode 100644 index cefa875d170..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class paramatt -{ -public: - static void mymethod( String^ str1, [Out]interior_ptr str2, interior_ptr str3 ) - { - *str2 = "string"; - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.ParameterAttributes" ); - - // Get the Type and the method. - Type^ Mytype = Type::GetType( "paramatt" ); - MethodBase^ Mymethodbase = Mytype->GetMethod( "mymethod" ); - - // Display the method. - Console::Write( "\nMymethodbase = {0}", Mymethodbase ); - - // Get the ParameterInfo array. - array^Myarray = Mymethodbase->GetParameters(); - - // Get and display the attributes for the second parameter. - ParameterAttributes Myparamattributes = Myarray[ 1 ]->Attributes; - Console::Write( "\nFor the second parameter:\nMyparamattributes = {0}, which is an {1}", (int)Myparamattributes, Myparamattributes ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/CPP/source.cpp deleted file mode 100644 index 9d1bd81902a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class parminfo -{ -public: - static void mymethod( int int1m, [Out]interior_ptr str2m, interior_ptr str3m ) - { - *str2m = "in mymethod"; - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.Parameterinfo" ); - - //Get the ParameterInfo parameter of a function. - //Get the type. - Type^ Mytype = Type::GetType( "parminfo" ); - - //Get and display the method. - MethodBase^ Mymethodbase = Mytype->GetMethod( "mymethod" ); - Console::Write( "\nMymethodbase = {0}", Mymethodbase ); - - //Get the ParameterInfo array. - array^Myarray = Mymethodbase->GetParameters(); - - //Get and display the IsOut of each parameter. - System::Collections::IEnumerator^ enum0 = Myarray->GetEnumerator(); - while ( enum0->MoveNext() ) - { - ParameterInfo^ Myparam = safe_cast(enum0->Current); - Console::Write( "\nFor parameter # {0}, the IsOut is - {1}", Myparam->Position, Myparam->IsOut ); - } - - return 0; -} - -/* -This code produces the following output: - -Reflection.ParameterInfo - -Mymethodbase = Void mymethod (Int32, System.String ByRef, System.String ByRef) -For parameter # 0, the IsOut is - False -For parameter # 1, the IsOut is - True -For parameter # 2, the IsOut is - False -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/CPP/source.cpp deleted file mode 100644 index f604a9598d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class parminfo -{ -public: - static void mymethod( int int1m, [Out]interior_ptr str2m, interior_ptr str3m ) - { - *str2m = "in mymethod"; - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.Parameterinfo" ); - - //Get the ParameterInfo parameter of a function. - //Get the type. - Type^ Mytype = Type::GetType( "parminfo" ); - - //Get and display the method. - MethodBase^ Mymethodbase = Mytype->GetMethod( "mymethod" ); - Console::Write( "\nMymethodbase = {0}", Mymethodbase ); - - //Get the ParameterInfo array. - array^Myarray = Mymethodbase->GetParameters(); - - //Get and display the name of each parameter. - System::Collections::IEnumerator^ enum0 = Myarray->GetEnumerator(); - while ( enum0->MoveNext() ) - { - ParameterInfo^ Myparam = safe_cast(enum0->Current); - Console::Write( "\nFor parameter # {0}, the Name is - {1}", Myparam->Position, Myparam->Name ); - } - - return 0; -} - -/* -This code produces the following output: - -Reflection.ParameterInfo - -Mymethodbase -= Void mymethod (Int32, System.String ByRef, System.String ByRef) -For parameter # 0, the Name is - int1m -For parameter # 1, the Name is - str2m -For parameter # 2, the Name is - str3m -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/CPP/source.cpp deleted file mode 100644 index e005d0ef83a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; -public ref class parminfo -{ -public: - static void mymethod( int int1m, [Out]interior_ptr str2m, interior_ptr str3m ) - { - *str2m = "in mymethod"; - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.Parameterinfo" ); - - //Get the ParameterInfo parameter of a function. - //Get the type. - Type^ Mytype = Type::GetType( "parminfo" ); - - //Get and display the method. - MethodBase^ Mymethodbase = Mytype->GetMethod( "mymethod" ); - Console::Write( "\nMymethodbase = {0}", Mymethodbase ); - - //Get the ParameterInfo array. - array^Myarray = Mymethodbase->GetParameters(); - - //Get and display the ParameterInfo of each parameter. - System::Collections::IEnumerator^ enum0 = Myarray->GetEnumerator(); - while ( enum0->MoveNext() ) - { - ParameterInfo^ Myparam = safe_cast(enum0->Current); - Console::Write( "\nFor parameter # {0}, the ParameterType is - {1}", Myparam->Position, Myparam->ParameterType ); - } - - return 0; -} - -/* -This code produces the following output: - -Reflection.Parameterinfo - -Mymethodbase = Void mymethod(Int32, System.String ByRef, System.String ByRef) -For parameter # 0, the ParameterType is - System.Int32 -For parameter # 1, the ParameterType is - System.String& -For parameter # 2, the ParameterType is - System.String& -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/CPP/source.cpp deleted file mode 100644 index 189cd35d9c7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,161 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define three properties: one read-write, one default, -// and one read only. -// Define a read-write property. -public ref class Aproperty -{ -private: - String^ caption; - -public: - Aproperty() - : caption( "A Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - - -// Define a default property. -public ref class Bproperty -{ -private: - String^ caption; - -public: - Bproperty() - : caption( "B Default caption" ) - {} - -public: - property String^ Item - { - String^ get() - { - return "1"; - } - - } - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - - -// Define a read-only property. -public ref class Cproperty -{ -private: - String^ caption; - -public: - Cproperty() - : caption( "C Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.PropertyAttributes" ); - - // Determine whether a property exists, and change its value. - Aproperty^ Mypropertya = gcnew Aproperty; - Bproperty^ Mypropertyb = gcnew Bproperty; - Cproperty^ Mypropertyc = gcnew Cproperty; - Console::Write( "\n1. Mypropertya->Caption = {0}", Mypropertya->Caption ); - Console::Write( "\n1. Mypropertyb->Caption = {0}", Mypropertyb->Caption ); - Console::Write( "\n1. Mypropertyc->Caption = {0}", Mypropertyc->Caption ); - - // Only Mypropertya can be changed, as Mypropertyb is read-only. - Mypropertya->Caption = "A- This is changed."; - Mypropertyb->Caption = "B- This is changed."; - - // Note that Mypropertyc is not changed because it is read only - Console::Write( "\n\n2. Mypropertya->Caption = {0}", Mypropertya->Caption ); - Console::Write( "\n2. Mypropertyb->Caption = {0}", Mypropertyb->Caption ); - Console::Write( "\n2. Mypropertyc->Caption = {0}", Mypropertyc->Caption ); - - // Get the PropertyAttributes enumeration of the property. - // Get the type. - Type^ MyTypea = Type::GetType( "Aproperty" ); - Type^ MyTypeb = Type::GetType( "Bproperty" ); - Type^ MyTypec = Type::GetType( "Cproperty" ); - - // Get the property attributes. - PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" ); - PropertyAttributes Myattributesa = Mypropertyinfoa->Attributes; - PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "Item" ); - PropertyAttributes Myattributesb = Mypropertyinfob->Attributes; - PropertyInfo^ Mypropertyinfoc = MyTypec->GetProperty( "Caption" ); - PropertyAttributes Myattributesc = Mypropertyinfoc->Attributes; - - // Display the property attributes value. - Console::Write( "\n\na- {0}", Myattributesa ); - Console::Write( "\nb- {0}", Myattributesb ); - Console::Write( "\nc- {0}", Myattributesc ); - return 0; -} - -// This example displays the following output to the console -// -// Reflection.PropertyAttributes -// -// 1. Mypropertya.Caption = A Default caption -// 1. Mypropertyb.Caption = B Default caption -// 1. Mypropertyc.Caption = C Default caption -// -// 2. Mypropertya.Caption = A- This is changed. -// 2. Mypropertyb.Caption = B- This is changed. -// 2. Mypropertyc.Caption = C Default caption -// -// a- None -// b- None -// c- None -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/CPP/source.cpp deleted file mode 100644 index 5e3598f1d39..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/CPP/source.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define one readable property and one not readable. -public ref class Mypropertya -{ -private: - String^ caption; - -public: - Mypropertya() - : caption( "A Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -public ref class Mypropertyb -{ -private: - String^ caption; - -public: - Mypropertyb() - : caption( "B Default caption" ) - {} - - - property String^ Caption - { - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.PropertyInfo" ); - - // Define two properties. - Mypropertya^ mypropertya = gcnew Mypropertya; - Mypropertyb^ mypropertyb = gcnew Mypropertyb; - Console::Write( "\nMypropertya->Caption = {0}", mypropertya->Caption ); - - // Mypropertyb.Caption cannot be read, because - // there is no get accessor. - // Get the type and PropertyInfo. - Type^ MyTypea = Type::GetType( "Mypropertya" ); - PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" ); - Type^ MyTypeb = Type::GetType( "Mypropertyb" ); - PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "Caption" ); - - // Get and display the CanRead property. - Console::Write( "\nCanRead a - {0}", Mypropertyinfoa->CanRead ); - Console::Write( "\nCanRead b - {0}", Mypropertyinfob->CanRead ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/CPP/source.cpp deleted file mode 100644 index c83b78e6d61..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/CPP/source.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define one writable property and one not writable. -public ref class Mypropertya -{ -private: - String^ caption; - -public: - Mypropertya() - : caption( "A Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -public ref class Mypropertyb -{ -private: - String^ caption; - -public: - Mypropertyb() - : caption( "B Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.PropertyInfo" ); - - // Define two properties. - Mypropertya^ mypropertya = gcnew Mypropertya; - Mypropertyb^ mypropertyb = gcnew Mypropertyb; - - // Read and display the property. - Console::Write( "\nMypropertya->Caption = {0}", mypropertya->Caption ); - Console::Write( "\nMypropertyb->Caption = {0}", mypropertyb->Caption ); - - // Write to the property. - mypropertya->Caption = "A- No Change"; - - // Mypropertyb.Caption cannot be written to because - // there is no set accessor. - // Read and display the property. - Console::Write( "\nMypropertya->Caption = {0}", mypropertya->Caption ); - Console::Write( "\nMypropertyb->Caption = {0}", mypropertyb->Caption ); - - // Get the type and PropertyInfo. - Type^ MyTypea = Type::GetType( "Mypropertya" ); - PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" ); - Type^ MyTypeb = Type::GetType( "Mypropertyb" ); - PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "Caption" ); - - // Get and display the CanWrite property. - Console::Write( "\nCanWrite a - {0}", Mypropertyinfoa->CanWrite ); - Console::Write( "\nCanWrite b - {0}", Mypropertyinfob->CanWrite ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/CPP/source.cpp deleted file mode 100644 index e947e02ff48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define a property. -public ref class Myproperty -{ -private: - String^ caption; - -public: - Myproperty() - : caption( "A Default caption" ) - {} - - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.PropertyInfo" ); - - // Get the type and PropertyInfo for two separate properties. - Type^ MyTypea = Type::GetType( "Myproperty" ); - PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" ); - Type^ MyTypeb = Type::GetType( "System.Reflection.MethodInfo" ); - PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "MemberType" ); - - // Get and display the GetGetMethod method for each property. - MethodInfo^ Mygetmethodinfoa = Mypropertyinfoa->GetGetMethod(); - Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfoa->Name, Mygetmethodinfoa->ReturnType ); - MethodInfo^ Mygetmethodinfob = Mypropertyinfob->GetGetMethod(); - Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfob->Name, Mygetmethodinfob->ReturnType ); - - // Display the GetGetMethod without using the MethodInfo. - Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypea->FullName, Mypropertyinfoa->Name, Mypropertyinfoa->GetGetMethod() ); - Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypeb->FullName, Mypropertyinfob->Name, Mypropertyinfob->GetGetMethod() ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/CPP/source.cpp deleted file mode 100644 index 6c130b9d45f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/CPP/source.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// A class that contains some properties. -public ref class MyProperty -{ -private: - - // Define a simple string property. - String^ caption; - -public: - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -private: - - // A very limited indexer that gets or sets one of four - // strings. - array^strings; - -public: - MyProperty() - { - array^temp0 = {"abc","def","ghi","jkl"}; - strings = temp0; - } - - - property String^ Item [int] - { - String^ get( int Index ) - { - return strings[ Index ]; - } - - void set( int Index, String^ value ) - { - strings[ Index ] = value; - } - - } - -}; - -int main() -{ - - // Get the type and PropertyInfo. - Type^ t = Type::GetType( "MyProperty" ); - PropertyInfo^ pi = t->GetProperty( "Caption" ); - - // Get the public GetIndexParameters method. - array^parms = pi->GetIndexParameters(); - Console::WriteLine( "\n{0}.{1} has {2} parameters.", t->FullName, pi->Name, parms->GetLength( 0 ) ); - - // Display a property that has parameters. - pi = t->GetProperty( "Item" ); - parms = pi->GetIndexParameters(); - Console::WriteLine( "{0}.{1} has {2} parameters.", t->FullName, pi->Name, parms->GetLength( 0 ) ); - for ( int i = 0; i < parms->GetLength( 0 ); i++ ) - { - Console::WriteLine( " Parameter: {0}", parms[ i ]->Name ); - - } - return 0; -} - -/* - This example produces the following output: - MyProperty.Caption has 0 parameters. - MyProperty.Item has 1 parameters. - Parameter: Index - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/CPP/source.cpp deleted file mode 100644 index 490380e255b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define a property. -public ref class Myproperty -{ -private: - String^ caption; - -public: - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -int main() -{ - Console::WriteLine( "\nReflection.PropertyInfo" ); - - // Get the type and PropertyInfo for two separate properties. - Type^ MyTypea = Type::GetType( "Myproperty" ); - PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" ); - Type^ MyTypeb = Type::GetType( "System.Text.StringBuilder" ); - PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "Length" ); - - // Get and display the GetSetMethod method for each property. - MethodInfo^ Mygetmethodinfoa = Mypropertyinfoa->GetSetMethod(); - Console::Write( "\nSetAccessor for {0} returns a {1}", Mypropertyinfoa->Name, Mygetmethodinfoa->ReturnType ); - MethodInfo^ Mygetmethodinfob = Mypropertyinfob->GetSetMethod(); - Console::Write( "\nSetAccessor for {0} returns a {1}", Mypropertyinfob->Name, Mygetmethodinfob->ReturnType ); - - // Display the GetSetMethod without using the MethodInfo. - Console::Write( "\n\n{0}.{1} GetSetMethod - {2}", MyTypea->FullName, Mypropertyinfoa->Name, Mypropertyinfoa->GetSetMethod() ); - Console::Write( "\n{0}.{1} GetSetMethod - {2}", MyTypeb->FullName, Mypropertyinfob->Name, Mypropertyinfob->GetSetMethod() ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/CPP/source.cpp deleted file mode 100644 index a56525a268e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Console::WriteLine( "\nReflection.PropertyInfo" ); - - // Get the type and PropertyInfo. - Type^ MyType = Type::GetType( "System.Reflection.MemberInfo" ); - PropertyInfo^ Mypropertyinfo = MyType->GetProperty( "Name" ); - - // Read and display the MemberType property. - Console::Write( "\nMemberType = {0}", Mypropertyinfo->MemberType ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.SetValue1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.SetValue1 Example/CPP/source.cpp deleted file mode 100644 index 7c87302d269..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.SetValue1 Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Define a property. -public ref class TestClass -{ -private: - String^ caption; - -public: - TestClass() - { - caption = "A Default caption"; - } - - - property String^ Caption - { - String^ get() - { - return caption; - } - - void set( String^ value ) - { - if ( caption != value ) - { - caption = value; - } - } - - } - -}; - -int main() -{ - TestClass^ t = gcnew TestClass; - - // Get the type and PropertyInfo. - Type^ myType = t->GetType(); - PropertyInfo^ pinfo = myType->GetProperty( "Caption" ); - - // Display the property value, using the GetValue method. - Console::WriteLine( "\nGetValue: {0}", pinfo->GetValue( t, nullptr ) ); - - // Use the SetValue method to change the caption. - pinfo->SetValue( t, "This caption has been changed.", nullptr ); - - // Display the caption again. - Console::WriteLine( "GetValue: {0}", pinfo->GetValue( t, nullptr ) ); - Console::WriteLine( "\nPress the Enter key to continue." ); - Console::ReadLine(); - return 0; -} - -/* -This example produces the following output: - -GetValue: A Default caption -GetValue: This caption has been changed - -Press the Enter key to continue. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp deleted file mode 100644 index bdf0c7f6486..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; - -void main() -{ - Random^ rnd = gcnew Random; - array^b = gcnew array(10); - rnd->NextBytes( b ); - Console::WriteLine("The Random bytes are:"); - for ( int i = 0; i < 10; i++ ) - Console::WriteLine("{0}: {1}", i, b[i]); -} -// The example displays output similar to the following: -// The Random bytes are: -// 0: 131 -// 1: 96 -// 2: 226 -// 3: 213 -// 4: 176 -// 5: 208 -// 6: 99 -// 7: 89 -// 8: 226 -// 9: 194 -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft Example/CPP/source.cpp deleted file mode 100644 index 7c44cb174ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft Example/CPP/source.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#using - -using namespace System; - -ref class Sample -{ -private: - void Method() - { - // - String^ str = "BBQ and Slaw"; - Console::WriteLine( str->PadLeft( 15 ) ); // Displays " BBQ and Slaw". - Console::WriteLine( str->PadLeft( 5 ) ); // Displays "BBQ and Slaw". - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/CPP/source.cpp deleted file mode 100644 index 4f65f5fcc67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#using - -// -using namespace System; - -void main() -{ - String^ str = "forty-two"; - Console::WriteLine( str->PadLeft( 15, L'.' ) ); - Console::WriteLine( str->PadLeft( 2, L'.' ) ); -} -// The example displays the following output: -// ......forty-two -// forty-two -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight Example/CPP/source.cpp deleted file mode 100644 index d313d14119e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -ref class Sample -{ -private: - void Method() - { - - // - String^ str = "BBQ and Slaw"; - Console::Write( "|" ); - Console::Write( str->PadRight( 15 ) ); - Console::WriteLine( "|" ); // Displays "|BBQ and Slaw |". - Console::Write( "|" ); - Console::Write( str->PadRight( 5 ) ); - Console::WriteLine( "|" ); // Displays "|BBQ and Slaw|". - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/CPP/source.cpp deleted file mode 100644 index 0786d97857d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#using - -using namespace System; -ref class Sample -{ -private: - void Method() - { - // - String^ str = "forty-two"; - Console::Write( "|" ); - Console::Write( str->PadRight( 15, '.' ) ); - Console::WriteLine( "|" ); // Displays "|forty-two......|". - Console::Write( "|" ); - Console::Write( str->PadRight( 5, '.' ) ); - Console::WriteLine( "|" ); // Displays "|forty-two|". - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/CPP/source.cpp deleted file mode 100644 index 16e8d85658e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class dtype abstract -{ -public: - ref class MyClassA abstract - { - public: - virtual int m() = 0; - }; - - ref class MyClassB abstract: public MyClassA{}; -}; - -int main() -{ - Console::WriteLine( "The declaring type of m is {0}.", dtype::MyClassB::typeid->GetMethod( "m" )->DeclaringType ); -} -/* The example produces the following output: - -The declaring type of m is dtype+MyClassA. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/CPP/source.cpp deleted file mode 100644 index ee3ada47aea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::Reflection; - -public ref class Sample -{ -public: - void Method( Type^ type ) - { - ConstructorInfo^ cInfo; - - // - cInfo = type->GetConstructor( BindingFlags::ExactBinding, nullptr, - Type::EmptyTypes, nullptr ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.FilterName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.FilterName Example/CPP/source.cpp deleted file mode 100644 index eaae896f09f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.FilterName Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -using namespace System; -using namespace System::Reflection; - -// Class added so sample will compile -public ref class Application -{ -public: - void Method(){} -}; - -public ref class Sample -{ -public: - void Method() - { - // - // Get the set of methods associated with the type - array^ mi = Application::typeid->FindMembers( - (MemberTypes)(MemberTypes::Constructor | MemberTypes::Method), - (BindingFlags)(BindingFlags::Public | BindingFlags::Static | - BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::DeclaredOnly), - Type::FilterName, "*" ); - Console::WriteLine( "Number of methods (includes constructors): {0}", mi->Length ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source1.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source1.cpp deleted file mode 100644 index 4c9e6c12c06..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source1.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class t -{ -public: - t(){} - - static t(){} - - t( int /*i*/ ){} - -}; - -int main() -{ - array^p = t::typeid->GetConstructors(); - Console::WriteLine( p->Length ); - for ( int i = 0; i < p->Length; i++ ) - { - Console::WriteLine( p[ i ]->IsStatic ); - - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source2.cpp deleted file mode 100644 index 881b9216d30..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source2.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class t -{ -public: - t(){} - - t( int /*i*/ ){} - - static t(){} - -}; - -int main() -{ - array^p = t::typeid->GetConstructors( static_cast(BindingFlags::Public | BindingFlags::Static | BindingFlags::NonPublic | BindingFlags::Instance) ); - Console::WriteLine( p->Length ); - for ( int i = 0; i < p->Length; i++ ) - { - Console::WriteLine( p[ i ]->IsStatic ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp deleted file mode 100644 index f0af5fbd409..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Reflection; - -int main() -{ - //Get the Type and MemberInfo. - Type^ t = Type::GetType("System.IO.File"); - array^ members = t->GetMembers(); - - //Get and display the DeclaringType method. - Console::WriteLine("There are {0} members in {1}.", - members->Length, t->FullName ); - Console::WriteLine("Is {0} non-public? {1}", - t->FullName, t->IsNotPublic ); -} -// The example displays the following output: -// There are 60 members in System.IO.File. -// Is System.IO.File non-public? False -// - -// -public ref class A -{ -public: - ref class B{}; - - -private: - ref class C{}; - - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/CPP/source.cpp deleted file mode 100644 index 47d546e7a06..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Reflection; -using namespace System::Text; -public ref class Sample -{ -protected: - bool ShowMethods; - StreamWriter^ myWriter; - -private: - void DumpMethods( Type^ aType ) - { - if ( !ShowMethods ) - return; - - array^mInfo = aType->GetMethods(); - myWriter->WriteLine( "Methods" ); - bool found = false; - if ( mInfo->Length != 0 ) - { - for ( int i = 0; i < mInfo->Length; i++ ) - { - - // Only display methods declared in this type. Also - // filter out any methods with special names, because these - // cannot be generally called by the user. That is, their - // functionality is usually exposed in other ways, for example, - // property get/set methods are exposed as properties. - if ( mInfo[ i ]->DeclaringType == aType && !mInfo[ i ]->IsSpecialName ) - { - found = true; - StringBuilder^ modifiers = gcnew StringBuilder; - if ( mInfo[ i ]->IsStatic ) - { - modifiers->Append( "static " ); - } - if ( mInfo[ i ]->IsPublic ) - { - modifiers->Append( "public " ); - } - if ( mInfo[ i ]->IsFamily ) - { - modifiers->Append( "protected " ); - } - if ( mInfo[ i ]->IsAssembly ) - { - modifiers->Append( "internal " ); - } - if ( mInfo[ i ]->IsPrivate ) - { - modifiers->Append( "private " ); - } - myWriter->WriteLine( "{0} {1}", modifiers, mInfo[ i ] ); - } - - } - } - - if ( !found ) - { - myWriter->WriteLine( "(none)" ); - } - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.MemberType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.MemberType Example/CPP/source.cpp deleted file mode 100644 index 5f55897e971..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.MemberType Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ -using namespace System; -using namespace System::Reflection; - -public ref class Sample -{ -public: - void Method( Type^ t, MemberInfo^ mi ) - { - // - array^ others = t->GetMember( mi->Name, mi->MemberType, - (BindingFlags)(BindingFlags::Public | BindingFlags::Static | - BindingFlags::NonPublic | BindingFlags::Instance) ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.Missing Example/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.Missing Example/cpp/source.cpp deleted file mode 100644 index be2838788b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.Missing Example/cpp/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::CodeDom::Compiler; - -ref class Example -{ -public: - static void Main() - { - // VB source for example. Not all versions of CS and CPP compilers - // support optional arguments. - String^ codeLines = - "Imports System\n\n" + - "Public Class OptionalArg\n" + - " Public Sub MyMethod(ByVal a As Integer, _\n" + - " Optional ByVal b As Double = 1.2, _\n" + - " Optional ByVal c As Integer = 1)\n\n" + - " Console.WriteLine(\"a = \" & a & \" b = \" & b & \" c = \" & c)\n" + - " End Sub\n" + - "End Class\n"; - - // Generate a OptionalArg instance from the source above. - Object^ o = GenerateObjectFromSource("OptionalArg", codeLines, "VisualBasic"); - Type^ t; - - t = o->GetType(); - BindingFlags bf = BindingFlags::Public | BindingFlags::Instance | - BindingFlags::InvokeMethod | BindingFlags::OptionalParamBinding; - - t->InvokeMember("MyMethod", bf, nullptr, o, gcnew array {10, 55.3, 12}); - t->InvokeMember("MyMethod", bf, nullptr, o, gcnew array {10, 1.3, Type::Missing}); - t->InvokeMember("MyMethod", bf, nullptr, o, gcnew array {10, Type::Missing, Type::Missing}); - } - -private: - static Object^ GenerateObjectFromSource(String^ objectName, - String^ sourceLines, String^ providerName) - { - Object^ genObject = nullptr; - CodeDomProvider^ codeProvider = CodeDomProvider::CreateProvider(providerName); - CompilerParameters^ cp = gcnew CompilerParameters(); - - cp->GenerateExecutable = false; - cp->GenerateInMemory = true; - - CompilerResults^ results = - codeProvider->CompileAssemblyFromSource(cp, sourceLines); - if (results->Errors->Count == 0) - { - genObject = results->CompiledAssembly->CreateInstance(objectName); - } - - return genObject; - } -}; - -int main() -{ - Example::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/CPP/source.cpp deleted file mode 100644 index e40dfeced46..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class MyClassA abstract -{ -public: - ref class MyClassB abstract - { - - }; - -}; - -int main() -{ - Console::WriteLine( "Reflected type of MyClassB is {0}", MyClassA::MyClassB::typeid->ReflectedType ); - //Outputs MyClassA, the enclosing type. -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Reflection.MemberTypes/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Reflection.MemberTypes/cpp/source.cpp deleted file mode 100644 index d0cc8fad02a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Reflection.MemberTypes/cpp/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Get the type of a chosen class. - Type^ t = ReflectionTypeLoadException::typeid; - - // Get the MemberInfo array. - array^ members = t->GetMembers(); - - // Get and display the name and the MemberType for each member. - Console::WriteLine("Members of {0}", t->Name); - for each (MemberInfo^ member in members) { - MemberTypes memberType = member->MemberType; - Console::WriteLine(" {0}: {1}", member->Name, memberType); - } -} -// The example displays the following output: -// Members of ReflectionTypeLoadException -// get_Types: Method -// get_LoaderExceptions: Method -// GetObjectData: Method -// get_Message: Method -// get_Data: Method -// GetBaseException: Method -// get_InnerException: Method -// get_TargetSite: Method -// get_StackTrace: Method -// get_HelpLink: Method -// set_HelpLink: Method -// get_Source: Method -// set_Source: Method -// ToString: Method -// get_HResult: Method -// GetType: Method -// Equals: Method -// GetHashCode: Method -// GetType: Method -// .ctor: Constructor -// .ctor: Constructor -// Types: Property -// LoaderExceptions: Property -// Message: Property -// Data: Property -// InnerException: Property -// TargetSite: Property -// StackTrace: Property -// HelpLink: Property -// Source: Property -// HResult: Property -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals.cpp deleted file mode 100644 index 3caae363b62..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Equals.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -#using - -using namespace System; -using namespace System::Numerics; - -void main() -{ - BigInteger bigIntValue; - - Byte byteValue = 16; - bigIntValue = BigInteger(byteValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - byteValue.GetType()->Name, byteValue, - bigIntValue.Equals((Int64)byteValue)); - - SByte sbyteValue = -16; - bigIntValue = BigInteger(sbyteValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - sbyteValue.GetType()->Name, sbyteValue, - bigIntValue.Equals((Int64)sbyteValue)); - - Int16 shortValue = 1233; - bigIntValue = BigInteger(shortValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - shortValue.GetType()->Name, shortValue, - bigIntValue.Equals((Int64)shortValue)); - - UInt16 ushortValue = 64000; - bigIntValue = BigInteger(ushortValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - ushortValue.GetType()->Name, ushortValue, - bigIntValue.Equals((Int64)ushortValue)); - - int intValue = -1603854; - bigIntValue = BigInteger(intValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - intValue.GetType()->Name, intValue, - bigIntValue.Equals((Int64)intValue)); - - UInt32 uintValue = 1223300; - bigIntValue = BigInteger(uintValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - uintValue.GetType()->Name, uintValue, - bigIntValue.Equals((Int64)uintValue)); - - Int64 longValue = -123822229012; - bigIntValue = BigInteger(longValue); - Console::WriteLine("{0} {1} = {2} {3} : {4}", - bigIntValue.GetType()->Name, bigIntValue, - longValue.GetType()->Name, longValue, - bigIntValue.Equals((Int64)longValue)); -} -/* -The example displays output like the following: - BigInteger 16 = Byte 16 : True - BigInteger -16 = SByte -16 : True - BigInteger 1233 = Int16 1233 : True - BigInteger 64000 = UInt16 64000 : True - BigInteger -1603854 = Int32 -1603854 : True - BigInteger 1223300 = UInt32 1223300 : True - BigInteger -123822229012 = Int64 -123822229012 : True -*/ -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp deleted file mode 100644 index c480f604daa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Equals2.cpp : Defines the entry point for the console application. -// - -// -#using - -using namespace System; -using namespace System::Numerics; - - -void main() -{ - const Int64 LIGHT_YEAR = 5878625373183; - - BigInteger altairDistance = 17 * LIGHT_YEAR; - BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR; - BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR; - Int64 tauCetiDistance = 12 * LIGHT_YEAR; - UInt64 procyon2Distance = 12 * LIGHT_YEAR; - Object^ wolf424ABDistance = 14 * LIGHT_YEAR; - - Console::WriteLine("Approx. equal distances from Epsilon Indi to:"); - Console::WriteLine(" Altair: {0}", - epsilonIndiDistance.Equals(altairDistance)); - Console::WriteLine(" Ursae Majoris 47: {0}", - epsilonIndiDistance.Equals(ursaeMajoris47Distance)); - Console::WriteLine(" TauCeti: {0}", - epsilonIndiDistance.Equals(tauCetiDistance)); - Console::WriteLine(" Procyon 2: {0}", - epsilonIndiDistance.Equals(procyon2Distance)); - Console::WriteLine(" Wolf 424 AB: {0}", - epsilonIndiDistance.Equals(wolf424ABDistance)); -} -/* -The example displays output like the following: - Approx. equal distances from Epsilon Indi to: - Altair: False - Ursae Majoris 47: False - TauCeti: True - Procyon 2: True - Wolf 424 AB: False -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/CPP/source.cpp deleted file mode 100644 index 44abeeae6c3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -class MethodBodyDemo -{ -public: - - // This class will demonstrate how to create a method body using - // the MethodBuilder::CreateMethodBody(Byte[], int) method. - static Type^ BuildDynType() - { - Type^ addType = nullptr; - AppDomain^ currentDom = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBldr = currentDom->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - - // The dynamic assembly space has been created. Next, create a module - // within it. The type Point will be reflected into this module. - ModuleBuilder^ myModuleBldr = myAsmBldr->DefineDynamicModule( "MyModule" ); - TypeBuilder^ myTypeBldr = myModuleBldr->DefineType( "Adder" ); - array^temp0 = {int::typeid,int::typeid}; - MethodBuilder^ myMthdBldr = myTypeBldr->DefineMethod( "DoAdd", static_cast(MethodAttributes::Public | MethodAttributes::Static), int::typeid, temp0 ); - - // Build the array of Bytes holding the MSIL instructions. - - /* 02h is the opcode for ldarg.0 */ - /* 03h is the opcode for ldarg.1 */ - /* 58h is the opcode for add */ - /* 2Ah is the opcode for ret */ - array^temp1 = {0x02,0x03,0x58,0x2A}; - array^ILcodes = temp1; - myMthdBldr->CreateMethodBody( ILcodes, ILcodes->Length ); - addType = myTypeBldr->CreateType(); - return addType; - } - -}; - -int main() -{ - Type^ myType = MethodBodyDemo::BuildDynType(); - Console::WriteLine( "---" ); - Console::Write( "Enter the first integer to add: " ); - int aVal = Convert::ToInt32( Console::ReadLine() ); - Console::Write( "Enter the second integer to add: " ); - int bVal = Convert::ToInt32( Console::ReadLine() ); - Object^ adderInst = Activator::CreateInstance( myType, gcnew array(0) ); - array^temp1 = {aVal,bVal}; - Console::WriteLine( "The value of adding {0} to {1} is: {2}.", aVal, bVal, myType->InvokeMember( "DoAdd", BindingFlags::InvokeMethod, nullptr, adderInst, temp1 ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/GetAssembly1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/GetAssembly1.cpp deleted file mode 100644 index bd325cd3b40..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/GetAssembly1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Get a Type object. - Type^ t = int::typeid; - // Instantiate an Assembly class to the assembly housing the Integer type. - Assembly^ assem = Assembly::GetAssembly(t); - // Display the name of the assembly. - Console::WriteLine("Name: {0}", assem->FullName); - // Get the location of the assembly using the file: protocol. - Console::WriteLine("CodeBase: {0}", assem->CodeBase); -} -// The example displays output like the following: -// Name: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 -// CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp deleted file mode 100644 index 21eed0e53a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp +++ /dev/null @@ -1,182 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; - -void Snippet1() -{ - Assembly^ SampleAssembly; - // Instantiate a target object. - Int32 Integer1(0); - Type^ Type1; - // Set the Type instance to the target class type. - Type1 = Integer1.GetType(); - // Instantiate an Assembly class to the assembly housing the Integer type. - SampleAssembly = Assembly::GetAssembly( Integer1.GetType() ); - // Gets the location of the assembly using file: protocol. - Console::WriteLine( "CodeBase= {0}", SampleAssembly->CodeBase ); -} -void Snippet2() -{ - // - Assembly^ SampleAssembly; - // Instantiate a target object. - Int32 Integer1(0); - Type^ Type1; - // Set the Type instance to the target class type. - Type1 = Integer1.GetType(); - // Instantiate an Assembly class to the assembly housing the Integer type. - SampleAssembly = Assembly::GetAssembly( Integer1.GetType() ); - // Write the display name of assembly including base name and version. - Console::WriteLine( "FullName= {0}", SampleAssembly->FullName ); - // The example displays the following output: - // FullName=mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - // -} -void Snippet3() -{ - // - Assembly^ SampleAssembly; - // Instantiate a target object. - Int32 Integer1(0); - Type^ Type1; - // Set the Type instance to the target class type. - Type1 = Integer1.GetType(); - // Instantiate an Assembly class to the assembly housing the Integer type. - SampleAssembly = Assembly::GetAssembly( Integer1.GetType() ); - // Display the physical location of the assembly containing the manifest. - Console::WriteLine( "Location= {0}", SampleAssembly->Location ); - // The example displays the following output: - // Location=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll - // -} - -void Snippet5() -{ - // - Assembly^ SampleAssembly; - // Instantiate a target object. - Int32 Integer1(0); - Type^ Type1; - // Set the Type instance to the target class type. - Type1 = Integer1.GetType(); - // Instantiate an Assembly class to the assembly housing the Integer type. - SampleAssembly = Assembly::GetAssembly( Integer1.GetType() ); - // Display the name of the assembly currently executing - Console::WriteLine( "GetExecutingAssembly= {0}", Assembly::GetExecutingAssembly()->FullName ); - // The example displays the following output: - // GetExecutingAssembly=assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - // -} -void Snippet6() -{ - // - Assembly^ SampleAssembly; - // Load the assembly by providing the location of the assembly file. - SampleAssembly = Assembly::LoadFrom( "c:\\Sample.Assembly.dll" ); - for each ( Type^ ExportedType in SampleAssembly->GetExportedTypes() ) - { - Console::WriteLine( ExportedType ); - } - // -} -void Snippet7() -{ - // - Assembly^ SampleAssembly; - // Load the assembly by providing the type name. - SampleAssembly = Assembly::Load( "MyAssembly" ); - for each ( String^ Resource in SampleAssembly->GetManifestResourceNames() ) - { - Console::WriteLine( Resource ); - } - // -} -void Snippet8() -{ - // - Assembly^ SampleAssembly; - SampleAssembly = Assembly::Load( "System.Data" ); - array^ Types = SampleAssembly->GetTypes(); - for each ( Type^ oType in Types ) - { - Console::WriteLine( oType->Name ); - } - // -} -void Snippet9() -{ - // - Assembly^ SampleAssembly; - SampleAssembly = Assembly::LoadFrom( "c:\\Sample.Assembly.dll" ); - - // Obtain a reference to the first class contained in the assembly. - Type^ oType = SampleAssembly->GetTypes()[ 0 ]; - // Obtain a reference to the public properties of the type. - array^ Props = oType->GetProperties(); - // Display information about public properties of assembly type. - // Prop = Prop1 - // DeclaringType = Sample::Assembly.Class1 - // Type = System::String - // Readable = True - // Writable = False - for each ( PropertyInfo^ Prop in Props ) - { - Console::WriteLine( "Prop= {0}", Prop->Name ); - Console::WriteLine( " DeclaringType= {0}", Prop->DeclaringType ); - Console::WriteLine( " Type= {0}", Prop->PropertyType ); - Console::WriteLine( " Readable= {0}", Prop->CanRead ); - Console::WriteLine( " Writable= {0}", Prop->CanWrite ); - } - // -} -void Snippet10() -{ - // - Assembly^ SampleAssembly; - SampleAssembly = Assembly::LoadFrom( "c:\\Sample.Assembly.dll" ); - array^ Methods = SampleAssembly->GetTypes()[ 0 ]->GetMethods(); - // Obtain a reference to the method members - for each ( MethodInfo^ Method in Methods ) - { - Console::WriteLine( "Method Name= {0}", Method->Name ); - } - // -} -void Snippet11() -{ - // - Assembly^ SampleAssembly; - SampleAssembly = Assembly::LoadFrom( "c:\\Sample.Assembly.dll" ); - // Obtain a reference to a method known to exist in assembly. - MethodInfo^ Method = SampleAssembly->GetTypes()[ 0 ]->GetMethod( "Method1" ); - // Obtain a reference to the parameters collection of the MethodInfo instance. - array^ Params = Method->GetParameters(); - // Display information about method parameters. - // Param = sParam1 - // Type = System::String - // Position = 0 - // Optional=False - for each ( ParameterInfo^ Param in Params ) - { - Console::WriteLine( "Param= {0}", Param->Name ); - Console::WriteLine( " Type= {0}", Param->ParameterType ); - Console::WriteLine( " Position= {0}", Param->Position ); - Console::WriteLine( " Optional= {0}", Param->IsOptional ); - } - // - Console::ReadLine(); -} - -void main() -{ - Snippet1(); - Snippet2(); - Snippet3(); - Snippet5(); - Snippet6(); - Snippet7(); - Snippet8(); - Snippet9(); - Snippet10(); - Snippet11(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/codebase1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/codebase1.cpp deleted file mode 100644 index 3c54fa6e1c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/codebase1.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Instantiate a target object. - int integer1 = 1632; - // Instantiate an Assembly class to the assembly housing the Integer type. - Assembly^ systemAssembly = integer1.GetType()->Assembly; - // Get the location of the assembly using the file: protocol. - Console::WriteLine("CodeBase = {0}", systemAssembly->CodeBase); -} -// The example displays output like the following: -// CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/getcallingassembly1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/getcallingassembly1.cpp deleted file mode 100644 index a109f1df474..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/getcallingassembly1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Instantiate a target object. - Int32 integer1 = 0; - // Set the Type instance to the target class type. - Type^ type1 = integer1.GetType(); - // Instantiate an Assembly class to the assembly housing the Integer type. - Assembly^ sampleAssembly = Assembly::GetAssembly(integer1.GetType()); - // Display the name of the assembly that is calling the method. - Console::WriteLine("GetCallingAssembly = {0}", Assembly::GetCallingAssembly()->FullName); -} -// The example displays output like the following: -// GetCallingAssembly = Example, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp deleted file mode 100644 index ba2e35bfbb6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ DynamicDotProductGen() -{ - Type^ ivType = nullptr; - array^temp0 = {int::typeid,int::typeid,int::typeid}; - array^ctorParams = temp0; - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "IntVectorAsm"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ IntVectorModule = myAsmBuilder->DefineDynamicModule( "IntVectorModule", "Vector.dll" ); - TypeBuilder^ ivTypeBld = IntVectorModule->DefineType( "IntVector", TypeAttributes::Public ); - FieldBuilder^ xField = ivTypeBld->DefineField( "x", int::typeid, FieldAttributes::Private ); - FieldBuilder^ yField = ivTypeBld->DefineField( "y", int::typeid, FieldAttributes::Private ); - FieldBuilder^ zField = ivTypeBld->DefineField( "z", int::typeid, FieldAttributes::Private ); - Type^ objType = Type::GetType( "System.Object" ); - ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array(0) ); - ConstructorBuilder^ ivCtor = ivTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams ); - ILGenerator^ ctorIL = ivCtor->GetILGenerator(); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Call, objCtor ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_1 ); - ctorIL->Emit( OpCodes::Stfld, xField ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_2 ); - ctorIL->Emit( OpCodes::Stfld, yField ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_3 ); - ctorIL->Emit( OpCodes::Stfld, zField ); - ctorIL->Emit( OpCodes::Ret ); - - // This method will find the dot product of the stored vector - // with another. - array^temp1 = {ivTypeBld}; - array^dpParams = temp1; - - // Here, you create a MethodBuilder containing the - // name, the attributes (public, static, private, and so on), - // the return type (int, in this case), and a array of Type - // indicating the type of each parameter. Since the sole parameter - // is a IntVector, the very class you're creating, you will - // pass in the TypeBuilder (which is derived from Type) instead of - // a Type object for IntVector, avoiding an exception. - // -- This method would be declared in C# as: - // public int DotProduct(IntVector aVector) - MethodBuilder^ dotProductMthd = ivTypeBld->DefineMethod( "DotProduct", MethodAttributes::Public, int::typeid, dpParams ); - - // A ILGenerator can now be spawned, attached to the MethodBuilder. - ILGenerator^ mthdIL = dotProductMthd->GetILGenerator(); - - // Here's the body of our function, in MSIL form. We're going to find the - // "dot product" of the current vector instance with the passed vector - // instance. For reference purposes, the equation is: - // (x1 * x2) + (y1 * y2) + (z1 * z2) = the dot product - // First, you'll load the reference to the current instance "this" - // stored in argument 0 (ldarg.0) onto the stack. Ldfld, the subsequent - // instruction, will pop the reference off the stack and look up the - // field "x", specified by the FieldInfo token "xField". - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldfld, xField ); - - // That completed, the value stored at field "x" is now atop the stack. - // Now, you'll do the same for the Object reference we passed as a - // parameter, stored in argument 1 (ldarg.1). After Ldfld executed, - // you'll have the value stored in field "x" for the passed instance - // atop the stack. - mthdIL->Emit( OpCodes::Ldarg_1 ); - mthdIL->Emit( OpCodes::Ldfld, xField ); - - // There will now be two values atop the stack - the "x" value for the - // current vector instance, and the "x" value for the passed instance. - // You'll now multiply them, and push the result onto the evaluation stack. - mthdIL->Emit( OpCodes::Mul_Ovf_Un ); - - // Now, repeat this for the "y" fields of both vectors. - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldfld, yField ); - mthdIL->Emit( OpCodes::Ldarg_1 ); - mthdIL->Emit( OpCodes::Ldfld, yField ); - mthdIL->Emit( OpCodes::Mul_Ovf_Un ); - - // At this time, the results of both multiplications should be atop - // the stack. You'll now add them and push the result onto the stack. - mthdIL->Emit( OpCodes::Add_Ovf_Un ); - - // Multiply both "z" field and push the result onto the stack. - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldfld, zField ); - mthdIL->Emit( OpCodes::Ldarg_1 ); - mthdIL->Emit( OpCodes::Ldfld, zField ); - mthdIL->Emit( OpCodes::Mul_Ovf_Un ); - - // Finally, add the result of multiplying the "z" fields with the - // result of the earlier addition, and push the result - the dot product - - // onto the stack. - mthdIL->Emit( OpCodes::Add_Ovf_Un ); - - // The "ret" opcode will pop the last value from the stack and return it - // to the calling method. You're all done! - mthdIL->Emit( OpCodes::Ret ); - ivType = ivTypeBld->CreateType(); - return ivType; -} - -int main() -{ - Type^ IVType = nullptr; - Object^ aVector1 = nullptr; - Object^ aVector2 = nullptr; - array^temp2 = {int::typeid,int::typeid,int::typeid}; - array^aVtypes = temp2; - array^temp3 = {10,10,10}; - array^aVargs1 = temp3; - array^temp4 = {20,20,20}; - array^aVargs2 = temp4; - - // Call the method to build our dynamic class. - IVType = DynamicDotProductGen(); - Console::WriteLine( "---" ); - ConstructorInfo^ myDTctor = IVType->GetConstructor( aVtypes ); - aVector1 = myDTctor->Invoke( aVargs1 ); - aVector2 = myDTctor->Invoke( aVargs2 ); - array^passMe = gcnew array(1); - passMe[ 0 ] = dynamic_cast(aVector2); - Console::WriteLine( "(10, 10, 10) . (20, 20, 20) = {0}", IVType->InvokeMember( "DotProduct", BindingFlags::InvokeMethod, nullptr, aVector1, passMe ) ); -} - -// +++ OUTPUT +++ -// --- -// (10, 10, 10) . (20, 20, 20) = 600 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.AddResourceFile Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.AddResourceFile Example/CPP/source.cpp deleted file mode 100644 index 210c6ee6489..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.AddResourceFile Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -ref class AsmBuilderGetFileDemo -{ -public: - static String^ myResourceFileName = "MyResource.txt"; - static FileInfo^ CreateResourceFile() - { - FileInfo^ f = gcnew FileInfo( myResourceFileName ); - StreamWriter^ sw = f->CreateText(); - sw->WriteLine( "Hello, world!" ); - sw->Close(); - return f; - } - - static AssemblyBuilder^ BuildDynAssembly() - { - String^ myAsmFileName = "MyAsm.dll"; - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - myAsmBuilder->AddResourceFile( "MyResource", myResourceFileName ); - - // To confirm that the resource file has been added to the manifest, - // we will save the assembly as MyAsm.dll. You can view the manifest - // and confirm the presence of the resource file by running - // "ildasm MyAsm.dll" from the prompt in the directory where you executed - // the compiled code. - myAsmBuilder->Save( myAsmFileName ); - return myAsmBuilder; - } - -}; - -int main() -{ - FileStream^ myResourceFS = nullptr; - AsmBuilderGetFileDemo::CreateResourceFile(); - Console::WriteLine( "The contents of MyResource.txt, via GetFile:" ); - AssemblyBuilder^ myAsm = AsmBuilderGetFileDemo::BuildDynAssembly(); - try - { - myResourceFS = myAsm->GetFile( AsmBuilderGetFileDemo::myResourceFileName ); - } - catch ( NotSupportedException^ ) - { - Console::WriteLine( "---" ); - Console::WriteLine( "System::Reflection::Emit::AssemblyBuilder::GetFile\nis not supported in this SDK build." ); - Console::WriteLine( "The file data will now be retrieved directly, via a new FileStream." ); - Console::WriteLine( "---" ); - myResourceFS = gcnew FileStream( AsmBuilderGetFileDemo::myResourceFileName,FileMode::Open ); - } - - StreamReader^ sr = gcnew StreamReader( myResourceFS,System::Text::Encoding::ASCII ); - Console::WriteLine( sr->ReadToEnd() ); - sr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.DefineDynamicModule Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.DefineDynamicModule Example/CPP/source.cpp deleted file mode 100644 index 90c18c11fa1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.DefineDynamicModule Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class TypeBuilderMemberDemo -{ -public: - static void DefineDynamicModuleDemo1() - { - // - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyAssembly"; - AssemblyBuilder^ myAsmBuilder = myAppDomain->DefineDynamicAssembly( - myAsmName, AssemblyBuilderAccess::Run ); - - // Create a transient dynamic module. Since no DLL name is specified with - // this constructor, it cannot be saved. - ModuleBuilder^ myModuleBuilder = myAsmBuilder->DefineDynamicModule( "MyModule1" ); - // - } - - static void DefineDynamicModuleDemo2() - { - // - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyAssembly"; - AssemblyBuilder^ myAsmBuilder = myAppDomain->DefineDynamicAssembly( - myAsmName, AssemblyBuilderAccess::Run ); - - // Create a transient dynamic module. Since no DLL name is specified with - // this constructor, it can not be saved. By specifying the second parameter - // of the constructor as false, we can suppress the emission of symbol info. - ModuleBuilder^ myModuleBuilder = myAsmBuilder->DefineDynamicModule( - "MyModule2", false ); - // - } - - static void DefineDynamicModuleDemo3() - { - // - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyAssembly"; - AssemblyBuilder^ myAsmBuilder = myAppDomain->DefineDynamicAssembly( - myAsmName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module that can be saved as the specified DLL name. - ModuleBuilder^ myModuleBuilder = myAsmBuilder->DefineDynamicModule( - "MyModule3", "MyModule3.dll" ); - // - } - - static void DefineDynamicModuleDemo4() - { - // - AppDomain^ myAppDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyAssembly"; - AssemblyBuilder^ myAsmBuilder = myAppDomain->DefineDynamicAssembly( - myAsmName, AssemblyBuilderAccess::Run ); - - // Create a dynamic module that can be saved as the specified DLL name. By - // specifying the third parameter as true, we can allow the emission of symbol info. - ModuleBuilder^ myModuleBuilder = myAsmBuilder->DefineDynamicModule( - "MyModule4", "MyModule4.dll", true ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/CPP/source.cpp deleted file mode 100644 index 7ecadcfc345..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/CPP/source.cpp +++ /dev/null @@ -1,236 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// The Point class is the class we will reflect on and copy into our -// dynamic assembly. The public static function PointMain() will be used -// as our entry point. -// -// We are constructing the type seen here dynamically, and will write it -// out into a .exe file for later execution from the command-line. -// --- -// __gc class Point { -// -// private: -// int x; -// int y; -// -// public: -// Point(int ix, int iy) { -// -// this->x = ix; -// this->y = iy; -// -// } -// -// int DotProduct (Point* p) { -// -// return ((this->x * p->x) + (this->y * p->y)); -// -// } -// -// static void PointMain() { -// -// Console::Write(S"Enter the 'x' value for point 1: "); -// int x1 = Convert::ToInt32(Console::ReadLine()); -// -// Console::Write(S"Enter the 'y' value for point 1: "); -// int y1 = Convert::ToInt32(Console::ReadLine()); -// -// Console::Write(S"Enter the 'x' value for point 2: "); -// int x2 = Convert::ToInt32(Console::ReadLine()); -// -// Console::Write(S"Enter the 'y' value for point 2: "); -// int y2 = Convert::ToInt32(Console::ReadLine()); -// -// Point* p1 = new Point(x1, y1); -// Point* p2 = new Point(x2, y2); -// -// Console::WriteLine(S"( {0}, {1}) . ( {2}, {3}) = {4}.", -// __box(x1), __box(y1), __box(x2), __box(y2), p1->DotProduct(p2)); -// -// } -// -// }; -// --- -Type^ BuildDynAssembly() -{ - Type^ pointType = nullptr; - AppDomain^ currentDom = Thread::GetDomain(); - Console::Write( "Please enter a name for your new assembly: " ); - StringBuilder^ asmFileNameBldr = gcnew StringBuilder; - asmFileNameBldr->Append( Console::ReadLine() ); - asmFileNameBldr->Append( ".exe" ); - String^ asmFileName = asmFileNameBldr->ToString(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBldr = currentDom->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - - // We've created a dynamic assembly space - now, we need to create a module - // within it to reflect the type Point into. - ModuleBuilder^ myModuleBldr = myAsmBldr->DefineDynamicModule( asmFileName, asmFileName ); - TypeBuilder^ myTypeBldr = myModuleBldr->DefineType( "Point" ); - FieldBuilder^ xField = myTypeBldr->DefineField( "x", int::typeid, FieldAttributes::Private ); - FieldBuilder^ yField = myTypeBldr->DefineField( "y", int::typeid, FieldAttributes::Private ); - - // Build the constructor. - Type^ objType = Type::GetType( "System.Object" ); - ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array(0) ); - array^temp4 = {int::typeid,int::typeid}; - array^ctorParams = temp4; - ConstructorBuilder^ pointCtor = myTypeBldr->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams ); - ILGenerator^ ctorIL = pointCtor->GetILGenerator(); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Call, objCtor ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_1 ); - ctorIL->Emit( OpCodes::Stfld, xField ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_2 ); - ctorIL->Emit( OpCodes::Stfld, yField ); - ctorIL->Emit( OpCodes::Ret ); - - // Build the DotProduct method. - Console::WriteLine( "Constructor built." ); - array^temp0 = {myTypeBldr}; - MethodBuilder^ pointDPBldr = myTypeBldr->DefineMethod( "DotProduct", MethodAttributes::Public, int::typeid, temp0 ); - ILGenerator^ dpIL = pointDPBldr->GetILGenerator(); - dpIL->Emit( OpCodes::Ldarg_0 ); - dpIL->Emit( OpCodes::Ldfld, xField ); - dpIL->Emit( OpCodes::Ldarg_1 ); - dpIL->Emit( OpCodes::Ldfld, xField ); - dpIL->Emit( OpCodes::Mul_Ovf_Un ); - dpIL->Emit( OpCodes::Ldarg_0 ); - dpIL->Emit( OpCodes::Ldfld, yField ); - dpIL->Emit( OpCodes::Ldarg_1 ); - dpIL->Emit( OpCodes::Ldfld, yField ); - dpIL->Emit( OpCodes::Mul_Ovf_Un ); - dpIL->Emit( OpCodes::Add_Ovf_Un ); - dpIL->Emit( OpCodes::Ret ); - - // Build the PointMain method. - Console::WriteLine( "DotProduct built." ); - MethodBuilder^ pointMainBldr = myTypeBldr->DefineMethod( "PointMain", static_cast(MethodAttributes::Public | MethodAttributes::Static), void::typeid, nullptr ); - pointMainBldr->InitLocals = true; - ILGenerator^ pmIL = pointMainBldr->GetILGenerator(); - - // We have four methods that we wish to call, and must represent as - // MethodInfo tokens: - // - void Console::WriteLine(String*) - // - String* Console::ReadLine() - // - int Convert::Int32(String*) - // - void Console::WriteLine(String*, Object*[]) - array^temp1 = {String::typeid}; - MethodInfo^ writeMI = Console::typeid->GetMethod( "Write", temp1 ); - MethodInfo^ readLineMI = Console::typeid->GetMethod( "ReadLine", gcnew array(0) ); - array^temp2 = {String::typeid}; - MethodInfo^ convertInt32MI = Convert::typeid->GetMethod( "ToInt32", temp2 ); - array^temp5 = {String::typeid,array::typeid}; - array^wlParams = temp5; - MethodInfo^ writeLineMI = Console::typeid->GetMethod( "WriteLine", wlParams ); - - // Although we could just refer to the local variables by - // index (short ints for Ldloc/Stloc, bytes for LdLoc_S/Stloc_S), - // this time, we'll use LocalBuilders for clarity and to - // demonstrate their usage and syntax. - LocalBuilder^ x1LB = pmIL->DeclareLocal( int::typeid ); - LocalBuilder^ y1LB = pmIL->DeclareLocal( int::typeid ); - LocalBuilder^ x2LB = pmIL->DeclareLocal( int::typeid ); - LocalBuilder^ y2LB = pmIL->DeclareLocal( int::typeid ); - LocalBuilder^ point1LB = pmIL->DeclareLocal( myTypeBldr ); - LocalBuilder^ point2LB = pmIL->DeclareLocal( myTypeBldr ); - LocalBuilder^ tempObjArrLB = pmIL->DeclareLocal( array::typeid ); - pmIL->Emit( OpCodes::Ldstr, "Enter the 'x' value for point 1: " ); - pmIL->EmitCall( OpCodes::Call, writeMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, readLineMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, convertInt32MI, nullptr ); - pmIL->Emit( OpCodes::Stloc, x1LB ); - pmIL->Emit( OpCodes::Ldstr, "Enter the 'y' value for point 1: " ); - pmIL->EmitCall( OpCodes::Call, writeMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, readLineMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, convertInt32MI, nullptr ); - pmIL->Emit( OpCodes::Stloc, y1LB ); - pmIL->Emit( OpCodes::Ldstr, "Enter the 'x' value for point 2: " ); - pmIL->EmitCall( OpCodes::Call, writeMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, readLineMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, convertInt32MI, nullptr ); - pmIL->Emit( OpCodes::Stloc, x2LB ); - pmIL->Emit( OpCodes::Ldstr, "Enter the 'y' value for point 2: " ); - pmIL->EmitCall( OpCodes::Call, writeMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, readLineMI, nullptr ); - pmIL->EmitCall( OpCodes::Call, convertInt32MI, nullptr ); - pmIL->Emit( OpCodes::Stloc, y2LB ); - pmIL->Emit( OpCodes::Ldloc, x1LB ); - pmIL->Emit( OpCodes::Ldloc, y1LB ); - pmIL->Emit( OpCodes::Newobj, pointCtor ); - pmIL->Emit( OpCodes::Stloc, point1LB ); - pmIL->Emit( OpCodes::Ldloc, x2LB ); - pmIL->Emit( OpCodes::Ldloc, y2LB ); - pmIL->Emit( OpCodes::Newobj, pointCtor ); - pmIL->Emit( OpCodes::Stloc, point2LB ); - pmIL->Emit( OpCodes::Ldstr, "( {0}, {1}) . ( {2}, {3}) = {4}." ); - pmIL->Emit( OpCodes::Ldc_I4_5 ); - pmIL->Emit( OpCodes::Newarr, Object::typeid ); - pmIL->Emit( OpCodes::Stloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldc_I4_0 ); - pmIL->Emit( OpCodes::Ldloc, x1LB ); - pmIL->Emit( OpCodes::Box, int::typeid ); - pmIL->Emit( OpCodes::Stelem_Ref ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldc_I4_1 ); - pmIL->Emit( OpCodes::Ldloc, y1LB ); - pmIL->Emit( OpCodes::Box, int::typeid ); - pmIL->Emit( OpCodes::Stelem_Ref ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldc_I4_2 ); - pmIL->Emit( OpCodes::Ldloc, x2LB ); - pmIL->Emit( OpCodes::Box, int::typeid ); - pmIL->Emit( OpCodes::Stelem_Ref ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldc_I4_3 ); - pmIL->Emit( OpCodes::Ldloc, y2LB ); - pmIL->Emit( OpCodes::Box, int::typeid ); - pmIL->Emit( OpCodes::Stelem_Ref ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->Emit( OpCodes::Ldc_I4_4 ); - pmIL->Emit( OpCodes::Ldloc, point1LB ); - pmIL->Emit( OpCodes::Ldloc, point2LB ); - pmIL->EmitCall( OpCodes::Callvirt, pointDPBldr, nullptr ); - pmIL->Emit( OpCodes::Box, int::typeid ); - pmIL->Emit( OpCodes::Stelem_Ref ); - pmIL->Emit( OpCodes::Ldloc, tempObjArrLB ); - pmIL->EmitCall( OpCodes::Call, writeLineMI, nullptr ); - pmIL->Emit( OpCodes::Ret ); - Console::WriteLine( "PointMain (entry point) built." ); - pointType = myTypeBldr->CreateType(); - Console::WriteLine( "Type completed." ); - myAsmBldr->SetEntryPoint( pointMainBldr ); - myAsmBldr->Save( asmFileName ); - Console::WriteLine( "Assembly saved as ' {0}'.", asmFileName ); - Console::WriteLine( "Type ' {0}' at the prompt to run your new dynamically generated dot product calculator.", asmFileName ); - - // After execution, this program will have generated and written to disk, - // in the directory you executed it from, a program named - // .exe. You can run it by typing - // the name you gave it during execution, in the same directory where - // you executed this program. - return pointType; -} - -int main() -{ - Type^ myType = BuildDynAssembly(); - Console::WriteLine( "---" ); - - // Let's invoke the type 'Point' created in our dynamic assembly. - array^temp3 = {nullptr,nullptr}; - Object^ ptInstance = Activator::CreateInstance( myType, temp3 ); - myType->InvokeMember( "PointMain", BindingFlags::InvokeMethod, nullptr, ptInstance, gcnew array(0) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp deleted file mode 100644 index 5fc4617dce5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp +++ /dev/null @@ -1,150 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ DynamicPointTypeGen() -{ - Type^ pointType = nullptr; - array^temp0 = {int::typeid,int::typeid,int::typeid}; - array^ctorParams = temp0; - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" ); - TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public ); - FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public ); - FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public ); - FieldBuilder^ zField = pointTypeBld->DefineField( "z", int::typeid, FieldAttributes::Public ); - Type^ objType = Type::GetType( "System.Object" ); - ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array(0) ); - ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams ); - ILGenerator^ ctorIL = pointCtor->GetILGenerator(); - - // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3 - // hold the actual passed parameters. ldarg.0 is used by instance methods - // to hold a reference to the current calling bject instance. Static methods - // do not use arg.0, since they are not instantiated and hence no reference - // is needed to distinguish them. - ctorIL->Emit( OpCodes::Ldarg_0 ); - - // Here, we wish to create an instance of System::Object by invoking its - // constructor, as specified above. - ctorIL->Emit( OpCodes::Call, objCtor ); - - // Now, we'll load the current instance in arg 0, along - // with the value of parameter "x" stored in arg 1, into stfld. - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_1 ); - ctorIL->Emit( OpCodes::Stfld, xField ); - - // Now, we store arg 2 "y" in the current instance with stfld. - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_2 ); - ctorIL->Emit( OpCodes::Stfld, yField ); - - // Last of all, arg 3 "z" gets stored in the current instance. - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_3 ); - ctorIL->Emit( OpCodes::Stfld, zField ); - - // Our work complete, we return. - ctorIL->Emit( OpCodes::Ret ); - - // Now, let's create three very simple methods so we can see our fields. - array^temp1 = {"GetX","GetY","GetZ"}; - array^mthdNames = temp1; - System::Collections::IEnumerator^ myEnum = mthdNames->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ mthdName = safe_cast(myEnum->Current); - MethodBuilder^ getFieldMthd = pointTypeBld->DefineMethod( mthdName, MethodAttributes::Public, int::typeid, nullptr ); - ILGenerator^ mthdIL = getFieldMthd->GetILGenerator(); - mthdIL->Emit( OpCodes::Ldarg_0 ); - if ( mthdName->Equals( "GetX" ) ) - mthdIL->Emit( OpCodes::Ldfld, xField ); - else - if ( mthdName->Equals( "GetY" ) ) - mthdIL->Emit( OpCodes::Ldfld, yField ); - else - if ( mthdName->Equals( "GetZ" ) ) - mthdIL->Emit( OpCodes::Ldfld, zField ); - - - - mthdIL->Emit( OpCodes::Ret ); - } - - pointType = pointTypeBld->CreateType(); - - // Let's save it, just for posterity. - myAsmBuilder->Save( "Point.dll" ); - return pointType; -} - -int main() -{ - Type^ myDynamicType = nullptr; - Object^ aPoint = nullptr; - array^temp2 = {int::typeid,int::typeid,int::typeid}; - array^aPtypes = temp2; - array^temp3 = {4,5,6}; - array^aPargs = temp3; - - // Call the method to build our dynamic class. - myDynamicType = DynamicPointTypeGen(); - Console::WriteLine( "Some information about my new Type '{0}':", myDynamicType->FullName ); - Console::WriteLine( "Assembly: '{0}'", myDynamicType->Assembly ); - Console::WriteLine( "Attributes: '{0}'", myDynamicType->Attributes ); - Console::WriteLine( "Module: '{0}'", myDynamicType->Module ); - Console::WriteLine( "Members: " ); - System::Collections::IEnumerator^ myEnum = myDynamicType->GetMembers()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MemberInfo^ member = safe_cast(myEnum->Current); - Console::WriteLine( "-- {0} {1};", member->MemberType, member->Name ); - } - - Console::WriteLine( "---" ); - - // Let's take a look at the constructor we created. - ConstructorInfo^ myDTctor = myDynamicType->GetConstructor( aPtypes ); - Console::WriteLine( "Constructor: {0};", myDTctor ); - Console::WriteLine( "---" ); - - // Now, we get to use our dynamically-created class by invoking the constructor. - aPoint = myDTctor->Invoke( aPargs ); - Console::WriteLine( "aPoint is type {0}.", aPoint->GetType() ); - - // Finally, let's reflect on the instance of our new type - aPoint - and - // make sure everything proceeded according to plan. - Console::WriteLine( "aPoint.x = {0}", myDynamicType->InvokeMember( "GetX", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array(0) ) ); - Console::WriteLine( "aPoint.y = {0}", myDynamicType->InvokeMember( "GetY", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array(0) ) ); - Console::WriteLine( "aPoint.z = {0}", myDynamicType->InvokeMember( "GetZ", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array(0) ) ); - - // +++ OUTPUT +++ - // Some information about my new Type 'Point': - // Assembly: 'MyDynamicAssembly, Version=0.0.0.0' - // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public' - // Module: 'PointModule' - // Members: - // -- Field x; - // -- Field y; - // -- Field z; - // -- Method GetHashCode; - // -- Method Equals; - // -- Method ToString; - // -- Method GetType; - // -- Constructor .ctor; - // --- - // Constructor: Void .ctor(Int32, Int32, Int32); - // --- - // aPoint is type Point. - // aPoint.x = 4 - // aPoint.y = 5 - // aPoint.z = 6 -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/CPP/source.cpp deleted file mode 100644 index 0529bd4ec8c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/CPP/source.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// We will apply this custom attribute to our dynamic type. -public ref class ClassCreator: public Attribute -{ -private: - String^ creator; - -public: - - property String^ Creator - { - String^ get() - { - return creator; - } - - } - ClassCreator( String^ name ) - { - this->creator = name; - } - -}; - - -// We will apply this dynamic attribute to our dynamic method. -public ref class DateLastUpdated: public Attribute -{ -private: - String^ dateUpdated; - -public: - - property String^ DateUpdated - { - String^ get() - { - return dateUpdated; - } - - } - DateLastUpdated( String^ theDate ) - { - this->dateUpdated = theDate; - } - -}; - -Type^ BuildTypeWithCustomAttributesOnMethod() -{ - AppDomain^ currentDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyAssembly"; - AssemblyBuilder^ myAsmBuilder = currentDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run ); - ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MyModule" ); - - // First, we'll build a type with a custom attribute attached. - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyType", TypeAttributes::Public ); - array^temp6 = {String::typeid}; - array^ctorParams = temp6; - ConstructorInfo^ classCtorInfo = ClassCreator::typeid->GetConstructor( ctorParams ); - array^temp0 = {"Joe Programmer"}; - CustomAttributeBuilder^ myCABuilder = gcnew CustomAttributeBuilder( classCtorInfo,temp0 ); - myTypeBuilder->SetCustomAttribute( myCABuilder ); - - // Now, let's build a method and add a custom attribute to it. - array^temp1 = gcnew array(0); - MethodBuilder^ myMethodBuilder = myTypeBuilder->DefineMethod( "HelloWorld", MethodAttributes::Public, nullptr, temp1 ); - array^temp7 = {String::typeid}; - ctorParams = temp7; - classCtorInfo = DateLastUpdated::typeid->GetConstructor( ctorParams ); - array^temp2 = {DateTime::Now.ToString()}; - CustomAttributeBuilder^ myCABuilder2 = gcnew CustomAttributeBuilder( classCtorInfo,temp2 ); - myMethodBuilder->SetCustomAttribute( myCABuilder2 ); - ILGenerator^ myIL = myMethodBuilder->GetILGenerator(); - myIL->EmitWriteLine( "Hello, world!" ); - myIL->Emit( OpCodes::Ret ); - return myTypeBuilder->CreateType(); -} - -int main() -{ - Type^ myType = BuildTypeWithCustomAttributesOnMethod(); - Object^ myInstance = Activator::CreateInstance( myType ); - array^customAttrs = myType->GetCustomAttributes( true ); - Console::WriteLine( "Custom Attributes for Type 'MyType':" ); - Object^ attrVal = nullptr; - System::Collections::IEnumerator^ myEnum = customAttrs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ customAttr = safe_cast(myEnum->Current); - array^temp3 = gcnew array(0); - attrVal = ClassCreator::typeid->InvokeMember( "Creator", BindingFlags::GetProperty, nullptr, customAttr, temp3 ); - Console::WriteLine( "-- Attribute: [{0} = \"{1}\"]", customAttr, attrVal ); - } - - Console::WriteLine( "Custom Attributes for Method 'HelloWorld()' in 'MyType':" ); - customAttrs = myType->GetMember( "HelloWorld" )[ 0 ]->GetCustomAttributes( true ); - System::Collections::IEnumerator^ myEnum2 = customAttrs->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - Object^ customAttr = safe_cast(myEnum2->Current); - array^temp4 = gcnew array(0); - attrVal = DateLastUpdated::typeid->InvokeMember( "DateUpdated", BindingFlags::GetProperty, nullptr, customAttr, temp4 ); - Console::WriteLine( "-- Attribute: [{0} = \"{1}\"]", customAttr, attrVal ); - } - - Console::WriteLine( "---" ); - array^temp5 = gcnew array(0); - Console::WriteLine( myType->InvokeMember( "HelloWorld", BindingFlags::InvokeMethod, nullptr, myInstance, temp5 ) ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp deleted file mode 100644 index 2c62a49f16a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ BuildMyType() -{ - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run ); - ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MyJumpTableDemo" ); - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "JumpTableDemo", TypeAttributes::Public ); - array^temp0 = {int::typeid}; - MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "SwitchMe", static_cast(MethodAttributes::Public | MethodAttributes::Static), String::typeid, temp0 ); - ILGenerator^ myIL = myMthdBuilder->GetILGenerator(); - Label defaultCase = myIL->DefineLabel(); - Label endOfMethod = myIL->DefineLabel(); - - // We are initializing our jump table. Note that the labels - // will be placed later using the MarkLabel method. - array diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/CPP/source.cpp deleted file mode 100644 index 06f186f7b7b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class MyDynamicAssembly -{ -public: - static void BuildDynamicMethod( TypeBuilder^ myTypeBuilder, - array^ mthdParamTypes, - Type^ returnType, - int addrOfLegacyNumberObject ) - { - // - MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod", - MethodAttributes::Public, - returnType, mthdParamTypes ); - - // We will assume that an external unmanaged type "LegacyNumber" has been loaded, and - // that it has a method "ToString" which returns a String. - - MethodInfo^ unmanagedMthdMI = Type::GetType( "LegacyNumber" )->GetMethod( "ToString" ); - ILGenerator^ myMthdIL = myMthdBuilder->GetILGenerator(); - - // Code to emit various IL opcodes here ... - - // Load a reference to the specific Object instance onto the stack. - - myMthdIL->Emit( OpCodes::Ldc_I4, addrOfLegacyNumberObject ); - myMthdIL->Emit( OpCodes::Ldobj, Type::GetType( "LegacyNumber" ) ); - - // Make the call to the unmanaged type method, telling it that the method is - // the member of a specific instance, to expect a String - // as a return value, and that there are no explicit parameters. - myMthdIL->EmitCalli( OpCodes::Calli, - System::Runtime::InteropServices::CallingConvention::ThisCall, - String::typeid, - gcnew array( 0 ) ); - - // More IL code emission here ... - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp deleted file mode 100644 index cc26ae7bb54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp +++ /dev/null @@ -1,116 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ CreateDynamicType() -{ - array^ctorParams = {int::typeid,int::typeid}; - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run ); - ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" ); - TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public ); - FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public ); - FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public ); - Type^ objType = Type::GetType( "System.Object" ); - ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array(0) ); - ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams ); - ILGenerator^ ctorIL = pointCtor->GetILGenerator(); - - // First, you build the constructor. - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Call, objCtor ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_1 ); - ctorIL->Emit( OpCodes::Stfld, xField ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_2 ); - ctorIL->Emit( OpCodes::Stfld, yField ); - ctorIL->Emit( OpCodes::Ret ); - - // Now, you'll build a method to output some information on the - // inside your dynamic class. This method will have the following - // definition in C#: - // public void WritePoint() - MethodBuilder^ writeStrMthd = pointTypeBld->DefineMethod( "WritePoint", MethodAttributes::Public, void::typeid, nullptr ); - ILGenerator^ writeStrIL = writeStrMthd->GetILGenerator(); - - // The below ILGenerator created demonstrates a few ways to create - // String* output through STDIN. - // ILGenerator::EmitWriteLine(String*) will generate a ldstr and a - // call to WriteLine for you. - writeStrIL->EmitWriteLine( "The value of this current instance is:" ); - - // Here, you will do the hard work yourself. First, you need to create - // the String* we will be passing and obtain the correct WriteLine overload - // for said String*. In the below case, you are substituting in two values, - // so the chosen overload is Console::WriteLine(String*, Object*, Object*). - String^ inStr = "( {0}, {1})"; - array^wlParams = {String::typeid,Object::typeid,Object::typeid}; - - // We need the MethodInfo to pass into EmitCall later. - MethodInfo^ writeLineMI = Console::typeid->GetMethod( "WriteLine", wlParams ); - - // Push the String* with the substitutions onto the stack. - // This is the first argument for WriteLine - the String* one. - writeStrIL->Emit( OpCodes::Ldstr, inStr ); - - // Since the second argument is an Object*, and it corresponds to - // to the substitution for the value of our integer field, you - // need to box that field to an Object*. First, push a reference - // to the current instance, and then push the value stored in - // field 'x'. We need the reference to the current instance (stored - // in local argument index 0) so Ldfld can load from the correct - // instance (this one). - writeStrIL->Emit( OpCodes::Ldarg_0 ); - writeStrIL->Emit( OpCodes::Ldfld, xField ); - - // Now, we execute the box opcode, which pops the value of field 'x', - // returning a reference to the integer value boxed as an Object*. - writeStrIL->Emit( OpCodes::Box, int::typeid ); - - // Atop the stack, you'll find our String* inStr, followed by a reference - // to the boxed value of 'x'. Now, you need to likewise box field 'y'. - writeStrIL->Emit( OpCodes::Ldarg_0 ); - writeStrIL->Emit( OpCodes::Ldfld, yField ); - writeStrIL->Emit( OpCodes::Box, int::typeid ); - - // Now, you have all of the arguments for your call to - // Console::WriteLine(String*, Object*, Object*) atop the stack: - // the String* InStr, a reference to the boxed value of 'x', and - // a reference to the boxed value of 'y'. - // Call Console::WriteLine(String*, Object*, Object*) with EmitCall. - writeStrIL->EmitCall( OpCodes::Call, writeLineMI, nullptr ); - - // Lastly, EmitWriteLine can also output the value of a field - // using the overload EmitWriteLine(FieldInfo). - writeStrIL->EmitWriteLine( "The value of 'x' is:" ); - writeStrIL->EmitWriteLine( xField ); - writeStrIL->EmitWriteLine( "The value of 'y' is:" ); - writeStrIL->EmitWriteLine( yField ); - - // Since we return no value (void), the ret opcode will not - // return the top stack value. - writeStrIL->Emit( OpCodes::Ret ); - return pointTypeBld->CreateType(); -} - -int main() -{ - array^ctorParams = gcnew array(2); - Console::Write( "Enter a integer value for X: " ); - String^ myX = Console::ReadLine(); - Console::Write( "Enter a integer value for Y: " ); - String^ myY = Console::ReadLine(); - Console::WriteLine( "---" ); - ctorParams[ 0 ] = Convert::ToInt32( myX ); - ctorParams[ 1 ] = Convert::ToInt32( myY ); - Type^ ptType = CreateDynamicType(); - Object^ ptInstance = Activator::CreateInstance( ptType, ctorParams ); - ptType->InvokeMember( "WritePoint", BindingFlags::InvokeMethod, nullptr, ptInstance, gcnew array(0) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp deleted file mode 100644 index a8bc130aeb6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -int main() -{ - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "AdderExceptionAsm"; - AssemblyBuilder^ myAsmBldr = myDomain->DefineDynamicAssembly( myAsmName, - AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ myModBldr = myAsmBldr->DefineDynamicModule( myAsmName->Name, - myAsmName->Name + ".dll" ); - TypeBuilder^ myTypeBldr = myModBldr->DefineType( "Adder" ); - array^adderParams = {int::typeid,int::typeid}; - - // This method will add two numbers which are 100 or less. If either of the - // passed integer vales are greater than 100, it will throw an exception. - MethodBuilder^ adderBldr = myTypeBldr->DefineMethod( "DoAdd", - static_cast(MethodAttributes::Public | MethodAttributes::Static), - int::typeid, adderParams ); - ILGenerator^ adderIL = adderBldr->GetILGenerator(); - - // Types and methods used in the code to throw, catch, and - // display OverflowException. Note that if the catch block were - // for a more general type, such as Exception, we would need - // a MethodInfo for that type's ToString method. - // - Type^ overflow = OverflowException::typeid; - ConstructorInfo^ exCtorInfo = overflow->GetConstructor( - gcnew array { String::typeid }); - MethodInfo^ exToStrMI = overflow->GetMethod( "ToString" ); - MethodInfo^ writeLineMI = Console::typeid->GetMethod( "WriteLine", - gcnew array { String::typeid, Object::typeid } ); - - LocalBuilder^ tmp1 = adderIL->DeclareLocal( int::typeid ); - LocalBuilder^ tmp2 = adderIL->DeclareLocal( overflow ); - - // In order to successfully branch, we need to create labels - // representing the offset IL instruction block to branch to. - // These labels, when the MarkLabel(Label) method is invoked, - // will specify the IL instruction to branch to. - // - Label failed = adderIL->DefineLabel(); - Label endOfMthd = adderIL->DefineLabel(); - - // Begin the try block. - Label exBlock = adderIL->BeginExceptionBlock(); - - // First, load argument 0 and the integer value of S"100" onto the - // stack. If arg0 > 100, branch to the label S"failed", which is marked - // as the address of the block that throws an exception. - adderIL->Emit( OpCodes::Ldarg_0 ); - adderIL->Emit( OpCodes::Ldc_I4_S, 100 ); - adderIL->Emit( OpCodes::Bgt_S, failed ); - - // Now, check to see if argument 1 was greater than 100. If it was, - // branch to S"failed." Otherwise, fall through and perform the addition, - // branching unconditionally to the instruction at the label S"endOfMthd". - adderIL->Emit( OpCodes::Ldarg_1 ); - adderIL->Emit( OpCodes::Ldc_I4_S, 100 ); - adderIL->Emit( OpCodes::Bgt_S, failed ); - - adderIL->Emit( OpCodes::Ldarg_0 ); - adderIL->Emit( OpCodes::Ldarg_1 ); - adderIL->Emit( OpCodes::Add_Ovf_Un ); - // Store the result of the addition. - adderIL->Emit( OpCodes::Stloc_S, tmp1 ); - adderIL->Emit( OpCodes::Br_S, endOfMthd ); - - // If one of the arguments was greater than 100, we need to throw an - // exception. We'll use "OverflowException" with a customized message. - // First, we load our message onto the stack, and then create a new - // exception Object using the constructor overload that accepts a - // String* message. - adderIL->MarkLabel( failed ); - adderIL->Emit( OpCodes::Ldstr, "Cannot accept values over 100 for add." ); - adderIL->Emit( OpCodes::Newobj, exCtorInfo ); - - // We're going to need to refer to that exception Object later, so let's - // store it in a temporary variable. Since the store function pops the - // the value/reference off the stack, and we'll need it to throw the - // exception, we will subsequently load it back onto the stack as well. - adderIL->Emit( OpCodes::Stloc_S, tmp2 ); - adderIL->Emit( OpCodes::Ldloc_S, tmp2 ); - - // Throw the exception now on the stack. - adderIL->ThrowException( overflow ); - - // Start the catch block for OverflowException. - // - adderIL->BeginCatchBlock( overflow ); - - // When we enter the catch block, the thrown exception - // is on the stack. Store it, then load the format string - // for WriteLine. - // - adderIL->Emit(OpCodes::Stloc_S, tmp2); - adderIL->Emit(OpCodes::Ldstr, "Caught {0}"); - - // Push the thrown exception back on the stack, then - // call its ToString() method. Note that if this catch block - // were for a more general exception type, like Exception, - // it would be necessary to use the ToString for that type. - // - adderIL->Emit(OpCodes::Ldloc_S, tmp2); - adderIL->EmitCall(OpCodes::Callvirt, exToStrMI, nullptr); - - // The format string and the return value from ToString() are - // now on the stack. Call WriteLine(string, object). - // - adderIL->EmitCall( OpCodes::Call, writeLineMI, nullptr ); - - // Since our function has to return an integer value, we'll load -1 onto - // the stack to indicate an error, and store it in local variable tmp1. - adderIL->Emit( OpCodes::Ldc_I4_M1 ); - adderIL->Emit( OpCodes::Stloc_S, tmp1 ); - - // End the exception handling block. - adderIL->EndExceptionBlock(); - - // The end of the method. If no exception was thrown, the correct value - // will be saved in tmp1. If an exception was thrown, tmp1 will be equal - // to -1. Either way, we'll load the value of tmp1 onto the stack and return. - adderIL->MarkLabel( endOfMthd ); - adderIL->Emit( OpCodes::Ldloc_S, tmp1 ); - adderIL->Emit( OpCodes::Ret ); - - Type^ adderType = myTypeBldr->CreateType(); - - Object^ addIns = Activator::CreateInstance( adderType ); - - array^addParams = gcnew array(2); - - Console::Write( "Enter an integer value: " ); - addParams[ 0 ] = Convert::ToInt32( Console::ReadLine() ); - - Console::Write( "Enter another integer value: " ); - addParams[ 1 ] = Convert::ToInt32( Console::ReadLine() ); - - Console::WriteLine( "If either integer was > 100, an exception will be thrown." ); - - Console::WriteLine( "---" ); - Console::WriteLine( " {0} + {1} = {2}", addParams[ 0 ], addParams[ 1 ], adderType->InvokeMember( "DoAdd", BindingFlags::InvokeMethod, nullptr, addIns, addParams ) ); -} - -/* This code produces output similar to the following: - -Enter an integer value: 24 -Enter another integer value: 101 -If either integer was > 100, an exception will be thrown. ---- -Caught System.OverflowException: Arithmetic operation resulted in an overflow. - at Adder.DoAdd(Int32 , Int32 ) - 24 + 101 = -1 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/CPP/source.cpp deleted file mode 100644 index 8b29b655e66..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/CPP/source.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ BuildAdderType() -{ - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "AdderExceptionAsm"; - AssemblyBuilder^ myAsmBldr = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run ); - ModuleBuilder^ myModBldr = myAsmBldr->DefineDynamicModule( "AdderExceptionMod" ); - TypeBuilder^ myTypeBldr = myModBldr->DefineType( "Adder" ); - array^adderParams = {int::typeid,int::typeid}; - - // This method will add two numbers which are 100 or less. If either of the - // passed integer vales are greater than 100, it will return the value of -1. - MethodBuilder^ adderBldr = myTypeBldr->DefineMethod( "DoAdd", static_cast(MethodAttributes::Public | MethodAttributes::Static), int::typeid, adderParams ); - ILGenerator^ adderIL = adderBldr->GetILGenerator(); - - // In order to successfully branch, we need to create labels - // representing the offset IL instruction block to branch to. - // These labels, when the MarkLabel(Label) method is invoked, - // will specify the IL instruction to branch to. - Label failed = adderIL->DefineLabel(); - Label endOfMthd = adderIL->DefineLabel(); - - // First, load argument 0 and the integer value of "100" onto the - // stack. If arg0 > 100, branch to the label "failed", which is marked - // as the address of the block that loads -1 onto the stack, bypassing - // the addition. - adderIL->Emit( OpCodes::Ldarg_0 ); - adderIL->Emit( OpCodes::Ldc_I4_S, 100 ); - adderIL->Emit( OpCodes::Bgt_S, failed ); - - // Now, check to see if argument 1 was greater than 100. If it was, - // branch to "failed." Otherwise, fall through and perform the addition, - // branching unconditionally to the instruction at the label "endOfMthd". - adderIL->Emit( OpCodes::Ldarg_1 ); - adderIL->Emit( OpCodes::Ldc_I4_S, 100 ); - adderIL->Emit( OpCodes::Bgt_S, failed ); - adderIL->Emit( OpCodes::Ldarg_0 ); - adderIL->Emit( OpCodes::Ldarg_1 ); - adderIL->Emit( OpCodes::Add_Ovf_Un ); - adderIL->Emit( OpCodes::Br_S, endOfMthd ); - - // If this label is branched to (the failure case), load -1 onto the stack - // and fall through to the return opcode. - adderIL->MarkLabel( failed ); - adderIL->Emit( OpCodes::Ldc_I4_M1 ); - - // The end of the method. If both values were less than 100, the - // correct result will return. If one of the arguments was greater - // than 100, the result will be -1. - adderIL->MarkLabel( endOfMthd ); - adderIL->Emit( OpCodes::Ret ); - return myTypeBldr->CreateType(); -} - -int main() -{ - Type^ adderType = BuildAdderType(); - Object^ addIns = Activator::CreateInstance( adderType ); - array^addParams = gcnew array(2); - Console::Write( "Enter an integer value: " ); - addParams[ 0 ] = Convert::ToInt32( Console::ReadLine() ); - Console::Write( "Enter another integer value: " ); - addParams[ 1 ] = Convert::ToInt32( Console::ReadLine() ); - Console::WriteLine( "---" ); - int adderResult = safe_cast(adderType->InvokeMember( "DoAdd", BindingFlags::InvokeMethod, nullptr, addIns, addParams )); - if ( adderResult != -1 ) - { - Console::WriteLine( " {0} + {1} = {2}", addParams[ 0 ], addParams[ 1 ], adderResult ); - } - else - { - Console::WriteLine( "One of the integers to add was greater than 100!" ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/CPP/source.cpp deleted file mode 100644 index 13c415b9f79..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/CPP/source.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -void AddMethodDynamically( TypeBuilder^ myTypeBld, - String^ mthdName, - array^ mthdParams, - Type^ returnType, - String^ mthdAction ) -{ - MethodBuilder^ myMthdBld = myTypeBld->DefineMethod( mthdName, static_cast(MethodAttributes::Public | MethodAttributes::Static), returnType, mthdParams ); - ILGenerator^ ILOut = myMthdBld->GetILGenerator(); - int numParams = mthdParams->Length; - for ( Byte x = 0; x < numParams; x++ ) - { - ILOut->Emit( OpCodes::Ldarg_S, x ); - - } - if ( numParams > 1 ) - { - for ( int y = 0; y < (numParams - 1); y++ ) - { - if ( mthdAction->Equals( "A" ) ) - ILOut->Emit( OpCodes::Add ); - else - if ( mthdAction->Equals( "M" ) ) - ILOut->Emit( OpCodes::Mul ); - else - ILOut->Emit( OpCodes::Add ); - - } - } - - ILOut->Emit( OpCodes::Ret ); -}; - -void main() -{ - AppDomain^ myDomain = AppDomain::CurrentDomain; - AssemblyName^ asmName = gcnew AssemblyName; - asmName->Name = "MyDynamicAsm"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( asmName, - AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ myModule = myAsmBuilder->DefineDynamicModule( "MyDynamicAsm", - "MyDynamicAsm.dll" ); - TypeBuilder^ myTypeBld = myModule->DefineType( "MyDynamicType", - TypeAttributes::Public ); - - // Get info from the user to build the method dynamically. - Console::WriteLine( "Let's build a simple method dynamically!" ); - Console::WriteLine( "Please enter a few numbers, separated by spaces." ); - String^ inputNums = Console::ReadLine(); - Console::Write( "Do you want to [A]dd (default) or [M]ultiply these numbers? " ); - String^ myMthdAction = Console::ReadLine()->ToUpper(); - Console::Write( "Lastly, what do you want to name your new dynamic method? " ); - String^ myMthdName = Console::ReadLine(); - - // Process inputNums into an array and create a corresponding Type array - int index = 0; - array^inputNumsList = inputNums->Split(); - array^myMthdParams = gcnew array(inputNumsList->Length); - array^inputValsList = gcnew array(inputNumsList->Length); - for each (String^ inputNum in inputNumsList) - { - inputValsList[ index ] = Convert::ToInt32( inputNum ); - myMthdParams[ index ] = int::typeid; - index++; - } - - - // Now, call the method building method with the parameters, passing the - // TypeBuilder by reference. - AddMethodDynamically( myTypeBld, - myMthdName, - myMthdParams, - int::typeid, - myMthdAction ); - Type^ myType = myTypeBld->CreateType(); - - Console::WriteLine( "---" ); - Console::WriteLine( "The result of {0} the inputted values is: {1}", - ((myMthdAction->Equals( "M" )) ? "multiplying" : "adding"), - myType->InvokeMember( myMthdName, - BindingFlags::InvokeMethod | BindingFlags::Public | BindingFlags::Static, - nullptr, - nullptr, - inputValsList ) ); - Console::WriteLine( "---" ); - - // Let's take a look at the method we created. - // If you are interested in seeing the MSIL generated dynamically for the method - // your program generated, change to the directory where you ran the compiled - // code sample and type "ildasm MyDynamicAsm.dll" at the prompt. When the list - // of manifest contents appears, click on "MyDynamicType" and then on the name of - // of the method you provided during execution. - - myAsmBuilder->Save( "MyDynamicAsm.dll" ); - - MethodInfo^ myMthdInfo = myType->GetMethod( myMthdName ); - Console::WriteLine( "Your Dynamic Method: {0};", myMthdInfo ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/CPP/source.cpp deleted file mode 100644 index e11b9039eea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ -using namespace System; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class MyMethodBuilderDemo -{ -public: - static void BuildDynMethod( ModuleBuilder^ myModBuilder ) - { - // - // myModBuilder is an instance of ModuleBuilder. - // Note that for the use of PermissionSet and SecurityAction, - // the namespaces System::Security and System::Security::Permissions - // should be included. - - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyType", - TypeAttributes::Public ); - - array^ temp0 = {int::typeid, int::typeid}; - MethodBuilder^ myMethod1 = myTypeBuilder->DefineMethod( "MyMethod", - MethodAttributes::Public, - int::typeid, temp0 ); - - PermissionSet^ myMethodPermissions = gcnew PermissionSet( - PermissionState::Unrestricted ); - - myMethod1->AddDeclarativeSecurity( SecurityAction::Demand, - myMethodPermissions ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp deleted file mode 100644 index b0197f9c238..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -class MoreMethodBuilderSnippets -{ -public: - static void ContainerMethod( AssemblyBuilder^ myAsmBuilder ) - { - - // - ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MathFunctions" ); - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "MyMathFunctions", TypeAttributes::Public ); - array^temp0 = {int::typeid,int::typeid}; - MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "Adder", MethodAttributes::Public, int::typeid, temp0 ); - - // Create body via ILGenerator here ... - Type^ myNewType = myTypeBuilder->CreateType(); - Module^ myModule = myMthdBuilder->GetModule(); - array^myModTypes = myModule->GetTypes(); - Console::WriteLine( "Module: {0}", myModule->Name ); - Console::WriteLine( "------- with path {0}", myModule->FullyQualifiedName ); - Console::WriteLine( "------- in assembly {0}", myModule->Assembly->FullName ); - System::Collections::IEnumerator^ myEnum = myModTypes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ myModType = safe_cast(myEnum->Current); - Console::WriteLine( "------- has type {0}", myModType->FullName ); - } - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/CPP/source4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/CPP/source4.cpp deleted file mode 100644 index 8588434c8e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/CPP/source4.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -class MoreMethodBuilderSnippets -{ -public: - static void ContainerMethod( ModuleBuilder^ myModBuilder ) - { - // - TypeBuilder^ myType1 = myModBuilder->DefineType( "MyMathFunctions", TypeAttributes::Public ); - array^temp0 = {Type::GetType( "System.Int32&" ),int::typeid}; - MethodBuilder^ myMthdBuilder = myType1->DefineMethod( "AddToRefValue", MethodAttributes::Public, void::typeid, temp0 ); - ParameterBuilder^ myParam1 = myMthdBuilder->DefineParameter( 1, ParameterAttributes::Out, "thePool" ); - ParameterBuilder^ myParam2 = myMthdBuilder->DefineParameter( 2, ParameterAttributes::In, "addMeToPool" ); - - // Create body via ILGenerator here, and complete the type. - array^myParams = myMthdBuilder->GetParameters(); - Console::WriteLine( "Method: {0}", myMthdBuilder->Name ); - - for each (ParameterInfo^ myParam in myParams) - { - Console::WriteLine("------- Parameter: {0} {1} at pos {2}, with attribute {3}", - myParam->ParameterType, myParam->Name, myParam->Position, - myParam->Attributes.ToString()); - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/CPP/source.cpp deleted file mode 100644 index 3f7e32af646..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class MethodBuilderAssortedMembersDemo -{ -public: - static void MemberSnippets( TypeBuilder^ myTypeBuilder ) - { - // - array^ temp0 = { int::typeid, int::typeid }; - MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod", - MethodAttributes::Public, - CallingConventions::HasThis, - int::typeid, - temp0 ); - - // Specifies that the dynamic method declared above has a an MSIL implementation, - // is managed, synchronized (single-threaded) through the body, and that it - // cannot be inlined. - - myMthdBuilder->SetImplementationFlags( (MethodImplAttributes)( - MethodImplAttributes::IL | - MethodImplAttributes::Managed | - MethodImplAttributes::Synchronized | - MethodImplAttributes::NoInlining) ); - - // Create an ILGenerator for the MethodBuilder and emit MSIL here ... - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/CPP/source.cpp deleted file mode 100644 index 43dd7762fff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class VariousMethodBuilderSnippets -{ -public: - static void ContainerMethod( TypeBuilder^ myDynamicType ) - { - // - array^ temp0 = { String::typeid }; - MethodBuilder^ myMethod = myDynamicType->DefineMethod( "MyMethodReturnsMarshal", - MethodAttributes::Public, - UInt32::typeid, - temp0 ); - - // We want the return value of our dynamic method to be marshalled as - // an 64-bit (8-Byte) signed integer, instead of the default 32-bit - // unsigned int as specified above. The UnmanagedMarshal class can perform - // the type conversion. - - UnmanagedMarshal^ marshalMeAsI8 = UnmanagedMarshal::DefineUnmanagedMarshal( - System::Runtime::InteropServices::UnmanagedType::I8 ); - - myMethod->SetMarshal( marshalMeAsI8 ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/CPP/source2.cpp deleted file mode 100644 index f2b05b30c44..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/CPP/source2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -class VariousMethodBuilderSnippets -{ -public: - static void ContainerMethod( TypeBuilder^ myDynamicType ) - { - // - array^ temp0 = { String::typeid }; - MethodBuilder^ myMethod = myDynamicType->DefineMethod( "MyMethod", - MethodAttributes::Public, - int::typeid, - temp0 ); - - // A 128-bit key in hex form, represented as a Byte array. - array^ keyVal = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xFF, 0xFF}; - - System::Text::ASCIIEncoding^ encoder = gcnew System::Text::ASCIIEncoding; - array^ symFullName = encoder->GetBytes( "My Dynamic Method" ); - - myMethod->SetSymCustomAttribute( "SymID", keyVal ); - myMethod->SetSymCustomAttribute( "SymFullName", symFullName ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/CPP/source.cpp deleted file mode 100644 index 2f0d3457db5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// -int main() -{ - - // We need a blank OpCode Object for reference when calling FieldInfo::GetValue(). - OpCode blankOpCode; - Type^ myOpCodesType = Type::GetType( "System.Reflection.Emit.OpCodes" ); - array^listOfOpCodes = myOpCodesType->GetFields(); - Console::WriteLine( "Which OpCodes take single-Byte arguments?" ); - Console::WriteLine( "-----------------------------------------" ); - - // Now, let's reflect on each FieldInfo and create an instance of the OpCode it represents. - System::Collections::IEnumerator^ myEnum = listOfOpCodes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FieldInfo^ opCodeFI = safe_cast(myEnum->Current); - Object^ theOpCode = opCodeFI->GetValue( blankOpCode ); - Console::WriteLine( " {0}: {1}", opCodeFI->Name, OpCodes::TakesSingleByteArgument( *dynamic_cast(theOpCode) ) ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/CPP/source.cpp deleted file mode 100644 index 7039d6968a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/CPP/source.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ BuildCustomerDataType() -{ - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run ); - ModuleBuilder^ myModBuilder = myAsmBuilder->DefineDynamicModule( "MyMod" ); - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "CustomerData", TypeAttributes::Public ); - FieldBuilder^ customerNameBldr = myTypeBuilder->DefineField( "customerName", String::typeid, FieldAttributes::Private ); - FieldBuilder^ acctIDBldr = myTypeBuilder->DefineField( "acctID", String::typeid, FieldAttributes::Private ); - FieldBuilder^ balanceAmtBldr = myTypeBuilder->DefineField( "balanceAmt", double::typeid, FieldAttributes::Private ); - array^temp0 = {String::typeid,String::typeid,double::typeid}; - ConstructorBuilder^ myCtorBuilder = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::HasThis, temp0 ); - ILGenerator^ ctorIL = myCtorBuilder->GetILGenerator(); - Type^ objType = Type::GetType( "System.Object" ); - ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array(0) ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Call, objCtor ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_1 ); - ctorIL->Emit( OpCodes::Stfld, customerNameBldr ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_2 ); - ctorIL->Emit( OpCodes::Stfld, acctIDBldr ); - ctorIL->Emit( OpCodes::Ldarg_0 ); - ctorIL->Emit( OpCodes::Ldarg_3 ); - ctorIL->Emit( OpCodes::Stfld, balanceAmtBldr ); - ctorIL->Emit( OpCodes::Ret ); - - // This method will take an amount from a static pool and add it to the balance. - // Note that we are passing the first parameter, fundsPool, by reference. Therefore, - // we need to inform the MethodBuilder to expect a ref, by declaring the first - // parameter's type to be System::Double& (a reference to a double). - array^temp4 = {Type::GetType( "System.Double&" ),double::typeid}; - MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "AddFundsFromPool", MethodAttributes::Public, double::typeid, temp4 ); - ParameterBuilder^ poolRefBuilder = myMthdBuilder->DefineParameter( 1, ParameterAttributes::Out, "fundsPool" ); - ParameterBuilder^ amountFromPoolBuilder = myMthdBuilder->DefineParameter( 2, ParameterAttributes::In, "amountFromPool" ); - ILGenerator^ mthdIL = myMthdBuilder->GetILGenerator(); - mthdIL->Emit( OpCodes::Ldarg_1 ); - mthdIL->Emit( OpCodes::Ldarg_1 ); - mthdIL->Emit( OpCodes::Ldind_R8 ); - mthdIL->Emit( OpCodes::Ldarg_2 ); - mthdIL->Emit( OpCodes::Sub ); - mthdIL->Emit( OpCodes::Stind_R8 ); - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldfld, balanceAmtBldr ); - mthdIL->Emit( OpCodes::Ldarg_2 ); - mthdIL->Emit( OpCodes::Add ); - mthdIL->Emit( OpCodes::Stfld, balanceAmtBldr ); - mthdIL->Emit( OpCodes::Ldarg_0 ); - mthdIL->Emit( OpCodes::Ldfld, balanceAmtBldr ); - mthdIL->Emit( OpCodes::Ret ); - return myTypeBuilder->CreateType(); -} - -int main() -{ - Type^ custType = nullptr; - Object^ custObj = nullptr; - array^custArgTypes = {String::typeid,String::typeid,double::typeid}; - - // Call the method to build our dynamic class. - custType = BuildCustomerDataType(); - Console::WriteLine( "---" ); - ConstructorInfo^ myCustCtor = custType->GetConstructor( custArgTypes ); - double initialBalance = 100.00; - array^temp5 = {"Joe Consumer","5678-XYZ",initialBalance}; - custObj = myCustCtor->Invoke( temp5 ); - array^myMemberInfo = custType->GetMember( "AddFundsFromPool" ); - double thePool = 1000.00; - Console::WriteLine( "The pool is currently ${0}", thePool ); - Console::WriteLine( "The original balance of the account instance is ${0}", initialBalance ); - double amountFromPool = 50.00; - Console::WriteLine( "The amount to be subtracted from the pool and added to the account is ${0}", amountFromPool ); - Console::WriteLine( "---" ); - Console::WriteLine( "Calling {0} ...", myMemberInfo[ 0 ] ); - Console::WriteLine( "---" ); - array^passMe = {thePool,amountFromPool}; - Console::WriteLine( "The new balance in the account instance is ${0}", custType->InvokeMember( "AddFundsFromPool", BindingFlags::InvokeMethod, nullptr, custObj, passMe ) ); - thePool = safe_cast(passMe[ 0 ]); - Console::WriteLine( "The new amount in the pool is ${0}", thePool ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp deleted file mode 100644 index 8f782758f2a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -Type^ BuildDynamicTypeWithProperties() -{ - AppDomain^ myDomain = Thread::GetDomain(); - AssemblyName^ myAsmName = gcnew AssemblyName; - myAsmName->Name = "MyDynamicAssembly"; - - // To generate a persistable assembly, specify AssemblyBuilderAccess::RunAndSave. - AssemblyBuilder^ myAsmBuilder = - myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave ); - - // Generate a persistable single-module assembly. - ModuleBuilder^ myModBuilder = - myAsmBuilder->DefineDynamicModule( myAsmName->Name, myAsmName->Name + ".dll" ); - TypeBuilder^ myTypeBuilder = myModBuilder->DefineType( "CustomerData", TypeAttributes::Public ); - - // Define a private field to hold the property value. - FieldBuilder^ customerNameBldr = myTypeBuilder->DefineField( "customerName", String::typeid, FieldAttributes::Private ); - - // The last argument of DefineProperty is an empty array of Type - // objects, because the property has no parameters. (Alternatively, - // you can specify a null value.) - PropertyBuilder^ custNamePropBldr = - myTypeBuilder->DefineProperty( "CustomerName", PropertyAttributes::HasDefault, String::typeid, gcnew array(0) ); - - // The property set and property get methods require a special - // set of attributes. - MethodAttributes getSetAttr = - MethodAttributes::Public | MethodAttributes::SpecialName | - MethodAttributes::HideBySig; - - // Define the "get" accessor method for CustomerName. - MethodBuilder^ custNameGetPropMthdBldr = - myTypeBuilder->DefineMethod( "get_CustomerName", - getSetAttr, - String::typeid, - Type::EmptyTypes ); - - ILGenerator^ custNameGetIL = custNameGetPropMthdBldr->GetILGenerator(); - custNameGetIL->Emit( OpCodes::Ldarg_0 ); - custNameGetIL->Emit( OpCodes::Ldfld, customerNameBldr ); - custNameGetIL->Emit( OpCodes::Ret ); - - // Define the "set" accessor method for CustomerName. - array^temp2 = {String::typeid}; - MethodBuilder^ custNameSetPropMthdBldr = - myTypeBuilder->DefineMethod( "set_CustomerName", - getSetAttr, - nullptr, - temp2 ); - - ILGenerator^ custNameSetIL = custNameSetPropMthdBldr->GetILGenerator(); - custNameSetIL->Emit( OpCodes::Ldarg_0 ); - custNameSetIL->Emit( OpCodes::Ldarg_1 ); - custNameSetIL->Emit( OpCodes::Stfld, customerNameBldr ); - custNameSetIL->Emit( OpCodes::Ret ); - - // Last, we must map the two methods created above to our PropertyBuilder to - // their corresponding behaviors, "get" and "set" respectively. - custNamePropBldr->SetGetMethod( custNameGetPropMthdBldr ); - custNamePropBldr->SetSetMethod( custNameSetPropMthdBldr ); - - Type^ retval = myTypeBuilder->CreateType(); - - // Save the assembly so it can be examined with Ildasm.exe, - // or referenced by a test program. - myAsmBuilder->Save(myAsmName->Name + ".dll"); - return retval; -} - -int main() -{ - Type^ custDataType = BuildDynamicTypeWithProperties(); - array^custDataPropInfo = custDataType->GetProperties(); - System::Collections::IEnumerator^ myEnum = custDataPropInfo->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - PropertyInfo^ pInfo = safe_cast(myEnum->Current); - Console::WriteLine( "Property '{0}' created!", pInfo ); - } - - Console::WriteLine( "---" ); - - // Note that when invoking a property, you need to use the proper BindingFlags - - // BindingFlags::SetProperty when you invoke the "set" behavior, and - // BindingFlags::GetProperty when you invoke the "get" behavior. Also note that - // we invoke them based on the name we gave the property, as expected, and not - // the name of the methods we bound to the specific property behaviors. - Object^ custData = Activator::CreateInstance( custDataType ); - array^temp3 = {"Joe User"}; - custDataType->InvokeMember( "CustomerName", BindingFlags::SetProperty, nullptr, custData, temp3 ); - Console::WriteLine( "The customerName field of instance custData has been set to '{0}'.", custDataType->InvokeMember( "CustomerName", BindingFlags::GetProperty, nullptr, custData, gcnew array(0) ) ); -} - -// --- O U T P U T --- -// The output should be as follows: -// ------------------- -// Property 'System.String CustomerName' created! -// --- -// The customerName field of instance custData has been set to 'Joe User'. -// ------------------- -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/CPP/nestedenum.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/CPP/nestedenum.cpp deleted file mode 100644 index bfeecb340d6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/CPP/nestedenum.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; -using namespace System::Threading; -using namespace System::Text; -using namespace System::Resources; -using namespace System::Collections; -using namespace System::IO; - -// Helper class called when a resolve type event is raised. -ref class TypeResolveHandler -{ -private: - Module^ m_Module; - -public: - TypeResolveHandler( Module^ mod ) - { - m_Module = mod; - } - - Assembly^ ResolveEvent( Object^ sender, ResolveEventArgs^ args ); -}; - -ref class NestedEnum -{ -internal: - static TypeBuilder^ enumType = nullptr; - static Type^ tNested = nullptr; - static Type^ tNesting = nullptr; - -public: - static void Main() - { - AssemblyName^ asmName = gcnew AssemblyName; - asmName->Name = "NestedEnum"; - AssemblyBuilder^ asmBuild = Thread::GetDomain()->DefineDynamicAssembly( asmName, AssemblyBuilderAccess::RunAndSave ); - ModuleBuilder^ modBuild = asmBuild->DefineDynamicModule( "ModuleOne", "NestedEnum.dll" ); - - // Hook up the event listening. - TypeResolveHandler^ typeResolveHandler = gcnew TypeResolveHandler( modBuild ); - - // Add a listener for the type resolve events. - AppDomain^ currentDomain = Thread::GetDomain(); - ResolveEventHandler^ resolveHandler = gcnew ResolveEventHandler( typeResolveHandler, &TypeResolveHandler::ResolveEvent ); - currentDomain->TypeResolve += resolveHandler; - TypeBuilder^ tb = modBuild->DefineType( "AType", TypeAttributes::Public ); - TypeBuilder^ eb = tb->DefineNestedType( "AnEnum", static_cast(TypeAttributes::NestedPublic | TypeAttributes::Sealed), Enum::typeid, 0 ); - eb->DefineField( "value__", int::typeid, static_cast(FieldAttributes::Private | FieldAttributes::SpecialName) ); - FieldBuilder^ fb = eb->DefineField( "Field1", eb, static_cast(FieldAttributes::Public | FieldAttributes::Literal | FieldAttributes::Static) ); - fb->SetConstant( 1 ); - enumType = eb; - - // Comment out this field. - // When this field is defined, the loader cannot determine the size - // of the type. Therefore, a TypeResolve event is generated when the - // nested type is completed. - tb->DefineField( "Field2", eb, FieldAttributes::Public ); - tNesting = tb->CreateType(); - if ( tNesting == nullptr ) - Console::WriteLine( "NestingType CreateType failed but didn't throw!" ); - - try - { - tNested = eb->CreateType(); - if ( tNested == nullptr ) - Console::WriteLine( "NestedType CreateType failed but didn't throw!" ); - } - catch ( Exception^ ) - { - - // This is needed because you might have already completed the type in the TypeResolve event. - } - - if ( tNested != nullptr ) - { - Type^ x = tNested->DeclaringType; - if ( x == nullptr ) - Console::WriteLine( "Declaring type is null." ); - else - Console::WriteLine( x->Name ); - } - - asmBuild->Save( "NestedEnum.dll" ); - - // Remove the listener for the type resolve events. - currentDomain->TypeResolve -= resolveHandler; - } - -}; - -Assembly^ TypeResolveHandler::ResolveEvent( Object^ sender, ResolveEventArgs^ args ) -{ - Console::WriteLine( args->Name ); - - // Use args.Name to look up the type name. In this case, you are getting AnEnum. - try - { - NestedEnum::tNested = NestedEnum::enumType->CreateType(); - } - catch ( Exception^ ) - { - - // This is needed to throw away InvalidOperationException. - // Loader might send the TypeResolve event more than once - // and the type might be complete already. - } - - - // Complete the type. - return m_Module->Assembly; -} - -int main() -{ - NestedEnum::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/cpp/source.cpp deleted file mode 100644 index 8f8a66f0c27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/cpp/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Test -{ -public: - virtual String^ ToString() override - { - return "An instance of class Test!"; - } -}; - -int main() -{ - Test^ target = gcnew Test(); - MethodInfo^ toStringInfo = target->GetType()->GetMethod("ToString"); - Console::WriteLine("{0} is defined in {1}", toStringInfo->Name, - toStringInfo->Module->Name); - - MethodInfo^ getHashCodeInfo = target->GetType()->GetMethod("GetHashCode"); - Console::WriteLine("{0} is defined in {1}", getHashCodeInfo->Name, - getHashCodeInfo->Module->Name); -} - -/* -* This example produces the following console output: -* -* ToString is defined in source.exe -* GetHashCode is defined in mscorlib.dll -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/cpp/hide.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/cpp/hide.cpp deleted file mode 100644 index 2ba285b7284..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/cpp/hide.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// The base class Parent contains an overloaded method PrintCall. -// -public ref class Parent -{ -public: - virtual void PrintCall() - { - Console::WriteLine("Parent's PrintCall()"); - } -public: - virtual void PrintCall(int x) - { - Console::WriteLine("Parent's PrintCall({0})", x); - } -}; - -// The derived class Child hides one overload of the inherited -// method PrintCall. -// -public ref class Child : public Parent -{ -public: - void PrintCall(int i) new - { - Console::WriteLine("Child's PrintCall({0})", i); - } -}; - -int main() -{ - Child^ childInstance = gcnew Child(); - - // In C#, the method in the derived class hides by name and by - // signature, so the overload in the derived class hides only one - // of the overloads in the base class. - // - Console::WriteLine("------ List the overloads of PrintCall in the " + - "derived class Child ------"); - Type^ t = childInstance->GetType(); - for each(MethodInfo^ minfo in t->GetMethods()) - { - if (minfo->Name == "PrintCall") - { - Console::WriteLine("Overload of PrintCall: {0}" + - " IsHideBySig = {1}, DeclaringType = {2}", - minfo, minfo->IsHideBySig, minfo->DeclaringType); - } - } - - // The method PrintCall in the derived class hides one overload of the - // method in Parent. Contrast this with Visual Basic, which hides by - // name instead of by name and signature. In Visual Basic, the - // parameterless overload of PrintCall would be unavailable from Child. - // - Console::WriteLine( - "------ Call the overloads of PrintCall available in Child ------"); - childInstance->PrintCall(); - childInstance->PrintCall(42); - - // If Child is cast to the base type Parent, both overloads of the - // shadowed method can be called. - // - Console::WriteLine( - "------ Call the shadowed overloads of PrintCall ------"); - Parent^ parentInstance = childInstance; - parentInstance->PrintCall(); - parentInstance->PrintCall(42); -} - -/* This code example produces the following output: - ------- List the overloads of PrintCall in the derived class Child ------ -Overload of PrintCall: Void PrintCall(Int32) IsHideBySig = True, DeclaringType = Child -Overload of PrintCall: Void PrintCall() IsHideBySig = True, DeclaringType = Parent -Overload of PrintCall: Void PrintCall(Int32) IsHideBySig = True, DeclaringType = Parent ------- Call the overloads of PrintCall available in Child ------ -Parent's PrintCall() -Child's PrintCall(42) ------- Call the shadowed overloads of PrintCall ------ -Parent's PrintCall() -Parent's PrintCall(42) - -*/ - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/CPP/class1.cpp deleted file mode 100644 index 2fca1e3a971..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/CPP/class1.cpp +++ /dev/null @@ -1,17 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing this class. - Module^ myModule = moduleArray[ 0 ]; - Assembly^ myAssembly = myModule->Assembly; - Console::WriteLine( "myModule.Assembly = {0}.", myAssembly->FullName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp deleted file mode 100644 index 82159ee05f7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; -public ref class MySecondClass{}; - - -// This class does not fit the filter criterion My*. -public ref class YourClass{}; - -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - Module^ myModule = moduleArray[ 0 ]; - array^tArray; - tArray = myModule->FindTypes( Module::FilterTypeName, "My*" ); - IEnumerator^ myEnum = tArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ t = safe_cast(myEnum->Current); - Console::WriteLine( "Found a module beginning with My*: {0}.", t->Name ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/CPP/class1.cpp deleted file mode 100644 index 3aa584f6d2c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/CPP/class1.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; -public ref class MyMainClass{}; - -public ref class MySecondClass{}; - - -// This class does not fit the filter criteria my*. -public ref class YourClass{}; - -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - Module^ myModule = moduleArray[ 0 ]; - array^tArray; - tArray = myModule->FindTypes( Module::FilterTypeNameIgnoreCase, "my*" ); - IEnumerator^ myEnum = tArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ t = safe_cast(myEnum->Current); - Console::WriteLine( "Found a module beginning with my*: {0}", t->Name ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/CPP/class1.cpp deleted file mode 100644 index 68633196a7c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/CPP/class1.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing this class. - Module^ myModule = moduleArray[ 0 ]; - Console::WriteLine( "myModule.FullyQualifiedName = {0}", myModule->FullyQualifiedName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/CPP/class1.cpp deleted file mode 100644 index 38137adc219..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/CPP/class1.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; - -namespace ReflectionModule_Examples -{ - - //Define a module-level attribute. - //A very simple custom attribute. - - [AttributeUsage(AttributeTargets::Class|AttributeTargets::Module)] - public ref class MySimpleAttribute: public Attribute - { - private: - String^ name; - - public: - MySimpleAttribute( String^ newName ) - { - name = newName; - } - - }; - - - [module:MySimpleAttribute("module-level")]; - ref class MyMainClass{}; - -} - -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MySimpleAttribute::typeid->Assembly->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - System::Reflection::Module^ myModule = moduleArray[ 0 ]; - array^attributes; - attributes = myModule->GetCustomAttributes( true ); - IEnumerator^ myEnum = attributes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "Found this attribute on myModule: {0}.", o ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/CPP/class1.cpp deleted file mode 100644 index 3cf8509d34b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/CPP/class1.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; - -namespace ReflectionModule_Examples -{ - - // Define a very simple custom attribute - - [AttributeUsage(AttributeTargets::Class|AttributeTargets::Module)] - public ref class MySimpleAttribute: public Attribute - { - private: - String^ name; - - public: - MySimpleAttribute( String^ newName ) - { - name = newName; - } - - }; - -} - - -//Define a module-level attribute. - -[module:ReflectionModule_Examples::MySimpleAttribute("module-level")]; -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MySimpleAttribute::typeid->Assembly->GetModules( false ); - - // In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - System::Reflection::Module^ myModule = moduleArray[ 0 ]; - array^attributes; - - //Get only MySimpleAttribute attributes for this module. - attributes = myModule->GetCustomAttributes( myModule->GetType( "ReflectionModule_Examples.MySimpleAttribute", false, false ), true ); - IEnumerator^ myEnum = attributes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "Found this attribute on myModule: {0}", o ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/CPP/class1.cpp deleted file mode 100644 index e7972909d1e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/CPP/class1.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -namespace ReflectionModule_Examples -{ - public ref class MyMainClass{}; - -} - -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - Module^ myModule = moduleArray[ 0 ]; - Type^ myType; - myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass" ); - Console::WriteLine( "Got type: {0}", myType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/CPP/class1.cpp deleted file mode 100644 index 7c898abb0c9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/CPP/class1.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -namespace ReflectionModule_Examples -{ - public ref class MyMainClass{}; - -} - -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - Module^ myModule = moduleArray[ 0 ]; - Type^ myType; - myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass", false ); - Console::WriteLine( "Got type: {0}", myType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/CPP/class1.cpp deleted file mode 100644 index 3759068bbe0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/CPP/class1.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -namespace ReflectionModule_Examples -{ - public ref class MyMainClass{}; - -} - -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MyMainClass::typeid->Assembly->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing this class. - Module^ myModule = moduleArray[ 0 ]; - Type^ myType; - myType = myModule->GetType( "ReflectionModule_Examples.MyMainClass", false, false ); - Console::WriteLine( "Got type: {0}", myType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/CPP/class1.cpp deleted file mode 100644 index 651c5025f0d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/CPP/class1.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -namespace ReflectionModule_Examples -{ - - //A very simple custom attribute. - - [AttributeUsage(AttributeTargets::Class|AttributeTargets::Module)] - public ref class MySimpleAttribute: public Attribute - { - private: - String^ name; - - public: - MySimpleAttribute( String^ newName ) - { - name = newName; - } - - }; - -} - - -//Define a module-level attribute. - -[module:ReflectionModule_Examples::MySimpleAttribute("module-level")]; -int main() -{ - array^moduleArray; - moduleArray = ReflectionModule_Examples::MySimpleAttribute::typeid->Assembly->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing these classes. - System::Reflection::Module^ myModule = moduleArray[ 0 ]; - Type^ myType; - myType = myModule->GetType( "ReflectionModule_Examples.MySimpleAttribute" ); - Console::WriteLine( "IsDefined(MySimpleAttribute) = {0}", myModule->IsDefined( myType, false ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/CPP/class1.cpp deleted file mode 100644 index 41922a945e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/CPP/class1.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing this class. - Module^ myModule = moduleArray[ 0 ]; - Console::WriteLine( "myModule->IsResource() = {0}", myModule->IsResource() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/CPP/class1.cpp deleted file mode 100644 index bd17af9afb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/CPP/class1.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - array^moduleArray; - moduleArray = Assembly::GetExecutingAssembly()->GetModules( false ); - - //In a simple project with only one module, the module at index - // 0 will be the module containing this class. - Module^ myModule = moduleArray[ 0 ]; - Console::WriteLine( "myModule->ToString returns: {0}", myModule ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp deleted file mode 100644 index 8720dbc53fd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; - -// Define a sample interface to use as an interface constraint. -interface class ITest{}; - -// Define a base type to use as a class constraint. -public ref class Base{}; - -// Define the generic type to examine. The first generic type parameter, -// T, derives from the class Base and implements ITest. This demonstrates -// a base class constraint and an interface constraint. In the .NET -// Framework version 2.0, C++ has no way of expressing special constraints. -// See the C# example code. -// -generic - where T : Base, ITest -ref class Test {}; - -// Define a type that derives from Base and implements interface -// ITest. This type satisfies the constraint on T in class Test. -public ref class Derived: public Base, public ITest {}; - -public ref class Example -{ -public: - static void Main() - { - // Create a constructed type from Test, and from it - // get the generic type definition. - // - Type^ def = Test::typeid; - Console::WriteLine( L"\r\nExamining generic type {0}", def ); - - // Get the type parameters of the generic type definition, - // and display them. - // - for each (Type^ tp in def->GetGenericArguments()) - { - Console::WriteLine( L"\r\nType parameter: {0}", tp); - Console::WriteLine( L"\t{0}", - ListGenericParameterAttributes( tp ) ); - - // List the base class and interface constraints. The - // constraints do not appear in any particular order. If - // there are no class or interface constraints, an empty - // array is returned. - // - for each (Type^ constraint in tp->GetGenericParameterConstraints()) - { - Console::WriteLine( L"\t{0}", constraint ); - } - } - } - -private: - - // List the variance and special constraint flags. - // - static String^ ListGenericParameterAttributes( Type^ t ) - { - String^ retval; - GenericParameterAttributes gpa = t->GenericParameterAttributes; - - // Select the variance flag. - GenericParameterAttributes variance = - static_cast( - gpa & GenericParameterAttributes::VarianceMask ); - - if ( variance == GenericParameterAttributes::None ) - retval = L"No variance flag;"; - else - { - if ( (variance & GenericParameterAttributes::Covariant) != - GenericParameterAttributes::None ) - retval = L"Covariant;"; - else - retval = L"Contravariant;"; - } - - // Select the special constraint flags. - GenericParameterAttributes constraints = - static_cast( - gpa & GenericParameterAttributes::SpecialConstraintMask); - - if ( constraints == GenericParameterAttributes::None ) - retval = String::Concat( retval, L" No special constraints" ); - else - { - if ( (constraints & GenericParameterAttributes::ReferenceTypeConstraint) != - GenericParameterAttributes::None ) - retval = String::Concat( retval, L" ReferenceTypeConstraint" ); - - if ( (constraints & GenericParameterAttributes::NotNullableValueTypeConstraint) != - GenericParameterAttributes::None ) - retval = String::Concat( retval, L" NotNullableValueTypeConstraint" ); - - if ( (constraints & GenericParameterAttributes::DefaultConstructorConstraint) != - GenericParameterAttributes::None ) - retval = String::Concat( retval, L" DefaultConstructorConstraint" ); - } - - return retval; - } -}; - -int main() -{ - Example::Main(); -} - -/* This example produces the following output: - -Examining generic type Test`2[T,U] - -Type parameter: T - No variance flag; No special constraints - Base - ITest - -Type parameter: U - No variance flag; No special constraints - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp deleted file mode 100644 index 2b795397fac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Use attributes to mark the class as serializable and obsolete. - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration("System.Serializable"); - class1->CustomAttributes->Add(codeAttrDecl); - - CodeAttributeArgument^ codeAttr = - gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression("This class is obsolete.")); - codeAttrDecl = gcnew CodeAttributeDeclaration("System.Obsolete", codeAttr); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.Serializable()] -//[System.Obsolete("This class is obsolete.")] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp deleted file mode 100644 index 5523f2c37c7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new code attribute - CodeAttributeDeclaration^ codeAttrDecl = gcnew CodeAttributeDeclaration( - "System.CLSCompliantAttribute", - gcnew CodeAttributeArgument(gcnew CodePrimitiveExpression(false))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.CLSCompliantAttribute(false)] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp deleted file mode 100644 index 4db196685db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declares a type constructor that calls a method. - CodeConstructor^ constructor1 = gcnew CodeConstructor(); - constructor1->Attributes = MemberAttributes::Public; - class1->Members->Add(constructor1); - - // Creates a method reference for dict.Init. - CodeMethodReferenceExpression^ methodRef1 = - gcnew CodeMethodReferenceExpression( - gcnew CodeVariableReferenceExpression("dict"), - "Init", - gcnew array { - gcnew CodeTypeReference("System.Decimal"), - gcnew CodeTypeReference("System.Int32")}); - - // Invokes the dict.Init method from the constructor. - CodeMethodInvokeExpression^ invoke1 = - gcnew CodeMethodInvokeExpression(methodRef1, gcnew array {}); - constructor1->Statements->Add(invoke1); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//public class Class1 { -// -// public Class1() { -// dict.Init(); -// } -// } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp deleted file mode 100644 index dcd7661e4aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new generated code attribute - GeneratedCodeAttribute^ generatedCodeAttribute = - gcnew GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0"); - - // Use the generated code attribute members in the attribute declaration - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration(generatedCodeAttribute->GetType()->Name, - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Tool)), - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Version))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -// [GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0")] -// public class Class1 { -// } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/cpp/getexecutingassembly1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/cpp/getexecutingassembly1.cpp deleted file mode 100644 index f2ad3ec6d43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/cpp/getexecutingassembly1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -ref class Example -{}; - -void main() -{ - // Get the assembly from a known type in that assembly. - Type^ t = Example::typeid; - Assembly^ assemFromType = t->Assembly; - Console::WriteLine("Assembly that contains Example:"); - Console::WriteLine(" {0}\n", assemFromType->FullName); - - // Get the currently executing assembly. - Assembly^ currentAssem = Assembly::GetExecutingAssembly(); - Console::WriteLine("Currently executing assembly:"); - Console::WriteLine(" {0}\n", currentAssem->FullName); - - Console::WriteLine("The two Assembly objects are equal: {0}", - assemFromType->Equals(currentAssem)); -} -// The example displays the following output: -// Assembly that contains Example: -// GetExecutingAssembly1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -// -// Currently executing assembly: -// GetExecutingAssembly1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null -// -// The two Assembly objects are equal: True -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/cpp/remarks.cpp deleted file mode 100644 index 31f5e221cac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/cpp/remarks.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -public ref class CompareGenericTypes -{ -public: - static void Main() - { - try - { - AppDomain^ currentDomain = AppDomain::CurrentDomain; - - AssemblyName^ aName = gcnew AssemblyName("TempAssembly"); - AssemblyBuilder^ ab = currentDomain->DefineDynamicAssembly(aName, AssemblyBuilderAccess::Run); - - ModuleBuilder^ mb = ab->DefineDynamicModule(aName->Name); - - TypeBuilder^ tbldr = mb->DefineType("MyNewType", TypeAttributes::Public); - tbldr->DefineGenericParameters("T"); - // - Type^ t1 = tbldr->MakeGenericType(String::typeid); - Type^ t2 = tbldr->MakeGenericType(String::typeid); - bool result = t1->Equals(t2); - // - Console::WriteLine("Types t1 and t2 match: {0:s}", result ? "Yes" : "No"); - } - catch (Exception^ ex) - { - Console::WriteLine(ex->Message); - Console::WriteLine(ex->StackTrace); - } - } -}; - -int main() -{ - CompareGenericTypes::Main(); -} - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.fieldattributes/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.reflection.fieldattributes/cpp/remarks.cpp deleted file mode 100644 index 7f81c1fa446..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.fieldattributes/cpp/remarks.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -using namespace System; -using namespace System::Reflection; - -public ref class FieldAttribTest -{ -public: - static int field1 = 99; - - static void Main() - { - Object^ obj = gcnew FieldAttribTest(); - - // - FieldInfo^ fi = obj->GetType()->GetField("field1"); - - if ((fi->Attributes & FieldAttributes::FieldAccessMask) == - FieldAttributes::Public) - { - Console::WriteLine("{0:s} is public. Value: {1:d}", fi->Name, fi->GetValue(obj)); - } - // - } -}; - -int main() -{ - FieldAttribTest::Main(); -} - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.parametermodifier/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.reflection.parametermodifier/cpp/source.cpp deleted file mode 100644 index 588767ccad5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.reflection.parametermodifier/cpp/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -using namespace System; -using namespace System::Reflection; - -public ref class ParmInfoTest -{ -public: - static void Main() - { - Object^ obj = gcnew ParmInfoTest; - - // - // Create an array containing the arguments. - array^ args = {"Argument 1", "Argument 2", "Argument 3" }; - - // Initialize a ParameterModifier with the number of parameters. - ParameterModifier p = ParameterModifier(3); - - // Pass the first and third parameters by reference. - p[0] = true; - p[2] = true; - - // The ParameterModifier must be passed as the single element - // of an array. - - array^ mods = { p }; - - // Invoke the method late bound. - obj->GetType()->InvokeMember("MethodName", BindingFlags::InvokeMethod, - nullptr, obj, args, mods, nullptr, nullptr); - // - } - - void MethodName(String^% str1, String^ str2, String^% str3) - { - Console::WriteLine("Called 'MethodName'"); - } -}; - -int main() -{ - ParmInfoTest::Main(); -} - - - diff --git a/snippets/cpp/VS_Snippets_Data/XPathValidation/CPP/XPathValidation.cpp b/snippets/cpp/VS_Snippets_Data/XPathValidation/CPP/XPathValidation.cpp deleted file mode 100644 index 75adbf6a471..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XPathValidation/CPP/XPathValidation.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::XPath; - -class XPathValidation -{ -public: - - static void Main() - { - try - { - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add("http://www.contoso.com/books", "contosoBooks.xsd"); - settings->ValidationType = ValidationType::Schema; - - XmlReader^ reader = XmlReader::Create("contosoBooks.xml", settings); - XmlDocument^ document = gcnew XmlDocument(); - document->Load(reader); - - ValidationEventHandler^ eventHandler = gcnew ValidationEventHandler(ValidationEventHandlerOne); - - // the following call to Validate succeeds. - document->Validate(eventHandler); - - // add a node so that the document is no longer valid - XPathNavigator^ navigator = document->CreateNavigator(); - navigator->MoveToFollowing("price", "http://www.contoso.com/books"); - XmlWriter^ writer = navigator->InsertAfter(); - writer->WriteStartElement("anotherNode", "http://www.contoso.com/books"); - writer->WriteEndElement(); - writer->Close(); - - // the document will now fail to successfully validate - document->Validate(eventHandler); - } - catch(Exception^ ex) - { - Console::WriteLine(ex->Message); - } - } - - static void ValidationEventHandlerOne(Object^ sender, ValidationEventArgs^ e) - { - switch (e->Severity) - { - case XmlSeverityType::Error: - Console::WriteLine("Error: {0}", e->Message); - break; - case XmlSeverityType::Warning: - Console::WriteLine("Warning {0}", e->Message); - break; - } - - } -}; - -int main() -{ - XPathValidation::Main(); - Console::ReadLine(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XmlDocument.XmlResolver/CPP/docresolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlDocument.XmlResolver/CPP/docresolver.cpp deleted file mode 100644 index 2b1b5ca9f4d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlDocument.XmlResolver/CPP/docresolver.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Net; -int main() -{ - - // Supply the credentials necessary to access the DTD file stored on the network. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = CredentialCache::DefaultCredentials; - - // Create and load the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->XmlResolver = resolver; // Set the resolver. - doc->Load( "book5.xml" ); - - // Display the entity replacement text which is pulled from the DTD file. - Console::WriteLine( doc->DocumentElement->LastChild->InnerText ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.Cctor/CPP/valid_xsd2.cpp b/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.Cctor/CPP/valid_xsd2.cpp deleted file mode 100644 index 1b175cb5e4e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.Cctor/CPP/valid_xsd2.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -public ref class Sample -{ -private: - static Boolean m_success = true; - -public: - Sample() - { - - // Validate the document using an external XSD schema. Validation should fail. - Validate( "notValidXSD.xml" ); - - // Validate the document using an inline XSD. Validation should succeed. - Validate( "inlineXSD.xml" ); - } - - -private: - - // Display the validation error. - void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ args ) - { - m_success = false; - Console::WriteLine( "\r\n\tValidation error: {0}", args->Message ); - } - - void Validate( String^ filename ) - { - m_success = true; - Console::WriteLine( "\r\n******" ); - Console::WriteLine( "Validating XML file {0}", filename ); - XmlTextReader^ txtreader = gcnew XmlTextReader( filename ); - XmlValidatingReader^ reader = gcnew XmlValidatingReader( txtreader ); - - // Set the validation event handler - reader->ValidationEventHandler += gcnew ValidationEventHandler( this, &Sample::ValidationCallBack ); - - // Read XML data - while ( reader->Read() ) - {} - - Console::WriteLine( "Validation finished. Validation {0}", (m_success == true ? (String^)"successful!" : "failed.") ); - - // Close the reader. - reader->Close(); - } - -}; - -int main() -{ - Sample^ validation = gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.IsDefault/CPP/readdefattr.cpp b/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.IsDefault/CPP/readdefattr.cpp deleted file mode 100644 index d4ffcecd285..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.IsDefault/CPP/readdefattr.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the reader. - XmlTextReader^ txtreader = gcnew XmlTextReader( "book4.xml" ); - XmlValidatingReader^ reader = gcnew XmlValidatingReader( txtreader ); - reader->MoveToContent(); - - // Display each of the attribute nodes, including default attributes. - while ( reader->MoveToNextAttribute() ) - { - if ( reader->IsDefault ) - Console::Write( "(default attribute) " ); - - Console::WriteLine( " {0} = {1}", reader->Name, reader->Value ); - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.SchemaType/CPP/schematype.cpp b/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.SchemaType/CPP/schematype.cpp deleted file mode 100644 index 8704a0b66bd..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.SchemaType/CPP/schematype.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Sample -{ -private: - static void ValidationCallBack( Object^ sender, ValidationEventArgs^ args ) - { - Console::WriteLine( "***Validation error" ); - Console::WriteLine( "\tSeverity: {0}", args->Severity ); - Console::WriteLine( "\tMessage : {0}", args->Message ); - } - -public: - static void main() - { - XmlTextReader^ tr = gcnew XmlTextReader( "booksSchema.xml" ); - XmlValidatingReader^ vr = gcnew XmlValidatingReader( tr ); - vr->Schemas->Add( nullptr, "books.xsd" ); - vr->ValidationType = ValidationType::Schema; - vr->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - while ( vr->Read() ) - { - if ( vr->NodeType == XmlNodeType::Element ) - { - if ( dynamic_cast(vr->SchemaType) != nullptr ) - { - XmlSchemaComplexType^ sct = dynamic_cast(vr->SchemaType); - Console::WriteLine( " {0}( {1})", vr->Name, sct->Name ); - } - else - { - Object^ value = vr->ReadTypedValue(); - Console::WriteLine( " {0}( {1}): {2}", vr->Name, value->GetType()->Name, value ); - } - } - } - } -}; - -int main() -{ - Sample::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.XmlResolver/CPP/vrdr_resolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.XmlResolver/CPP/vrdr_resolver.cpp deleted file mode 100644 index c8b97c43ecc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlValidatingReader.XmlResolver/CPP/vrdr_resolver.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ UserName = args[ 1 ]; - String^ SecurelyStoredPassword = args[ 2 ]; - String^ Domain = args[ 3 ]; - - // - // Create the reader. -> - XmlTextReader^ txtreader = gcnew XmlTextReader( "book5.xml" ); - XmlValidatingReader^ reader = gcnew XmlValidatingReader( txtreader ); - txtreader->WhitespaceHandling = WhitespaceHandling::None; - - // Set the credentials necessary to access the DTD file stored on the network. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; - reader->XmlResolver = resolver; - - // Display each of the element nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "< {0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::DocumentType: - Console::Write( "Name, reader->Value ); - break; - - case XmlNodeType::EntityReference: - Console::Write( reader->Name ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp deleted file mode 100644 index 072abfddaab..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Net; -using namespace System::Net::Http; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - void Method() - { - // - Uri^ siteUri = gcnew Uri("http://www.contoso.com/"); - - // HttpClient lifecycle management best practices: - // https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use - HttpClient^ client = gcnew HttpClient; - HttpRequestMessage^ request = gcnew HttpRequestMessage(HttpMethod::Get, siteUri); - HttpResponseMessage^ response = client->Send(request); - // - } -}; - -void main() -{ - Form1^ f = gcnew Form1; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp deleted file mode 100644 index 1d511f22f6b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsolutePath Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - void Method() - { - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->AbsolutePath ); - // - } -}; - -void main() -{ - Form1^ f = gcnew Form1; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp deleted file mode 100644 index f5adb1e6dc0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.AbsoluteUri Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->AbsoluteUri ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp deleted file mode 100644 index 2cb8990b9d0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Authority Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com:8080/" ); - Uri^ myUri = gcnew Uri( baseUri,"shownew.htm?date=today" ); - Console::WriteLine( myUri->Authority ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp deleted file mode 100644 index 0d5b9b87897..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.CheckHostName Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Console::WriteLine( Uri::CheckHostName( "www.contoso.com" ) ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp deleted file mode 100644 index db24745352e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Host Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com:8080/" ); - Uri^ myUri = gcnew Uri( baseUri,"shownew.htm?date=today" ); - Console::WriteLine( myUri->Host ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp deleted file mode 100644 index 77b48ab3d82..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.PathAndQuery Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm?date=today" ); - - Console::WriteLine( myUri->PathAndQuery ); - // -} - -void Method2() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm?date=today" ); - - Console::WriteLine( myUri->Query ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp deleted file mode 100644 index 2298149c102..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Port Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->Port ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp deleted file mode 100644 index 2a79562ae4c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Scheme Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"catalog/shownew.htm?date=today" ); - Console::WriteLine( myUri->Scheme ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp deleted file mode 100644 index 1977347df49..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp deleted file mode 100644 index 74ea933f0d1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ myUri = gcnew Uri( "http://www.contoso.com/Hello%20World.htm",true ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp deleted file mode 100644 index aa310799d84..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com" ); - Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm" ); - Console::WriteLine( myUri->ToString() ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp deleted file mode 100644 index 1cd0cad6310..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri4 Example/CPP/source.cpp +++ /dev/null @@ -1,12 +0,0 @@ - - -#using - -using namespace System; -void main() -{ - // - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - Uri^ myUri = gcnew Uri( baseUri,"Hello%20World.htm",false ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp deleted file mode 100644 index 7d57c1f31fb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ uBuild = gcnew UriBuilder( "http://www.contoso.com/" ); - uBuild->Path = "index.htm"; - uBuild->Fragment = "main"; - Uri^ myUri = uBuild->Uri; - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp deleted file mode 100644 index 8ed7f68ec92..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http", "www.contoso.com" ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp deleted file mode 100644 index af69e8f961a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http", "www.contoso.com",8080 ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp deleted file mode 100644 index 6c6a09487e1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http","www.contoso.com",8080,"index.htm" ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp deleted file mode 100644 index 3e0bf14858e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Security::Principal; -using namespace System::Windows::Forms; - -void main() -{ - // - UriBuilder^ myUri = gcnew UriBuilder( "http","www.contoso.com",8080,"index.htm","#top" ); - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp deleted file mode 100644 index fb120510b57..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetResponse/CPP/httpwebrequest_begingetresponse.cpp +++ /dev/null @@ -1,158 +0,0 @@ - - -// System::Net::HttpWebRequest::BeginGetResponse System::Net::HttpWebRequest::EndGetResponse -/** -* Snippet1, Snippet2, Snippet3 go together. -* This program shows how to use BeginGetResponse and EndGetResponse methods of the -* HttpWebRequest class. -* It uses an asynchronous approach to get the response for the HTTP Web Request. -* The RequestState class is defined to chekc the state of the request. -* After a HttpWebRequest Object* is created, its BeginGetResponse method is used to start -* the asynchronous response phase. -* Finally, the EndGetResponse method is used to end the asynchronous response phase . -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -private: - - // This class stores the State of the request. - const int BUFFER_SIZE; - -public: - StringBuilder^ requestData; - array^BufferRead; - HttpWebRequest^ request; - HttpWebResponse^ response; - Stream^ streamResponse; - RequestState() - : BUFFER_SIZE( 1024 ) - { - BufferRead = gcnew array(BUFFER_SIZE); - requestData = gcnew StringBuilder( "" ); - request = nullptr; - streamResponse = nullptr; - } - -}; - -ref class HttpWebRequest_BeginGetResponse -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static int BUFFER_SIZE = 1024; - - // - // - static void RespCallback( IAsyncResult^ asynchronousResult ) - { - try - { - - // State of request is asynchronous. - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - HttpWebRequest^ myHttpWebRequest2 = myRequestState->request; - myRequestState->response = dynamic_cast(myHttpWebRequest2->EndGetResponse( asynchronousResult )); - - // Read the response into a Stream object. - Stream^ responseStream = myRequestState->response->GetResponseStream(); - myRequestState->streamResponse = responseStream; - - // Begin the Reading of the contents of the HTML page and print it to the console. - IAsyncResult^ asynchronousInputRead = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - } - - static void ReadCallBack( IAsyncResult^ asyncResult ) - { - try - { - RequestState^ myRequestState = dynamic_cast(asyncResult->AsyncState); - Stream^ responseStream = myRequestState->streamResponse; - int read = responseStream->EndRead( asyncResult ); - - // Read the HTML page and then print it to the console. - if ( read > 0 ) - { - myRequestState->requestData->Append( Encoding::ASCII->GetString( myRequestState->BufferRead, 0, read ) ); - IAsyncResult^ asynchronousResult = responseStream->BeginRead( myRequestState->BufferRead, 0, BUFFER_SIZE, gcnew AsyncCallback( ReadCallBack ), myRequestState ); - } - else - { - Console::WriteLine( "\nThe contents of the Html page are : " ); - if ( myRequestState->requestData->Length > 1 ) - { - String^ stringContent; - stringContent = myRequestState->requestData->ToString(); - Console::WriteLine( stringContent ); - } - Console::WriteLine( "Press any key to continue.........." ); - Console::ReadLine(); - responseStream->Close(); - allDone->Set(); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - - } - -}; - -int main() -{ - try - { - - // Create a HttpWebrequest object to the desired URL. - HttpWebRequest^ myHttpWebRequest1 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - - // Create an instance of the RequestState and assign the previous myHttpWebRequest1 - // object to its request field. - RequestState^ myRequestState = gcnew RequestState; - myRequestState->request = myHttpWebRequest1; - - // Start the asynchronous request. - IAsyncResult^ result = dynamic_cast(myHttpWebRequest1->BeginGetResponse( gcnew AsyncCallback( HttpWebRequest_BeginGetResponse::RespCallback ), myRequestState )); - HttpWebRequest_BeginGetResponse::allDone->WaitOne(); - - // Release the HttpWebResponse resource. - myRequestState->response->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - Console::WriteLine( "Press any key to continue.........." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Press any key to continue.........." ); - Console::Read(); - } - -} - -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp deleted file mode 100644 index 7dc16c6e6be..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp +++ /dev/null @@ -1,150 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Threading; - -// TryCreate -void SampleTryCreate() -{ - // - // String to parse. - String^ addressString = "catalog/shownew.htm?date=today"; - - // Parse the string and create a new Uri instance, if possible. - Uri^ result; - if ( Uri::TryCreate( addressString, UriKind::RelativeOrAbsolute, result ) ) - { - // The call was successful. Write the URI address to the console. - Console::Write( result ); - - // Check whether new Uri instance is absolute or relative. - if ( result->IsAbsoluteUri ) - Console::WriteLine( " is an absolute Uri." ); - else - Console::WriteLine( " is a relative Uri." ); - } - else - { - // Let the user know that the call failed. - Console::WriteLine( "addressString could not be parsed as a URI address." ); - } - // -} - -// Constructor -void SampleConstructor() -{ - // - // Create an absolute Uri from a string. - String^ addressString1 = "http://www.contoso.com/"; - String^ addressString2 = "catalog/shownew.htm?date=today"; - Uri^ absoluteUri = gcnew Uri(addressString1); - - // Create a relative Uri from a string. allowRelative = true to allow for - // creating a relative Uri. - Uri^ relativeUri = gcnew Uri(addressString2); - - // Check whether the new Uri is absolute or relative. - if ( !relativeUri->IsAbsoluteUri ) - Console::WriteLine( "{0} is a relative Uri.", relativeUri ); - - // Create a new Uri from an absolute Uri and a relative Uri. - Uri^ combinedUri = gcnew Uri( absoluteUri,relativeUri ); - Console::WriteLine( combinedUri->AbsoluteUri ); - // -} - -// OriginalString -void SampleOriginalString() -{ - // - // Create a new Uri from a string address. - Uri^ uriAddress = gcnew Uri( "HTTP://www.ConToso.com:80//thick%20and%20thin.htm" ); - - // Write the new Uri to the console and note the difference in the two values. - // ToString() gives the canonical version. OriginalString gives the original - // string that was passed to the constructor. - // The following outputs "http://www.contoso.com//thick and thin.htm". - Console::WriteLine( uriAddress ); - - // The following outputs "HTTP://www.ConToso.com:80//thick%20and%20thin.htm". - Console::WriteLine( uriAddress->OriginalString ); - // -} - - -// DNSSafeHost -void SampleDNSSafeHost() -{ - // - // Create new Uri using a string address. - Uri^ address = gcnew Uri( "http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm" ); - - // Make the address DNS safe. - // The following outputs "[fe80::200:39ff:fe36:1a2d]". - Console::WriteLine( address->Host ); - - // The following outputs "fe80::200:39ff:fe36:1a2d%254". - Console::WriteLine( address->DnsSafeHost ); - // -} - -// operator == and !== -void SampleOperatorEqual() -{ - // - // Create some Uris. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" ); - Uri^ address3 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // The first two are equal because the fragment is ignored. - if ( address1 == address2 ) - Console::WriteLine( "{0} is equal to {1}", address1, address2 ); - - // The second two are not equal. - if ( address2 != address3 ) - Console::WriteLine( "{0} is not equal to {1}", address2, address3 ); - // -} - -// IsBaseOf -void SampleIsBaseOf() -{ - // - // Create a base Uri. - Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" ); - - // Create a new Uri from a string. - Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // Determine whether BaseUri is a base of UriAddress. - if ( baseUri->IsBaseOf( uriAddress ) ) - Console::WriteLine( "{0} is the base of {1}", baseUri, uriAddress ); - // -} - -int main() -{ - // TryParse - SampleTryCreate(); - - // Constructor - SampleConstructor(); - - // OriginalString - SampleOriginalString(); - - // DNSSafeHost - SampleDNSSafeHost(); - - // operator == and !== - SampleOperatorEqual(); - - // IsBaseOf - SampleIsBaseOf(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp deleted file mode 100644 index f7f450b51de..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp +++ /dev/null @@ -1,271 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Threading; -using namespace System::Runtime::Serialization; - -namespace Example -{ - public ref class Test - { - public: - static void Main() - { - // Snippets 1 and 2 - HexConversions(); - - // snippet 7 - SampleToString(); - - // snippet 8 - SampleEquals(); - - // snippets 4, 5, and 6 - GetParts(); - - // snippet 3 - SampleMakeRelative(); - - // snippets 9 - 17 - SampleCheckSchemeName(); - - // snippets 18 - SampleUserInfo(); - } - - private: - static void SampleToString() - { - // - // Create a new Uri from a string address. - Uri^ uriAddress = gcnew Uri( "HTTP://www.Contoso.com:80/thick%20and%20thin.htm" ); - - // Write the new Uri to the console and note the difference in the two values. - // ToString() gives the canonical version. OriginalString gives the orginal - // string that was passed to the constructor. - // The following outputs "http://www.contoso.com/thick and thin.htm". - Console::WriteLine( uriAddress ); - - // The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm". - Console::WriteLine( uriAddress->OriginalString ); - // - } - - static void SampleEquals() - { - // - // Create some Uris. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" ); - if ( address1->Equals( address2 ) ) - { - Console::WriteLine( "The two addresses are equal" ); - } - else - { - Console::WriteLine( "The two addresses are not equal" ); - } - // Will output "The two addresses are equal" - // - } - - static void GetParts() - { - // - // Create Uri - Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Console::WriteLine( uriAddress->Fragment ); - Console::WriteLine( "Uri {0} the default port ", uriAddress->IsDefaultPort ? (String^)"uses" : "does not use" ); - - Console::WriteLine( "The path of this Uri is {0}", uriAddress->GetLeftPart( UriPartial::Path ) ); - Console::WriteLine( "Hash code {0}", uriAddress->GetHashCode() ); - // The example displays output similar to the following: - // #search - // Uri uses the default port - // The path of this Uri is http://www.contoso.com/index.htm - // Hash code -988419291 - // - - // - Uri^ uriAddress1 = gcnew Uri( "http://www.contoso.com/title/index.htm" ); - Console::WriteLine( "The parts are {0}, {1}, {2}", uriAddress1->Segments[ 0 ], uriAddress1->Segments[ 1 ], uriAddress1->Segments[ 2 ] ); - // - - // - Uri^ uriAddress2 = gcnew Uri( "file://server/filename.ext" ); - Console::WriteLine( uriAddress2->LocalPath ); - Console::WriteLine( "Uri {0} a UNC path", uriAddress2->IsUnc ? (String^)"is" : "is not" ); - Console::WriteLine( "Uri {0} a local host", uriAddress2->IsLoopback ? (String^)"is" : "is not" ); - Console::WriteLine( "Uri {0} a file", uriAddress2->IsFile ? (String^)"is" : "is not" ); - // The example displays the following output: - // \\server\filename.ext - // Uri is a UNC path - // Uri is not a local host - // Uri is a file - // - } - - static void HexConversions() - { - - // - char testChar = 'e'; - if ( Uri::IsHexDigit( testChar ) ) - { - Console::WriteLine( "'{0}' is the hexadecimal representation of {1}", - testChar, Uri::FromHex( testChar ) ); - } - else - { - Console::WriteLine( "'{0}' is not a hex character", testChar ); - } - - String^ returnString = Uri::HexEscape( testChar ); - Console::WriteLine( "The hexadecimal value of '{0}' is {1}", testChar, returnString ); - // - - // - String^ testString = "%75"; - int index = 0; - if ( Uri::IsHexEncoding( testString, index ) ) - { - Console::WriteLine( "The character is {0}", - Uri::HexUnescape( testString, index ) ); - } - else - { - Console::WriteLine( "The character is not hex encoded" ); - } - // - } - - // MakeRelative - static void SampleMakeRelative() - { - // - // Create a base Uri. - Uri^ address1 = gcnew Uri( "http://www.contoso.com/" ); - - // Create a new Uri from a string. - Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" ); - - // Determine the relative Uri. - Console::WriteLine( "The difference is {0}", address1->MakeRelativeUri( address2 ) ); - // - } - - //CheckSchemeName - static void SampleCheckSchemeName() - { - // - Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" ); - Console::WriteLine( "address 1 {0} a valid scheme name", - Uri::CheckSchemeName( address1->Scheme ) ? (String^)" has" : " does not have" ); - if ( address1->Scheme == Uri::UriSchemeHttp ) - { - Console::WriteLine( "Uri is HTTP type" ); - } - - Console::WriteLine( address1->HostNameType ); - // - - // - Uri^ address2 = gcnew Uri( "file://server/filename.ext" ); - if ( address2->Scheme == Uri::UriSchemeFile ) - { - Console::WriteLine( "Uri is a file" ); - } - // - - Console::WriteLine( address2->HostNameType ); - - // - Uri^ address3 = gcnew Uri( "mailto:user@contoso.com?subject=uri" ); - if ( address3->Scheme == Uri::UriSchemeMailto ) - { - Console::WriteLine( "Uri is an email address" ); - } - // - - // - Uri^ address4 = gcnew Uri( "news:123456@contoso.com" ); - if ( address4->Scheme == Uri::UriSchemeNews ) - { - Console::WriteLine( "Uri is an Internet news group" ); - } - // - - // - Uri^ address5 = gcnew Uri( "nntp://news.contoso.com/123456@contoso.com" ); - if ( address5->Scheme == Uri::UriSchemeNntp ) - { - Console::WriteLine( "Uri is nntp protocol" ); - } - // - - // - Uri^ address6 = gcnew Uri( "gopher://example.contoso.com/" ); - if ( address6->Scheme == Uri::UriSchemeGopher ) - { - Console::WriteLine( "Uri is Gopher protocol" ); - } - // - - // - Uri^ address7 = gcnew Uri( "ftp://contoso/files/testfile.txt" ); - if ( address7->Scheme == Uri::UriSchemeFtp ) - { - Console::WriteLine( "Uri is Ftp protocol" ); - } - // - - // - Uri^ address8 = gcnew Uri( "https://example.contoso.com" ); - if ( address8->Scheme == Uri::UriSchemeHttps ) - { - Console::WriteLine( "Uri is Https protocol." ); - } - // - - // - String^ address = "www.contoso.com"; - String^ uriString = String::Format( "{0}{1}{2}", - Uri::UriSchemeHttp, Uri::SchemeDelimiter, address ); - -#if OLDMETHOD - Uri^ result; - if ( Uri::TryParse( uriString, false, false, result ) ) - { - Console::WriteLine( "{0} is a valid Uri", result ); - } - else - { - Console::WriteLine( "Uri not created" ); - } -#endif - Uri ^result = gcnew Uri(uriString); - if (result->IsWellFormedOriginalString()) - Console::WriteLine("{0} is a well formed Uri", uriString); - else - Console::WriteLine("{0} is not a well formed Uri", uriString); - // - } - - static void SampleUserInfo() - { - // - Uri^ uriAddress = gcnew Uri( "http://user:password@www.contoso.com/index.htm " ); - Console::WriteLine( uriAddress->UserInfo ); - Console::WriteLine( "Fully Escaped {0}", - uriAddress->UserEscaped ? (String^)"yes" : "no" ); - // - } - }; -} - -int main() -{ - Example::Test::Main(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp b/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp deleted file mode 100644 index c2507006a55..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Runtime::Serialization::Formatters::Soap; - -// A test object that needs to be serialized. - -[Serializable] -ref class TestSimpleObject -{ -private: - int member1; - String^ member2; - String^ member3; - double member4; - -public: - - // A field that is not serialized. - - [NonSerialized] - String^ member5; - TestSimpleObject() - { - member1 = 11; - member2 = "hello"; - member3 = "hello"; - member4 = 3.14159265; - member5 = "hello world!"; - } - - void Print() - { - Console::WriteLine( "member1 = ' {0}'", member1 ); - Console::WriteLine( "member2 = ' {0}'", member2 ); - Console::WriteLine( "member3 = ' {0}'", member3 ); - Console::WriteLine( "member4 = ' {0}'", member4 ); - Console::WriteLine( "member5 = ' {0}'", member5 ); - } - -}; - -int main() -{ - // Creates a new TestSimpleObject object. - TestSimpleObject^ obj = gcnew TestSimpleObject; - Console::WriteLine( "Before serialization the Object* contains: " ); - obj->Print(); - - // Opens a file and serializes the object into it in binary format. - Stream^ stream = File::Open( "data.xml", FileMode::Create ); - SoapFormatter^ formatter = gcnew SoapFormatter; - - formatter->Serialize( stream, obj ); - stream->Close(); - - // Empties obj. - obj = nullptr; - - // Opens file S"data.xml" and deserializes the object from it. - stream = File::Open( "data.xml", FileMode::Open ); - formatter = gcnew SoapFormatter; - - obj = dynamic_cast(formatter->Deserialize( stream )); - stream->Close(); - Console::WriteLine( "" ); - Console::WriteLine( "After deserialization the object contains: " ); - obj->Print(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp b/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp deleted file mode 100644 index dbc94df5f39..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#pragma region^ Using directives - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; - -#pragma endregion - -int main() -{ - // - UriBuilder^ baseUri = gcnew UriBuilder - ("http://www.contoso.com/default.aspx?Param1=7890"); - String^ queryToAppend = "param2=1234"; - if (baseUri->Query != nullptr && baseUri->Query->Length > 1) - { - // Note: In .NET Core and .NET 5+, you can simplify by removing - // the call to Substring(), which removes the leading "?" character. - baseUri->Query = baseUri->Query->Substring(1)+ "&" + queryToAppend; - } - else - { - baseUri->Query = queryToAppend; - } - // -} diff --git a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute Example/CPP/source.cpp deleted file mode 100644 index 261eb1e694e..00000000000 --- a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ - // -public: - [RecommendedAsConfigurable(true)] - property int MyProperty - { - int get() - { - // Insert code here. - return 0; - } - void set( int /*value*/ ) - { - // Insert code here. - } - } - // - void Method1() - { - // - // Gets the attributes for the property. - AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes; - - // Checks to see if the value of the RecommendedAsConfigurableAttribute is Yes. - if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) ) - { - // Insert code here. - } - - // This is another way to see if the property is recommended as configurable. - RecommendedAsConfigurableAttribute^ myAttribute = dynamic_cast(attributes[ RecommendedAsConfigurableAttribute::typeid ]); - if ( myAttribute->RecommendedAsConfigurable ) - { - // Insert code here. - } - // - } - - void Method2() - { - // - AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty ); - if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) ) - { - // Insert code here. - } - // - } -}; - -/* -This code produces the following output. - -myQ is not synchronized. -mySyncdQ is synchronized. -*/ diff --git a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurable Example/CPP/source.cpp deleted file mode 100644 index daaf00fa8cb..00000000000 --- a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurable Example/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - -public: - void Method() - { - // - // Gets the attributes for the property. - AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes; - - // Checks to see if the property is recommended as configurable. - RecommendedAsConfigurableAttribute^ myAttribute = dynamic_cast(attributes[ RecommendedAsConfigurableAttribute::typeid ]); - if ( myAttribute->RecommendedAsConfigurable ) - { - // Insert code here. - } - // - } -}; - -/* -This code produces the following output. - -myQ is not synchronized. -mySyncdQ is synchronized. -*/ diff --git a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurableAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurableAttribute Example/CPP/source.cpp deleted file mode 100644 index 7b9aaf400ee..00000000000 --- a/snippets/cpp/VS_Snippets_Winforms/Classic RecommendedAsConfigurableAttribute.RecommendedAsConfigurableAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - TextBox^ textBox1; - - - // -public: - [RecommendedAsConfigurable(true)] - property int MyProperty - { - int get() - { - // Insert code here. - return 0; - } - void set( int value ) - { - - // Insert code here. - } - } - // -}; diff --git a/xml/System.Numerics/BigInteger.xml b/xml/System.Numerics/BigInteger.xml index 07e24014d96..3761217f3b7 100644 --- a/xml/System.Numerics/BigInteger.xml +++ b/xml/System.Numerics/BigInteger.xml @@ -1827,7 +1827,6 @@ The individual bytes in the `value` array should be in little-endian order, from ## Examples The following example instantiates a object from each integral type except . It then calls the method to compare the value with the original integer value that was passed to the constructor. As the output shows, the values are equal in each case. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Numerics/BigInteger/Equals/EqualsExample1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Numerics/BigInteger/Equals/EqualsExample1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/vb/EqualsExample1.vb" id="Snippet1"::: @@ -1894,7 +1893,6 @@ The individual bytes in the `value` array should be in little-endian order, from ## Examples The following example compares the approximate distance of several stars from Earth with the distance of Epsilon Indi from Earth to determine whether they are equal. The example uses each overload of the method to test for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Numerics/BigInteger/Equals/EqualsExample1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Numerics/BigInteger/Equals/EqualsExample1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/vb/EqualsExample1.vb" id="Snippet2"::: @@ -2033,7 +2031,6 @@ The individual bytes in the `value` array should be in little-endian order, from ## Examples The following example compares the approximate distance of several stars from Earth with the distance of Epsilon Indi from Earth to determine whether they are equal. The example uses each overload of the method to test for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/cpp/equals2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Numerics/BigInteger/Equals/EqualsExample1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Numerics/BigInteger/Equals/EqualsExample1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Numerics.BigInteger.Equals/vb/EqualsExample1.vb" id="Snippet2"::: diff --git a/xml/System.Reflection.Emit/AssemblyBuilder.xml b/xml/System.Reflection.Emit/AssemblyBuilder.xml index f1cce090757..07e99e27bfe 100644 --- a/xml/System.Reflection.Emit/AssemblyBuilder.xml +++ b/xml/System.Reflection.Emit/AssemblyBuilder.xml @@ -89,7 +89,6 @@ For more information about this API, see [Supplemental API remarks for AssemblyB method to get a resource writer. The example uses the resource writer to add three resource strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/CPP/assemblybuilder_defineresource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineResource/assemblybuilder_defineresource.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder.DefineResource Example 2/VB/assemblybuilder_defineresource.vb" id="Snippet1"::: @@ -1157,7 +1149,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The following code sample creates and attaches an array of bytes representing an unmanaged resource to a dynamic assembly, using `DefineUnmanagedResource`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/CPP/assemblybuilder_defineunmanagedresource2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/assemblybuilder_defineunmanagedresource2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource2/VB/assemblybuilder_defineunmanagedresource2.vb" id="Snippet1"::: @@ -1218,7 +1209,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The example below demonstrates a call to `DefineUnmanagedResource`, passing an external resource file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/CPP/assemblybuilder_defineunmanagedresource.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/DefineUnmanagedResource/assemblybuilder_defineunmanagedresource.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineUnmanagedResource/VB/assemblybuilder_defineunmanagedresource.vb" id="Snippet3"::: @@ -1298,7 +1288,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The example below illustrates the usage of `DefineVersionInfoResource`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyCompanyAttribute/Overview/assemblybuilder_defineversioninforesource.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: @@ -1367,7 +1356,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The example below illustrates the usage of `DefineVersionInfoResource`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyCompanyAttribute/Overview/assemblybuilder_defineversioninforesource.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: @@ -3164,7 +3152,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The following code sample creates a dynamic assembly and then persists it to a local disk using `Save`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/Save/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.AssemblyBuilder.Save Example/VB/source.vb" id="Snippet1"::: @@ -3386,7 +3373,6 @@ The following code example shows how to define and use a dynamic assembly. The e ## Examples The following code sample illustrates the use of `SetCustomAttribute` within , using a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/CPP/assemblybuilder_setcustomattribute1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/SetCustomAttribute/assemblybuilder_setcustomattribute1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute1/VB/assemblybuilder_setcustomattribute1.vb" id="Snippet1"::: @@ -3470,7 +3456,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample illustrates the use of `SetCustomAttribute` to attach a custom attribute to a dynamically generated assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/CPP/assemblybuilder_setcustomattribute2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/AssemblyBuilder/SetCustomAttribute/assemblybuilder_setcustomattribute2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_SetCustomAttribute2/VB/assemblybuilder_setcustomattribute2.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/ConstructorBuilder.xml b/xml/System.Reflection.Emit/ConstructorBuilder.xml index 5bbb76a62da..c49bcc051f3 100644 --- a/xml/System.Reflection.Emit/ConstructorBuilder.xml +++ b/xml/System.Reflection.Emit/ConstructorBuilder.xml @@ -93,7 +93,6 @@ ## Examples The following code sample illustrates the contextual usage of a `ConstructorBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/VB/source.vb" id="Snippet1"::: @@ -178,7 +177,6 @@ ## Examples The following code sample illustrates the use of `AddDeclarativeSecurity`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/AddDeclarativeSecurity/constructorbuilder_attributes_4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/VB/constructorbuilder_attributes_4.vb" id="Snippet1"::: @@ -239,7 +237,6 @@ ## Remarks The following code sample illustrates the use of `Attributes`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/AddDeclarativeSecurity/constructorbuilder_attributes_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/VB/constructorbuilder_attributes_4.vb" id="Snippet2"::: @@ -341,7 +338,6 @@ The following code sample illustrates the use of `DeclaringType`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/CPP/constructorbuilder_attributes_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/AddDeclarativeSecurity/constructorbuilder_attributes_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_Attributes_4/VB/constructorbuilder_attributes_4.vb" id="Snippet2"::: @@ -632,7 +628,6 @@ ## Examples The following code sample illustrates the use of the `GetILGenerator` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ConstructorBuilder Example/VB/source.vb" id="Snippet1"::: @@ -776,7 +771,6 @@ ## Remarks The following code sample illustrates the use of `GetMethodImplementationFlags`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/GetMethodImplementationFlags/constructorbuilder_getmodule_4.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/VB/constructorbuilder_getmodule_4.vb" id="Snippet3"::: @@ -818,7 +812,6 @@ ## Remarks The following code sample illustrates the usage of `GetModule`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/GetModule/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/VB/source3.vb" id="Snippet1"::: @@ -876,7 +869,6 @@ ## Examples The code sample illustrates the use of `GetParameters`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/GetMethodImplementationFlags/constructorbuilder_getmodule_4.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/VB/constructorbuilder_getmodule_4.vb" id="Snippet4"::: @@ -922,7 +914,6 @@ ## Remarks This code sample illustrates the use of `GetToken`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/GetMethodImplementationFlags/constructorbuilder_getmodule_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/VB/constructorbuilder_getmodule_4.vb" id="Snippet2"::: @@ -1410,7 +1401,6 @@ ## Remarks The following code sample illustrates the use of `Name`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_Name_5/CPP/constructorbuilder_name_5.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/Name/constructorbuilder_name_5.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_Name_5/VB/constructorbuilder_name_5.vb" id="Snippet2"::: @@ -1573,7 +1563,6 @@ ## Examples The following code sample illustrates the use of `SetCustomAttribute` of the context of a , passing a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/CPP/constructorbuilder_setcustomattribute1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/SetCustomAttribute/constructorbuilder_setcustomattribute1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute1/VB/constructorbuilder_setcustomattribute1.vb" id="Snippet1"::: @@ -1648,7 +1637,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample illustrates the use of `SetCustomAttribute` of the context of a , passing a byte blob. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/CPP/constructorbuilder_setcustomattribute2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/SetCustomAttribute/constructorbuilder_setcustomattribute2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_SetCustomAttribute2/VB/constructorbuilder_setcustomattribute2.vb" id="Snippet1"::: @@ -1743,7 +1731,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Remarks The following code sample illustrates the use of `SetImplementationFlags`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/CPP/constructorbuilder_setimplementationflags.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/SetImplementationFlags/constructorbuilder_setimplementationflags.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_SetImplementationFlags/VB/constructorbuilder_setimplementationflags.vb" id="Snippet1"::: @@ -1874,7 +1861,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Remarks The following code sample illustrates the use of `SetSymCustomAttributes`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/CPP/constructorbuilder_setsymcustomattribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/SetSymCustomAttribute/constructorbuilder_setsymcustomattribute.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_SetSymCustomAttribute/VB/constructorbuilder_setsymcustomattribute.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/CustomAttributeBuilder.xml b/xml/System.Reflection.Emit/CustomAttributeBuilder.xml index cb03f3db954..db197f59b00 100644 --- a/xml/System.Reflection.Emit/CustomAttributeBuilder.xml +++ b/xml/System.Reflection.Emit/CustomAttributeBuilder.xml @@ -81,7 +81,6 @@ ## Examples The following code sample illustrates the use of `CustomAttributeBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/CustomAttributeBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.CustomAttributeBuilder Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/DynamicMethod.xml b/xml/System.Reflection.Emit/DynamicMethod.xml index 3db6a665d24..c455da29cdf 100644 --- a/xml/System.Reflection.Emit/DynamicMethod.xml +++ b/xml/System.Reflection.Emit/DynamicMethod.xml @@ -57,7 +57,6 @@ method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet1"::: ]]> @@ -361,7 +360,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/VB/source.vb" id="Snippet1"::: @@ -978,7 +976,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the method attributes of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet21"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet21"::: @@ -1034,7 +1031,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the calling convention of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet22"::: @@ -1121,7 +1117,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/VB/source.vb" id="Snippet1"::: @@ -1299,7 +1294,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the declaring type of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet23"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet23"::: @@ -1365,7 +1359,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example shows how to define parameter information for a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet33"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet33"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet33"::: @@ -1671,7 +1664,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.ctor1/VB/source.vb" id="Snippet1"::: @@ -1741,7 +1733,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example demonstrates this method overload. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet2"::: @@ -1847,7 +1838,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the parameters of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet34"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet34"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet34"::: @@ -1905,7 +1895,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the property of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet24"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet24"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet24"::: @@ -1991,7 +1980,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example invokes a dynamic method with exact binding, using the US-English culture. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet4"::: @@ -2443,7 +2431,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the property of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet26"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet26"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet26"::: @@ -2501,7 +2488,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the name of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet27"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet27"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet27"::: @@ -2564,7 +2550,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the reflected type of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet28"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet28"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet28"::: @@ -2667,7 +2652,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the return type of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet30"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet30"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet30"::: @@ -2723,7 +2707,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example shows how to display the custom attributes of the return type of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet31"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet31"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet31"::: @@ -2781,7 +2764,6 @@ The following code example creates a dynamic method that takes two parameters. T ## Examples The following code example displays the method of a dynamic method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection.DynamicMethod.All/cpp/source.cpp" id="Snippet32"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet32"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection.DynamicMethod.All/VB/source.vb" id="Snippet32"::: diff --git a/xml/System.Reflection.Emit/EnumBuilder.xml b/xml/System.Reflection.Emit/EnumBuilder.xml index 35e5c672a7f..16e5034413c 100644 --- a/xml/System.Reflection.Emit/EnumBuilder.xml +++ b/xml/System.Reflection.Emit/EnumBuilder.xml @@ -101,7 +101,6 @@ > [!NOTE] > Prior to the .NET Framework version 2.0, this code example does not produce a correct enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Overview/modulebuilder_defineenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineEnum/VB/modulebuilder_defineenum.vb" id="Snippet1"::: @@ -179,7 +178,6 @@ ## Examples The following code sample demonstrates the use of the `Assembly` property to reference the parent assembly of the current `EnumBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Assembly/enumbuilder_properties_5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_Properties_5/VB/enumbuilder_properties_5.vb" id="Snippet1"::: @@ -245,7 +243,6 @@ See for a description of the format of the @@ -628,7 +625,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr > [!NOTE] > Prior to the .NET Framework version 2.0, this code example does not produce a correct enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Overview/modulebuilder_defineenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineEnum/VB/modulebuilder_defineenum.vb" id="Snippet1"::: @@ -1084,7 +1080,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr The following code sample illustrates the use of `GetCustomAttribute` in the context of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/GetCustomAttributes/enumbuilder_setcustomattribute2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/VB/enumbuilder_setcustomattribute2.vb" id="Snippet1"::: @@ -1145,7 +1140,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr The following code sample illustrates the use of `GetCustomAttribute` in the context of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/CPP/enumbuilder_setcustomattribute1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/GetCustomAttributes/enumbuilder_setcustomattribute1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute1/VB/enumbuilder_setcustomattribute1.vb" id="Snippet2"::: @@ -2409,7 +2403,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr ## Examples The following code sample demonstrates the use of the `GUID` property to reference the associated of the current `EnumBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/CPP/enumbuilder_properties_4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/GUID/enumbuilder_properties_4.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_Properties_4.cs/VB/enumbuilder_properties_4.vb" id="Snippet4"::: @@ -3496,7 +3489,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr ## Examples The following code sample demonstrates the use of the `Module` property to reference the parent module of the current `EnumBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Assembly/enumbuilder_properties_5.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_Properties_5/VB/enumbuilder_properties_5.vb" id="Snippet3"::: @@ -3548,7 +3540,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr ## Examples The following code sample demonstrates the use of the `Name` property to reference the name of the current `EnumBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Assembly/enumbuilder_properties_5.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_Properties_5/VB/enumbuilder_properties_5.vb" id="Snippet4"::: @@ -3607,7 +3598,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr ## Examples The following code sample demonstrates the use of the `Namespace` property to reference the associated namespace of the current `EnumBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_Properties_5/CPP/enumbuilder_properties_5.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Assembly/enumbuilder_properties_5.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_Properties_5/VB/enumbuilder_properties_5.vb" id="Snippet5"::: @@ -3720,7 +3710,6 @@ The following code sample demonstrates the use of the `AssemblyQualifiedName` pr ## Examples The following code sample illustrates the use of `SetCustomAttribute` in the context of , passing a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/GetCustomAttributes/enumbuilder_setcustomattribute2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/VB/enumbuilder_setcustomattribute2.vb" id="Snippet2"::: @@ -3795,7 +3784,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample illustrates the use of `SetCustomAttribute` in the context of , passing a byte blob. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/CPP/enumbuilder_setcustomattribute2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/GetCustomAttributes/enumbuilder_setcustomattribute2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EnumBuilder_SetCustomAttribute2/VB/enumbuilder_setcustomattribute2.vb" id="Snippet2"::: diff --git a/xml/System.Reflection.Emit/FieldBuilder.xml b/xml/System.Reflection.Emit/FieldBuilder.xml index 58d40f419ed..827940ee522 100644 --- a/xml/System.Reflection.Emit/FieldBuilder.xml +++ b/xml/System.Reflection.Emit/FieldBuilder.xml @@ -165,7 +165,6 @@ ## Remarks The following code sample illustrates the use of `Attributes`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/Attributes/fieldbuilder_reflectedtype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_ReflectedType/VB/fieldbuilder_reflectedtype.vb" id="Snippet1"::: @@ -727,7 +726,6 @@ The following code sample illustrates the use of `ReflectedType`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_ReflectedType/CPP/fieldbuilder_reflectedtype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/Attributes/fieldbuilder_reflectedtype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_ReflectedType/VB/fieldbuilder_reflectedtype.vb" id="Snippet1"::: @@ -895,7 +893,6 @@ ## Examples The following code sample illustrates the use of `SetCustomAttribute` in the context of , using a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/SetCustomAttribute/fieldbuilder_setcustomattributes.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/VB/fieldbuilder_setcustomattributes.vb" id="Snippet1"::: @@ -971,7 +968,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample illustrates the use of `SetCustomAttribute` in the context of , using a byte blob. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/CPP/fieldbuilder_setcustomattributes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/SetCustomAttribute/fieldbuilder_setcustomattributes.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_SetCustomAttributes/VB/fieldbuilder_setcustomattributes.vb" id="Snippet1"::: @@ -1065,7 +1061,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Remarks The following code sample illustrates the use of `SetMarshal`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/SetMarshal/fieldbuilder_setoffset.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_SetOffset/VB/fieldbuilder_setoffset.vb" id="Snippet1"::: @@ -1129,7 +1124,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Remarks The following code sample illustrates the use of `SetOffset`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldBuilder_SetOffset/CPP/fieldbuilder_setoffset.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/FieldBuilder/SetMarshal/fieldbuilder_setoffset.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldBuilder_SetOffset/VB/fieldbuilder_setoffset.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/GenericTypeParameterBuilder.xml b/xml/System.Reflection.Emit/GenericTypeParameterBuilder.xml index 432ae0f28f0..fbd9e0a585d 100644 --- a/xml/System.Reflection.Emit/GenericTypeParameterBuilder.xml +++ b/xml/System.Reflection.Emit/GenericTypeParameterBuilder.xml @@ -81,7 +81,6 @@ ## Examples The following code example creates a generic type with two type parameters, and saves them in the assembly GenericEmitExample1.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see [How to: Define a Generic Type with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-type-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb" id="Snippet1"::: @@ -3309,7 +3308,6 @@ ## Examples The following code example creates a dynamic module, an abstract generic type named `Sample` with one type parameter, `T`, and an abstract method named `TestMethod`. `TestMethod` takes a `ref` parameter (`ByRef` in Visual Basic) of type `T`, a pointer to type `T`, and an array of `T`. This method returns a two-dimensional array of `T`. The code example saves the dynamic module to disk, so you can examine it using the MSIL Disassembler (Ildasm.exe). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/MakeArrayType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/VB/source.vb" id="Snippet1"::: @@ -3377,7 +3375,6 @@ ## Examples The following code example creates a dynamic module, an abstract generic type named `Sample` with one type parameter, `T`, and an abstract method named `TestMethod`. `TestMethod` takes a `ref` parameter (`ByRef` in Visual Basic) of type `T`, a pointer to type `T`, and an array of `T`. This method returns a two-dimensional array of `T`. The code example saves the dynamic module to disk, so you can examine it using the MSIL Disassembler (Ildasm.exe). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/MakeArrayType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/VB/source.vb" id="Snippet1"::: @@ -3438,7 +3435,6 @@ ## Examples The following code example creates a dynamic module, an abstract generic type named `Sample` with one type parameter, `T`, and an abstract method named `TestMethod`. `TestMethod` takes a `ref` parameter (`ByRef` in Visual Basic) of type `T`, a pointer to type `T`, and an array of `T`. This method returns a two-dimensional array of `T`. The code example saves the dynamic module to disk, so you can examine it using the MSIL Disassembler (Ildasm.exe). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/MakeArrayType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/VB/source.vb" id="Snippet1"::: @@ -3559,7 +3555,6 @@ ## Examples The following code example creates a dynamic module, an abstract generic type named `Sample` with one type parameter, `T`, and an abstract method named `TestMethod`. `TestMethod` takes a `ref` parameter (`ByRef` in Visual Basic) of type `T`, a pointer to type `T`, and an array of `T`. This method returns a two-dimensional array of `T`. The code example saves the dynamic module to disk, so you can examine it using the MSIL Disassembler (Ildasm.exe). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/MakeArrayType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MakeXxxGenericTypeParameterBuilder/VB/source.vb" id="Snippet1"::: @@ -3848,7 +3843,6 @@ ## Examples The following code example creates a generic type with two type parameters, the second of which has a base type constraint, and saves them in the assembly GenericEmitExample1.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see [How to: Define a Generic Type with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-type-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb" id="Snippet1"::: @@ -4100,7 +4094,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code example creates a generic type with two type parameters, the first of which is constrained to have a parameterless constructor and to be a reference type, and saves them in the assembly GenericEmitExample1.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see [How to: Define a Generic Type with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-type-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb" id="Snippet1"::: @@ -4211,7 +4204,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code example creates a generic type with two type parameters, the second of which has two interface constraints, and saves them in the assembly GenericEmitExample1.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see [How to: Define a Generic Type with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-type-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/ILGenerator.xml b/xml/System.Reflection.Emit/ILGenerator.xml index 49639a6e8a1..67b0a7d149b 100644 --- a/xml/System.Reflection.Emit/ILGenerator.xml +++ b/xml/System.Reflection.Emit/ILGenerator.xml @@ -177,7 +177,6 @@ ## Examples The code sample below demonstrates the contextual usage of the `BeginCatchBlock` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginCatchBlock/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/VB/source.vb" id="Snippet1"::: @@ -302,7 +301,6 @@ ## Examples The code sample below demonstrates the contextual usage of the `BeginExceptionBlock` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginCatchBlock/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/VB/source.vb" id="Snippet1"::: @@ -363,7 +361,6 @@ ## Examples The following code sample illustrates the use of `BeginFaultBlock`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/CPP/ilgenerator_beginfaultblock.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginFaultBlock/ilgenerator_beginfaultblock.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ILGenerator_BeginFaultBlock/VB/ilgenerator_beginfaultblock.vb" id="Snippet1"::: @@ -424,7 +421,6 @@ ## Examples The following code sample illustrates the use of `BeginFinallyBlock`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/CPP/ILGenerator_BeginFinallyBlock_2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginFinallyBlock/ilgenerator_beginfinallyblock_2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ILGenerator_BeginFinallyBlock_2/VB/ilgenerator_beginfinallyblock_2.vb" id="Snippet2"::: @@ -488,7 +484,6 @@ ## Examples The following code sample illustrates the use of `BeginScope` and `EndScope`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginScope/ilgenerator_begin_endscope.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ILGenerator_Begin_EndScope/VB/ilgenerator_begin_endscope.vb" id="Snippet2"::: @@ -596,7 +591,6 @@ ## Examples The following code example demonstrates the use of the `DeclareLocal` method. This code is part of a larger code example for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DeclareLocal/localbuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/VB/localbuilder_sample_4.vb" id="Snippet2"::: @@ -731,7 +725,6 @@ ## Examples The code sample below demonstrates the contextual usage of the `DefineLabel` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DefineLabel/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.Label Example/VB/source.vb" id="Snippet1"::: @@ -807,7 +800,6 @@ ## Examples The code sample below demonstrates the use of `Emit` to generate MSIL output via an instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/Emit/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: @@ -1237,7 +1229,6 @@ ## Examples The code sample below illustrates the creation of a dynamic method with a jump table. The jump table is built using an array of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/Emit/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: @@ -1305,7 +1296,6 @@ ## Examples The code sample below illustrates the creation of a dynamic method with a jump table. The jump table is built using an array of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/Emit/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: @@ -1887,7 +1877,6 @@ The method does not throw @@ -1983,7 +1972,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The following code sample demonstrates the contextual usage of the method to call an unmanaged type method external to the dynamic class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/EmitCalli/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.EmitCalli Example/VB/source.vb" id="Snippet1"::: @@ -2152,7 +2140,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The code sample below demonstrates the contextual usage of the method to write a string to the console in a dynamic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/EmitWriteLine/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/VB/source.vb" id="Snippet1"::: @@ -2225,7 +2212,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The following code sample demonstrates the use of the method to write a string to the console in a dynamic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/EmitWriteLine/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/VB/source.vb" id="Snippet1"::: @@ -2295,7 +2281,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The code sample below demonstrates the contextual usage of the `EmitWriteLine` method to write a string to the console in a dynamic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/EmitWriteLine/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/VB/source.vb" id="Snippet1"::: @@ -2351,7 +2336,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The code sample below demonstrates the contextual usage of the `EndExceptionBlock` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginCatchBlock/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/VB/source.vb" id="Snippet1"::: @@ -2416,7 +2400,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The following code sample illustrates the use of `BeginScope` and `EndScope`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ILGenerator_Begin_EndScope/CPP/ilgenerator_begin_endscope.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginScope/ilgenerator_begin_endscope.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ILGenerator_Begin_EndScope/VB/ilgenerator_begin_endscope.vb" id="Snippet2"::: @@ -2534,7 +2517,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The code sample below demonstrates the contextual usage of `MarkLabel` to implement MSIL branching in a dynamic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/Emit/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: @@ -2910,7 +2892,6 @@ The following code example emits two methods, a `varargs` method and a method th ## Examples The following code sample demonstrates the contextual usage of `ThrowException` to throw an exception inside the MSIL of a dynamic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/BeginCatchBlock/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.ThrowException Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/LocalBuilder.xml b/xml/System.Reflection.Emit/LocalBuilder.xml index f4b41cbbd4b..bbfe6ac0799 100644 --- a/xml/System.Reflection.Emit/LocalBuilder.xml +++ b/xml/System.Reflection.Emit/LocalBuilder.xml @@ -91,7 +91,6 @@ ## Examples The following example creates a `static` method (`Shared` in Visual Basic) named `Function1` that returns a string and has a parameter of type . In the body of the method, the code example creates objects representing two local variables, and sets symbol information for the local variables. The method does not do anything significant, but the method body demonstrates storing a parameter to a local variable, storing a literal string to a local variable, and loading a local variable. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DeclareLocal/localbuilder_sample_4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/VB/localbuilder_sample_4.vb" id="Snippet1"::: @@ -262,7 +261,6 @@ ## Examples The following code sample illustrates the use of `LocalType`. This code is part of a larger example for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DeclareLocal/localbuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/VB/localbuilder_sample_4.vb" id="Snippet2"::: @@ -322,7 +320,6 @@ ## Examples The following code sample illustrates the use of the method. This code is part of a larger example for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DeclareLocal/localbuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/VB/localbuilder_sample_4.vb" id="Snippet2"::: @@ -387,7 +384,6 @@ ## Examples The following code sample illustrates the use of the method. This code is part of a larger example for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/CPP/localbuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/DeclareLocal/localbuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LocalBuilder_Sample_SetLocalSymInfo/VB/localbuilder_sample_4.vb" id="Snippet2"::: diff --git a/xml/System.Reflection.Emit/MethodBuilder.xml b/xml/System.Reflection.Emit/MethodBuilder.xml index cbbc9579727..3fd52ef3073 100644 --- a/xml/System.Reflection.Emit/MethodBuilder.xml +++ b/xml/System.Reflection.Emit/MethodBuilder.xml @@ -79,7 +79,6 @@ class to create a method within a dynamic type. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder Example/VB/source.vb" id="Snippet1"::: ]]> @@ -163,7 +162,6 @@ The following example uses the class ## Examples The code sample below illustrates the contextual use of `AddDeclarativeSecurity` to require the caller of a method to have unrestricted permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/AddDeclarativeSecurity/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.AddDeclarativeSecurity Example/VB/source.vb" id="Snippet1"::: @@ -363,7 +361,6 @@ The following example uses the class ## Examples In the example provided below, a simple method that adds two integers is generated via opcode using `CreateMethodBody`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/CreateMethodBody/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Refelction.Emit.MethodBuilder.CreateMethodBody Example/VB/source.vb" id="Snippet1"::: @@ -432,7 +429,6 @@ The following example uses the class ## Examples The following code illustrates the use of the `Type` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBuilderClass_TypeSample/CPP/methodbuilderclass.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DeclaringType/methodbuilderclass.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBuilderClass_TypeSample/VB/methodbuilderclass.vb" id="Snippet1"::: @@ -510,7 +506,6 @@ The following example uses the class > [!NOTE] > This code example generates a simple method body that merely returns a null reference. For a code example with a more fully developed method body that creates and uses generic types, see [How to: Define a Generic Method with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-method-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet1"::: @@ -1123,7 +1118,6 @@ The following example uses the class ## Examples The code sample below demonstrates the contextual usage of the `GetILGenerator` method, creating and emitting a dynamic assembly that will calculate the dot product of two points in 3D space. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/GetILGenerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/VB/source.vb" id="Snippet1"::: @@ -1184,7 +1178,6 @@ The following example uses the class ## Examples The code sample below demonstrates the contextual usage of the `GetILGenerator` method, creating and emitting a dynamic assembly that will calculate the dot product of two points in 3D space. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/GetILGenerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit ILGenerator Example/VB/source.vb" id="Snippet1"::: @@ -1303,7 +1296,6 @@ The following example uses the class ## Examples The sample code below illustrates the usage of the `GetModule` method to retrieve information about a dynamically-generated module. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/CPP/source3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ConstructorBuilder/GetModule/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetModule/VB/source3.vb" id="Snippet1"::: @@ -1356,7 +1348,6 @@ The following example uses the class ## Examples The code sample below illustrates the use of `GetParameters` to discover information on the parameters passed to a dynamically-generated method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/CPP/source4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/GetParameters/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.GetParameters Example/VB/source4.vb" id="Snippet1"::: @@ -1675,7 +1666,6 @@ The following example uses the class ## Examples The following code example displays the status of a method. This code is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet7"::: @@ -1733,7 +1723,6 @@ The following example uses the class ## Examples The following code example displays the status of a method. This code is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet7"::: @@ -1948,7 +1937,6 @@ The following example uses the class > [!NOTE] > For another code example that uses , see . is also used extensively when emitting code that uses generic types. See [How to: Define a Generic Method with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-method-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/MakeGenericMethod/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBuilder.MakeGenericMethod/vb/source.vb" id="Snippet1"::: @@ -2588,7 +2576,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The code sample below illustrates the contextual use of the `SetImplementationFlags` method to describe the implementation of MSIL in a method body. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/SetImplementationFlags/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetImplementationFlags Example/VB/source.vb" id="Snippet1"::: @@ -2675,7 +2662,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The code sample below illustrates the contextual usage of the `SetMarshal` method to marshal the results of a method call as a different type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/SetMarshal/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetMarshal Example/VB/source.vb" id="Snippet1"::: @@ -2814,10 +2800,8 @@ For information on how to format `binaryAttribute`, see the metadata specificati This code is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet5"::: @@ -2890,10 +2874,8 @@ For information on how to format `binaryAttribute`, see the metadata specificati This code is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet5"::: @@ -3141,7 +3123,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The code sample below illustrates the contextual usage of the `SetSymCustomAttribute` method to set the byte values for the name and key of a custom attribute attached to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/SetSymCustomAttribute/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.MethodBuilder.SetSymCustomAttribute Example/VB/source2.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/MethodRental.xml b/xml/System.Reflection.Emit/MethodRental.xml index c51830a3637..2ebd010c3b4 100644 --- a/xml/System.Reflection.Emit/MethodRental.xml +++ b/xml/System.Reflection.Emit/MethodRental.xml @@ -123,22 +123,21 @@ Flags that control the swapping. See the definitions of the constants. Swaps the body of a method. - @@ -183,11 +182,11 @@ Caller-allocated array which receives the IDs corresponding to the names. Maps a set of names to a corresponding set of dispatch identifiers. - The method is called late-bound using the COM IDispatch interface. @@ -224,11 +223,11 @@ Receives a pointer to the requested type information object. Retrieves the type information for an object, which can then be used to get the type information for an interface. - The method is called late-bound using the COM IDispatch interface. @@ -261,11 +260,11 @@ Points to a location that receives the number of type information interfaces provided by the object. Retrieves the number of type information interfaces that an object provides (either 0 or 1). - The method is called late-bound using the COM IDispatch interface. @@ -312,11 +311,11 @@ The index of the first argument that has an error. Provides access to properties and methods exposed by an object. - The method is called late-bound using the COM IDispatch interface. diff --git a/xml/System.Reflection.Emit/ModuleBuilder.xml b/xml/System.Reflection.Emit/ModuleBuilder.xml index cbaad27085b..69959bc270c 100644 --- a/xml/System.Reflection.Emit/ModuleBuilder.xml +++ b/xml/System.Reflection.Emit/ModuleBuilder.xml @@ -85,7 +85,6 @@ ## Examples The following code sample demonstrates the use of `ModuleBuilder` to create a dynamic module. Note that the ModuleBuilder is created by calling in , rather than through a constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_Class/CPP/modulebuilder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/Overview/modulebuilder.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_Class/VB/modulebuilder.vb" id="Snippet1"::: @@ -217,7 +216,6 @@ ## Examples The following sample illustrates the use of `CreateGlobalFunctions` to create a static global method from a implemented with . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/CreateGlobalFunctions/modulebuilder_createglobalfunctions.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/VB/modulebuilder_createglobalfunctions.vb" id="Snippet2"::: @@ -346,7 +344,6 @@ ## Examples The following code sample illustrates the use of `DefineDocument` to attach an external symbol document (in this case, a raw IL file) to a dynamic module. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: @@ -462,7 +459,6 @@ > [!NOTE] > Prior to the .NET Framework version 2.0, this code example does not produce a correct enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineEnum/CPP/modulebuilder_defineenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/EnumBuilder/Overview/modulebuilder_defineenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineEnum/VB/modulebuilder_defineenum.vb" id="Snippet1"::: @@ -602,7 +598,6 @@ ## Examples The following example illustrates the use of `DefineGlobalMethod` to create a type-independent method tied to the current . After building the global method, must be called in order to complete it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/CreateGlobalFunctions/modulebuilder_createglobalfunctions.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/VB/modulebuilder_createglobalfunctions.vb" id="Snippet1"::: @@ -702,7 +697,6 @@ ## Examples The following code sample illustrates the use of `DefineGlobalMethod` to create a type-independent method tied to the current . After building the global method, must be called in order to complete it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/CPP/modulebuilder_createglobalfunctions.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/CreateGlobalFunctions/modulebuilder_createglobalfunctions.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_CreateGlobalFunctions/VB/modulebuilder_createglobalfunctions.vb" id="Snippet1"::: @@ -998,7 +992,6 @@ ## Examples The following example uses the method to define an initialized data field in the `.sdata` section of the portable executable (PE) file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/CPP/modulebuilder_defineinitializeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineInitializedData/modulebuilder_defineinitializeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineInitializedData/VB/modulebuilder_defineinitializeddata.vb" id="Snippet1"::: @@ -1237,7 +1230,6 @@ > [!IMPORTANT] > To get a non-zero return value, you must add to the method implementation flags after you create the , by using the and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefinePInvokeMethod/modulebuilder_definepinvokemethod1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/VB/modulebuilder_definepinvokemethod1.vb" id="Snippet1"::: @@ -1357,7 +1349,6 @@ This example uses a different overload of the method, but the technique is the same. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/CPP/modulebuilder_definepinvokemethod1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefinePInvokeMethod/modulebuilder_definepinvokemethod1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefinePInvokeMethod1/VB/modulebuilder_definepinvokemethod1.vb" id="Snippet1"::: @@ -1493,7 +1484,6 @@ ## Examples The following example illustrates the use of `DefineResource` to add an external resource to the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource1/CPP/modulebuilder_defineresource1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineResource/modulebuilder_defineresource1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineResource1/VB/modulebuilder_defineresource1.vb" id="Snippet1"::: @@ -1560,7 +1550,6 @@ ## Examples The following example illustrates the use of DefineResource to add an external resource to the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineResource2/CPP/modulebuilder_defineresource2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineResource/modulebuilder_defineresource2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineResource2/VB/modulebuilder_defineresource2.vb" id="Snippet1"::: @@ -1649,7 +1638,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -1728,7 +1716,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -1821,7 +1808,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -1916,7 +1902,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -2011,7 +1996,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -2117,7 +2101,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -2214,7 +2197,6 @@ ## Examples The following example creates a in the current dynamic module using `CreateType`, builds and completes the type, and saves the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/DefineType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ModuleBuilder.DefineType Example/VB/source.vb" id="Snippet1"::: @@ -2701,7 +2683,6 @@ ## Examples The following example demonstrates how to use to obtain the corresponding to a method that returns an array value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/GetArrayMethod/modulebuilder_getarraymethod.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/VB/modulebuilder_getarraymethod.vb" id="Snippet1"::: @@ -2821,7 +2802,6 @@ ## Examples The following example demonstrates how to use to obtain the corresponding to a method that returns an array value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/CPP/modulebuilder_getarraymethod.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ModuleBuilder/GetArrayMethod/modulebuilder_getarraymethod.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_GetArrayMethod/VB/modulebuilder_getarraymethod.vb" id="Snippet2"::: diff --git a/xml/System.Reflection.Emit/OpCodes.xml b/xml/System.Reflection.Emit/OpCodes.xml index f56be8851d1..539e53de671 100644 --- a/xml/System.Reflection.Emit/OpCodes.xml +++ b/xml/System.Reflection.Emit/OpCodes.xml @@ -52,18 +52,17 @@ Provides field representations of the Microsoft Intermediate Language (MSIL) instructions for emission by the class members (such as ). - to emit `OpCodes` into a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example demonstrates the construction of a dynamic method using to emit `OpCodes` into a . + :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/EmitWriteLine/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.OpCodes Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -107,54 +106,54 @@ Adds two values and pushes the result onto the evaluation stack. - ). - - Integer addition wraps, rather than saturates. For example, assuming 8-bit integers where `value1` is set to 255 and `value2` is set to 1, the wrapped result is 0 rather than 256. - - Floating-point overflow returns `+inf` (`PositiveInfinity`) or `-inf` (`NegativeInfinity`). - - The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) and generates an error. - -|operand|value1 type|value2 type|result type| -|-------------|-----------------|-----------------|-----------------| -|add|`int32`|`int32`|`int32`| -|add|`int32`|`native int`|`native int`| -|add|`int32`|`&`|`&`| -|add|`int32`|`*`|`*`| -|add|`int64`|`int64`|`int64`| -|add|`native int`|`int32`|`native int`| -|add|`native int`|`native int`|`native int`| -|add|`native int`|`&`|`&`| -|add|`native int`|`*`|`*`| -|add|`F`|`F`|`F`| -|add|`&`|`int32`|`&`| -|add|`&`|`native int`|`&`| -|add|`*`|`int32`|`*`| -|add|`*`|`native int`|`*`| - - The following method overload can use the `add` opcode: - -- - + ). + + Integer addition wraps, rather than saturates. For example, assuming 8-bit integers where `value1` is set to 255 and `value2` is set to 1, the wrapped result is 0 rather than 256. + + Floating-point overflow returns `+inf` (`PositiveInfinity`) or `-inf` (`NegativeInfinity`). + + The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) and generates an error. + +|operand|value1 type|value2 type|result type| +|-------------|-----------------|-----------------|-----------------| +|add|`int32`|`int32`|`int32`| +|add|`int32`|`native int`|`native int`| +|add|`int32`|`&`|`&`| +|add|`int32`|`*`|`*`| +|add|`int64`|`int64`|`int64`| +|add|`native int`|`int32`|`native int`| +|add|`native int`|`native int`|`native int`| +|add|`native int`|`&`|`&`| +|add|`native int`|`*`|`*`| +|add|`F`|`F`|`F`| +|add|`&`|`int32`|`&`| +|add|`&`|`native int`|`&`| +|add|`*`|`int32`|`*`| +|add|`*`|`native int`|`*`| + + The following method overload can use the `add` opcode: + +- + ]]> @@ -198,52 +197,52 @@ Adds two integers, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result is not represented in the result type. - - You can perform this operation on signed integers. For floating-point values, use . - - The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) instruction and generates an error. - -|operand|value1 type|value2 type|result type| -|-------------|-----------------|-----------------|-----------------| -|add|`int32`|`int32`|`int32`| -|add|`int32`|`native int`|`native int`| -|add|`int32`|`&`|`&`| -|add|`int32`|`*`|`*`| -|add|`int64`|`int64`|`int64`| -|add|`native int`|`int32`|`native int`| -|add|`native int`|`native int`|`native int`| -|add|`native int`|`&`|`&`| -|add|`native int`|`*`|`*`| -|add|`F`|`F`|`F`| -|add|`&`|`int32`|`&`| -|add|`&`|`native int`|`&`| -|add|`*`|`int32`|`*`| -|add|`*`|`native int`|`*`| - - The following method overload can use the `add.ovf` opcode: - -- - + is thrown if the result is not represented in the result type. + + You can perform this operation on signed integers. For floating-point values, use . + + The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) instruction and generates an error. + +|operand|value1 type|value2 type|result type| +|-------------|-----------------|-----------------|-----------------| +|add|`int32`|`int32`|`int32`| +|add|`int32`|`native int`|`native int`| +|add|`int32`|`&`|`&`| +|add|`int32`|`*`|`*`| +|add|`int64`|`int64`|`int64`| +|add|`native int`|`int32`|`native int`| +|add|`native int`|`native int`|`native int`| +|add|`native int`|`&`|`&`| +|add|`native int`|`*`|`*`| +|add|`F`|`F`|`F`| +|add|`&`|`int32`|`&`| +|add|`&`|`native int`|`&`| +|add|`*`|`int32`|`*`| +|add|`*`|`native int`|`*`| + + The following method overload can use the `add.ovf` opcode: + +- + ]]> @@ -287,52 +286,52 @@ Adds two unsigned integer values, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result is not represented in the result type. - - You can perform this operation on signed integers. For floating-point values, use . - - The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) instruction and generates an error. - -|operand|value1 type|value2 type|result type| -|-------------|-----------------|-----------------|-----------------| -|add|`int32`|`int32`|`int32`| -|add|`int32`|`native int`|`native int`| -|add|`int32`|`&`|`&`| -|add|`int32`|`*`|`*`| -|add|`int64`|`int64`|`int64`| -|add|`native int`|`int32`|`native int`| -|add|`native int`|`native int`|`native int`| -|add|`native int`|`&`|`&`| -|add|`native int`|`*`|`*`| -|add|`F`|`F`|`F`| -|add|`&`|`int32`|`&`| -|add|`&`|`native int`|`&`| -|add|`*`|`int32`|`*`| -|add|`*`|`native int`|`*`| - - The following method overload can use the `add.ovf.un` opcode: - -- - + is thrown if the result is not represented in the result type. + + You can perform this operation on signed integers. For floating-point values, use . + + The acceptable operand types and their corresponding result data type are listed in the table below. If there is no entry for a particular type combination (for example, `int32` and `float`; `int32` and `int64`), it is an invalid Microsoft Intermediate Language (MSIL) instruction and generates an error. + +|operand|value1 type|value2 type|result type| +|-------------|-----------------|-----------------|-----------------| +|add|`int32`|`int32`|`int32`| +|add|`int32`|`native int`|`native int`| +|add|`int32`|`&`|`&`| +|add|`int32`|`*`|`*`| +|add|`int64`|`int64`|`int64`| +|add|`native int`|`int32`|`native int`| +|add|`native int`|`native int`|`native int`| +|add|`native int`|`&`|`&`| +|add|`native int`|`*`|`*`| +|add|`F`|`F`|`F`| +|add|`&`|`int32`|`&`| +|add|`&`|`native int`|`&`| +|add|`*`|`int32`|`*`| +|add|`*`|`native int`|`*`| + + The following method overload can use the `add.ovf.un` opcode: + +- + ]]> @@ -376,33 +375,33 @@ Computes the bitwise AND of two values and pushes the result onto the evaluation stack. - method overload can use the `and` opcode: - -- - + method overload can use the `and` opcode: + +- + ]]> @@ -446,23 +445,23 @@ Returns an unmanaged pointer to the argument list of the current method. - method overload can use the `arglist` opcode: - -- - + method overload can use the `arglist` opcode: + +- + ]]> @@ -506,35 +505,35 @@ Transfers control to a target instruction if two values are equal. - |beq `target`|Branch to the target instruction at offset `target` if the two values are equal.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is equal to `value2`, the branch operation is performed. - - The `beq` instruction transfers control to the specified target instruction if `value1` is equal to `value2`. The effect is the same as performing a `ceq` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - The acceptable operand types are encapsulated below: - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. - - Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction (such transfers are severely restricted and must use the instruction instead). - - The following method overload can use the `beq` opcode: - -- - + |beq `target`|Branch to the target instruction at offset `target` if the two values are equal.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is equal to `value2`, the branch operation is performed. + + The `beq` instruction transfers control to the specified target instruction if `value1` is equal to `value2`. The effect is the same as performing a `ceq` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + The acceptable operand types are encapsulated below: + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. + + Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction (such transfers are severely restricted and must use the instruction instead). + + The following method overload can use the `beq` opcode: + +- + ]]> @@ -578,35 +577,35 @@ Transfers control to a target instruction (short form) if two values are equal. - |beq.s `target`|Branch to the target instruction at offset `target` if equal, short form| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is equal to `value2`, the branch operation is performed. - - The `beq.s` instruction transfers control to the specified target instruction if `value1` is equal to `value2`. The effect is the same as performing a `ceq` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - The acceptable operand types are encapsulated below: - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. - - Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction (such transfers are severely restricted and must use the instruction instead). - - The following method overload can use the `beq.s` opcode: - -- - + |beq.s `target`|Branch to the target instruction at offset `target` if equal, short form| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is equal to `value2`, the branch operation is performed. + + The `beq.s` instruction transfers control to the specified target instruction if `value1` is equal to `value2`. The effect is the same as performing a `ceq` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + The acceptable operand types are encapsulated below: + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. + + Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction (such transfers are severely restricted and must use the instruction instead). + + The following method overload can use the `beq.s` opcode: + +- + ]]> @@ -650,31 +649,31 @@ Transfers control to a target instruction if the first value is greater than or equal to the second value. - `|bge `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. - - The `bge` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`. The effect is identical to performing a `clt` instruction (`clt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bge` opcode: - -- - + `|bge `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. + + The `bge` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`. The effect is identical to performing a `clt` instruction (`clt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bge` opcode: + +- + ]]> @@ -718,31 +717,31 @@ Transfers control to a target instruction (short form) if the first value is greater than or equal to the second value. - `|bge.s `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value, short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. - - The `bge.s` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`. The effect is identical to performing a `clt` instruction (`clt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bge.s` opcode: - -- - + `|bge.s `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value, short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. + + The `bge.s` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`. The effect is identical to performing a `clt` instruction (`clt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bge.s` opcode: + +- + ]]> @@ -786,31 +785,31 @@ Transfers control to a target instruction if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. - `|bge.un `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values).| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. - - The `bge.un` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction (`clt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bge.un` opcode: - -- - + `|bge.un `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values).| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. + + The `bge.un` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction (`clt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bge.un` opcode: + +- + ]]> @@ -854,31 +853,31 @@ Transfers control to a target instruction (short form) if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. - |bge.un.s `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. - - The `bge.un.s` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction (`clt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bge.un.s` opcode: - -- - + |bge.un.s `target`|Branch to the target instruction at the specified offset if the first value is greater than or equal to the second value (unsigned values), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than or equal to `value2`, the branch operation is performed. + + The `bge.un.s` instruction transfers control to the specified target instruction if `value1` is greater than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction (`clt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bge.un.s` opcode: + +- + ]]> @@ -922,31 +921,31 @@ Transfers control to a target instruction if the first value is greater than the second value. - |bgt `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. - - The `bgt` instruction transfers control to the specified target instruction if `value1` is greater than `value2`. The effect is identical to performing a `cgt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bgt` opcode: - -- - + |bgt `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. + + The `bgt` instruction transfers control to the specified target instruction if `value1` is greater than `value2`. The effect is identical to performing a `cgt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bgt` opcode: + +- + ]]> @@ -990,31 +989,31 @@ Transfers control to a target instruction (short form) if the first value is greater than the second value. - |bgt.s `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value, short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. - - The `bgt.s` instruction transfers control to the specified target instruction if `value1` is greater than `value2`. The effect is identical to performing a `cgt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bgt.s` opcode: - -- - + |bgt.s `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value, short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. + + The `bgt.s` instruction transfers control to the specified target instruction if `value1` is greater than `value2`. The effect is identical to performing a `cgt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bgt.s` opcode: + +- + ]]> @@ -1058,31 +1057,31 @@ Transfers control to a target instruction if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. - |bgt.un `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values).| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. - - The `bgt.un` instruction transfers control to the specified target instruction if `value1` is greater than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bgt.un` opcode: - -- - + |bgt.un `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values).| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. + + The `bgt.un` instruction transfers control to the specified target instruction if `value1` is greater than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bgt.un` opcode: + +- + ]]> @@ -1126,31 +1125,31 @@ Transfers control to a target instruction (short form) if the first value is greater than the second value, when comparing unsigned integer values or unordered float values. - |bgt.un.s `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. - - The `bgt.un.s` instruction transfers control to the specified target instruction if `value1` is greater than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bgt.un.s` opcode: - -- - + |bgt.un.s `target`|Branch to the target instruction at the specified offset if the first value is greater than the second value (unsigned values), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is greater than `value2`, the branch operation is performed. + + The `bgt.un.s` instruction transfers control to the specified target instruction if `value1` is greater than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bgt.un.s` opcode: + +- + ]]> @@ -1194,31 +1193,31 @@ Transfers control to a target instruction if the first value is less than or equal to the second value. - `|ble `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. - - The `ble` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `cgt` instruction (`cgt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `ble` opcode: - -- - + `|ble `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. + + The `ble` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `cgt` instruction (`cgt.un` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `ble` opcode: + +- + ]]> @@ -1262,31 +1261,31 @@ Transfers control to a target instruction (short form) if the first value is less than or equal to the second value. - `|ble.s `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value, short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. - - The `ble.s` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `cgt` instruction (`cgt.un` for floats) instruction followed by a`brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `ble.s` opcode: - -- - + `|ble.s `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value, short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. + + The `ble.s` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `cgt` instruction (`cgt.un` for floats) instruction followed by a`brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `ble.s` opcode: + +- + ]]> @@ -1330,31 +1329,31 @@ Transfers control to a target instruction if the first value is less than or equal to the second value, when comparing unsigned integer values or unordered float values. - `|ble.un `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values).| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. - - The `ble.un` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction (`cgt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `ble.un` opcode: - -- - + `|ble.un `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values).| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. + + The `ble.un` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction (`cgt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `ble.un` opcode: + +- + ]]> @@ -1398,31 +1397,31 @@ Transfers control to a target instruction (short form) if the first value is less than or equal to the second value, when comparing unsigned integer values or unordered float values. - `|ble.un.s `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. - - The `ble.un.s` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction (`cgt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `ble.un.s` opcode: - -- - + `|ble.un.s `target`|Branch to the target instruction at the specified offset if the first value is less than or equal to the second value (unsigned values), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than or equal to `value2`, the branch operation is performed. + + The `ble.un.s` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `cgt.un` instruction (`cgt` for floats) followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `ble.un.s` opcode: + +- + ]]> @@ -1466,31 +1465,31 @@ Transfers control to a target instruction if the first value is less than the second value. - |blt `target`|Branch to the target instruction at the specified offset if the first value is less than the second value.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. - - The `blt` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `clt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `blt` opcode: - -- - + |blt `target`|Branch to the target instruction at the specified offset if the first value is less than the second value.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. + + The `blt` instruction transfers control to the specified target instruction if `value1` is less than or equal to `value2`. The effect is identical to performing a `clt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `blt` opcode: + +- + ]]> @@ -1534,31 +1533,31 @@ Transfers control to a target instruction (short form) if the first value is less than the second value. - |blt.s `target`|Branch to the target instruction at the specified offset if the first value is less than the second value, short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. - - The `blt.s` instruction transfers control to the specified target instruction if `value1` is less than `value2`. The effect is identical to performing a `clt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `blt.s` opcode: - -- - + |blt.s `target`|Branch to the target instruction at the specified offset if the first value is less than the second value, short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. + + The `blt.s` instruction transfers control to the specified target instruction if `value1` is less than `value2`. The effect is identical to performing a `clt` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `blt.s` opcode: + +- + ]]> @@ -1602,41 +1601,41 @@ Transfers control to a target instruction if the first value is less than the second value, when comparing unsigned integer values or unordered float values. - |blt.un `target`|Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values).| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. - - The `blt.un` instruction transfers control to the specified target instruction if `value1` is less than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `blt.un` opcode: - -- - - ]]> - - - - - - - - - + |blt.un `target`|Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values).| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. + + The `blt.un` instruction transfers control to the specified target instruction if `value1` is less than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `blt.un` opcode: + +- + + ]]> + + + + + + + + + Field @@ -1670,31 +1669,31 @@ Transfers control to a target instruction (short form) if the first value is less than the second value, when comparing unsigned integer values or unordered float values. - |blt.un.s `target`|Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. - - The `blt.un` instruction transfers control to the specified target instruction if `value1` is less than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `blt.un.s` opcode: - -- - + |blt.un.s `target`|Branch to the target instruction at the specified offset if the first value is less than the second value (unsigned values), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is less than `value2`, the branch operation is performed. + + The `blt.un` instruction transfers control to the specified target instruction if `value1` is less than `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `clt.un` instruction followed by a `brtrue` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `blt.un.s` opcode: + +- + ]]> @@ -1738,31 +1737,31 @@ Transfers control to a target instruction when two unsigned integer values or unordered float values are not equal. - |bne.un `target`|Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values).| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is not equal to `value2`, the branch operation is performed. - - The `bne.un` instruction transfers control to the specified target instruction if `value1` is not equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `ceq` instruction followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bne.un` opcode: - -- - + |bne.un `target`|Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values).| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is not equal to `value2`, the branch operation is performed. + + The `bne.un` instruction transfers control to the specified target instruction if `value1` is not equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `ceq` instruction followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bne.un` opcode: + +- + ]]> @@ -1806,31 +1805,31 @@ Transfers control to a target instruction (short form) when two unsigned integer values or unordered float values are not equal. - |bne.un.s `target`|Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value1` is pushed onto the stack. - -2. `value2` is pushed onto the stack. - -3. `value2` and `value1` are popped from the stack; if `value1` is not equal to `value2`, the branch operation is performed. - - The `bne.un` instruction transfers control to the specified target instruction if `value1` is not equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `ceq` instruction followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `bne.un.s` opcode: - -- - + |bne.un.s `target`|Branch to the target instruction at the specified offset if two unsigned integer values are not equal (unsigned values), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value1` is pushed onto the stack. + +2. `value2` is pushed onto the stack. + +3. `value2` and `value1` are popped from the stack; if `value1` is not equal to `value2`, the branch operation is performed. + + The `bne.un` instruction transfers control to the specified target instruction if `value1` is not equal to `value2`, when compared using unsigned integer or unordered float values. The effect is identical to performing a `ceq` instruction followed by a `brfalse` branch to the specific target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `bne.un.s` opcode: + +- + ]]> @@ -1874,39 +1873,39 @@ Converts a value type to an object reference (type ). - |box `valTypeToken`|Convert a value type (of the type specified in `valTypeToken`) to a true object reference.| - - The stack transitional behavior, in sequential order, is: - -1. A value type is pushed onto the stack. - -2. The value type is popped from the stack; the `box` operation is performed. - -3. An object reference to the resulting "boxed" value type is pushed onto the stack. - - A value type has two separate representations within the Common Language Infrastructure (CLI): - -- A 'raw' form used when a value type is embedded within another object or on the stack. - -- A 'boxed' form, where the data in the value type is wrapped (boxed) into an object so it can exist as an independent entity. - - The `box` instruction converts the 'raw' (unboxed) value type into an object reference (type `O`). This is accomplished by creating a new object and copying the data from the value type into the newly allocated object. `valTypeToken` is a metadata token indicating the type of the value type on the stack. - - is thrown if there is insufficient memory to satisfy the request. - - is thrown if the class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) is converted to native code, rather than at runtime. - - The following method overload can use the `box` opcode: - -- - + |box `valTypeToken`|Convert a value type (of the type specified in `valTypeToken`) to a true object reference.| + + The stack transitional behavior, in sequential order, is: + +1. A value type is pushed onto the stack. + +2. The value type is popped from the stack; the `box` operation is performed. + +3. An object reference to the resulting "boxed" value type is pushed onto the stack. + + A value type has two separate representations within the Common Language Infrastructure (CLI): + +- A 'raw' form used when a value type is embedded within another object or on the stack. + +- A 'boxed' form, where the data in the value type is wrapped (boxed) into an object so it can exist as an independent entity. + + The `box` instruction converts the 'raw' (unboxed) value type into an object reference (type `O`). This is accomplished by creating a new object and copying the data from the value type into the newly allocated object. `valTypeToken` is a metadata token indicating the type of the value type on the stack. + + is thrown if there is insufficient memory to satisfy the request. + + is thrown if the class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) is converted to native code, rather than at runtime. + + The following method overload can use the `box` opcode: + +- + ]]> @@ -1950,25 +1949,25 @@ Unconditionally transfers control to a target instruction. - |br `target`|Branches to a target instruction at the specified offset.| - - No evaluation stack behaviors are performed by this operation. - - The `br` instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `br` opcode: - -- - + |br `target`|Branches to a target instruction at the specified offset.| + + No evaluation stack behaviors are performed by this operation. + + The `br` instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `br` opcode: + +- + ]]> @@ -2012,25 +2011,25 @@ Unconditionally transfers control to a target instruction (short form). - |br.s `target`|Branches to a target instruction at the specified offset, short form.| - - No evaluation stack behaviors are performed by this operation. - - The `br.s` instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `br.s` opcode: - -- - + |br.s `target`|Branches to a target instruction at the specified offset, short form.| + + No evaluation stack behaviors are performed by this operation. + + The `br.s` instruction unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `br.s` opcode: + +- + ]]> @@ -2074,27 +2073,27 @@ Signals the Common Language Infrastructure (CLI) to inform the debugger that a break point has been tripped. - method overload can use the `break` opcode: - -- - + method overload can use the `break` opcode: + +- + ]]> @@ -2138,31 +2137,31 @@ Transfers control to a target instruction if is , a null reference ( in Visual Basic), or zero. - |brfalse `target`

brnull `target`

brzero `target`|Branches to a target instruction at the specified offset if `false`.| - - The stack transitional behavior, in sequential order, is: - -1. `value` is pushed onto the stack by a previous operation. - -2. `value` is popped from the stack; if `value` is `false`, branch to `target`. - - The `brfalse` instruction (and its aliases `brnull` and `brzero`) transfers control to the specified target instruction if `value` (of type `int32`, `int64`, object reference `O`, managed pointer `&`, transient pointer `*`, `native int`) is zero (`false`). If `value` is non-zero (`true`) execution continues at the next instruction. - - The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `brfalse` opcode: - -- - + |brfalse `target`

brnull `target`

brzero `target`|Branches to a target instruction at the specified offset if `false`.| + + The stack transitional behavior, in sequential order, is: + +1. `value` is pushed onto the stack by a previous operation. + +2. `value` is popped from the stack; if `value` is `false`, branch to `target`. + + The `brfalse` instruction (and its aliases `brnull` and `brzero`) transfers control to the specified target instruction if `value` (of type `int32`, `int64`, object reference `O`, managed pointer `&`, transient pointer `*`, `native int`) is zero (`false`). If `value` is non-zero (`true`) execution continues at the next instruction. + + The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `brfalse` opcode: + +- + ]]>
@@ -2206,31 +2205,31 @@ Transfers control to a target instruction if is , a null reference, or zero. - |brfalse.s `target`

brnull.s `target`

brzero.s `target`|Branches to a target instruction at the specified offset if `false`, short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value` is pushed onto the stack by a previous operation. - -2. `value` is popped from the stack; if `value` is `false`, branch to `target`. - - The `brfalse.s` instruction (and its aliases `brnull` and `brzero`) transfers control to the specified target instruction if `value` (of type `int32`, `int64`, object reference `O`, managed pointer `&`, transient pointer `*`, `native int`) is zero (`false`). If `value` is non-zero (`true`) execution continues at the next instruction. - - The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `brfalse.s` opcode: - -- - + |brfalse.s `target`

brnull.s `target`

brzero.s `target`|Branches to a target instruction at the specified offset if `false`, short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value` is pushed onto the stack by a previous operation. + +2. `value` is popped from the stack; if `value` is `false`, branch to `target`. + + The `brfalse.s` instruction (and its aliases `brnull` and `brzero`) transfers control to the specified target instruction if `value` (of type `int32`, `int64`, object reference `O`, managed pointer `&`, transient pointer `*`, `native int`) is zero (`false`). If `value` is non-zero (`true`) execution continues at the next instruction. + + The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `brfalse.s` opcode: + +- + ]]>
@@ -2274,33 +2273,33 @@ Transfers control to a target instruction if is , not null, or non-zero. - |brtrue `target`

brinst `target`|Branch to a target instruction at the specified offset if non-zero (`true`).| - - The stack transitional behavior, in sequential order, is: - -1. `value` is pushed onto the stack by a previous operation. - -2. `value` is popped from the stack; if `value` is `true`, branch to `target`. - - The `brtrue` instruction transfers control to the specified target instruction if `value` (type `native int`) is nonzero (`true`). If `value` is zero (`false`) execution continues at the next instruction. - - If `value` is an object reference (type `O`) then `brinst` (an alias for `brtrue`) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see ). - - The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `brtrue` opcode: - -- - + |brtrue `target`

brinst `target`|Branch to a target instruction at the specified offset if non-zero (`true`).| + + The stack transitional behavior, in sequential order, is: + +1. `value` is pushed onto the stack by a previous operation. + +2. `value` is popped from the stack; if `value` is `true`, branch to `target`. + + The `brtrue` instruction transfers control to the specified target instruction if `value` (type `native int`) is nonzero (`true`). If `value` is zero (`false`) execution continues at the next instruction. + + If `value` is an object reference (type `O`) then `brinst` (an alias for `brtrue`) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see ). + + The target instruction is represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `brtrue` opcode: + +- + ]]>
@@ -2344,33 +2343,33 @@ Transfers control to a target instruction (short form) if is , not null, or non-zero. - |brtrue.s `target`

brinst.s `target`|Branch to a target instruction at the specified offset if non-zero (`true`), short form.| - - The stack transitional behavior, in sequential order, is: - -1. `value` is pushed onto the stack by a previous operation. - -2. `value` is popped from the stack; if `value` is `true`, branch to `target`. - - The `brtrue.s` instruction transfers control to the specified target instruction if `value` (type `native int`) is nonzero (`true`). If `value` is zero (`false`) execution continues at the next instruction. - - If `value` is an object reference (type `O`) then `brinst` (an alias for `brtrue`) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see ). - - The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. - - The following method overload can use the `brtrue.s` opcode: - -- - + |brtrue.s `target`

brinst.s `target`|Branch to a target instruction at the specified offset if non-zero (`true`), short form.| + + The stack transitional behavior, in sequential order, is: + +1. `value` is pushed onto the stack by a previous operation. + +2. `value` is popped from the stack; if `value` is `true`, branch to `target`. + + The `brtrue.s` instruction transfers control to the specified target instruction if `value` (type `native int`) is nonzero (`true`). If `value` is zero (`false`) execution continues at the next instruction. + + If `value` is an object reference (type `O`) then `brinst` (an alias for `brtrue`) transfers control if it represents an instance of an object (for example, if it is not the null object reference; see ). + + The target instruction is represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. + + The following method overload can use the `brtrue.s` opcode: + +- + ]]>
@@ -2414,49 +2413,49 @@ Calls the method indicated by the passed method descriptor. - |call `methodDesc`|Call the method described by `methodDesc`.| - - The stack transitional behavior, in sequential order, is: - -1. Method arguments `arg1` through `argN` are pushed onto the stack. - -2. Method arguments `arg1` through `argN` are popped from the stack; the method call is performed with these arguments and control is transferred to the method referred to by the method descriptor. When complete, a return value is generated by the callee method and sent to the caller. - -3. The return value is pushed onto the stack. - - The `call` instruction calls the method indicated by the method descriptor passed with the instruction. The method descriptor is a metadata token that indicates the method to call and the number, type, and order of the arguments that have been placed on the stack to be passed to that method as well as the calling convention to be used. The `call` instruction can be immediately preceded by a `tail` () prefix instruction to specify that the current method state should be released before transferring control. If the call transfers control to a method of higher trust than the origin method, the stack frame is not released. Instead, the execution continues silently as if the `tail` had not been supplied. The metadata token carries sufficient information to determine whether the call is to a static method, an instance method, a virtual method, or a global function. In all of these cases the destination address is determined entirely from the method descriptor (contrast this with the instruction for calling virtual methods, where the destination address also depends upon the runtime type of the instance reference pushed before the ). - - The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. There are three important special cases: - - 1. Calls to an instance (or virtual) method must push that instance reference before any of the user-visible arguments. The instance reference must not be a null reference. The signature carried in the metadata does not contain an entry in the parameter list for the `this` pointer; instead, it uses a bit to indicate whether the method requires passing the `this` pointer. - - 2. It is valid to call a virtual method using `call` (rather than `callvirt`); this indicates that the method is to be resolved using the class specified by method rather than as specified dynamically from the object being invoked. - - 3. Note that a delegate's `Invoke` method can be called with either the `call` or `callvirt` instruction. - - may be thrown if system security does not grant the caller access to the called method. The security check may occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time. - + |call `methodDesc`|Call the method described by `methodDesc`.| + + The stack transitional behavior, in sequential order, is: + +1. Method arguments `arg1` through `argN` are pushed onto the stack. + +2. Method arguments `arg1` through `argN` are popped from the stack; the method call is performed with these arguments and control is transferred to the method referred to by the method descriptor. When complete, a return value is generated by the callee method and sent to the caller. + +3. The return value is pushed onto the stack. + + The `call` instruction calls the method indicated by the method descriptor passed with the instruction. The method descriptor is a metadata token that indicates the method to call and the number, type, and order of the arguments that have been placed on the stack to be passed to that method as well as the calling convention to be used. The `call` instruction can be immediately preceded by a `tail` () prefix instruction to specify that the current method state should be released before transferring control. If the call transfers control to a method of higher trust than the origin method, the stack frame is not released. Instead, the execution continues silently as if the `tail` had not been supplied. The metadata token carries sufficient information to determine whether the call is to a static method, an instance method, a virtual method, or a global function. In all of these cases the destination address is determined entirely from the method descriptor (contrast this with the instruction for calling virtual methods, where the destination address also depends upon the runtime type of the instance reference pushed before the ). + + The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. There are three important special cases: + + 1. Calls to an instance (or virtual) method must push that instance reference before any of the user-visible arguments. The instance reference must not be a null reference. The signature carried in the metadata does not contain an entry in the parameter list for the `this` pointer; instead, it uses a bit to indicate whether the method requires passing the `this` pointer. + + 2. It is valid to call a virtual method using `call` (rather than `callvirt`); this indicates that the method is to be resolved using the class specified by method rather than as specified dynamically from the object being invoked. + + 3. Note that a delegate's `Invoke` method can be called with either the `call` or `callvirt` instruction. + + may be thrown if system security does not grant the caller access to the called method. The security check may occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time. + > [!NOTE] -> When calling methods of System.Object on value types, consider using the `constrained` prefix with the `callvirt` instruction instead of emitting a `call` instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the `constrained` prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a `MethodImpl`. These issues are described in more detail in the opcode. - - The following method overloads can use the `call` opcode: - -- - +> When calling methods of System.Object on value types, consider using the `constrained` prefix with the `callvirt` instruction instead of emitting a `call` instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the `constrained` prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a `MethodImpl`. These issues are described in more detail in the opcode. + + The following method overloads can use the `call` opcode: + +- + - - + - - + > [!NOTE] -> The method is provided for `varargs` calls. Use the method for normal calls. - +> The method is provided for `varargs` calls. Use the method for normal calls. + ]]> @@ -2500,41 +2499,41 @@ Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments described by a calling convention. - |calli `callSiteDescr`|Calls the method pointed to with arguments described by the calling convention.| - - The stack transitional behavior, in sequential order, is: - -1. Method arguments `arg1` through `argN` are pushed onto the stack. - -2. The method entry pointer is pushed onto the stack. - -3. Method arguments `arg1` through `argN` and the method entry pointer are popped from the stack; the call to the method is performed. When complete, a return value is generated by the callee method and sent to the caller. - -4. The return value is pushed onto the stack. - - The `calli` instruction calls the method entry pointer with the arguments `arg1` through `argN`. The types of these arguments are described by the specific calling convention (`callSiteDesc`). The `calli` instruction may be immediately preceded by a `tail` prefix () to specify that the current method state should be released before transferring control. If the call would transfer control to a method of higher trust than the origin method the stack frame will not be released; instead, the execution will continue silently as if the `tail` had not been supplied. - - The method entry pointer is assumed to be a specific pointer to native code (of the target machine) that can be legitimately called with the arguments described by the calling convention (a metadata token for a stand-alone signature). Such a pointer can be created using the or instructions, or passed in from native code. - - The calling convention is not checked dynamically, so code that uses a `calli` instruction does not work correctly if the destination does not actually use the specified calling convention. - - The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The argument-building code sequence for an instance or virtual method must push that instance reference (which must not be a null reference) before any of the user-visible arguments. - - may be thrown if the system security does not grant the caller access to the called method. The security check can occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. - - The following methods can be used to perform a `calli` instruction on the stack. Note that `calli` should be called through the below methods rather than using the class to place the instruction directly on the stack. - -- for calls using a managed calling convention. - -- for calls using an unmanaged calling convention. - + |calli `callSiteDescr`|Calls the method pointed to with arguments described by the calling convention.| + + The stack transitional behavior, in sequential order, is: + +1. Method arguments `arg1` through `argN` are pushed onto the stack. + +2. The method entry pointer is pushed onto the stack. + +3. Method arguments `arg1` through `argN` and the method entry pointer are popped from the stack; the call to the method is performed. When complete, a return value is generated by the callee method and sent to the caller. + +4. The return value is pushed onto the stack. + + The `calli` instruction calls the method entry pointer with the arguments `arg1` through `argN`. The types of these arguments are described by the specific calling convention (`callSiteDesc`). The `calli` instruction may be immediately preceded by a `tail` prefix () to specify that the current method state should be released before transferring control. If the call would transfer control to a method of higher trust than the origin method the stack frame will not be released; instead, the execution will continue silently as if the `tail` had not been supplied. + + The method entry pointer is assumed to be a specific pointer to native code (of the target machine) that can be legitimately called with the arguments described by the calling convention (a metadata token for a stand-alone signature). Such a pointer can be created using the or instructions, or passed in from native code. + + The calling convention is not checked dynamically, so code that uses a `calli` instruction does not work correctly if the destination does not actually use the specified calling convention. + + The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The argument-building code sequence for an instance or virtual method must push that instance reference (which must not be a null reference) before any of the user-visible arguments. + + may be thrown if the system security does not grant the caller access to the called method. The security check can occur when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. + + The following methods can be used to perform a `calli` instruction on the stack. Note that `calli` should be called through the below methods rather than using the class to place the instruction directly on the stack. + +- for calls using a managed calling convention. + +- for calls using an unmanaged calling convention. + ]]> @@ -2578,50 +2577,50 @@ Calls a late-bound method on an object, pushing the return value onto the evaluation stack. - |callvirt `method`|Calls a specific method associated with `obj`.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference `obj` is pushed onto the stack. - -2. Method arguments `arg1` through `argN` are pushed onto the stack. - -3. Method arguments `arg1` through `argN` and the object reference `obj` are popped from the stack; the method call is performed with these arguments and control is transferred to the method in `obj` referred to by the method metadata token. When complete, a return value is generated by the callee method and sent to the caller. - -4. The return value is pushed onto the stack. - - The `callvirt` instruction calls a late-bound method on an object. That is, the method is chosen based on the runtime type of `obj` rather than the compile-time class visible in the method pointer. `Callvirt` can be used to call both virtual and instance methods. The `callvirt` instruction may be immediately preceded by a `tail` () prefix to specify that the current stack frame should be released before transferring control. If the call would transfer control to a method of higher trust than the original method the stack frame will not be released. - - The method metadata token provides the name, class and signature of the method to call. The class associated with `obj` is the class of which it is an instance. If the class defines a non-static method that matches the indicated method name and signature, this method is called. Otherwise all classes in the base class chain of this class are checked in order. It is an error if no method is found. - - `Callvirt` pops the object and the associated arguments off the evaluation stack before calling the method. If the method has a return value, it is pushed on the stack upon method completion. On the callee side, the `obj` parameter is accessed as argument 0, `arg1` as argument 1, and so on. - - The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The instance reference `obj` (always required for `callvirt`) must be pushed before any of the user-visible arguments. The signature (carried in the metadata token) need not contain an entry in the parameter list for the this pointer. - - Note that a virtual method can also be called using the instruction. - - is thrown if a non-static method with the indicated name and signature could not be found in the class associated with `obj` or any of its base classes. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. - - is thrown if obj is null. - - is thrown if system security does not grant the caller access to the called method. The security check may occur when the CIL is converted to native code rather than at run time. - + |callvirt `method`|Calls a specific method associated with `obj`.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference `obj` is pushed onto the stack. + +2. Method arguments `arg1` through `argN` are pushed onto the stack. + +3. Method arguments `arg1` through `argN` and the object reference `obj` are popped from the stack; the method call is performed with these arguments and control is transferred to the method in `obj` referred to by the method metadata token. When complete, a return value is generated by the callee method and sent to the caller. + +4. The return value is pushed onto the stack. + + The `callvirt` instruction calls a late-bound method on an object. That is, the method is chosen based on the runtime type of `obj` rather than the compile-time class visible in the method pointer. `Callvirt` can be used to call both virtual and instance methods. The `callvirt` instruction may be immediately preceded by a `tail` () prefix to specify that the current stack frame should be released before transferring control. If the call would transfer control to a method of higher trust than the original method the stack frame will not be released. + + The method metadata token provides the name, class and signature of the method to call. The class associated with `obj` is the class of which it is an instance. If the class defines a non-static method that matches the indicated method name and signature, this method is called. Otherwise all classes in the base class chain of this class are checked in order. It is an error if no method is found. + + `Callvirt` pops the object and the associated arguments off the evaluation stack before calling the method. If the method has a return value, it is pushed on the stack upon method completion. On the callee side, the `obj` parameter is accessed as argument 0, `arg1` as argument 1, and so on. + + The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, then the third, until all necessary arguments are atop the stack in descending order. The instance reference `obj` (always required for `callvirt`) must be pushed before any of the user-visible arguments. The signature (carried in the metadata token) need not contain an entry in the parameter list for the this pointer. + + Note that a virtual method can also be called using the instruction. + + is thrown if a non-static method with the indicated name and signature could not be found in the class associated with `obj` or any of its base classes. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. + + is thrown if obj is null. + + is thrown if system security does not grant the caller access to the called method. The security check may occur when the CIL is converted to native code rather than at run time. + > [!NOTE] -> When calling methods of System.Object on value types, consider using the `constrained` prefix with the `callvirt` instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the `constrained` prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a `MethodImpl`. These issues are described in more detail in the opcode. - - The following method overload can use the `callvirt` opcode: - -- - -- - +> When calling methods of System.Object on value types, consider using the `constrained` prefix with the `callvirt` instruction. This removes the need to emit different IL depending on whether or not the value type overrides the method, avoiding a potential versioning problem. Consider using the `constrained` prefix when invoking interface methods on value types, since the value type method implementing the interface method can be changed using a `MethodImpl`. These issues are described in more detail in the opcode. + + The following method overload can use the `callvirt` opcode: + +- + +- + ]]> @@ -2671,33 +2670,33 @@ Attempts to cast an object passed by reference to the specified class. - |castclass `class`|Casts an object to a new object of type `class`.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference is pushed onto the stack. - -2. The object reference is popped from the stack; the referenced object is cast as the specified `class`. - -3. If successful, a new object reference is pushed onto the stack. - - The `castclass` instruction attempts to cast the object reference (type `O`) atop the stack to a specified class. The new class is specified by a metadata token indicating the desired class. If the class of the object on the top of the stack does not implement the new class (assuming the new class is an interface) and is not a derived class of the new class then an is thrown. If the object reference is a null reference, `castclass` succeeds and returns the new object as a null reference. - - is thrown if obj cannot be cast to class. - - is thrown if class cannot be found. This is typically detected when a Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime. - - The following method overload can use the `castclass` opcode: - -- - + |castclass `class`|Casts an object to a new object of type `class`.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference is pushed onto the stack. + +2. The object reference is popped from the stack; the referenced object is cast as the specified `class`. + +3. If successful, a new object reference is pushed onto the stack. + + The `castclass` instruction attempts to cast the object reference (type `O`) atop the stack to a specified class. The new class is specified by a metadata token indicating the desired class. If the class of the object on the top of the stack does not implement the new class (assuming the new class is an interface) and is not a derived class of the new class then an is thrown. If the object reference is a null reference, `castclass` succeeds and returns the new object as a null reference. + + is thrown if obj cannot be cast to class. + + is thrown if class cannot be found. This is typically detected when a Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime. + + The following method overload can use the `castclass` opcode: + +- + ]]> @@ -2741,33 +2740,33 @@ Compares two values. If they are equal, the integer value 1 ) is pushed onto the evaluation stack; otherwise 0 () is pushed onto the evaluation stack. - method overload can use the `ceq` opcode: - -- - + method overload can use the `ceq` opcode: + +- + ]]> @@ -2811,33 +2810,33 @@ Compares two values. If the first value is greater than the second, the integer value 1 ) is pushed onto the evaluation stack; otherwise 0 () is pushed onto the evaluation stack. - method overload can use the `cgt` opcode: - -- - + method overload can use the `cgt` opcode: + +- + ]]> @@ -2881,37 +2880,37 @@ Compares two unsigned or unordered values. If the first value is greater than the second, the integer value 1 ) is pushed onto the evaluation stack; otherwise 0 () is pushed onto the evaluation stack. - method overload can use the `cgt.un` opcode: - -- - + method overload can use the `cgt.un` opcode: + +- + ]]> @@ -2955,43 +2954,43 @@ Throws if value is not a finite number. - if value is not a finite number.| - - The stack transitional behavior, in sequential order, is: - -1. `value` is pushed onto the stack. - -2. `value` is popped from the stack and the `ckfinite` instruction is performed on it. - -3. `value` is pushed back onto the stack if no exception is thrown. - - The `ckfinite instruction` throws if `value` (a floating-point number) is either a "not a number" value (NaN) or a `+-` infinity value. `Ckfinite` leaves the value on the stack if no exception is thrown. Execution is unspecified if `value` is not a floating-point number. - - is thrown if `value` is not a 'normal' number. - - Note that a special exception or a derived class of may be more appropriate, passing the incorrect value to the exception handler. - - The following method overload can use the `ckfinite` opcode: - -- - - ]]> - - -
- - - - - - + if value is not a finite number.| + + The stack transitional behavior, in sequential order, is: + +1. `value` is pushed onto the stack. + +2. `value` is popped from the stack and the `ckfinite` instruction is performed on it. + +3. `value` is pushed back onto the stack if no exception is thrown. + + The `ckfinite instruction` throws if `value` (a floating-point number) is either a "not a number" value (NaN) or a `+-` infinity value. `Ckfinite` leaves the value on the stack if no exception is thrown. Execution is unspecified if `value` is not a floating-point number. + + is thrown if `value` is not a 'normal' number. + + Note that a special exception or a derived class of may be more appropriate, passing the incorrect value to the exception handler. + + The following method overload can use the `ckfinite` opcode: + +- + + ]]> + + + + + + + + + Field @@ -3025,33 +3024,33 @@ Compares two values. If the first value is less than the second, the integer value 1 ) is pushed onto the evaluation stack; otherwise 0 () is pushed onto the evaluation stack. - method overload can use the `clt` opcode: - -- - + method overload can use the `clt` opcode: + +- + ]]> @@ -3095,39 +3094,39 @@ Compares the unsigned or unordered values and . If is less than , then the integer value 1 ) is pushed onto the evaluation stack; otherwise 0 () is pushed onto the evaluation stack. - method overload can use the `clt.un` opcode: - -- - + method overload can use the `clt.un` opcode: + +- + ]]> @@ -3170,47 +3169,47 @@ Constrains the type on which a virtual method call is made. - |constrained. `thisType`|Call a virtual method on a type constrained to be type `T`.| - - The `constrained` prefix is permitted only on a `callvirt` instruction. - - The state of the MSIL stack at this point must be as follows: - -1. A managed pointer, `ptr`, is pushed onto the stack. The type of `ptr` must be a managed pointer (`&`) to `thisType`. Note that this is different from the case of an unprefixed `callvirt` instruction, which expects a reference of `thisType`. - -2. Method arguments `arg1` through `argN` are pushed onto the stack, just as with an unprefixed `callvirt` instruction. - - The `constrained` prefix is designed to allow `callvirt` instructions to be made in a uniform way independent of whether `thisType` is a value type or a reference type. - - When a `callvirt` `method` instruction has been prefixed by `constrained` `thisType`, the instruction is executed as follows: - -- If `thisType` is a reference type (as opposed to a value type) then `ptr` is dereferenced and passed as the 'this' pointer to the `callvirt` of `method`. - -- If `thisType` is a value type and `thisType` implements `method` then `ptr` is passed unmodified as the 'this' pointer to a `call` `method` instruction, for the implementation of `method` by `thisType`. - -- If `thisType` is a value type and `thisType` does not implement `method` then `ptr` is dereferenced, boxed, and passed as the 'this' pointer to the `callvirt` `method` instruction. - - This last case can occur only when `method` was defined on , , or and not overridden by `thisType`. In this case, the boxing causes a copy of the original object to be made. However, because none of the methods of , , and modify the state of the object, this fact cannot be detected. - - The `constrained` prefix supports IL generators that create generic code. Normally the `callvirt` instruction is not valid on value types. Instead it is required that IL compilers effectively perform the 'this' transformation outlined above at compile time, depending on the type of `ptr` and the method being called. However, when `ptr` is a generic type that is unknown at compile time, it is not possible to make this transformation at compile time. - - The `constrained` opcode allows IL compilers to make a call to a virtual function in a uniform way independent of whether `ptr` is a value type or a reference type. Although it is intended for the case where `thisType` is a generic type variable, the `constrained` prefix also works for nongeneric types and can reduce the complexity of generating virtual calls in languages that hide the distinction between value types and reference types. - - Using the `constrained` prefix also avoids potential versioning problems with value types. If the `constrained` prefix is not used, different IL must be emitted depending on whether or not a value type overrides a method of System.Object. For example, if a value type `V` overrides the Object.ToString() method, a `call` `V.ToString()` instruction is emitted; if it does not, a `box` instruction and a `callvirt` `Object.ToString()` instruction are emitted. A versioning problem can arise in the former case if the override is later removed, and in the latter case if an override is later added. - - The `constrained` prefix can also be used for invocation of interface methods on value types, because the value type method implementing the interface method can be changed using a `MethodImpl`. If the `constrained` prefix is not used, the compiler is forced to choose which of the value type's methods to bind to at compile time. Using the `constrained` prefix allows the MSIL to bind to the method that implements the interface method at run time, rather than at compile time. - - The following method overload can use the `constrained` opcode: - -- - + |constrained. `thisType`|Call a virtual method on a type constrained to be type `T`.| + + The `constrained` prefix is permitted only on a `callvirt` instruction. + + The state of the MSIL stack at this point must be as follows: + +1. A managed pointer, `ptr`, is pushed onto the stack. The type of `ptr` must be a managed pointer (`&`) to `thisType`. Note that this is different from the case of an unprefixed `callvirt` instruction, which expects a reference of `thisType`. + +2. Method arguments `arg1` through `argN` are pushed onto the stack, just as with an unprefixed `callvirt` instruction. + + The `constrained` prefix is designed to allow `callvirt` instructions to be made in a uniform way independent of whether `thisType` is a value type or a reference type. + + When a `callvirt` `method` instruction has been prefixed by `constrained` `thisType`, the instruction is executed as follows: + +- If `thisType` is a reference type (as opposed to a value type) then `ptr` is dereferenced and passed as the 'this' pointer to the `callvirt` of `method`. + +- If `thisType` is a value type and `thisType` implements `method` then `ptr` is passed unmodified as the 'this' pointer to a `call` `method` instruction, for the implementation of `method` by `thisType`. + +- If `thisType` is a value type and `thisType` does not implement `method` then `ptr` is dereferenced, boxed, and passed as the 'this' pointer to the `callvirt` `method` instruction. + + This last case can occur only when `method` was defined on , , or and not overridden by `thisType`. In this case, the boxing causes a copy of the original object to be made. However, because none of the methods of , , and modify the state of the object, this fact cannot be detected. + + The `constrained` prefix supports IL generators that create generic code. Normally the `callvirt` instruction is not valid on value types. Instead it is required that IL compilers effectively perform the 'this' transformation outlined above at compile time, depending on the type of `ptr` and the method being called. However, when `ptr` is a generic type that is unknown at compile time, it is not possible to make this transformation at compile time. + + The `constrained` opcode allows IL compilers to make a call to a virtual function in a uniform way independent of whether `ptr` is a value type or a reference type. Although it is intended for the case where `thisType` is a generic type variable, the `constrained` prefix also works for nongeneric types and can reduce the complexity of generating virtual calls in languages that hide the distinction between value types and reference types. + + Using the `constrained` prefix also avoids potential versioning problems with value types. If the `constrained` prefix is not used, different IL must be emitted depending on whether or not a value type overrides a method of System.Object. For example, if a value type `V` overrides the Object.ToString() method, a `call` `V.ToString()` instruction is emitted; if it does not, a `box` instruction and a `callvirt` `Object.ToString()` instruction are emitted. A versioning problem can arise in the former case if the override is later removed, and in the latter case if an override is later added. + + The `constrained` prefix can also be used for invocation of interface methods on value types, because the value type method implementing the interface method can be changed using a `MethodImpl`. If the `constrained` prefix is not used, the compiler is forced to choose which of the value type's methods to bind to at compile time. Using the `constrained` prefix allows the MSIL to bind to the method that implements the interface method at run time, rather than at compile time. + + The following method overload can use the `constrained` opcode: + +- + ]]> @@ -3254,35 +3253,35 @@ Converts the value on top of the evaluation stack to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.i` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.i` opcode: + +- + ]]> @@ -3326,35 +3325,35 @@ Converts the value on top of the evaluation stack to , then extends (pads) it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.i1` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.i1` opcode: + +- + ]]> @@ -3398,35 +3397,35 @@ Converts the value on top of the evaluation stack to , then extends (pads) it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.i2` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.i2` opcode: + +- + ]]> @@ -3470,35 +3469,35 @@ Converts the value on top of the evaluation stack to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.i4` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.i4` opcode: + +- + ]]> @@ -3542,35 +3541,35 @@ Converts the value on top of the evaluation stack to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.i8` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.i8` opcode: + +- + ]]> @@ -3614,33 +3613,33 @@ Converts the signed value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i` opcode: + +- + ]]> @@ -3684,33 +3683,33 @@ Converts the unsigned value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i.un` opcode: + +- + ]]> @@ -3754,33 +3753,33 @@ Converts the signed value on top of the evaluation stack to signed and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i1` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i1` opcode: + +- + ]]> @@ -3824,33 +3823,33 @@ Converts the unsigned value on top of the evaluation stack to signed and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i1.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i1.un` opcode: + +- + ]]> @@ -3894,33 +3893,33 @@ Converts the signed value on top of the evaluation stack to signed and extending it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i2` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i2` opcode: + +- + ]]> @@ -3964,33 +3963,33 @@ Converts the unsigned value on top of the evaluation stack to signed and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i2.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i2.un` opcode: + +- + ]]> @@ -4034,33 +4033,33 @@ Converts the signed value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i4` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i4` opcode: + +- + ]]> @@ -4104,33 +4103,33 @@ Converts the unsigned value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i4.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i4.un` opcode: + +- + ]]> @@ -4174,33 +4173,33 @@ Converts the signed value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i8` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i8` opcode: + +- + ]]> @@ -4244,33 +4243,33 @@ Converts the unsigned value on top of the evaluation stack to signed , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.i8.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.i8.un` opcode: + +- + ]]> @@ -4314,36 +4313,36 @@ Converts the signed value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u` opcode: - -- - - ]]> - - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u` opcode: + +- + + ]]> + + @@ -4384,33 +4383,33 @@ Converts the unsigned value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.uvf.u.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.uvf.u.un` opcode: + +- + ]]> @@ -4454,33 +4453,33 @@ Converts the signed value on top of the evaluation stack to and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u1` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u1` opcode: + +- + ]]> @@ -4524,33 +4523,33 @@ Converts the unsigned value on top of the evaluation stack to and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u1.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u1.un` opcode: + +- + ]]> @@ -4594,33 +4593,33 @@ Converts the signed value on top of the evaluation stack to and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u2` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u2` opcode: + +- + ]]> @@ -4664,33 +4663,33 @@ Converts the unsigned value on top of the evaluation stack to and extends it to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u2.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u2.un` opcode: + +- + ]]> @@ -4734,33 +4733,33 @@ Converts the signed value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u4` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u4` opcode: + +- + ]]> @@ -4804,33 +4803,33 @@ Converts the unsigned value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u4.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u4.un` opcode: + +- + ]]> @@ -4874,33 +4873,33 @@ Converts the signed value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u8` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u8` opcode: + +- + ]]> @@ -4944,33 +4943,33 @@ Converts the unsigned value on top of the evaluation stack to , throwing on overflow. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `conv.ovf.u8.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `conv.ovf.u8.un` opcode: + +- + ]]> @@ -5014,35 +5013,35 @@ Converts the unsigned integer value on top of the evaluation stack to . - method overload can use the `conv.r.un` opcode: - -- - + method overload can use the `conv.r.un` opcode: + +- + ]]> @@ -5086,35 +5085,35 @@ Converts the value on top of the evaluation stack to . - method overload can use the `conv.r4` opcode: - -- - + method overload can use the `conv.r4` opcode: + +- + ]]> @@ -5158,35 +5157,35 @@ Converts the value on top of the evaluation stack to . - method overload can use the `conv.r8` opcode: - -- - + method overload can use the `conv.r8` opcode: + +- + ]]> @@ -5230,35 +5229,35 @@ Converts the value on top of the evaluation stack to , and extends it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.u` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.u` opcode: + +- + ]]> @@ -5302,35 +5301,35 @@ Converts the value on top of the evaluation stack to , and extends it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.u1` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.u1` opcode: + +- + ]]> @@ -5374,35 +5373,35 @@ Converts the value on top of the evaluation stack to , and extends it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.u2` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.u2` opcode: + +- + ]]> @@ -5446,35 +5445,35 @@ Converts the value on top of the evaluation stack to , and extends it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.u4` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.u4` opcode: + +- + ]]> @@ -5518,35 +5517,35 @@ Converts the value on top of the evaluation stack to , and extends it to . - and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. - - The following method overload can use the `conv.u8` opcode: - -- - + and for equivalent instructions that will throw an exception when the result type can not properly represent the result value. + + The following method overload can use the `conv.u8` opcode: + +- + ]]> @@ -5590,37 +5589,37 @@ Copies a specified number bytes from a source address to a destination address. - ` instruction to indicate that either the source or the destination is unaligned. - - The operation of the `cpblk` instruction can be altered by an immediately preceding or prefix instruction. - - may be thrown if an invalid address is detected. - - The following method overload can use the `cpblk` opcode: - -- - + ` instruction to indicate that either the source or the destination is unaligned. + + The operation of the `cpblk` instruction can be altered by an immediately preceding or prefix instruction. + + may be thrown if an invalid address is detected. + + The following method overload can use the `cpblk` opcode: + +- + ]]> @@ -5664,31 +5663,31 @@ Copies the value type located at the address of an object (type , or ) to the address of the destination object (type , or ). - |cpobj `classTok`|Copies a value type from a source object to a destination object.| - - The stack transitional behavior, in sequential order, is: - -1. The destination object reference is pushed onto the stack. - -2. The source object reference is pushed onto the stack. - -3. The two object references are popped from the stack; the value type at the address of the source object is copied to the address of the destination object. - - The behavior of `cpobj` is unspecified if the source and destination object references are not pointers to instances of the class represented by the class token `classTok` (a `typeref` or `typedef`), or if `classTok` does not represent a value type. - - may be thrown if an invalid address is detected. - - The following method overload can use the `cpobj` opcode: - -- - + |cpobj `classTok`|Copies a value type from a source object to a destination object.| + + The stack transitional behavior, in sequential order, is: + +1. The destination object reference is pushed onto the stack. + +2. The source object reference is pushed onto the stack. + +3. The two object references are popped from the stack; the value type at the address of the source object is copied to the address of the destination object. + + The behavior of `cpobj` is unspecified if the source and destination object references are not pointers to instances of the class represented by the class token `classTok` (a `typeref` or `typedef`), or if `classTok` does not represent a value type. + + may be thrown if an invalid address is detected. + + The following method overload can use the `cpobj` opcode: + +- + ]]> @@ -5732,53 +5731,53 @@ Divides two values and pushes the result as a floating-point (type ) or quotient (type ) onto the evaluation stack. - if the result cannot be represented in the result type. This can happen if `value1` is the maximum negative value, and `value2` is -1. - - Integral operations throw if `value2` is zero. - - Note that on Intel-based platforms an is thrown when computing (minint div -1). Floating-point operations never throw an exception (they produce NaNs or infinities instead). - - The following method overload can use the `div` opcode: - -- - - ]]> - - - + if the result cannot be represented in the result type. This can happen if `value1` is the maximum negative value, and `value2` is -1. + + Integral operations throw if `value2` is zero. + + Note that on Intel-based platforms an is thrown when computing (minint div -1). Floating-point operations never throw an exception (they produce NaNs or infinities instead). + + The following method overload can use the `div` opcode: + +- + + ]]> + + + @@ -5818,31 +5817,31 @@ Divides two unsigned integer values and pushes the result () onto the evaluation stack. - method overload can use the `div.un` opcode: - -- - + method overload can use the `div.un` opcode: + +- + ]]> @@ -5886,31 +5885,31 @@ Copies the current topmost value on the evaluation stack, and then pushes the copy onto the evaluation stack. - method overload can use the `dup` opcode: - -- - + method overload can use the `dup` opcode: + +- + ]]> @@ -5954,37 +5953,37 @@ Transfers control from the clause of an exception back to the Common Language Infrastructure (CLI) exception handler. - method overload can use the `endfilter` opcode: - -- - + method overload can use the `endfilter` opcode: + +- + ]]> @@ -6028,31 +6027,31 @@ Transfers control from the or clause of an exception block back to the Common Language Infrastructure (CLI) exception handler. -
endfault|Ends the `finally` or `fault` clause of an exception block.| - - There are no stack transition behaviors for this instruction. - - `Endfinally` and `endfault` signal the end of the `finally` or `fault` clause so that stack unwinding can continue until the exception handler is invoked. The `endfinally` or `endfault` instruction transfers control back to the CLI exception mechanism. The mechanism then searches for the next `finally` clause in the chain if the protected block was exited with a leave instruction. If the protected block was exited with an exception, the CLI will search for the next `finally` or `fault`, or enter the exception handler chosen during the first pass of exception handling. - - An `endfinally` instruction might only appear lexically within a `finally` block. Unlike the `endfilter` instruction, there is no requirement that the block end with an `endfinally` instruction, and there can be as many `endfinally` instructions within the block as required. These same restrictions apply to the `endfault` instruction and the `fault` block. - - Control cannot be transferred into a `finally` (or `fault`) block except through the exception mechanism. Control cannot be transferred out of a `finally` (or `fault`) block except through the use of a `throw` instruction or executing the `endfinally` (or `endfault`) instruction. In particular, you cannot "fall out" of a `finally` (or `fault`) block or to execute a or instruction within a `finally` (or `fault`) block. - - Note that the `endfault` and `endfinally` instructions are aliases - they correspond to the same opcode. - - The following method overload can use the `endfinally` (`endfault`) opcode, as well as the `ILGenerator` method . - -- - -- - +
endfault|Ends the `finally` or `fault` clause of an exception block.| + + There are no stack transition behaviors for this instruction. + + `Endfinally` and `endfault` signal the end of the `finally` or `fault` clause so that stack unwinding can continue until the exception handler is invoked. The `endfinally` or `endfault` instruction transfers control back to the CLI exception mechanism. The mechanism then searches for the next `finally` clause in the chain if the protected block was exited with a leave instruction. If the protected block was exited with an exception, the CLI will search for the next `finally` or `fault`, or enter the exception handler chosen during the first pass of exception handling. + + An `endfinally` instruction might only appear lexically within a `finally` block. Unlike the `endfilter` instruction, there is no requirement that the block end with an `endfinally` instruction, and there can be as many `endfinally` instructions within the block as required. These same restrictions apply to the `endfault` instruction and the `fault` block. + + Control cannot be transferred into a `finally` (or `fault`) block except through the exception mechanism. Control cannot be transferred out of a `finally` (or `fault`) block except through the use of a `throw` instruction or executing the `endfinally` (or `endfault`) instruction. In particular, you cannot "fall out" of a `finally` (or `fault`) block or to execute a or instruction within a `finally` (or `fault`) block. + + Note that the `endfault` and `endfinally` instructions are aliases - they correspond to the same opcode. + + The following method overload can use the `endfinally` (`endfault`) opcode, as well as the `ILGenerator` method . + +- + +- + ]]>
@@ -6096,35 +6095,35 @@ Initializes a specified block of memory at a specific address to a given size and initial value. - or prefix instruction. - - may be thrown if an invalid address is detected. - - The following method overload can use the `initblk` opcode: - -- - + or prefix instruction. + + may be thrown if an invalid address is detected. + + The following method overload can use the `initblk` opcode: + +- + ]]> @@ -6168,29 +6167,29 @@ Initializes each field of the value type at a specified address to a null reference or a 0 of the appropriate primitive type. - |`initobj` `typeTok`|Initializes a value type.| - - The stack transitional behavior, in sequential order, is: - -1. The address of the value type to initialize is pushed onto the stack. - -2. The address is popped from the stack; the value type at the specified address is initialized as type `typeTok`. - - The `initobj` instruction initializes each field of the value type specified by the pushed address (of type `native int`, `&`, or `*`) to a null reference or a 0 of the appropriate primitive type. After this method is called, the instance is ready for a constructor method to be called. If `typeTok` is a reference type, this instruction has the same effect as `ldnull` followed by `stind.ref`. - - Unlike , `initobj` does not call the constructor method. `Initobj` is intended for initializing value types, while `newobj` is used to allocate and initialize objects. - - The following method overload can use the `initobj` opcode: - -- - + |`initobj` `typeTok`|Initializes a value type.| + + The stack transitional behavior, in sequential order, is: + +1. The address of the value type to initialize is pushed onto the stack. + +2. The address is popped from the stack; the value type at the specified address is initialized as type `typeTok`. + + The `initobj` instruction initializes each field of the value type specified by the pushed address (of type `native int`, `&`, or `*`) to a null reference or a 0 of the appropriate primitive type. After this method is called, the instance is ready for a constructor method to be called. If `typeTok` is a reference type, this instruction has the same effect as `ldnull` followed by `stind.ref`. + + Unlike , `initobj` does not call the constructor method. `Initobj` is intended for initializing value types, while `newobj` is used to allocate and initialize objects. + + The following method overload can use the `initobj` opcode: + +- + ]]> @@ -6234,31 +6233,31 @@ Tests whether an object reference (type ) is an instance of a particular class. - |isinst `class`|Tests if an object reference is an instance of `class`, returning either a null reference or an instance of that class or interface.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference is pushed onto the stack. - -2. The object reference is popped from the stack and tested to see if it is an instance of the class passed in `class`. - -3. The result (either an object reference or a null reference) is pushed onto the stack. - - `Class` is a metadata token indicating the desired class. If the class of the object on the top of the stack implements `class` (if `class` is an interface) or is a derived class of `class` (if `class` is a regular class) then it is cast to type `class` and the result is pushed on the stack, exactly as though had been called. Otherwise, a null reference is pushed on the stack. If the object reference itself is a null reference, then `isinst` likewise returns a null reference. - - is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. - - The following method overload can use the `isinst` opcode: - -- - + |isinst `class`|Tests if an object reference is an instance of `class`, returning either a null reference or an instance of that class or interface.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference is pushed onto the stack. + +2. The object reference is popped from the stack and tested to see if it is an instance of the class passed in `class`. + +3. The result (either an object reference or a null reference) is pushed onto the stack. + + `Class` is a metadata token indicating the desired class. If the class of the object on the top of the stack implements `class` (if `class` is an interface) or is a derived class of `class` (if `class` is a regular class) then it is cast to type `class` and the result is pushed on the stack, exactly as though had been called. Otherwise, a null reference is pushed on the stack. If the object reference itself is a null reference, then `isinst` likewise returns a null reference. + + is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. + + The following method overload can use the `isinst` opcode: + +- + ]]> @@ -6302,27 +6301,27 @@ Exits current method and jumps to specified method. - |jmp `method`|Exit current method and jump to specified method.| - - There are no stack transition behaviors for this instruction. - - The `jmp` (jump) instruction transfers control to the method specified by `method`, which is a metadata token for a method reference. The current arguments are transferred to the destination method. - - The evaluation stack must be empty when this instruction is executed. The calling convention, number and type of arguments at the destination address must match that of the current method. - - The `jmp` instruction cannot be used to transferred control out of a `try`, `filter`, `catch`, or `finally` block. - - The following method overload can use the `jmp` opcode: - -- - + |jmp `method`|Exit current method and jump to specified method.| + + There are no stack transition behaviors for this instruction. + + The `jmp` (jump) instruction transfers control to the method specified by `method`, which is a metadata token for a method reference. The current arguments are transferred to the destination method. + + The evaluation stack must be empty when this instruction is executed. The calling convention, number and type of arguments at the destination address must match that of the current method. + + The `jmp` instruction cannot be used to transferred control out of a `try`, `filter`, `catch`, or `finally` block. + + The following method overload can use the `jmp` opcode: + +- + ]]> @@ -6366,29 +6365,29 @@ Loads an argument (referenced by a specified index value) onto the stack. - |ldarg `index`|Load argument at `index` onto stack.| - - The stack transitional behavior, in sequential order, is: - -1. The argument value at `index` is pushed onto the stack. - - The `ldarg` instruction pushes the argument indexed at `index`, where arguments are indexed from 0 onwards, onto the evaluation stack. The `ldarg` instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature. - - For procedures that take a variable-length argument list, the `ldarg` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the instruction for more details). - - Arguments that hold an integer value smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldarg` opcode: - -- - + |ldarg `index`|Load argument at `index` onto stack.| + + The stack transitional behavior, in sequential order, is: + +1. The argument value at `index` is pushed onto the stack. + + The `ldarg` instruction pushes the argument indexed at `index`, where arguments are indexed from 0 onwards, onto the evaluation stack. The `ldarg` instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature. + + For procedures that take a variable-length argument list, the `ldarg` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the instruction for more details). + + Arguments that hold an integer value smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldarg` opcode: + +- + ]]> @@ -6432,29 +6431,29 @@ Loads the argument at index 0 onto the evaluation stack. - method overload can use the `ldarg.0` opcode: - -- - + method overload can use the `ldarg.0` opcode: + +- + ]]> @@ -6498,29 +6497,29 @@ Loads the argument at index 1 onto the evaluation stack. - method overload can use the `ldarg.1` opcode: - -- - + method overload can use the `ldarg.1` opcode: + +- + ]]> @@ -6564,29 +6563,29 @@ Loads the argument at index 2 onto the evaluation stack. - method overload can use the `ldarg.2` opcode: - -- - + method overload can use the `ldarg.2` opcode: + +- + ]]> @@ -6630,29 +6629,29 @@ Loads the argument at index 3 onto the evaluation stack. - method overload can use the `ldarg.3` opcode: - -- - + method overload can use the `ldarg.3` opcode: + +- + ]]> @@ -6696,31 +6695,31 @@ Loads the argument (referenced by a specified short form index) onto the evaluation stack. - |ldarg.s `index`|Load argument at `index` onto stack, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The argument value at `index` is pushed onto the stack. - - The `ldarg.s` instruction is an efficient encoding for loading arguments indexed from 4 through 255. - - The `ldarg.s` instruction pushes the argument indexed at `index`, where arguments are indexed from 0 onwards, onto the evaluation stack. The `ldarg.s` instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature. - - For procedures that take a variable-length argument list, the `ldarg.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the instruction for more details). - - Arguments that hold an integer value smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldarg.s` opcode: - -- - + |ldarg.s `index`|Load argument at `index` onto stack, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The argument value at `index` is pushed onto the stack. + + The `ldarg.s` instruction is an efficient encoding for loading arguments indexed from 4 through 255. + + The `ldarg.s` instruction pushes the argument indexed at `index`, where arguments are indexed from 0 onwards, onto the evaluation stack. The `ldarg.s` instruction can be used to load a value type or a primitive value onto the stack by copying it from an incoming argument. The type of the argument value is the same as the type of the argument, as specified by the current method's signature. + + For procedures that take a variable-length argument list, the `ldarg.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature (see the instruction for more details). + + Arguments that hold an integer value smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldarg.s` opcode: + +- + ]]> @@ -6764,29 +6763,29 @@ Load an argument address onto the evaluation stack. - |ldarga `index`|Fetch the address of argument indexed by `index`.| - - The stack transitional behavior, in sequential order, is: - -1. The address `addr` of the argument indexed by `index` is pushed onto the stack. - + |ldarga `index`|Fetch the address of argument indexed by `index`.| + + The stack transitional behavior, in sequential order, is: + +1. The address `addr` of the argument indexed by `index` is pushed onto the stack. + The `ldarga` instruction fetches the address (of type `&`) of the argument indexed by `index`, where arguments are indexed from 0 onwards. The address `addr` is always aligned to a natural boundary on the target machine. The argument is stored in unmanaged memory, so the return value can be converted to an unmanaged pointer without pinning. - - For procedures that take a variable-length argument list, the `ldarga` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. - - `ldarga` is used for by-ref parameter passing. For other cases, and should be used. - - The following method overload can use the `ldarga` opcode: - -- - + + For procedures that take a variable-length argument list, the `ldarga` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. + + `ldarga` is used for by-ref parameter passing. For other cases, and should be used. + + The following method overload can use the `ldarga` opcode: + +- + ]]> @@ -6830,31 +6829,31 @@ Load an argument address, in short form, onto the evaluation stack. - |ldarga.s `index`|Fetch the address of argument indexed by `index`, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The address `addr` of the argument indexed by `index` is pushed onto the stack. - - `ldarga.s` (the short form of `ldarga`) should be used for argument numbers 0 through 255, and is a more efficient encoding. - - The `ldarga.s` instruction fetches the address (of type`*`) of the argument indexed by `index`, where arguments are indexed from 0 onwards. The address `addr` is always aligned to a natural boundary on the target machine. - - For procedures that take a variable-length argument list, the `ldarga.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. - - `ldarga.s` is used for by-ref parameter passing. For other cases, and should be used. - - The following method overload can use the `ldarga.s` opcode: - -- - + |ldarga.s `index`|Fetch the address of argument indexed by `index`, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The address `addr` of the argument indexed by `index` is pushed onto the stack. + + `ldarga.s` (the short form of `ldarga`) should be used for argument numbers 0 through 255, and is a more efficient encoding. + + The `ldarga.s` instruction fetches the address (of type`*`) of the argument indexed by `index`, where arguments are indexed from 0 onwards. The address `addr` is always aligned to a natural boundary on the target machine. + + For procedures that take a variable-length argument list, the `ldarga.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. + + `ldarga.s` is used for by-ref parameter passing. For other cases, and should be used. + + The following method overload can use the `ldarga.s` opcode: + +- + ]]> @@ -6898,31 +6897,31 @@ Pushes a supplied value of type onto the evaluation stack as an . - |ldc.i4 `num`|Pushes the value `num` onto the stack.| - - The stack transitional behavior, in sequential order, is: - -1. The value `num` is pushed onto the stack. - - Note that there are special short (and hence more efficient) encodings for the integers -128 through 127, and especially short encodings for -1 through 8. All short encodings push 4 byte integers on the stack. Longer encodings are used for 8 byte integers and 4 and 8 byte floating-point numbers, as well as 4-byte values that do not fit in the short forms. There are three ways to push an 8 byte integer constant onto the stack - - 1. Use the instruction for constants that must be expressed in more than 32 bits. - - 2. Use the instruction followed by a for constants that require 9 to 32 bits. - - 3. Use a short form instruction followed by a for constants that can be expressed in 8 or fewer bits. - - The following method overload can use the `ldc.i4` opcode: - -- - + |ldc.i4 `num`|Pushes the value `num` onto the stack.| + + The stack transitional behavior, in sequential order, is: + +1. The value `num` is pushed onto the stack. + + Note that there are special short (and hence more efficient) encodings for the integers -128 through 127, and especially short encodings for -1 through 8. All short encodings push 4 byte integers on the stack. Longer encodings are used for 8 byte integers and 4 and 8 byte floating-point numbers, as well as 4-byte values that do not fit in the short forms. There are three ways to push an 8 byte integer constant onto the stack + + 1. Use the instruction for constants that must be expressed in more than 32 bits. + + 2. Use the instruction followed by a for constants that require 9 to 32 bits. + + 3. Use a short form instruction followed by a for constants that can be expressed in 8 or fewer bits. + + The following method overload can use the `ldc.i4` opcode: + +- + ]]> @@ -6966,25 +6965,25 @@ Pushes the integer value of 0 onto the evaluation stack as an . - method overload can use the `ldc.i4.0` opcode: - -- - + method overload can use the `ldc.i4.0` opcode: + +- + ]]> @@ -7028,25 +7027,25 @@ Pushes the integer value of 1 onto the evaluation stack as an . - method overload can use the `ldc.i4.1` opcode: - -- - + method overload can use the `ldc.i4.1` opcode: + +- + ]]> @@ -7090,25 +7089,25 @@ Pushes the integer value of 2 onto the evaluation stack as an . - method overload can use the `ldc.i4.2` opcode: - -- - + method overload can use the `ldc.i4.2` opcode: + +- + ]]> @@ -7152,25 +7151,25 @@ Pushes the integer value of 3 onto the evaluation stack as an . - method overload can use the `ldc.i4.3` opcode: - -- - + method overload can use the `ldc.i4.3` opcode: + +- + ]]> @@ -7214,25 +7213,25 @@ Pushes the integer value of 4 onto the evaluation stack as an . - method overload can use the `ldc.i4.4` opcode: - -- - + method overload can use the `ldc.i4.4` opcode: + +- + ]]> @@ -7276,25 +7275,25 @@ Pushes the integer value of 5 onto the evaluation stack as an . - method overload can use the `ldc.i4.5` opcode: - -- - + method overload can use the `ldc.i4.5` opcode: + +- + ]]> @@ -7338,26 +7337,26 @@ Pushes the integer value of 6 onto the evaluation stack as an . - method overload can use the `ldc.i4.6` opcode: - -- - - ]]> + method overload can use the `ldc.i4.6` opcode: + +- + + ]]>
@@ -7400,25 +7399,25 @@ Pushes the integer value of 7 onto the evaluation stack as an . - method overload can use the `ldc.i4.7` opcode: - -- - + method overload can use the `ldc.i4.7` opcode: + +- + ]]> @@ -7462,25 +7461,25 @@ Pushes the integer value of 8 onto the evaluation stack as an . - method overload can use the `ldc.i4.8` opcode: - -- - + method overload can use the `ldc.i4.8` opcode: + +- + ]]> @@ -7524,25 +7523,25 @@ Pushes the integer value of -1 onto the evaluation stack as an . - method overload can use the `ldc.i4.m1` opcode: - -- - + method overload can use the `ldc.i4.m1` opcode: + +- + ]]> @@ -7586,26 +7585,26 @@ Pushes the supplied value onto the evaluation stack as an , short form. - |ldc.i4.s `num`|Pushes `num` onto the stack as `int32`, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The value `num` is pushed onto the stack. - - `ldc.i4.s` is a more efficient encoding for pushing the integers from -128 to 127 onto the evaluation stack. - + |ldc.i4.s `num`|Pushes `num` onto the stack as `int32`, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The value `num` is pushed onto the stack. + + `ldc.i4.s` is a more efficient encoding for pushing the integers from -128 to 127 onto the evaluation stack. + The following method overloads can use the `ldc.i4.s` opcode: - + - - - + ]]> @@ -7649,25 +7648,25 @@ The following method overloads Pushes a supplied value of type onto the evaluation stack as an . - |ldc.i8 `num`|Pushes `num` onto the stack as `int64`.| - - The stack transitional behavior, in sequential order, is: - -1. The value `num` is pushed onto the stack. - - This encoding pushes an `int64` value onto the stack. - - The following method overload can use the `ldc.i8` opcode: - -- - + |ldc.i8 `num`|Pushes `num` onto the stack as `int64`.| + + The stack transitional behavior, in sequential order, is: + +1. The value `num` is pushed onto the stack. + + This encoding pushes an `int64` value onto the stack. + + The following method overload can use the `ldc.i8` opcode: + +- + ]]> @@ -7711,25 +7710,25 @@ The following method overloads Pushes a supplied value of type onto the evaluation stack as type (float). - |ldc.r4 `num`|Pushes `num` onto the stack as `F`.| - - The stack transitional behavior, in sequential order, is: - -1. The value `num` is pushed onto the stack. - - This encoding pushes a `float32` value onto the stack. - - The following method overload can use the `ldc.r4` opcode: - -- - + |ldc.r4 `num`|Pushes `num` onto the stack as `F`.| + + The stack transitional behavior, in sequential order, is: + +1. The value `num` is pushed onto the stack. + + This encoding pushes a `float32` value onto the stack. + + The following method overload can use the `ldc.r4` opcode: + +- + ]]> @@ -7773,25 +7772,25 @@ The following method overloads Pushes a supplied value of type onto the evaluation stack as type (float). - |ldc.r8 `num`|Pushes `num` onto the stack as `F`.| - - The stack transitional behavior, in sequential order, is: - -1. The value `num` is pushed onto the stack. - - This encoding pushes a `float64` value onto the stack. - - The following method overload can use the `ldc.r8` opcode: - -- - + |ldc.r8 `num`|Pushes `num` onto the stack as `F`.| + + The stack transitional behavior, in sequential order, is: + +1. The value `num` is pushed onto the stack. + + This encoding pushes a `float64` value onto the stack. + + The following method overload can use the `ldc.r8` opcode: + +- + ]]> @@ -7834,37 +7833,37 @@ The following method overloads Loads the element at a specified array index onto the top of the evaluation stack as the type specified in the instruction. - |ldelem `typeTok`|Loads the element at `index` onto the top of the stack as type `typeTok`.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference `array` is pushed onto the stack. - -2. An index value `index` is pushed onto the stack. - -3. `index` and `array` are popped from the stack; the value stored at position `index` in `array` is looked up. - -4. The value is pushed onto the stack. - - The `ldelem` instruction loads the value of the element with index `index` (type `native int`) in the zero-based one-dimensional array `array` and places it on the top of the stack. Arrays are objects, and hence represented by a value of type `O`. - - The type of the return value is specified by the token `typeTok` in the instruction. - - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the upper bound of `array`. - - The following method overload can use the `ldelem` opcode: - -- - + |ldelem `typeTok`|Loads the element at `index` onto the top of the stack as type `typeTok`.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference `array` is pushed onto the stack. + +2. An index value `index` is pushed onto the stack. + +3. `index` and `array` are popped from the stack; the value stored at position `index` in `array` is looked up. + +4. The value is pushed onto the stack. + + The `ldelem` instruction loads the value of the element with index `index` (type `native int`) in the zero-based one-dimensional array `array` and places it on the top of the stack. Arrays are objects, and hence represented by a value of type `O`. + + The type of the return value is specified by the token `typeTok` in the instruction. + + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the upper bound of `array`. + + The following method overload can use the `ldelem` opcode: + +- + ]]> @@ -7908,41 +7907,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as a . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.i` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.i` opcode: + +- + ]]> @@ -7986,41 +7985,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.i1` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.i1` opcode: + +- + ]]> @@ -8064,41 +8063,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.i2` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.i2` opcode: + +- + ]]> @@ -8142,41 +8141,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.i4` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.i4` opcode: + +- + ]]> @@ -8220,41 +8219,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.i8` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.i8` opcode: + +- + ]]> @@ -8298,41 +8297,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as type (float). - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.r4` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.r4` opcode: + +- + ]]> @@ -8376,41 +8375,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as type (float). - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.r8` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.r8` opcode: + +- + ]]> @@ -8454,39 +8453,39 @@ The following method overloads Loads the element containing an object reference at a specified array index onto the top of the evaluation stack as type (object reference). - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.ref` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.ref` opcode: + +- + ]]> @@ -8530,41 +8529,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.u1` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.u1` opcode: + +- + ]]> @@ -8608,41 +8607,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.u2` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.u2` opcode: + +- + ]]> @@ -8686,41 +8685,41 @@ The following method overloads Loads the element with type at a specified array index onto the top of the evaluation stack as an . - is thrown if `array` is a null reference. - - is thrown if array does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelem.u4` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if array does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelem.u4` opcode: + +- + ]]> @@ -8764,41 +8763,41 @@ The following method overloads Loads the address of the array element at a specified array index onto the top of the evaluation stack as type (managed pointer). - |ldelema `class`|Loads the address of the array element at `index` onto the top of the evaluation stack as type `&` (managed pointer).| - - The stack transitional behavior, in sequential order, is: - -1. An object reference `array` is pushed onto the stack. - -2. An index value `index` is pushed onto the stack. - -3. `index` and `array` are popped from the stack; the address stored at position `index` in `array` is looked up. - -4. The address is pushed onto the stack. - - The `ldelema` is used to retrieve the address of an object at a particular index in an array of objects (of type `class`). The `ldelema` instruction loads the address of the value at index `index` (type `native int`) in the zero-based one-dimensional array `array` and places it on the top of the stack. Arrays are objects and hence represented by a value of type `O`. The value must be of type `class` passed with the instruction. - - The return value for `ldelema` is a managed pointer (type `&`). - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. - - is thrown if `array` is a null reference. - - is thrown if `array` does not hold elements of the required type. - - is thrown if `index` is negative, or larger than the bound of `array`. - - The following method overload can use the `ldelema` opcode: - -- - + |ldelema `class`|Loads the address of the array element at `index` onto the top of the evaluation stack as type `&` (managed pointer).| + + The stack transitional behavior, in sequential order, is: + +1. An object reference `array` is pushed onto the stack. + +2. An index value `index` is pushed onto the stack. + +3. `index` and `array` are popped from the stack; the address stored at position `index` in `array` is looked up. + +4. The address is pushed onto the stack. + + The `ldelema` is used to retrieve the address of an object at a particular index in an array of objects (of type `class`). The `ldelema` instruction loads the address of the value at index `index` (type `native int`) in the zero-based one-dimensional array `array` and places it on the top of the stack. Arrays are objects and hence represented by a value of type `O`. The value must be of type `class` passed with the instruction. + + The return value for `ldelema` is a managed pointer (type `&`). + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. + + is thrown if `array` is a null reference. + + is thrown if `array` does not hold elements of the required type. + + is thrown if `index` is negative, or larger than the bound of `array`. + + The following method overload can use the `ldelema` opcode: + +- + ]]> @@ -8842,35 +8841,35 @@ The following method overloads Finds the value of a field in the object whose reference is currently on the evaluation stack. - |ldfld `field`|Pushes the value of a field in a specified object onto the stack.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference (or pointer) is pushed onto the stack. - -2. The object reference (or pointer) is popped from the stack; the value of the specified field in the object is found. - -3. The value stored in the field is pushed onto the stack. - - The `ldfld` instruction pushes the value of a field located in an object onto the stack. The object must be on the stack as an object reference (type `O`), a managed pointer (type `&`), an unmanaged pointer (type `native int`), a transient pointer (type `*`), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member. The return type is the same as the one associated with the field. The field may be either an instance field (in which case the object must not be a null reference) or a static field. - - The `ldfld` instruction can be preceded by either or both of the and prefixes. - - is thrown if the object is null and the field is not static. - - is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. - - The following method overload can use the `ldfld` opcode: - -- - + |ldfld `field`|Pushes the value of a field in a specified object onto the stack.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference (or pointer) is pushed onto the stack. + +2. The object reference (or pointer) is popped from the stack; the value of the specified field in the object is found. + +3. The value stored in the field is pushed onto the stack. + + The `ldfld` instruction pushes the value of a field located in an object onto the stack. The object must be on the stack as an object reference (type `O`), a managed pointer (type `&`), an unmanaged pointer (type `native int`), a transient pointer (type `*`), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member. The return type is the same as the one associated with the field. The field may be either an instance field (in which case the object must not be a null reference) or a static field. + + The `ldfld` instruction can be preceded by either or both of the and prefixes. + + is thrown if the object is null and the field is not static. + + is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. + + The following method overload can use the `ldfld` opcode: + +- + ]]> @@ -8914,39 +8913,39 @@ The following method overloads Finds the address of a field in the object whose reference is currently on the evaluation stack. - |ldflda `field`|Pushes the address of `field` in a specified object onto the stack.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference (or pointer) is pushed onto the stack. - -2. The object reference (or pointer) is popped from the stack; the address of the specified field in the object is found. - -3. The address of the specified field is pushed onto the stack. - - The `ldflda` instruction pushes the address of a field located in an object onto the stack. The object must be on the stack as an object reference (type `O`), a managed pointer (type `&`), an unmanaged pointer (type `native int`), a transient pointer (type `*`), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member. - - The value returned by `ldflda` is a managed pointer (type `&`) unless the object is pushed onto the stack as an unmanaged pointer, in which case the return address is also an unmanaged pointer (type `native int`). - - The `ldflda` instruction can be preceded by either or both of the and prefixes. - - is thrown if the object is not within the application domain from which it is being accessed. The address of a field that is not inside the accessing application domain cannot be loaded. - - is thrown if the object is null and the field is not static. - - is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. - - The following method overload can use the `ldflda` opcode: - -- - + |ldflda `field`|Pushes the address of `field` in a specified object onto the stack.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference (or pointer) is pushed onto the stack. + +2. The object reference (or pointer) is popped from the stack; the address of the specified field in the object is found. + +3. The address of the specified field is pushed onto the stack. + + The `ldflda` instruction pushes the address of a field located in an object onto the stack. The object must be on the stack as an object reference (type `O`), a managed pointer (type `&`), an unmanaged pointer (type `native int`), a transient pointer (type `*`), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member. + + The value returned by `ldflda` is a managed pointer (type `&`) unless the object is pushed onto the stack as an unmanaged pointer, in which case the return address is also an unmanaged pointer (type `native int`). + + The `ldflda` instruction can be preceded by either or both of the and prefixes. + + is thrown if the object is not within the application domain from which it is being accessed. The address of a field that is not inside the accessing application domain cannot be loaded. + + is thrown if the object is null and the field is not static. + + is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. + + The following method overload can use the `ldflda` opcode: + +- + ]]> @@ -8990,27 +8989,27 @@ The following method overloads Pushes an unmanaged pointer (type ) to the native code implementing a specific method onto the evaluation stack. - |ldftn `method`|Pushes a pointer to a method referenced by `method` on the stack.| - - The stack transitional behavior, in sequential order, is: - -1. The unmanaged pointer to a specific method is pushed onto the stack. - - The specific method (`method`) can be called using the instruction if it references a managed method (or a stub that transitions from managed to unmanaged code). - - The value returned points to native code using the CLR calling convention. This method pointer should not be passed to unmanaged native code as a callback routine. - - The following method overload can use the `ldftn` opcode: - -- - + |ldftn `method`|Pushes a pointer to a method referenced by `method` on the stack.| + + The stack transitional behavior, in sequential order, is: + +1. The unmanaged pointer to a specific method is pushed onto the stack. + + The specific method (`method`) can be called using the instruction if it references a managed method (or a stub that transitions from managed to unmanaged code). + + The value returned points to native code using the CLR calling convention. This method pointer should not be passed to unmanaged native code as a callback routine. + + The following method overload can use the `ldftn` opcode: + +- + ]]> @@ -9054,39 +9053,39 @@ The following method overloads Loads a value of type as a onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.i` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.i` opcode: + +- + ]]> @@ -9130,39 +9129,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.i1` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.i1` opcode: + +- + ]]> @@ -9206,39 +9205,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.i2` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.i2` opcode: + +- + ]]> @@ -9282,39 +9281,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.i4` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.i4` opcode: + +- + ]]> @@ -9358,39 +9357,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.i8` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.i8` opcode: + +- + ]]> @@ -9434,39 +9433,39 @@ The following method overloads Loads a value of type as a type (float) onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.r4` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.r4` opcode: + +- + ]]> @@ -9510,39 +9509,39 @@ The following method overloads Loads a value of type as a type (float) onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.r8` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.r8` opcode: + +- + ]]> @@ -9586,39 +9585,39 @@ The following method overloads Loads an object reference as a type (object reference) onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.ref` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.ref` opcode: + +- + ]]> @@ -9662,39 +9661,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.u1` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.u1` opcode: + +- + ]]> @@ -9738,39 +9737,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.u2` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.u2` opcode: + +- + ]]> @@ -9814,39 +9813,39 @@ The following method overloads Loads a value of type as an onto the evaluation stack indirectly. - instruction that specifies the corresponding built-in value class. - - Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. - - Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. - - The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. - - can be thrown if an invalid address is detected. - - The following method overload can use the `ldind.u4` opcode: - -- - + instruction that specifies the corresponding built-in value class. + + Note that integer values of less than 4 bytes are extended to `int32` (not `native int`) when they are loaded onto the evaluation stack. Floating-point values are converted to `F` type when loaded onto the evaluation stack. + + Correctly-formed Microsoft Intermediate Language (MSIL) ensures that the `ldind` instructions are used in a manner consistent with the type of the pointer. + + The address initially pushed onto the stack must be aligned to the natural size of objects on the machine or a can occur (see the prefix instruction for preventative measures). The results of all MSIL instructions that return addresses (for example, and ) are safely aligned. For datatypes larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering might not run on all platforms. + + can be thrown if an invalid address is detected. + + The following method overload can use the `ldind.u4` opcode: + +- + ]]> @@ -9890,31 +9889,31 @@ The following method overloads Pushes the number of elements of a zero-based, one-dimensional array onto the evaluation stack. - is thrown if the array reference is a null reference. - - The following method overload can use the `ldlen` opcode: - -- - + is thrown if the array reference is a null reference. + + The following method overload can use the `ldlen` opcode: + +- + ]]> @@ -9958,31 +9957,31 @@ The following method overloads Loads the local variable at a specific index onto the evaluation stack. - |ldloc `index`|Loads the local variable at index `index` onto stack.| - - The stack transitional behavior, in sequential order, is: - -1. The local variable value at the specified index is pushed onto the stack. - - The `ldloc` instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method only if the initialize flag on the method is true. There are 65,535 (2^16-1) local variables possible (0-65,534). Index 65,535 is not valid since likely implementations will use a 2-byte integer to track both a local's index, along with the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method. - - The `ldloc.0`, `ldloc.1`, `ldloc.2`, and `ldloc.3` instructions provide an efficient encoding for accessing the first four local variables. - - The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overloads can use the `ldloc` opcode: - -- - -- - + |ldloc `index`|Loads the local variable at index `index` onto stack.| + + The stack transitional behavior, in sequential order, is: + +1. The local variable value at the specified index is pushed onto the stack. + + The `ldloc` instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method only if the initialize flag on the method is true. There are 65,535 (2^16-1) local variables possible (0-65,534). Index 65,535 is not valid since likely implementations will use a 2-byte integer to track both a local's index, along with the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method. + + The `ldloc.0`, `ldloc.1`, `ldloc.2`, and `ldloc.3` instructions provide an efficient encoding for accessing the first four local variables. + + The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overloads can use the `ldloc` opcode: + +- + +- + ]]> @@ -10026,27 +10025,27 @@ The following method overloads Loads the local variable at index 0 onto the evaluation stack. - , allowing access to the local variable at index 0. - - The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldloc.0` opcode: - -- - + , allowing access to the local variable at index 0. + + The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldloc.0` opcode: + +- + ]]> @@ -10090,27 +10089,27 @@ The following method overloads Loads the local variable at index 1 onto the evaluation stack. - , allowing access to the local variable at index 1. - - The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldloc.1` opcode: - -- - + , allowing access to the local variable at index 1. + + The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldloc.1` opcode: + +- + ]]> @@ -10154,27 +10153,27 @@ The following method overloads Loads the local variable at index 2 onto the evaluation stack. - , allowing access to the local variable at index 2. - - The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldloc.2` opcode: - -- - + , allowing access to the local variable at index 2. + + The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldloc.2` opcode: + +- + ]]> @@ -10218,27 +10217,27 @@ The following method overloads Loads the local variable at index 3 onto the evaluation stack. - , allowing access to the local variable at index 3. - - The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overload can use the `ldloc.3` opcode: - -- - + , allowing access to the local variable at index 3. + + The type of the value is the same as the type of the local variable, which is specified in the method header. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overload can use the `ldloc.3` opcode: + +- + ]]> @@ -10282,29 +10281,29 @@ The following method overloads Loads the local variable at a specific index onto the evaluation stack, short form. - |ldloc.s `index`|Loads the local variable at index `index` onto stack, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The local variable value at the specified index is pushed onto the stack. - - The `ldloc.s` instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method if the initialize flag on the method is true. There are 256 (2^8) local variables possible (0-255) in the short form, which is a more efficient encoding than `ldloc`. - - The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). - - The following method overloads can use the `ldloc.s` opcode: - -- - -- - + |ldloc.s `index`|Loads the local variable at index `index` onto stack, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The local variable value at the specified index is pushed onto the stack. + + The `ldloc.s` instruction pushes the contents of the local variable number at the passed index onto the evaluation stack, where the local variables are numbered 0 onwards. Local variables are initialized to 0 before entering the method if the initialize flag on the method is true. There are 256 (2^8) local variables possible (0-255) in the short form, which is a more efficient encoding than `ldloc`. + + The type of the value is the same as the type of the local variable, which is specified in the method header. See Partition I. Local variables that are smaller than 4 bytes long are expanded to type `int32` when they are loaded onto the stack. Floating-point values are expanded to their native size (type `F`). + + The following method overloads can use the `ldloc.s` opcode: + +- + +- + ]]> @@ -10348,25 +10347,25 @@ The following method overloads Loads the address of the local variable at a specific index onto the evaluation stack. - |ldloca `index`|Loads the address of the local variable at `index` onto the evaluation stack.| - - The stack transitional behavior, in sequential order, is: - -1. The address stored in the local variable at the specified index is pushed onto the stack. - + |ldloca `index`|Loads the address of the local variable at `index` onto the evaluation stack.| + + The stack transitional behavior, in sequential order, is: + +1. The address stored in the local variable at the specified index is pushed onto the stack. + The `ldloca` instruction pushes the address of the local variable number at the passed index onto the stack, where local variables are numbered 0 onwards. The value pushed on the stack is already aligned correctly for use with instructions like and . The result is a managed pointer (type `&`). The local variable is stored in unmanaged memory, so the return value can be converted to an unmanaged pointer without pinning. - - The following method overload can use the `ldloca` opcode: - -- - + + The following method overload can use the `ldloca` opcode: + +- + ]]> @@ -10410,27 +10409,27 @@ The following method overloads Loads the address of the local variable at a specific index onto the evaluation stack, short form. - |ldloca.s `index`|Loads the address of the local variable at `index` onto the evaluation stack, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The address stored in the local variable at the specified index is pushed onto the stack. - - The `ldloca.s` instruction pushes the address of the local variable number at the passed index onto the stack, where local variables are numbered 0 onwards. The value pushed on the stack is already aligned correctly for use with instructions like and . The result is a transient pointer (type `*`). - - The `ldloca.s` instruction provides an efficient encoding for use with the local variables 0 through 255. - - The following method overload can use the `ldloca.s` opcode: - -- - + |ldloca.s `index`|Loads the address of the local variable at `index` onto the evaluation stack, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The address stored in the local variable at the specified index is pushed onto the stack. + + The `ldloca.s` instruction pushes the address of the local variable number at the passed index onto the stack, where local variables are numbered 0 onwards. The value pushed on the stack is already aligned correctly for use with instructions like and . The result is a transient pointer (type `*`). + + The `ldloca.s` instruction provides an efficient encoding for use with the local variables 0 through 255. + + The following method overload can use the `ldloca.s` opcode: + +- + ]]> @@ -10474,27 +10473,27 @@ The following method overloads Pushes a null reference (type ) onto the evaluation stack. - method overload can use the `ldnull` opcode: - -- - + method overload can use the `ldnull` opcode: + +- + ]]> @@ -10538,35 +10537,35 @@ The following method overloads Copies the value type object pointed to by an address to the top of the evaluation stack. - |ldobj `class`|Copy instance of value type `class` to the stack.| - - The stack transitional behavior, in sequential order, is: - -1. The address of a value type object is pushed onto the stack. - -2. The address is popped from the stack and the instance at that particular address is looked up. - -3. The value of the object stored at that address is pushed onto the stack. - - The `ldobj` instruction is used to pass a value type as a parameter. - - The `ldobj` instruction copies the value pointed to by `addrOfValObj` (of type `&`, `*`, or `native int`) to the top of the stack. The number of bytes copied depends on the size of the class (as specified by the `class` parameter). The `class` parameter is a metadata token representing the value type. - - The operation of the `ldobj` instruction can be altered by an immediately preceding or prefix instruction. - - is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime. - - The following method overload can use the `ldobj` opcode: - -- - + |ldobj `class`|Copy instance of value type `class` to the stack.| + + The stack transitional behavior, in sequential order, is: + +1. The address of a value type object is pushed onto the stack. + +2. The address is popped from the stack and the instance at that particular address is looked up. + +3. The value of the object stored at that address is pushed onto the stack. + + The `ldobj` instruction is used to pass a value type as a parameter. + + The `ldobj` instruction copies the value pointed to by `addrOfValObj` (of type `&`, `*`, or `native int`) to the top of the stack. The number of bytes copied depends on the size of the class (as specified by the `class` parameter). The `class` parameter is a metadata token representing the value type. + + The operation of the `ldobj` instruction can be altered by an immediately preceding or prefix instruction. + + is thrown if class cannot be found. This is typically detected when the Microsoft Intermediate Language (MSIL) instruction is converted to native code rather than at runtime. + + The following method overload can use the `ldobj` opcode: + +- + ]]> @@ -10610,27 +10609,27 @@ The following method overloads Pushes the value of a static field onto the evaluation stack. - |ldsfld `field`|Push the value of `field` on the stack.| - - The stack transitional behavior, in sequential order, is: - -1. The value of the specific field is pushed onto the stack. - - The `ldsfld` instruction pushes the value of a static (shared among all instances of a class) field on the stack. The return type is that associated with the passed metadata token `field`. - - The `ldsfld` instruction can have a prefix. - - The following method overload can use the `ldsfld` opcode: - -- - + |ldsfld `field`|Push the value of `field` on the stack.| + + The stack transitional behavior, in sequential order, is: + +1. The value of the specific field is pushed onto the stack. + + The `ldsfld` instruction pushes the value of a static (shared among all instances of a class) field on the stack. The return type is that associated with the passed metadata token `field`. + + The `ldsfld` instruction can have a prefix. + + The following method overload can use the `ldsfld` opcode: + +- + ]]> @@ -10674,29 +10673,29 @@ The following method overloads Pushes the address of a static field onto the evaluation stack. - |ldsflda `field`|Push the address of `field` on the stack| - - The stack transitional behavior, in sequential order, is: - -1. The address of a specific field is pushed onto the stack. - - The `ldsflda` instruction pushes the address of a static (shared among all instances of a class) field on the stack. The address may be represented as a transient pointer (type `*`) if the metadata token `field` refers to a type whose memory is managed. Otherwise, it corresponds to an unmanaged pointer (type `native int`). Note that `field` may be a static global with an assigned relative virtual address (the offset of the field from the base address at which its containing PE file is loaded into memory) where the memory is unmanaged. - - The `ldsflda` instruction can have a prefix. - - is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at runtime. - - The following method overload can use the `ldsflda` opcode: - -- - + |ldsflda `field`|Push the address of `field` on the stack| + + The stack transitional behavior, in sequential order, is: + +1. The address of a specific field is pushed onto the stack. + + The `ldsflda` instruction pushes the address of a static (shared among all instances of a class) field on the stack. The address may be represented as a transient pointer (type `*`) if the metadata token `field` refers to a type whose memory is managed. Otherwise, it corresponds to an unmanaged pointer (type `native int`). Note that `field` may be a static global with an assigned relative virtual address (the offset of the field from the base address at which its containing PE file is loaded into memory) where the memory is unmanaged. + + The `ldsflda` instruction can have a prefix. + + is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at runtime. + + The following method overload can use the `ldsflda` opcode: + +- + ]]> @@ -10740,27 +10739,27 @@ The following method overloads Pushes a new object reference to a string literal stored in the metadata. - |ldstr `mdToken`|Pushes a string object for the metadata string token `mdToken`.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference to a string is pushed onto the stack. - - The `ldstr` instruction pushes an object reference (type `O`) to a new string object representing the specific string literal stored in the metadata. The `ldstr` instruction allocates the requisite amount of memory and performs any format conversion required to convert the string literal from the form used in the file to the string format required at runtime. - - The Common Language Infrastructure (CLI) guarantees that the result of two `ldstr` instructions referring to two metadata tokens that have the same sequence of characters return precisely the same string object (a process known as "string interning"). - - The following method overload can use the `ldstr` opcode: - -- - + |ldstr `mdToken`|Pushes a string object for the metadata string token `mdToken`.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference to a string is pushed onto the stack. + + The `ldstr` instruction pushes an object reference (type `O`) to a new string object representing the specific string literal stored in the metadata. The `ldstr` instruction allocates the requisite amount of memory and performs any format conversion required to convert the string literal from the form used in the file to the string format required at runtime. + + The Common Language Infrastructure (CLI) guarantees that the result of two `ldstr` instructions referring to two metadata tokens that have the same sequence of characters return precisely the same string object (a process known as "string interning"). + + The following method overload can use the `ldstr` opcode: + +- + ]]> @@ -10804,33 +10803,33 @@ The following method overloads Converts a metadata token to its runtime representation, pushing it onto the evaluation stack. - |ldtoken `token`|Converts a metadata token to its runtime representation.| - - The stack transitional behavior, in sequential order, is: - -1. The passed token is converted to a `RuntimeHandle` and pushed onto the stack. - - The `ldtoken` instruction pushes a `RuntimeHandle` for the specified metadata token. A `RuntimeHandle` can be a `fieldref/fielddef`, a `methodref/methoddef`, or a `typeref/typedef`. - - The value pushed on the stack can be used in calls to `Reflection` methods in the system class library. - - For information on runtime handles, see the following classes: , , and . - - The following method overloads can use the `ldtoken` opcode: - -- - -- - -- - + |ldtoken `token`|Converts a metadata token to its runtime representation.| + + The stack transitional behavior, in sequential order, is: + +1. The passed token is converted to a `RuntimeHandle` and pushed onto the stack. + + The `ldtoken` instruction pushes a `RuntimeHandle` for the specified metadata token. A `RuntimeHandle` can be a `fieldref/fielddef`, a `methodref/methoddef`, or a `typeref/typedef`. + + The value pushed on the stack can be used in calls to `Reflection` methods in the system class library. + + For information on runtime handles, see the following classes: , , and . + + The following method overloads can use the `ldtoken` opcode: + +- + +- + +- + ]]> @@ -10874,31 +10873,31 @@ The following method overloads Pushes an unmanaged pointer (type ) to the native code implementing a particular virtual method associated with a specified object onto the evaluation stack. - |ldvirtftn `method`|Pushes the pointer to an object's virtual method `method` on the stack.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference is pushed onto the stack. - -2. The object reference is popped from the stack and the address of the entry point to the method (as specified by the metadata token `method`) is looked up. - -3. The pointer to `method` is pushed onto the stack. - - The resulting unmanaged pointer pushed onto the stack by the `ldvirtftn` instruction can be called using the instruction if it references a managed method (or a stub that transitions from managed to unmanaged code). - - The unmanaged pointer points to native code using the CLR calling convention. This method pointer should not be passed to unmanaged native code as a callback routine. - - The following method overload can use the `ldvirtftn` opcode: - -- - + |ldvirtftn `method`|Pushes the pointer to an object's virtual method `method` on the stack.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference is pushed onto the stack. + +2. The object reference is popped from the stack and the address of the entry point to the method (as specified by the metadata token `method`) is looked up. + +3. The pointer to `method` is pushed onto the stack. + + The resulting unmanaged pointer pushed onto the stack by the `ldvirtftn` instruction can be called using the instruction if it references a managed method (or a stub that transitions from managed to unmanaged code). + + The unmanaged pointer points to native code using the CLR calling convention. This method pointer should not be passed to unmanaged native code as a callback routine. + + The following method overload can use the `ldvirtftn` opcode: + +- + ]]> @@ -10942,29 +10941,29 @@ The following method overloads Exits a protected region of code, unconditionally transferring control to a specific target instruction. - |leave `target`|Exits a protected region of code.| - - There is no stack transition behavior specified for this instruction. - - The `leave` instruction unconditionally transfers control to the specific target instruction, represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. - - The `leave` instruction is similar to the `br` instruction, but it can be used to exit a `try`, `filter`, or `catch` block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The `leave` instruction empties the evaluation stack and ensures that the appropriate surrounding `finally` blocks are executed. - - You cannot use a `leave` instruction to exit a `finally` block. To ease code generation for exception handlers it is valid from within a catch block to use a `leave` instruction to transfer control to any instruction within the associated `try` block. - - If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. - - The following method overloads can use the `leave` opcode: - -- - + |leave `target`|Exits a protected region of code.| + + There is no stack transition behavior specified for this instruction. + + The `leave` instruction unconditionally transfers control to the specific target instruction, represented as a 4-byte signed offset from the beginning of the instruction following the current instruction. + + The `leave` instruction is similar to the `br` instruction, but it can be used to exit a `try`, `filter`, or `catch` block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The `leave` instruction empties the evaluation stack and ensures that the appropriate surrounding `finally` blocks are executed. + + You cannot use a `leave` instruction to exit a `finally` block. To ease code generation for exception handlers it is valid from within a catch block to use a `leave` instruction to transfer control to any instruction within the associated `try` block. + + If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. + + The following method overloads can use the `leave` opcode: + +- + ]]> @@ -11008,29 +11007,29 @@ The following method overloads Exits a protected region of code, unconditionally transferring control to a target instruction (short form). - |leave.s `target`|Exit a protected region of code, short form.| - - There is no stack transition behavior specified for this instruction. - - The `leave.s` instruction unconditionally transfers control to the passed target instruction, represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. - - The `leave.s` instruction is similar to the `br` instruction, but it can be used to exit a `try`, `filter`, or `catch` block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The `leave.s` instruction empties the evaluation stack and ensures that the appropriate surrounding `finally` blocks are executed. - - You cannot use a `leave.s` instruction to exit a `finally` block. To ease code generation for exception handlers it is valid from within a catch block to use a `leave.s` instruction to transfer control to any instruction within the associated `try` block. - - If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. - - The following method overload can use the `leave.s` opcode: - -- - + |leave.s `target`|Exit a protected region of code, short form.| + + There is no stack transition behavior specified for this instruction. + + The `leave.s` instruction unconditionally transfers control to the passed target instruction, represented as a 1-byte signed offset from the beginning of the instruction following the current instruction. + + The `leave.s` instruction is similar to the `br` instruction, but it can be used to exit a `try`, `filter`, or `catch` block whereas the ordinary branch instructions can only be used in such a block to transfer control within it. The `leave.s` instruction empties the evaluation stack and ensures that the appropriate surrounding `finally` blocks are executed. + + You cannot use a `leave.s` instruction to exit a `finally` block. To ease code generation for exception handlers it is valid from within a catch block to use a `leave.s` instruction to transfer control to any instruction within the associated `try` block. + + If an instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. + + The following method overload can use the `leave.s` opcode: + +- + ]]> @@ -11074,35 +11073,35 @@ The following method overloads Allocates a certain number of bytes from the local dynamic memory pool and pushes the address (a transient pointer, type ) of the first allocated byte onto the evaluation stack. - , the local memory pool is made available for reuse. - - The resulting address is aligned so that any primitive data type can be stored there using the `stind` instructions (such as ) and loaded using the `ldind` instructions (such as ). - - The `localloc` instruction cannot occur within a `filter`, `catch`, `finally`, or `fault` block. - - is thrown if there is insufficient memory to service the request. - - The following method overload can use the `localloc` opcode: - -- - + , the local memory pool is made available for reuse. + + The resulting address is aligned so that any primitive data type can be stored there using the `stind` instructions (such as ) and loaded using the `ldind` instructions (such as ). + + The `localloc` instruction cannot occur within a `filter`, `catch`, `finally`, or `fault` block. + + is thrown if there is insufficient memory to service the request. + + The following method overload can use the `localloc` opcode: + +- + ]]> @@ -11146,33 +11145,33 @@ The following method overloads Pushes a typed reference to an instance of a specific type onto the evaluation stack. - |mkrefany `class`|Pushes a typed reference of type `class` onto the stack.| - - The stack transitional behavior, in sequential order, is: - -1. A pointer to piece of data is pushed onto the stack. - -2. The pointer is popped and converted to a typed reference of type `class`. - -3. The typed reference is pushed onto the stack. - - The `mkrefany` instruction supports the passing of dynamically typed references. The pointer must be of type `&`, `*`, or `native int`, and hold the valid address of a piece of data. `Class` is the class token describing the type of the data referenced by the pointer. `Mkrefany` pushes a typed reference on the stack, providing an opaque descriptor of the pointer and the type `class`. - - The only valid operation permitted upon a typed reference is to pass it to a method that requires a typed reference as a parameter. The callee can then use the and instructions to retrieve the type (class) and the address respectively. - - is thrown if `class` cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. - - The following method overload can use the `mkrefany` opcode: - -- - + |mkrefany `class`|Pushes a typed reference of type `class` onto the stack.| + + The stack transitional behavior, in sequential order, is: + +1. A pointer to piece of data is pushed onto the stack. + +2. The pointer is popped and converted to a typed reference of type `class`. + +3. The typed reference is pushed onto the stack. + + The `mkrefany` instruction supports the passing of dynamically typed references. The pointer must be of type `&`, `*`, or `native int`, and hold the valid address of a piece of data. `Class` is the class token describing the type of the data referenced by the pointer. `Mkrefany` pushes a typed reference on the stack, providing an opaque descriptor of the pointer and the type `class`. + + The only valid operation permitted upon a typed reference is to pass it to a method that requires a typed reference as a parameter. The callee can then use the and instructions to retrieve the type (class) and the address respectively. + + is thrown if `class` cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at runtime. + + The following method overload can use the `mkrefany` opcode: + +- + ]]> @@ -11216,35 +11215,35 @@ The following method overloads Multiplies two values and pushes the result on the evaluation stack. - for an integer-specific multiply operation with overflow handling. - - For floating-point types, 0 * infinity = NaN. - - The following method overload can use the `mul` opcode: - -- - + for an integer-specific multiply operation with overflow handling. + + For floating-point types, 0 * infinity = NaN. + + The following method overload can use the `mul` opcode: + +- + ]]> @@ -11288,33 +11287,33 @@ The following method overloads Multiplies two integer values, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `mul.ovf` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `mul.ovf` opcode: + +- + ]]> @@ -11358,33 +11357,33 @@ The following method overloads Multiplies two unsigned integer values, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result can not be represented in the result type. - - The following method overload can use the `mul.ovf.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + The following method overload can use the `mul.ovf.un` opcode: + +- + ]]> @@ -11428,33 +11427,33 @@ The following method overloads Negates a value and pushes the result onto the evaluation stack. - instruction instead (that is, subtract from 0). - - Negating a floating-point number cannot overflow, and negating NaN returns NaN. - - The following method overload can use the `neg` opcode: - -- - + instruction instead (that is, subtract from 0). + + Negating a floating-point number cannot overflow, and negating NaN returns NaN. + + The following method overload can use the `neg` opcode: + +- + ]]> @@ -11498,39 +11497,39 @@ The following method overloads Pushes an object reference to a new zero-based, one-dimensional array whose elements are of a specific type onto the evaluation stack. - |newarr `etype`|Creates a new array with elements of type `etype`.| - - The stack transitional behavior, in sequential order, is: - -1. The number of elements in the array is pushed onto the stack. - -2. The number of elements is popped from the stack and the array is created. - -3. An object reference to the new array is pushed onto the stack. - - The `newarr` instruction pushes an object reference (type `O`) to a new zero-based, one-dimensional array whose elements are of type `etype` (a metadata token describing the type). The number of elements in the new array should be specified as a `native int`. Valid array indexes range from zero to the maximum number of elements minus one. - - The elements of an array can be any type, including value types. - - Zero-based, one-dimensional arrays of numbers are created using a metadata token referencing the appropriate value type (, and so on). Elements of the array are initialized to 0 of the appropriate type. - - Nonzero-based one-dimensional arrays and multidimensional arrays are created using rather than `newarr`. More commonly, they are created using the methods of the class in the .NET Framework. - - is thrown if there is insufficient memory to satisfy the request. - - is thrown if `numElems` is less than 0. - - The following method overload can use the `newarr` opcode: - -- - + |newarr `etype`|Creates a new array with elements of type `etype`.| + + The stack transitional behavior, in sequential order, is: + +1. The number of elements in the array is pushed onto the stack. + +2. The number of elements is popped from the stack and the array is created. + +3. An object reference to the new array is pushed onto the stack. + + The `newarr` instruction pushes an object reference (type `O`) to a new zero-based, one-dimensional array whose elements are of type `etype` (a metadata token describing the type). The number of elements in the new array should be specified as a `native int`. Valid array indexes range from zero to the maximum number of elements minus one. + + The elements of an array can be any type, including value types. + + Zero-based, one-dimensional arrays of numbers are created using a metadata token referencing the appropriate value type (, and so on). Elements of the array are initialized to 0 of the appropriate type. + + Nonzero-based one-dimensional arrays and multidimensional arrays are created using rather than `newarr`. More commonly, they are created using the methods of the class in the .NET Framework. + + is thrown if there is insufficient memory to satisfy the request. + + is thrown if `numElems` is less than 0. + + The following method overload can use the `newarr` opcode: + +- + ]]> @@ -11574,41 +11573,41 @@ The following method overloads Creates a new object or a new instance of a value type, pushing an object reference (type ) onto the evaluation stack. - |newobj `ctor`|Allocates an uninitialized object or value type and calls the constructor method `ctor`.| - - The stack transitional behavior, in sequential order, is: - -1. Arguments `arg1` through `argn` are pushed on the stack in sequence. - -2. Arguments `argn` through `arg1` are popped from the stack and passed to `ctor` for object creation. - -3. A reference to the new object is pushed onto the stack. - - The `newobj` instruction creates a new object or a new instance of a value type. `Ctor` is a metadata token (a `methodref` or `methoddef` that must be marked as a constructor) that indicates the name, class and signature of the constructor to call. - - The `newobj` instruction allocates a new instance of the class associated with `ctor` and initializes all the fields in the new instance to 0 (of the proper type) or null references as appropriate. It then calls the constructor `ctor` with the given arguments along with the newly created instance. After the constructor has been called, the now initialized object reference (type `O`) is pushed on the stack. - - From the constructor's point of view, the uninitialized object is argument 0 and the other arguments passed to newobj follow in order. - - All zero-based, one-dimensional arrays are created using , not `newobj`. On the other hand, all other arrays (more than one dimension, or one-dimensional but not zero-based) are created using `newobj`. - - Value types are not usually created using `newobj`. They are usually allocated either as arguments or local variables, using `newarr` (for zero-based, one-dimensional arrays), or as fields of objects. Once allocated, they are initialized using . However, the `newobj` instruction can be used to create a new instance of a value type on the stack, that can then be passed as an argument, stored in a local, and so on. - - is thrown if there is insufficient memory to satisfy the request. - - is thrown if a constructor method `ctor` with the indicated name, class and signature could not be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. - - The following method overload can use the `newobj` opcode: - -- - + |newobj `ctor`|Allocates an uninitialized object or value type and calls the constructor method `ctor`.| + + The stack transitional behavior, in sequential order, is: + +1. Arguments `arg1` through `argn` are pushed on the stack in sequence. + +2. Arguments `argn` through `arg1` are popped from the stack and passed to `ctor` for object creation. + +3. A reference to the new object is pushed onto the stack. + + The `newobj` instruction creates a new object or a new instance of a value type. `Ctor` is a metadata token (a `methodref` or `methoddef` that must be marked as a constructor) that indicates the name, class and signature of the constructor to call. + + The `newobj` instruction allocates a new instance of the class associated with `ctor` and initializes all the fields in the new instance to 0 (of the proper type) or null references as appropriate. It then calls the constructor `ctor` with the given arguments along with the newly created instance. After the constructor has been called, the now initialized object reference (type `O`) is pushed on the stack. + + From the constructor's point of view, the uninitialized object is argument 0 and the other arguments passed to newobj follow in order. + + All zero-based, one-dimensional arrays are created using , not `newobj`. On the other hand, all other arrays (more than one dimension, or one-dimensional but not zero-based) are created using `newobj`. + + Value types are not usually created using `newobj`. They are usually allocated either as arguments or local variables, using `newarr` (for zero-based, one-dimensional arrays), or as fields of objects. Once allocated, they are initialized using . However, the `newobj` instruction can be used to create a new instance of a value type on the stack, that can then be passed as an argument, stored in a local, and so on. + + is thrown if there is insufficient memory to satisfy the request. + + is thrown if a constructor method `ctor` with the indicated name, class and signature could not be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. + + The following method overload can use the `newobj` opcode: + +- + ]]> @@ -11652,23 +11651,23 @@ The following method overloads Fills space if opcodes are patched. No meaningful operation is performed although a processing cycle can be consumed. - method overload can use the `nop` opcode: - -- - + method overload can use the `nop` opcode: + +- + ]]> @@ -11712,29 +11711,29 @@ The following method overloads Computes the bitwise complement of the integer value on top of the stack and pushes the result onto the evaluation stack as the same type. - method overload can use the `not` opcode: - -- - + method overload can use the `not` opcode: + +- + ]]> @@ -11778,33 +11777,33 @@ The following method overloads Compute the bitwise complement of the two integer values on top of the stack and pushes the result onto the evaluation stack. - method overload can use the `or` opcode: - -- - + method overload can use the `or` opcode: + +- + ]]> @@ -11848,25 +11847,25 @@ The following method overloads Removes the value currently on top of the evaluation stack. - method overload can use the `pop` opcode: - -- - + method overload can use the `pop` opcode: + +- + ]]> @@ -12237,55 +12236,55 @@ The following method overloads Specifies that the subsequent array address operation performs no type check at run time, and that it returns a managed pointer whose mutability is restricted. - method overload can use the `readonly` opcode: - -- - + method overload can use the `readonly` opcode: + +- + ]]> @@ -12329,31 +12328,31 @@ callvirt m Retrieves the type token embedded in a typed reference. - instruction for information on creating typed references. - - The following method overload can use the `refanytype` opcode: - -- - + instruction for information on creating typed references. + + The following method overload can use the `refanytype` opcode: + +- + ]]> @@ -12397,35 +12396,35 @@ callvirt m Retrieves the address (type ) embedded in a typed reference. - |refanyval `type`|Pushes the address stored in a typed reference.| - - The stack transitional behavior, in sequential order, is: - -1. A value type reference is pushed onto the stack. - -2. The typed reference is popped from the stack and the corresponding address retrieved. - -3. The address is pushed onto the stack. - - A typed reference contains a type token and an address to an object instance. - - The `refanyval` instruction retrieves the address embedded in the a typed reference. The type embedded in the typed reference supplied on the stack must match the type specified by `type` (a metadata token, either a `typedef` or a `typeref`). See the instruction for related content. - - is thrown if `type` is not identical to the type stored in the type reference (in this case, `type` is the class supplied to the instruction that constructed said typed reference). - - is thrown if `type` cannot be found. - - The following method overload can use the `refanyval` opcode: - -- - + |refanyval `type`|Pushes the address stored in a typed reference.| + + The stack transitional behavior, in sequential order, is: + +1. A value type reference is pushed onto the stack. + +2. The typed reference is popped from the stack and the corresponding address retrieved. + +3. The address is pushed onto the stack. + + A typed reference contains a type token and an address to an object instance. + + The `refanyval` instruction retrieves the address embedded in the a typed reference. The type embedded in the typed reference supplied on the stack must match the type specified by `type` (a metadata token, either a `typedef` or a `typeref`). See the instruction for related content. + + is thrown if `type` is not identical to the type stored in the type reference (in this case, `type` is the class supplied to the instruction that constructed said typed reference). + + is thrown if `type` cannot be found. + + The following method overload can use the `refanyval` opcode: + +- + ]]> @@ -12469,42 +12468,42 @@ callvirt m Divides two values and pushes the remainder onto the evaluation stack. - if `value2` is zero. - - Note that on the Intel-based platforms an is thrown when computing (minint `rem` -1). - - The following method overload can use the `rem` opcode: - -- - + if `value2` is zero. + + Note that on the Intel-based platforms an is thrown when computing (minint `rem` -1). + + The following method overload can use the `rem` opcode: + +- + ]]> @@ -12548,41 +12547,41 @@ callvirt m Divides two unsigned values and pushes the remainder onto the evaluation stack. - treats them as signed integers. - - `Rem.un` is unspecified for floating-point numbers. - - Integral operations throw if `value2` is zero. - - The following method overload can use the `rem.un` opcode: - -- - + treats them as signed integers. + + `Rem.un` is unspecified for floating-point numbers. + + Integral operations throw if `value2` is zero. + + The following method overload can use the `rem.un` opcode: + +- + ]]> @@ -12626,31 +12625,31 @@ callvirt m Returns from the current method, pushing a return value (if present) from the callee's evaluation stack onto the caller's evaluation stack. - instruction with a destination of a `ret` instruction that is outside all enclosing exception blocks. Because the `filter` and `finally` blocks are logically part of exception handling and not the method in which their code is embedded, correctly generated Microsoft Intermediate Language (MSIL) instructions do not perform a method return from within a `filter` or `finally`. - - The following method overload can use the `ret` opcode: - -- - + instruction with a destination of a `ret` instruction that is outside all enclosing exception blocks. Because the `filter` and `finally` blocks are logically part of exception handling and not the method in which their code is embedded, correctly generated Microsoft Intermediate Language (MSIL) instructions do not perform a method return from within a `filter` or `finally`. + + The following method overload can use the `ret` opcode: + +- + ]]> @@ -12694,23 +12693,23 @@ callvirt m Rethrows the current exception. - method overload can use the `rethrow` opcode: - -- - + method overload can use the `rethrow` opcode: + +- + ]]> @@ -12754,33 +12753,33 @@ callvirt m Shifts an integer value to the left (in zeroes) by a specified number of bits, pushing the result onto the evaluation stack. - method overload can use the `shl` opcode: - -- - + method overload can use the `shl` opcode: + +- + ]]> @@ -12824,33 +12823,33 @@ callvirt m Shifts an integer value (in sign) to the right by a specified number of bits, pushing the result onto the evaluation stack. - method overload can use the `shr` opcode: - -- - + method overload can use the `shr` opcode: + +- + ]]> @@ -12894,33 +12893,33 @@ callvirt m Shifts an unsigned integer value (in zeroes) to the right by a specified number of bits, pushing the result onto the evaluation stack. - method overload can use the `shr.un` opcode: - -- - + method overload can use the `shr.un` opcode: + +- + ]]> @@ -12964,27 +12963,27 @@ callvirt m Pushes the size, in bytes, of a supplied value type onto the evaluation stack. - |sizeof `valType`|Push the size, in bytes, of a value type as an `unsigned int32`.| - - The stack transitional behavior, in sequential order, is: - -1. The size (in bytes) of the supplied value type (`valType`) is pushed onto the stack. - - `valType` must be a metadata token (a `typeref` or `typedef`) that specifies a value type, reference type, or generic type parameter. - - For a reference type, the size returned is the size of a reference value of the corresponding type (4 bytes on 32-bit systems), not the size of the data stored in objects referred to by the reference value. A generic type parameter can be used only in the body of the type or method that defines it. When that type or method is instantiated, the generic type parameter is replaced by a value type or reference type. - - The following method overload can use the `sizeof` opcode: - -- - + |sizeof `valType`|Push the size, in bytes, of a value type as an `unsigned int32`.| + + The stack transitional behavior, in sequential order, is: + +1. The size (in bytes) of the supplied value type (`valType`) is pushed onto the stack. + + `valType` must be a metadata token (a `typeref` or `typedef`) that specifies a value type, reference type, or generic type parameter. + + For a reference type, the size returned is the size of a reference value of the corresponding type (4 bytes on 32-bit systems), not the size of the data stored in objects referred to by the reference value. A generic type parameter can be used only in the body of the type or method that defines it. When that type or method is instantiated, the generic type parameter is replaced by a value type or reference type. + + The following method overload can use the `sizeof` opcode: + +- + ]]> @@ -13029,29 +13028,29 @@ callvirt m Stores the value on top of the evaluation stack in the argument slot at a specified index. - |starg `num`|Pops the top value from the stack and stores it in argument slot `num`.| - - The stack transitional behavior, in sequential order, is: - -1. The value currently on top of the stack is popped and placed in argument slot `num`. - - The `starg` instruction pops a value from the stack and places it in argument slot `num`. The type of the value must match the type of the argument, as specified in the current method's signature. - - For procedures that take a variable argument list, the `starg` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. - - Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. - - The following method overload can use the `starg` opcode: - -- - + |starg `num`|Pops the top value from the stack and stores it in argument slot `num`.| + + The stack transitional behavior, in sequential order, is: + +1. The value currently on top of the stack is popped and placed in argument slot `num`. + + The `starg` instruction pops a value from the stack and places it in argument slot `num`. The type of the value must match the type of the argument, as specified in the current method's signature. + + For procedures that take a variable argument list, the `starg` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. + + Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. + + The following method overload can use the `starg` opcode: + +- + ]]> @@ -13095,31 +13094,31 @@ callvirt m Stores the value on top of the evaluation stack in the argument slot at a specified index, short form. - |starg.s `num`|Pops the top value from the stack and stores it in argument slot `num`, short form.| - - The stack transitional behavior, in sequential order, is: - -1. The value currently on top of the stack is popped and placed in argument slot `num`. - - The `starg.s` instruction pops a value from the stack and places it in argument slot `num`. The type of the value must match the type of the argument, as specified in the current method's signature. - - The `starg.s` instruction provides an efficient encoding for use with the first 256 arguments. - - For procedures that take a variable argument list, the `starg.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. - - Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. - - The following method overload can use the `starg.s` opcode: - -- - + |starg.s `num`|Pops the top value from the stack and stores it in argument slot `num`, short form.| + + The stack transitional behavior, in sequential order, is: + +1. The value currently on top of the stack is popped and placed in argument slot `num`. + + The `starg.s` instruction pops a value from the stack and places it in argument slot `num`. The type of the value must match the type of the argument, as specified in the current method's signature. + + The `starg.s` instruction provides an efficient encoding for use with the first 256 arguments. + + For procedures that take a variable argument list, the `starg.s` instruction can be used only for the initial fixed arguments, not those in the variable part of the signature. + + Performing a store into arguments that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the argument. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. + + The following method overload can use the `starg.s` opcode: + +- + ]]> @@ -13162,39 +13161,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack, whose type is specified in the instruction. - |stelem `typeTok`|Replaces the array element at the supplied index with a value of type `typeTok` on the stack.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference to an array, `array`, is pushed onto the stack. - -2. An index value, `index`, to an element in `array` is pushed onto the stack. - -3. A value of the type specified in the instruction is pushed onto the stack. - -4. The value, the index, and the array reference are popped from the stack; the value is put into the array element at the given index. - - The `stelem` instruction replaces the value of the element at the supplied zero-based index in the one-dimensional array `array` with the value. The value has the type specified by the token `typeTok` in the instruction. - - Arrays are objects, and hence represented by a value of type `O`. The index is type `native int`. - - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem` opcode: - -- - + |stelem `typeTok`|Replaces the array element at the supplied index with a value of type `typeTok` on the stack.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference to an array, `array`, is pushed onto the stack. + +2. An index value, `index`, to an element in `array` is pushed onto the stack. + +3. A value of the type specified in the instruction is pushed onto the stack. + +4. The value, the index, and the array reference are popped from the stack; the value is put into the array element at the given index. + + The `stelem` instruction replaces the value of the element at the supplied zero-based index in the one-dimensional array `array` with the value. The value has the type specified by the token `typeTok` in the instruction. + + Arrays are objects, and hence represented by a value of type `O`. The index is type `native int`. + + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem` opcode: + +- + ]]> @@ -13238,39 +13237,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.i` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.i` opcode: + +- + ]]> @@ -13314,39 +13313,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.i1` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.i1` opcode: + +- + ]]> @@ -13390,39 +13389,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.i2` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.i2` opcode: + +- + ]]> @@ -13466,39 +13465,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.i4` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.i4` opcode: + +- + ]]> @@ -13542,39 +13541,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.i8` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.i8` opcode: + +- + ]]> @@ -13618,39 +13617,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.r4` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.r4` opcode: + +- + ]]> @@ -13694,39 +13693,39 @@ callvirt m Replaces the array element at a given index with the value on the evaluation stack. - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.r8` opcode: - -- - + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.r8` opcode: + +- + ]]> @@ -13770,41 +13769,41 @@ callvirt m Replaces the array element at a given index with the object ref value (type ) on the evaluation stack. - . For one-dimensional arrays that aren't zero-based and for multidimensional arrays, the class provides a method. - - is thrown if `array` is a null reference. - - is thrown if `index` is negative, or larger than the bound of `array`. - - is thrown if `array` does not hold elements of the required type. - - The following method overload can use the `stelem.ref` opcode: - -- - + . For one-dimensional arrays that aren't zero-based and for multidimensional arrays, the class provides a method. + + is thrown if `array` is a null reference. + + is thrown if `index` is negative, or larger than the bound of `array`. + + is thrown if `array` does not hold elements of the required type. + + The following method overload can use the `stelem.ref` opcode: + +- + ]]> @@ -13848,33 +13847,33 @@ callvirt m Replaces the value stored in the field of an object reference or pointer with a new value. - |stfld `field`|Replaces the value of `field` of the object with a new value.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference or pointer is pushed onto the stack. - -2. A value is pushed onto the stack. - -3. The value and the object reference/pointer are popped from the stack; the value of `field` in the object is replaced with the supplied value. - - The `stfld` instruction replaces the value of a field of an object (type `O`) or via a pointer (type `native int`, `&`, or `*`) with a given value. `Field` is a metadata token that refers to a field member reference. The `stfld` instruction can have a prefix of either or both of and . - - is thrown if the object reference or pointer is a null reference and the field isn't static. - - is thrown if `field` is not found in the metadata. This is typically checked when the Microsoft Intermediate Language (MSIL) instruction is converted to native code, not at runtime. - - The following method overload can use the `stfld` opcode: - -- - + |stfld `field`|Replaces the value of `field` of the object with a new value.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference or pointer is pushed onto the stack. + +2. A value is pushed onto the stack. + +3. The value and the object reference/pointer are popped from the stack; the value of `field` in the object is replaced with the supplied value. + + The `stfld` instruction replaces the value of a field of an object (type `O`) or via a pointer (type `native int`, `&`, or `*`) with a given value. `Field` is a metadata token that refers to a field member reference. The `stfld` instruction can have a prefix of either or both of and . + + is thrown if the object reference or pointer is a null reference and the field isn't static. + + is thrown if `field` is not found in the metadata. This is typically checked when the Microsoft Intermediate Language (MSIL) instruction is converted to native code, not at runtime. + + The following method overload can use the `stfld` opcode: + +- + ]]> @@ -13918,33 +13917,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.i` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.i` opcode: + +- + ]]> @@ -13988,33 +13987,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.i1` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.i1` opcode: + +- + ]]> @@ -14058,33 +14057,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.i2` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.i2` opcode: + +- + ]]> @@ -14128,33 +14127,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.i4` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.i4` opcode: + +- + ]]> @@ -14198,33 +14197,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.i8` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.i8` opcode: + +- + ]]> @@ -14268,33 +14267,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.r4` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.r4` opcode: + +- + ]]> @@ -14338,33 +14337,33 @@ callvirt m Stores a value of type at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.r8` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.r8` opcode: + +- + ]]> @@ -14408,33 +14407,33 @@ callvirt m Stores a object reference value at a supplied address. - or prefix instruction. - - is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. - - The following method overload can use the `stind.ref` opcode: - -- - + or prefix instruction. + + is thrown if `addr` is not naturally aligned for the argument type implied by the instruction suffix. + + The following method overload can use the `stind.ref` opcode: + +- + ]]> @@ -14478,31 +14477,31 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at a specified index. - |stloc `index`|Pops a value from the stack and stores it in local variable `index`.| - - The stack transitional behavior, in sequential order, is: - -1. A value is popped off of the stack and placed in local variable `index`. - - The `stloc` instruction pops the top value off the evaluation stack and moves it into local variable number `index`, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature. - - Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. - - Correct Microsoft Intermediate Language (MSIL) instructions require that `index` be a valid local index. For the `stloc` instruction, `index` must lie in the range 0 to 65534 inclusive (specifically, 65535 is not valid). The reason for excluding 65535 is pragmatic: likely implementations will use a 2-byte integer to track both a local's index, as well as the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method. - - The following method overloads can use the `stloc` opcode: - -- - -- - + |stloc `index`|Pops a value from the stack and stores it in local variable `index`.| + + The stack transitional behavior, in sequential order, is: + +1. A value is popped off of the stack and placed in local variable `index`. + + The `stloc` instruction pops the top value off the evaluation stack and moves it into local variable number `index`, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature. + + Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. + + Correct Microsoft Intermediate Language (MSIL) instructions require that `index` be a valid local index. For the `stloc` instruction, `index` must lie in the range 0 to 65534 inclusive (specifically, 65535 is not valid). The reason for excluding 65535 is pragmatic: likely implementations will use a 2-byte integer to track both a local's index, as well as the total number of locals for a given method. If an index of 65535 had been made valid, it would require a wider integer to track the number of locals in such a method. + + The following method overloads can use the `stloc` opcode: + +- + +- + ]]> @@ -14546,29 +14545,29 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at index 0. - method overload can use the `stloc.0` opcode: - -- - + method overload can use the `stloc.0` opcode: + +- + ]]> @@ -14612,29 +14611,29 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at index 1. - method overload can use the `stloc.1` opcode: - -- - + method overload can use the `stloc.1` opcode: + +- + ]]> @@ -14678,29 +14677,29 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at index 2. - method overload can use the `stloc.2` opcode: - -- - + method overload can use the `stloc.2` opcode: + +- + ]]> @@ -14744,29 +14743,29 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at index 3. - method overload can use the `stloc.3` opcode: - -- - + method overload can use the `stloc.3` opcode: + +- + ]]> @@ -14810,31 +14809,31 @@ callvirt m Pops the current value from the top of the evaluation stack and stores it in the local variable list at (short form). - |stloc.s `index`|Pops a value from the stack and stores it in local variable `index`, short form.| - - The stack transitional behavior, in sequential order, is: - -1. A value is popped off of the stack and placed in local variable `index`. - - The `stloc.s` instruction pops the top value off the evaluation stack and moves it into local variable number `index`, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature. - - The `stloc.s` instruction provides an efficient encoding for local variables 0 through 255. - - Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. - - The following method overloads can use the `stloc.s` opcode: - -- - -- - + |stloc.s `index`|Pops a value from the stack and stores it in local variable `index`, short form.| + + The stack transitional behavior, in sequential order, is: + +1. A value is popped off of the stack and placed in local variable `index`. + + The `stloc.s` instruction pops the top value off the evaluation stack and moves it into local variable number `index`, where local variables are numbered 0 onwards. The type of the value must match the type of the local variable as specified in the current method's local signature. + + The `stloc.s` instruction provides an efficient encoding for local variables 0 through 255. + + Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. Floating-point values are rounded from their native size (type `F`) to the size associated with the argument. + + The following method overloads can use the `stloc.s` opcode: + +- + +- + ]]> @@ -14878,33 +14877,33 @@ callvirt m Copies a value of a specified type from the evaluation stack into a supplied memory address. - |stobj `class`|Stores a value of type `class` from the stack into memory.| - - The stack transitional behavior, in sequential order, is: - -1. An address is pushed onto the stack. - -2. A value type object of type `class` is pushed onto the stack. - -3. The object and the address are popped from the stack; the value type object is stored at the address. - - The `stobj` instruction copies the value type object into the address specified by the address (a pointer of type `native int`, `*`, or `&`). The number of bytes copied depends on the size of the class represented by `class`, a metadata token representing a value type. - - The operation of the `stobj` instruction can be altered by an immediately preceding or prefix instruction. - - is thrown if class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time. - - The following method overload can use the `stobj` opcode: - -- - + |stobj `class`|Stores a value of type `class` from the stack into memory.| + + The stack transitional behavior, in sequential order, is: + +1. An address is pushed onto the stack. + +2. A value type object of type `class` is pushed onto the stack. + +3. The object and the address are popped from the stack; the value type object is stored at the address. + + The `stobj` instruction copies the value type object into the address specified by the address (a pointer of type `native int`, `*`, or `&`). The number of bytes copied depends on the size of the class represented by `class`, a metadata token representing a value type. + + The operation of the `stobj` instruction can be altered by an immediately preceding or prefix instruction. + + is thrown if class cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code rather than at run time. + + The following method overload can use the `stobj` opcode: + +- + ]]> @@ -14948,31 +14947,31 @@ callvirt m Replaces the value of a static field with a value from the evaluation stack. - |stsfld `field`|Replaces the value in `field` with a supplied value.| - - The stack transitional behavior, in sequential order, is: - -1. A value is pushed onto the stack. - -2. A value is popped from the stack and stored in `field`. - - The `stsfld` instruction replaces the value of a static field with a value from the stack. `field` is a metadata token that must refer to a static field member. - - The `stsfld` instruction may be prefixed by . - - is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. - - The following method overload can use the `stsfld` opcode: - -- - + |stsfld `field`|Replaces the value in `field` with a supplied value.| + + The stack transitional behavior, in sequential order, is: + +1. A value is pushed onto the stack. + +2. A value is popped from the stack and stored in `field`. + + The `stsfld` instruction replaces the value of a static field with a value from the stack. `field` is a metadata token that must refer to a static field member. + + The `stsfld` instruction may be prefixed by . + + is thrown if field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time. + + The following method overload can use the `stsfld` opcode: + +- + ]]> @@ -15016,35 +15015,35 @@ callvirt m Subtracts one value from another and pushes the result onto the evaluation stack. - ). - - Integer subtraction wraps, rather than saturates. For example: assuming 8-bit integers, where `value1` is set to 0 and `value2` is set to 1, the "wrapped" result will be 255. - - Floating-point overflow returns `+inf` (`PositiveInfinity`) or `-inf` (`NegativeInfinity`). - - The following method overload can use the `sub` opcode: - -- - + ). + + Integer subtraction wraps, rather than saturates. For example: assuming 8-bit integers, where `value1` is set to 0 and `value2` is set to 1, the "wrapped" result will be 255. + + Floating-point overflow returns `+inf` (`PositiveInfinity`) or `-inf` (`NegativeInfinity`). + + The following method overload can use the `sub` opcode: + +- + ]]> @@ -15088,33 +15087,33 @@ callvirt m Subtracts one integer value from another, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result can not be represented in the result type. - - This operation is performed on signed integers; for floating-point values, use . - - The following method overload can use the `sub.ovf` opcode: - -- - + is thrown if the result can not be represented in the result type. + + This operation is performed on signed integers; for floating-point values, use . + + The following method overload can use the `sub.ovf` opcode: + +- + ]]> @@ -15158,33 +15157,33 @@ callvirt m Subtracts one unsigned integer value from another, performs an overflow check, and pushes the result onto the evaluation stack. - is thrown if the result can not be represented in the result type. - - This operation is performed on signed integers; for floating-point values, use . - - The following method overload can use the `sub.ovf.un` opcode: - -- - + is thrown if the result can not be represented in the result type. + + This operation is performed on signed integers; for floating-point values, use . + + The following method overload can use the `sub.ovf.un` opcode: + +- + ]]> @@ -15228,42 +15227,41 @@ callvirt m Implements a jump table. - < `int32` >... < `int32` >|switch (`N`, `t1`, `t2`... `tN`)|Jumps to one of `N` values.| - - The stack transitional behavior, in sequential order, is: - -1. A value is pushed onto the stack. - -2. The value is popped off the stack and execution is transferred to the instruction at the offset indexed by the value, where the value is less than `N`. - - The `switch` instruction implements a jump table. The format of the instruction is an `unsigned int32` representing the number of targets `N`, followed by `N` int32 values specifying jump targets. These targets are represented as offsets (positive or negative) from the beginning of the instruction following this `switch` instruction. - - The `switch` instruction pops a value off the stack and compares it, as an unsigned integer, to `N`. If value is less than `N`, execution is transferred to the target indexed by value, where targets are numbered from 0 (for example, a value of 0 takes the first target, a value of 1 takes the second target, and so on). If the value is greater than or equal to `N`, execution continues at the next instruction (fall through). - - If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. - - Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. (Such transfers are severely restricted and must use the leave instruction instead). - - The following method overload can use the `switch` opcode. The `Label[]` argument is an array of Labels representing 32-bit offsets. - -- - - - -## Examples - The following code sample illustrates the use of the `Switch` opcode to generate a jump table using an array of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/CPP/source.cpp" id="Snippet1"::: + < `int32` >... < `int32` >|switch (`N`, `t1`, `t2`... `tN`)|Jumps to one of `N` values.| + + The stack transitional behavior, in sequential order, is: + +1. A value is pushed onto the stack. + +2. The value is popped off the stack and execution is transferred to the instruction at the offset indexed by the value, where the value is less than `N`. + + The `switch` instruction implements a jump table. The format of the instruction is an `unsigned int32` representing the number of targets `N`, followed by `N` int32 values specifying jump targets. These targets are represented as offsets (positive or negative) from the beginning of the instruction following this `switch` instruction. + + The `switch` instruction pops a value off the stack and compares it, as an unsigned integer, to `N`. If value is less than `N`, execution is transferred to the target indexed by value, where targets are numbered from 0 (for example, a value of 0 takes the first target, a value of 1 takes the second target, and so on). If the value is greater than or equal to `N`, execution continues at the next instruction (fall through). + + If the target instruction has one or more prefix codes, control can only be transferred to the first of these prefixes. + + Control transfers into and out of `try`, `catch`, `filter`, and `finally` blocks cannot be performed by this instruction. (Such transfers are severely restricted and must use the leave instruction instead). + + The following method overload can use the `switch` opcode. The `Label[]` argument is an array of Labels representing 32-bit offsets. + +- + + + +## Examples + The following code sample illustrates the use of the `Switch` opcode to generate a jump table using an array of . + :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ILGenerator/Emit/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ILGenerator.Emit Example 2/VB/source.vb" id="Snippet1"::: + ]]> @@ -15307,27 +15305,27 @@ callvirt m Performs a postfixed method call instruction such that the current method's stack frame is removed before the actual call instruction is executed. - , , or instruction. It indicates that the current method's stack frame should be removed before the call instruction is executed. It also implies that the value returned from the following call is also the value returned by the current method, and the call can therefore be converted into a cross-method jump. - - The stack must be empty except for the arguments being transferred by the following call. The instruction following the call instruction must be a ret. Thus the only valid code sequence is `tail. call` (or `calli` or `callvirt`). Correct Microsoft Intermediate Language (MSIL) instructions must not branch to the `call` instruction, but they may branch to the subsequent . - - The current frame cannot be discarded when control is transferred from untrusted code to trusted code, since this would jeopardize code identity security. The .NET Framework security checks can therefore cause the `tail` to be ignored, leaving a standard instruction. Similarly, in order to allow the exit of a synchronized region to occur after the call returns, the `tail` prefix is ignored when used to exit a method that is marked synchronized. - - The following method overload can use the `tail` opcode: - -- - + , , or instruction. It indicates that the current method's stack frame should be removed before the call instruction is executed. It also implies that the value returned from the following call is also the value returned by the current method, and the call can therefore be converted into a cross-method jump. + + The stack must be empty except for the arguments being transferred by the following call. The instruction following the call instruction must be a ret. Thus the only valid code sequence is `tail. call` (or `calli` or `callvirt`). Correct Microsoft Intermediate Language (MSIL) instructions must not branch to the `call` instruction, but they may branch to the subsequent . + + The current frame cannot be discarded when control is transferred from untrusted code to trusted code, since this would jeopardize code identity security. The .NET Framework security checks can therefore cause the `tail` to be ignored, leaving a standard instruction. Similarly, in order to allow the exit of a synchronized region to occur after the call returns, the `tail` prefix is ignored when used to exit a method that is marked synchronized. + + The following method overload can use the `tail` opcode: + +- + ]]> @@ -15377,27 +15375,26 @@ callvirt m or . - instance takes a single byte argument in the following cases: - -- The opcode performs a branch instruction to a byte-sized address (for example, and ). - -- The opcode pushes a byte value onto the stack (for example, ). - -- The opcode references a variable or argument via the byte-sized "short form" (for example, and ). - - Otherwise, it returns `false`. - - The example below demonstrates the use of `TakesSingleByteArgument` by reflecting on to the `OpCodes` class and testing to see whether each `OpCode` field takes a single-byte argument. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/CPP/source.cpp" id="Snippet1"::: + instance takes a single byte argument in the following cases: + +- The opcode performs a branch instruction to a byte-sized address (for example, and ). + +- The opcode pushes a byte value onto the stack (for example, ). + +- The opcode references a variable or argument via the byte-sized "short form" (for example, and ). + + Otherwise, it returns `false`. + + The example below demonstrates the use of `TakesSingleByteArgument` by reflecting on to the `OpCodes` class and testing to see whether each `OpCode` field takes a single-byte argument. + :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/OpCodes/TakesSingleByteArgument/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.OpCodes.TakesSingleByteArgument Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -15441,29 +15438,29 @@ callvirt m Throws the exception object currently on the evaluation stack. - is thrown if the object reference is a null reference. - - The following method overload can use the `throw` opcode: - -- - + is thrown if the object reference is a null reference. + + The following method overload can use the `throw` opcode: + +- + ]]> @@ -15507,33 +15504,33 @@ callvirt m Indicates that an address currently atop the evaluation stack might not be aligned to the natural size of the immediately following , , , , , , , or instruction. - |unaligned. `alignment`|Indicates that the subsequent pointer instruction may be unaligned.| - - The stack transitional behavior, in sequential order, is: - -1. An address is pushed onto the stack. - - `Unaligned` specifies that the address (an unmanaged pointer, `native int`) on the stack might not be aligned to the natural size of the immediately following `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. That is, for a instruction the alignment of the address may not be to a 4-byte boundary. For `initblk` and `cpblk` the default alignment is architecture dependent (4-byte on 32-bit CPUs, 8-byte on 64-bit CPUs). Code generators that do not restrict their output to a 32-bit word size must use `unaligned` if the alignment is not known at compile time to be 8-byte. - - The value of alignment must be 1, 2, or 4 and means that the generated code should assume that the address is byte, double-byte, or quad-byte aligned, respectively. Note that transient pointers (type `*`) are always aligned. - - While the alignment for a `cpblk` instruction would logically require two numbers (one for the source and one for the destination), there is no noticeable impact on performance if only the lower number is specified. - - The `unaligned` and `volatile` prefixes can be combined in either order. They must immediately precede a `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. Only the prefix is allowed for the and instructions. - - The following method overloads can use the `unaligned` opcode: - -- - -- - + |unaligned. `alignment`|Indicates that the subsequent pointer instruction may be unaligned.| + + The stack transitional behavior, in sequential order, is: + +1. An address is pushed onto the stack. + + `Unaligned` specifies that the address (an unmanaged pointer, `native int`) on the stack might not be aligned to the natural size of the immediately following `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. That is, for a instruction the alignment of the address may not be to a 4-byte boundary. For `initblk` and `cpblk` the default alignment is architecture dependent (4-byte on 32-bit CPUs, 8-byte on 64-bit CPUs). Code generators that do not restrict their output to a 32-bit word size must use `unaligned` if the alignment is not known at compile time to be 8-byte. + + The value of alignment must be 1, 2, or 4 and means that the generated code should assume that the address is byte, double-byte, or quad-byte aligned, respectively. Note that transient pointers (type `*`) are always aligned. + + While the alignment for a `cpblk` instruction would logically require two numbers (one for the source and one for the destination), there is no noticeable impact on performance if only the lower number is specified. + + The `unaligned` and `volatile` prefixes can be combined in either order. They must immediately precede a `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. Only the prefix is allowed for the and instructions. + + The following method overloads can use the `unaligned` opcode: + +- + +- + ]]> @@ -15577,43 +15574,43 @@ callvirt m Converts the boxed representation of a value type to its unboxed form. - |unbox `valType`|Extracts the value type data from `obj`, its boxed representation.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference is pushed onto the stack. - -2. The object reference is popped from the stack and unboxed to a value type pointer. - -3. The value type pointer is pushed onto the stack. - - A value type has two separate representations within the Common Language Infrastructure (CLI): - -- A 'raw' form used when a value type is embedded within another object. - -- A 'boxed' form, where the data in the value type is wrapped (boxed) into an object so it can exist as an independent entity. - - The `unbox` instruction converts the object reference (type `O`), the boxed representation of a value type, to a value type pointer (a managed pointer, type `&`), its unboxed form. The supplied value type (`valType`) is a metadata token indicating the type of value type contained within the boxed object. - - Unlike , which is required to make a copy of a value type for use in the object, `unbox` is not required to copy the value type from the object. Typically it simply computes the address of the value type that is already present inside of the boxed object. - - is thrown if the object is not boxed as `valType`. - - is thrown if the object reference is a null reference. - - is thrown if the value type `valType` cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. - - The following method overload can use the `unbox` opcode: - -- - + |unbox `valType`|Extracts the value type data from `obj`, its boxed representation.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference is pushed onto the stack. + +2. The object reference is popped from the stack and unboxed to a value type pointer. + +3. The value type pointer is pushed onto the stack. + + A value type has two separate representations within the Common Language Infrastructure (CLI): + +- A 'raw' form used when a value type is embedded within another object. + +- A 'boxed' form, where the data in the value type is wrapped (boxed) into an object so it can exist as an independent entity. + + The `unbox` instruction converts the object reference (type `O`), the boxed representation of a value type, to a value type pointer (a managed pointer, type `&`), its unboxed form. The supplied value type (`valType`) is a metadata token indicating the type of value type contained within the boxed object. + + Unlike , which is required to make a copy of a value type for use in the object, `unbox` is not required to copy the value type from the object. Typically it simply computes the address of the value type that is already present inside of the boxed object. + + is thrown if the object is not boxed as `valType`. + + is thrown if the object reference is a null reference. + + is thrown if the value type `valType` cannot be found. This is typically detected when Microsoft Intermediate Language (MSIL) instructions are converted to native code, rather than at runtime. + + The following method overload can use the `unbox` opcode: + +- + ]]> @@ -15656,37 +15653,37 @@ callvirt m Converts the boxed representation of a type specified in the instruction to its unboxed form. - |unbox.any `typeTok`|Extract the data from `obj`, its boxed representation.| - - The stack transitional behavior, in sequential order, is: - -1. An object reference `obj` is pushed onto the stack. - -2. The object reference is popped from the stack and unboxed to the type specified in the instruction. - -3. The resulting object reference or value type is pushed onto the stack. - - When applied to the boxed form of a value type, the `unbox.any` instruction extracts the value contained within `obj` (of type `O`), and is therefore equivalent to `unbox` followed by `ldobj`. - - When applied to a reference type, the `unbox.any` instruction has the same effect as `castclass` `typeTok`. - - If the operand `typeTok` is a generic type parameter, then the runtime behavior is determined by the type that is specified for that generic type parameter. - - is thrown if `obj` is not a boxed type. - - is thrown if `obj` is a null reference. - - The following method overload can use the `unbox.any` opcode: - -- - + |unbox.any `typeTok`|Extract the data from `obj`, its boxed representation.| + + The stack transitional behavior, in sequential order, is: + +1. An object reference `obj` is pushed onto the stack. + +2. The object reference is popped from the stack and unboxed to the type specified in the instruction. + +3. The resulting object reference or value type is pushed onto the stack. + + When applied to the boxed form of a value type, the `unbox.any` instruction extracts the value contained within `obj` (of type `O`), and is therefore equivalent to `unbox` followed by `ldobj`. + + When applied to a reference type, the `unbox.any` instruction has the same effect as `castclass` `typeTok`. + + If the operand `typeTok` is a generic type parameter, then the runtime behavior is determined by the type that is specified for that generic type parameter. + + is thrown if `obj` is not a boxed type. + + is thrown if `obj` is a null reference. + + The following method overload can use the `unbox.any` opcode: + +- + ]]> @@ -15730,27 +15727,27 @@ callvirt m Specifies that an address currently atop the evaluation stack might be volatile, and the results of reading that location cannot be cached or that multiple stores to that location cannot be suppressed. - and `volatile` prefixes can be combined in either order. They must immediately precede a `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. Only the `volatile` prefix is allowed for the and instructions. - - The following method overload can use the `volatile` opcode: - -- - + and `volatile` prefixes can be combined in either order. They must immediately precede a `ldind`, `stind`, `ldfld`, `stfld`, `ldobj`, `stobj`, `initblk`, or `cpblk` instruction. Only the `volatile` prefix is allowed for the and instructions. + + The following method overload can use the `volatile` opcode: + +- + ]]> @@ -15794,33 +15791,33 @@ callvirt m Computes the bitwise XOR of the top two values on the evaluation stack, pushing the result onto the evaluation stack. - method overload can use the `xor` opcode: - -- - + method overload can use the `xor` opcode: + +- + ]]> diff --git a/xml/System.Reflection.Emit/ParameterBuilder.xml b/xml/System.Reflection.Emit/ParameterBuilder.xml index 27889885838..1fe36af8758 100644 --- a/xml/System.Reflection.Emit/ParameterBuilder.xml +++ b/xml/System.Reflection.Emit/ParameterBuilder.xml @@ -87,7 +87,6 @@ ## Examples The following example demonstrates how to create a dynamic method with a parameter passed by reference using `ParameterBuilder`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/ParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.ParameterBuilder Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection.Emit/PropertyBuilder.xml b/xml/System.Reflection.Emit/PropertyBuilder.xml index 83c7f5ce965..5b19d9e2da6 100644 --- a/xml/System.Reflection.Emit/PropertyBuilder.xml +++ b/xml/System.Reflection.Emit/PropertyBuilder.xml @@ -85,7 +85,6 @@ ## Examples The following code sample demonstrates how to implement properties in a dynamic type using a `PropertyBuilder` obtained via to create the property framework and an associated to implement the IL logic within the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/PropertyBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/VB/source.vb" id="Snippet1"::: @@ -1458,7 +1457,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample demonstrates how to attach a dynamic method to a `get` property created with `PropertyBuilder` using `SetGetMethod`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/PropertyBuilder/SetGetMethod/propertybuilder_setgetmethod_4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/VB/propertybuilder_setgetmethod_4.vb" id="Snippet1"::: @@ -1552,7 +1550,6 @@ For information on how to format `binaryAttribute`, see the metadata specificati ## Examples The following code sample demonstrates how to attach a dynamic method to a `set` property created with `PropertyBuilder` using `SetSetMethod`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/CPP/propertybuilder_setgetmethod_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/PropertyBuilder/SetGetMethod/propertybuilder_setgetmethod_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PropertyBuilder_SetGetMethod_4/VB/propertybuilder_setgetmethod_4.vb" id="Snippet2"::: diff --git a/xml/System.Reflection.Emit/TypeBuilder.xml b/xml/System.Reflection.Emit/TypeBuilder.xml index 57ac7fbec80..d3b2c8c7ce0 100644 --- a/xml/System.Reflection.Emit/TypeBuilder.xml +++ b/xml/System.Reflection.Emit/TypeBuilder.xml @@ -90,13 +90,11 @@ @@ -181,7 +179,6 @@ The following code sample demonstrates how to build a type dynamically by using ## Examples The following example demonstrates the use of the `AddDeclarativeSecurity` method to add a security demand for with the flag to a dynamic type named `MyDynamicClass`, in an assembly named EmittedExample.dll. The example produces no console output; after you run it, you can use [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine EmittedExample.dll. In `MyDynamicClass`, open the `.class public auto ansi` statement to see the declarative permission. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/CPP/typebuilder_adddeclarativesecurity.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/AddDeclarativeSecurity/typebuilder_adddeclarativesecurity.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_AddDeclarativeSecurity/VB/typebuilder_adddeclarativesecurity.vb" id="Snippet1"::: @@ -261,7 +258,6 @@ The following code sample demonstrates how to build a type dynamically by using ## Examples The following code sample demonstrates the implementation of an interface on a dynamically created type using `AddInterfaceImplementation`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/AddInterfaceImplementation/typebuilder_sample_4.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_Sample_4/VB/typebuilder_sample_4.vb" id="Snippet3"::: @@ -575,7 +571,6 @@ See for a description of the format of the ## Examples The following code example shows how to define an event handler for the event, in order to call the method on a nested type during a call on the enclosing type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/CPP/nestedenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/CreateType/nestedenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.TypeBuilder.CreateType Example/VB/nestedenum.vb" id="Snippet1"::: @@ -876,7 +871,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates the use of `DefineConstructor` to set a constructor's particular signature and attributes on a dynamic type and return a corresponding for MSIL population. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/AddInterfaceImplementation/typebuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_Sample_4/VB/typebuilder_sample_4.vb" id="Snippet2"::: @@ -1111,7 +1105,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates the use of `DefineConstructor` to set a constructor's particular signature and attributes on a dynamic type and return a corresponding for MSIL population. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Sample_4/CPP/typebuilder_sample_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/AddInterfaceImplementation/typebuilder_sample_4.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_Sample_4/VB/typebuilder_sample_4.vb" id="Snippet2"::: @@ -1526,7 +1519,6 @@ See for a description of the format of the ## Examples The following code example creates a generic type with two type parameters and saves them in the assembly GenericEmitExample1.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see [How to: Define a Generic Type with Reflection Emit](/dotnet/framework/reflection-and-codedom/how-to-define-a-generic-type-with-reflection-emit). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/GenericTypeParameterBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb" id="Snippet1"::: @@ -1756,13 +1748,10 @@ See for a description of the format of the This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GenericMethodBuilder/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/MethodBuilder/DefineGenericParameters/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GenericMethodBuilder/VB/source.vb" id="Snippet5"::: @@ -1920,7 +1909,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates the use of `DefineMethod` to set a constructor's particular signature and attributes on a dynamic type and to return a corresponding for MSIL population. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefineMethod/typebuilder_definenestedtype1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/VB/typebuilder_definenestedtype1.vb" id="Snippet2"::: @@ -2011,7 +1999,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates the use of `DefineMethod` to set a constructor's particular signature and attributes on a dynamic type and to return a corresponding for MSIL population. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/CPP/typebuilder_definenestedtype1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefineMethod/typebuilder_definenestedtype1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefineNestedType1/VB/typebuilder_definenestedtype1.vb" id="Snippet2"::: @@ -2326,7 +2313,6 @@ See for a description of the format of the The code example creates an instance of the emitted class. It obtains a object for `I.M()`, and uses it to invoke the emitted class's explicit interface implementation. It then obtains a object for `A.M()`, and uses it to invoke the emitted class's override of that method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefineMethodOverride/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder.DefineMethodOverride/vb/source.vb" id="Snippet1"::: @@ -3211,7 +3197,6 @@ See for a description of the format of the When the example is run, it executes the `PInvoke` method. It also saves the dynamic assembly as PInvokeTest.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the `MyType` class and the `static` (`Shared` in Visual Basic) `PInvoke` method it contains. You can compile a Visual Basic or C# program that uses the static `MyType.GetTickCount` method by including a reference to the DLL when you run csc.exe or vbc.exe; for example, `/r:PInvokeTest.dll`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefinePInvokeMethod/100656_fix.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/VB/100656_fix.vb" id="Snippet1"::: @@ -3338,7 +3323,6 @@ See for a description of the format of the When the example is run, it executes the `PInvoke` method. It also saves the dynamic assembly as PInvokeTest.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the `MyType` class and the `static` (`Shared` in Visual Basic) `PInvoke` method it contains. You can compile a Visual Basic or C# program that uses the static `MyType.GetTickCount` method by including a reference to the DLL when you run csc.exe or vbc.exe; for example, `/r:PInvokeTest.dll`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefinePInvokeMethod/100656_fix.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/VB/100656_fix.vb" id="Snippet1"::: @@ -3504,7 +3488,6 @@ See for a description of the format of the When the example is run, it executes the `PInvoke` method. It also saves the dynamic assembly as PInvokeTest.dll. You can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the `MyType` class and the `static` (`Shared` in Visual Basic) `PInvoke` method it contains. You can compile a Visual Basic or C# program that uses the static `MyType.GetTickCount` method by including a reference to the DLL when you run csc.exe or vbc.exe; for example, `/r:PInvokeTest.dll`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/cpp/100656_fix.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefinePInvokeMethod/100656_fix.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefinePInvokeMethod_Fix/VB/100656_fix.vb" id="Snippet1"::: @@ -3722,7 +3705,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates how to define a dynamic property and obtain a for specification. Note that a `PropertyBuilder` must also have a corresponding , which will house the IL logic for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/PropertyBuilder/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Emit.PropertyBuilder Example/VB/source.vb" id="Snippet1"::: @@ -4224,7 +4206,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates how to create an initialization constructor using `DefineTypeInitializer`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_Properties1/CPP/typebuilder_properties.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefineTypeInitializer/typebuilder_properties.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_Properties1/VB/typebuilder_properties.vb" id="Snippet3"::: @@ -4323,7 +4304,6 @@ See for a description of the format of the ## Examples The following code sample demonstrates the use of `DefineUninitializedData` to create an uninitialized data field in a dynamic type: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/CPP/typebuilder_defineuninitializeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/DefineUninitializedData/typebuilder_defineuninitializeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeBuilder_DefineUninitializedData/VB/typebuilder_defineuninitializeddata.vb" id="Snippet1"::: @@ -7994,7 +7974,6 @@ See for a description of the format of the - Two instances that represent the same constructed type do not compare as equal. For example, in the following code `t1.Equals(t2)` returns `false`: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/TypeBuilder/MakeGenericType/remarks.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.reflection.emit.typebuilder.makegenerictype/vb/remarks.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/AmbiguousMatchException.xml b/xml/System.Reflection/AmbiguousMatchException.xml index 4ee15590a3f..ef2c101c125 100644 --- a/xml/System.Reflection/AmbiguousMatchException.xml +++ b/xml/System.Reflection/AmbiguousMatchException.xml @@ -289,7 +289,6 @@ ## Examples The following example shows two methods, each named `Mymethod`. One method takes an integer and the other takes a string. If an integer is passed to `Mymethod`, the first method is used. If a string is passed, the second method is used. If it cannot be determined which `Mymethod` to use, `AmbiguousMatchException` is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AmbiguousMatchException/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic AmbiguousMatchException.AmbiguousMatchException2 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/Assembly.xml b/xml/System.Reflection/Assembly.xml index f9c5c259004..037ff7e3103 100644 --- a/xml/System.Reflection/Assembly.xml +++ b/xml/System.Reflection/Assembly.xml @@ -153,7 +153,6 @@ The code example also demonstrates the use of the method to obtain an object that can be used to parse the full name of the assembly. The example displays the version number of the assembly, the property, and the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyClass/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyClass/vb/source.vb" id="Snippet1"::: @@ -287,7 +286,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following example uses the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/codebase1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/codebase1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/codebase1.vb" id="Snippet1"::: @@ -1166,7 +1164,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following example retrieves the display name of the currently executing assembly, and the display name of the assembly that contains the type (`int` in C#, `Integer` in Visual Basic). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Assembly.FullName/CPP/Example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/FullName/Example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Assembly.FullName/VB/Example.vb" id="Snippet1"::: @@ -1240,7 +1237,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following example retrieves the assembly that contains the type and displays its name and file location. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/GetAssembly1.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/GetAssembly1.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/GetAssembly1.vb" id="Snippet12"::: @@ -1319,7 +1315,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following example gets the calling assembly of the current method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/getcallingassembly1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/getcallingassembly1.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/getcallingassembly1.vb" id="Snippet4"::: @@ -1678,7 +1673,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following example uses the property to get the currently executing assembly based on a type contained in that assembly. It also calls the method to show that it returns an object that represents the same assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/cpp/getexecutingassembly1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetExecutingAssembly/getexecutingassembly1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.reflection.assembly.getexecutingassembly/vb/getexecutingassembly1.vb" id="Snippet5"::: @@ -1746,7 +1740,6 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex ## Examples The following code sample defines a number of classes with various access levels, and calls to display the ones that are visible from outside the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Assembly.GetExportedTypes/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetExportedTypes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Assembly.GetExportedTypes/VB/source.vb" id="Snippet1"::: @@ -2656,7 +2649,6 @@ Note: In .NET for Win ## Examples The following example displays the name of the module in the returned array that contains the assembly manifest. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetModules/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Assembly.GetModules Example/VB/source.vb" id="Snippet1"::: @@ -2973,7 +2965,6 @@ Note: In .NET for Win The following code example demonstrates calling the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection/VB/Reflection.vb" id="Snippet1"::: @@ -3556,7 +3547,6 @@ Note: In .NET for Win ## Examples The following example displays parameters of one method on a type in the specified assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/assembly.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/assembly.vb" id="Snippet11"::: @@ -4219,7 +4209,6 @@ To load the correct assembly, it's recommended to call the `Load` method by pass ## Examples The following example loads an assembly given its fully qualified name, and lists all the types contained in the specified assembly. For information about how to obtain the fully qualified assembly name, see [Assembly Names](/dotnet/standard/assembly/names). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Assembly.Load1/CPP/load1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/Load/load1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Assembly.Load1/VB/load1.vb" id="Snippet1"::: @@ -4920,7 +4909,6 @@ The assembly is loaded into the default AssemblyLoadContext. For more informatio ## Examples The following example loads an assembly given its file name or path. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/assembly.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/assembly.vb" id="Snippet11"::: @@ -5724,7 +5712,6 @@ In .NET 5 and later versions, for bundled assemblies, the value returned is an e ## Examples The following example displays the location of the loaded file that contains the manifest. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Assembly/CPP/assembly.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/CodeBase/assembly.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Assembly/VB/assembly.vb" id="Snippet3"::: diff --git a/xml/System.Reflection/AssemblyCompanyAttribute.xml b/xml/System.Reflection/AssemblyCompanyAttribute.xml index 1947cb75e1d..e9e07cdea04 100644 --- a/xml/System.Reflection/AssemblyCompanyAttribute.xml +++ b/xml/System.Reflection/AssemblyCompanyAttribute.xml @@ -68,15 +68,14 @@ Defines a company name custom attribute for an assembly manifest. - attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog. -## Examples - The following example shows how to apply attributes, including the attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyCompanyAttribute/Overview/assemblybuilder_defineversioninforesource.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: + ]]> Assemblies in .NET diff --git a/xml/System.Reflection/AssemblyCopyrightAttribute.xml b/xml/System.Reflection/AssemblyCopyrightAttribute.xml index 81afcc0aefe..561fbafb848 100644 --- a/xml/System.Reflection/AssemblyCopyrightAttribute.xml +++ b/xml/System.Reflection/AssemblyCopyrightAttribute.xml @@ -68,15 +68,14 @@ Defines a copyright custom attribute for an assembly manifest. - attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog. -## Examples - The following example shows how to apply attributes, including the attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyCompanyAttribute/Overview/assemblybuilder_defineversioninforesource.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: + ]]> Assemblies in .NET diff --git a/xml/System.Reflection/AssemblyDelaySignAttribute.xml b/xml/System.Reflection/AssemblyDelaySignAttribute.xml index df73e0add59..f5df27bb12f 100644 --- a/xml/System.Reflection/AssemblyDelaySignAttribute.xml +++ b/xml/System.Reflection/AssemblyDelaySignAttribute.xml @@ -82,7 +82,6 @@ sn -k TestPublicKey.snk Compile the example as a .dll. If you compile from the command line, use the `/t:library` option. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyDelaySignAttribute/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/AssemblyFlagsAttribute.xml b/xml/System.Reflection/AssemblyFlagsAttribute.xml index 3d0e7794743..a57171c988b 100644 --- a/xml/System.Reflection/AssemblyFlagsAttribute.xml +++ b/xml/System.Reflection/AssemblyFlagsAttribute.xml @@ -78,7 +78,6 @@ ## Examples The following code example shows how to apply the to an assembly, and how to read the flags at run time. The example also creates an instance of the attribute, and uses the property to display the flags. For an example of how to apply the to a dynamic assembly, see the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyFlagsAttribute/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyFlagsAttribute/VB/source.vb" id="Snippet1"::: @@ -208,7 +207,6 @@ ## Examples The following code example shows how to apply the to an assembly, and how to read the flags at run time. The example also creates an instance of the attribute, and uses the property to display the flags. For an example of how to apply the to a dynamic assembly, see the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyFlagsAttribute/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyFlagsAttribute/VB/source.vb" id="Snippet1"::: @@ -337,7 +335,6 @@ ## Examples The following code example shows how to apply the to an assembly, and how to read the flags at run time. The example also creates an instance of the attribute, and uses the property to display the flags. For an example of how to apply the to a dynamic assembly, see the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyFlagsAttribute/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyFlagsAttribute/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyFlagsAttribute/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/AssemblyKeyFileAttribute.xml b/xml/System.Reflection/AssemblyKeyFileAttribute.xml index 686d82cfcee..2759f713573 100644 --- a/xml/System.Reflection/AssemblyKeyFileAttribute.xml +++ b/xml/System.Reflection/AssemblyKeyFileAttribute.xml @@ -89,7 +89,6 @@ sn -k TestPublicKey.snk Compile the example as a .dll. If you compile from the command line, use the `/t:library` option. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyDelaySignAttribute/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/AssemblyName.xml b/xml/System.Reflection/AssemblyName.xml index 41c520abb9e..0f2e70188e3 100644 --- a/xml/System.Reflection/AssemblyName.xml +++ b/xml/System.Reflection/AssemblyName.xml @@ -182,7 +182,6 @@ ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012 ## Examples This example shows how to use various reflection classes to analyze the metadata contained in an assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection/VB/Reflection.vb" id="Snippet1"::: @@ -256,7 +255,6 @@ ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012 ## Examples The following example creates a dynamic assembly named `MyAssembly.exe` and saves it to your hard disk. After running the example, you can use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the assembly metadata. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/.ctor/assemblyname_constructor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_Constructor/VB/assemblyname_constructor.vb" id="Snippet1"::: @@ -324,7 +322,6 @@ ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012 ## Examples The following example creates an instance of from a display name. The individual elements of the display name are output to the console as properties of the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor_2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_Constructor_2/VB/source.vb" id="Snippet1"::: @@ -463,7 +460,6 @@ Note: In .NET for Win ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to specify the directory where the assembly is saved. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/CodeBase/assemblyname_codebase.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_CodeBase/VB/assemblyname_codebase.vb" id="Snippet1"::: @@ -570,7 +566,6 @@ Note: In .NET for Win ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to specify the culture, which is part of the assembly's display name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/CodeBase/assemblyname_codebase.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_CodeBase/VB/assemblyname_codebase.vb" id="Snippet2"::: @@ -737,7 +732,6 @@ Note: In .NET for Win ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to specify that the assembly has a public key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/Flags/assemblyname_keypair.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_KeyPair/VB/assemblyname_keypair.vb" id="Snippet4"::: @@ -818,7 +812,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the code example sets the , , , and properties, which together comprise an assembly's full name, or display name. The property is then used to retrieve the display name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/CodeBase/assemblyname_codebase.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_CodeBase/VB/assemblyname_codebase.vb" id="Snippet4"::: @@ -889,7 +882,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example gets the for an assembly on disk. It will not run unless you replace the string "MyAssembly.exe" with the file name of an assembly (including the path, if necessary) on your hard disk. Alternatively, you can compile this example as "MyAssembly.exe". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/GetAssemblyName/assemblyname_getassemblyname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_GetAssemblyName/VB/assemblyname_getassemblyname.vb" id="Snippet1"::: @@ -1027,7 +1019,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the method is used to give the assembly a public key. The method is then used to retrieve the public key, which is displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/Flags/assemblyname_keypair.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_KeyPair/VB/assemblyname_keypair.vb" id="Snippet2"::: @@ -1094,7 +1085,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the method is used to set the assembly's public key token. The method is then used to retrieve the public key token, which is displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/Flags/assemblyname_keypair.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_KeyPair/VB/assemblyname_keypair.vb" id="Snippet3"::: @@ -1162,7 +1152,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to set the hash algorithm for the assembly manifest. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_CodeBase/CPP/assemblyname_codebase.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/CodeBase/assemblyname_codebase.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_CodeBase/VB/assemblyname_codebase.vb" id="Snippet3"::: @@ -1227,7 +1216,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to set the assembly's public and private cryptographic keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_KeyPair/CPP/assemblyname_keypair.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/Flags/assemblyname_keypair.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_KeyPair/VB/assemblyname_keypair.vb" id="Snippet1"::: @@ -1294,7 +1282,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to set the simple name of the dynamic assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/.ctor/assemblyname_constructor.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_Constructor/VB/assemblyname_constructor.vb" id="Snippet2"::: @@ -1538,7 +1525,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the method is used to give the assembly a public key. The method is then used to retrieve the public key, which is displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/SetPublicKey/assemblyname_setpublickey.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_SetPublicKey/VB/assemblyname_setpublickey.vb" id="Snippet1"::: @@ -1605,7 +1591,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the method is used to set the assembly's public key token. The method is then used to retrieve the public key token, which is displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_SetPublicKey/CPP/assemblyname_setpublickey.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/SetPublicKey/assemblyname_setpublickey.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_SetPublicKey/VB/assemblyname_setpublickey.vb" id="Snippet2"::: @@ -1879,7 +1864,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ## Examples The following example gets an object for a hypothetical `MyAssembly.exe` assembly, and then uses the method to retrieve the full assembly name, or display name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_GetAssemblyName/CPP/assemblyname_getassemblyname.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/GetAssemblyName/assemblyname_getassemblyname.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_GetAssemblyName/VB/assemblyname_getassemblyname.vb" id="Snippet2"::: @@ -1947,7 +1931,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 The following example retrieves and displays the version numbers of the currently executing assembly and the assembly that contains the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName.Version/cpp/Example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/Version/Example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName.Version/vb/Example.vb" id="Snippet1"::: @@ -1955,7 +1938,6 @@ mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 The following example emits a dynamic assembly and saves it to the current directory. When the assembly is created, the property is used to specify version information for the assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyName_Constructor/CPP/assemblyname_constructor.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyName/.ctor/assemblyname_constructor.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyName_Constructor/VB/assemblyname_constructor.vb" id="Snippet3"::: diff --git a/xml/System.Reflection/AssemblyTitleAttribute.xml b/xml/System.Reflection/AssemblyTitleAttribute.xml index 3a2d2ff59c9..ecf1570d1f4 100644 --- a/xml/System.Reflection/AssemblyTitleAttribute.xml +++ b/xml/System.Reflection/AssemblyTitleAttribute.xml @@ -68,22 +68,21 @@ Specifies a description for an assembly. - attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog box. -## Remarks - The assembly title is a friendly name, which can include spaces. - - In Windows Vista, the information specified for this attribute appears on the **Details** tab of the **Windows File Properties** dialog box for the assembly. The property name is **File description**. In Windows XP, this information appears on the **Version** tab of the **Windows File Properties** dialog box. - - - -## Examples - The following example shows how to add attributes, including the attribute, to a dynamic assembly. The example saves the assembly to disk, and the attribute value can be viewed by using the **Windows File Properties** dialog box. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/CPP/assemblybuilder_defineversioninforesource.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyCompanyAttribute/Overview/assemblybuilder_defineversioninforesource.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyBuilder_DefineVersionInfoResource/VB/assemblybuilder_defineversioninforesource.vb" id="Snippet1"::: + ]]> Assemblies in .NET @@ -133,11 +132,11 @@ The assembly title. Initializes a new instance of the class. - Assemblies in .NET @@ -187,11 +186,11 @@ Gets assembly title information. The assembly title. - property appears on the **Details** tab of the **Windows File Properties** dialog box for the assembly. The property name is **File description**. In Windows XP, this property appears on the **Version** tab of the **Windows File Properties** dialog box. - + property appears on the **Details** tab of the **Windows File Properties** dialog box for the assembly. The property name is **File description**. In Windows XP, this property appears on the **Version** tab of the **Windows File Properties** dialog box. + ]]> Assemblies in .NET diff --git a/xml/System.Reflection/Binder.xml b/xml/System.Reflection/Binder.xml index aa94bd1afc7..eb856b0b16a 100644 --- a/xml/System.Reflection/Binder.xml +++ b/xml/System.Reflection/Binder.xml @@ -63,22 +63,21 @@ Selects a member from a list of candidates, and performs type conversion from actual argument type to formal argument type. - class are used by methods such as , which selects from a set of possible members to execute, based on a set of parameter types and argument values; , which selects a method based on parameter types; and so on. + + A default implementation of the class is provided by the property. + + + +## Examples + The following example implements and demonstrates all members of the `Binder` class. The private method `CanConvertFrom` finds compatible types for a given type. -## Remarks - Implementations of the class are used by methods such as , which selects from a set of possible members to execute, based on a set of parameter types and argument values; , which selects a method based on parameter types; and so on. - - A default implementation of the class is provided by the property. - - - -## Examples - The following example implements and demonstrates all members of the `Binder` class. The private method `CanConvertFrom` finds compatible types for a given type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Binder/Overview/binder.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Binder_1/VB/binder.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Binder_1/VB/binder.vb" id="Snippet1"::: + ]]> @@ -121,11 +120,11 @@ Initializes a new instance of the class. - @@ -187,23 +186,23 @@ Selects a field from the given set of fields, based on the specified criteria. The matching field. - , the default binder implementation provided by simply returns the first element of `match`. No selection is done. - - This method controls the binding provided by . - - If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. - + , the default binder implementation provided by simply returns the first element of `match`. No selection is done. + + This method controls the binding provided by . + + If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. + ]]> For the default binder, includes , and contains multiple fields that are equally good matches for . For example, contains a MyClass object that implements the IMyClass interface, and contains a field of type MyClass and a field of type IMyClass. For the default binder, includes , and contains no fields that can accept . - For the default binder, includes , and is or an empty array. - - -or- - + For the default binder, includes , and is or an empty array. + + -or- + includes , and is . @@ -291,17 +290,17 @@ Selects a method to invoke from the given set of methods, based on the supplied arguments. The matching method. - . Use this remap capability to get back by-reference arguments when such arguments are present. When you pass arguments by name, the binder reorders the argument array. The `state` parameter keeps track of argument reordering, thus enabling the binder's method to reorder the argument array to its original form. - - The method is used by the method. - - If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. - + . Use this remap capability to get back by-reference arguments when such arguments are present. When you pass arguments by name, the binder reorders the argument array. The `state` parameter keeps track of argument reordering, thus enabling the binder's method to reorder the argument array to its original form. + + The method is used by the method. + + If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. + ]]> For the default binder, contains multiple methods that are equally good matches for . For example, contains a MyClass object that implements the IMyClass interface, and contains a method that takes MyClass and a method that takes IMyClass. @@ -365,33 +364,33 @@ Changes the type of the given to the given . An object that contains the given value as the new type. - . This is consistent with lookup of members that are protected, private, and so on. - - The general principle is that `ChangeType` should perform only widening coercions, which never lose data. An example of a widening coercion is coercing a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. This is distinguished from a narrowing coercion, which may lose data. An example of a narrowing coercion is coercing a 64-bit signed integer to a 32-bit signed integer. - - The following table lists the coercions performed by the default `ChangeType`. - -|Source type|Target type| -|-----------------|-----------------| -|Any type|Its base type.| -|Any type|The interface it implements.| -|Char|UInt16, UInt32, Int32, UInt64, Int64, Single, Double| -|Byte|Char, UInt16, Int16, UInt32, Int32, UInt64, Int64, Single, Double| -|SByte|Int16, Int32, Int64, Single, Double| -|UInt16|UInt32, Int32, UInt64, Int64, Single, Double| -|Int16|Int32, Int64, Single, Double| -|UInt32|UInt64, Int64, Single, Double| -|Int32|Int64, Single, Double| -|UInt64|Single, Double| -|Int64|Single, Double| -|Single|Double| -|Non-reference|By-reference.| - - If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. - + . This is consistent with lookup of members that are protected, private, and so on. + + The general principle is that `ChangeType` should perform only widening coercions, which never lose data. An example of a widening coercion is coercing a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. This is distinguished from a narrowing coercion, which may lose data. An example of a narrowing coercion is coercing a 64-bit signed integer to a 32-bit signed integer. + + The following table lists the coercions performed by the default `ChangeType`. + +|Source type|Target type| +|-----------------|-----------------| +|Any type|Its base type.| +|Any type|The interface it implements.| +|Char|UInt16, UInt32, Int32, UInt64, Int64, Single, Double| +|Byte|Char, UInt16, Int16, UInt32, Int32, UInt64, Int64, Single, Double| +|SByte|Int16, Int32, Int64, Single, Double| +|UInt16|UInt32, Int32, UInt64, Int64, Single, Double| +|Int16|Int32, Int64, Single, Double| +|UInt32|UInt64, Int64, Single, Double| +|Int32|Int64, Single, Double| +|UInt64|Single, Double| +|Int64|Single, Double| +|Single|Double| +|Non-reference|By-reference.| + + If a binder implementation allows coercion of string values to numeric types, the `culture` parameter is necessary to convert a string that represents 1000 to a value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions. + ]]> @@ -448,11 +447,11 @@ A binder-provided object that keeps track of argument reordering. Upon returning from , restores the argument to what it was when it came from . - @@ -520,18 +519,18 @@ Selects a method from the given set of methods, based on the argument type. The matching method, if found; otherwise, . - For the default binder, contains multiple methods that are equally good matches for the parameter types described by . For example, the array in contains a object for MyClass and the array in contains a method that takes a base class of MyClass and a method that takes an interface that MyClass implements. - For the default binder, is or an empty array. - - -or- - + For the default binder, is or an empty array. + + -or- + An element of derives from , but is not of type . @@ -601,11 +600,11 @@ Selects a property from the given set of properties, based on the specified criteria. The matching property. - For the default binder, contains multiple properties that are equally good matches for and . diff --git a/xml/System.Reflection/BindingFlags.xml b/xml/System.Reflection/BindingFlags.xml index eac66df5f8f..5ebb86e3054 100644 --- a/xml/System.Reflection/BindingFlags.xml +++ b/xml/System.Reflection/BindingFlags.xml @@ -85,88 +85,87 @@ Specifies flags that control binding and the way in which the search for members and types is conducted by reflection. - methods and other places such as : - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - - `InvokeMember` and `GetMethod` are especially important. - - The binding flags can be categorized by how they identify a type member, as listed in the following table. - -|Identified by Accessibility|Identified by Binding Argument|Identified by Operation| -|---------------------------------|------------------------------------|-----------------------------| -|DeclaredOnly

FlattenHierarchy

IgnoreCase

IgnoreReturn

Instance

NonPublic

Public

Static|ExactBinding

OptionalParamBinding|CreateInstance

GetField

SetField

GetProperty

SetProperty

InvokeMethod

PutDispProperty

PutRefDispProperty| - + methods and other places such as : + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + + `InvokeMember` and `GetMethod` are especially important. + + The binding flags can be categorized by how they identify a type member, as listed in the following table. + +|Identified by Accessibility|Identified by Binding Argument|Identified by Operation| +|---------------------------------|------------------------------------|-----------------------------| +|DeclaredOnly

FlattenHierarchy

IgnoreCase

IgnoreReturn

Instance

NonPublic

Public

Static|ExactBinding

OptionalParamBinding|CreateInstance

GetField

SetField

GetProperty

SetProperty

InvokeMethod

PutDispProperty

PutRefDispProperty| + > [!NOTE] -> You must specify `Instance` or `Static` along with `Public` or `NonPublic` or no members will be returned. - - The following table lists the coercions performed by the default . This table applies especially to the `BindingFlags.ExactBinding` binding flag. The general principle is that should perform only widening coercions, which never lose data. An example of a widening coercion is coercing a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. This is distinguished from a narrowing coercion, which may lose data. An example of a narrowing coercion is coercing a 64-bit signed integer to a 32-bit signed integer. - -|Source Type|Target Type| -|-----------------|-----------------| -|Any type|Its base type.| -|Any type|The interface it implements.| -|`Char`|`UInt16`, `UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| -|`Byte`|`Char`, `UInt16`, `Int16`, `UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| -|`SByte`|`Int16`, `Int32`, `Int64`, `Single`, `Double`| -|`UInt16`|`UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| -|`Int16`|`Int32`, `Int64`, `Single`, `Double`| -|`UInt32`|`UInt64`, `Int64`, `Single`, `Double`| -|`Int32`|`Int64`, `Single`, `Double`| -|`UInt64`|`Single`, `Double`| -|`Int64`|`Single`, `Double`| -|`Single`|`Double`| -|Non-reference|By-reference.| +> You must specify `Instance` or `Static` along with `Public` or `NonPublic` or no members will be returned. + + The following table lists the coercions performed by the default . This table applies especially to the `BindingFlags.ExactBinding` binding flag. The general principle is that should perform only widening coercions, which never lose data. An example of a widening coercion is coercing a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. This is distinguished from a narrowing coercion, which may lose data. An example of a narrowing coercion is coercing a 64-bit signed integer to a 32-bit signed integer. + +|Source Type|Target Type| +|-----------------|-----------------| +|Any type|Its base type.| +|Any type|The interface it implements.| +|`Char`|`UInt16`, `UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| +|`Byte`|`Char`, `UInt16`, `Int16`, `UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| +|`SByte`|`Int16`, `Int32`, `Int64`, `Single`, `Double`| +|`UInt16`|`UInt32`, `Int32`, `UInt64`, `Int64`, `Single`, `Double`| +|`Int16`|`Int32`, `Int64`, `Single`, `Double`| +|`UInt32`|`UInt64`, `Int64`, `Single`, `Double`| +|`Int32`|`Int64`, `Single`, `Double`| +|`UInt64`|`Single`, `Double`| +|`Int64`|`Single`, `Double`| +|`Single`|`Double`| +|Non-reference|By-reference.| + +When the `BindingFlags.ExactBinding` binding flag is used, reflection models the accessibility rules of the common type system. For example, if the caller is in the same assembly, the caller does not need special permissions for internal members. Otherwise, the caller needs . This is consistent with the lookup of members that are protected, private, and so on. + + + + + + +## Examples + The following example demonstrates many of the binding flags. -When the `BindingFlags.ExactBinding` binding flag is used, reflection models the accessibility rules of the common type system. For example, if the caller is in the same assembly, the caller does not need special permissions for internal members. Otherwise, the caller needs . This is consistent with the lookup of members that are protected, private, and so on. - - - - - - -## Examples - The following example demonstrates many of the binding flags. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/BindingFlags/CPP/bindingflagssample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/BindingFlags/Overview/bindingflagssample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/BindingFlags/VB/bindingflagssample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/BindingFlags/VB/bindingflagssample.vb" id="Snippet1"::: + ]]>
@@ -215,8 +214,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 512 - Specifies that reflection should create an instance of the specified type. Calls the constructor that matches the given arguments. The supplied member name is ignored. If the type of lookup is not specified, (Instance | Public) will apply. It is not possible to call a type initializer. - + Specifies that reflection should create an instance of the specified type. Calls the constructor that matches the given arguments. The supplied member name is ignored. If the type of lookup is not specified, (Instance | Public) will apply. It is not possible to call a type initializer. + This flag is passed to an method to invoke a constructor. @@ -493,8 +492,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 1024 - Specifies that the value of the specified field should be returned. - + Specifies that the value of the specified field should be returned. + This flag is passed to an method to get a field value. @@ -542,8 +541,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 4096 - Specifies that the value of the specified property should be returned. - + Specifies that the value of the specified property should be returned. + This flag is passed to an method to invoke a property getter. @@ -733,8 +732,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 256 - Specifies that a method is to be invoked. This must not be a constructor or a type initializer. - + Specifies that a method is to be invoked. This must not be a constructor or a type initializer. + This flag is passed to an method to invoke a method. @@ -1016,8 +1015,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 2048 - Specifies that the value of the specified field should be set. - + Specifies that the value of the specified field should be set. + This flag is passed to an method to set a field value. @@ -1065,8 +1064,8 @@ When the `BindingFlags.ExactBinding` binding flag is used, reflection models the 8192 - Specifies that the value of the specified property should be set. For COM properties, specifying this binding flag is equivalent to specifying and . - + Specifies that the value of the specified property should be set. For COM properties, specifying this binding flag is equivalent to specifying and . + This flag is passed to an method to invoke a property setter. diff --git a/xml/System.Reflection/CallingConventions.xml b/xml/System.Reflection/CallingConventions.xml index ae437c5cb6d..ad89922f6d9 100644 --- a/xml/System.Reflection/CallingConventions.xml +++ b/xml/System.Reflection/CallingConventions.xml @@ -72,18 +72,17 @@ Defines the valid calling conventions for a method. - diff --git a/xml/System.Reflection/ConstructorInfo.xml b/xml/System.Reflection/ConstructorInfo.xml index 1e7d646ea44..5bb2e0a821d 100644 --- a/xml/System.Reflection/ConstructorInfo.xml +++ b/xml/System.Reflection/ConstructorInfo.xml @@ -105,7 +105,6 @@ ## Examples The following example uses `ConstructorInfo` with and to find the constructors that match the specified search criteria. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructor/type_getconstructor3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetConstructor3/VB/type_getconstructor3.vb" id="Snippet1"::: @@ -614,7 +613,6 @@ Note: In .NET for Win ## Examples The following example uses the property to identify a object as a constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ConstructorInfo/MemberType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/CustomAttributeData.xml b/xml/System.Reflection/CustomAttributeData.xml index 0cb3383b32a..47432f3ca56 100644 --- a/xml/System.Reflection/CustomAttributeData.xml +++ b/xml/System.Reflection/CustomAttributeData.xml @@ -111,7 +111,6 @@ The attribute that is applied to the type demonstrates array properties, with both positional and named arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -290,7 +289,6 @@ The property is used in the `ShowAttributeData` method that displays custom attribute data. In this code example, the returned by this property is used to display a text string that describes the constructor, demonstrating that the property returns the constructor that would initialize the attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -371,7 +369,6 @@ The property is used in the `ShowAttributeData` method that displays custom attribute data. In this code example, this property is used to display the list of arguments passed to the constructor that initialized the attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -508,7 +505,6 @@ The method is used in `Main()` to get the custom attributes applied to the assembly. The return value of the method is passed to the `ShowAttributeData` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -588,7 +584,6 @@ The method is used in `Main()` to get the custom attributes that were applied to a type and to a test method ( derives from ). The return value of is passed to the `ShowAttributeData` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -725,7 +720,6 @@ The method is used in `Main()` to retrieve the custom attributes applied to a parameter of a test method. The return value of is passed to the `ShowAttributeData` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -849,7 +843,6 @@ The property is used in the `ShowAttributeData` method that displays custom attribute data. In this code example, this property is used to display the list of named arguments specified for the attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -918,7 +911,6 @@ In this example, the method is used in the `ShowAttributeData` method, to identify the attribute whose data is being displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/CustomAttributeNamedArgument.xml b/xml/System.Reflection/CustomAttributeNamedArgument.xml index 06af7cd191d..657fdf7737e 100644 --- a/xml/System.Reflection/CustomAttributeNamedArgument.xml +++ b/xml/System.Reflection/CustomAttributeNamedArgument.xml @@ -109,7 +109,6 @@ The attribute that is applied to the type demonstrates array properties, with both positional and named arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -741,7 +740,6 @@ The property is used in the `ShowAttributeData` method that displays custom attribute data, to obtain the types and values of named attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/CustomAttributeTypedArgument.xml b/xml/System.Reflection/CustomAttributeTypedArgument.xml index 9d8e4ce05c7..1f1b0917b1b 100644 --- a/xml/System.Reflection/CustomAttributeTypedArgument.xml +++ b/xml/System.Reflection/CustomAttributeTypedArgument.xml @@ -110,7 +110,6 @@ The attribute that is applied to the type demonstrates array properties, with both positional and named arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -305,7 +304,6 @@ The property is used in the `ShowValueOrArray` method that displays custom attribute data, to display the types of attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: @@ -686,7 +684,6 @@ The property is used in the `ShowValueOrArray` method that displays custom attribute data, to display the values of attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/CustomAttributeData/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/DefaultMemberAttribute.xml b/xml/System.Reflection/DefaultMemberAttribute.xml index 65a346d874f..d850cf9835b 100644 --- a/xml/System.Reflection/DefaultMemberAttribute.xml +++ b/xml/System.Reflection/DefaultMemberAttribute.xml @@ -69,20 +69,19 @@ Defines the member of a type that is the default member used by . - . If the is not present on the containing type, then the type does not have an indexer. The C# compiler emits the on any type containing an indexer. In C# it is an error to manually attribute a type with the if the type also declares an indexer. + + + +## Examples + The following example uses the attribute to make the `Age` property the default member of the `MyClass` class. -## Remarks - A property is imported as an indexer (default indexed property in Visual Basic) if the property has arguments and if the name of the property or one of its accessors matches the name specified by the . If the is not present on the containing type, then the type does not have an indexer. The C# compiler emits the on any type containing an indexer. In C# it is an error to manually attribute a type with the if the type also declares an indexer. - - - -## Examples - The following example uses the attribute to make the `Age` property the default member of the `MyClass` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetDefaultMembers/CPP/type_getdefaultmembers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetDefaultMembers/type_getdefaultmembers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetDefaultMembers/VB/type_getdefaultmembers.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetDefaultMembers/VB/type_getdefaultmembers.vb" id="Snippet1"::: + ]]> @@ -127,8 +126,8 @@ - A containing the name of the member to invoke. This may be a constructor, method, property, or field. A suitable invocation attribute must be specified when the member is invoked. The default member of a class can be specified by passing an empty as the name of the member. - + A containing the name of the member to invoke. This may be a constructor, method, property, or field. A suitable invocation attribute must be specified when the member is invoked. The default member of a class can be specified by passing an empty as the name of the member. + The default member of a type is marked with the custom attribute or marked in COM in the usual way. Initializes a new instance of the class. To be added. @@ -177,11 +176,11 @@ Gets the name from the attribute. A string representing the member name. - diff --git a/xml/System.Reflection/EventAttributes.xml b/xml/System.Reflection/EventAttributes.xml index 627b427137f..233521c07b9 100644 --- a/xml/System.Reflection/EventAttributes.xml +++ b/xml/System.Reflection/EventAttributes.xml @@ -72,22 +72,21 @@ Specifies the attributes of an event. - diff --git a/xml/System.Reflection/EventInfo.xml b/xml/System.Reflection/EventInfo.xml index ef22c3ecd3e..64ad881a4e2 100644 --- a/xml/System.Reflection/EventInfo.xml +++ b/xml/System.Reflection/EventInfo.xml @@ -114,7 +114,6 @@ ## Examples The following code gets an object for the event of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetEvent/type_getevent1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/type_getevent1/VB/type_getevent1.vb" id="Snippet1"::: @@ -493,7 +492,6 @@ Note: In Represents a clause in a structured exception-handling block. - class provides information about the clauses in a `try`…`catch`…`finally` block (`Try`…`Catch`…`Finally` in Visual Basic). To get a list of exception-handling clauses in a method, obtain a that represents the method. Use the method to obtain a object, and then use the property to get the list of clauses. - + class provides information about the clauses in a `try`…`catch`…`finally` block (`Try`…`Catch`…`Finally` in Visual Basic). To get a list of exception-handling clauses in a method, obtain a that represents the method. Use the method to obtain a object, and then use the property to get the list of clauses. + > [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + You can use Ildasm.exe to examine the MSIL for the compiled code example, to see how the offsets and lengths are calculated. + + + This code is part of a larger example located in the class topic. -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - You can use Ildasm.exe to examine the MSIL for the compiled code example, to see how the offsets and lengths are calculated. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -126,11 +122,11 @@ Initializes a new instance of the class. - objects. - + objects. + ]]> @@ -177,32 +173,28 @@ Gets the type of exception handled by this clause. A object that represents that type of exception handled by this clause, or if the property is or . - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> Invalid use of property for the object's current state. @@ -249,14 +241,14 @@ Gets the offset within the method body, in bytes, of the user-supplied filter code. The offset within the method body, in bytes, of the user-supplied filter code. The value of this property has no meaning if the property has any value other than . - clause. - + clause. + > [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and MSIL instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - + ]]> Cannot get the offset because the exception handling clause is not a filter. @@ -303,32 +295,28 @@ Gets a value indicating whether this exception-handling clause is a finally clause, a type-filtered clause, or a user-filtered clause. An value that indicates what kind of action this clause performs. - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -375,32 +363,28 @@ Gets the length, in bytes, of the body of this exception-handling clause. An integer that represents the length, in bytes, of the MSIL that forms the body of this exception-handling clause. - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -446,32 +430,28 @@ Gets the offset within the method body, in bytes, of this exception-handling clause. An integer that represents the offset within the method body, in bytes, of this exception-handling clause. - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -558,33 +538,29 @@ The total length, in bytes, of the try block that includes this exception-handling clause. The total length, in bytes, of the try block that includes this exception-handling clause. - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -630,32 +606,28 @@ The offset within the method, in bytes, of the try block that includes this exception-handling clause. An integer that represents the offset within the method, in bytes, of the try block that includes this exception-handling clause. - [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example located in the class topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example located in the class topic. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Reflection/ExceptionHandlingClauseOptions.xml b/xml/System.Reflection/ExceptionHandlingClauseOptions.xml index a6c6ccb2d23..fb849e4c2bf 100644 --- a/xml/System.Reflection/ExceptionHandlingClauseOptions.xml +++ b/xml/System.Reflection/ExceptionHandlingClauseOptions.xml @@ -52,33 +52,29 @@ Identifies kinds of exception-handling clauses. - object and call the method to obtain the method body. Use the property to obtain a list of objects. - + object and call the method to obtain the method body. Use the property to obtain a list of objects. + > [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and Microsoft intermediate language (MSIL) instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". + +## Examples + The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. + + + This code is part of a larger example provided for the class. -## Examples - The following code example defines a test method named `MethodBodyExample`, and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects and display their properties. - - - This code is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Reflection/FieldAttributes.xml b/xml/System.Reflection/FieldAttributes.xml index 7c9b11fcb44..e3364f4f2a6 100644 --- a/xml/System.Reflection/FieldAttributes.xml +++ b/xml/System.Reflection/FieldAttributes.xml @@ -72,28 +72,26 @@ Specifies flags that describe the attributes of a field. - diff --git a/xml/System.Reflection/FieldInfo.xml b/xml/System.Reflection/FieldInfo.xml index 7e87c54a3f9..b5fcf6a1b59 100644 --- a/xml/System.Reflection/FieldInfo.xml +++ b/xml/System.Reflection/FieldInfo.xml @@ -104,7 +104,6 @@ ## Examples The following example uses the method to get the field-related information from the class, and then displays field attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo/CPP/fieldinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/Overview/fieldinfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo/VB/fieldinfo.vb" id="Snippet1"::: @@ -217,7 +216,6 @@ ## Examples The following code example builds three fields and displays their field attributes. A `FieldAttributes` value can contain more than one attribute, such as both `Public` and `Literal`, as shown in the third field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldAttributes/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldAttributes Example/VB/source.vb" id="Snippet1"::: @@ -336,7 +334,6 @@ ## Examples The following example retrieves MyClass.MyField field information and displays the field associated with the field handle. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_FieldHandle/CPP/fieldinfo_fieldhandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/FieldHandle/fieldinfo_fieldhandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_FieldHandle/VB/fieldinfo_fieldhandle.vb" id="Snippet1"::: @@ -404,7 +401,6 @@ ## Examples The following example creates a field, gets its type and , and displays its . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/FieldType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.FieldType Example/VB/source.vb" id="Snippet1"::: @@ -490,7 +486,6 @@ ## Examples The following code example uses the method to get objects for the fields of a type, gets a structure for each field, and then retrieves the objects from the handles using this overload of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/CPP/fieldinfo_getfieldfromhandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/GetFieldFromHandle/fieldinfo_getfieldfromhandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_GetFieldFromHandle/VB/fieldinfo_getfieldfromhandle.vb" id="Snippet1"::: @@ -966,13 +961,11 @@ ## Examples The following example uses the method to retrieve the value of a static field. Note that the value of the `obj` argument is `null`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetFldVal/CPP/getfldval.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/GetValue/getfldval.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetFldVal/VB/getfldval.vb" id="Snippet1"::: The following example retrieves an array of objects that represents the fields of the `FieldsClass` type, and then calls the to display the value of each field for the `fieldsInst` object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_GetValue/CPP/fieldinfo_getvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/GetValue/fieldinfo_getvalue.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_GetValue/VB/fieldinfo_getvalue.vb" id="Snippet1"::: @@ -1108,7 +1101,6 @@ Note: In .NET for Win ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1178,7 +1170,6 @@ Note: In .NET for Win The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1250,7 +1241,6 @@ Note: In .NET for Win ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1323,7 +1313,6 @@ Note: In .NET for Win ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1397,7 +1386,6 @@ Note: In .NET for Win ## Examples In the following example, two fields are created. The second field is read-only, having no set accessor, and `IsInitOnly` is set to `true`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsInitOnly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsInitOnly Example/VB/source.vb" id="Snippet1"::: @@ -1539,7 +1527,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example gets the field information of the fields of MyClass, determines if the fields can be serialized, and displays the results. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsNotSerialized/CPP/fieldinfo_isnotserialized.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsNotSerialized/fieldinfo_isnotserialized.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_IsNotSerialized/VB/fieldinfo_isnotserialized.vb" id="Snippet1"::: @@ -1599,7 +1586,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example creates a class and displays the name, field and property value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/CPP/fieldinfo_ispinvokeimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsPinvokeImpl/fieldinfo_ispinvokeimpl.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_IsPInvokeImpl/VB/fieldinfo_ispinvokeimpl.vb" id="Snippet1"::: @@ -1671,7 +1657,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example returns a value indicating whether or not the field of the class is private. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsPrivate/CPP/fieldinfo_isprivate.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsPrivate/fieldinfo_isprivate.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_IsPrivate/VB/fieldinfo_isprivate.vb" id="Snippet1"::: @@ -1744,7 +1729,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example returns a value indicating whether or not the field of the class is public or private. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsPublic/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsPublic Example/VB/source.vb" id="Snippet1"::: @@ -2008,7 +1992,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example returns a value indicating whether or not the fields in the class contain a SpecialName attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_IsSpecialName/CPP/fieldinfo_isspecialname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetFields/fieldinfo_isspecialname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_IsSpecialName/VB/fieldinfo_isspecialname.vb" id="Snippet1"::: @@ -2080,7 +2063,6 @@ Myfieldb - B readonly field, IsInitOnly = True ## Examples The following example determines whether the specified field is static and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsStatic/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsStatic Example/VB/source.vb" id="Snippet1"::: @@ -2157,7 +2139,6 @@ Myfieldb - B static field; IsStatic - True ## Examples The following example determines whether the specified member is a field and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/MemberType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.MemberType Example/VB/source.vb" id="Snippet1"::: @@ -2377,7 +2358,6 @@ This method cannot be used to set values of static, init-only (`readonly` in C#) ## Examples The following example sets the value of a field, gets and displays the value, modifies the field, and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FieldInfo_SetValue/CPP/fieldinfo_setvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/SetValue/fieldinfo_setvalue.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FieldInfo_SetValue/VB/fieldinfo_setvalue.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/GenericParameterAttributes.xml b/xml/System.Reflection/GenericParameterAttributes.xml index d0a947714bc..16bba95587b 100644 --- a/xml/System.Reflection/GenericParameterAttributes.xml +++ b/xml/System.Reflection/GenericParameterAttributes.xml @@ -62,20 +62,19 @@ Describes the constraints on a generic type parameter of a generic type or method. - enumeration are divided into two groups, the variance group and the special constraints group. To test a value for variance flags, first perform a bitwise AND operation with VarianceMask. If the result is None, there are no variance flags. Similarly, use SpecialConstraintMask to test for constraint flags. + + + +## Examples + The following code example defines a generic type `Test` with two type parameters. The second type parameter has a base class constraint and a reference type constraint. When the program executes, the constraints are examined using the property and the method. -## Remarks - The members of the enumeration are divided into two groups, the variance group and the special constraints group. To test a value for variance flags, first perform a bitwise AND operation with VarianceMask. If the result is None, there are no variance flags. Similarly, use SpecialConstraintMask to test for constraint flags. - - - -## Examples - The following code example defines a generic type `Test` with two type parameters. The second type parameter has a base class constraint and a reference type constraint. When the program executes, the constraints are examined using the property and the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GenericParameterAttributes/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Reflection/IReflect.xml b/xml/System.Reflection/IReflect.xml index 9a360f849ae..2ad6514e6a3 100644 --- a/xml/System.Reflection/IReflect.xml +++ b/xml/System.Reflection/IReflect.xml @@ -52,11 +52,11 @@ Interoperates with the IDispatch interface. - interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the reflection methods. Implementing this interface enables a type to customize its behavior when the object is being accessed from COM as an `IDispatch` object. The class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. - + interface is used to interoperate with the [IDispatch interface](/windows/win32/api/oaidl/nn-oaidl-idispatch). defines a subset of the reflection methods. Implementing this interface enables a type to customize its behavior when the object is being accessed from COM as an `IDispatch` object. The class can be used to marshal an object that implements or as a COM `IDispatch` object, and vice versa. + ]]> @@ -173,11 +173,11 @@ Returns an array of objects that correspond to all fields of the current class. An array of objects containing all the field information for this reflection object that meets the search constraints specified in . - flag specifies that non-public methods are included in the search. The flag specifies that public methods are included in the search. - + flag specifies that non-public methods are included in the search. The flag specifies that public methods are included in the search. + ]]> @@ -238,11 +238,11 @@ Retrieves an array of objects corresponding to all public members or to all members that match a specified name. An array of objects matching the parameter. - method retrieves an array of objects by using the name and binding attribute that correspond to all public members or to all members that match a specified name. The case of the specified name is observed or ignored, as specified by . - + method retrieves an array of objects by using the name and binding attribute that correspond to all public members or to all members that match a specified name. The case of the specified name is observed or ignored, as specified by . + ]]> @@ -301,11 +301,11 @@ Retrieves an array of objects that correspond either to all public members or to all members of the current class. An array of objects containing all the member information for this reflection object. - objects by using the binding attribute that corresponds either to all public members or to all members of the current class. It returns an array of all of the members defined for this object. - + objects by using the binding attribute that corresponds either to all public members or to all members of the current class. It returns an array of all of the members defined for this object. + ]]> @@ -455,11 +455,11 @@ Retrieves a object corresponding to a specified method, using a array to choose from among overloaded methods. The requested method that matches all the specified parameters. - enum member, the kind of type conversion specified by the `binder` parameter, the overload, and the that describes the signature of the method. - + enum member, the kind of type conversion specified by the `binder` parameter, the overload, and the that describes the signature of the method. + ]]> The object implements multiple methods with the same name. @@ -518,11 +518,11 @@ Retrieves an array of objects with all public methods or all methods of the current class. An array of objects containing all the methods defined for this reflection object that meet the search constraints specified in . - @@ -726,11 +726,11 @@ Retrieves a object that corresponds to a specified property with specified search constraints. A object for the located property, if a property with the specified name was located in this reflection object, or if the property was not located. - object corresponding to a specified property under specified search constraints. A type array is used to choose from among overloaded methods. - + object corresponding to a specified property under specified search constraints. A type array is used to choose from among overloaded methods. + ]]> @@ -821,29 +821,28 @@ Invokes a specified member. The specified member. - [!NOTE] -> The array of parameter modifiers passed to the method must contain a single parameter modifier. Only the first parameter modifier is considered when determining which argument needs to be passed by reference when exposed to COM. +> The array of parameter modifiers passed to the method must contain a single parameter modifier. Only the first parameter modifier is considered when determining which argument needs to be passed by reference when exposed to COM. + + The binder finds all matching methods, in accordance with the type of binding requested (, , and so on). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder. After the method is selected, it is invoked, and accessibility is checked at that point. The search may control which set of methods is searched based upon the accessibility attribute associated with the method. selects the method to be invoked. The default binder selects the most specific match. + + Access restrictions are ignored for fully trusted code. That is, private constructors, methods, fields, and properties can be accessed and invoked through reflection whenever the code is fully trusted. + + + +## Examples + The following example obtains the value of the property. - The binder finds all matching methods, in accordance with the type of binding requested (, , and so on). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder. After the method is selected, it is invoked, and accessibility is checked at that point. The search may control which set of methods is searched based upon the accessibility attribute associated with the method. selects the method to be invoked. The default binder selects the most specific match. - - Access restrictions are ignored for fully trusted code. That is, private constructors, methods, fields, and properties can be accessed and invoked through reflection whenever the code is fully trusted. - - - -## Examples - The following example obtains the value of the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/IReflect/InvokeMember/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic IReflect.InvokeMember Example/VB/source.vb" id="Snippet1"::: + ]]> More than one argument is specified for a field . diff --git a/xml/System.Reflection/LocalVariableInfo.xml b/xml/System.Reflection/LocalVariableInfo.xml index b50e28efa27..989f6ff4732 100644 --- a/xml/System.Reflection/LocalVariableInfo.xml +++ b/xml/System.Reflection/LocalVariableInfo.xml @@ -70,34 +70,30 @@ Discovers the attributes of a local variable and provides access to local variable metadata. - property. Use the method to obtain the for a object. - + property. Use the method to obtain the for a object. + > [!NOTE] -> Local variable names are not persisted in metadata. In Microsoft intermediate language (MSIL), local variables are accessed by their position in the local variable signature. - - +> Local variable names are not persisted in metadata. In Microsoft intermediate language (MSIL), local variables are accessed by their position in the local variable signature. + + + +## Examples + The following example defines a test method named `MethodBodyExample`, and displays its local variable information. The method is used to obtain a object for the test method. The property is then used to obtain a list of objects and to display their types and index order. + + This code example is part of a larger example provided for the class. -## Examples - The following example defines a test method named `MethodBodyExample`, and displays its local variable information. The method is used to obtain a object for the test method. The property is then used to obtain a list of objects and to display their types and index order. - - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet3"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet6"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet6"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet6"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet6"::: + ]]> @@ -142,11 +138,11 @@ Initializes a new instance of the class. - objects. - + objects. + ]]> @@ -196,11 +192,11 @@ if the object referred to by the variable is pinned in memory; otherwise, . - @@ -249,11 +245,11 @@ Gets the index of the local variable within the method body. An integer value that represents the order of declaration of the local variable within the method body. - diff --git a/xml/System.Reflection/MemberInfo.xml b/xml/System.Reflection/MemberInfo.xml index 4dbe934f41b..76e1a0aa231 100644 --- a/xml/System.Reflection/MemberInfo.xml +++ b/xml/System.Reflection/MemberInfo.xml @@ -113,7 +113,6 @@ ## Examples This example shows how to use various reflection classes to analyze the metadata contained in an assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection/VB/Reflection.vb" id="Snippet1"::: @@ -426,7 +425,6 @@ ## Examples The following example defines a custom attribute and associates the attribute with `MyClass.MyMethod`, retrieves the attribute at run time, and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/CPP/memberinfo_getcustomattributes1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberInfo/GetCustomAttributes/memberinfo_getcustomattributes1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MemberInfo_GetCustomAttributes1/VB/memberinfo_getcustomattributes1.vb" id="Snippet1"::: @@ -803,7 +801,6 @@ For more information, see [How to use and debug assembly unloadability in .NET C ## Examples The following example determines whether the specified attribute is applied to the specified member. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/CPP/memberinfo_getcustomattribute_isdefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberInfo/IsDefined/memberinfo_getcustomattribute_isdefined.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MemberInfo_GetCustomAttribute_IsDefined/VB/memberinfo_getcustomattribute_isdefined.vb" id="Snippet1"::: @@ -869,7 +866,6 @@ For more information, see [How to use and debug assembly unloadability in .NET C ## Examples The following example displays the member name and type of a specified class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ConstructorInfo/MemberType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MemberInfo.MemberType Example/VB/source.vb" id="Snippet1"::: @@ -987,7 +983,6 @@ For more information, see [How to use and debug assembly unloadability in .NET C ## Examples The following code example declares a class that inherits and overrides . The example obtains objects for the class's `ToString` method and for the inherited method, and displays the names of the modules in which the two methods are declared. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberInfo/Module/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.MemberInfo.Module/VB/source.vb" id="Snippet1"::: @@ -1057,7 +1052,6 @@ For more information, see [How to use and debug assembly unloadability in .NET C ## Examples This example lists the `Name` and `DeclaringType` property of each member of the specified class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberInfo/Name/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MemberInfo.Name Example/VB/source.vb" id="Snippet1"::: @@ -1235,7 +1229,6 @@ For more information, see [How to use and debug assembly unloadability in .NET C ## Examples The following code example shows how the changes when the member is viewed from a obtained from type and from a obtained from the class itself, which inherits but does not override . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberInfo/ReflectedType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MemberInfo.ReflectedType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/MemberTypes.xml b/xml/System.Reflection/MemberTypes.xml index 7d587c39b4c..0477852b68f 100644 --- a/xml/System.Reflection/MemberTypes.xml +++ b/xml/System.Reflection/MemberTypes.xml @@ -72,50 +72,49 @@ Marks each type of member that is defined as a derived class of . - . + +- . + +- . + +- . + +- . + +- . + +- . + + To obtain the value for a type: + +1. Get a object that represents that type. + +2. Retrieve the value of the property. + + To get the values for the members of a type.: + +1. Get a object that represents that type. + +2. Retrieve the array that represents the members of that type by calling the method. + +3. Retrieve the value of the From the property for each member in the array. A `switch` statement in C# or `Select Case` statement in Visual Basic is typically used to process member types. + + matches CorTypeAttr as defined in the corhdr.h file. + + + +## Examples + The following example displays the names of the members of the class and their associated member types. -## Remarks - These enumeration values are returned by the following properties: - -- . - -- . - -- . - -- . - -- . - -- . - -- . - - To obtain the value for a type: - -1. Get a object that represents that type. - -2. Retrieve the value of the property. - - To get the values for the members of a type.: - -1. Get a object that represents that type. - -2. Retrieve the array that represents the members of that type by calling the method. - -3. Retrieve the value of the From the property for each member in the array. A `switch` statement in C# or `Select Case` statement in Visual Basic is typically used to process member types. - - matches CorTypeAttr as defined in the corhdr.h file. - - - -## Examples - The following example displays the names of the members of the class and their associated member types. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Reflection.MemberTypes/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MemberTypes/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Reflection.MemberTypes/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Reflection.MemberTypes/vb/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Reflection/MethodAttributes.xml b/xml/System.Reflection/MethodAttributes.xml index 85569a2afda..bb55cc1d468 100644 --- a/xml/System.Reflection/MethodAttributes.xml +++ b/xml/System.Reflection/MethodAttributes.xml @@ -72,15 +72,14 @@ Specifies flags for method attributes. These flags are defined in the corhdr.h file. - diff --git a/xml/System.Reflection/MethodBase.xml b/xml/System.Reflection/MethodBase.xml index ece55bab79c..07beb9307dd 100644 --- a/xml/System.Reflection/MethodBase.xml +++ b/xml/System.Reflection/MethodBase.xml @@ -205,7 +205,6 @@ ## Examples The following code example displays the attributes of the user-defined method Mymethod. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetFields/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/VB/source.vb" id="Snippet1"::: @@ -672,7 +671,6 @@ > [!NOTE] > Not all computer languages can generate clauses. The Visual Basic example shows a filter clause, using a Visual Basic `When` expression, which is omitted from the examples for other languages. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet1"::: @@ -885,7 +883,6 @@ ## Examples The following example defines a constructor in a dynamic assembly and then uses the method to display the method implementation flags that are set by default. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/CPP/constructorbuilder_getmodule_4.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/GetMethodImplementationFlags/constructorbuilder_getmodule_4.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConstructorBuilder_GetModule_4/VB/constructorbuilder_getmodule_4.vb" id="Snippet3"::: @@ -950,7 +947,6 @@ The example defines a delegate named `MyDelegate` and an event named `ev` of type `MyDelegate`. The code in the `Main` method discovers the event signature by getting the delegate type of the event, getting the `Invoke` method of the delegate type, and then retrieving and displaying the parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventArg/CPP/eventarg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/EventInfo/EventHandlerType/eventarg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventArg/VB/eventarg.vb" id="Snippet1"::: @@ -1094,7 +1090,6 @@ ## Examples The following code example demonstrates dynamic method lookup using reflection. Note that you cannot use the object from the base class to invoke the overridden method in the derived class, because late binding cannot resolve overrides. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/Invoke/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.Invoke1 Example/VB/source.vb" id="Snippet1"::: @@ -1221,7 +1216,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following example demonstrates all members of the class using an overload of . The private method `CanConvertFrom` finds compatible types for a given type. For another example of invoking members in a custom binding scenario, see [Dynamically Loading and Using Types](/dotnet/framework/reflection-and-codedom/dynamically-loading-and-using-types). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Binder_1/CPP/binder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Binder/Overview/binder.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Binder_1/VB/binder.vb" id="Snippet1"::: @@ -1306,7 +1300,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following example determines whether specified the method is abstract and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsAbstract/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsAbstract Example/VB/source.vb" id="Snippet1"::: @@ -1375,7 +1368,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1549,7 +1541,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1618,7 +1609,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1691,7 +1681,6 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1773,7 +1762,6 @@ If `IsVirtual` is `false` or `IsFinal` is `true`, then the method cannot be over ## Examples The following example displays `false` for `IsFinal`, which might lead you to think that MyMethod is overridable. The code prints `false` even though MyMethod is not marked `virtual` and thus cannot be overridden. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsFinal/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/VB/source.vb" id="Snippet1"::: @@ -1984,7 +1972,6 @@ The following table summarizes the invariant conditions for terms specific to ge ## Examples The following code example contains a base class with an overloaded method, and a derived class that hides one of the overloads. In the Visual Basic version of the code example, the property returns `false` for the member in the derived class. In the C# version of the code sample, the property returns `true` for the member in the derived class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/cpp/hide.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsHideBySig/hide.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.MethodBase.IsHideBySig/VB/hide.vb" id="Snippet1"::: @@ -2110,7 +2097,6 @@ The following table summarizes the invariant conditions for terms specific to ge ## Examples The following example uses the property to display a message that indicates whether the specified method is public. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsPublic/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsPublic Example/VB/source.vb" id="Snippet1"::: @@ -2374,7 +2360,6 @@ The following table summarizes the invariant conditions for terms specific to ge ## Examples This example shows a use of to filter internal or private members out of a list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsSpecialName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.IsSpecialName Example/VB/source.vb" id="Snippet1"::: @@ -2522,7 +2507,6 @@ If MethodInfo.IsVirtual AndAlso Not MethodInfo.IsFinal Then ## Examples The following example displays `false` for `IsFinal`, which might lead you to think that `MyMethod` is overridable. The code prints `false` even though `MyMethod` is not marked `virtual` and thus cannot be overridden. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodBase/IsFinal/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.IsVirtual Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/MethodBody.xml b/xml/System.Reflection/MethodBody.xml index 2e898306c7e..b414b6c7dcd 100644 --- a/xml/System.Reflection/MethodBody.xml +++ b/xml/System.Reflection/MethodBody.xml @@ -57,30 +57,29 @@ Provides access to the metadata and MSIL for the body of a method. - class provides access to information about the local variables and exception-handling clauses in a method body, and to the Microsoft intermediate language (MSIL) that makes up the method body. - - You can use the token-resolution methods of the module class, such as , , and , to resolve the tokens in the method body to objects, objects, and objects that provide detailed information about the types, methods, and fields accessed by the MSIL in the method body. - + class provides access to information about the local variables and exception-handling clauses in a method body, and to the Microsoft intermediate language (MSIL) that makes up the method body. + + You can use the token-resolution methods of the module class, such as , , and , to resolve the tokens in the method body to objects, objects, and objects that provide detailed information about the types, methods, and fields accessed by the MSIL in the method body. + > [!NOTE] > Parsing method bodies requires a thorough understanding of metadata and MSIL instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". + + To obtain a object for a given method, first obtain a object for the method, then call the object's method. + + + +## Examples + The following code example defines a test method named `MethodBodyExample` and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. + + The example uses the property to obtain a list of objects and then displays their types and index order. The property is used to obtain a list of exception-handling clauses. + - To obtain a object for a given method, first obtain a object for the method, then call the object's method. - - - -## Examples - The following code example defines a test method named `MethodBodyExample` and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. - - The example uses the property to obtain a list of objects and then displays their types and index order. The property is used to obtain a list of exception-handling clauses. - - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet1"::: + ]]> @@ -118,11 +117,11 @@ Initializes a new instance of the class. - objects. - + objects. + ]]> @@ -168,33 +167,29 @@ Gets a list that includes all the exception-handling clauses in the method body. An of objects representing the exception-handling clauses in the body of the method. - object contains information that identifies the try block with which it is associated. - + object contains information that identifies the try block with which it is associated. + > [!NOTE] > Working with exception-handling clauses requires a thorough understanding of metadata and MSIL instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - -## Examples - The following code example defines a test method named `MethodBodyExample` and displays information about its exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects. - - - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample` and displays information about its exception-handling clauses. The method is used to obtain a object for the test method. The property is used to obtain a list of objects. + + + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet7"::: + ]]> @@ -246,14 +241,14 @@ Returns the MSIL for the method body, as an array of bytes. An array of type that contains the MSIL for the method body. - , , and , to resolve the tokens in the method body to objects, objects, and objects that provide detailed information about the types, methods, and fields accessed by the MSIL in the method body. - + , , and , to resolve the tokens in the method body to objects, objects, and objects that provide detailed information about the types, methods, and fields accessed by the MSIL in the method body. + > [!NOTE] > Parsing method bodies requires a thorough understanding of metadata and MSIL instruction formats. Information can be found in the [Common Language Infrastructure (CLI) documentation](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), especially "Partition II: Metadata Definition and Semantics". - + ]]> @@ -302,27 +297,25 @@ if the method body contains code to initialize local variables to for reference types, or to the zero-initialized value for value types; otherwise, . - property refers to variables that are not explicitly initialized; that is, variables that are declared with syntax such as `int x;` in C# or `Dim x As Integer` in Visual Basic. - - Reference variables are initialized to `null` by default. Numeric variables are initialized to zero. - - - -## Examples - The following code example defines a test method named `MethodBodyExample` and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The and properties are displayed. - - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + property refers to variables that are not explicitly initialized; that is, variables that are declared with syntax such as `int x;` in C# or `Dim x As Integer` in Visual Basic. + + Reference variables are initialized to `null` by default. Numeric variables are initialized to zero. + + + +## Examples + The following code example defines a test method named `MethodBodyExample` and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The and properties are displayed. + + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: + ]]> @@ -368,14 +361,14 @@ Gets a metadata token for the signature that describes the local variables for the method in metadata. An integer that represents the metadata token. - property to obtain information about the method's local variables. - + property to obtain information about the method's local variables. + > [!NOTE] > Information about local variable signatures can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics". For more information, see [ECMA 335 Common Language Infrastructure (CLI)](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/). - + ]]> @@ -421,31 +414,27 @@ Gets the list of local variables declared in the method body. An of objects that describe the local variables declared in the method body. - property. - - - -## Examples - The following code example defines a test method named `MethodBodyExample` and displays its local variable information. The method is used to obtain a object for the test method. The property is used to obtain a list of objects. - - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + property. + + + +## Examples + The following code example defines a test method named `MethodBodyExample` and displays its local variable information. The method is used to obtain a object for the test method. The property is used to obtain a list of objects. + + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet3"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet6"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet6"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet6"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet6"::: + ]]> @@ -492,23 +481,21 @@ Gets the maximum number of items on the operand stack when the method is executing. The maximum number of items on the operand stack when the method is executing. - method is used to obtain a object for the test method. The and properties are displayed. - - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet2"::: + +## Examples + The following code example defines a test method named `MethodBodyExample` and displays its local variable information and exception-handling clauses. The method is used to obtain a object for the test method. The and properties are displayed. + + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodBody/cpp/source.cpp" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ExceptionHandlingClause/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodBody/VB/source.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Reflection/MethodInfo.xml b/xml/System.Reflection/MethodInfo.xml index e2688c1827d..21dde845f00 100644 --- a/xml/System.Reflection/MethodInfo.xml +++ b/xml/System.Reflection/MethodInfo.xml @@ -654,7 +654,6 @@ For a list of the invariant conditions for other terms used in generic reflectio This example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet8"::: @@ -757,13 +756,10 @@ End Class This example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet4"::: @@ -1190,7 +1186,6 @@ End Class - Displays properties of the constructed generic method. - Retrieves the generic method definition from the constructed method and compares it to the original definition. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet1"::: @@ -1273,7 +1268,6 @@ End Class ## Examples The following example displays the type of the specified member. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodInfo/MemberType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodInfo.MemberType Example/VB/source.vb" id="Snippet1"::: @@ -1504,7 +1498,6 @@ End Class ## Examples The following example displays the return type of the specified method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/MethodInfo/ReturnType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodInfo.ReturnType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/Module.xml b/xml/System.Reflection/Module.xml index 2ec4b4fd8c5..4a16980ccf2 100644 --- a/xml/System.Reflection/Module.xml +++ b/xml/System.Reflection/Module.xml @@ -231,7 +231,6 @@ ## Examples The following example displays the full name of the specified assembly in the specified module. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/Assembly/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.Assembly Example/VB/class1.vb" id="Snippet1"::: @@ -388,7 +387,6 @@ ## Examples The following example displays the module names that match the specified search criteria. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/FilterTypeName/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/VB/class1.vb" id="Snippet1"::: @@ -449,7 +447,6 @@ ## Examples The following example displays the module names that match the specified search criteria, ignoring the case. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/FilterTypeNameIgnoreCase/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeNameIgnoreCase Example/VB/class1.vb" id="Snippet1"::: @@ -534,7 +531,6 @@ ## Examples The following example demonstrates the `FindTypes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/FilterTypeName/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.FilterTypeName Example/VB/class1.vb" id="Snippet1"::: @@ -612,7 +608,6 @@ ## Examples The following example displays the fully qualified name of the specified module. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/FullyQualifiedName/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.FullyQualifiedName/VB/class1.vb" id="Snippet1"::: @@ -685,7 +680,6 @@ ## Examples The following example displays the module names that match the specified search criteria. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/GetCustomAttributes/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 1Arg Example/VB/class1.vb" id="Snippet1"::: @@ -749,7 +743,6 @@ ## Examples The following example displays the module names of the specified type that match the specified search criteria. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/GetCustomAttributes/class11.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.GetCustomAttributes 2Arg Example/VB/class1.vb" id="Snippet1"::: @@ -1811,7 +1804,6 @@ ## Examples The following example displays the name of a type in the specified module. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/GetType/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.GetType 1Arg Example/VB/class1.vb" id="Snippet1"::: @@ -1923,7 +1915,6 @@ ## Examples The following example displays the name of a type in the specified module, specifying `false` for the `ignoreCase` parameter so that case will not be ignored. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/GetType/class11.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.GetType 2Arg Example/VB/class1.vb" id="Snippet1"::: @@ -2034,7 +2025,6 @@ ## Examples The following example displays the name of a type in the specified module. The `throwOnError` and `ignoreCase` parameters are specified as `false`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/GetType/class12.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.GetType 3Arg Example/VB/class1.vb" id="Snippet1"::: @@ -2187,7 +2177,6 @@ ## Examples The following example demonstrates a use of the `IsDefined` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/IsDefined/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.IsDefined Example/VB/class1.vb" id="Snippet1"::: @@ -2253,7 +2242,6 @@ ## Examples The following example demonstrates a use of the `IsResource` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/IsResource/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.IsResource Example/VB/class1.vb" id="Snippet1"::: @@ -2540,7 +2528,6 @@ ## Examples This example shows the effect of the `ScopeName`, `FullyQualifiedName`, and `Name` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/Name/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Module.Name Example/VB/source.vb" id="Snippet1"::: @@ -3627,7 +3614,6 @@ ## Examples This example shows the effect of the `ScopeName`, `FullyQualifiedName`, and `Name` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/ScopeName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Module.ScopeName Example/VB/source.vb" id="Snippet1"::: @@ -4012,7 +3998,6 @@ ## Examples The following example demonstrates a use of the `ToString` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Module/ToString/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Reflection.Module.ToString Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/ParameterAttributes.xml b/xml/System.Reflection/ParameterAttributes.xml index 970d9f1e711..96f54fc6f51 100644 --- a/xml/System.Reflection/ParameterAttributes.xml +++ b/xml/System.Reflection/ParameterAttributes.xml @@ -72,22 +72,21 @@ Defines the attributes that can be associated with a parameter. These are defined in CorHdr.h. - diff --git a/xml/System.Reflection/ParameterInfo.xml b/xml/System.Reflection/ParameterInfo.xml index f5e95daeb0f..39c7c394ee6 100644 --- a/xml/System.Reflection/ParameterInfo.xml +++ b/xml/System.Reflection/ParameterInfo.xml @@ -125,7 +125,6 @@ ## Examples This example shows how to use various reflection classes to analyze the metadata contained in an assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection/VB/Reflection.vb" id="Snippet1"::: @@ -231,7 +230,6 @@ ## Examples The following example defines a method with three parameters. It uses the property to get the attributes of the second parameter and display them at the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ParameterInfo_Attributes1/CPP/parameterinfo_attributes1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/Attributes/parameterinfo_attributes1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ParameterInfo_Attributes1/VB/parameterinfo_attributes1.vb" id="Snippet1"::: @@ -593,7 +591,6 @@ When the example is run, it uses the method to retrieve the custom attributes that have been applied to all parameters of all methods in `MyClass`, and displays them at the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/GetCustomAttributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ParameterInfo_GetCustomAttributes/VB/source.vb" id="Snippet1"::: @@ -1049,7 +1046,6 @@ When the example is run, it uses the method to test all parameters of all methods in the example class. It then displays the parameters that have `MyAttribute` or `MyDerivedAttribute`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/CPP/ParameterInfo_GetCustomAttribute_IsDefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/IsDefined/parameterinfo_getcustomattribute_isdefined.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ParameterInfo_GetCustomAttribute_IsDefined/VB/parameterinfo_getcustomattribute_isdefined.vb" id="Snippet1"::: @@ -1131,7 +1127,6 @@ After executing `DefineMethod`, the example searches the assemblies that are currently loaded until it finds the dynamic assembly. It loads `MyType` from the assembly, gets a object for the `MyMethod` method, and examines the parameters. The example uses the , , and properties to display information about the parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/IsIn/parameterinfo_isin_isout_isoptional.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/VB/parameterinfo_isin_isout_isoptional.vb" id="Snippet1"::: @@ -1265,7 +1260,6 @@ After executing `DefineMethod`, the example searches the assemblies that are currently loaded until it finds the dynamic assembly. It loads `MyType` from the assembly, gets a object for the `MyMethod` method, and examines the parameters. The example uses the , , and properties to display information about the parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/CPP/ParameterInfo_IsIn_IsOut_IsOptional.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/IsIn/parameterinfo_isin_isout_isoptional.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ParameterInfo_IsIn_IsOut_IsOptional/VB/parameterinfo_isin_isout_isoptional.vb" id="Snippet1"::: @@ -1343,7 +1337,6 @@ After executing `DefineMethod`, the example searches the assemblies that are currently loaded until it finds the dynamic assembly. It loads `MyType` from the assembly, gets a object for the `MyMethod` method, and examines the parameters. The example uses the , , and properties to display information about the parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/IsOut/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ParameterInfo.IsOut Example/VB/source.vb" id="Snippet1"::: @@ -1631,7 +1624,6 @@ ## Examples The following example shows how to get objects for the parameters of a method, and then use the property to obtain the parameter names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/Name/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ParameterInfo.Name Example/VB/source.vb" id="Snippet1"::: @@ -1755,7 +1747,6 @@ ## Examples The following example shows how to get objects for the parameters of a method, and then use the property to display the type of each parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterInfo/ParameterType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ParameterInfo.ParameterType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/ParameterModifier.xml b/xml/System.Reflection/ParameterModifier.xml index f4788062fd2..fc79c360af8 100644 --- a/xml/System.Reflection/ParameterModifier.xml +++ b/xml/System.Reflection/ParameterModifier.xml @@ -74,20 +74,19 @@ Attaches a modifier to parameters so that binding can work with parameter signatures in which the types have been modified. - structure is used with the method overload when passing parameters by reference to a COM component that is accessed late bound. The parameters that are to be passed by reference are specified by a single structure, which must be passed in an array containing a single element. The single structure in this array must be initialized with the number of parameters in the member that is to be invoked. To indicate which of these parameters are passed by reference, set the value of the property (the indexer in C#) to `true` for the index number corresponding to the zero-based position of the parameter. + + + +## Examples + The following code example shows this for a member that has three string arguments, the first and third of which are passed by reference. Assume that a variable named `obj` contains a reference to the COM object. -## Remarks - The structure is used with the method overload when passing parameters by reference to a COM component that is accessed late bound. The parameters that are to be passed by reference are specified by a single structure, which must be passed in an array containing a single element. The single structure in this array must be initialized with the number of parameters in the member that is to be invoked. To indicate which of these parameters are passed by reference, set the value of the property (the indexer in C#) to `true` for the index number corresponding to the zero-based position of the parameter. - - - -## Examples - The following code example shows this for a member that has three string arguments, the first and third of which are passed by reference. Assume that a variable named `obj` contains a reference to the COM object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.reflection.parametermodifier/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/ParameterModifier/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.reflection.parametermodifier/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.reflection.parametermodifier/vb/source.vb" id="Snippet1"::: + ]]> @@ -187,11 +186,11 @@ if the parameter at this index position is to be modified by this ; otherwise, . - diff --git a/xml/System.Reflection/PropertyAttributes.xml b/xml/System.Reflection/PropertyAttributes.xml index b62f955117a..3138f529f5d 100644 --- a/xml/System.Reflection/PropertyAttributes.xml +++ b/xml/System.Reflection/PropertyAttributes.xml @@ -72,22 +72,21 @@ Defines the attributes that can be associated with a property. These attribute values are defined in corhdr.h. - enumerated value. Note that the read-only property has no setter and thus cannot be changed by.`Caption = statement`. -## Remarks - To get the `PropertyAttributes`, first get the class `Type`. From the `Type`, get the `PropertyInfo`. From the `PropertyInfo`, get the `Attributes`. - - The enumerated value is a number representing the bitwise OR of the attributes implemented on the method. - - - -## Examples - The following example builds three properties and displays the enumerated value. Note that the read-only property has no setter and thus cannot be changed by.`Caption = statement`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyAttributes/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyAttributes Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Reflection/PropertyInfo.xml b/xml/System.Reflection/PropertyInfo.xml index 3b636fe94cf..bfec937c51c 100644 --- a/xml/System.Reflection/PropertyInfo.xml +++ b/xml/System.Reflection/PropertyInfo.xml @@ -118,7 +118,6 @@ > [!NOTE] > This example generates about 55,000 lines of data, which you can redirect to a text file at the command prompt, as follows: **example.exe > propertyinfo.txt** - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Reflection/VB/Reflection.vb" id="Snippet1"::: @@ -303,7 +302,6 @@ ## Examples The following example defines two properties. The first property is readable and the `CanRead` property is `true`. The second property is not readable (there is no get accessor), and the `CanRead` property is `false`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/CanRead/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.CanRead Example/VB/source.vb" id="Snippet1"::: @@ -378,7 +376,6 @@ ## Examples The following example defines two properties. The first property is writable and the `CanWrite` property is `true`. The second property is not writable (there is no `set` accessor), and the `CanWrite` property is `false`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/CanWrite/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.CanWrite Example/VB/source.vb" id="Snippet1"::: @@ -794,7 +791,6 @@ ## Examples The following example displays the public or non-public `get` accessor for the specified property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/GetGetMethod/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.GetGetMethod1 Example/VB/source.vb" id="Snippet1"::: @@ -913,7 +909,6 @@ ## Examples The following example displays the index parameters of the specified property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/GetIndexParameters/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.GetIndexParameters Example/VB/source.vb" id="Snippet1"::: @@ -1325,7 +1320,6 @@ ## Examples The following example displays the `set` accessor for the specified property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/GetSetMethod/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.GetSetMethod1 Example/VB/source.vb" id="Snippet1"::: @@ -1772,7 +1766,6 @@ Console.WriteLine("CurrCult: " + ## Examples The following example displays the type of the specified member. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/MemberType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PropertyInfo.MemberType Example/VB/source.vb" id="Snippet1"::: @@ -2105,7 +2098,6 @@ Console.WriteLine("CurrCult: " + ## Examples The following example declares a class named `Example` with one `static` (`Shared` in Visual Basic) and one instance property. The example uses the method to change the original property values and displays the original and final values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/example2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/SetValue/example2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PropertyInfo.SetValue/vb/example2.vb" id="Snippet2"::: @@ -2208,7 +2200,6 @@ Note: In Encapsulates access to a public or private key pair used to sign strong name assemblies. - @@ -249,11 +248,11 @@ A string containing the key pair. Initializes a new instance of the class, building the key pair from a . - @@ -317,11 +316,11 @@ A object that contains contextual information about the source or destination. Initializes a new instance of the class, building the key pair from serialized data. - .NET Core and .NET 5+ only: In all cases. From 86e66647ca56634b8048d62dc8ca28fab0f21587 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:40:25 -0700 Subject: [PATCH 2/2] Delete C++ snippets from System.NET APIs (#11399) --- .../CPP/authenticationmanager_unregister2.cpp | 63 - .../CPP/authorization_constructor3.cpp | 104 -- .../CPP/authorization_protectionrealm.cpp | 192 --- .../CPP/source.cpp | 25 - .../Classic Dns Example/CPP/source.cpp | 20 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 16 - .../CPP/source.cpp | 23 - .../CPP/source.cpp | 25 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 36 - .../CPP/source.cpp | 20 - .../CPP/source.cpp | 53 - .../CPP/source.cpp | 17 - .../CPP/source.cpp | 24 - .../CPP/source.cpp | 34 - .../CPP/source.cpp | 62 - .../CPP/source.cpp | 32 - .../CPP/source.cpp | 30 - .../CPP/source.cpp | 106 -- .../Classic TcpListenerExample/CPP/source.cpp | 83 -- .../CPP/source.cpp | 38 - .../CPP/source.cpp | 280 ----- .../Classic UdpClientExample/CPP/source.cpp | 45 - .../Classic WebProxy Example/CPP/source.cpp | 22 - .../Classic WebRequest Example/CPP/source.cpp | 24 - .../CPP/source.cpp | 15 - .../CPP/source.cpp | 248 ---- .../CPP/CookieCollection_Item_1.cpp | 147 --- .../CPP/CookieCollection_Item_2.cpp | 143 --- .../CPP/credentialcache_add_remove.cpp | 84 -- .../credentialcache_defaultcredentials.cpp | 82 -- .../CPP/credentialcache_getcredential.cpp | 86 -- .../CPP/credentialcache_getenumerator.cpp | 92 -- .../CPP/dnspermission_constructor.cpp | 69 -- .../CPP/dnspermission_copy.cpp | 67 - .../CPP/dnspermission_fromxml.cpp | 95 -- .../CPP/dnspermission_issubsetof.cpp | 84 -- .../CPP/dnspermission_isunrestricted.cpp | 73 -- .../CPP/dns_begin_endresolve.cpp | 80 -- .../CPP/dns_gethostbyaddress_ipaddress.cpp | 80 -- .../CPP/dns_gethostbyname.cpp | 73 -- .../Dns_GetHostName/CPP/dns_gethostname.cpp | 45 - .../Dns_Resolve/CPP/dns_resolve.cpp | 84 -- .../CPP/filewebrequest_contentlength.cpp | 72 -- .../CPP/filewebrequest_reqbeginend.cpp | 118 -- .../CPP/filewebrequest_resbeginend.cpp | 105 -- .../CPP/filewebresponse_close.cpp | 58 - ...ewebresponse_contentlength_contenttype.cpp | 56 - .../CPP/filewebresponse_getresponsestream.cpp | 77 -- .../CPP/filewebresponse_headers.cpp | 57 - .../CPP/filewebresponse_responseuri.cpp | 56 - .../CPP/httpversion_version10.cpp | 49 - .../CPP/httpwebrequest_accept.cpp | 92 -- .../CPP/httpwebrequest_allowautoredirect.cpp | 60 - ...tpwebrequest_allowwritestreambuffering.cpp | 81 -- .../httpwebrequest_begingetrequeststream.cpp | 97 -- .../CPP/httpwebrequest_connection.cpp | 94 -- .../CPP/httpwebrequest_contentlength.cpp | 102 -- .../CPP/httpwebrequest_headers.cpp | 57 - .../CPP/httpwebrequest_ifmodifiedsince.cpp | 90 -- .../CPP/httpwebrequest_pipelined.cpp | 86 -- .../CPP/httpwebrequest_protocolversion.cpp | 67 - .../CPP/httpwebrequest_referer.cpp | 89 -- .../CPP/httpwebrequest_sendchunked.cpp | 112 -- .../CPP/httpwebrequest_timeout.cpp | 61 - .../CPP/httpwebrequest_useragent.cpp | 58 - .../CPP/httpwebresponse_close.cpp | 52 - .../CPP/source.cpp | 82 -- .../CPP/httpwebresponse_getresponseheader.cpp | 70 -- .../CPP/httpwebresponse_getresponsestream.cpp | 73 -- .../CPP/httpwebresponse_headers.cpp | 61 - .../CPP/httpwebresponse_lastmodified.cpp | 67 - .../CPP/httpwebresponse_method_server.cpp | 59 - .../CPP/httpwebresponse_protocolversion.cpp | 59 - .../CPP/httpwebresponse_responseuri.cpp | 63 - ...bresponse_statuscode_statusdescription.cpp | 56 - .../CPP/httpwebrequest_haveresponse.cpp | 78 -- .../CPP/httpwebrequest_proxy.cpp | 110 -- .../ICredential/CPP/icredential.cpp | 125 -- .../CPP/ipaddress_broadcast_loopback.cpp | 33 - .../CPP/ipaddress_networktohost.cpp | 87 -- .../IPAddress_None/CPP/ipaddress_none.cpp | 22 - .../CPP/ipendpoint_properties.cpp | 123 -- .../CPP/iphostentry_addresslist.cpp | 59 - .../CPP/iwebproxy_interface.cpp | 87 -- .../NCLAutoProxy/CPP/proxy.cpp | 235 ---- .../NCLCookies/CPP/cookiessnippets.cpp | 77 -- .../NCLEmptyWebProxy/CPP/test.cpp | 31 - .../NCLFtpAsync/CPP/async.cpp | 227 ---- .../NCLFtpClient/CPP/ftptests.cpp | 842 ------------- .../NCLMailSync/CPP/NclMailSync.cpp | 1082 ----------------- .../NCLNetInfo2/CPP/networkexamples.cpp | 1010 --------------- .../NCLNetInfoReport/CPP/netinfo.cpp | 603 --------- .../CPP/NCLPhysicalAddress.cpp | 140 --- .../NCLPingSampler/CPP/pingtest.cpp | 249 ---- .../NCLResponse1/CPP/httpwebrequest1.cpp | 51 - .../NCLServicePoint/CPP/nclservicepoint.cpp | 88 -- .../NCLSimpleCache/CPP/NCLSimpleCache.cpp | 274 ----- .../CPP/nclsocketenhancements.cpp | 713 ----------- .../CPP/iocontrolserver.cpp | 68 -- .../NCLSocketIoControl1/CPP/iocontrolcode.cpp | 70 -- .../NCLTcpClientSync/CPP/tcpclient.cpp | 36 - .../NCLWebProxy/CPP/nclwebproxy.cpp | 186 --- .../NCLWebRequestSimple/CPP/webrequestget.cpp | 45 - .../CPP/source.cpp | 40 - .../NclMailASync/cpp/mailasync.cpp | 94 -- .../NclNetAddressChanged1/CPP/changed.cpp | 27 - .../NclPingAsync/CPP/asyncping.cpp | 115 -- .../NclPingSync/CPP/syncping.cpp | 48 - .../NclSslClientSync/CPP/clientsync.cpp | 260 ---- .../CPP/NclSslServerAsync.cpp | 265 ---- .../NclSslServerSync/CPP/NclSslServerSync.cpp | 235 ---- .../NclTcpServerSync/cpp/tcplistener.cpp | 39 - .../CPP/networkcredential_constructor2.cpp | 67 - .../CPP/networkcredential_getcredential.cpp | 68 -- ...orkcredential_username_password_domain.cpp | 74 -- .../CPP/source.cpp | 51 - .../CPP/source.cpp | 108 -- .../SelectModeExample/CPP/source.cpp | 65 - .../SocketPropertyTester/CPP/class1.cpp | 105 -- .../Socket_Select/CPP/source.cpp | 75 -- .../Socket_Send_Receive/CPP/source.cpp | 128 -- .../Socket_Socket_Options/CPP/source.cpp | 105 -- .../Socket_Sync_Send_Receive/CPP/source.cpp | 449 ------- .../CPP/custombasicauthentication.cpp | 355 ------ .../System.Net.Dns/CPP/dnsnewmethods.cpp | 145 --- .../CPP/getresponse.cpp | 120 -- .../CPP/getrequeststream.cpp | 134 -- .../CPP/noneanyloopback.cpp | 140 --- .../CPP/isloopback.cpp | 75 -- .../System.Net.IPAddress.Parse/CPP/parse.cpp | 73 -- .../System.Net.IPAddress/CPP/ipaddress.cpp | 142 --- .../System.Net.IPEndPoint/CPP/ipendpoint.cpp | 230 ---- .../CPP/servicepoint.cpp | 203 ---- .../cpp/servicepoint.cpp | 241 ---- .../CPP/custombasicauthentication.cpp | 344 ------ .../CPP/listener.cpp | 130 -- .../CPP/sender.cpp | 107 -- .../CPP/beginconnect.cpp | 128 -- .../CPP/sendgeneric.cpp | 175 --- .../CPP/tcpclient.cpp | 118 -- .../CPP/newtcpclient.cpp | 125 -- .../CPP/tcpserver.cpp | 226 ---- .../cpp/tcpserver.cpp | 150 --- .../CPP/joinmulticastgroup.cpp | 326 ----- .../CPP/newudpclient.cpp | 88 -- .../cpp/asyncudp.cpp | 261 ---- .../CPP/source.cpp | 44 - .../CPP/webexception_constructor1.cpp | 63 - .../CPP/webexception_constructor2.cpp | 62 - .../CPP/webexception_constructor3.cpp | 62 - .../CPP/webexception_constructor4.cpp | 64 - .../CPP/webexception_constructor5.cpp | 117 -- .../CPP/webexception_status_response.cpp | 40 - .../CPP/webheadercollection_add.cpp | 67 - .../CPP/webheadercollection_getvalues_1.cpp | 58 - .../CPP/webheadercollection_isrestricted.cpp | 49 - .../CPP/webheadercollection_remove.cpp | 79 -- .../CPP/webheadercollection_set.cpp | 65 - .../CPP/webrequest_begingetrequest.cpp | 92 -- .../CPP/webrequest_contenttype.cpp | 95 -- .../CPP/webrequest_create.cpp | 60 - .../CPP/webrequest_headers.cpp | 44 - .../WebRequest_Proxy/CPP/webrequest_proxy.cpp | 108 -- .../CPP/webrequest_requesturi.cpp | 49 - .../CPP/webrequest_timeout.cpp | 66 - .../CPP/webresponse_close.cpp | 58 - .../CPP/webresponse_contentlength_type.cpp | 59 - .../CPP/webresponse_getresponsestream.cpp | 81 -- .../CPP/webresponse_headers.cpp | 64 - .../CPP/webresponse_responseuri.cpp | 67 - .../CPP/dnspermission_union_intersect.cpp | 97 -- xml/System.Net.Cache/HttpCacheAgeControl.xml | 23 +- .../HttpRequestCacheLevel.xml | 35 +- .../HttpRequestCachePolicy.xml | 361 +++--- xml/System.Net.Cache/RequestCacheLevel.xml | 31 +- xml/System.Net.Cache/RequestCachePolicy.xml | 129 +- xml/System.Net.Mail/Attachment.xml | 8 - xml/System.Net.Mail/AttachmentCollection.xml | 41 +- xml/System.Net.Mail/MailAddress.xml | 409 +++---- xml/System.Net.Mail/MailAddressCollection.xml | 62 +- xml/System.Net.Mail/MailMessage.xml | 91 +- .../SendCompletedEventHandler.xml | 23 +- xml/System.Net.Mail/SmtpAccess.xml | 23 +- xml/System.Net.Mail/SmtpClient.xml | 13 - xml/System.Net.Mail/SmtpException.xml | 189 ++- .../SmtpFailedRecipientsException.xml | 43 +- xml/System.Net.Mail/SmtpStatusCode.xml | 1 - xml/System.Net.Mime/ContentDisposition.xml | 358 +++--- xml/System.Net.Mime/ContentType.xml | 289 +++-- xml/System.Net.Mime/DispositionTypeNames.xml | 53 +- xml/System.Net.Mime/TransferEncoding.xml | 31 +- .../DuplicateAddressDetectionState.xml | 27 +- .../IPAddressInformation.xml | 93 +- .../IPGlobalProperties.xml | 574 +++++---- .../IPGlobalStatistics.xml | 546 ++++----- .../IPInterfaceProperties.xml | 290 +++-- .../IPStatus.xml | 29 +- .../IPv4InterfaceProperties.xml | 212 ++-- .../IPv6InterfaceProperties.xml | 89 +- .../IcmpV4Statistics.xml | 697 +++++------ .../IcmpV6Statistics.xml | 851 +++++++------ .../NetworkChange.xml | 66 +- .../NetworkInformationAccess.xml | 23 +- .../NetworkInterface.xml | 12 - .../NetworkInterfaceComponent.xml | 23 +- .../OperationalStatus.xml | 23 +- .../PhysicalAddress.xml | 7 - xml/System.Net.NetworkInformation/Ping.xml | 12 - .../PingCompletedEventArgs.xml | 48 +- .../PingCompletedEventHandler.xml | 23 +- .../PingOptions.xml | 157 ++- .../PingReply.xml | 170 ++- .../PrefixOrigin.xml | 27 +- .../SuffixOrigin.xml | 27 +- .../TcpConnectionInformation.xml | 68 +- .../TcpState.xml | 23 +- .../TcpStatistics.xml | 369 +++--- .../UdpStatistics.xml | 152 ++- .../AuthenticationLevel.xml | 27 +- .../LocalCertificateSelectionCallback.xml | 32 +- .../RemoteCertificateValidationCallback.xml | 38 +- xml/System.Net.Security/SslStream.xml | 34 - xml/System.Net.Sockets/AddressFamily.xml | 23 +- xml/System.Net.Sockets/IOControlCode.xml | 23 +- .../IPv6MulticastOption.xml | 5 - xml/System.Net.Sockets/LingerOption.xml | 163 ++- xml/System.Net.Sockets/MulticastOption.xml | 5 - xml/System.Net.Sockets/NetworkStream.xml | 5 - xml/System.Net.Sockets/SelectMode.xml | 23 +- xml/System.Net.Sockets/Socket.xml | 62 - xml/System.Net.Sockets/SocketFlags.xml | 13 +- xml/System.Net.Sockets/SocketOptionLevel.xml | 27 +- xml/System.Net.Sockets/SocketOptionName.xml | 23 +- xml/System.Net.Sockets/SocketType.xml | 27 +- xml/System.Net.Sockets/TcpClient.xml | 20 - xml/System.Net.Sockets/TcpListener.xml | 636 +++++----- .../TransmitFileOptions.xml | 25 +- xml/System.Net.Sockets/UdpClient.xml | 36 - xml/System.Net/AuthenticationManager.xml | 243 ++-- xml/System.Net/Authorization.xml | 191 ++- xml/System.Net/Cookie.xml | 15 - xml/System.Net/CookieCollection.xml | 2 - xml/System.Net/CredentialCache.xml | 8 - xml/System.Net/Dns.xml | 664 +++++----- xml/System.Net/DnsPermission.xml | 208 ++-- .../DownloadDataCompletedEventArgs.xml | 57 +- .../DownloadDataCompletedEventHandler.xml | 32 +- .../DownloadProgressChangedEventArgs.xml | 3 - .../DownloadProgressChangedEventHandler.xml | 1 - .../DownloadStringCompletedEventArgs.xml | 57 +- .../DownloadStringCompletedEventHandler.xml | 32 +- xml/System.Net/FileWebRequest.xml | 401 +++--- xml/System.Net/FileWebResponse.xml | 212 ++-- xml/System.Net/FtpStatusCode.xml | 27 +- xml/System.Net/FtpWebRequest.xml | 22 - xml/System.Net/FtpWebResponse.xml | 319 +++-- xml/System.Net/GlobalProxySelection.xml | 81 +- xml/System.Net/HttpVersion.xml | 21 +- xml/System.Net/HttpWebRequest.xml | 38 +- xml/System.Net/HttpWebResponse.xml | 17 - xml/System.Net/IAuthenticationModule.xml | 131 +- xml/System.Net/ICredentialPolicy.xml | 49 +- xml/System.Net/ICredentials.xml | 48 +- xml/System.Net/IPAddress.xml | 15 - xml/System.Net/IPEndPoint.xml | 243 ++-- xml/System.Net/IPHostEntry.xml | 67 +- xml/System.Net/IWebProxy.xml | 81 +- xml/System.Net/NetworkCredential.xml | 8 +- xml/System.Net/OpenReadCompletedEventArgs.xml | 57 +- .../OpenReadCompletedEventHandler.xml | 32 +- .../OpenWriteCompletedEventArgs.xml | 57 +- .../OpenWriteCompletedEventHandler.xml | 32 +- xml/System.Net/ServicePoint.xml | 15 - xml/System.Net/ServicePointManager.xml | 12 - xml/System.Net/SocketAddress.xml | 1 - .../UploadDataCompletedEventArgs.xml | 57 +- .../UploadDataCompletedEventHandler.xml | 32 +- .../UploadFileCompletedEventArgs.xml | 57 +- .../UploadFileCompletedEventHandler.xml | 32 +- .../UploadStringCompletedEventArgs.xml | 57 +- .../UploadStringCompletedEventHandler.xml | 32 +- xml/System.Net/WebException.xml | 7 - xml/System.Net/WebHeaderCollection.xml | 7 - xml/System.Net/WebProxy.xml | 593 +++++---- xml/System.Net/WebRequest.xml | 19 - xml/System.Net/WebResponse.xml | 8 - 288 files changed, 5816 insertions(+), 27094 deletions(-) delete mode 100644 snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp delete mode 100644 snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp diff --git a/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp b/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp deleted file mode 100644 index eaec1a8cfc9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System.Net.AuthenticationManager.UnRegister(String). -// System.Net.AuthenticationManager.Register. -// Grouping Clause : 1,3 AND 2,3. - -/*This program demonstrates the 'UnRegister(String)' and 'Register' methods of -'AuthenticationManager' class. It gets all the authentication modules registered with the system into an -IEnumerator instance ,unregisters the first authentication module and displays to show that it was -unregistered. Then registers the same module back again and displays all the modules again.*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void DisplayAllModules() -{ - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\n\tThe following modules are now registered with the system:" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\n\t\tModule : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t\t\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } -} -// - -int main() -{ - try - { -// -// - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - // Display all the modules that are already registered with the system. - DisplayAllModules(); - registeredModules->Reset(); - registeredModules->MoveNext(); - // Get the first Authentication module registered with the system. - IAuthenticationModule^ authenticationModule1 = dynamic_cast(registeredModules->Current); - // Call the UnRegister() method to unregister the first authentication module from the system. - String^ authenticationScheme = authenticationModule1->AuthenticationType; - AuthenticationManager::Unregister( authenticationScheme ); - Console::WriteLine( "\nSuccessfully unregistered '{0}'.", authenticationModule1 ); - // Display all modules to see that the module was unregistered. - DisplayAllModules(); -// - // Calling 'Register()' method to register 'authenticationModule1' module back again. - AuthenticationManager::Register( authenticationModule1 ); - Console::WriteLine( "\nSuccessfully re-registered '{0}'.", authenticationModule1 ); - // Display the modules to verify that 'authenticationModule1' has been registered back again. - DisplayAllModules(); -// - Console::WriteLine( "Press any key to continue" ); - Console::ReadLine(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following Exception was raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp b/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp deleted file mode 100644 index 9d25d5c5604..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp +++ /dev/null @@ -1,104 +0,0 @@ - - -// System::Net::Authorization::Authorization(String*, bool, String*) -/* This program demonstrates the contructor 'Authorization(String*, bool, String*)' of the authorization -* class. -* -* We implement the interface S"IAuthenticationModule*" to make CloneBasic which is a custom authentication module. -* The custom authentication module encodes username and password as base64 strings and then returns -* back an authorization instance. This authorization is internally used by the HttpWebRequest for -* authentication. -* * -* Please Note : This program has to be compiled as a dll. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; - -namespace CloneBasicAuthentication -{ - public ref class CloneBasic: public IAuthenticationModule - { - private: - String^ m_authenticationType; - bool m_canPreAuthenticate; - - public: - CloneBasic() - { - m_authenticationType = "CloneBasic"; - m_canPreAuthenticate = false; - } - - property String^ AuthenticationType - { - virtual String^ get() - { - return m_authenticationType; - } - } - - property bool CanPreAuthenticate - { - virtual bool get() - { - return m_canPreAuthenticate; - } - } - - // - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - try - { - String^ message; - - // Check if Challenge String* was raised by a site which requires CloneBasic authentication. - if ( (challenge == nullptr) || ( !challenge->StartsWith( "CloneBasic" )) ) - return nullptr; - NetworkCredential^ myCredentials; - if ( dynamic_cast(credentials) == nullptr ) - { - myCredentials = credentials->GetCredential( request->RequestUri, "CloneBasic" ); - if ( myCredentials == nullptr ) - return nullptr; - } - else - myCredentials = dynamic_cast(credentials); - - // Message encryption scheme : - // a)Concatenate username and password seperated by space; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain our encoded authorization message. - message = String::Concat( myCredentials->UserName, " ", myCredentials->Password ); - - // Apply AsciiEncoding to our user name and password to obtain it as an array of bytes. - Encoding^ asciiEncoding = Encoding::ASCII; - array^byteArray = gcnew array(asciiEncoding->GetByteCount( message )); - byteArray = asciiEncoding->GetBytes( message ); - - // Perform Base64 transform. - message = Convert::ToBase64String( byteArray ); - - // The following overloaded contructor sets the 'Message' property of authorization to the base64 String*; - // that we just formed and it also sets the 'Complete' property to true and the connection group id; - // to the domain of the NetworkCredential Object*. - Authorization^ myAuthorization = gcnew Authorization( String::Concat( "CloneBasic ", message, true, request->ConnectionGroupName ) ); - return myAuthorization; - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Raised ...: {0}", e->Message ); - return nullptr; - } - } - // - - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } - }; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp b/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp deleted file mode 100644 index 6f0a633e81e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp +++ /dev/null @@ -1,192 +0,0 @@ - - -// System::Net::Authorization::Authorization(String*, bool);System::Net::Authorization::ProtectionRealm -/* This program demonstrates the 'ProtectionRealm' property and 'Authorization(String*, bool)' constructor of -the S"Authorization" class. The S"IAuthenticationModule*" interface is implemented in 'CloneBasic' to make -it a custom authentication module. The custom authentication module encodes username and password as -base64 strings and then returns back an 'Authorization' instance. The 'Authorization' instance encapsulates -a list of Uri's for which it is applicable using the S"ProtectionRealm" property. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -void GetPage( String^ url, String^ username, String^ passwd ) -{ - try - { - String^ challenge = nullptr; - HttpWebRequest^ myHttpWebRequest = nullptr; - try - { - // Create a 'HttpWebRequest' Object* for the above 'url'. - myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // The following method call throws the 'WebException'. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Release resources of response Object*. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - for ( int i = 0; i < e->Response->Headers->Count; ++i ) - - // Retrieve the challenge String* from the header S"WWW-Authenticate". - if ( (String::Compare( e->Response->Headers->Keys[ i ], "WWW-Authenticate", true ) == 0) ) - challenge = e->Response->Headers[ i ]; - } - - if ( challenge != nullptr ) - { - // Challenge was raised by the client.Declare your credentials. - NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); - - // Pass the challenge , 'NetworkCredential' Object* and the 'HttpWebRequest' Object* to the - // 'Authenticate' method of the S"AuthenticationManager" to retrieve an S"Authorization" ; - // instance. - Authorization^ urlAuthorization = AuthenticationManager::Authenticate( challenge, myHttpWebRequest, myCredentials ); - if ( urlAuthorization != nullptr ) - { - Console::WriteLine( "\nSuccessfully Created 'Authorization' object with authorization Message:\n \" {0}\"", urlAuthorization->Message ); - Console::WriteLine( "\n\nThis authorization is valid for the following Uri's:" ); - int count = 0; - System::Collections::IEnumerator^ myEnum = urlAuthorization->ProtectionRealm->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ uri = safe_cast(myEnum->Current); - ++count; - Console::WriteLine( "\nUri->Item[ {0}]: {1}", count, uri ); - } - } - else - Console::WriteLine( "\nAuthorization Object* was returned as 0. Please check if site accepts 'CloneBasic' authentication" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n The following exception was raised : {0}", e->Message ); - } -} - -void PrintUsage() -{ - Console::WriteLine( "\r\nUsage: Try a site which requires CloneBasic(custom made) authentication as below" ); - Console::WriteLine( " Authorization_ProtectionRealm URLname username password" ); - Console::WriteLine( "\nExample:" ); - Console::WriteLine( "\n Authorization_ProtectionRealm http://www.microsoft.com/net/ george george123" ); -} - -// The 'CloneBasic' authentication module class implements 'IAuthenticationModule*'. -public ref class CloneBasic: public IAuthenticationModule -{ -private: - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - CloneBasic() - { - m_authenticationType = "CloneBasic"; - m_canPreAuthenticate = false; - } - - property String^ AuthenticationType - { - virtual String^ get() - { - return m_authenticationType; - } - } - - property bool CanPreAuthenticate - { - virtual bool get() - { - return m_canPreAuthenticate; - } - } - - // - // - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - try - { - String^ message; - - // Check if Challenge String* was raised by a site which requires 'CloneBasic' authentication. - if ( (challenge == nullptr) || ( !challenge->StartsWith( "CloneBasic" )) ) - return nullptr; - NetworkCredential^ myCredentials; - if ( dynamic_cast(credentials) == nullptr ) - { - myCredentials = credentials->GetCredential( request->RequestUri, "CloneBasic" ); - if ( myCredentials == nullptr ) - return nullptr; - } - else - myCredentials = dynamic_cast(credentials); - - // Message encryption scheme : - // a)Concatenate username and password seperated by space; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain our encoded authorization message. - message = String::Concat( myCredentials->UserName, " ", myCredentials->Password ); - - // Apply AsciiEncoding to 'message' String* to obtain it as an array of bytes. - Encoding^ ascii = Encoding::ASCII; - array^byteArray = gcnew array(ascii->GetByteCount( message )); - byteArray = ascii->GetBytes( message ); - - // Performing Base64 transformation. - message = Convert::ToBase64String( byteArray ); - Authorization^ myAuthorization = gcnew Authorization( String::Concat( "CloneBasic ", message, true ) ); - array^protectionRealm = gcnew array(1); - protectionRealm[ 0 ] = request->RequestUri->AbsolutePath; - myAuthorization->ProtectionRealm = protectionRealm; - return myAuthorization; - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised in Authenticate method: {0}", e->Message ); - return nullptr; - } - } - // - // - - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } -}; - -// The 'Client' class is defined here to test the above custom authentication module. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ url; - String^ userName; - String^ passwd; - if ( args->Length < 3 ) - { - PrintUsage(); - return 0; - } - else - { - url = args[ 0 ]; - userName = args[ 1 ]; - passwd = args[ 2 ]; - } - - Console::WriteLine(); - CloneBasic^ authenticationModule = gcnew CloneBasic; - AuthenticationManager::Register( authenticationModule ); - AuthenticationManager::Unregister( "Basic" ); - - // Get response from Uri. - GetPage( url, userName, passwd ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp deleted file mode 100644 index eb8a5c280ac..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -public ref class Class -{ -private: - void Method1() - { - String^ UserName = Console::ReadLine(); - String^ SecurelyStoredPassword = Console::ReadLine(); - String^ Domain = Console::ReadLine(); - - WebRequest^ wReq = WebRequest::Create( "http://www.contoso.com" ); - - // - CredentialCache^ myCache = gcnew CredentialCache; - - myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Basic", gcnew NetworkCredential( UserName,SecurelyStoredPassword ) ); - myCache->Add( gcnew Uri( "http://www.contoso.com/" ), "Digest", gcnew NetworkCredential( UserName,SecurelyStoredPassword,Domain ) ); - - wReq->Credentials = myCache; - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp deleted file mode 100644 index 1902e81255b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Net; -using namespace System::Windows::Forms; -public ref class Form1: public Form - -{ -protected: - void Method() - { - // - IPHostEntry^ hostInfo = Dns::GetHostEntry( "www.contoso.com" ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp deleted file mode 100644 index e4aa5aedcd2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Uri^ proxyURI = gcnew Uri( "http://webproxy:80" ); - GlobalProxySelection::Select = gcnew WebProxy( proxyURI ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp deleted file mode 100644 index 16cbdf361c8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,16 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -public ref class Sample -{ -public: - void Method() - { - // - HttpWebRequest^ myReq = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp deleted file mode 100644 index 352469e1bea..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^, EventArgs^ ) - { - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( "http://www.contoso.com/" )); - - // - bool hasChanged = req->RequestUri->Equals( req->Address ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp deleted file mode 100644 index 945bd743eee..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Web; -using namespace System::Web::UI; - -public ref class Page1: public Page -{ -private: - void Page_Load( Object^, EventArgs^ ) - { - // - HttpWebRequest^ HttpWReq = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - HttpWebResponse^ HttpWResp = dynamic_cast(HttpWReq->GetResponse()); - - // Insert code that uses the response object. - HttpWResp->Close(); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp deleted file mode 100644 index ef840b46dcf..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ -protected: - void Method( Socket^ mySocket ) - { - // - LingerOption^ myOpts = gcnew LingerOption( true,1 ); - mySocket->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger, myOpts ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp deleted file mode 100644 index c92542655c2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Http; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - String^ SecurelyStoredUserName = ""; - String^ SecurelyStoredPassword = ""; - String^ SecurelyStoredDomain = ""; - - // - NetworkCredential^ myCred = gcnew NetworkCredential( - SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain ); - - CredentialCache^ myCache = gcnew CredentialCache; - - myCache->Add( gcnew Uri( "http://www.contoso.com" ), "Basic", myCred ); - myCache->Add( gcnew Uri( "http://app.contoso.com" ), "Basic", myCred ); - - // HttpClient lifecycle management best practices: - // https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use - HttpClientHandler^ handler = gcnew HttpClientHandler(); - handler->Credentials = myCache; - HttpClient^ client = gcnew HttpClient(handler); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp deleted file mode 100644 index 1a04a196a24..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method() - { - // - Uri^ myUri = gcnew Uri( "http://www.contoso.com/" ); - ServicePoint^ mySP = ServicePointManager::FindServicePoint( myUri ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp deleted file mode 100644 index 7a9fdb44639..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Windows::Forms; -using namespace System::Web; -using namespace System::Web::Services; - -// Class added so sample will compile -public ref class MyCertificatePolicy: public ICertificatePolicy -{ -public: - virtual bool CheckValidationResult( System::Net::ServicePoint^, System::Security::Cryptography::X509Certificates::X509Certificate^, System::Net::WebRequest^, int ) - { - return true; - } -}; - -public ref class Form1: public Form -{ -public: - void Method( Uri^ myUri ) - { - // - ServicePointManager::CertificatePolicy = gcnew MyCertificatePolicy; - - // Create the request and receive the response - try - { - WebRequest^ myRequest = WebRequest::Create( myUri ); - WebResponse^ myResponse = myRequest->GetResponse(); - ProcessResponse( myResponse ); - myResponse->Close(); - } - // Catch any exceptions - catch ( WebException^ e ) - { - if ( e->Status == WebExceptionStatus::TrustFailure ) - { - // Code for handling security certificate problems goes here. - } - // Other exception handling goes here - } - // - } - - // Method added so sample will compile - void ProcessResponse( WebResponse^ ){} -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp deleted file mode 100644 index e1e657e660b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ - // -protected: - void AcceptMethod( Socket^ listeningSocket ) - { - Socket^ mySocket = listeningSocket->Accept(); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp deleted file mode 100644 index 6c46b3b92d7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class Sample -{ -protected: - void Method( Socket^ aSocket, EndPoint^ anEndPoint ) - { - // - try - { - aSocket->Bind( anEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Winsock error: {0}", e ); - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp deleted file mode 100644 index 2e51128de63..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Security::Permissions; - -public ref class Sample -{ -protected: - [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] - void Method( Socket^ aSocket ) - { - // - try - { - aSocket->Shutdown(SocketShutdown::Both); - aSocket->Close(); - } - catch (...) - { - aSocket->Close(); - throw; - } - - if ( aSocket->Connected ) - { - Console::WriteLine( "Winsock error: {0}", Convert::ToString( - System::Runtime::InteropServices::Marshal::GetLastWin32Error() ) ); - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp deleted file mode 100644 index 6693a8bdfcc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -static void ConnectAndCheck( Socket^ client, EndPoint^ anEndPoint ) -{ - // - client->Connect( anEndPoint ); - if ( !client->Connected ) - { - Console::WriteLine( "Winsock error: {0}", Convert::ToString( - System::Runtime::InteropServices::Marshal::GetLastWin32Error() ) ); - } - - // This is how you can determine whether a socket is still connected. - bool blockingState = client->Blocking; - try - { - array^tmp = gcnew array(1); - client->Blocking = false; - client->Send( tmp, 0, static_cast(0) ); - Console::WriteLine( L"Connected!" ); - } - catch ( SocketException^ e ) - { - // 10035 == WSAEWOULDBLOCK - if ( e->NativeErrorCode.Equals( 10035 ) ) - { - Console::WriteLine( "Connected from an exception!" ); - } - else - { - Console::WriteLine( "Disconnected: {0}!", e->NativeErrorCode ); - } - } - finally - { - client->Blocking = blockingState; - } - - Console::WriteLine( "Connected: {0}", client->Connected ); - // -} - -[STAThread] -int main() -{ - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - String^ host = "localhost"; - int port = 80; - - IPHostEntry^ hostEntry = Dns::Resolve( host ); - IPEndPoint^ EPHost = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],port ); - - ConnectAndCheck( s, EPHost ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp deleted file mode 100644 index 66f68944d86..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -void CreateAndListen( int port, int backlog ) -{ - // - // create the socket - Socket^ listenSocket = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - // bind the listening socket to the port - IPAddress^ hostIP = ( Dns::Resolve( IPAddress::Any->ToString() ) )->AddressList[ 0 ]; - IPEndPoint^ ep = gcnew IPEndPoint( hostIP,port ); - listenSocket->Bind( ep ); - - // start listening - listenSocket->Listen( backlog ); - // -} - -[STAThread] -int main() -{ - CreateAndListen( 10042, 10 ); - Console::WriteLine( "enter to exit" ); - Console::Read(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp deleted file mode 100644 index 27d0003bd8b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -void MySerializeIPEndPointClassMethod() -{ - // - //Creates an IpEndPoint. - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - //Serializes the IPEndPoint. - SocketAddress^ socketAddress = ipLocalEndPoint->Serialize(); - - //Verifies that ipLocalEndPoint is now serialized by printing its contents. - Console::WriteLine( "Contents of the socketAddress are: {0}", socketAddress ); - //Checks the Family property. - Console::WriteLine( "The address family of the socketAddress is: {0}", socketAddress->Family ); - //Checks the underlying buffer size. - Console::WriteLine( "The size of the underlying buffer is: {0}", socketAddress->Size ); - // -} - -int main() -{ - MySerializeIPEndPointClassMethod(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 719fbbc6521..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - { - Console::WriteLine( "Enter a selection" ); - return 0; - } - - if ( args[ 1 ] == "endpointExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local endpoint. - - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - if ( args[ 1 ] == "ipAddressExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local IP address and port number. - - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - if ( args[ 1 ] == "portNumberExample" ) - { - // - //Creates an instance of the TcpListener class by providing a local port number. - - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - - try - { - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - IPAddress^ ipAddress = Dns::Resolve( "localhost" )->AddressList[ 0 ]; - TcpListener^ tcpListener = gcnew TcpListener( ipAddress,13 ); - tcpListener->Start(); - Console::WriteLine( "Waiting for a connection...." ); - - try - { - // - // Accepts the pending client connection and returns a socket for communciation. - Socket^ socket = tcpListener->AcceptSocket(); - Console::WriteLine( "Connection accepted." ); - - String^ responseString = "You have successfully connected to me"; - - //Forms and sends a response string to the connected client. - array^sendBytes = Encoding::ASCII->GetBytes( responseString ); - int i = socket->Send( sendBytes ); - Console::WriteLine( "Message Sent /> : {0}", responseString ); - // - - //Any communication with the remote client using the socket can go here. - - //Closes the tcpListener and the socket. - socket->Shutdown( SocketShutdown::Both ); - socket->Close(); - tcpListener->Stop(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp deleted file mode 100644 index c216c7fe3f7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -/** -* This program shows how to use the TcpListener class. -* It creates a TcpListener that listens on the specified port (13000). -* To run this program at the command line you enter: -* cs_tcpserver -* Any TcpClient that wants to use this server -* has to explicitly connect to an address obtained by the combination of -* the server on which this TcpServer is running and the port 13000. -* This TcpServer simply echoes back the message sent by the TcpClient, after -* translating it into uppercase. -**/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -int main() -{ - try - { - - // Set the TcpListener on port 13000. - Int32 port = 13000; - TcpListener^ server = gcnew TcpListener(IPAddress::Any, port); - - // Start listening for client requests. - server->Start(); - - // Buffer for reading data - array^bytes = gcnew array(256); - String^ data = nullptr; - - // Enter the listening loop. - while ( true ) - { - Console::Write( "Waiting for a connection... " ); - - // Perform a blocking call to accept requests. - // You could also use server.AcceptSocket() here. - TcpClient^ client = server->AcceptTcpClient(); - Console::WriteLine( "Connected!" ); - data = nullptr; - - // Get a stream object for reading and writing - NetworkStream^ stream = client->GetStream(); - Int32 i; - - // Loop to receive all the data sent by the client. - while ( (i = stream->Read( bytes, 0, bytes->Length )) != 0 ) - { - - // Translate data bytes to a ASCII string. - data = System::Text::Encoding::ASCII->GetString( bytes, 0, i ); - Console::WriteLine( String::Format( "Received: {0}", data ) ); - - // Process the data sent by the client. - data = data->ToUpper(); - array^msg = System::Text::Encoding::ASCII->GetBytes( data ); - - // Send back a response. - stream->Write( msg, 0, msg->Length ); - Console::WriteLine( String::Format( "Sent: {0}", data ) ); - } - - // Shutdown and end connection - client->Close(); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - - Console::WriteLine( "\nHit enter to continue..." ); - Console::Read(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 8c3fe289538..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -// This derived class demonstrate the use of three protected methods belonging to the UdpClient class. -public ref class MyUdpClientDerivedClass: public UdpClient -{ -public: - MyUdpClientDerivedClass() - : UdpClient() - {} - - void UsingProtectedMethods() - { - //Uses the protected Active property belonging to the UdpClient base class to determine if a connection is established. - if ( this->Active ) - { - //Calls the protected Client property belonging to the UdpClient base class. - Socket^ s = this->Client; - - //Uses the Socket returned by Client to set an option that is not available using UdpClient. - s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Broadcast, 1 ); - } - } -}; -// - -int main() -{ - MyUdpClientDerivedClass^ myUdpClientDerivedClass = gcnew MyUdpClientDerivedClass; - myUdpClientDerivedClass->UsingProtectedMethods(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 9ac0d6b76e3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class MyUdpClientExample -{ -public: - // MyUdpClientConstructor is just used to illustrate the different constructors available in in the UdpClient class. - static void MyUdpClientConstructor( String^ myConstructorType ) - { - if ( myConstructorType->Equals( "PortNumberExample" ) ) - { - // - //Creates an instance of the UdpClient class to listen on - // the default interface using a particular port. - try - { - UdpClient^ udpClient = gcnew UdpClient( 11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "LocalEndPointExample" ) ) - { - // - //Creates an instance of the UdpClient class using a local endpoint. - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - try - { - UdpClient^ udpClient = gcnew UdpClient( ipLocalEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "HostNameAndPortNumExample" ) ) - { - // - //Creates an instance of the UdpClient class with a remote host name and a port number. - try - { - UdpClient^ udpClient = gcnew UdpClient( "www.contoso.com",11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConstructorType->Equals( "DefaultExample" ) ) - { - // - //Creates an instance of the UdpClient class using the default constructor. - UdpClient^ udpClient = gcnew UdpClient; - // - } - else - { - // Do nothing. - } - } - - // MyUdpClientConnection method is just used to illustrate the different connection methods of UdpClient class. - static void MyUdpClientConnection( String^ myConnectionType ) - { - if ( myConnectionType->Equals( "HostnameAndPortNumExample" ) ) - { - // - //Uses a host name and port number to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - try - { - udpClient->Connect( "www.contoso.com", 11002 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConnectionType == "IPAddressAndPortNumExample" ) - { - // - //Uses the IP address and port number to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - try - { - udpClient->Connect( ipAddress, 11003 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myConnectionType == "RemoteEndPointExample" ) - { - // - //Uses a remote endpoint to establish a socket connection. - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - try - { - udpClient->Connect( ipEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - // Do nothing. - } - } - - // This class demonstrates sending and receiving using a Udp socket. - static void MyUdpClientCommunicator( String^ mySendType ) - { - if ( mySendType == "EndPointExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there?" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length, ipEndPoint ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( mySendType == "HostNameAndPortNumberExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length, "www.contoso.com", 11000 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( mySendType == "StraightSendExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient( "www.contoso.com",11000 ); - array^ sendBytes = Encoding::ASCII->GetBytes( "Is anybody there" ); - try - { - udpClient->Send( sendBytes, sendBytes->Length ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else - { - // Do nothing. - } - - // - //Creates a UdpClient for reading incoming data. - UdpClient^ receivingUdpClient = gcnew UdpClient( 11000 ); - - //Creates an IPEndPoint to record the IP Address and port number of the sender. - // The IPEndPoint will allow you to read datagrams sent from any source. - IPEndPoint^ RemoteIpEndPoint = gcnew IPEndPoint( IPAddress::Any,0 ); - try - { - // Blocks until a message returns on this socket from a remote host. - array^receiveBytes = receivingUdpClient->Receive( RemoteIpEndPoint ); - - String^ returnData = Encoding::ASCII->GetString( receiveBytes ); - - Console::WriteLine( "This is the message you received {0}", returnData ); - Console::WriteLine( "This message was sent from {0} on their port number {1}", - RemoteIpEndPoint->Address, RemoteIpEndPoint->Port ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - - // This example class demonstrates methods used to join and drop multicast groups. - static void MyUdpClientMulticastConfiguration( String^ myAction ) - { - if ( myAction == "JoinMultiCastExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - IPAddress^ multicastIpAddress = Dns::Resolve( "MulticastGroupName" )->AddressList[ 0 ]; - try - { - udpClient->JoinMulticastGroup( multicastIpAddress ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - } - else if ( myAction == "JoinMultiCastWithTimeToLiveExample" ) - { - // - UdpClient^ udpClient = gcnew UdpClient; - // Creates an IPAddress to use to join and drop the multicast group. - IPAddress^ multicastIpAddress = IPAddress::Parse( "239.255.255.255" ); - - try - { - // The packet dies after 50 router hops. - udpClient->JoinMulticastGroup( multicastIpAddress, 50 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - - // - // Informs the server that you want to remove yourself from the multicast client list. - try - { - udpClient->DropMulticastGroup( multicastIpAddress ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // - - // - // Closes the UDP client by calling the public method Close(). - udpClient->Close(); - // - } - else - { - // Do nothing. - } - } -}; -//end class - -int main() -{ - // For our example, we will use the default constructor. - MyUdpClientExample::MyUdpClientConstructor( "defaultExample" ); - MyUdpClientExample::MyUdpClientConnection( "HostNameAndPortNumExample" ); - MyUdpClientExample::MyUdpClientCommunicator( "EndPointExample" ); - MyUdpClientExample::MyUdpClientMulticastConfiguration( "JoinMultiCastExample" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp deleted file mode 100644 index 12a033e105e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - // - // With this constructor the local port number is arbitrarily assigned. - UdpClient^ udpClient = gcnew UdpClient; - try - { - udpClient->Connect( "host.contoso.com", 11000 ); - - // Send message to the host to which you have connected. - array^sendBytes = Encoding::ASCII->GetBytes( "Is anybody there?" ); - udpClient->Send( sendBytes, sendBytes->Length ); - - // Send message to a different host using optional hostname and port parameters. - UdpClient^ udpClientB = gcnew UdpClient; - udpClientB->Send( sendBytes, sendBytes->Length, "AlternateHostMachineName", 11000 ); - - //IPEndPoint object will allow us to read datagrams sent from any source. - IPEndPoint^ RemoteIpEndPoint = gcnew IPEndPoint( IPAddress::Any,0 ); - - // Block until a message returns on this socket from a remote host. - array^receiveBytes = udpClient->Receive( RemoteIpEndPoint ); - String^ returnData = Encoding::ASCII->GetString( receiveBytes ); - - // Use the IPEndPoint object to determine which of these two hosts responded. - Console::WriteLine( String::Concat( "This is the message you received ", returnData->ToString() ) ); - Console::WriteLine( String::Concat( "This message was sent from ", RemoteIpEndPoint->Address->ToString(), " on their port number ", RemoteIpEndPoint->Port.ToString() ) ); - udpClient->Close(); - udpClientB->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp deleted file mode 100644 index bfcfe422816..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Http; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - WebProxy^ proxyObject = gcnew WebProxy("http://proxyserver:80/", true); - - // HttpClient lifecycle management best practices: - // https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use - HttpClientHandler^ handler = gcnew HttpClientHandler(); - handler->Proxy = proxyObject; - HttpClient^ client = gcnew HttpClient(handler); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp deleted file mode 100644 index 2a706abc691..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - // Initialize the WebRequest. - WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Return the response. - WebResponse^ myResponse = myRequest->GetResponse(); - - // Code to use the WebResponse goes here. - - // Close the response to free resources. - myResponse->Close(); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp deleted file mode 100644 index ef3028f80a5..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -public ref class Sample -{ -private: - void sampleFunction() - { - // - WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" ); - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp deleted file mode 100644 index 7064ebe4ae4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp +++ /dev/null @@ -1,248 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; -public ref class MyTcpClientExample -{ -public: - - // - // MyTcpClientConstructor is just used to illustrate the different constructors available in in the TcpClient class - static void MyTcpClientConstructor( String^ myConstructorType ) - { - if ( myConstructorType == "IPAddressExample" ) - { - - // - //Creates a TCPClient using a local end point. - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipLocalEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - TcpClient^ tcpClientA = gcnew TcpClient( ipLocalEndPoint ); - - // - } - else - if ( myConstructorType == "HostNameExample" ) - { - - // - // Creates a TCPClient using hostname and port. - TcpClient^ tcpClientB = gcnew TcpClient( "www.contoso.com",11000 ); - - // - } - else - if ( myConstructorType == "DefaultExample" ) - { - - // - //Creates a TCPClient using the default constructor. - TcpClient^ tcpClientC = gcnew TcpClient; - - // - } - else - { - - // - TcpClient^ tcpClientD = gcnew TcpClient( AddressFamily::InterNetwork ); - - // - } - } - - - // MyTcpClientConnection class is just used to illustrate the different connection methods of the TcpClient class. - static void MyTcpClientConnection( String^ myConnectionType ) - { - if ( myConnectionType == "HostnameExample" ) - { - - // - //Uses a host name and port number to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - tcpClient->Connect( "www.contoso.com", 11002 ); - - // - tcpClient->Close(); - } - else - if ( myConnectionType == "IPAddressExample" ) - { - - // - //Uses the IP address and port number to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - tcpClient->Connect( ipAddress, 11003 ); - - // - tcpClient->Close(); - } - else - if ( myConnectionType == "RemoteEndPointExample" ) - { - - // - //Uses a remote end point to establish a socket connection. - TcpClient^ tcpClient = gcnew TcpClient; - IPAddress^ ipAddress = Dns::Resolve( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddress,11004 ); - tcpClient->Connect( ipEndPoint ); - - // - tcpClient->Close(); - } - else - { - - // Do nothing. - } - } - - - // MyTcpClientPropertySetter is just used to illustrate setting and getting various properties of the TcpClient class. - static void MyTcpClientPropertySetter() - { - TcpClient^ tcpClient = gcnew TcpClient; - - // - // sets the receive buffer size using the ReceiveBufferSize public property. - tcpClient->ReceiveBufferSize = 1024; - - // gets the receive buffer size using the ReceiveBufferSize public property. - if ( tcpClient->ReceiveBufferSize == 1024 ) - Console::WriteLine( "The receive buffer was successfully set to {0}", tcpClient->ReceiveBufferSize ); - - - // - // - //sets the send buffer size using the SendBufferSize public property. - tcpClient->SendBufferSize = 1024; - - // gets the send buffer size using the SendBufferSize public property. - if ( tcpClient->SendBufferSize == 1024 ) - Console::WriteLine( "The send buffer was successfully set to {0}", tcpClient->SendBufferSize ); - - - // - // - // Sets the receive time out using the ReceiveTimeout public property. - tcpClient->ReceiveTimeout = 5; - - // Gets the receive time out using the ReceiveTimeout public property. - if ( tcpClient->ReceiveTimeout == 5 ) - Console::WriteLine( "The receive time out limit was successfully set {0}", tcpClient->ReceiveTimeout ); - - - // - // - // sets the send time out using the SendTimeout public property. - tcpClient->SendTimeout = 5; - - // gets the send time out using the SendTimeout public property. - if ( tcpClient->SendTimeout == 5 ) - Console::WriteLine( "The send time out limit was successfully set {0}", tcpClient->SendTimeout ); - - - // - // - // sets the amount of time to linger after closing, using the LingerOption public property. - LingerOption^ lingerOption = gcnew LingerOption( true,10 ); - tcpClient->LingerState = lingerOption; - - // gets the amount of linger time set, using the LingerOption public property. - if ( tcpClient->LingerState->LingerTime == 10 ) - Console::WriteLine( "The linger state setting was successfully set to {0}", tcpClient->LingerState->LingerTime ); - - - // - // - // Sends data immediately upon calling NetworkStream.Write. - tcpClient->NoDelay = true; - - // Determines if the delay is enabled by using the NoDelay property. - if ( tcpClient->NoDelay) - Console::WriteLine( "The delay was set successfully to {0}", tcpClient->NoDelay ); - - - // - tcpClient->Close(); - } - - static void MyTcpClientCommunicator() - { - - // - TcpClient^ tcpClient = gcnew TcpClient; - - // Uses the GetStream public method to return the NetworkStream. - NetworkStream^ netStream = tcpClient->GetStream(); - if ( netStream->CanWrite ) - { - array^sendBytes = Encoding::UTF8->GetBytes( "Is anybody there?" ); - netStream->Write( sendBytes, 0, sendBytes->Length ); - } - else - { - Console::WriteLine( "You cannot write data to this stream." ); - tcpClient->Close(); - - // Closing the tcpClient instance does not close the network stream. - netStream->Close(); - return; - } - - if ( netStream->CanRead ) - { - - // Reads NetworkStream into a byte buffer. - array^bytes = gcnew array(tcpClient->ReceiveBufferSize); - - // Read can return anything from 0 to numBytesToRead. - // This method blocks until at least one byte is read. - netStream->Read( bytes, 0, (int)tcpClient->ReceiveBufferSize ); - - // Returns the data received from the host to the console. - String^ returndata = Encoding::UTF8->GetString( bytes ); - Console::WriteLine( "This is what the host returned to you: {0}", returndata ); - } - else - { - Console::WriteLine( "You cannot read data from this stream." ); - tcpClient->Close(); - - // Closing the tcpClient instance does not close the network stream. - netStream->Close(); - return; - } - - - // - } - -}; - - -//end class -int main() -{ - - // Using the default constructor. - MyTcpClientExample::MyTcpClientConstructor( "DefaultExample" ); - - // Establish a connection by using the hostname and port number. - MyTcpClientExample::MyTcpClientConnection( "HostnameExample" ); - - // Set and verify all communication parameters before attempting communication. - MyTcpClientExample::MyTcpClientPropertySetter(); - - // Send and receive data using tcpClient class. - MyTcpClientExample::MyTcpClientCommunicator(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp b/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp deleted file mode 100644 index 14edae82980..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp +++ /dev/null @@ -1,147 +0,0 @@ - - -/* -This program demonstrates 'Item(string)' and 'Count' properties of 'CookieCollection' class. - -This program uses an internal site called "CookiesServer.aspx". The program creates a 'HttpWebRequest' -object with the 'URL' taken from command line argument. When no cookies are initially sent to -the server, it responds with a specific page querying the client for information. The client queries -this information from the user and sends it to the server in the second request. This information is -used by the server to not only structure the page sent subsequently but also construct some cookies to be -set by the client, for future requests. The response and the cookies that are sent from the server are -displayed to the console. - -Note: This program requires the "CookiesServer.aspx" server to be running before the execution of this -program.Please refer the "ReadmeCookiesServer.txt" file for setting up the server. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Text::RegularExpressions; -void DisplayCookies( CookieCollection^ cookies ) -{ - // - // - // Get the cookies in the 'CookieCollection' object using the 'Item' property. - // The 'Item' property in C++ is implemented through Indexers. - // The class that implements indexers is usually a collection of other objects. - // This class provides access to those objects with the '[i]' syntax. - try - { - if ( cookies->Count == 0 ) - { - Console::WriteLine( "No cookies to display" ); - return; - } - - Console::WriteLine( "{0}", cookies[ "UserName" ] ); - Console::WriteLine( "{0}", cookies[ "DateOfBirth" ] ); - Console::WriteLine( "{0}", cookies[ "PlaceOfBirth" ] ); - Console::WriteLine( "" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - // - // -} - -void printUsage() -{ - Console::WriteLine( "Usage : " ); - Console::WriteLine( "CookieCollection_Item_1 " ); - Console::WriteLine( " is the name of the CookiesServer.aspx site installed locally" ); - Console::WriteLine( "\nExample : CookieCollection_Item_1 http://www.MyServer.com/CookiesServer.aspx" ); -} - -void GetPage( Uri^ requestUri ) -{ - try - { - array^output = gcnew array(120); - Stream^ myStream; - Encoding^ asciiEncoding = gcnew ASCIIEncoding; - - // Create the request. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - - // Get the response without any cookies sent to the server. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - String^ usrName; - String^ dateBirth; - String^ placeBirth; - - // Get the information from the user as requested by the server and send it over to the server. - myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - myHttpWebRequest->Method = "POST"; - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - Console::WriteLine( "\nEnter the values to be sent to the server :\n" ); - Console::Write( "UserName : " ); - usrName = Console::ReadLine(); - Console::Write( "\nDateOfBirth [dd/mm/yyyy]: " ); - dateBirth = Console::ReadLine(); - Regex^ regex = gcnew Regex( "/" ); - String^ convertDate = regex->Replace( dateBirth, "%2F" ); - Console::Write( "\nPlaceOfBirth : " ); - placeBirth = Console::ReadLine(); - Console::WriteLine( "" ); - output = asciiEncoding->GetBytes( String::Format( "UserName={0}&DateOfBirth={1}&PlaceOfBirth={2}&__EVENTTARGET=PlaceOfBirth&__EVENTARGUMENT=", usrName, convertDate, placeBirth ) ); - myHttpWebRequest->ContentLength = output->Length; - myStream = myHttpWebRequest->GetRequestStream(); - myStream->Write( output, 0, output->Length ); - myStream->Close(); - myHttpWebResponse->Close(); - - // Get the response. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Output the response to the console. - myStream = myHttpWebResponse->GetResponseStream(); - Console::WriteLine( "Displaying the contents of the page of '{0}' site:", requestUri ); - Console::WriteLine( "" ); - int bytesRead = 0; - while ( (bytesRead = myStream->Read( output, 0, output->Length )) != 0 ) - Console::Write( asciiEncoding->GetString( output, 0, bytesRead ) ); - Console::WriteLine( "" ); - Console::WriteLine( "\nDisplaying the cookies in the response : " ); - Console::WriteLine( "" ); - DisplayCookies( myHttpWebResponse->Cookies ); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - printUsage(); - return 0; - } - GetPage( gcnew Uri( args[ 1 ] ) ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} diff --git a/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp b/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp deleted file mode 100644 index 5f84293fef8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp +++ /dev/null @@ -1,143 +0,0 @@ - - -/* -This program demonstrates 'Item(int)' properties of 'CookieCollection' class. - -This program uses an internal site called "CookiesServer.aspx". The program creates a 'HttpWebRequest' -object with the 'URL' taken from command line argument. When no cookies are initially sent to -the server, it responds with a specific page querying the client for information. The client queries -this information from the user and sends it to the server in the second request. This information is -used by the server to not only structure the page sent subsequently but also construct some cookies to be -set by the client, for future requests. The response and the cookies that are sent from the server are -displayed to the console. - -Note: This program requires the "CookiesServer.aspx" server to be running before the execution of this -program.Please refer the "ReadmeCookiesServer.txt" file for setting up the server. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Text::RegularExpressions; -void DisplayCookies( CookieCollection^ cookies ) -{ - // - // Get the cookies in the 'CookieCollection' object using the 'Item' property. - // The 'Item' property in C++ is implemented through Indexers. - // The class that implements indexers is usually a collection of other objects. - // This class provides access to those objects with the '[i]' syntax. - try - { - if ( cookies->Count == 0 ) - { - Console::WriteLine( "No cookies to display" ); - return; - } - - for ( int j = 0; j < cookies->Count; j++ ) - Console::WriteLine( "{0}", cookies[ j ] ); - Console::WriteLine( "" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - // -} - -void GetPage( Uri^ requestUri ) -{ - try - { - array^output = gcnew array(120); - Stream^ myStream; - Encoding^ asciiEncoding = gcnew ASCIIEncoding; - - // Create the request. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - - // Get the response without any cookies sent to the server. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - String^ usrName; - String^ dateBirth; - String^ placeBirth; - - // Get the information from the user as requested by the server and send it over to the server. - myHttpWebRequest = dynamic_cast(WebRequest::Create( requestUri )); - myHttpWebRequest->Method = "POST"; - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - Console::WriteLine( "\nEnter the values to be sent to the server :\n" ); - Console::Write( "UserName : " ); - usrName = Console::ReadLine(); - Console::Write( "\nDateOfBirth [dd/mm/yyyy]: " ); - dateBirth = Console::ReadLine(); - Regex^ regex = gcnew Regex( "/" ); - String^ convertDate = regex->Replace( dateBirth, "%2F" ); - Console::Write( "\nPlaceOfBirth : " ); - placeBirth = Console::ReadLine(); - Console::WriteLine( "" ); - output = asciiEncoding->GetBytes( String::Format( "UserName={0}&DateOfBirth={1}&PlaceOfBirth={2}&__EVENTTARGET=PlaceOfBirth&__EVENTARGUMENT=", usrName, convertDate, placeBirth ) ); - myHttpWebRequest->ContentLength = output->Length; - myStream = myHttpWebRequest->GetRequestStream(); - myStream->Write( output, 0, output->Length ); - myStream->Close(); - myHttpWebResponse->Close(); - - // Get the response. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Output the response to the console. - myStream = myHttpWebResponse->GetResponseStream(); - Console::WriteLine( "Displaying the contents of the page of '{0}' site:", requestUri ); - Console::WriteLine( "" ); - int bytesRead = 0; - while ( (bytesRead = myStream->Read( output, 0, output->Length )) != 0 ) - Console::Write( asciiEncoding->GetString( output, 0, bytesRead ) ); - Console::WriteLine( "" ); - Console::WriteLine( "\nDisplaying the cookies in the response : " ); - Console::WriteLine( "" ); - DisplayCookies( myHttpWebResponse->Cookies ); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } - -} - -void printUsage() -{ - Console::WriteLine( "Usage : " ); - Console::WriteLine( "CookieCollection_Item_2 " ); - Console::WriteLine( " is the name of the CookiesServer.aspx site installed locally" ); - Console::WriteLine( "\nExample : CookieCollection_Item_2 http://www.MyServer.com/CookiesServer.aspx" ); -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - printUsage(); - return 0; - } - GetPage( gcnew Uri( args[ 1 ] ) ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException raised.\nError : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised.\nError : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp b/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp deleted file mode 100644 index 30b79abc081..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// System::Net::CredentialCache->Add;System::Net::CredentialCache::CredentialCache(); -// System::Net::CredentialCache::Remove;System::Net::CredentialCache. - -/*This program demontrates the 'Remove' method, 'Add' method and 'CredentialCache' -constructor of the 'CredentialCache' class. It takes an URL creates a 'WebRequest' Object* for the Url. -The program stores a known set of credentials in a credential cache and removes a credential when it -is no longer needed. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { -// -// - CredentialCache^ myCredentialCache = gcnew CredentialCache; - // Used Dummy names as credentials. They are to be replaced by credentials applicable locally. - myCredentialCache->Add( gcnew Uri( "http://www.microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://www.msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - Console::WriteLine( "\nAdded your credentials to the program's CredentialCache" ); -// -// - // Create a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentialCache; - Console::WriteLine( "\nLinked CredentialCache to your request." ); - // Send the request and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - // Process response here. - - Console::Write( "Response received successfully." ); - - // Call 'Remove' method to dispose credentials for current Uri as not required further. - myCredentialCache->Remove( myWebRequest->RequestUri, "Basic" ); - Console::WriteLine( "\nYour credentials have now been removed from the program's CredentialCache" ); - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - { - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - } - else - { - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } - -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_Add_Remove " ); - Console::WriteLine( "\n Example: CredentialCache_Add_Remove http://www.microsoft.com Catherine cath$ microsoft" ); - } - else if ( args->Length == 4 ) - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - else - { - Console::WriteLine( "\nInvalid arguments." ); - return 0; - } - - Console::WriteLine( " Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp b/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp deleted file mode 100644 index 778e10ae046..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// System::Net::CredentialCache::DefaultCredentials. -/* This program demonstrates the 'DefaultCredentials' property of the 'CredentialCache' -class. -Creates an 'HttpWebRequest' Object* to access the local Uri S"http://localhost"(IIS documentation start page) -Assigns the static property 'DefaultCredentials' of 'CredentialCache' as 'Credentials' for the 'HttpWebRequest' -Object*. DefaultCredentials returns the system credentials for the current security context in which -the application is running. For a client-side application, these are usually the Windows credentials -(user name, password, and domain) of the user running the application. -These credentials are used internally to authenticate the request. -The html contents of the start page are displayed to the console. - -Note: Make sure that S"Windows Authentication" has been set as Directory Security settings -for default web site in IIS -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { - // - // Ensure Directory Security settings for default web site in IIS is "Windows Authentication". - String^ url = "http://localhost"; - - // Create a 'HttpWebRequest' object with the specified url. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // Assign the credentials of the logged in user or the user being impersonated. - myHttpWebRequest->Credentials = CredentialCache::DefaultCredentials; - - // Send the 'HttpWebRequest' and wait for response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Authentication successful" ); - Console::WriteLine( "Response received successfully" ); - - // - Console::WriteLine( "\nPress enter to continue" ); - Console::ReadLine(); - - // Get the stream associated with the response object. - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received" ); - array^read = gcnew array(256); - - // Read 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - while ( count > 0 ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ output = gcnew String( read,0,count ); - Console::Write( output ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - - // Release the resources of response Object*. - myHttpWebResponse->Close(); - - // Release the resources of stream Object*. - readStream->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nException Raised. The following error occurred : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp b/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp deleted file mode 100644 index f38f54663af..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp +++ /dev/null @@ -1,86 +0,0 @@ - - -// System::Net::CredentialCache::GetCredential -/*This program demontrates the 'GetCredential' method of the CredentialCache class. It takes an URL -creates a 'WebRequest' Object* for the Url. The program stores a known set of credentials in a credential cache. -'GetCredential' will then retrieve the credentials for the requested Uri. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void Display( NetworkCredential^ credential ) -{ - Console::WriteLine( "\nThe credentials are:" ); - Console::WriteLine( "\nUsername : {0} , Password : {1} , Domain : {2}", credential->UserName, credential->Password, credential->Domain ); -} - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { - CredentialCache^ myCredentialCache = gcnew CredentialCache; - - // Dummy names used as credentials. - myCredentialCache->Add( gcnew Uri( "http://microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - - // Create a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - - // Call 'GetCredential' to obtain the credentials specific to our Uri. - NetworkCredential^ myCredential = myCredentialCache->GetCredential( gcnew Uri( url ), "Basic" ); - Display( myCredential ); - - // Associating only our credentials. - myWebRequest->Credentials = myCredential; - - // Sends the request and waits for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process response here. - Console::WriteLine( "\nResponse Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - else - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_GetCredential " ); - Console::WriteLine( "\n Example: CredentialCache_GetCredential http://www.microsoft.com Catherine cath$ microsoft" ); - } - else - if ( (args->Length == 4) ) - { - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - } - else - { - Console::WriteLine( "\nInvalid arguments." ); - return 0; - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp b/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp deleted file mode 100644 index 86beeaa5a72..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp +++ /dev/null @@ -1,92 +0,0 @@ - - -// System::Net::CredentialCache::GetEnumerator -/*This program demontrates the 'GetEnumerator' method of the CredentialCache class. -It takes an URL, creates a 'WebRequest' Object* for the Url. The program stores a known set of credentials -in a credential cache which is then bound to the request. If the url requested has it's credentials in the cache -the response will be OK . 'GetEnumerator' method is used to enlist all the credentials stored in the -'CredentialCache' Object*. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -void Display( NetworkCredential^ credential ) -{ - Console::WriteLine( "\n\tUsername : {0} , Password : {1} , Domain : {2}", credential->UserName, credential->Password, credential->Domain ); -} - -void GetPage( String^ url, String^ userName, String^ password, String^ domainName ) -{ - try - { - CredentialCache^ myCredentialCache = gcnew CredentialCache; - - // Dummy Credentials used here. - myCredentialCache->Add( gcnew Uri( "http://microsoft.com/" ), "Basic", gcnew NetworkCredential( "user1","passwd1","domain1" ) ); - myCredentialCache->Add( gcnew Uri( "http://msdn.com/" ), "Basic", gcnew NetworkCredential( "user2","passwd2","domain2" ) ); - myCredentialCache->Add( gcnew Uri( url ), "Basic", gcnew NetworkCredential( userName,password,domainName ) ); - - // Creates a webrequest with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentialCache; - IEnumerator^ listCredentials = myCredentialCache->GetEnumerator(); - Console::WriteLine( "\nDisplaying credentials stored in CredentialCache: " ); - while ( listCredentials->MoveNext() ) - Display( dynamic_cast(listCredentials->Current) ); - Console::WriteLine( "\nNow Displaying the same using 'foreach' : " ); - - // Can use foreach with CredentialCache(Since GetEnumerator function of IEnumerable* has been implemented by 'CredentialCache' class. - IEnumerator^ myEnum = myCredentialCache->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - NetworkCredential^ credential = safe_cast(myEnum->Current); - Display( credential ); - } - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process response here. - Console::WriteLine( "\nResponse Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - if ( e->Response != nullptr ) - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", (dynamic_cast(e->Response))->StatusDescription ); - else - Console::WriteLine( "\r\nFailed to obtain a response. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\n Usage:" ); - Console::WriteLine( "\n CredentialCache_GetEnumerator " ); - Console::WriteLine( "\n Example: CredentialCache_GetEnumerator http://www.microsoft.com Catherine cath$ microsoft" ); - } - else - if ( args->Length == 4 ) - { - GetPage( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ] ); - } - else - { - Console::WriteLine( "\n Invalid arguments." ); - return 0; - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp deleted file mode 100644 index cfe2812f5b9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -This program demonstrates the 'Constructor' of 'DnsPermission' class. -It creates an instance of 'DnsPermission' class and checks for permission.Then it -creates a 'SecurityElement' Object* and prints it's attributes which hold the XML -encoding of 'DnsPermission' instance . -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void useDns() - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::Unrestricted ); - - // Check for permission. - permission->Demand(); - // Create a SecurityElement Object* to hold XML encoding of the DnsPermission instance. - SecurityElement^ securityElementObj = permission->ToXml(); - Console::WriteLine( "Tag, Attributes and Values of 'DnsPermission' instance :" ); - Console::WriteLine( "\n\tTag : {0}", securityElementObj->Tag ); - // Print the attributes and values. - PrintKeysAndValues( securityElementObj->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\n\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp b/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp deleted file mode 100644 index 0e9c78efb39..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -This program demonstrates the 'Copy' method of 'DnsPermission' class. -It creates an identical copy of 'DnsPermission' instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -class DnsPermissionExample -{ - // -public: - void UseDns() - { - // Create a DnsPermission instance. - DnsPermission^ myPermission = gcnew DnsPermission( PermissionState::Unrestricted ); - // Check for permission. - myPermission->Demand(); - // Create an identical copy of the above 'DnsPermission' Object*. - DnsPermission^ myPermissionCopy = dynamic_cast(myPermission->Copy()); - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - // Print the attributes and values. - PrintKeysAndValues( myPermission->ToXml()->Attributes ); - Console::WriteLine( "Attribute and values of copied instance :" ); - PrintKeysAndValues( myPermissionCopy->ToXml()->Attributes ); - } - -private: - void PrintKeysAndValues( Hashtable^ myHashtable ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myHashtable->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample * dnsPermissionExampleObj = new DnsPermissionExample; - dnsPermissionExampleObj->UseDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp b/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp deleted file mode 100644 index 3674b00df6c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -This program demonstrates the 'FromXml' method of 'DnsPermission' class. -It creates an instance of 'DnsPermission' class and prints the XML encoding of that instance.Then it -creates a 'SecurityElement' Object* and adds the attributes corresponding to the above 'DnsPermission' -Object*. A new 'DnsPermission' instance is reconstructed from the 'SecurityElement' instance by calling -'FromXml' method and it's XML encoding is printed. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void ConstructDnsPermission() - { - try - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::None ); - // Create a SecurityElement instance by calling the ToXml method on the - // DnsPermission instance. - // Print its attributes, which hold the XML encoding of the DnsPermission - // instance. - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - PrintKeysAndValues( permission->ToXml()->Attributes ); - - // Create a SecurityElement instance. - SecurityElement^ securityElementObj = gcnew SecurityElement( "IPermission" ); - // Add attributes and values of the SecurityElement instance corresponding to - // the permission instance. - securityElementObj->AddAttribute( "version", "1" ); - securityElementObj->AddAttribute( "Unrestricted", "true" ); - securityElementObj->AddAttribute( "class", "System.Net.DnsPermission" ); - - // Reconstruct a DnsPermission instance from an XML encoding. - DnsPermission^ permission1 = gcnew DnsPermission( PermissionState::None ); - permission1->FromXml( securityElementObj ); - - // Print the attributes and values of the constructed DnsPermission Object*. - Console::WriteLine( "After reconstruction Attributes and Values of new DnsPermission instance :" ); - PrintKeysAndValues( permission1->ToXml()->Attributes ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NullReferenceException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->ConstructDnsPermission(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp b/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp deleted file mode 100644 index 929717f0e2e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -This program demonstrates the 'IsSubsetOf' method of 'DnsPermission' class. -'IsSubsetOf' method returns true, if the current DnsPermission instance allows no -more access to DNS servers than does the specified 'DnsPermission' instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ -private: - DnsPermission^ permission; - - // -public: - void useDns() - { - // Create a DnsPermission instance. - permission = gcnew DnsPermission( PermissionState::Unrestricted ); - DnsPermission^ dnsPermission1 = gcnew DnsPermission( PermissionState::None ); - // Check for permission. - permission->Demand(); - dnsPermission1->Demand(); - // Print the attributes and values. - Console::WriteLine( "Attributes and Values of 'DnsPermission' instance :" ); - PrintKeysAndValues( permission->ToXml()->Attributes ); - Console::WriteLine( "Attributes and Values of specified 'DnsPermission' instance :" ); - PrintKeysAndValues( dnsPermission1->ToXml()->Attributes ); - Subset( dnsPermission1 ); - } - -private: - void Subset( DnsPermission^ Permission1 ) - { - if ( permission->IsSubsetOf( Permission1 ) ) - { - Console::WriteLine( "Current 'DnsPermission' instance is a subset of specified 'DnsPermission' instance." ); - } - else - { - Console::WriteLine( "Current 'DnsPermission' instance is not a subset of specified 'DnsPermission' instance." ); - } - } - - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp b/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp deleted file mode 100644 index 0c760523b02..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -This program demonstrates the 'IsUnrestricted' method of 'DnsPermission' class. -It checks the overall permission state of the Object* and it will return true if the -'DnsPermission' instance was created with unrestricted permission state otherwise false. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ - // -public: - void useDns() - { - // Create a DnsPermission instance. - DnsPermission^ permission = gcnew DnsPermission( PermissionState::Unrestricted ); - // Check for permission. - permission->Demand(); - Console::WriteLine( "Attributes and Values of DnsPermission instance :" ); - // Print the attributes and values. - PrintKeysAndValues( permission->ToXml()->Attributes ); - // Check the permission state. - if ( permission->IsUnrestricted() ) - { - Console::WriteLine( "Overall permissions : Unrestricted" ); - } - else - { - Console::WriteLine( "Overall permissions : Restricted" ); - } - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash table. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp b/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp deleted file mode 100644 index d3f14c02e89..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -This program demonstrates 'BeginResolve' and 'EndResolve' methods of Dns class. -It obtains the 'IPHostEntry' Object* by calling 'BeginResolve' and 'EndResolve' method -of 'Dns' class by passing a URL, a callback function and an instance of 'RequestState' -class.Then prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; - -// -// -public ref class DnsBeginGetHostByName -{ -public: - static System::Threading::ManualResetEvent^ allDone = nullptr; - ref class RequestState - { - public: - IPHostEntry^ host; - RequestState() - { - host = nullptr; - } - }; - - static void RespCallback( IAsyncResult^ ar ) - { - try - { - // Convert the IAsyncResult* Object* to a RequestState Object*. - RequestState^ tempRequestState = dynamic_cast(ar->AsyncState); - - // End the asynchronous request. - tempRequestState->host = Dns::EndResolve( ar ); - allDone->Set(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } -}; - -int main() -{ - DnsBeginGetHostByName::allDone = gcnew ManualResetEvent( false ); - - // Create an instance of the RequestState class. - DnsBeginGetHostByName::RequestState^ myRequestState = - gcnew DnsBeginGetHostByName::RequestState; - - // Begin an asynchronous request for information like host name, IP addresses, or - // aliases for specified the specified URI. - IAsyncResult^ asyncResult = Dns::BeginResolve( "www.contoso.com", - gcnew AsyncCallback( DnsBeginGetHostByName::RespCallback ), myRequestState ); - - // Wait until asynchronous call completes. - DnsBeginGetHostByName::allDone->WaitOne(); - Console::WriteLine( "Host name : {0}", myRequestState->host->HostName ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < myRequestState->host->AddressList->Length; index++ ) - Console::WriteLine( myRequestState->host->AddressList[ index ] ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < myRequestState->host->Aliases->Length; index++ ) - Console::WriteLine( myRequestState->host->Aliases[ index ] ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp b/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp deleted file mode 100644 index 500d528483d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -This program demonstrates 'GetHostByAddress(IPAddress)' method of 'Dns' class. -It takes an IP address String* from commandline or uses default value and creates -an instance of IPAddress for the specified IP address String*. Obtains the IPHostEntry -Object* by calling 'GetHostByAddress' method of 'Dns' class and prints host name, -IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -class DnsHostByAddress -{ -public: - void DisplayHostAddress( String^ IpAddressString ) - { - // Call 'GetHostByAddress(IPAddress)' method giving an 'IPAddress' Object* as argument. - // Obtain an 'IPHostEntry' instance, containing address information of the specified host. - // - try - { - IPAddress^ hostIPAddress = IPAddress::Parse( IpAddressString ); - IPHostEntry^ hostInfo = Dns::GetHostByAddress( hostIPAddress ); - - // Get the IP address list that resolves to the host names contained in - // the Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases :" ); - for ( int index = 0; index < alias->Length; index++ ) - Console::WriteLine( alias[ index ] ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < address->Length; index++ ) - Console::WriteLine( address[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ IpAddressString = ""; - DnsHostByAddress * myDnsHostByAddress = new DnsHostByAddress; - Console::Write( "Type an IP address (press Enter for default, default is '207.46.131.199'): " ); - IpAddressString = Console::ReadLine(); - if ( IpAddressString->Length > 0 ) - myDnsHostByAddress->DisplayHostAddress( IpAddressString ); - else - myDnsHostByAddress->DisplayHostAddress( "207.46.131.199" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp b/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp deleted file mode 100644 index a65db62149f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -This program demonstrates 'GetHostByName' method of 'Dns' class. -It takes a URL String* from commandline or uses default value, and obtains -the 'IPHostEntry' Object* by calling 'GetHostByName' method of 'Dns' class.Then -prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class DnsHostByName -{ -public: - void DisplayHostName( String^ hostName ) - { - // Call the GetHostByName method passing a DNS style host name(for example, - // S"www.contoso.com") as an argument. - // Obtain the IPHostEntry instance, that contains information of the specified host. - // - try - { - IPHostEntry^ hostInfo = Dns::GetHostByName( hostName ); - - // Get the IP address list that resolves to the host names contained in the - // Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < alias->Length; index++ ) - Console::WriteLine( alias[ index ] ); - Console::WriteLine( "\nIP address list : " ); - for ( int index = 0; index < address->Length; index++ ) - Console::WriteLine( address[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ hostName = ""; - DnsHostByName^ myDnsHostByName = gcnew DnsHostByName; - Console::Write( "Type a URL (press Enter for default, default is 'www.microsoft.net') : " ); - hostName = Console::ReadLine(); - if ( hostName->Length > 0 ) - myDnsHostByName->DisplayHostName( hostName ); - else - myDnsHostByName->DisplayHostName( "www.microsoft.net" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp b/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp deleted file mode 100644 index 975e9204362..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -This program demonstrates the 'GetHostName' method of 'Dns' class. -It creates a 'DnsHostName' instance and calls 'GetHostName' method to get the local host -computer name. Then prints the computer name on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -public ref class DnsHostName -{ - // -public: - void DisplayLocalHostName() - { - try - { - // Get the local computer host name. - String^ hostName = Dns::GetHostName(); - Console::WriteLine( "Computer name : {0}", hostName ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - } - // -}; - -int main() -{ - DnsHostName^ dnsHostNameObj = gcnew DnsHostName; - dnsHostNameObj->DisplayLocalHostName(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp b/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp deleted file mode 100644 index f280df48999..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -This program demonstrates 'Resolve' method of 'Dns' class. -It takes a URL or IP address String* from commandline or uses default value and obtains the 'IPHostEntry' -Object* by calling 'Resolve' method of 'Dns' class. Then prints host name, IP address list and aliases. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -class DnsResolve -{ -public: - void DisplayHostAddress( String^ hostString ) - { - // Call the Resolve method passing a DNS style host name or an IP address in dotted-quad notation - // (for example, S"www.contoso.com" or S"207.46.131.199") to obtain an IPHostEntry instance that contains - // address information for the specified host. - // - try - { - IPHostEntry^ hostInfo = Dns::Resolve( hostString ); - - // Get the IP address list that resolves to the host names contained in the - // Alias property. - array^address = hostInfo->AddressList; - - // Get the alias names of the addresses in the IP address list. - array^alias = hostInfo->Aliases; - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "\nAliases : " ); - for ( int index = 0; index < alias->Length; index++ ) - { - Console::WriteLine( alias[ index ] ); - - } - Console::WriteLine( "\nIP Address list :" ); - for ( int index = 0; index < address->Length; index++ ) - { - Console::WriteLine( address[ index ] ); - - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NullReferenceException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - // - } -}; - -int main() -{ - String^ hostString = ""; - DnsResolve * myDnsResolve = new DnsResolve; - Console::Write( "Type a URL or IP address (press Enter for default, default is '207.46.131.199') : " ); - hostString = Console::ReadLine(); - if ( hostString->Length > 0 ) - myDnsResolve->DisplayHostAddress( hostString ); - else - myDnsResolve->DisplayHostAddress( "207.46.131.199" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp deleted file mode 100644 index ff1a5cacc7d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// System::Net::FileWebRequest::ContentLength;System::Net::FileWebRequest::RequestUri; - -/* -This program demonstrates 'ContentLength'and 'RequestUri' property of 'FileWebRequest' class. -The path of a file where user would like to write something is obtained from command line argument. -Then a 'WebRequest' Object* is created. The 'ContentLength' property of 'FileWebRequest' is used to -set the length of the file content that was written. -*/ - -#using - -using namespace System::Net; -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter where you want to write:" ); - Console::WriteLine( "Usage:FileWebRequest_ContentLen //\nExample:FileWebRequest_ContentLen shafeeque/shaf/hello.txt" ); - } - else - { - try - { - // Create an 'Uri' Object*. - Uri^ myUrl = gcnew Uri( String::Concat( "file://", args[ 1 ] ) ); - FileWebRequest^ myFileWebRequest = nullptr; - -// - myFileWebRequest = (FileWebRequest^)( WebRequest::Create( myUrl ) ); - - Console::WriteLine( "Enter the string you want to write into the file:" ); - String^ userInput = Console::ReadLine(); - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^ byteArray = encoder->GetBytes( userInput ); - - // Set the 'Method' property of 'FileWebRequest' Object* to 'POST' method. - myFileWebRequest->Method = "POST"; - - // The 'ContentLength' property is used to set the content length of the file. - myFileWebRequest->ContentLength = byteArray->Length; -// - -// - // Compare the file name and 'RequestUri' is same or not. - if ( myFileWebRequest->RequestUri->Equals( myUrl ) ) - { - // 'GetRequestStream' method returns the stream handler for writing into the file. - Stream^ readStream = myFileWebRequest->GetRequestStream(); - // Write to the stream - readStream->Write( byteArray, 0, userInput->Length ); - readStream->Close(); - } - - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - Console::WriteLine( "The content length sent to the server is {0}.", myFileWebRequest->ContentLength ); -// - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "The ArgumentException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatException is : {0}", e->Message ); - } - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp deleted file mode 100644 index 7203551b787..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp +++ /dev/null @@ -1,118 +0,0 @@ - - -// System::Net::FileWebRequest::BeginGetRequestStream;System::Net::FileWebRequest::EndGetRequestStream; -// Snippet1 and Snippet2 go together -/* -This program demonstrates 'BeginGetRequestStream' and 'EndGetRequestStream' method of 'FileWebRequest' class -The path of the file from where content is to be read is obtained as a command line argument and a 'webRequest' -Object* is created.Using the 'BeginGetRequestStream' method and 'EndGetRequestStream' of 'FileWebRequest' class -a stream Object* is obtained which is used to write into the file. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; - -// -// -public ref class RequestDeclare -{ -public: - FileWebRequest^ myFileWebRequest; - String^ userinput; - RequestDeclare() - { - myFileWebRequest = nullptr; - } - -}; - -ref class FileWebRequest_reqbeginend -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void ReadCallback( IAsyncResult^ ar ) - { - try - { - - // State of the request is asynchronous. - RequestDeclare^ requestDeclare = dynamic_cast(ar->AsyncState); - FileWebRequest^ myFileWebRequest = requestDeclare->myFileWebRequest; - String^ sendToFile = requestDeclare->userinput; - - // End the Asynchronus request by calling the 'EndGetRequestStream()' method. - Stream^ readStream = myFileWebRequest->EndGetRequestStream( ar ); - - // Convert the String* into Byte array. - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^byteArray = encoder->GetBytes( sendToFile ); - - // Write to the stream. - readStream->Write( byteArray, 0, sendToFile->Length ); - readStream->Close(); - allDone->Set(); - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - Console::WriteLine( "\nPress Enter to continue." ); - } - catch ( ApplicationException^ e ) - { - Console::WriteLine( "ApplicationException is : {0}", e->Message ); - } - - } - -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebRequest_reqbeginend //\n" ); - Console::WriteLine( "Example:FileWebRequest_reqbeginend shafeeque/shaf/hello.txt" ); - } - else - { - try - { - - // Place a webrequest. - WebRequest^ myWebRequest = WebRequest::Create( String::Concat( "file://", args[ 1 ] ) ); - - // Create an instance of the 'RequestDeclare' and associate the 'myWebRequest' to it. - RequestDeclare^ requestDeclare = gcnew RequestDeclare; - requestDeclare->myFileWebRequest = dynamic_cast(myWebRequest); - - // Set the 'Method' property of 'FileWebRequest' Object* to 'POST' method. - requestDeclare->myFileWebRequest->Method = "POST"; - Console::WriteLine( "Enter the String* you want to write into the file:" ); - requestDeclare->userinput = Console::ReadLine(); - - // Begin the Asynchronous request for getting file content using 'BeginGetRequestStream()' method . - IAsyncResult^ r = dynamic_cast(requestDeclare->myFileWebRequest->BeginGetRequestStream( gcnew AsyncCallback( &FileWebRequest_reqbeginend::ReadCallback ), requestDeclare )); - FileWebRequest_reqbeginend::allDone->WaitOne(); - Console::Read(); - } - catch ( ProtocolViolationException^ e ) - { - Console::WriteLine( "ProtocolViolationException is : {0}", e->Message ); - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "InvalidOperationException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatExceptionException is : {0}", e->Message ); - } - - } -} - -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp deleted file mode 100644 index 0a0ee8a55eb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp +++ /dev/null @@ -1,105 +0,0 @@ - - -// System::Net::FileWebRequest::BeginGetResponse;System::Net::FileWebRequest::EndGetResponse; -// Snippet1 and Snippet2 go together -/* -This program demonstrates 'BeginGetResponse' and 'EndGetResponse' methods of 'FileWebRequest' class. -The path of the file from where content is to be read is obtained as a command line argument and a -'WebRequest' Object* is created. Using the 'BeginGetResponse' method and 'EndGetResponse' of 'FileWebRequest' -class a 'FileWebResponse' Object* is obtained which is used to print the content on the file. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Threading; - -// -// -public ref class RequestDeclare -{ -public: - FileWebRequest^ myFileWebRequest; - RequestDeclare() - { - myFileWebRequest = nullptr; - } - -}; - -ref class FileWebRequest_resbeginend -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void RespCallback( IAsyncResult^ ar ) - { - - // State of request is asynchronous. - RequestDeclare^ requestDeclare = dynamic_cast(ar->AsyncState); - FileWebRequest^ myFileWebRequest = requestDeclare->myFileWebRequest; - - // End the Asynchronus request by calling the 'EndGetResponse()' method. - FileWebResponse^ myFileWebResponse = dynamic_cast(myFileWebRequest->EndGetResponse( ar )); - - // Reade the response into Stream. - StreamReader^ streamReader = gcnew StreamReader( myFileWebResponse->GetResponseStream() ); - array^readBuffer = gcnew array(256); - int count = streamReader->Read( readBuffer, 0, 256 ); - Console::WriteLine( "The contents of the file are :\n" ); - while ( count > 0 ) - { - String^ str = gcnew String( readBuffer,0,count ); - Console::WriteLine( str ); - count = streamReader->Read( readBuffer, 0, 256 ); - } - - streamReader->Close(); - - // Release the response Object* resources. - myFileWebResponse->Close(); - allDone->Set(); - Console::WriteLine( "File reading is over." ); - } - -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebRequest_resbeginend //\n" ); - Console::WriteLine( "Example:FileWebRequest_resbeginend shafeeque/shaf/hello.txt" ); - } - else - { - try - { - - // Place a 'Webrequest'. - WebRequest^ myWebRequest = WebRequest::Create( String::Concat( "file://", args[ 1 ] ) ); - - // Create an instance of the 'RequestDeclare' and associating the 'myWebRequest' to it. - RequestDeclare^ myRequestDeclare = gcnew RequestDeclare; - myRequestDeclare->myFileWebRequest = dynamic_cast(myWebRequest); - - // Begin the Asynchronous request for getting file content using 'BeginGetResponse()' method. - IAsyncResult^ asyncResult = dynamic_cast(myRequestDeclare->myFileWebRequest->BeginGetResponse( gcnew AsyncCallback( &FileWebRequest_resbeginend::RespCallback ), myRequestDeclare )); - FileWebRequest_resbeginend::allDone->WaitOne(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException is : {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatException is : {0}", e->Message ); - } - - } -} - -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp deleted file mode 100644 index 7125135810a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Net::FileWebResponse::Close -/*This program demontrates the 'Close' method of 'FileWebResponse' Class. -It takes an Uri from console and creates a 'FileWebRequest' Object* for the Uri::It then gets back -the response Object* from the Uri. The response Object* can be processed as desired. The program then -closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a FileWebrequest with the specified Uri. - FileWebRequest^ myFileWebRequest = dynamic_cast(WebRequest::Create( fileUrl )); - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = dynamic_cast(myFileWebRequest->GetResponse()); - // Process the response here. - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Release resources of response Object*. - myFileWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed." ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_Close // \nExample:FileWebResponse_Close microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp deleted file mode 100644 index 5dff4113057..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::FileWebResponse::ContentLength;System::Net::FileWebResponse::ContentType. - -/* This program demonstrates the 'ContentLength' and 'ContentType' properties of the 'FileWebResponse' class. -It creates a web request and queries for a response. It then prints the content length -and content type of the entity body in the response onto the console */ - -#using - -using namespace System; -using namespace System::Net; - -// -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object* with the specified Uri. - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - // Print the ContentLength and ContentType properties received as headers in the response Object*. - Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myFileWebResponse->ContentLength, myFileWebResponse->ContentType ); - // Release resources of response Object*. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_ContentLength_ContentType // \nExample:FileWebResponse_ContentLength_ContentType microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp deleted file mode 100644 index 37b23a614f8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// System::Net::FileWebResponse::GetResponseStream. - -/* This program demonstrates the 'GetResponseStream' method of the 'FileWebResponse' class. -It creates a 'FileWebRequest' Object* and queries for a response. -The response stream obtained is piped to a higher level stream reader. The reader reads -256 characters at a time, writes them into a String* and then displays the String* onto the console*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object* with the specified Uri. - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - // Send the 'FileWebRequest' Object* and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - - // Get the stream Object* associated with the response Object*. - Stream^ receiveStream = myFileWebResponse->GetResponseStream(); - - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received" ); - - array^ read = gcnew array(256); - // Read 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "File Data...\r\n" ); - while ( count > 0 ) - { - // Dump the 256 characters on a String* and display the String* onto the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - // Release resources of stream Object*. - readStream->Close(); - // Release resources of response Object*. - myFileWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the file name as command line parameter:" ); - Console::WriteLine( "Usage:FileWebResponse_GetResponseStream // \nExample:FileWebResponse_GetResponseStream microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp deleted file mode 100644 index 3d637455677..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// System::Net::FileWebResponse::Headers - -/* This program demonstrates the 'Headers' property of the 'FileWebResponse' class. -It creates a web request and queries for a response. It then prints [Out] all* the response -headers (name -value pairs) onto the console. */ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - // Create a 'FileWebrequest' Object^ with the specified Uri . - FileWebRequest^ myFileWebRequest = (FileWebRequest^)(WebRequest::Create( fileUrl )); - // Send the 'FileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)(myFileWebRequest->GetResponse()); - // Display all Headers present in the response received from the Uri. - Console::WriteLine( "\r\nThe following headers were received in the response:" ); - // Display each header and the key of the response Object^. - for ( int i = 0; i < myFileWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Header value : {1}", - myFileWebResponse->Headers->Keys[ i ], myFileWebResponse->Headers[ (HttpRequestHeader)i ] ); - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised: {0}", e->Message ); - } - -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the file name as command line parameter as:" ); - Console::WriteLine( "Usage:FileWebResponse_Headers // \nExample:FileWebResponse_Headers microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp b/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp deleted file mode 100644 index 677397be699..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::FileWebResponse::ResponseUri - -/* This program demonstrates the 'ResponseUri' property of the 'FileWebResponse' class. -It creates a 'FileWebRequest' Object* and queries for a response. It then displays the Uri of the file -system resource that provided the response. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ fileUrl = gcnew Uri( String::Concat( "file://", url ) ); - - // Create a 'FileWebrequest' object with the specified Uri . - FileWebRequest^ myFileWebRequest = (FileWebRequest^)( WebRequest::Create( fileUrl ) ); - - // Send the 'fileWebRequest' and wait for response. - FileWebResponse^ myFileWebResponse = (FileWebResponse^)( myFileWebRequest->GetResponse() ); - Console::WriteLine( "\nThe Uri of the file system resource that provided the response is :\n {0}\n\n", myFileWebResponse->ResponseUri ); - - // Release resources of response object. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException thrown. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the file name as command line parameter as:" ); - Console::WriteLine( "Usage:FileWebResponse_ResponseUri // \nExample:FileWebResponse_ResponseUri microsoft/shared/hello.txt" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp deleted file mode 100644 index 21704539710..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*System::Net::HttpVersion::Version10 -This program demonstrates the 'Version10' field of the 'HttpVersion' Class. -The 'Version' property of 'HttpRequestMessage' class identifies the Version of HTTP being used. -Then the default value of 'Version' property is displayed to the console. -The 'Version10' field of the 'HttpVersion' class is assigned to the 'Version' property of the 'HttpRequestMessage' Class. -The changed Version and the 'Version' of the response object are displayed. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Http; - -int main() -{ - try - { - // - // HttpClient lifecycle management best practices: - // https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-guidelines#recommended-use - HttpClient^ client = gcnew HttpClient(); - - HttpRequestMessage^ request = new HttpRequestMessage(HttpMethod::Get, "http://www.microsoft.com"); - Console::WriteLine("Default HTTP request version is {0}", request.Version); - - request.Version = HttpVersion.Version10; - Console::WriteLine("Request version after assignment is {0}", request.Version); - - HttpResponseMessage^ response = client->Send(request); - Console::WriteLine("Response HTTP version {0}", response.Version); - // - Console::WriteLine("\nPress 'Enter' Key to Continue.............."); - Console::Read(); - } - catch (HttpRequestException^ e) - { - Console::WriteLine("HttpRequestException Caught!"); - Console::WriteLine("Message : {0} ", e->Message); - Console::WriteLine("Source : {0} ", e->Source); - } - catch (Exception^ e) - { - Console::WriteLine("Exception Caught!"); - Console::WriteLine("Source : {0}", e->Source); - Console::WriteLine("Message : {0}", e->Message); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp deleted file mode 100644 index defe1c29135..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* System::Net::HttpWebRequest::Accept -This program demonstrates 'Accept' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created. The 'Accept' property of 'HttpWebRequest' -class is set to 'image/*' that in turn sets the 'Accept' field of HTTP Request Headers to -S"image/*". HTTP Request and Response headers are displayed to the console. -The contents of the page of the requested URI are displayed to the console. -'Accept' property is set with an aim to receive the response in a specific format. - -Note: This program requires http://localhost/CodeSnippetTest::html as Command line parameter. -If the requested page contains any content other than 'image/*' an error of 'status (406) Not Acceptable' -is returned. The functionality of 'Accept' property is supported only by servers that use HTTP 1.1 -protocol.Please refer to RFC 2616 for further information on HTTP Headers. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Set the 'Accept' property to accept an image of any type. - myHttpWebRequest->Accept = "image/*"; - // The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - Console::WriteLine( "Press 'Enter' Key to Continue......." ); - Console::Read(); - // Displaying the contents of the page to the console - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter" ); - Console::WriteLine( "Usage:HttpWebRequest_Accept http://www.microsoft.com/library/homepage/images/ms-banner.gif" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp deleted file mode 100644 index 1e2f153e109..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* System::Net::HttpWebRequest::AllowAutoRedirect System::Net::HttpWebRequest->Address -This program demonstrates the 'AllowAutoRedirect' and 'Address' properties of the 'HttpWebRequest' Class. -A new 'HttpWebRequest' Object* is created. The 'AllowAutoredirect' property, which redirects a page automatically -to the new Uri, is set to true. Using the 'Address' property, the address of the 'Responding Uri' is printed to -console. The contents of the redirected page are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// - // Create a new HttpWebRequest Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->MaximumAutomaticRedirections = 1; - myHttpWebRequest->AllowAutoRedirect = true; - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nThe Requested Uri is {0}", myHttpWebRequest->RequestUri ); - Console::WriteLine( "\nThe Actual Uri responding to the request is \n {0}", myHttpWebRequest->Address ); -// - Console::WriteLine( "\nPress any Key to Continue.........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\nMessage: {0}", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp deleted file mode 100644 index da5e28f5284..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*System::Net::HttpWebRequest::AllowWriteStreamBuffering -This program demonstrates 'AllowWriteStreamBuffering' property of 'HttpWebRequestClass'. -A new 'HttpWebRequest' Object* is created. -The 'AllowWriteStreamBuffering' property value is set to false. -If the 'AllowWriteStreamBuffering' is set to false, -then 'ContentLength' property should be set to the length of data to be posted before posting the data -else the Http Status(411) Length required is returned. -Data to be posted to the Uri is requested from the user. -The 'Method' property is set to POST to be able to post data to the Uri. -The 'GetRequestStream' method of the 'HttpWebRequest' class returns a stream Object*. -This stream Object* is used to write data to the Uri. -The HTML contents of the page are displayed to the console after the posted data is accepted by the URL - -Note:This program posts data to the Uri : http://www20.brinkster.com/codesnippets/next.asp. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' object to the mentioned Uri. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com/codesnippets/next.asp" ) ); - // Set AllowWriteStreamBuffering to 'false'. - myHttpWebRequest->AllowWriteStreamBuffering = false; - Console::WriteLine( "\nPlease Enter the data to be posted to the (http://www.contoso.com/codesnippets/next.asp) uri:" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "firstone= ", inputData ); - // Set 'Method' property of 'HttpWebRequest' class to POST. - myHttpWebRequest->Method = "POST"; - ASCIIEncoding^ encodedData = gcnew ASCIIEncoding; - array^ byteArray = encodedData->GetBytes( postData ); - // Set 'ContentType' property of the 'HttpWebRequest' class to S"application/x-www-form-urlencoded". - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - // If the AllowWriteStreamBuffering property of HttpWebRequest is set to false, the contentlength has to be set to length of data to be posted else Exception(411) is raised. - myHttpWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - newStream->Close(); - Console::WriteLine( "\nData has been posted to the Uri\n\nPlease wait for the response.........." ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - Console::WriteLine( "\n(The 'ContentLength' property of 'HttpWebRequest' is not set after 'AllowWriteStreamBuffering' is set to 'false'.)" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp deleted file mode 100644 index 452b35e9ca7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* System::Net::HttpWebRequest::BeginGetRequestStream, System::Net::HttpWebRequest::EndGetRequestStream - -This program demonstrates the 'BeginGetRequestStream' and 'EndGetRequestStream' methods of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object is created. The 'Method' property of the 'HttpWebRequest' Object* is set to -'POST'. The 'ContentType' property is set to S"application/x-www-form-urlencoded". Then, the 'BeginGetRequestStream' -method of 'HttpWebRequest' class starts the Asynchronous writing to the 'HttpWebRequest' Object*. The -'EndGetRequestStream' method of 'HttpWebRequest' class ends the Asynchronous writing of data and returns a -stream Object*. The 'Stream' Object* is used to write data to the 'HttpWebRequest' Object*. - -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -ref class HttpWebRequestBeginGetRequest -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void Main() - { - - // - // Create a new HttpWebRequest object. - HttpWebRequest^ request = dynamic_cast(WebRequest::Create( "http://www.contoso.com/example.aspx" )); - - // Set the ContentType property. - request->ContentType = "application/x-www-form-urlencoded"; - - // Set the Method property to 'POST' to post data to the Uri. - request->Method = "POST"; - - // Start the asynchronous operation. - AsyncCallback^ del = gcnew AsyncCallback(GetRequestStreamCallback); - request->BeginGetRequestStream( del, request ); - - // Keep the main thread from continuing while the asynchronous - // operation completes. A real world application - // could do something useful such as updating its user interface. - allDone->WaitOne(); - } - - -private: - static void GetRequestStreamCallback(IAsyncResult^ asynchronousResult) - { - HttpWebRequest^ request = dynamic_cast(asynchronousResult->AsyncState); - - // End the operation - Stream^ postStream = request->EndGetRequestStream(asynchronousResult); - - Console::WriteLine("Please enter the input data to be posted:"); - String^ postData = Console::ReadLine(); - - // Convert the string into a byte array. - array^ByteArray = Encoding::UTF8->GetBytes(postData); - - // Write to the request stream. - postStream->Write(ByteArray, 0, postData->Length); - postStream->Close(); - - // Start the asynchronous operation to get the response - AsyncCallback^ del = gcnew AsyncCallback(GetResponseCallback); - request->BeginGetResponse(del, request); - } - - static void GetResponseCallback(IAsyncResult^ asynchronousResult) - { - HttpWebRequest^ request = dynamic_cast(asynchronousResult->AsyncState); - - // End the operation - HttpWebResponse^ response = dynamic_cast(request->EndGetResponse(asynchronousResult)); - Stream^ streamResponse = response->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader(streamResponse); - String^ responseString = streamRead->ReadToEnd(); - Console::WriteLine(responseString); - // Close the stream object - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse - response->Close(); - allDone->Set(); - } - // -}; - -void main() -{ - HttpWebRequestBeginGetRequest::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp deleted file mode 100644 index 6d2c9db2782..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp +++ /dev/null @@ -1,94 +0,0 @@ - - -// System::Net::HttpWebRequest::KeepAlive System::Net::HttpWebRequest::Connection -/** -* This program demonstrates Connection and KeepAlive properties of the -* HttpWebRequest Class. -* Two new HttpWebRequest objects are created. The KeepAlive property of one of -* the objects is set to false that in turn sets the value of Connection field of -* the HTTP request Headers to Close. -* The Connection property of the other HttpWebRequest Object* is assigned the -* value Close. This throws an ArgumentException which is caught. The HTTP request -* Headers are displayed to the console. -* The contents of the HTML page of the requested URI are displayed. -**/ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -// -int main() -{ - try - { - - // Create a new HttpWebRequest object. Make sure that - // a default proxy is set if you are behind a firewall. - HttpWebRequest^ myHttpWebRequest1 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - myHttpWebRequest1->KeepAlive = false; - - // Assign the response object of HttpWebRequest to a HttpWebResponse variable. - HttpWebResponse^ myHttpWebResponse1 = dynamic_cast(myHttpWebRequest1->GetResponse()); - Console::WriteLine( "\nThe HTTP request Headers for the first request are: \n {0}", myHttpWebRequest1->Headers ); - Console::WriteLine( "Press Enter Key to Continue.........." ); - Console::Read(); - Stream^ streamResponse = myHttpWebResponse1->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "The contents of the Html page are.......\n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - Console::WriteLine(); - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the resources held by response object. - myHttpWebResponse1->Close(); - - // - // Create a new HttpWebRequest object for the specified Uri. - HttpWebRequest^ myHttpWebRequest2 = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - myHttpWebRequest2->Connection = "Close"; - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse2 = dynamic_cast(myHttpWebRequest2->GetResponse()); - - // Release the resources held by response object. - myHttpWebResponse2->Close(); - Console::WriteLine( "\nThe Http RequestHeaders are \n {0}", myHttpWebRequest2->Headers ); - - // - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "\nThe second HttpWebRequest Object* has raised an Argument Exception as 'Connection' Property is set to 'Close'" ); - Console::WriteLine( "\n {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp deleted file mode 100644 index 39d85a9efc9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -System::Net::HttpWebRequest::Method, System::Net::HttpWebRequest::ContentLength, System::Net::HttpWebRequest::ContentType -System::Net::HttpWebRequest::GetRequestStream -This program the demonstrates 'Method', 'ContentLength', and 'ContentType' properties and the 'GetRequestStream' -method of the HttpWebRequest Class. -It creates a 'HttpWebRequest' Object*. The 'Method' property of 'HttpWebRequestClass' is set to 'POST'. -The 'ContentType' property is set to 'application/x-www-form-urlencoded'. The 'ContentLength' property -is set to the length of the Byte stream to be posted. A new 'Stream' Object* is obtained from the -'GetRequestStream' method of the 'HttpWebRequest' class. Data to be posted is requested from the user. -Data is posted using the stream Object*. The HTML contents of the page are then displayed to the console -after the Posted data is accepted by the URL. -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { - // Create a new WebRequest Object to the mentioned Uri. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com/codesnippets/next.asp" ) ); - - Console::WriteLine( "\nThe value of 'ContentLength' property before sending the data is {0}", myHttpWebRequest->ContentLength ); - -// -// - // Set the 'Method' property of the 'Webrequest' to 'POST'. - myHttpWebRequest->Method = "POST"; - Console::WriteLine( "\nPlease enter the data to be posted to the (http://www.contoso.com/codesnippets/next.asp) Uri :" ); - - // Create a new String* Object* to POST data to the Url. - String^ inputData = Console::ReadLine(); - -// -// - String^ postData = String::Concat( "firstone= ", inputData ); - ASCIIEncoding^ encoding = gcnew ASCIIEncoding; - array^ byte1 = encoding->GetBytes( postData ); - - // Set the content type of the data being posted. - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the content length of the String* being posted. - myHttpWebRequest->ContentLength = byte1->Length; - - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - - newStream->Write( byte1, 0, byte1->Length ); - Console::WriteLine( "The value of 'ContentLength' property after sending the data is {0}", myHttpWebRequest->ContentLength ); - - // Close the Stream Object*. - newStream->Close(); -// -// -// -// - Console::WriteLine( "\nThe String* entered is successfully posted to the Uri " ); - Console::WriteLine( "Please wait for the response......." ); - - // Assign the response Object* of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - - Console::WriteLine( "\nThe contents of the HTML page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the resources held by response Object*. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue............." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp deleted file mode 100644 index dbc0defcc7f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*System::Net::HttpWebRequest::Headers -This program demonstrates the 'Headers' property of 'HttpWebRequest' Class. -A new 'HttpWebRequest' Object* is created. -The (name, value) collection of the Http Headers are displayed to the console. -The contents of the HTML page of the requested URI are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe HttpHeaders are \n\n\tName\t\tValue\n {0}", myHttpWebRequest->Headers ); - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe HTML contents of page the are : \n\n " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - Console::WriteLine( "Status : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp deleted file mode 100644 index 2ffbd73948e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -/* -System::Net::HttpWebRequest::IfModifiedSince -This program demonstrates the 'IfModifiedSince' property of the 'HttpWebRequest' class . -A new 'HttpWebrequest' Object* is created. -A new 'DateTime' Object* is created with the value intialized to the present DateTime. -The 'IfModifiedSince' property of 'HttpWebRequest' Object* is compared with the 'DateTime' Object*. -If the requested page has been modified since the time of the DateTime Object* -then the output displays the page has been modified -else the response headers and the contents of the page of the requested Uri are printed to the Console. -*/ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -int main() -{ - try - { - - // - // Create a new 'Uri' object with the mentioned string. - Uri^ myUri = gcnew Uri( "http://www.contoso.com" ); - - // Create a new 'HttpWebRequest' object with the above 'Uri' object. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( myUri )); - - // Create a new 'DateTime' object. - DateTime targetDate = DateTime::Now; - // Set a target date of a week ago - targetDate.AddDays(-7.0); - myHttpWebRequest->IfModifiedSince = targetDate; - - try - { - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Response headers \n {0}\n", myHttpWebResponse->Headers ); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - if (e->Response) - { - if ( ((HttpWebResponse ^)e->Response)->StatusCode == HttpStatusCode::NotModified) - Console::WriteLine("\nThe page has not been modified since {0}", targetDate); - else - Console::WriteLine("\nUnexpected status code = {0}", ((HttpWebResponse ^)e->Response)->StatusCode); - } - else - Console::WriteLine("\nUnexpected Web Exception {0}" + e->Message); - } -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp deleted file mode 100644 index df05ea9c022..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*System::Net.HttpWebRequest::PipeLined -This program demonstrates 'Pipelined' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created. The 'Pipelined' property is displayed to the console. -HTTP Request and Response Headers are displayed to the console. The contents of the page of the -requested URI are displayed to the console. - -Note:The 'Pipelined' property is supported only by servers that allow Pipelining of requests. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - streamRead->Close(); - streamResponse->Close(); - // Release the response object resources. - myHttpWebResponse->Close(); - Console::WriteLine( "\n'Pipelined' property is: {0}", myHttpWebRequest->Pipelined ); - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter:" ); - Console::WriteLine( "->Item[ Usage:HttpWebRequest_Pipelined http://www.microsoft.com ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp deleted file mode 100644 index c8320fd47ff..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* System::Net::HttpWebRequest::ProtocolVersion -This Program demonstrates the 'ProtocolVersion' property of the 'HttpWebRequest' Class. -The 'ProtocolVersion' is a property that identifies the Version of the Protocol being used. -A new 'HttpWebRequest' Object* is created. Then the default version, being used is displayed onto -the console. It is then set to another version and displayed to the Console::The HTML contents -of the page of the requested Uri are printed to the console. -Note: Here the 'ProtocolVersion' property displays the ProtocolVersion being used. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.microsoft.com" ) ); - // Use the existing 'ProtocolVersion' , and display it onto the console. - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol used is {0}", myHttpWebRequest->ProtocolVersion ); - // Set the 'ProtocolVersion' property of the 'HttpWebRequest' to 'Version1::0' . - myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe 'ProtocolVersion' of the protocol changed to {0}", myHttpWebRequest->ProtocolVersion ); - Console::WriteLine( "\nThe protocol version of the response Object* is {0}", myHttpWebResponse->ProtocolVersion ); -// - Console::WriteLine( "\nPress any Key to Continue.............." ); - Console::Read(); - Console::Read(); - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML Page are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue.............." ); - Console::Read(); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised!" ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp deleted file mode 100644 index b5053d05743..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*System::Net::HttpWebRequest::Referer -This program demonstrates the 'Referer' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created. The 'Referer' property is displayed to the console. -HTTP Request and Response Headers are displayed to the console. The contents of the page of the -requested URI are displayed to the console. - -Note: The 'Referer' property is used by the server to store the address of the Uri that has referred -the request to that server.Please refer to RFC 2616 for more information on HTTP Headers. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// - // Create a 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Set referer property to http://www.microsoft.com . - myHttpWebRequest->Referer = "http://www.microsoft.com"; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML page are......." ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - Console::WriteLine( "\nHTTP Request Headers :\n\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nHTTP Response Headers :\n\n {0}", myHttpWebResponse->Headers ); - streamRead->Close(); - streamResponse->Close(); - // Release the response object resources. - myHttpWebResponse->Close(); - Console::WriteLine( "Referer to the site is: {0}", myHttpWebRequest->Referer ); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue......" ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter" ); - Console::WriteLine( "->Item[ Usage:HttpWebRequest_Referer http://www.microsoft.com ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp deleted file mode 100644 index a5409b84b58..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -System::Net::HttpWebRequest::SendChunked -System::Net::HttpWebRequest::TransferEncoding -This program demonstrates the 'TransferEncoding' and 'SendChunked' properties of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created. The 'SendChunked' property value is set to 'true' and the -'TransferEncoding' property is set to S"gzip". If the 'TransferEncoding' property is set with 'SendChunked' -property set to 'false' then 'InvalidOperationException' is raised. Data to be posted to the Uri is -requested from the user. The HTML contents of the page are displayed to the console after the posted -data is accepted by the URL - -Note: This program requires http://localhost/CodeSnippetTest::asp as command-line parameter. -If the 'TransferEncoding' of type 'gzip' is not implemented by the server an error of status -'(501) Not implemented' is returned. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -void GetPage( String^ myUri ) -{ - try - { -// -// - // A new 'HttpWebRequest' object is created. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - myHttpWebRequest->SendChunked = true; - // 'TransferEncoding' property is set to 'gzip'. - myHttpWebRequest->TransferEncoding = "gzip"; - Console::WriteLine( "\nPlease Enter the data to be posted to the (http:///CodeSnippetTest::asp) uri:" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "testdata= ", inputData ); - // 'Method' property of 'HttpWebRequest' class is set to POST. - myHttpWebRequest->Method = "POST"; - ASCIIEncoding^ encodedData = gcnew ASCIIEncoding; - array^ byteArray = encodedData->GetBytes( postData ); - // 'ContentType' property of the 'HttpWebRequest' class is set to S"application/x-www-form-urlencoded". - myHttpWebRequest->ContentType = "application/x-www-form-urlencoded"; - // 'ContentLength' property is set to Length of the data to be posted. - myHttpWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myHttpWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - newStream->Close(); - Console::WriteLine( "\nData has been posted to the Uri\n\nPlease wait for the response.........." ); - // The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Displaying the contents of the page to the console - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML page are : " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// -// - Console::WriteLine( "\nPress 'Enter' Key to Continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - try - { - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Uri address as a command line parameter:" ); - Console::WriteLine( "[ Usage:HttpWebRequest_Sendchunked http:///CodeSnippetTest.asp ]" ); - } - else - { - GetPage( args[ 1 ] ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp deleted file mode 100644 index 3d42654bab4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/*System::Net::HttpWebRequest::Time->Item[Out] -This program demonstrates the 'Timeout' property of the HttpWebRequest Class. -A new HttpWebRequest Object is created. The default value of the 'Timeout' property is printed to the console. -It is then set to some value and displayed to the console. If the 'Timeout' property is set to a value less -than the time required to get the response an 'Exception' is raised. The 'Timeout' property measures the time in -milliseconds. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' Object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - Console::WriteLine( "\nThe timeout time of the request before setting the property is {0} milliseconds.", myHttpWebRequest->Timeout ); - // Set the 'Timeout' property of the HttpWebRequest to 10 milliseconds. - myHttpWebRequest->Timeout = 10; - // Display the 'Timeout' property of the 'HttpWebRequest' on the console. - Console::WriteLine( "\nThe timeout time of the request after setting the timeout is {0} milliseconds.", myHttpWebRequest->Timeout ); - // A HttpWebResponse object is created and is GetResponse Property of the HttpWebRequest associated with it - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); -// - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the HTML page are, " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue............." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised!" ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp deleted file mode 100644 index 3ef82849abc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*System::Net::HttpWebRequest::UserAgent -This program demonstrates the 'UserAgent' property of the 'HttpWebRequest' class. -A new 'HttpWebRequest' Object* is created. The 'UserAgent' property is set to -"Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0; COM+ 1.0.2702)". -This in turn sets the 'User-Agent' field of HTTP Request headers. -The response is obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a new 'HttpWebRequest' object to the mentioned URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->UserAgent = ".NET Framework Test Client"; - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML Page are :\n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nHTTP Request Headers :\n {0}", myHttpWebRequest->Headers ); - Console::WriteLine( "\nUserAgent is: {0}", myHttpWebRequest->UserAgent ); - Console::WriteLine( "\nPress 'Enter' Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - Console::WriteLine( "Status : {0} ", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp deleted file mode 100644 index d91c5e15fe4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Net::HttpWebResponse::Close -/* This program demonstrates the 'Close' method of the 'HttpWebResponse' class. -It creates a web request and queries for a response. The response Object* can be processed as desired. -The program then closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - // Sends the HttpWebRequest and waits for a response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed" ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Close http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp deleted file mode 100644 index 3b3d5bf4ec6..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ -// - try - { - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - - Console::WriteLine( "The encoding method used is: {0}", myHttpWebResponse->ContentEncoding ); - Console::WriteLine( "The character set used is : {0}", myHttpWebResponse->CharacterSet ); - - char separator = '/'; - String^ contenttype = myHttpWebResponse->ContentType; - // Retrieve 'text' if the content type is of 'text/html. - String^ maintype = contenttype->Substring( 0, contenttype->IndexOf( separator ) ); - // Display only 'text' type. - if ( String::Compare( maintype, "text" ) == 0 ) - { - Console::WriteLine( "\n Content type is 'text'." ); -// - -// - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - - Console::WriteLine( "\r\nResponse stream received." ); - array^ read = gcnew array(256); - - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "\nText retrieved from the URL follows:\r\n" ); - - int index = 0; - while ( index < myHttpWebResponse->ContentLength ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ str = gcnew String( read,0,count ); - Console::WriteLine( str ); - index += count; - count = readStream->Read( read, 0, 256 ); - } - receiveStream->Close(); - Console::WriteLine( "" ); - } - // Release the resources of response object. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ContentLength_ContentType http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp deleted file mode 100644 index 30522491953..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// System::Net::HttpWebResponse::GetResponseHeader -/* This program demonstrates the 'GetResponseHeader' method of the 'HttpWebResponse' class. -It creates a web request and queries for a response. If the site requires authentication it -will respond with a challenge String* which is extracted using 'GetResponse()' method. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void GetPage( String^ url ) -{ - try - { - Uri^ ourUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( ourUri ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - Console::WriteLine( "\nThe server did not issue any challenge. Please try again with a protected resource URL." ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - HttpWebResponse^ response = (HttpWebResponse^)( e->Response ); - if ( response != nullptr ) - { - if ( response->StatusCode == HttpStatusCode::Unauthorized ) - { - String^ challenge = nullptr; - challenge = response->GetResponseHeader( "WWW-Authenticate" ); - if ( challenge != nullptr ) - Console::WriteLine( "\nThe following challenge was raised by the server: {0}", challenge ); - } - else - { - Console::WriteLine( "\nThe following WebException was raised : {0}", e->Message ); - } - } - else - { - Console::WriteLine( "\nResponse Received from server was 0" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter a protected resource url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_GetResponseHeader http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp deleted file mode 100644 index 06388e73b74..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// System::Net::HttpWebResponse::GetResponseStream -/* This program demonstrates the 'GetResponseStream' method of the 'HttpWebResponse' class. -It creates a web request and queries for a response. It then gets the response stream. -This response stream is piped to a higher level stream reader. The reader reads 256 characters at a time, -writes them into a String* and then displays the String* in the console. */ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - // Creates an HttpWebRequest with the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - // Sends the HttpWebRequest and waits for the response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Gets the stream associated with the response. - Stream^ receiveStream = myHttpWebResponse->GetResponseStream(); - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - // Pipes the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( receiveStream,encode ); - Console::WriteLine( "\r\nResponse stream received." ); - array^ read = gcnew array(256); - // Reads 256 characters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - while ( count > 0 ) - { - // Dumps the 256 characters on a String* and displays the String* to the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - Console::WriteLine( "" ); - // Releases the resources of the response. - myHttpWebResponse->Close(); - // Releases the resources of the Stream. - readStream->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_GetResponseStream http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp deleted file mode 100644 index 29ad6442cd2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// System::Net::HttpWebResponse::Headers - -/* This program demonstrates the 'Headers' property of the 'HttpWebResponse' class -It creates a web request and queries for a response. It then displays all the response headers -onto the console. */ -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { - // - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - - // Sends the HttpWebRequest and waits for response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Displays all the headers present in the response received from the URI. - Console::WriteLine( "\r\nThe following headers were received in the response:" ); - - // Displays each header and its key associated with the response. - for ( int i = 0; i < myHttpWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Value : {1}", - myHttpWebResponse->Headers->Keys[ i ], - myHttpWebResponse->Headers[ (System::Net::HttpRequestHeader)i ] ); - - // Releases the resources of the response. - myHttpWebResponse->Close(); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Headers http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp deleted file mode 100644 index 07b78aa598f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::HttpWebResponse::LastModified -/* This program demonstrates the 'LastModified' property of the 'HttpWebResponse' class -It creates a web request and queries for a response. The program checks -if the entity requested was modified any time today. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ myUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\r\nRequest succeeded and the requested information is in the response , Description : {0}", - myHttpWebResponse->StatusDescription ); - } - DateTime today = DateTime::Now; - // Uses the LastModified property to compare with today's date. - if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 0 ) - { - Console::WriteLine( "\nThe requested URI entity was modified today" ); - } - else if ( DateTime::Compare( today, myHttpWebResponse->LastModified ) == 1 ) - { - Console::WriteLine( "\nThe requested URI was last modified on: {0}", - myHttpWebResponse->LastModified ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_LastModified http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp deleted file mode 100644 index 527ce130a0f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::HttpWebResponse::Method;System::Net::HttpWebResponse::Server -/* This program demonstrates the 'Method' and 'Server' properties of the 'HttpWebResponse' class. -It creates a Web request and queries for a response. It evaluates the response method used and the prints -the Web server name to the console*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ -// -// - try - { - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( url ) ); - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - String^ method; - method = myHttpWebResponse->Method; - if ( String::Compare( method, "GET" ) == 0 ) - { - Console::WriteLine( "\nThe 'GET' method was successfully invoked on the following Web Server : {0}", - myHttpWebResponse->Server ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -// -// -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_Method_Server http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp deleted file mode 100644 index 932674a8594..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::HttpWebResponse::ProtocolVersion -/* This program demonstrates the 'ProtocolVersion' property of the 'HttpWebResponse' class. -It creates a web request and queries for a response. The server should respond using the same version */ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ ourUri = gcnew Uri( url ); - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( ourUri ) ); - myHttpWebRequest->ProtocolVersion = HttpVersion::Version10; - // Sends the HttpWebRequest and waits for the response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - // Ensures that only Http/1.0 responses are accepted. - if ( myHttpWebResponse->ProtocolVersion != HttpVersion::Version10 ) - { - Console::WriteLine( "\nThe server responded with a version other than Http/1.0" ); - } - else if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\nRequest sent using version Http/1.0. Successfully received response with version HTTP/1.0 " ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ProtocolVersion http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp deleted file mode 100644 index 96ee68302ee..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Net::HttpWebResponse::ResponseUri -/*This program demonstrates the 'ResponseUri' property of the 'HttpWebResponse' class -It creates a web request and queries for a response. It checks if the original Uri -was redirected by the server. */ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ myUri = gcnew Uri( url ); - // Create a 'HttpWebRequest' object for the specified url. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) ); - // Send the request and wait for response. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\nRequest succeeded and the requested information is in the response , Description : {0}", - myHttpWebResponse->StatusDescription ); - } - if ( myUri->Equals( myHttpWebResponse->ResponseUri ) ) - { - Console::WriteLine( "\nThe Request Uri was not redirected by the server" ); - } - else - { - Console::WriteLine( "\nThe Request Uri was redirected to : {0}", myHttpWebResponse->ResponseUri ); - } - // Release resources of response Object*. - myHttpWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_ResponseUri http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp b/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp deleted file mode 100644 index 21dba8b604f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Net::HttpWebResponse::StatusCode; System::Net::HttpWebResponse::StatusDescription - -/* This program demonstrates the 'StatusCode' and 'StatusDescription' property of the 'HttpWebResponse' class. -It creates a web request and queries for a response. */ - -#using - -using namespace System; -using namespace System::Net; - -// -// -void GetPage( String^ url ) -{ - try - { - // Creates an HttpWebRequest for the specified URL. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( url )); - // Sends the HttpWebRequest and waits for a response. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK ) - { - Console::WriteLine( "\r\nResponse Status Code is OK and StatusDescription is: {0}", - myHttpWebResponse->StatusDescription ); - } - // Releases the resources of the response. - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised. The following error occurred : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised : {0}", e->Message ); - } -} -// -// - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "HttpWebResponse_StatusCode_StatusDescription http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp b/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp deleted file mode 100644 index ebd4e3a0178..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -/*System::Net::HttpWebRequest::HaveResponse - -This program demonstrates 'HaveResponse' property of 'HttpWebRequest' Class. -A new 'HttpWebRequest' is created. -The 'HaveResponse' property is a ReadOnly, boolean property that indicates -whether the Request Object* has received any response or not. -The default value of 'HaveResponse' property of the 'HttpWebRequest' is displayed to the console. -The HttpWebResponse variable is assigned the response Object* of 'HttpWebRequest'. -The HaveReponse property is tested for its value. -If there is a response then the HTML contents of the page of the requested Uri are displayed to the console -else a message 'The response is not received' is displayed to the console. - -*/ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; -int main() -{ - try - { - - // - // Create a new 'HttpWebRequest' Object. - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.contoso.com" )); - HttpWebResponse^ myHttpWebResponse; - - // Display the 'HaveResponse' property of the 'HttpWebRequest' object to the console. - Console::WriteLine( "\nThe value of 'HaveResponse' property before a response object is obtained : {0}", myHttpWebRequest->HaveResponse ); - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - if ( myHttpWebRequest->HaveResponse ) - { - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of Html Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myHttpWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue.........." ); - Console::Read(); - } - else - { - Console::WriteLine( "\nThe response is not received " ); - } - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught" ); - Console::WriteLine( "\nSource : {0}", e->Source ); - Console::WriteLine( "\nMessage : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp b/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp deleted file mode 100644 index 28631707a47..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*System::Net::HttpWebRequest::Proxy -This program demonstrates the 'Proxy' property of the 'HttpWebRequest' class. -A 'HttpWebRequest' Object* and a 'Proxy' Object* is created. The Proxy Object is then assigned to -the 'Proxy' property of the 'HttpWebRequest' Object* and printed onto the console (this is the default -Proxy setting).New Proxy address and the credentials are requested from the User::A new Proxy Object* is -then constructed from the supplied inputs. Then the 'Proxy' property of the request is associated with the new -Proxy Object*. -Note: No credentials are required if the Proxy does not require any authentication. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - HttpWebRequest ^ myWebRequest = - (HttpWebRequest ^) (WebRequest::Create("http://www.microsoft.com")); - - // Obtain the 'Proxy' of the Default browser. - IWebProxy ^ proxy = myWebRequest->Proxy; - // Print the Proxy Url to the console. - if (proxy) - { - Console::WriteLine("Proxy: {0}", - proxy->GetProxy(myWebRequest->RequestUri)); - } - else - { - Console::WriteLine("Proxy is null; no proxy will be used"); - } - - WebProxy ^ myProxy = gcnew WebProxy; - - Console::WriteLine("\nPlease enter the new Proxy Address that is to be set:"); - Console::WriteLine("(Example:http://myproxy.example.com:port)"); - String ^ proxyAddress; - - try - { - proxyAddress = Console::ReadLine(); - if (proxyAddress->Length > 0) { - Console::WriteLine("\nPlease enter the Credentials "); - Console::WriteLine("Username:"); - String ^ username; - username = Console::ReadLine(); - Console::WriteLine("\nPassword:"); - String ^ password; - password = Console::ReadLine(); - // Create a new Uri object. - Uri ^ newUri = gcnew Uri(proxyAddress); - // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set. - myProxy->Address = newUri; - // Create a NetworkCredential object and associate it with the Proxy property of request object. - myProxy->Credentials = - gcnew NetworkCredential(username, password); - myWebRequest->Proxy = myProxy; - } - Console::WriteLine("\nThe Address of the new Proxy settings are {0}", - myProxy->Address); - HttpWebResponse ^ myWebResponse = - (HttpWebResponse ^) (myWebRequest->GetResponse()); -// - - // Print the HTML contents of the page to the console. - Stream ^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader ^ streamRead = gcnew StreamReader(streamResponse); - array < Char > ^readBuff = gcnew array < Char > (256); - int count = streamRead->Read(readBuff, 0, 256); - Console::WriteLine("\nThe contents of the HTML pages are :"); - while (count > 0) { - String ^ outputData = gcnew String(readBuff, 0, count); - Console::Write(outputData); - count = streamRead->Read(readBuff, 0, 256); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine("\nPress any key to continue........."); - Console::Read(); - } - catch(UriFormatException ^ e) - { - Console::WriteLine("\nUriFormatException is thrown. Message: {0}", - e->Message); - Console::WriteLine("\nThe format of the Proxy address you entered is invalid"); - Console::WriteLine("\nPress any key to continue........."); - Console::Read(); - } - } - catch(WebException ^ e) - { - Console::WriteLine("\nWebException raised!"); - Console::WriteLine("\nMessage: {0} ", e->Message); - Console::WriteLine("\nStatus: {0} ", e->Status); - } - catch(Exception ^ e) - { - Console::WriteLine("\nException is raised. "); - Console::WriteLine("\nMessage: {0} ", e->Message); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp b/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp deleted file mode 100644 index 3e874fd030b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -This program demonstrates the 'GetCredential' method of the 'ICredentials*' interface. -The 'CredentialList' class implements the 'ICredentials*' interface, which stores credentials for multiple -internet resources. The program takes URL, Username, Password, and Domain name from command line and adds -it to an instance of the 'CredentialList' class. An instance of the 'WebRequest' class is obtained and the 'Credentials' -property of the 'WebRequest' class is set to an instance of the 'NetworkCredential' class obtained by calling the -'GetCredential' method of the 'CredentialList' class. Then it sends the request and obtains a response. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Collections; - -// -ref class CredentialList: public ICredentials -{ -private: - ref class CredentialInfo - { - public: - Uri^ uriObj; - String^ authenticationType; - NetworkCredential^ networkCredentialObj; - CredentialInfo( Uri^ uriObj, String^ authenticationType, NetworkCredential^ networkCredentialObj ) - { - this->uriObj = uriObj; - this->authenticationType = authenticationType; - this->networkCredentialObj = networkCredentialObj; - } - }; - - ArrayList^ arrayListObj; - -public: - CredentialList() - { - arrayListObj = gcnew ArrayList; - } - - void Add( Uri^ uriObj, String^ authenticationType, NetworkCredential^ credential ) - { - - // Add a 'CredentialInfo' object into a list. - arrayListObj->Add( gcnew CredentialInfo( uriObj,authenticationType,credential ) ); - } - - // Remove the 'CredentialInfo' object from the list that matches to the given 'Uri' and 'AuthenticationType' - void Remove( Uri^ uriObj, String^ authenticationType ) - { - for ( int index = 0; index < arrayListObj->Count; index++ ) - { - CredentialInfo^ credentialInfo = dynamic_cast(arrayListObj[ index ]); - if ( uriObj->Equals( credentialInfo->uriObj ) && authenticationType->Equals( credentialInfo->authenticationType ) ) - arrayListObj->RemoveAt( index ); - } - } - - virtual NetworkCredential^ GetCredential( Uri^ uriObj, String^ authenticationType ) - { - for ( int index = 0; index < arrayListObj->Count; index++ ) - { - CredentialInfo^ credentialInfoObj = dynamic_cast(arrayListObj[ index ]); - if ( uriObj->Equals( credentialInfoObj->uriObj ) && authenticationType->Equals( credentialInfoObj->authenticationType ) ) - return credentialInfoObj->networkCredentialObj; - } - return nullptr; - } -}; -// - -void GetPage( String^ urlString, String^ UserName, String^ password, String^ DomainName ) -{ - try - { - CredentialList^ credentialListObj = gcnew CredentialList; - - // Dummy names used as credentials. - credentialListObj->Add( gcnew Uri( urlString ), - "Basic", gcnew NetworkCredential( UserName,password,DomainName ) ); - credentialListObj->Add( gcnew Uri( "http://www.msdn.microsoft.com" ), - "Basic", gcnew NetworkCredential( "User1","Passwd1","Domain1" ) ); - - // Create a 'WebRequest' for the specified url. - WebRequest^ myWebRequest = WebRequest::Create( urlString ); - - // Call 'GetCredential' to obtain the credentials specific to a Uri. - myWebRequest->Credentials = credentialListObj->GetCredential( gcnew Uri( urlString ), "Basic" ); - - // Send the request and get the response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // ....Process the response here. - Console::WriteLine( "\n Response Received." ); - myWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException caught !!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught !!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} - -int main() -{ - String^ urlString; - String^ username; - String^ password; - String^ domainname; - Console::Write( "Enter a URL(for e.g. http://www.microsoft.com : " ); - urlString = Console::ReadLine(); - Console::Write( "Enter User name : " ); - username = Console::ReadLine(); - Console::Write( "Enter Password :" ); - password = Console::ReadLine(); - Console::Write( "Enter Domain name : " ); - domainname = Console::ReadLine(); - GetPage( urlString, username, password, domainname ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp b/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp deleted file mode 100644 index 252026db492..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* -This program demonstrates the 'Loopback' and 'Broadcast' field of 'IPAddress' class. -It prints the loopback IP address 127.0.0.1 and Broadcast IP address 255.255.255.255 -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void PrintLoopbackAddress() -{ - // Gets the IP loopback address and converts it to a string. - String^ IpAddressString = IPAddress::Loopback->ToString(); - Console::WriteLine( "Loopback IP address : {0}", IpAddressString ); -} -// - -// -void PrintBroadcastAddress() -{ - // Get the IP Broadcast address and convert it to string. - String^ IpAddressString = IPAddress::Broadcast->ToString(); - Console::WriteLine( "\nBroadcast IP address : {0}", IpAddressString ); -} -// - -int main() -{ - PrintLoopbackAddress(); - PrintBroadcastAddress(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp b/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp deleted file mode 100644 index e1bb9569466..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -This program demonstrates 'NetworkToHostOrder(short)', 'NetworkToHostOrder(int)' and -'NetworkToHostOrder(long)' methods of 'IPAddress' class. -It takes a String* from commandline for each of above cases and convert it to the corresponding -primitive type(i.e. short, int, long) value. Alternatively it uses default values for each cases. -Then these values are converted from network Byte order to host Byte order by calling the -overloaded 'NetworkToHostOrder' methods of 'IPAddress' class. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -void NetworkToHostOrder_Short( short networkByte ) -{ - short hostByte; - // Converts a short value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -// -void NetworkToHostOrder_Integer( int networkByte ) -{ - int hostByte; - // Converts an integer value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -// -void NetworkToHostOrder_Long( __int64 networkByte ) -{ - __int64 hostByte; - // Converts a long value from network Byte order to host Byte order. - hostByte = IPAddress::NetworkToHostOrder( networkByte ); - Console::WriteLine( "Network Byte order to Host Byte order of {0} is {1}", networkByte, hostByte ); -} -// - -int main() -{ - try - { - short networkByteShort = 4365; - int networkByteInt = 286064640; - __int64 networkByteLong = 1228638273342013440I64; - String^ networkByteString = ""; - - Console::Write( "'Program converts Network Byte order to Host Byte order for short, int and long values'" ); - Console::Write( "\nEnter a short value for Convertion(press Enter for default, default is '4365') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteShort = Convert::ToInt16( networkByteString ); - NetworkToHostOrder_Short( networkByteShort ); - - networkByteString = ""; - Console::Write( "\nEnter an Integer value for Convertion(press Enter for default, default is '286064640') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteInt = Convert::ToInt32( networkByteString ); - NetworkToHostOrder_Integer( networkByteInt ); - - networkByteString = ""; - Console::Write( "\nEnter a long value for Convertion(press Enter for default, default is '1228638273342013440') : " ); - networkByteString = Console::ReadLine(); - if ( networkByteString->Length > 0 ) - networkByteLong = Convert::ToInt64( networkByteString ); - NetworkToHostOrder_Long( networkByteLong ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp b/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp deleted file mode 100644 index c4ef78097fa..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -/* -This program demonstrates the 'None' field of 'IPAddress' class. -Provides an IP address indicating that no network interface should be used. -*/ -#using - -using namespace System; -using namespace System::Net; - -// -int main() -{ - - // Gets the IP address indicating that no network interface should be used - // and converts it to a String*. - String^ address = IPAddress::None->ToString(); - Console::WriteLine( "IP address : {0}", address ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp b/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp deleted file mode 100644 index fdaff450fae..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// System.Net.IPEndPoint.MaxPort; System.Net.IPEndPoint.MinPort; -// System.Net.IPEndPoint.AddressFamily; System.Net.IPEndPoint.IPEndPoint(long,int) -// System.Net.IPEndPoint.Address; System.Net.IPEndPoint.Port; - -/*This program demonstrates the properties 'MaxPort', 'MinPort','Address','Port' -and 'AddressFamily' and a constructor 'IPEndPoint(long,int)' of class 'IPEndPoint'. - -A procedure DoSocketGet is created which internally uses a socket to transmit http "Get" requests to a Web resource. -The program accepts a resource Url, Resolves it to obtain 'IPAddress',Constructs 'IPEndPoint' instance using this -'IPAddress' and port 80.Invokes DoSocketGet procedure to obtain a response and displays the response to a console. - -It then accepts another Url, Resolves it to obtain 'IPAddress'. Assigns this IPAddress and port to the 'IPEndPoint' -and again invokes DoSocketGet to obtain a response and display. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::Net::Sockets; -using namespace System::Runtime::InteropServices; - -String^ DoSocketGet( IPEndPoint^ hostIPEndPoint, String^ getString ); // forward reference - -int main() -{ - try - { - Console::Write( "\nPlease enter an INTRANET Url as shown: [e.g. www.microsoft.com]:" ); - String^ hostString1 = Console::ReadLine(); - -// -// -// -// - IPAddress^ hostIPAddress1 = (Dns::Resolve( hostString1 ))->AddressList[ 0 ]; - Console::WriteLine( hostIPAddress1 ); - IPEndPoint^ hostIPEndPoint = gcnew IPEndPoint( hostIPAddress1,80 ); - Console::WriteLine( "\nIPEndPoint information:{0}", hostIPEndPoint ); - Console::WriteLine( "\n\tMaximum allowed Port Address :{0}", IPEndPoint::MaxPort ); - Console::WriteLine( "\n\tMinimum allowed Port Address :{0}", (int^)IPEndPoint::MinPort ); - Console::WriteLine( "\n\tAddress Family :{0}", hostIPEndPoint->AddressFamily ); -// - Console::Write( "\nPress Enter to continue" ); - Console::ReadLine(); - String^ getString = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", hostString1 ); - String^ pageContent = DoSocketGet( hostIPEndPoint, getString ); - if ( pageContent != nullptr ) - { - Console::WriteLine( "Default HTML page on {0} is:\r\n{1}", hostString1, pageContent ); - } -// -// -// - - Console::Write( "\n\n\nPlease enter another INTRANET Url as shown[e.g. www.microsoft.com]: " ); - String^ hostString2 = Console::ReadLine(); - -// -// - IPAddress^ hostIPAddress2 = (Dns::Resolve( hostString2 ))->AddressList[ 0 ]; - hostIPEndPoint->Address = hostIPAddress2; - hostIPEndPoint->Port = 80; - - getString = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", hostString2 ); - pageContent = DoSocketGet( hostIPEndPoint, getString ); - if ( pageContent != nullptr ) - { - Console::WriteLine( "Default HTML page on {0} is:\r\n{1}", hostString2, pageContent ); - } - -// -// - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -String^ DoSocketGet( IPEndPoint^ hostIPEndPoint, String^ getString ) -{ - try - { - // Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - - array^ byteGet = ASCII->GetBytes( getString ); - array^ recvBytes = gcnew array(256); - String^ strRetPage = nullptr; - // Create the Socket for sending data over TCP. - Socket^ mySocket = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream,ProtocolType::Tcp ); - // Connect to host using IPEndPoint. - mySocket->Connect( hostIPEndPoint ); - // Send the GET text to the host. - mySocket->Send( byteGet, byteGet->Length, (SocketFlags)( 0 ) ); - // Receive the page, loop until all bytes are received. - Int32 byteCount = mySocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)( 0 ) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( recvBytes, 0, byteCount ) ); - while ( byteCount > 0 ) - { - byteCount = mySocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)( 0 ) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( recvBytes, 0, byteCount ) ); - } - return strRetPage; - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - Console::WriteLine( "WinSock Error : {0}", Convert::ToString( Marshal::GetLastWin32Error() ) ); - return nullptr; - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp b/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp deleted file mode 100644 index f51adc5cf17..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -This program demostrates 'AddressList' property of 'IPHostEntry' class. -It takes a URL from commandline(or uses default value) and obtains a -'IPHostEntry' Object* by calling 'GetHostByName' method of 'Dns' class and -prints the host name and IP addresses associated with the specified URL. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -void GetIpAddressList( String^ hostString ) -{ - try - { - // Get 'IPHostEntry' object containing information - // like host name, IP addresses, aliases for a host. - IPHostEntry^ hostInfo = Dns::GetHostByName( hostString ); - Console::WriteLine( "Host name : {0}", hostInfo->HostName ); - Console::WriteLine( "IP address List : " ); - for ( int index = 0; index < hostInfo->AddressList->Length; index++ ) - Console::WriteLine( hostInfo->AddressList[ index ] ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} -// - -int main() -{ - String^ hostString = " "; - - // Create an instance of HostInfoSample class. - Console::Write( "Type a URL(or press Enter for default, default is 'www.microsoft.net') : " ); - hostString = Console::ReadLine(); - if ( hostString->Length > 0 ) - GetIpAddressList( hostString ); - else - GetIpAddressList( "www.microsoft.net" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp b/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp deleted file mode 100644 index 51a46703a72..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -This program demonstrates 'Credentials' property, 'GetProxy' and 'IsBypassed' methods of -IWebProxy* interface. -The 'WebProxy_Interface' class implements the 'IWebProxy*' interface. It provides an implementation for the -'GetProxy' and 'IsByPassed' methods and 'ICredentials*' property. The 'GetProxy' method returns the url -of the proxy server as specified in the constructor. The 'IsByPassed' method returns false indicating -that the proxy server must never be bypassed for any requested url. The 'ICredentials*' property stores -the credentials required by the proxy server to authenticate the actual user. -*/ - -#using - -using namespace System; -using namespace System::Net; - -// -// -// -public ref class WebProxy_Interface: public IWebProxy -{ -private: - // The credentials to be used with the web proxy. - ICredentials^ iCredentials; - - // Uri of the associated proxy server. - Uri^ webProxyUri; - -public: - WebProxy_Interface( Uri^ proxyUri ) - { - webProxyUri = proxyUri; - } - - property ICredentials^ Credentials - { - // Get and Set the Credentials property. - virtual ICredentials^ get() - { - return iCredentials; - } - virtual void set( ICredentials^ value ) - { - if ( iCredentials != value ) - { - iCredentials = value; - } - } - } - - // Return the web proxy for the specified destination (destUri). - virtual Uri^ GetProxy( Uri^ destUri ) - { - // Always use the same proxy. - return webProxyUri; - } - - // Return whether the web proxy should be bypassed for the specified destination (hostUri). - virtual bool IsBypassed( Uri^ hostUri ) - { - // Never bypass the proxy. - return false; - } -}; -// -// -// - -int main() -{ - // - WebProxy_Interface^ webProxy_Interface = gcnew WebProxy_Interface( gcnew Uri( "http://proxy.example.com" ) ); - - webProxy_Interface->Credentials = gcnew NetworkCredential( "myusername", "mypassword" ); - - Console::WriteLine( "The web proxy is : {0}", webProxy_Interface->GetProxy( gcnew Uri( "http://www.contoso.com" ) ) ); - - // Check if the webproxy can ne bypassed for the site "http://www.contoso.com". - if ( webProxy_Interface->IsBypassed( gcnew Uri( "http://www.contoso.com" ) ) ) - { - Console::WriteLine( "Web Proxy is by passed" ); - } - else - { - Console::WriteLine( "Web Proxy is not by passed" ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp deleted file mode 100644 index 6fdfe8f6904..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp +++ /dev/null @@ -1,235 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; - -// -// The following method displays the properties of the -// specified WebProxy instance. -void DisplayProxyProperties( WebProxy^ proxy ) -{ - Console::WriteLine( "Address: {0}", proxy->Address ); - Console::WriteLine( "Bypass on local: {0}", proxy->BypassProxyOnLocal ); - - int count = proxy->BypassList->Length; - if ( count == 0 ) - { - Console::WriteLine( "The bypass list is empty." ); - return; - } - - array^bypass = proxy->BypassList; - Console::WriteLine( "The bypass list contents:" ); - for ( int i = 0; i < count; i++ ) - { - Console::WriteLine( bypass[ i ] ); - - } -} -// - -// -// The following method creates a Web proxy that uses -// Web proxy auto-discovery and supplies -// credentials to be used to download the wpad.dat script. -void CheckAutoProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // See what proxy is used for the resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see if a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", - resource, resourceProxy ); - } -} -// - -// -// The following method creates a WebProxy object that uses Internet Explorer's -// detected script if it is found in the registry; otherwise, it -// tries to use Web proxy auto-discovery to set the proxy used for -// the request. -void CheckAutoGlobalProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // Display the proxy's properties. - DisplayProxyProperties( proxy ); - - // See what proxy is used for the resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} -// - -// The following method creates a Web proxy that -// has its initial values set by the Internet Explorer's -// explicit proxy address and bypass list. -// The proxy uses Internet Explorer's automatically detected -// script if it found in the registry; otherwise, it tries to use -// Web proxy auto-discovery to set the proxy used for -// the request. -void CheckAutoDefaultProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = dynamic_cast(WebRequest::DefaultWebProxy); - - // Display the proxy properties. - DisplayProxyProperties( proxy ); - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see if a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} - -// -// This method specifies a script that should -// be used in the event that auto-discovery fails. -void CheckAutoProxyAndScriptForRequest( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - DisplayProxyProperties( proxy ); - - // See what proxy is used for resource. - Uri^ resourceProxy = dynamic_cast(proxy->GetProxy(resource)); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, resourceProxy ); - } -} -// - -// if construct with glocabl select -// if use system = true then if proxy = Glocalproxy.Select - the returned instance -// will have its values set -// by IE settings. If you do webProxy get default roxy reads manual setting (proxy address and -// bypass - doesn't matter what the config file has. -// -// The following method explicitly identifies -// the script to be downloaded and used to select the proxy. -void CheckScriptedProxyForRequest( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // See what proxy is used for resource. - Uri^ resourceProxy = dynamic_cast(proxy->GetProxy(resource)); - - // Test to see whether a proxy was selected. - if ( resourceProxy == nullptr ) - { - Console::WriteLine( "No proxy selected for {0}.", resource ); - return; - } - else - { - Console::WriteLine( "proxy returned for {0}.", resource ); - { - - // DIRECT in script is returned as a null Uri object. - if ( resourceProxy == nullptr ) - Console::WriteLine( "DIRECT" ); - else - Console::WriteLine( "{0}", resourceProxy ); - - } - } -} -// - -// -WebResponse^ CheckLatestScriptRequest( Uri^ resource, WebProxy^ proxy ) -{ - WebRequest^ request = WebRequest::Create( resource ); - request->Proxy = proxy; - WebResponse^ response = request->GetResponse(); - return response; -} -// - -void CheckScriptedProxyForRequest2( Uri^ resource, Uri^ script ) -{ - WebProxy^ proxy = gcnew WebProxy; - - // if use ssystem = true then if proxy = Glocalproxy.Select - the returned instance - // will have its values set - // by IE settings. If you do webProxy get defaultProxy reads manual setting (proxy address and - // bypass - doesn't matter what the config file has. - - // if construct with global select - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - Console::WriteLine( "GetProxy returned for {0} is {1}.", resource, resourceProxy ); - - -} - -void Underline() -{ - Console::WriteLine( "=======================================" ); -} - -int main() -{ - Uri^ resource = gcnew Uri( "http://www.example.com" ); - - // Console.WriteLine("nothing - default ctor"); Underline(); - // DisplayProxyProperties(new WebProxy()); - // Console.WriteLine ("\n\nAuto-only - default ctor"); Underline(); - // CheckAutoProxyForRequest(resource); - Console::WriteLine( "\n\nAuto-only - GlobalProxySelection.Select" ); - Underline(); - CheckAutoGlobalProxyForRequest( resource ); - - /* - Console.WriteLine ("\n\nAuto-only - DefaultProxy"); Underline(); - CheckAutoDefaultProxyForRequest(resource); - */ - // Console.WriteLine("\n\n IE auto + Valid Script-only"); - // CheckScriptedProxyForRequest(resource, new Uri("http://sharriso1/wpad.dat")); - // Console.WriteLine("\n\n IE auto Invalid Script-only"); - // CheckScriptedProxyForRequest(resource, new Uri("http://sharriso1/wpadx.dat")); - /* Console.WriteLine("Auto and Valid script"); - CheckAutoProxyAndScriptForRequest(resource, new Uri("http://sharriso1/wpad.dat")); - - Console.WriteLine("Auto and Invalid script"); - CheckAutoProxyAndScriptForRequest(resource, new Uri("http://sharriso1/wpadx.dat")); - */ - // check snippet 5 - // CheckLatestScriptRequest(resource, WebProxy.GetDefaultProxy()); - // check snippet 6 - //CheckAutoProxyForRequest( resource); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp deleted file mode 100644 index 18275c877c2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; - -// This example is run at the command line. -// Specify one argument: the name of the host to -// send the request to. -// If the request is sucessful, the example displays the contents of the cookies -// returned by the host. -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args == nullptr || args->Length != 2 ) - { - Console::WriteLine( "Specify the URL to receive the request." ); - Environment::Exit( 1 ); - } - - - // - HttpWebRequest^ request = dynamic_cast(WebRequest::Create( args[ 1 ] )); - request->CookieContainer = gcnew CookieContainer; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - response->Cookies = request->CookieContainer->GetCookies( request->RequestUri ); - - // Print the properties of each cookie. - System::Collections::IEnumerator^ myEnum = response->Cookies->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Cookie^ cook = safe_cast(myEnum->Current); - Console::WriteLine( "Cookie:" ); - Console::WriteLine( "{0} = {1}", cook->Name, cook->Value ); - Console::WriteLine( "Domain: {0}", cook->Domain ); - Console::WriteLine( "Path: {0}", cook->Path ); - Console::WriteLine( "Port: {0}", cook->Port ); - Console::WriteLine( "Secure: {0}", cook->Secure ); - Console::WriteLine( "When issued: {0}", cook->TimeStamp ); - Console::WriteLine( "Expires: {0} (expired? {1})", cook->Expires, cook->Expired ); - Console::WriteLine( "Don't save: {0}", cook->Discard ); - Console::WriteLine( "Comment: {0}", cook->Comment ); - Console::WriteLine( "Uri for comments: {0}", cook->CommentUri ); - Console::WriteLine( "Version: RFC {0}", cook->Version == 1 ? (String^)"2109" : "2965" ); - - // - // Show the string representation of the cookie. - Console::WriteLine( "String: {0}", cook ); - - // - } - // - -} - -// -// Output from this example will be vary depending on the host name specified, -// but will be similar to the following. -/* -Cookie: -CustomerID = 13xyz -Domain: .contoso.com -Path: / -Port: -Secure: False -When issued: 1/14/2003 3:20:57 PM -Expires: 1/17/2013 11:14:07 AM (expired? False) -Don't save: False -Comment: -Uri for comments: -Version: RFC 2965 -String: CustomerID = 13xyz -*/ -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp deleted file mode 100644 index 6a13836357f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -int main() -{ - - // Create a request for the Web page at www.contoso.com. - WebRequest^ request = WebRequest::Create( L"http://www.contoso.com" ); - - // This application doesn't want they proxy to be used so it sets - // the global proxy to an empy proxy. - IWebProxy^ myProxy = GlobalProxySelection::GetEmptyWebProxy(); - - // Get the response. - WebResponse^ response = request->GetResponse(); - - // Display the response to the console. - Stream^ stream = response->GetResponseStream(); - StreamReader^ reader = gcnew StreamReader( stream ); - Console::WriteLine( reader->ReadToEnd() ); - - // Clean up. - reader->Close(); - stream->Close(); - response->Close(); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp deleted file mode 100644 index e507d6263b9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp +++ /dev/null @@ -1,227 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; -using namespace System::IO; - -// -public ref class FtpState -{ -private: - ManualResetEvent^ wait; - FtpWebRequest^ request; - String^ fileName; - Exception^ operationException; - String^ status; - -public: - FtpState() - { - wait = gcnew ManualResetEvent( false ); - } - - property ManualResetEvent^ OperationComplete - { - ManualResetEvent^ get() - { - return wait; - } - - } - - property FtpWebRequest^ Request - { - FtpWebRequest^ get() - { - return request; - } - - void set( FtpWebRequest^ value ) - { - request = value; - } - - } - - property String^ FileName - { - String^ get() - { - return fileName; - } - - void set( String^ value ) - { - fileName = value; - } - - } - - property Exception^ OperationException - { - Exception^ get() - { - return operationException; - } - - void set( Exception^ value ) - { - operationException = value; - } - - } - - property String^ StatusDescription - { - String^ get() - { - return status; - } - - void set( String^ value ) - { - status = value; - } - - } -}; -// - -// -public ref class AsynchronousFtpUpLoader -{ -public: - - // - // Command line arguments are two strings: - // 1. The url that is the name of the file being uploaded to the server. - // 2. The name of the file on the local machine. - // - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - - // Create a Uri instance with the specified URI string. - // If the URI is not correctly formed, the Uri constructor - // will throw an exception. - ManualResetEvent^ waitObject; - Uri^ target = gcnew Uri( args[ 1 ] ); - String^ fileName = args[ 2 ]; - FtpState^ state = gcnew FtpState; - FtpWebRequest ^ request = dynamic_cast(WebRequest::Create( target )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // This example uses anonymous logon. - // The request is anonymous by default; the credential does not have to be specified. - // The example specifies the credential only to - // control how actions are logged on the server. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - - // Store the request in the object that we pass into the - // asynchronous operations. - state->Request = request; - state->FileName = fileName; - - // Get the event to wait on. - waitObject = state->OperationComplete; - - // Asynchronously get the stream for the file contents. - request->BeginGetRequestStream( gcnew AsyncCallback( EndGetStreamCallback ), state ); - - // Block the current thread until all operations are complete. - waitObject->WaitOne(); - - // The operations either completed or threw an exception. - if ( state->OperationException != nullptr ) - { - throw state->OperationException; - } - else - { - Console::WriteLine( "The operation completed - {0}", state->StatusDescription ); - } - } - // - - // -private: - static void EndGetStreamCallback( IAsyncResult^ ar ) - { - FtpState^ state = dynamic_cast(ar->AsyncState); - Stream^ requestStream = nullptr; - - // End the asynchronous call to get the request stream. - try - { - requestStream = state->Request->EndGetRequestStream( ar ); - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( state->FileName ); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - - // Asynchronously get the response to the upload request. - state->Request->BeginGetResponse( gcnew AsyncCallback( EndGetResponseCallback ), state ); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Could not get the request stream." ); - state->OperationException = e; - state->OperationComplete->Set(); - return; - } - } - // - - // - // The EndGetResponseCallback method - // completes a call to BeginGetResponse. - static void EndGetResponseCallback( IAsyncResult^ ar ) - { - FtpState^ state = dynamic_cast(ar->AsyncState); - FtpWebResponse ^ response = nullptr; - try - { - response = dynamic_cast(state->Request->EndGetResponse( ar )); - response->Close(); - state->StatusDescription = response->StatusDescription; - - // Signal the main application thread that - // the operation is complete. - state->OperationComplete->Set(); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Error getting response." ); - state->OperationException = e; - state->OperationComplete->Set(); - } - } - // -}; -// - -int main() -{ - AsynchronousFtpUpLoader::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp deleted file mode 100644 index 1e751d2630a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp +++ /dev/null @@ -1,842 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; -using namespace System::Security::Cryptography::X509Certificates; - -public ref class FtpRequestTest -{ -private: - - // FxCop rule requires a private constructor. - FtpRequestTest(){} - - -public: - - // - static bool ListFilesOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectory; - - // Get the ServicePoint object used for this request, and limit it to one connection. - // In a real-world application you might use the default number of connections (2), - // or select a value that works best for your application. - ServicePoint^ sp = request->ServicePoint; - Console::WriteLine( "ServicePoint connections = {0}.", sp->ConnectionLimit ); - sp->ConnectionLimit = 1; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - if ( readStream != nullptr ) - { - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - } - - Console::WriteLine( "List status: {0}", response->StatusDescription ); - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - } - - return true; - } - // - - // new content - // - static bool NameListFilesOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectoryDetails; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - if ( readStream != nullptr ) - { - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - } - - Console::WriteLine( "Status: {0}", response->StatusDescription ); - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - } - - return true; - } - // - - // - static bool GetDateTimestampOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::GetDateTimestamp; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "{0} {1}", serverUri, response->LastModified ); - - // The output from this method will vary depening on the - // file specified and your regional settings. It is similar to: - // ftp://contoso.com/Data.txt 4/15/2003 10:46:02 AM - return true; - } - // - - // - static bool MakeDirectoryOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::MakeDirectory; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Status: {0}", response->StatusDescription ); - return true; - } - // - - // - static bool UploadUniqueFileOnServer( Uri^ serverUri, String^ fileName ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the directory on the server. - // Example: ftp://contoso.com. - // - // The fileName parameter identifies the file containing the data to be uploaded. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFileWithUniqueName; - - // Don't set a time limit for the operation to complete. - request->Timeout = System::Threading::Timeout::Infinite; - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( fileName ); - Stream^ requestStream = request->GetRequestStream(); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Upload status: {0}, {1}", response->StatusCode, response->StatusDescription ); - Console::WriteLine( "File name: {0}", response->ResponseUri ); - response->Close(); - return true; - } - // - - // - static bool RemoveDirectoryOnServer( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::RemoveDirectory; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Status: {0}", response->StatusDescription ); - return true; - } - // - - // - static bool UploadFileToServer( String^ fileName, Uri^ serverUri ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the file on the server. - // Example: ftp://contoso.com/someFile.txt. - // - // The fileName parameter identifies the file containing the data to be uploaded. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // Don't set a time limit for the operation to complete. - request->Timeout = System::Threading::Timeout::Infinite; - - // Copy the file contents to the request stream. - const int bufferLength = 2048; - array^buffer = gcnew array(bufferLength); - int count = 0; - int readBytes = 0; - FileStream^ stream = File::OpenRead( fileName ); - Stream^ requestStream = request->GetRequestStream(); - do - { - readBytes = stream->Read( buffer, 0, bufferLength ); - requestStream->Write( buffer, 0, bufferLength ); - count += readBytes; - } - while ( readBytes != 0 ); - - Console::WriteLine( "Writing {0} bytes to the stream.", count ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Upload status: {0}, {1}", response->StatusCode, response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool AppendFileOnServer( String^ fileName, Uri^ serverUri ) - { - // The URI described by serverUri should use the ftp:// scheme. - // It contains the name of the file on the server. - // Example: ftp://contoso.com/someFile.txt. - // The fileName parameter identifies the file containing - // the data to be appended to the file on the server. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::AppendFile; - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - array^fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - request->ContentLength = fileContents->Length; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - Stream^ requestStream = request->GetRequestStream(); - requestStream->Write( fileContents, 0, fileContents->Length ); - requestStream->Close(); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Append status: {0}", response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool DeleteFileOnServer( Uri^ serverUri ) - { - // The serverUri parameter should use the ftp:// scheme. - // It contains the name of the server file that is to be deleted. - // Example: ftp://contoso.com/someFile.txt. - // - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DeleteFile; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "Delete status: {0}", response->StatusDescription ); - response->Close(); - return true; - } - // - - // - static bool DisplayFileFromServer( Uri^ serverUri ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - WebClient^ request = gcnew WebClient; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - try - { - array^newFileData = request->DownloadData( serverUri->ToString() ); - String^ fileString = System::Text::Encoding::UTF8->GetString( newFileData ); - Console::WriteLine( fileString ); - } - catch ( WebException^ e ) - { - Console::WriteLine( e ); - } - - return true; - } - // - - - // -private: - // DisplayRequestProperties prints a request's properties. - // This method should be called after the request is sent to the server. - static void DisplayRequestProperties( FtpWebRequest^ request ) - { - // - Console::WriteLine( "User {0} {1}", request->Credentials->GetCredential( request->RequestUri, "basic" )->UserName, request->RequestUri ); - - // - Console::WriteLine( "Request: {0} {1}", request->Method, request->RequestUri ); - - // - Console::WriteLine( "Passive: {0} Keep alive: {1} Binary: {2} Timeout: {3}.", request->UsePassive, request->KeepAlive, request->UseBinary, request->Timeout == -1 ? "none" : request->Timeout.ToString() ); - - // - // - IWebProxy^ proxy = request->Proxy; - if ( proxy ) - { - Console::WriteLine( "Proxy: {0}", proxy->GetProxy( request->RequestUri ) ); - } - else - { - Console::WriteLine( "Proxy: (none)" ); - } - - Console::WriteLine( "ConnectionGroup: {0}", request->ConnectionGroupName == nullptr ? "none" : request->ConnectionGroupName ); - // - - Console::WriteLine( "Encrypted connection: {0}", request->EnableSsl ); - - Console::WriteLine("Method: {0}", request->Method); - } - // - - // -public: - // NOT Working - throws a protocolError - 350 Restarting at 8. for args shown in Main. - static bool RestartDownloadFromServer( String^ fileName, Uri^ serverUri, long offset ) - { - // The serverUri parameter should use the ftp:// scheme. - // It identifies the server file that is to be appended. - // Example: ftp://contoso.com/someFile.txt. - // - // The fileName parameter identifies the local file - // - // The offset parameter specifies where in the server file to start reading data. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DownloadFile; - request->ContentOffset = offset; - FtpWebResponse^ response = nullptr; - try - { - response = dynamic_cast(request->GetResponse()); - } - catch ( WebException^ e ) - { - Console::WriteLine( e->Status ); - Console::WriteLine( e->Message ); - return false; - } - - Stream^ newFile = response->GetResponseStream(); - StreamReader^ reader = gcnew StreamReader( newFile ); - - // Display downloaded data. - String^ newFileData = reader->ReadToEnd(); - - // Append the response data to the local file - // using a StreamWriter. - StreamWriter^ writer = File::AppendText(fileName); - writer->Write(newFileData); - - // Display the status description. - - // Cleanup. - writer->Close(); - reader->Close(); - response->Close(); - // string fileString = System.Text.Encoding.UTF8.GetString(newFileData); - // Console::WriteLine( sr ); - Console::WriteLine("Download restart - status: {0}",response->StatusDescription); - return true; - } - // - - // not enabled in M2 - // Sample call: SendCommandToServer("ftp://contoso.com/", "pwd"); - // The output can only return status information. - static bool SendCommandToServer( String^ serverUri, String^ command ) - { - // The serverUri parameter should start with the ftp:// scheme. - // It contains the name of the file on the server that will be appended. - // Example: ftp://contoso.com/someFile.txt. - // - // The command parameter identifies the command to send to the server. - if ( !serverUri->ToLower()->StartsWith( Uri::UriSchemeFtp ) ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = command; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "{0} status: {1}", command, response->StatusDescription ); - response->Close(); - return true; - } - - // - static bool DownloadFileFromServer( Uri^ serverUri, String^ localFileName ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - // Note that the cast to FtpWebRequest is done only - // for the purposes of illustration. If your application - // does not set any properties other than those defined in the - // System.Net.WebRequest class, you can use the following line instead: - // WebRequest request = WebRequest.Create(serverUri); - // - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::DownloadFile; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - StreamWriter^ writeStream = nullptr; - try - { - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - - // Display information about the data received from the server. - Console::WriteLine( "Bytes received: {0}", response->ContentLength ); - Console::WriteLine( "Message from server: {0}", response->StatusDescription ); - Console::WriteLine( "Resource: {0}", response->ResponseUri ); - - // Write the bytes received from the server to the local file. - if ( readStream != nullptr ) - { - writeStream = gcnew StreamWriter( localFileName,false ); - writeStream->Write( readStream->ReadToEnd() ); - } - } - finally - { - if ( readStream != nullptr ) - { - readStream->Close(); - } - - if ( response != nullptr ) - { - response->Close(); - } - - if ( writeStream != nullptr ) - { - writeStream->Close(); - } - } - - return true; - } - // - - // Make a request to show the request properties - static void GetRequestProperties( Uri^ serverUri ) - { - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - request->Proxy = gcnew WebProxy; - request->Method = WebRequestMethods::Ftp::DownloadFile; - request->Abort(); - DisplayRequestProperties( request ); - } - - // async snippets - // - static bool GetFileSizeFromServer( Uri^ serverUri ) - { - // The serverUri parameter should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::GetFileSize; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // Display information about the server response. - Console::WriteLine( "size of file: {0}", response->ContentLength ); - response->Close(); - return true; - } - // - - // - static bool ListFilesOnServerSsl( Uri^ serverUri ) - { - // The serverUri should start with the ftp:// scheme. - if ( serverUri->Scheme != Uri::UriSchemeFtp ) - { - return false; - } - - // Get the object used to communicate with the server. - FtpWebRequest^ request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::ListDirectory; - request->EnableSsl = true; - - // Get the ServicePoint object used for this request, and limit it to one connection. - // In a real-world application you might use the default number of connections (2), - // or select a value that works best for your application. - ServicePoint^ sp = request->ServicePoint; - Console::WriteLine( "ServicePoint connections = {0}.", sp->ConnectionLimit ); - sp->ConnectionLimit = 1; - FtpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine( "The content length is {0}", response->ContentLength ); - - // The following streams are used to read the data returned from the server. - Stream^ responseStream = nullptr; - StreamReader^ readStream = nullptr; - responseStream = response->GetResponseStream(); - readStream = gcnew StreamReader( responseStream,System::Text::Encoding::UTF8 ); - - // Display the data received from the server. - Console::WriteLine( readStream->ReadToEnd() ); - Console::WriteLine( "List status: {0}", response->StatusDescription ); - readStream->Close(); - response->Close(); - - // - Console::WriteLine( "Banner message: {0}", response->BannerMessage ); - // - - // - Console::WriteLine( "Welcome message: {0}", response->WelcomeMessage ); - // - - // - Console::WriteLine( "Exit message: {0}", response->ExitMessage ); - // - - return true; - } - - // -internal: - static FtpStatusCode WaitForFinalStatus( FtpWebResponse^ response ) - { - int status = (int)response->StatusCode; - - // < 200 is undefined or informational messages. - // 300 and 400 are intermediate and temporary errors respectively. - // 200- 299 and 500- 599 are final statuses indicating - // sucess or failure respectively. - while ( status < 200 || (status >= 300 && status < 500) ) - { - Console::Write( "{0}. ", status ); - System::Threading::Thread::Sleep( 100 ); - status = (int)response->StatusCode; - } - - return response->StatusCode; - } - - -public: - static void Main() - { - // tests for snippets: - // ListFilesOnServer(new Uri(S"ftp://sharriso1")); - // works m3.1 - // NameListFilesOnServer (new Uri (S"ftp://sharriso1")); - // throws - // GetDateTimestampOnServer (new Uri ("ftp://sharriso1")); - // GetDateTimestampOnServer (new Uri (S"ftp://sharriso1/localfile.txt")); - // RemoveDirectoryOnServer (new Uri (S"ftp://sharriso1/DirtyDir")); - // MakeDirectoryOnServer (new Uri (S"ftp://sharriso1/DirtyDir")); - // UploadUniqueFileOnServer (new Uri (S"ftp://sharriso1/SherdieDir/"), "sharriso2.log"); - // ListFilesOnServer (new Uri (S"ftp://sharriso1")); - ListFilesOnServerSsl( gcnew Uri( "ftp://sharriso1" ) ); - - // snippet 8 - not working - // snippet 1 - // ListFilesOnServer(new Uri("ftp://sharriso1/")); - // snippet 8 - not working - //SendCommandToServer("ftp://sharriso1/", "rename localfile.txt loc2.txt"); - // new snippet 7 - // upload is just helper - //UploadFileToServer("NCLFtpClient.xml", new Uri("ftp://sharriso1/NCLFtpClient.xml")); - // RestartDownloadFromServer("piecexml.txt", new Uri("ftp://sharriso1/NCLFtpClient.xml"), 8); - // DownloadFileFromServer(new Uri("ftp://sharriso1/onesandtwos.txt"), "downloadedFile0320_1.txt"); - // snippet 11 - GetFileSizeFromServer( gcnew Uri( "ftp://sharriso1/localfile.txt" ) ); - - // snippet 5 - // DisplayFileFromServer Not working! - // DisplayFileFromServer(new Uri("ftp://sharriso1/ss1.txt")); - // snippet 2 - // UploadFileToServer("local.txt", new Uri("ftp://sharriso1/localfile.txt")); - //DeleteFileOnServer(new Uri("ftp://sharriso1/localfile.txt")); - // DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - // AppendFileOnServer("dlagain.txt", new Uri("ftp://sharriso1/localfile.txt")); - // Snippet 14, 15, and 16 - // GetRequestProperties(new Uri("ftp://sharriso1/localfile.txt")); - // Snippet 9 - // DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - //AsynchronousUploadFileToServer( "system.pdb","ftp://sharriso1/localFile.pdb"); - // ListFilesOnServer(new Uri("ftp://sharriso1")); - //DownloadFileFromServer(new Uri("ftp://sharriso1/localFileagain.txt"), "dlagain.txt"); - //UploadPartialFileOnServer("allOnes.txt", "ftp://sharriso1/babyones.txt", 20 ); - // TestCloning(); - // test the async methods - // ManualResetEvent wait = new ManualResetEvent(false); - // AsynchronousFtpUpLoader uploader = new AsynchronousFtpUpLoader(wait); - // uploader.AsynchronousUploadFileToServer("ftptests.cs", "ftp://sharriso1/ftptests.txt"); - // wait.WaitOne(); - // Snippet 10 - // ManualResetEvent wait = new ManualResetEvent(false); - // AsynchronousFtpUpLoader uploader = new AsynchronousFtpUpLoader(wait); - // uploader.AbortUpload("mscorlib.xml", "ftp://sharriso1/ftptests.txt"); - // wait.WaitOne(); - } -}; - - -// The RequestState class is the state object used to store the request information -// during asynchronous operations. -private ref class RequestState -{ -internal: - FtpWebRequest^ request; - Object^ requestData; - RequestState( FtpWebRequest ^theRequest, Object^ data ) - { - request = theRequest; - requestData = data; - } -}; - -public ref class AsynchronousFtpUpLoader -{ -private: - ManualResetEvent^ wait; - FtpWebRequest^ request; - array^fileContents; - Exception^ asyncException; - -public: - AsynchronousFtpUpLoader( ManualResetEvent^ wait ) - { - this->wait = wait; - } - - // In the AsynchronousUploadFileToServer method, - // serverUri contains the name of the file on the FTP server, and - // fileName contains the name of the file on the local computer. - void AsynchronousUploadFileToServer( String^ fileName, String^ serverUri ) - { - request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // This example assumes the FTP site uses anonymous logon. - request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" ); - - // Get the file to be uploaded and convert it to bytes. - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - - // Set the content length to the number of bytes in the file. - request->ContentLength = fileContents->Length; - - // Asynchronously get the stream for the file contents. - IAsyncResult^ ar = request->BeginGetRequestStream( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetStreamCallback ), nullptr ); - Console::WriteLine( "Getting the request stream asynchronously..." ); - } - -private: - void EndGetStreamCallback( IAsyncResult^ ar ) - { - // Thread.Sleep(5000); - // Console.WriteLine("I'm awake now"); - Stream^ requestStream = nullptr; - - // End the asynchronous call to get the request stream. - try - { - requestStream = request->EndGetRequestStream( ar ); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Could not get the request stream." ); - asyncException = e; - wait->Set(); - return; - } - - // Write the file contents to the request stream. - requestStream->Write( fileContents, 0, fileContents->Length ); - Console::WriteLine( "Writing {0} bytes to the stream.", fileContents->Length ); - - // IMPORTANT: Close the request stream before sending the request. - requestStream->Close(); - IAsyncResult^ responseAR = request->BeginGetResponse( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetResponseCallback ), nullptr ); - } - - // The EndGetResponseCallback method - // completes a call to BeginGetResponse. - void EndGetResponseCallback( IAsyncResult^ ar ) - { - FtpWebResponse^ response = nullptr; - try - { - response = dynamic_cast(request->EndGetResponse( ar )); - } - // Return exceptions to the main application thread. - catch ( Exception^ e ) - { - Console::WriteLine( "Error getting response." ); - asyncException = e; - } - - Console::WriteLine( "Upload status: {0}", response->StatusDescription ); - - // Signal the application thread that this is complete. - wait->Set(); - } - - // -public: - void AbortUpload( String^ fileName, String^ serverUri ) - { - request = dynamic_cast(WebRequest::Create( serverUri )); - request->Method = WebRequestMethods::Ftp::UploadFile; - - // Get the file to be uploaded and convert it to bytes. - StreamReader^ sourceStream = gcnew StreamReader( fileName ); - fileContents = Encoding::UTF8->GetBytes( sourceStream->ReadToEnd() ); - sourceStream->Close(); - - // Set the content length to the number of bytes in the file. - request->ContentLength = fileContents->Length; - - // Asynchronously get the stream for the file contents. - IAsyncResult^ ar = request->BeginGetRequestStream( gcnew AsyncCallback( this, &AsynchronousFtpUpLoader::EndGetStreamCallback ), nullptr ); - Console::WriteLine( "Getting the request stream asynchronously..." ); - Console::WriteLine( "Press 'a' to abort the upload or any other key to continue" ); - String^ input = Console::ReadLine(); - if ( input->Equals( "a" ) ) - { - request->Abort(); - Console::WriteLine( "Request aborted" ); - return; - } - } - // -}; - -int main() -{ - FtpRequestTest::Main(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp deleted file mode 100644 index 81d174edffb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp +++ /dev/null @@ -1,1082 +0,0 @@ - -// NclMailSync -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::IO; -using namespace System::Text; - -public ref class CtorExamples -{ -public: - - // - static void CreateTestMessage1( String^ server, int port ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - MailMessage^ message = gcnew MailMessage( from,to,subject,body ); - SmtpClient^ client = gcnew SmtpClient( server,port ); - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage2( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the new SMTP client."; - message->Body = L"Using this new feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->UseDefaultCredentials = true; - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTimeoutTestMessage( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - MailMessage^ message = gcnew MailMessage( from,to,subject,body ); - SmtpClient^ client = gcnew SmtpClient( server ); - Console::WriteLine( L"Changing time out from {0} to 100.", client->Timeout ); - client->Timeout = 100; - - // Credentials are necessary if the server requires the client - // to authenticate before it will send email on the client's behalf. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - } - - - // - // - static void CreateTestMessage3() - { - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com" ); - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the new SMTP client."; - message->Body = L"Using this new feature, you can send an email message from an application very easily."; - - // Use the application or machine configuration to get the - // host, port, and credentials. - SmtpClient^ client = gcnew SmtpClient; - Console::WriteLine( L"Sending an email message to {0} at {1} by using the SMTP host {2}.", to->User, to->Host, client->Host ); - client->Send( message ); - } - - - // - // - static void CreateMessageWithMultipleViews( String^ server, String^ recipients ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",recipients,L"This email message has multiple views.",L"This is some plain text." ); - - // Construct the alternate body as HTML. - String^ body = L""; - body = String::Concat( body, L"" ); - body = String::Concat( body, L"
this is some HTML text" ); - body = String::Concat( body, L"
" ); - - // Add the alternate body to the message. - AlternateView^ alternate = AlternateView::CreateAlternateViewFromString(body); - message->AlternateViews->Add(alternate); - - // Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentType for the attachment. - ContentType^ c = alternate->ContentType; - Console::WriteLine( L"Content type" ); - Console::WriteLine( c ); - Console::WriteLine( L"Boundary {0}", c->Boundary ); - Console::WriteLine( L"CharSet {0}", c->CharSet ); - Console::WriteLine( L"MediaType {0}", c->MediaType ); - Console::WriteLine( L"Name {0}", c->Name ); - Console::WriteLine( L"Parameters: {0}", c->Parameters->Count ); - IEnumerator^ myEnum = c->Parameters->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - Console::WriteLine(); - alternate->~AlternateView(); - } - - - //
- // - static void CreateMessageWithAttachment( String^ server ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named Data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"Quarterly data report.",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment(file, MediaTypeNames::Application::Octet); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentDisposition for the attachment. - ContentDisposition^ cd = data->ContentDisposition; - Console::WriteLine( L"Content disposition" ); - Console::WriteLine( cd ); - Console::WriteLine( L"File {0}", cd->FileName ); - Console::WriteLine( L"Size {0}", cd->Size ); - Console::WriteLine( L"Creation {0}", cd->CreationDate ); - Console::WriteLine( L"Modification {0}", cd->ModificationDate ); - Console::WriteLine( L"Read {0}", cd->ReadDate ); - Console::WriteLine( L"Inline {0}", cd->Inline ); - Console::WriteLine( L"Parameters: {0}", cd->Parameters->Count ); - IEnumerator^ myEnum1 = cd->Parameters->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum1->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage4( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailAddress^ to = gcnew MailAddress( L"Jane@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - Console::WriteLine( L"Sending an email message to {0} by using SMTP host {1} port {2}.", to, client->Host, client->Port ); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateTestMessage5( String^ server ) - { - String^ to = L"jane@contoso.com"; - String^ from = L"ben@contoso.com"; - String^ subject = L"Using the new SMTP client."; - String^ body = L"Using this new feature, you can send an email message from an application very easily."; - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( from, to, subject, body ); - client->~SmtpClient(); - } - - - // - // - static void CreateBccTestMessage( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" ); - MailMessage^ message = gcnew MailMessage( from,to ); - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - MailAddress^ bcc = gcnew MailAddress( L"manager1@contoso.com" ); - message->Bcc->Add( bcc ); - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Sending an email message to {0} and {1}.", to->DisplayName, message->Bcc ); - try - { - client->Send( message ); - } - catch ( Exception^ ex ) - { - Console::WriteLine(L"Exception caught in CreateBccTestMessage(): {0}", - ex->ToString() ); - } - client->~SmtpClient(); - } - - - // - // - static void CreateCopyMessage( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" ); - MailMessage^ message = gcnew MailMessage( from,to ); - - // message.Subject = "Using the SmtpClient class."; - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - - // Add a carbon copy recipient. - MailAddress^ copy = gcnew MailAddress( L"Notification_List@contoso.com" ); - message->CC->Add( copy ); - SmtpClient^ client = gcnew SmtpClient( server ); - - // Include credentials if the server requires them. - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Sending an email message to {0} by using the SMTP host {1}.", to->Address, client->Host ); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageAttachment1( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"message{0}", DateTime::Now ); - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - - // Display the values in the ContentDisposition for the attachment. - Console::WriteLine( L"Content disposition" ); - Console::WriteLine( disposition ); - Console::WriteLine( L"File {0}", disposition->FileName ); - Console::WriteLine( L"Size {0}", disposition->Size ); - Console::WriteLine( L"Creation {0}", disposition->CreationDate ); - Console::WriteLine( L"Modification {0}", disposition->ModificationDate ); - Console::WriteLine( L"Read {0}", disposition->ReadDate ); - Console::WriteLine( L"Inline {0}", disposition->Inline ); - Console::WriteLine( L"Parameters: {0}", disposition->Parameters->Count ); - IEnumerator^ myEnum2 = disposition->Parameters->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum2->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"An inline text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentDisposition^ disposition = data->ContentDisposition; - disposition->Inline = true; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment2( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentType^ content = data->ContentType; - content->MediaType = MediaTypeNames::Text::Plain; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Make a contentType indicating that the log data - // that is attached is plain text. - ContentType^ ct = gcnew ContentType( MediaTypeNames::Text::Plain ); - - // Attach the log file stream to the email message. - Attachment^ data = gcnew Attachment( fs,ct ); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"log{0}.txt", DateTime::Now ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendNamedErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Make a ContentType indicating that the log data - // that is attached is plain text and is named. - ContentType^ ct = gcnew ContentType; - ct->MediaType = MediaTypeNames::Text::Plain; - ct->Name = String::Format( L"log{0}.txt", DateTime::Now ); - - // Create the attachment. - Attachment^ data = gcnew Attachment( fs,ct ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - return; - } - - - // - // - // The following example sends a summary of a log file as the message - // and the log as an email attachment. - static void SendNamedAndTypedErrorLog( String^ server, String^ recipientList ) - { - - // Create a message from logMailer@contoso.com to recipientList. - MailMessage^ message = gcnew MailMessage( L"logMailer@contoso.com",recipientList ); - message->Subject = L"Error Log report"; - String^ fileName = L"log.txt"; - - // Get the file stream for the error log. - // Requires the System.IO namespace. - FileStream^ fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - StreamReader^ s = gcnew StreamReader( fs ); - int errors = 0; - while ( s->ReadLine() != nullptr ) - { - - // Process each line from the log file here. - errors++; - } - - message->Body = String::Format( L"{0} errors in log as of {1}", errors, DateTime::Now ); - - // Close the stream reader. This also closes the file. - s->Close(); - - // Re-open the file at the beginning to make the attachment. - fs = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - - // Create a name for the log data file. - String^ name = String::Format( L"log{0}.txt", DateTime::Now ); - - // Create the attachment, name it, and specify the MIME type. - Attachment^ data = gcnew Attachment( fs,name,MediaTypeNames::Text::Plain ); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - // Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - - // Close the log file. - fs->Close(); - } - - - // - // - static Attachment^ SendAttachedMessage( String^ server ) - { - - // Set up the sender information. - String^ from = String::Concat( Environment::UserDomainName, L".", Environment::UserName, L"@contoso.com" ); - Console::WriteLine( L"From: {0}", from ); - - // Have the user enter the message recipient. - Console::Write( L"To: " ); - String^ recipient = Console::ReadLine(); - - // Check for recipient data. - // A real application would add error checking here for a valid email - // address format. This example accepts any input. - if ( recipient->Length == 0 ) - return nullptr; - - - // Get the subject. - Console::Write( L"Subject: " ); - String^ subject = Console::ReadLine(); - - // Get the message content. - Console::WriteLine( L"Enter the message. Press return on a blank line to finish:" ); - StringBuilder^ sb = gcnew StringBuilder; - String^ line; - while ( true ) - { - line = Console::ReadLine(); - if ( line->Length > 0 ) - { - - // Store the message and the end-of-line characters. - sb->AppendFormat( L"{0},{1}", line, Environment::NewLine ); - } - else - break; - } - - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( from,recipient ); - message->Subject = subject; - - // Attach the message string to this email message. - // Set the encoding to the computer's current encoding. - Attachment^ data = gcnew Attachment( sb->ToString(),MediaTypeNames::Text::Plain); - - // Add the attachment to the message. - message->Attachments->Add( data ); - - //Send the message. Supply credentials if necessary. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = CredentialCache::DefaultNetworkCredentials; - Console::WriteLine( L"Ready to send. Press enter to send. Type any character to quit:" ); - String^ answer = Console::ReadLine(); - if ( answer->Length == 0 ) - { - client->Send( message ); - Console::WriteLine( L"Message sent." ); - } - else - { - Console::WriteLine( L"Send canceled." ); - } - - client->~SmtpClient(); - return data; - } - - - // - // - static void CreateMessageWithFile( String^ server, String^ to ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to ); - message->Subject = L"Monthly Expense report"; - message->Body = L"Please review the attached report."; - - // Attach a file to this email message. - Attachment^ data = gcnew Attachment("data.xls", MediaTypeNames::Application::Octet); - AttachmentCollection^ attachments = message->Attachments; - attachments->Add( data ); - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - client->~SmtpClient(); - } - - - // - // - static void DisplayFileAttachment( Attachment^ a ) - { - Console::WriteLine( L"Content Disposition {0}", a->ContentDisposition ); - Console::WriteLine( L"Content Type {0}", a->ContentType ); - Console::WriteLine( L"Name {0}", a->Name ); - } - - - // - // - static void DisplayStringAttachment( Attachment^ a ) - { - Console::WriteLine( L"Content: {0}", a->ContentType ); - Console::WriteLine( L"Encoding {0}", a->TransferEncoding ); - Console::WriteLine( L"Content Disposition {0}", a->ContentDisposition->ToString() ); - Console::WriteLine( L"Content Type {0}", a->ContentType->ToString() ); - } - - - // - // - static void DisplayStreamAttachment( Attachment^ a ) - { - Stream^ s = a->ContentStream; - StreamReader^ reader = gcnew StreamReader( s ); - Console::WriteLine( L"Content: {0}", reader->ReadToEnd() ); - Console::WriteLine( L"Content Type {0}", a->ContentType ); - Console::WriteLine( L"Transfer Encoding {0}", a->TransferEncoding ); - - // Note that you cannot close the reader before the email is sent. - // Closing the reader before sending the email will close the - // ContentStream and cause an SmtpException. - reader = nullptr; - } - - - // - // - static void CreateMessageWithAttachment2( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named Data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment(file); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageWithAttachment3( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example assumes that a file named data.xls exists in the - // current working directory. - String^ file = L"data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment("Qtr3.xls"); - - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - - // Notify user if an error occurs. - try - { - client->Send( message ); - } - catch ( SmtpException^ e ) - { - Console::WriteLine( L"Error: {0}", e->StatusCode ); - } - finally - { - data->~Attachment(); - client->~SmtpClient(); - } - - } - - - // - // - static void CreateMessageWithAttachment4( String^ server, String^ to ) - { - - // Specify the file to be attached and sent. - // This example uses a file on a UNC share. - String^ file = L"\\\\share3\\c$\\reports\\data.xls"; - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"ReportMailer@contoso.com",to,L"Quarterly data report",L"See the attached spreadsheet." ); - - // Create the file attachment for this email message. - Attachment^ data = gcnew Attachment("qtr3.xls", MediaTypeNames::Application::Octet); - - // Add time stamp information for the file. - ContentDisposition^ disposition = data->ContentDisposition; - disposition->CreationDate = System::IO::File::GetCreationTime( file ); - disposition->ModificationDate = System::IO::File::GetLastWriteTime( file ); - disposition->ReadDate = System::IO::File::GetLastAccessTime( file ); - disposition->DispositionType = DispositionTypeNames::Attachment; - - // Add the file attachment to this email message. - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - - // Add credentials if the SMTP server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - - // Display the message headers. - array^keys = message->Headers->AllKeys; - Console::WriteLine( L"Headers" ); - IEnumerator^ myEnum3 = keys->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - String^ s = safe_cast(myEnum3->Current); - Console::WriteLine( L"{0}:", s ); - Console::WriteLine( L" {0}", message->Headers[ s ] ); - } - - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageAttachment5( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment(textMessage, - MediaTypeNames::Text::Plain); - ContentDisposition^ disposition = data->ContentDisposition; - - // Suggest a file name for the attachment. - disposition->FileName = String::Format( L"message{0}", DateTime::Now ); - message->Attachments->Add( data ); - - //Send the message. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void CreateMessageInlineAttachment3( String^ server, String^ textMessage ) - { - - // Create a message and set up the recipients. - MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"An inline text message for you.",L"Message: " ); - - // Attach the message string to this email message. - Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); - - // Send textMessage as part of the email body. - message->Attachments->Add( data ); - ContentDisposition^ disposition = data->ContentDisposition; - disposition->DispositionType = DispositionTypeNames::Inline; - - //Send the message. - // Include credentials if the server requires them. - SmtpClient^ client = gcnew SmtpClient( server ); - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - client->Send( message ); - data->~Attachment(); - client->~SmtpClient(); - } - - - // - // - static void RetryIfBusy( String^ server ) - { - MailAddress^ from = gcnew MailAddress( L"ben@contoso.com" ); - MailAddress^ to = gcnew MailAddress( L"jane@contoso.com" ); - MailMessage^ message = gcnew MailMessage( from,to ); - - // message.Subject = "Using the SmtpClient class."; - message->Subject = L"Using the SmtpClient class."; - message->Body = L"Using this feature, you can send an email message from an application very easily."; - - // Add a carbon copy recipient. - MailAddress^ copy = gcnew MailAddress( L"Notifications@contoso.com" ); - message->CC->Add( copy ); - SmtpClient^ client = gcnew SmtpClient( server ); - - // Include credentials if the server requires them. - client->Credentials = dynamic_cast(CredentialCache::DefaultNetworkCredentials); - Console::WriteLine( L"Sending an email message to {0} using the SMTP host {1}.", to->Address, client->Host ); - try - { - client->Send( message ); - } - catch ( SmtpFailedRecipientsException^ ex ) - { - for ( int i = 0; i < ex->InnerExceptions->Length; i++ ) - { - SmtpStatusCode status = ex->InnerExceptions[ i ]->StatusCode; - if ( status == SmtpStatusCode::MailboxBusy || status == SmtpStatusCode::MailboxUnavailable ) - { - Console::WriteLine( L"Delivery failed - retrying in 5 seconds." ); - System::Threading::Thread::Sleep( 5000 ); - client->Send( message ); - } - else - { - Console::WriteLine( L"Failed to deliver message to {0}", ex->InnerExceptions[ i ] ); - } - - } - } - catch ( Exception^ ex ) - { - Console::WriteLine(L"Exception caught in RetryIfBusy(): {0}", - ex->ToString() ); - } - finally - { - client->~SmtpClient(); - } - } - - - // - // silly snippets to get code coverage in exceptions! - // - static SmtpException^ GenerateDefaultSmtpException() - { - return gcnew SmtpException; - } - - - // - // - static SmtpException^ GenerateSmtpException( String^ message ) - { - return gcnew SmtpException( message ); - } - - - // - // - static SmtpException^ GenerateSmtpException( SmtpStatusCode status ) - { - return gcnew SmtpException( status ); - } - - - // - // - static SmtpException^ GenerateSmtpException( SmtpStatusCode status, String^ message ) - { - return gcnew SmtpException( status,message ); - } - - - // - // - static SmtpException^ GenerateSmtpException( String^ message, Exception^ innerException ) - { - return gcnew SmtpException( message,innerException ); - } - - - // - static void CreateSampleDispositions() - { - - // - ContentDisposition^ c1 = gcnew ContentDisposition; - Console::WriteLine( c1 ); - - // - // - ContentDisposition^ c2 = gcnew ContentDisposition( L"attachment" ); - Console::WriteLine( c2 ); - - // - ContentDisposition^ c3 = gcnew ContentDisposition( L"Attachment; filename = myFile;" ); - Console::WriteLine( c3 ); - } - - static void DumpMailAddress( MailAddress^ a ) - { - Console::WriteLine( L"Display: {0} Host: {1} User: {2} Address: {3}", a->DisplayName, a->Host, a->User, a->Address ); - } - - static void CreateSampleAddresses() - { - MailAddress^ a1 = gcnew MailAddress( L"Ben Miller " ); - Console::WriteLine( a1 ); - DumpMailAddress( a1 ); - - // WRONG but legal: Should not include angle brackets. - MailAddress^ a2 = gcnew MailAddress( L"" ); - Console::WriteLine( a2 ); - DumpMailAddress( a2 ); - MailAddress^ a3 = gcnew MailAddress( L"ben.address1@contoso.com" ); - Console::WriteLine( a3 ); - DumpMailAddress( a3 ); - - // Use a constructor that takes an address and the display name separately. - // Throwing a format exception - // MailAddress a4 = new MailAddress("tom@contoso.com", "Tom Smith"); - // Console.WriteLine(a4.ToString()); - // DumpMailAddress(a4); - // WRONG: Should not include angle brackets. - // MailAddress a5 = new MailAddress(" ", "Tom Smith"); - // Console.WriteLine(a5.ToString()); - // DumpMailAddress(a5); - // WRONG but legal: Should not include display name as part of address. - MailAddress^ a6 = gcnew MailAddress( L"Tom Smith",L"Bill Jones" ); - Console::WriteLine( a6 ); - DumpMailAddress( a6 ); - MailAddress^ a7 = gcnew MailAddress( L"tom@contoso.com",L" Tom Smith " ); - Console::WriteLine( a7 ); - DumpMailAddress( a7 ); - } - - static void DisplayContentType( ContentType^ c ) - { - Console::WriteLine( L"Boundary {0}", c->Boundary ); - Console::WriteLine( L"Charset {0}", c->CharSet ); - Console::WriteLine( L"MediaType {0}", c->MediaType ); - Console::WriteLine( L"Name {0}", c->Name ); - Console::WriteLine( L"Parameters: {0}", c->Parameters->Count ); - IEnumerator^ myEnum4 = c->Parameters->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum4->Current); - Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); - } - } - - static void CreateContentTypes() - { - ContentType^ c1 = gcnew ContentType; - Console::WriteLine( L"---c1 {0}", c1 ); - DisplayContentType( c1 ); - ContentType^ c2 = gcnew ContentType( L"text/html" ); - Console::WriteLine( L"---c2 {0}", c2 ); - DisplayContentType( c2 ); - ContentType^ c3 = gcnew ContentType( L"application/x-myPrivateSubtype; name=data.xyz; charset=us-ascii" ); - Console::WriteLine( L"---c3 {0}", c3 ); - DisplayContentType( c3 ); - } - - - // The first argument is the recipient. - // The second argument is the sender. - void NCLMailSyncRun() - { - - // CreateTestMessage2(args[0]); - //CreateMessageInlineAttachment3("smarthost", "string textMessage"); - //CreateTestMessage3(); - //CreateTestMessage4(args[0]); - // CreateTestMessageX(args[0]); - //CreateMessageWithMultipleViews("smarthost","sharriso@microsoft.com"); - CreateBccTestMessage( L"sharriso1" ); - - //CreateCopyMessage("sharriso1"); - // CreateMessageWithMultipleRecipients("sharriso1"); - //CreateTestMessageY("sharriso1"); - //CreateMessageWithAttachment("smarthost"); - //CreateContentTypes(); - // CreateMessageWithMultipleRecipients("smarthost"); - //CreateSampleAddresses(); - // CreateMessageAttachment1("smarthost", "This is an attached message."); - //CreateMessageInlineAttachment("sharriso1", "How cool is this?"); - //CreateMessageInlineAttachment2("smarthost", "This is an attached message."); - //SendErrorLog("smarthost", "sharriso@microsoft.com"); - //Attachment log = SendNamedErrorLog("smarthost", "sharriso@microsoft.com"); - //SendNamedAndTypedErrorLog("smarthost", "sharriso@microsoft.com"); - //Attachment a = SendAttachedMessage("smarthost"); - //DisplayStringAttachment(a); - // CreateMessageWithFile("smarthost", "sharriso@microsoft.com"); - // CreateMessageWithAttachment2("smarthost", "sharriso@microsoft.com"); - // CreateMessageWithAttachment3("xx","sharriso@microsoft.com"); - // CreateMessageWithAttachment4("smarthost", "sharriso@microsoft.com"); - // CreateMessageAttachment5("sharriso1", "string textMessage"); - //CreateSampleDispositions(); - RetryIfBusy("sharriso1"); - } - -}; - -void main() -{ - CtorExamples^ ce = gcnew CtorExamples; - ce->NCLMailSyncRun(); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp deleted file mode 100644 index 210b727cdc0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp +++ /dev/null @@ -1,1010 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Net::Sockets; - -// -void GetTcpConnections() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - System::Collections::IEnumerator^ myEnum = connections->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - TcpConnectionInformation ^ t = safe_cast(myEnum->Current); - Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address ); - Console::Write( "Remote endpoint: {0} ", t->RemoteEndPoint->Address ); - Console::WriteLine( "{0}", t->State ); - } -} -// - -// -void CountTcpConnections() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - int establishedConnections = 0; - System::Collections::IEnumerator^ myEnum1 = connections->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - TcpConnectionInformation ^ t = safe_cast(myEnum1->Current); - if ( t->State == TcpState::Established ) - { - establishedConnections++; - } - - Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address ); - Console::WriteLine( "Remote endpoint: {0} ", t->RemoteEndPoint->Address ); - } - - Console::WriteLine( "There are {0} established TCP connections.", establishedConnections ); -} -// - -// -void DisplayActiveUdpListeners() -{ - Console::WriteLine( "Active UDP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveUdpListeners(); - System::Collections::IEnumerator^ myEnum2 = endPoints->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum2->Current); - Console::WriteLine( e ); - } -} -// - -// -void ShowNetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - if ( !nics || nics->Length < 1 ) - { - Console::WriteLine( " No network interfaces found." ); - return; - } - - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "Interface information for {0}.{1}", properties->HostName, properties->DomainName ); - Console::WriteLine( " Number of interfaces .................... : {0}", nics->Length ); - System::Collections::IEnumerator^ myEnum3 = nics->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum3->Current); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - } -} -// - -// -void ShowTcpTimeouts() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Minimum Transmission Timeout............. : {0}", - tcpstat->MinimumTransmissionTimeout ); - Console::WriteLine( " Maximum Transmission Timeout............. : {0}", - tcpstat->MaximumTransmissionTimeout ); - Console::WriteLine( " Maximum connections ............. : {0}", - tcpstat->MaximumConnections ); -} -// - -// -void ShowTcpConnectionStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Connection Data:" ); - Console::WriteLine( " Current ............................ : {0}", - tcpstat->CurrentConnections ); - Console::WriteLine( " Cumulative .......................... : {0}", - tcpstat->CumulativeConnections ); - Console::WriteLine( " Initiated ........................... : {0}", - tcpstat->ConnectionsInitiated ); - Console::WriteLine( " Accepted ............................ : {0}", - tcpstat->ConnectionsAccepted ); - Console::WriteLine( " Failed Attempts ..................... : {0}", - tcpstat->FailedConnectionAttempts ); - Console::WriteLine( " Reset ............................... : {0}", - tcpstat->ResetConnections ); - Console::WriteLine( " Errors .............................. : {0}", - tcpstat->ErrorsReceived ); -} -// - -// -void ShowTcpSegmentData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( " Segment Data:" ); - Console::WriteLine( " Received ........................... : {0}", - tcpstat->SegmentsReceived ); - Console::WriteLine( " Sent ................................ : {0}", - tcpstat->SegmentsSent ); - Console::WriteLine( " Retransmitted ....................... : {0}", - tcpstat->SegmentsResent ); - Console::WriteLine( " Resent with reset ................... : {0}", - tcpstat->ResetsSent ); -} -// - -// -void ShowInterfaceByteCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum4 = adapters->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum4->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Bytes sent ............................: {0}", - stats->BytesSent ); - Console::WriteLine( " Bytes received ........................: {0}", - stats->BytesReceived ); - } -} -// - -// -void ShowUnicastCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum5 = adapters->GetEnumerator(); - while ( myEnum5->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum5->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Unicast Packets Sent ..................: {0}", - stats->UnicastPacketsSent ); - Console::WriteLine( " Unicast Packets Received ..............: {0}", - stats->UnicastPacketsReceived ); - } -} -// - -// -void ShowNonUnicastCounts() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum6 = adapters->GetEnumerator(); - while ( myEnum6->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum6->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Non Unicast Packets Sent ..............: {0}", - stats->NonUnicastPacketsSent ); - Console::WriteLine( " Non Unicast Packets Received ..........: {0}", - stats->NonUnicastPacketsReceived ); - } -} -// - -// -void ShowPacketDiscards() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum7 = adapters->GetEnumerator(); - while ( myEnum7->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum7->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Incoming Packets Discarded ............: {0}", - stats->IncomingPacketsDiscarded ); - Console::WriteLine( " Outgoing Packets Discarded ............: {0}", - stats->OutgoingPacketsDiscarded ); - } -} -// - -// -void ShowPacketErrors() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum8 = adapters->GetEnumerator(); - while ( myEnum8->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum8->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Incoming Packets Errors ...............: {0}", - stats->IncomingPacketsWithErrors ); - Console::WriteLine( " Outgoing packets Errors ...............: {0}", - stats->OutgoingPacketsWithErrors ); - Console::WriteLine( " Incoming Unknown Protocol Errors ......: {0}", - stats->IncomingUnknownProtocolPackets ); - } -} -// - -// -void ShowInterfaceSpeedAndQueue() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum9 = adapters->GetEnumerator(); - while ( myEnum9->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum9->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " Speed .................................: {0}", - adapter->Speed ); - Console::WriteLine( " Output queue length....................: {0}", - stats->OutputQueueLength ); - } -} -// - -// -void ShowIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Forwarding enabled ...................... : {0}", - ipstat->ForwardingEnabled ); - Console::WriteLine( " Interfaces .............................. : {0}", - ipstat->NumberOfInterfaces ); - Console::WriteLine( " IP addresses ............................ : {0}", - ipstat->NumberOfIPAddresses ); - Console::WriteLine( " Routes .................................. : {0}", - ipstat->NumberOfRoutes ); - Console::WriteLine( " Default TTL ............................. : {0}", - ipstat->DefaultTtl ); -} -// - -// -void ShowInboundIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Inbound Packet Data:" ); - Console::WriteLine( " Received ............................ : {0}", - ipstat->ReceivedPackets ); - Console::WriteLine( " Forwarded ........................... : {0}", - ipstat->ReceivedPacketsForwarded ); - Console::WriteLine( " Delivered ........................... : {0}", - ipstat->ReceivedPacketsDelivered ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->ReceivedPacketsDiscarded ); -} -// - -// -void ShowInboundIPErrors() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Inbound Packet Errors:" ); - Console::WriteLine( " Header Errors ....................... : {0}", - ipstat->ReceivedPacketsWithHeadersErrors ); - Console::WriteLine( " Address Errors ...................... : {0}", - ipstat->ReceivedPacketsWithAddressErrors ); - Console::WriteLine( " Unknown Protocol Errors ............. : {0}", - ipstat->ReceivedPacketsWithUnknownProtocol ); -} -// - -// -void ShowOutboundIPStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Outbound Packet Data:" ); - Console::WriteLine( " Requested ........................... : {0}", - ipstat->OutputPacketRequests ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->OutputPacketsDiscarded ); - Console::WriteLine( " No Routing Discards ................. : {0}", - ipstat->OutputPacketsWithNoRoute ); - Console::WriteLine( " Routing Entry Discards .............. : {0}", - ipstat->OutputPacketRoutingDiscards ); -} -// - -// -void ShowFragmentationStatistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( " Reassembly Data:" ); - Console::WriteLine( " Reassembly Timeout .................. : {0}", - ipstat->PacketReassemblyTimeout ); - Console::WriteLine( " Reassemblies Required ............... : {0}", - ipstat->PacketReassembliesRequired ); - Console::WriteLine( " Packets Reassembled ................. : {0}", - ipstat->PacketsReassembled ); - Console::WriteLine( " Packets Fragmented .................. : {0}", - ipstat->PacketsFragmented ); - Console::WriteLine( " Fragment Failures ................... : {0}", - ipstat->PacketFragmentFailures ); -} -// - -// -void ShowIcmpV4MessageData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", - statistics->MessagesSent, statistics->MessagesReceived ); -} -// - -// -void ShowIcmpV4EchoData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", - statistics->EchoRequestsSent, - statistics->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", - statistics->EchoRepliesSent, - statistics->EchoRepliesReceived ); -} -// - -// -void ShowIcmpV4ErrorData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", - statistics->ErrorsSent, - statistics->ErrorsReceived ); -} -// - -// -void ShowIcmpV4UnreachableData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", - statistics->DestinationUnreachableMessagesSent, - statistics->DestinationUnreachableMessagesReceived ); -} -// - -// -void ShowSourceQuenchData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", - statistics->SourceQuenchesSent, - statistics->SourceQuenchesReceived ); -} -// - -// -void ShowRedirectsData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", - statistics->RedirectsSent, - statistics->RedirectsReceived ); -} -// - -// -void ShowTimeExceededData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", - statistics->TimeExceededMessagesSent, - statistics->TimeExceededMessagesReceived ); -} -// - -// -void ShowParameterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", - statistics->ParameterProblemsSent, - statistics->ParameterProblemsReceived ); -} -// - -// -void ShowTimestampData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Timestamp Requests .................. Sent: {0,-10} Received: {1,-10}", - statistics->TimestampRequestsSent, - statistics->TimestampRequestsReceived ); - Console::WriteLine( " Timestamp Replies ................... Sent: {0,-10} Received: {1,-10}", - statistics->TimestampRepliesSent, - statistics->TimestampRepliesReceived ); -} -// - -// -void ShowAddressMaskData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ statistics = properties->GetIcmpV4Statistics(); - Console::WriteLine( " Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", - statistics->AddressMaskRequestsSent, - statistics->AddressMaskRequestsReceived ); - Console::WriteLine( " Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", - statistics->AddressMaskRepliesSent, - statistics->AddressMaskRepliesReceived ); -} -// - -// -void ShowIcmpV6EchoData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", - statistics->EchoRequestsSent, statistics->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", - statistics->EchoRepliesSent, statistics->EchoRepliesReceived ); -} -// - -// -void ShowIcmpV6ErrorData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", - statistics->ErrorsSent, statistics->ErrorsReceived ); -} -// - -// -void ShowIcmpV6UnreachableData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", - statistics->DestinationUnreachableMessagesSent, - statistics->DestinationUnreachableMessagesReceived ); -} -// - -// -void ShowIcmpV6MessageData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", - statistics->MessagesSent, statistics->MessagesReceived ); -} -// - -// -void ShowIcmpV6MembershipData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Queries .............................. Sent: {0,-10} Received: {1,-10}", - statistics->MembershipQueriesSent, statistics->MembershipQueriesReceived ); - Console::WriteLine( " Reductions ........................... Sent: {0,-10} Received: {1,-10}", - statistics->MembershipReductionsSent, statistics->MembershipReductionsReceived ); - Console::WriteLine( " Reports .............................. Sent: {0,-10} Received: {1,-10}", - statistics->MembershipReportsSent, statistics->MembershipReportsReceived ); -} -// - -// -void ShowIcmpV6NeighborData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Advertisements ...................... Sent: {0,-10} Received: {1,-10}", - statistics->NeighborAdvertisementsSent, statistics->NeighborAdvertisementsReceived ); - Console::WriteLine( " Solicits ............................ Sent: {0,-10} Received: {1,-10}", - statistics->NeighborSolicitsSent, statistics->NeighborSolicitsReceived ); -} -// - -// -void ShowIcmpV6BigPacketData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Too Big Packet ........................ Sent: {0,-10} Received: {1,-10}", - statistics->PacketTooBigMessagesSent, - statistics->PacketTooBigMessagesReceived ); -} -// - -// -void ShowIcmpV6RedirectsData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", - statistics->RedirectsSent, - statistics->RedirectsReceived ); -} -// - -// -void ShowIcmpV6TimeExceededData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", - statistics->TimeExceededMessagesSent, - statistics->TimeExceededMessagesReceived ); -} -// - -// -void ShowIcmpV6ParameterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", - statistics->ParameterProblemsSent, - statistics->ParameterProblemsReceived ); -} -// - -// -void ShowIcmpV6RouterData() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ statistics = properties->GetIcmpV6Statistics(); - Console::WriteLine( " Advertisements ....................... Sent: {0,-10} Received: {1,-10}", - statistics->RouterAdvertisementsSent, - statistics->RouterAdvertisementsReceived ); - Console::WriteLine( " Solicits ............................. Sent: {0,-10} Received: {1,-10}", - statistics->RouterSolicitsSent, - statistics->RouterSolicitsReceived ); -} -// - -// New content 10/29/03 -// -void DisplayDnsConfiguration() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum10 = adapters->GetEnumerator(); - while ( myEnum10->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum10->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( " DNS suffix................................. :{0}", - properties->DnsSuffix ); - Console::WriteLine( " DNS enabled ............................. : {0}", - properties->IsDnsEnabled ); - Console::WriteLine( " Dynamically configured DNS .............. : {0}", - properties->IsDynamicDnsEnabled ); - } -} -// - -// -void DisplayDnsAddresses() -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum11 = adapters->GetEnumerator(); - while ( myEnum11->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum11->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses; - if ( dnsServers->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum12 = dnsServers->GetEnumerator(); - while ( myEnum12->MoveNext() ) - { - IPAddress ^ dns = safe_cast(myEnum12->Current); - Console::WriteLine( " DNS Servers ............................. : {0}", - dns->ToString()); - } - } - } -} -// - -// -void DisplayAnycastAddresses() -{ - int count = 0; - - Console::WriteLine( "Anycast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum13 = adapters->GetEnumerator(); - while ( myEnum13->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum13->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses; - if ( anyCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum14 = anyCast->GetEnumerator(); - while ( myEnum14->MoveNext() ) - { - IPAddressInformation ^ any = safe_cast(myEnum14->Current); - Console::WriteLine( " Anycast Address .......................... : {0} {1} {2}", - any->Address, any->IsTransient ? "Transient" : "", - any->IsDnsEligible ? "DNS Eligible" : "" ); - count++; - } - Console::WriteLine(); - } - } - if (count == 0) - { - Console::WriteLine(" No anycast addresses were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayMulticastAddresses() -{ - int count = 0; - - Console::WriteLine( "Multicast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum15 = adapters->GetEnumerator(); - while ( myEnum15->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum15->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses; - if ( multiCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum16 = multiCast->GetEnumerator(); - while ( myEnum16->MoveNext() ) - { - MulticastIPAddressInformation ^ multi = safe_cast(myEnum16->Current); - Console::WriteLine( " Multicast Address ....................... : {0} {1} {2}", - multi->Address, multi->IsTransient ? "Transient" : "", - multi->IsDnsEligible ? "DNS Eligible" : "" ); - count++; - } - Console::WriteLine(); - } - } - if (count == 0) - { - Console::WriteLine(" No multicast addresses were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayUnicastAddresses() -{ - Console::WriteLine( "Unicast Addresses" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum17 = adapters->GetEnumerator(); - while ( myEnum17->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum17->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - UnicastIPAddressInformationCollection ^ uniCast = adapterProperties->UnicastAddresses; - if ( uniCast->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - String^ lifeTimeFormat = "dddd, MMMM dd, yyyy hh:mm:ss tt"; - System::Collections::IEnumerator^ myEnum18 = uniCast->GetEnumerator(); - while ( myEnum18->MoveNext() ) - { - UnicastIPAddressInformation ^ uni = safe_cast(myEnum18->Current); - DateTime when; - Console::WriteLine( " Unicast Address ......................... : {0}", - uni->Address ); - Console::WriteLine( " Prefix Origin ........................ : {0}", - uni->PrefixOrigin ); - Console::WriteLine( " Suffix Origin ........................ : {0}", - uni->SuffixOrigin ); - Console::WriteLine( " Duplicate Address Detection .......... : {0}", - uni->DuplicateAddressDetectionState ); - - // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM - // if en-us is the current culture. - // Calculate the date and time at the end of the lifetimes. - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressValidLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Valid Life Time ...................... : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressPreferredLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Preferred life time .................. : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->DhcpLeaseLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " DHCP Leased Life Time ................ : {0}", - when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayDhcpServerAddresses() -{ - Console::WriteLine( "DHCP Servers" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum19 = adapters->GetEnumerator(); - while ( myEnum19->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum19->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ addresses = adapterProperties->DhcpServerAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum20 = addresses->GetEnumerator(); - while ( myEnum20->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum20->Current); - Console::WriteLine( " Dhcp Address ............................ : {0}", - address ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayGatewayAddresses() -{ - Console::WriteLine( "Gateways" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum21 = adapters->GetEnumerator(); - while ( myEnum21->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum21->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - GatewayIPAddressInformationCollection ^ addresses = adapterProperties->GatewayAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum22 = addresses->GetEnumerator(); - while ( myEnum22->MoveNext() ) - { - GatewayIPAddressInformation^ address = safe_cast(myEnum22->Current); - Console::WriteLine( " Gateway Address ......................... : {0}", - address->Address->ToString() ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayIPv4NetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "IPv4 interface information for {0}.{1}", properties->HostName, properties->DomainName ); - System::Collections::IEnumerator^ myEnum23 = nics->GetEnumerator(); - while ( myEnum23->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum23->Current); - - // Only display informatin for interfaces that support IPv4. - if ( !adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - continue; - } - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - - // Underline the description. - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - - // Try to get the IPv4 interface properties. - IPv4InterfaceProperties ^ p = adapterProperties->GetIPv4Properties(); - - // Display the IPv4 specific data. - Console::WriteLine( " Index ............................. : {0}", - p->Index ); - Console::WriteLine( " MTU ............................... : {0}", - p->Mtu ); - Console::WriteLine( " APIPA active....................... : {0}", - p->IsAutomaticPrivateAddressingActive ); - Console::WriteLine( " APIPA enabled...................... : {0}", - p->IsAutomaticPrivateAddressingEnabled ); - Console::WriteLine( " Forwarding enabled................. : {0}", - p->IsForwardingEnabled ); - Console::WriteLine( " Uses WINS ......................... : {0}", - p->UsesWins ); - } -} -// - -// -void DisplayIPv6NetworkInterfaces() -{ - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "IPv6 interface information for {0}.{1}", - properties->HostName, properties->DomainName ); - - int count = 0; - - System::Collections::IEnumerator^ myEnum24 = nics->GetEnumerator(); - while ( myEnum24->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum24->Current); - - // Only display informatin for interfaces that support IPv6. - if ( !adapter->Supports( NetworkInterfaceComponent::IPv6 ) ) - { - continue; - } - - count++; - - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - - // Underline the description. - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - - // Try to get the IPv6 interface properties. - IPv6InterfaceProperties ^ p = adapterProperties->GetIPv6Properties(); - if ( !p ) - { - Console::WriteLine( "No IPv6 information is available for this interface." ); - continue; - } - - // Display the IPv6 specific data. - Console::WriteLine( " Index ............................. : {0}", - p->Index ); - Console::WriteLine( " MTU ............................... : {0}", - p->Mtu ); - } - if (count == 0) - { - Console::WriteLine(" No IPv6 interfaces were found."); - Console::WriteLine(); - } -} -// - -// -void DisplayWinsServerAddresses() -{ - Console::WriteLine( "WINS Servers" ); - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum25 = adapters->GetEnumerator(); - while ( myEnum25->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum25->Current); - IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties(); - IPAddressCollection ^ addresses = adapterProperties->WinsServersAddresses; - if ( addresses->Count > 0 ) - { - Console::WriteLine( adapter->Description ); - System::Collections::IEnumerator^ myEnum26 = addresses->GetEnumerator(); - while ( myEnum26->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum26->Current); - Console::WriteLine( " WINS Server ............................ : {0}", - address ); - } - Console::WriteLine(); - } - } -} -// - -// -void DisplayTypeAndAddress() -{ - IPGlobalProperties ^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( "Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - System::Collections::IEnumerator^ myEnum27 = nics->GetEnumerator(); - while ( myEnum27->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum27->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Physical Address ........................ : {0}", - adapter->GetPhysicalAddress() ); - Console::WriteLine( " Is receive only.......................... : {0}", - adapter->IsReceiveOnly ); - Console::WriteLine( " Multicast................................ : {0}", - adapter->SupportsMulticast ); - } -} -// - -int main() -{ - DisplayDnsAddresses(); - DisplayDnsConfiguration(); - DisplayAnycastAddresses(); - DisplayMulticastAddresses(); - DisplayUnicastAddresses(); - - DisplayDhcpServerAddresses(); - DisplayGatewayAddresses(); - - DisplayIPv4NetworkInterfaces(); - DisplayIPv6NetworkInterfaces(); - DisplayWinsServerAddresses(); - - DisplayTypeAndAddress(); - - GetTcpConnections(); - CountTcpConnections(); - DisplayActiveUdpListeners(); - ShowTcpSegmentData(); - ShowTcpConnectionStatistics(); - ShowTcpTimeouts(); - ShowInterfaceSpeedAndQueue(); - ShowPacketErrors(); - ShowPacketDiscards(); - ShowNonUnicastCounts(); - ShowUnicastCounts(); - ShowInterfaceByteCounts(); - ShowFragmentationStatistics(); - ShowOutboundIPStatistics(); - // - ShowInboundIPErrors(); - ShowInboundIPStatistics(); - ShowIPStatistics(); - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6MessageData(); - ShowIcmpV6EchoData(); - ShowIcmpV6ErrorData(); - ShowIcmpV6UnreachableData (); - ShowIcmpV6RouterData (); - } - ShowRedirectsData(); - ShowTimeExceededData(); - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6ParameterData (); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp deleted file mode 100644 index 850060ff81c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp +++ /dev/null @@ -1,603 +0,0 @@ - - -// Sample NCLNetInfoReport -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::NetworkInformation; -using namespace System::Text; - -// -void ShowIPStatistics( NetworkInterfaceComponent version ) -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IPGlobalStatistics ^ ipstat = nullptr; - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( "{0}IPv4 Statistics ", Environment::NewLine ); - break; - - case NetworkInterfaceComponent::IPv6: - ipstat = properties->GetIPv4GlobalStatistics(); - Console::WriteLine( "{0}IPv6 Statistics ", Environment::NewLine ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - // - - Console::WriteLine( " Forwarding enabled ...................... : {0}", - ipstat->ForwardingEnabled ); - Console::WriteLine( " Interfaces .............................. : {0}", - ipstat->NumberOfInterfaces ); - Console::WriteLine( " IP addresses ............................ : {0}", - ipstat->NumberOfIPAddresses ); - Console::WriteLine( " Routes .................................. : {0}", - ipstat->NumberOfRoutes ); - Console::WriteLine( " Default TTL ............................. : {0}", - ipstat->DefaultTtl ); - Console::WriteLine( "" ); - Console::WriteLine( " Inbound Packet Data:" ); - Console::WriteLine( " Received ............................ : {0}", - ipstat->ReceivedPackets ); - Console::WriteLine( " Forwarded ........................... : {0}", - ipstat->ReceivedPacketsForwarded ); - Console::WriteLine( " Delivered ........................... : {0}", - ipstat->ReceivedPacketsDelivered ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->ReceivedPacketsDiscarded ); - Console::WriteLine( " Header Errors ....................... : {0}", - ipstat->ReceivedPacketsWithHeadersErrors ); - Console::WriteLine( " Address Errors ...................... : {0}", - ipstat->ReceivedPacketsWithAddressErrors ); - Console::WriteLine( " Unknown Protocol Errors ............. : {0}", - ipstat->ReceivedPacketsWithUnknownProtocol ); - Console::WriteLine( "" ); - Console::WriteLine( " Outbound Packet Data:" ); - Console::WriteLine( " Requested ........................... : {0}", - ipstat->OutputPacketRequests ); - Console::WriteLine( " Discarded ........................... : {0}", - ipstat->OutputPacketsDiscarded ); - Console::WriteLine( " No Routing Discards ................. : {0}", - ipstat->OutputPacketsWithNoRoute ); - Console::WriteLine( " Routing Entry Discards .............. : {0}", - ipstat->OutputPacketRoutingDiscards ); - Console::WriteLine( "" ); - Console::WriteLine( " Reassembly Data:" ); - Console::WriteLine( " Reassembly Timeout .................. : {0}", - ipstat->PacketReassemblyTimeout ); - Console::WriteLine( " Reassemblies Required ............... : {0}", - ipstat->PacketReassembliesRequired ); - Console::WriteLine( " Packets Reassembled ................. : {0}", - ipstat->PacketsReassembled ); - Console::WriteLine( " Packets Fragmented .................. : {0}", - ipstat->PacketsFragmented ); - Console::WriteLine( " Fragment Failures ................... : {0}", - ipstat->PacketFragmentFailures ); - Console::WriteLine( "" ); -} -// - -// -void ShowTcpStatistics( NetworkInterfaceComponent version ) -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - TcpStatistics ^ tcpstat = nullptr; - Console::WriteLine( "" ); - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - tcpstat = properties->GetTcpIPv4Statistics(); - Console::WriteLine( "TCP/IPv4 Statistics:" ); - break; - - case NetworkInterfaceComponent::IPv6: - tcpstat = properties->GetTcpIPv6Statistics(); - Console::WriteLine( "TCP/IPv6 Statistics:" ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - // - Console::WriteLine( " Minimum Transmission Timeout............. : {0}", - tcpstat->MinimumTransmissionTimeout ); - Console::WriteLine( " Maximum Transmission Timeout............. : {0}", - tcpstat->MaximumTransmissionTimeout ); - Console::WriteLine( " Connection Data:" ); - Console::WriteLine( " Current ............................ : {0}", - tcpstat->CurrentConnections ); - Console::WriteLine( " Cumulative .......................... : {0}", - tcpstat->CumulativeConnections ); - Console::WriteLine( " Initiated ........................... : {0}", - tcpstat->ConnectionsInitiated ); - Console::WriteLine( " Accepted ............................ : {0}", - tcpstat->ConnectionsAccepted ); - Console::WriteLine( " Failed Attempts ..................... : {0}", - tcpstat->FailedConnectionAttempts ); - Console::WriteLine( " Reset ............................... : {0}", - tcpstat->ResetConnections ); - Console::WriteLine( "" ); - Console::WriteLine( " Segment Data:" ); - Console::WriteLine( " Received ........................... : {0}", - tcpstat->SegmentsReceived ); - Console::WriteLine( " Sent ................................ : {0}", - tcpstat->SegmentsSent ); - Console::WriteLine( " Retransmitted ....................... : {0}", - tcpstat->SegmentsResent ); - Console::WriteLine( "" ); -} -// - -// -void ShowUdpStatistics( NetworkInterfaceComponent version ) -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - UdpStatistics ^ udpStat = nullptr; - switch ( version ) - { - case NetworkInterfaceComponent::IPv4: - udpStat = properties->GetUdpIPv4Statistics(); - Console::WriteLine( "UDP IPv4 Statistics" ); - break; - - case NetworkInterfaceComponent::IPv6: - udpStat = properties->GetUdpIPv6Statistics(); - Console::WriteLine( "UDP IPv6 Statistics" ); - break; - - default: - throw gcnew ArgumentException( "version" ); - break; - } - Console::WriteLine( " Datagrams Received ...................... : {0}", udpStat->DatagramsReceived ); - Console::WriteLine( " Datagrams Sent .......................... : {0}", udpStat->DatagramsSent ); - Console::WriteLine( " Incoming Datagrams Discarded ............ : {0}", udpStat->IncomingDatagramsDiscarded ); - Console::WriteLine( " Incoming Datagrams With Errors .......... : {0}", udpStat->IncomingDatagramsWithErrors ); - Console::WriteLine( " UDP Listeners ........................... : {0}", udpStat->UdpListeners ); - Console::WriteLine( "" ); -} -// - -// -void ShowEchoIcmpv4( IcmpV4Statistics ^ stat4 ) -{ - if ( stat4 != nullptr ) - { - Console::WriteLine( "ICMP v4 Echo Requests ................. Sent: {0,-10} Received: {1,-10}", stat4->EchoRequestsSent, stat4->EchoRequestsReceived ); - Console::WriteLine( "ICMP v4 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat4->EchoRepliesSent, stat4->EchoRepliesReceived ); - } -} - -void ShowEchoIcmpv6( IcmpV6Statistics ^ stat6 ) -{ - if ( stat6 != nullptr ) - { - Console::WriteLine( "ICMP v6 Echo Requests.................. Sent: {0,-10} Received: {1,-10}", stat6->EchoRequestsSent, stat6->EchoRequestsReceived ); - Console::WriteLine( "ICMP v6 Echo Replies .................. Sent: {0,-10} Received: {1,-10}", stat6->EchoRepliesSent, stat6->EchoRepliesReceived ); - } -} - -// - -// -void ShowIcmpv4MessagesAndErrors( IcmpV4Statistics ^ stat4 ) -{ - if ( stat4 != nullptr ) - { - Console::WriteLine( "ICMP v4 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat4->MessagesSent, stat4->MessagesReceived ); - Console::WriteLine( "ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat4->ErrorsSent, stat4->ErrorsReceived ); - } - -} - -void ShowIcmpv6MessagesAndErrors( IcmpV6Statistics ^ stat6 ) -{ - if ( stat6 != nullptr ) - { - Console::WriteLine( "ICMP v6 Messages ...................... Sent: {0,-10} Received: {1,-10}", stat6->MessagesSent, stat6->MessagesReceived ); - Console::WriteLine( "ICMP v6 Errors ........................ Sent: {0,-10} Received: {1,-10}", stat6->ErrorsSent, stat6->ErrorsReceived ); - } -} -// - -// -void ShowIcmpV4Statistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV4Statistics ^ stat = properties->GetIcmpV4Statistics(); - Console::WriteLine( "ICMP V4 Statistics:" ); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", stat->MessagesSent, stat->MessagesReceived ); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", stat->ErrorsSent, stat->ErrorsReceived ); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", stat->EchoRequestsSent, stat->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", stat->EchoRepliesSent, stat->EchoRepliesReceived ); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", stat->DestinationUnreachableMessagesSent, stat->DestinationUnreachableMessagesReceived ); - Console::WriteLine( " Source Quenches ..................... Sent: {0,-10} Received: {1,-10}", stat->SourceQuenchesSent, stat->SourceQuenchesReceived ); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat->RedirectsSent, stat->RedirectsReceived ); - Console::WriteLine( " TimeExceeded ........................ Sent: {0,-10} Received: {1,-10}", stat->TimeExceededMessagesSent, stat->TimeExceededMessagesReceived ); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat->ParameterProblemsSent, stat->ParameterProblemsReceived ); - Console::WriteLine( " Timestamp Requests .................. Sent: {0,-10} Received: {1,-10}", stat->TimestampRequestsSent, stat->TimestampRequestsReceived ); - Console::WriteLine( " Timestamp Replies ................... Sent: {0,-10} Received: {1,-10}", stat->TimestampRepliesSent, stat->TimestampRepliesReceived ); - Console::WriteLine( " Address Mask Requests ............... Sent: {0,-10} Received: {1,-10}", stat->AddressMaskRequestsSent, stat->AddressMaskRequestsReceived ); - Console::WriteLine( " Address Mask Replies ................ Sent: {0,-10} Received: {1,-10}", stat->AddressMaskRepliesSent, stat->AddressMaskRepliesReceived ); - Console::WriteLine( "" ); -} -// - -// -void ShowIcmpV6Statistics() -{ - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - IcmpV6Statistics ^ stat = properties->GetIcmpV6Statistics(); - Console::WriteLine( "ICMP V6 Statistics:" ); - Console::WriteLine( " Messages ............................ Sent: {0,-10} Received: {1,-10}", stat->MessagesSent, stat->MessagesReceived ); - Console::WriteLine( " Errors .............................. Sent: {0,-10} Received: {1,-10}", stat->ErrorsSent, stat->ErrorsReceived ); - Console::WriteLine( " Echo Requests ....................... Sent: {0,-10} Received: {1,-10}", stat->EchoRequestsSent, stat->EchoRequestsReceived ); - Console::WriteLine( " Echo Replies ........................ Sent: {0,-10} Received: {1,-10}", stat->EchoRepliesSent, stat->EchoRepliesReceived ); - Console::WriteLine( " Destination Unreachables ............ Sent: {0,-10} Received: {1,-10}", stat->DestinationUnreachableMessagesSent, stat->DestinationUnreachableMessagesReceived ); - Console::WriteLine( " Parameter Problems .................. Sent: {0,-10} Received: {1,-10}", stat->ParameterProblemsSent, stat->ParameterProblemsReceived ); - Console::WriteLine( " Packets Too Big ..................... Sent: {0,-10} Received: {1,-10}", stat->PacketTooBigMessagesSent, stat->PacketTooBigMessagesReceived ); - Console::WriteLine( " Redirects ........................... Sent: {0,-10} Received: {1,-10}", stat->RedirectsSent, stat->RedirectsReceived ); - Console::WriteLine( " Router Advertisements ............... Sent: {0,-10} Received: {1,-10}", stat->RouterAdvertisementsSent, stat->RouterAdvertisementsReceived ); - Console::WriteLine( " Router Solicitations ................ Sent: {0,-10} Received: {1,-10}", stat->RouterSolicitsSent, stat->RouterSolicitsReceived ); - Console::WriteLine( " Time Exceeded ....................... Sent: {0,-10} Received: {1,-10}", stat->TimeExceededMessagesSent, stat->TimeExceededMessagesReceived ); - Console::WriteLine( " Neighbor Advertisements ............. Sent: {0,-10} Received: {1,-10}", stat->NeighborAdvertisementsSent, stat->NeighborAdvertisementsReceived ); - Console::WriteLine( " Neighbor Solicitations .............. Sent: {0,-10} Received: {1,-10}", stat->NeighborSolicitsSent, stat->NeighborSolicitsReceived ); - Console::WriteLine( " Membership Queries .................. Sent: {0,-10} Received: {1,-10}", stat->MembershipQueriesSent, stat->MembershipQueriesReceived ); - Console::WriteLine( " Membership Reports .................. Sent: {0,-10} Received: {1,-10}", stat->MembershipReportsSent, stat->MembershipReportsReceived ); - Console::WriteLine( " Membership Reductions ............... Sent: {0,-10} Received: {1,-10}", stat->MembershipReductionsSent, stat->MembershipReductionsReceived ); - Console::WriteLine( "" ); -} -// - -// -void ShowIPAddresses( String^ label, IPAddressCollection^ addresses ) -{ - if ( addresses->Count == 0 ) - return; - -// Console::WriteLine( "{0} {1} ", label, addresses->Item[ 0 ] ); - if ( addresses->Count > 1 ) - { - for ( int i = 1; i < addresses->Count; i++ ) - { - String^ address = addresses->ToString(); - String^ line = address->PadLeft( label->Length + address->Length + 1 ); - Console::WriteLine( "{0}", line ); - - } - } -} -// - -// -void ShowIPAddresses( IPInterfaceProperties ^ adapterProperties ) -{ - // - IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses; - if ( dnsServers != nullptr ) - { - System::Collections::IEnumerator^ myEnum = dnsServers->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddressInformation ^ dns = safe_cast(myEnum->Current); - Console::WriteLine( " DNS Servers ............................. : {0} ({1} {2})", - dns->Address, dns->IsTransient ? (String^)"Transient" : "", dns->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - } - // - - IPAddressInformationCollection ^ anyCast = adapterProperties->AnycastAddresses; - if ( anyCast != nullptr ) - { - System::Collections::IEnumerator^ myEnum1 = anyCast->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - IPAddressInformation ^ any = safe_cast(myEnum1->Current); - Console::WriteLine( " Anycast Address .......................... : {0} {1} {2}", any->Address, any->IsTransient ? (String^)"Transient" : "", any->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - - Console::WriteLine(); - } - - MulticastIPAddressInformationCollection ^ multiCast = adapterProperties->MulticastAddresses; - if ( multiCast != nullptr ) - { - System::Collections::IEnumerator^ myEnum2 = multiCast->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - IPAddressInformation ^ multi = safe_cast(myEnum2->Current); - Console::WriteLine( " Multicast Address ....................... : {0} {1} {2}", multi->Address, multi->IsTransient ? (String^)"Transient" : "", multi->IsDnsEligible ? (String^)"DNS Eligible" : "" ); - } - - Console::WriteLine(); - } - - // - UnicastIPAddressInformationCollection ^ uniCast = adapterProperties->UnicastAddresses; - if ( uniCast != nullptr ) - { - String^ lifeTimeFormat = "dddd, MMMM dd, yyyy hh:mm:ss tt"; - System::Collections::IEnumerator^ myEnum3 = uniCast->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - UnicastIPAddressInformation ^ uni = safe_cast(myEnum3->Current); - DateTime when; - Console::WriteLine( " Unicast Address ......................... : {0}", uni->Address ); - Console::WriteLine( " Prefix Origin ........................ : {0}", uni->PrefixOrigin ); - Console::WriteLine( " Suffix Origin ........................ : {0}", uni->SuffixOrigin ); - Console::WriteLine( " Duplicate Address Detection .......... : {0}", uni->DuplicateAddressDetectionState ); - - // Format the lifetimes as Sunday, February 16, 2003 11:33:44 PM - // if en-us is the current culture. - // Calculate the date and time at the end of the lifetimes. - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressValidLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Valid Life Time ...................... : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->AddressPreferredLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " Preferred life time .................. : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - when = DateTime::UtcNow + TimeSpan::FromSeconds( (double)uni->DhcpLeaseLifetime ); - when = when.ToLocalTime(); - Console::WriteLine( " DHCP Leased Life Time ................ : {0}", when.ToString( lifeTimeFormat, System::Globalization::CultureInfo::CurrentCulture ) ); - } - - Console::WriteLine(); - } - // -} -// - -// -void ShowInterfaceStatistics( NetworkInterface ^ adapter ) -{ - IPv4InterfaceStatistics ^ stats = adapter->GetIPv4Statistics(); - Console::WriteLine( "{0} Interface Statistics:", Environment::NewLine ); - Console::WriteLine( " Bytes sent ........................... : {0}", - stats->BytesSent ); - Console::WriteLine( " Bytes received ....................... : {0}", - stats->BytesReceived ); - Console::WriteLine( " Unicast Packets Sent ................. : {0}", - stats->UnicastPacketsSent ); - Console::WriteLine( " Unicast Packets Received ............. : {0}", - stats->UnicastPacketsReceived ); - Console::WriteLine( " Non Unicast Packets Sent ............. : {0}", - stats->NonUnicastPacketsSent ); - Console::WriteLine( " Non Unicast Packets Received ......... : {0}", - stats->NonUnicastPacketsReceived ); - Console::WriteLine( " Incoming Packets Discarded ........... : {0}", - stats->IncomingPacketsDiscarded ); - Console::WriteLine( " Outgoing Packets Discarded ........... : {0}", - stats->OutgoingPacketsDiscarded ); - Console::WriteLine( " Incoming Packets Errors .............. : {0}", - stats->IncomingPacketsWithErrors ); - Console::WriteLine( " Outgoing packets Errors .............. : {0}", - stats->OutgoingPacketsWithErrors ); - Console::WriteLine( " Incoming Unknown Protocol Errors ..... : {0}", - stats->IncomingUnknownProtocolPackets ); - Console::WriteLine( " Speed ................................ : {0}", - adapter->Speed ); - Console::WriteLine( " Output queue length................... : {0}", - stats->OutputQueueLength ); - Console::WriteLine(); -} -// - -// -void ShowNetworkInterfaces() -{ - IPGlobalProperties ^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( "Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( " No network interfaces found." ); - return; - } - - Console::WriteLine( " Number of interfaces .................... : {0}", nics->Length ); - System::Collections::IEnumerator^ myEnum4 = nics->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum4->Current); - IPInterfaceProperties ^ properties = adapter->GetIPProperties(); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Physical Address ........................ : {0}", - adapter->GetPhysicalAddress() ); - Console::WriteLine( " Operational status ...................... : {0}", - adapter->OperationalStatus ); - String^ versions = ""; - - // Create a display string for the supported IP versions. - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - versions = "IPv4"; - } - if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) ) - { - if ( versions->Length > 0 ) - { - versions = String::Concat( versions, " " ); - } - versions = String::Concat( versions, "IPv6" ); - } - Console::WriteLine( " IP version .............................. : {0}", - versions ); - ShowIPAddresses( properties ); - - // The following information is not useful for loopback adapters. - if ( adapter->NetworkInterfaceType == NetworkInterfaceType::Loopback ) - { - continue; - } - Console::WriteLine( " DNS suffix .............................. : {0}", - properties->DnsSuffix ); - String^ label; - - // - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - IPv4InterfaceProperties ^ ipv4 = properties->GetIPv4Properties(); - Console::WriteLine( " MTU...................................... : {0}", - ipv4->Mtu ); - if ( ipv4->UsesWins ) - { - IPAddressCollection ^ winsServers = properties->WinsServersAddresses; - if ( winsServers->Count > 0 ) - { - label = " WINS Servers ............................ :"; - ShowIPAddresses( label, winsServers ); - } - } - } - // - Console::WriteLine( " DNS enabled ............................. : {0}", - properties->IsDnsEnabled ); - Console::WriteLine( " Dynamically configured DNS .............. : {0}", - properties->IsDynamicDnsEnabled ); - Console::WriteLine( " Receive Only ............................ : {0}", - adapter->IsReceiveOnly ); - Console::WriteLine( " Multicast ............................... : {0}", - adapter->SupportsMulticast ); - ShowInterfaceStatistics( adapter ); - Console::WriteLine(); - } -} -// - - -// -void ShowInterfaceSummary() -{ - array^interfaces = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum5 = interfaces->GetEnumerator(); - while ( myEnum5->MoveNext() ) - { - NetworkInterface ^ adapter = safe_cast(myEnum5->Current); - Console::WriteLine( "Name: {0}", adapter->Name ); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( " Interface type .......................... : {0}", - adapter->NetworkInterfaceType ); - Console::WriteLine( " Operational status ...................... : {0}", adapter->OperationalStatus ); - String^ versions = ""; - - // Create a display string for the supported IP versions. - if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) ) - { - versions = "IPv4"; - } - - if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) ) - { - if ( versions->Length > 0 ) - { - versions = String::Concat( versions, " " ); - } - - versions = String::Concat( versions, "IPv6" ); - } - - Console::WriteLine( " IP version .............................. : {0}", versions ); - Console::WriteLine(); - } - - Console::WriteLine(); -} -// - -// -void ShowActiveTcpConnections() -{ - Console::WriteLine( "Active TCP Connections" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^connections = properties->GetActiveTcpConnections(); - System::Collections::IEnumerator^ myEnum6 = connections->GetEnumerator(); - while ( myEnum6->MoveNext() ) - { - TcpConnectionInformation ^ c = safe_cast(myEnum6->Current); - Console::WriteLine( "{0} <==> {1}", c->LocalEndPoint, c->RemoteEndPoint ); - } -} -// - -// -void ShowActiveTcpListeners() -{ - Console::WriteLine( "Active TCP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveTcpListeners(); - System::Collections::IEnumerator^ myEnum7 = endPoints->GetEnumerator(); - while ( myEnum7->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum7->Current); - Console::WriteLine( e ); - } -} -// - -// -void ShowActiveUdpListeners() -{ - Console::WriteLine( "Active UDP Listeners" ); - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - array^endPoints = properties->GetActiveUdpListeners(); - System::Collections::IEnumerator^ myEnum8 = endPoints->GetEnumerator(); - while ( myEnum8->MoveNext() ) - { - IPEndPoint^ e = safe_cast(myEnum8->Current); - Console::WriteLine( e ); - } -} -// - -int main() -{ - // - IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties(); - Console::WriteLine( "Computer name: {0}", properties->HostName ); - Console::WriteLine( "Domain name: {0}", properties->DomainName ); - Console::WriteLine( "Node type: {0:f}", properties->NodeType ); - Console::WriteLine( "DHCP scope: {0}", properties->DhcpScopeName ); - Console::WriteLine( "WINS proxy? {0}", properties->IsWinsProxy ); - // - - ShowActiveTcpConnections(); - ShowActiveTcpListeners(); - ShowActiveUdpListeners(); - if (Socket::SupportsIPv4) - { - ShowIcmpV4Statistics(); - } - if (Socket::OSSupportsIPv6) - { - ShowIcmpV6Statistics(); - } - ShowIPStatistics( NetworkInterfaceComponent::IPv4 ); - ShowTcpStatistics( NetworkInterfaceComponent::IPv4 ); - ShowUdpStatistics( NetworkInterfaceComponent::IPv4 ); - ShowEchoIcmpv4(properties->GetIcmpV4Statistics()); - ShowIcmpv4MessagesAndErrors(properties->GetIcmpV4Statistics()); - - if (Socket::OSSupportsIPv6) - { - ShowEchoIcmpv6(properties->GetIcmpV6Statistics()); - ShowIcmpv6MessagesAndErrors(properties->GetIcmpV6Statistics()); - } - - ShowNetworkInterfaces(); - ShowInterfaceSummary(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp deleted file mode 100644 index c3837c32960..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp +++ /dev/null @@ -1,140 +0,0 @@ - -#using - -using namespace System; -using namespace System::Net::NetworkInformation; -using namespace System::Collections; - -// -void DisplayAddressNone() -{ - PhysicalAddress^ none = PhysicalAddress::None; - Console::WriteLine( L"None: {0}", none ); - array^bytes = none->GetAddressBytes(); - System::Collections::IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( L"{0} ", b.ToString() ); - } - - Console::WriteLine(); -} - - -// -// -void ShowNetworkInterfaces() -{ - IPGlobalProperties^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - Console::WriteLine( L"Interface information for {0}.{1} ", computerProperties->HostName, computerProperties->DomainName ); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( L" No network interfaces found." ); - return; - } - - Console::WriteLine( L" Number of interfaces .................... : {0}", (nics->Length).ToString() ); - IEnumerator^ myEnum1 = nics->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - NetworkInterface^ adapter = safe_cast(myEnum1->Current); - IPInterfaceProperties^ properties = adapter->GetIPProperties(); - Console::WriteLine(); - Console::WriteLine( adapter->Description ); - Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) ); - Console::WriteLine( L" Interface type .......................... : {0}", adapter->NetworkInterfaceType ); - Console::Write( L" Physical address ........................ : " ); - PhysicalAddress^ address = adapter->GetPhysicalAddress(); - array^bytes = address->GetAddressBytes(); - for ( int i = 0; i < bytes->Length; i++ ) - { - - // Display the physical address in hexadecimal. - Console::Write( L"{0}", bytes[ i ].ToString( L"X2" ) ); - - // Insert a hyphen after each byte, unless we are at the end of the - // address. - if ( i != bytes->Length - 1 ) - { - Console::Write( L"-" ); - } - - } - Console::WriteLine(); - } -} - - -// -// -void ParseTest() -{ - PhysicalAddress^ address = PhysicalAddress::Parse( L"AC1EBA22" ); - Console::WriteLine( L"Address parsed as {0}", address->ToString() ); - PhysicalAddress^ address2 = PhysicalAddress::Parse( L"ac1eba22" ); - Console::WriteLine( L"Address2 parsed as {0}", address2->ToString() ); - bool test = address->Equals( address2 ); - Console::WriteLine( L"Equal? {0}", test ); -} - - -// -// -array^ StoreNetworkInterfaceAddresses() -{ - IPGlobalProperties^ computerProperties = IPGlobalProperties::GetIPGlobalProperties(); - array^nics = NetworkInterface::GetAllNetworkInterfaces(); - if ( nics == nullptr || nics->Length < 1 ) - { - Console::WriteLine( L" No network interfaces found." ); - return nullptr; - } - - array^ addresses = gcnew array(nics->Length); - int i = 0; - IEnumerator^ myEnum2 = nics->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - NetworkInterface^ adapter = safe_cast(myEnum2->Current); - IPInterfaceProperties^ properties = adapter->GetIPProperties(); - PhysicalAddress^ address = adapter->GetPhysicalAddress(); - array^bytes = address->GetAddressBytes(); - PhysicalAddress^ newAddress = gcnew PhysicalAddress( bytes ); - addresses[ i++ ] = newAddress; - } - - return addresses; -} - - -// -// -PhysicalAddress^ StrictParseAddress( String^ address ) -{ - PhysicalAddress^ newAddress = PhysicalAddress::Parse( address ); - if ( PhysicalAddress::None->Equals( newAddress ) ) - return nullptr; - - return newAddress; -} - - -// -int main() -{ - - DisplayAddressNone(); - ShowNetworkInterfaces(); - ParseTest(); - /* PhysicalAddress[] addresses = StoreNetworkInterfaceAddresses(); - foreach (PhysicalAddress address in addresses) - { - Console.WriteLine(address.ToString()); - } - */ - PhysicalAddress^ a = StrictParseAddress( nullptr ); - Console::WriteLine( a == nullptr ? L"null" : a->ToString() ); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp deleted file mode 100644 index 845a8d231bd..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp +++ /dev/null @@ -1,249 +0,0 @@ - - -//NCLPingSampler -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Text; -using namespace System::Threading; - -// -void SimplePing(); -void ComplexPing(); -void LocalPing(); -void ComplexLocalPing(); -void LocalPingTimeout(); -void AsyncComplexLocalPing(); -void PingCompletedCallback( Object^ sender, PingCompletedEventArgs^ e ); - -int main() -{ - -// SimplePing(); - LocalPing(); Console::WriteLine(); -// ComplexPing(); Console::WriteLine(); - ComplexLocalPing(); Console::WriteLine(); - AsyncComplexLocalPing(); -} - - -// -void SimplePing() -{ - Ping ^ pingSender = gcnew Ping; - PingReply ^ reply = pingSender->Send( "www.contoso.com" ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void ComplexPing() -{ - Ping ^ pingSender = gcnew Ping; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - - // Send the request. - PingReply ^ reply = pingSender->Send( "www.contoso.com", timeout, buffer, options ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void LocalPing() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - PingReply ^ reply = pingSender->Send( address ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void ComplexLocalPing() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - PingReply ^ reply = pingSender->Send( address, timeout, buffer, options ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void LocalPingTimeout() -{ - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - PingReply ^ reply = pingSender->Send( address, timeout, buffer); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - else - { - Console::WriteLine( reply->Status ); - } -} - - -// -// -void AsyncComplexLocalPing() -{ - - // Get an object that will block the main thread. - AutoResetEvent^ waiter = gcnew AutoResetEvent( false ); - - // Ping's the local machine. - Ping ^ pingSender = gcnew Ping; - - // When the PingCompleted event is raised, - // the PingCompletedCallback method is called. - pingSender->PingCompleted += gcnew PingCompletedEventHandler( PingCompletedCallback ); - IPAddress^ address = IPAddress::Loopback; - - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 10 seconds for a reply. - int timeout = 10000; - - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - - // Send the ping asynchronously. - // Use the waiter as the user token. - // When the callback completes, it can wake up this thread. - pingSender->SendAsync( address, timeout, buffer, options, waiter ); - - // Prevent this example application from ending. - // A real application should do something useful - // when possible. - waiter->WaitOne(); - Console::WriteLine( "Ping example completed." ); -} - - -// -// -void PingCompletedCallback( Object^ /*sender*/, PingCompletedEventArgs^ e ) -{ - - // If the operation was canceled, display a message to the user. - if ( e->Cancelled ) - { - Console::WriteLine( "Ping canceled." ); - } - - - // If an error occurred, display the exception to the user. - if ( e->Error != nullptr ) - { - Console::WriteLine( "Ping failed:" ); - Console::WriteLine( e->Error->ToString() ); - } - - PingReply ^ reply = e->Reply; - Console::WriteLine( reply->Status ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp deleted file mode 100644 index d4bf6281427..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp +++ /dev/null @@ -1,51 +0,0 @@ - - -// SampleID="NCLResponse1" -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Text; -using namespace System::IO; - -// Specify the URL to receive the request. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - HttpWebRequest^ request = dynamic_cast(WebRequest::Create(args[1])); - - // Set some reasonable limits on resources used by this request - request->MaximumAutomaticRedirections = 4; - request->MaximumResponseHeadersLength = 4; - - // Set credentials to use for this request. - request->Credentials = CredentialCache::DefaultCredentials; - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - Console::WriteLine("Content length is {0}", response->ContentLength); - Console::WriteLine("Content type is {0}", response->ContentType); - - // Get the stream associated with the response. - Stream^ receiveStream = response->GetResponseStream(); - - // Pipes the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader(receiveStream, Encoding::UTF8); - Console::WriteLine("Response stream received."); - Console::WriteLine(readStream->ReadToEnd()); - response->Close(); - readStream->Close(); -} - -/* -The output from this example will vary depending on the value passed into Main -but will be similar to the following: - -Content length is 1542 -Content type is text/html; charset=utf-8 -Response stream received. - -... - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp deleted file mode 100644 index d9632b38b2c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::IO; -using namespace System::Threading; - -namespace SystemNetExamples -{ - public ref class ServicePointExample - { - public: - - // Pass in the name of the Web page to retrieve. - static void PrintResponse(String^ page) - { - - // Create the request. - HttpWebRequest^ request; - Uri^ uri; - - - - try - { - uri = gcnew Uri(page); - } - catch (UriFormatException^ ex) - { - Console::WriteLine(ex->Message); - } - - request = (HttpWebRequest^) WebRequest::Create(uri); - - // Get the service point that handles the request's - // socket connection. - ServicePoint^ point = request->ServicePoint; - - // Set the receive buffer size on the underlying socket. - point->ReceiveBufferSize = 2048; - - // Set the connection lease timeout to infinite. - point->ConnectionLeaseTimeout = Timeout::Infinite; - - // Send the request. - HttpWebResponse^ response = - (HttpWebResponse^) request->GetResponse(); - Stream^ responseStream = response->GetResponseStream(); - StreamReader^ streamReader = - gcnew StreamReader(responseStream); - try - { - // Display the response. - Console::WriteLine(streamReader->ReadToEnd()); - responseStream->Close(); - response->Close(); - } - finally - { - streamReader->Close(); - } - } - }; -} - -// - -using namespace SystemNetExamples; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ page; - - if ((args == nullptr)||(args->Length < 2)||(args[1]->Length == 0)) - { - page = "http://www.contoso.com/default.html"; - } - else - { - page = args[1]; - } - ServicePointExample::PrintResponse(page); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp deleted file mode 100644 index 0c201db6c1c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp +++ /dev/null @@ -1,274 +0,0 @@ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Cache; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections::Specialized; -using namespace System::Collections; - -public ref class CacheExample -{ -public: - - // - static WebResponse^ GetResponseUsingDefaultCache( Uri^ uri ) - { - // Set a cache policy level for the "http:" scheme. - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default ); - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - // The following method demonstrates overriding the - // caching policy for a request. - static WebResponse^ GetResponseNoCache( Uri^ uri ) - { - // Set a default policy level for the "http:" and "https" schemes. - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::Default ); - HttpWebRequest::DefaultCachePolicy = policy; - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - - // Define a cache policy for this request only. - HttpRequestCachePolicy^ noCachePolicy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::NoCacheNoStore ); - request->CachePolicy = noCachePolicy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"IsFromCache? {0}", response->IsFromCache ); - - return response; - } - // - - // - static HttpRequestCachePolicy^ CreateLastSyncPolicy( DateTime when ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( when ); - Console::WriteLine( L"When: {0}", when ); - Console::WriteLine( policy->CacheSyncDate ); - return policy; - } - // - - // - static void DisplayPolicyDetails( HttpRequestCachePolicy^ policy ) - { - Console::WriteLine( L"Synchronize date: {0}", policy->CacheSyncDate ); - Console::WriteLine( L"Max age: {0}", policy->MaxAge ); - Console::WriteLine( L"Max stale: {0}", policy->MaxStale ); - Console::WriteLine( L"Min fresh: {0}", policy->MinFresh ); - } - // - - // - static HttpRequestCachePolicy^ CreateMinFreshPolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MinFresh,span ); - Console::WriteLine( L"Minimum freshness {0}", policy->MinFresh ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateMaxStalePolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxStale,span ); - Console::WriteLine( L"Max stale is {0}", policy->MaxStale ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateMaxAgePolicy( TimeSpan span ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAge,span ); - Console::WriteLine( L"Max age is {0}", policy->MaxAge ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateDefaultPolicy() - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy; - Console::WriteLine( policy ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateFreshAndAgePolicy( TimeSpan freshMinimum, TimeSpan ageMaximum ) - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAgeAndMinFresh, - ageMaximum, freshMinimum ); - Console::WriteLine( policy ); - return policy; - } - // - - // - static HttpRequestCachePolicy^ CreateFreshAndAgePolicy2( TimeSpan freshMinimum, TimeSpan ageMaximum, DateTime when ) - { - HttpRequestCachePolicy^ policy = - gcnew HttpRequestCachePolicy( HttpCacheAgeControl::MaxAgeAndMinFresh, - ageMaximum, freshMinimum, when ); - Console::WriteLine( policy ); - return policy; - - // For the following invocation: CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0), ); - // the output is: - // Level:Automatic AgeControl:MinFreshAndMaxAge MinFresh:18000 MaxAge:36000 - } - // - - // - static WebResponse^ GetResponseUsingCacheDefault( Uri^ uri ) - { - // Set the default cache policy level for the "http:" scheme. - RequestCachePolicy^ policy = gcnew RequestCachePolicy; - - // Create the request. - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy level is {0}.", policy->Level ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static HttpRequestCachePolicy^ CreateCacheIfAvailablePolicy() - { - HttpRequestCachePolicy^ policy = gcnew HttpRequestCachePolicy( HttpRequestCacheLevel::CacheIfAvailable ); - Console::WriteLine( policy ); - return policy; - } - // - - // - static WebResponse^ GetResponseFromCache( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::CacheOnly ); - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy level is {0}.", policy->Level ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static WebResponse^ GetResponseFromServer( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::NoCacheNoStore ); - WebRequest^ request = WebRequest::Create( uri ); - request->CachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy is {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - // - static WebResponse^ GetResponseFromServer2( Uri^ uri ) - { - RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::NoCacheNoStore ); - WebRequest^ request = WebRequest::Create( uri ); - WebRequest::DefaultCachePolicy = policy; - WebResponse^ response = request->GetResponse(); - Console::WriteLine( L"Policy is {0}.", policy ); - Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache ); - return response; - } - // - - void TestSimpleCache() - { - /* WebResponse response = GetResponseUsingDefaultCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - response = GetResponseNoCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - - DisplayPolicyDetails(CreateLastSyncPolicy(DateTime.Now)); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateMinFreshPolicy(new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateMaxStalePolicy(new TimeSpan(1,10,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - DisplayPolicyDetails(CreateMaxAgePolicy(new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateDefaultPolicy()); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0))); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateFreshAndAgePolicy2(new TimeSpan(5,0,0), new TimeSpan(10,0,0), DateTime.Now)); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - response = GetResponseUsingCacheDefault (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - - DisplayPolicyDetails(CreateCacheIfAvailablePolicy()); - - response = GetResponseFromCache (new Uri("http://www.example.com")); - DisplayResponseStream (response); - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - response = GetResponseFromServer (new Uri("http://www.example.com")); - DisplayResponseStream (response); - - Console.WriteLine("hit enter for next test..."); Console.ReadLine(); - */ - WebResponse^ response = GetResponseFromServer2( gcnew Uri( L"http://www.example.com" ) ); - DisplayResponseStream( response ); - Console::WriteLine( L"done." ); - } - - static void DisplayResponseStream( WebResponse^ response ) - { - Stream^ stream = response->GetResponseStream(); - while ( true ) - { - array^buffer = gcnew array(1024); - int read = stream->Read( buffer, 0, buffer->Length ); - if ( read == 0 ) - { - stream->Close(); - break; - } - else - { - Console::Write( Encoding::UTF8->GetString( buffer ) ); - } - } - - stream->Close(); - } - -}; - -void main() -{ - CacheExample^ ce = gcnew CacheExample; - ce->TestSimpleCache(); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp deleted file mode 100644 index cc3ba9554a1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp +++ /dev/null @@ -1,713 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -/***************************** -commented out contents of snippets 1,2,8 becuase this is not legal cpp. -the use of jagged arrays is not supprted and these throw a compiler error. - -*******************************/ -// State object for reading client data asynchronously -private ref class StateObject -{ -public private: - - // Client socket. - Socket^ workSocket; - - // Size of receive buffer. - literal int BufferSize = 1024; - - // Receive buffer. - array^buffer; - - // Received data string. - StringBuilder^ sb; - -public: - StateObject() - { - workSocket = nullptr; - buffer = gcnew array(BufferSize); - sb = gcnew StringBuilder; - } - -}; - -public ref class Test -{ -public: - - // Incoming data from client. - static String^ data = nullptr; - -private: - - // ManualResetEvent instances signal completion. - static ManualResetEvent^ connectDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ sendDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ receiveDone = gcnew ManualResetEvent( false ); - static ManualResetEvent^ disconnectDone = gcnew ManualResetEvent( false ); - - // The response from the remote device. - static String^ response = String::Empty; - -public: - - // Thread signal. - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - Console::WriteLine( "{0}", args ); - if ( args[ 1 ]->Equals( "as" ) ) - { - - // Start the asynchronous server. - Console::WriteLine( "the asychronous server" ); - AsynchronousServer(); - } - else - if ( args[ 1 ]->Equals( "ac" ) ) - { - - // Start the asynchronous client. - Console::WriteLine( "the asynchronous client" ); - AsynchronousClient(); - } - else - if ( args[ 1 ]->Equals( "ss" ) ) - { - - // Start the synchronous server. - Console::WriteLine( "the sychronous server" ); - SynchronousServer(); - } - else - if ( args[ 1 ]->Equals( "sc" ) ) - { - - // Start the synchronous client. - Console::WriteLine( "the synchronous client" ); - SynchronousClient(); - } - else - { - Console::WriteLine( "default" ); - } - } - - static void AsynchronousServer() - { - - // This server waits for a connection and then uses asychronous operations to - // accept the connection, get data from the connected client, - // echo that data back to the connected client. - // It then disconnects from the client and waits for another client. - Listen(); - - // ListenWithSocket(); - } - - static void Listen() - { - // This server waits for a connection and then uses asynchronous operations to - // accept the connection with initial data sent from the client. - // Establish the local endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ localEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind the socket to the local endpoint, and listen for incoming connections. - listener->Bind( localEndPoint ); - listener->Listen( 100 ); - for ( ; ; ) - { - - // Set the event to nonsignaled state. - allDone->Reset(); - - // Start an asynchronous socket to listen for connections and receive data from the client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection and receive the first 10 bytes of data. - int receivedDataSize = 10; - listener->BeginAccept( receivedDataSize, gcnew AsyncCallback( AcceptReceiveCallback ), listener ); - - // Wait until a connection is made and processed before continuing. - allDone->WaitOne(); - - } - } - - static void AcceptReceiveCallback( IAsyncResult^ ar ) - { - // Get the socket that handles the client request. - Socket^ listener = dynamic_cast(ar->AsyncState); - - // End the operation and display the received data on the console. - array^Buffer; - int bytesTransferred; - Socket^ handler = listener->EndAccept( Buffer, bytesTransferred, ar ); - String^ stringTransferred = Encoding::ASCII->GetString( Buffer, 0, bytesTransferred ); - Console::WriteLine( stringTransferred ); - Console::WriteLine( "Size of data transferred is {0}", bytesTransferred ); - - // Create the state object for the asynchronous receive. - StateObject^ state = gcnew StateObject; - state->workSocket = handler; - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - static void ListenWithSocket() - { - // This server waits for a connection and then uses asynchronous operations to - // accept the connection with initial data sent from the client. - // Establish the local endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ localEndPoint = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind the socket to the local endpoint, and listen for incoming connections. - listener->Bind( localEndPoint ); - listener->Listen( 100 ); - for ( ; ; ) - { - // Set the event to nonsignaled state. - allDone->Reset(); - - // Start an asynchronous socket to listen for connections and receive data from the client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection and receive the first 10 bytes of data. - // BeginAccept() creates the accepted socket. - int receivedDataSize = 10; - listener->BeginAccept( nullptr, receivedDataSize, gcnew AsyncCallback( AcceptReceiveDataCallback ), listener ); - - // Wait until a connection is made and processed before continuing. - allDone->WaitOne(); - } - } - - static void AcceptReceiveDataCallback( IAsyncResult^ ar ) - { - // Get the socket that handles the client request. - Socket^ listener = dynamic_cast(ar->AsyncState); - - // End the operation and display the received data on the console. - array^Buffer; - int bytesTransferred; - Socket^ handler = listener->EndAccept( Buffer, bytesTransferred, ar ); - String^ stringTransferred = Encoding::ASCII->GetString( Buffer, 0, bytesTransferred ); - Console::WriteLine( stringTransferred ); - Console::WriteLine( "Size of data transferred is {0}", bytesTransferred ); - - // Create the state object for the asynchronous receive. - StateObject^ state = gcnew StateObject; - state->workSocket = handler; - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - - static void ReadCallback( IAsyncResult^ ar ) - { - String^ content = String::Empty; - - // Retrieve the state object and the handler socket - // from the asynchronous state object. - StateObject^ state = dynamic_cast(ar->AsyncState); - Socket^ handler = state->workSocket; - - // Read data from the client socket. - int bytesRead = handler->EndReceive( ar ); - if ( bytesRead > 0 ) - { - // There might be more data, so store the data received so far. - state->sb->Append( Encoding::ASCII->GetString( state->buffer, 0, bytesRead ) ); - - // Check for end-of-file tag. If it is not there, read - // more data. - content = state->sb->ToString(); - if ( content->IndexOf( "" ) > -1 ) - { - // All the data has been read from the - // client. Display it on the console. - Console::WriteLine( "Read {0} bytes from socket. Data : {1}", content->Length, content ); - - // Echo the data back to the client. - Send( handler, content ); - } - else - { - // Not all data received. Get more. - handler->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReadCallback ), state ); - } - } - } - - -private: - static void Send( Socket^ handler, String^ data ) - { - // Convert the string data to byte data using ASCII encoding. - array^byteData = Encoding::ASCII->GetBytes( data ); - - // Begin sending the data to the remote device. - handler->BeginSend( byteData, 0, byteData->Length, static_cast(0), gcnew AsyncCallback( SendCallback ), handler ); - } - - static void SendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ handler = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - int bytesSent = handler->EndSend( ar ); - Console::WriteLine( "Sent {0} bytes to client.", bytesSent ); - handler->Shutdown( SocketShutdown::Both ); - handler->Close(); - - // Signal the main thread to continue. - allDone->Set(); - } - -public: - static void AsynchronousClient() - { - // The following methods set up a socket and demonstrate the use of a new Sockets method. - // Send multiple buffers to remote device. - // AsynchronousSendBuffers(); - // Send a file to the remote host. - // AsynchronousFileSend(); - // Send a file with pre and post buffers. - // AsynchronousFileSendWithBuffers(); - // Show use of Begin/EndDisconnect - ClientDisconnect(); - } - - -private: - static void ClientSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - int bytesSent = client->EndSend( ar ); - - // Write to the console the number of bytes sent. - Console::WriteLine( "Sent {0} bytes to server.", bytesSent ); - - // Signal that all bytes have been sent. - sendDone->Set(); - } - - -public: - - static void AsynchronousFileSend() - { - // Send a file to a remote device. - // Establish the remote endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // There is a text file test.txt in the root directory. - String^ fileName = "C:\\test.txt"; - - // Send file fileName to the remote device. - Console::WriteLine( fileName ); - client->BeginSendFile( fileName, gcnew AsyncCallback( FileSendCallback ), client ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - -private: - static void FileSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - client->EndSendFile( ar ); - sendDone->Set(); - } - -public: - static void AsynchronousFileSendWithBuffers() - { - // Send a file asynchronously to the remote device. Send a buffer before the file and a buffer afterwards. - // Establish the remote endpoint for the socket. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // Send a file fileName to the remote device with preBuffer and postBuffer data. - // Create the preBuffer data. - String^ string1 = String::Format( "This is text data that precedes the file.{0}", Environment::NewLine ); - array^preBuf = Encoding::ASCII->GetBytes( string1 ); - - // Create the postBuffer data. - String^ string2 = String::Format( "This is text data that will follow the file.{0}", Environment::NewLine ); - array^postBuf = Encoding::ASCII->GetBytes( string2 ); - - // There is a file test.txt in the root directory. - String^ fileName = "C:\\test.txt"; - - //Send file fileName with buffers and default flags to the remote device. - Console::WriteLine( fileName ); - client->BeginSendFile( fileName, preBuf, postBuf, static_cast(0), gcnew AsyncCallback( AsynchronousFileSendCallback ), client ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - - -private: - static void AsynchronousFileSendCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete sending the data to the remote device. - client->EndSendFile( ar ); - sendDone->Set(); - } - - static void ConnectCallback( IAsyncResult^ ar ) - { - // Retrieve the socket from the state object. - Socket^ client = dynamic_cast(ar->AsyncState); - - // Complete the connection. - client->EndConnect( ar ); - Console::WriteLine( "Socket connected to {0}", client->RemoteEndPoint ); - - // Signal that the connection has been made. - connectDone->Set(); - } - - static void Receive( Socket^ client ) - { - // Create the state object. - StateObject^ state = gcnew StateObject; - state->workSocket = client; - - // Begin receiving the data from the remote device. - client->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReceiveCallback ), state ); - } - - static void ReceiveCallback( IAsyncResult^ ar ) - { - // Retrieve the state object and the client socket - // from the asynchronous state object. - StateObject^ state = dynamic_cast(ar->AsyncState); - Socket^ client = state->workSocket; - - // Read data from the remote device. - int bytesRead = client->EndReceive( ar ); - if ( bytesRead > 0 ) - { - // There might be more data, so store the data received so far. - state->sb->Append( Encoding::ASCII->GetString( state->buffer, 0, bytesRead ) ); - - // Get the rest of the data. - client->BeginReceive( state->buffer, 0, StateObject::BufferSize, static_cast(0), gcnew AsyncCallback( ReceiveCallback ), state ); - } - else - { - // All the data has arrived; put it in response. - if ( state->sb->Length > 1 ) - { - response = state->sb->ToString(); - } - - // Signal that all bytes have been received. - receiveDone->Set(); - } - } - - -public: - static void ClientDisconnect() - { - // Establish the remote endpoint for the socket. - // For this example use local computer. - IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ]; - IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 ); - - // Create a TCP/IP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the remote endpoint. - client->BeginConnect( remoteEP, gcnew AsyncCallback( ConnectCallback ), client ); - - // Wait for connect. - connectDone->WaitOne(); - - // Send some data to the remote device. - String^ data = "This is a string of data "; - array^buffer = Encoding::ASCII->GetBytes( data ); - client->BeginSend( buffer, 0, buffer->Length, static_cast(0), gcnew AsyncCallback( ClientSendCallback ), client ); - - // Wait for send done. - sendDone->WaitOne(); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->BeginDisconnect( true, gcnew AsyncCallback( DisconnectCallback ), client ); - - // Wait for the disconnect to complete. - disconnectDone->WaitOne(); - if ( client->Connected ) - Console::WriteLine( "We're still connected" ); - else - Console::WriteLine( "We're disconnected" ); - } - -private: - static void DisconnectCallback( IAsyncResult^ ar ) - { - // Complete the disconnect request. - Socket^ client = dynamic_cast(ar->AsyncState); - client->EndDisconnect( ar ); - - // Signal that the disconnect is complete. - disconnectDone->Set(); - } - -public: - - static void SynchronousServer() - { - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ listener = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Bind to the local endpoint and listen to the incoming sockets. - listener->Bind( ipEndPoint ); - listener->Listen( 10 ); - for ( ; ; ) - { - Console::WriteLine( "Waiting for a connection..." ); - Socket^ handler = listener->Accept(); - String^ data = nullptr; - - // A client is connecting. - for ( ; ; ) - { - array^bytes = gcnew array(1024); - int bytesReceived = handler->Receive( bytes ); - data = String::Concat( data, Encoding::ASCII->GetString( bytes, 0, bytesReceived ) ); - if ( data->IndexOf( "" ) > -1 ) - { - break; - } - } - - // All the data has been read from the client. - // Display it on the console. - Console::WriteLine( "Read {0} bytes from socket. Data : {1}", data->Length, data ); - - // Echo the data back to the client. - //Send(handler, content); - handler->Send( Encoding::ASCII->GetBytes( data ) ); - handler->Shutdown( SocketShutdown::Both ); - handler->Close(); - } - } - - static void SynchronousClient() - { - // The following methods set up a socket and demonstrate the use of a new Sockets method. - // Set the socket options - // SetSocketOptions(); - // Send multiple buffers to remote device. - // SendMultiBuffers(); - // Send multiple buffers with socket flags - // SendMultiBuffersWithFlags(); - // Send a file to the remote host. - // FileSend(); - // Send a file with pre and post buffers - // FileSendWithBuffers(); - // Show synchronous disconnect - SynchronousDisconnect(); - } - -private: - static void SetSocketOptions() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // Set option that allows socket to close gracefully without lingering. - client->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::DontLinger, true ); - - // Set option that allows socket to receive out-of-band information in the data stream. - client->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::OutOfBandInline, true ); - - // - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - } - - static void FileSend() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // There is a text file test.txt located in the root directory. - String^ fileName = "C:\\test.txt"; - - // Send file fileName to remote device - Console::WriteLine( "Sending {0} to the host.", fileName ); - client->SendFile( fileName ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - // - } - - static void FileSendWithBuffers() - { - // - // Establish the local endpoint for the socket. - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - - // Create a TCP socket. - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote endpoint. - client->Connect( ipEndPoint ); - - // Send file fileName to the remote host with preBuffer and postBuffer data. - // There is a text file test.txt located in the root directory. - String^ fileName = "C:\\test.txt"; - - // Create the preBuffer data. - String^ string1 = String::Format( "This is text data that precedes the file.{0}", Environment::NewLine ); - array^preBuf = Encoding::ASCII->GetBytes( string1 ); - - // Create the postBuffer data. - String^ string2 = String::Format( "This is text data that will follow the file.{0}", Environment::NewLine ); - array^postBuf = Encoding::ASCII->GetBytes( string2 ); - - //Send file fileName with buffers and default flags to the remote device. - Console::WriteLine( "Sending {0} with buffers to the host.{1}", fileName, Environment::NewLine ); - client->SendFile( fileName, preBuf, postBuf, TransmitFileOptions::UseDefaultWorkerThread ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Close(); - // - } - -public: - static void SynchronousDisconnect() - { - // - IPHostEntry^ ipHost = Dns::GetHostEntry( Dns::GetHostName() ); - IPAddress^ ipAddr = ipHost->AddressList[ 0 ]; - IPEndPoint^ ipEndPoint = gcnew IPEndPoint( ipAddr,11000 ); - Socket^ client = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // Connect the socket to the remote end point. - client->Connect( ipEndPoint ); - - // Send some data to the remote device. - String^ data = "This is a string of data "; - array^buffer = Encoding::ASCII->GetBytes( data ); - int bytesTransferred = client->Send( buffer ); - - // Write to the console the number of bytes transferred. - Console::WriteLine( "{0} bytes were sent.\n", bytesTransferred ); - - // Release the socket. - client->Shutdown( SocketShutdown::Both ); - client->Disconnect( true ); - if ( client->Connected ) - Console::WriteLine( "We're still connnected" ); - else - Console::WriteLine( "We're disconnected" ); - // - } -}; - -int main() -{ - Test::Main(); -} - -/* -The output from this example will vary depending on the value passed into Main -but will be similar to the following: - -Content length is 1542 -Content type is text/html; charset=utf-8 -Response stream received. - -... - - -*/ diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp deleted file mode 100644 index 41bffbe3ab7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -// -// FIONREAD is also available as the "Available" property. -const int FIONREAD = 0x4004667F; - -void DisplayPendingByteCount( Socket^ s ) -{ - array^ outValue = BitConverter::GetBytes( 0 ); - - // Check how many bytes have been received. - s->IOControl( FIONREAD, nullptr, outValue ); - - UInt32 bytesAvailable = BitConverter::ToUInt32( outValue, 0 ); - Console::WriteLine( "server has {0} bytes pending. Available property says {1}.", - bytesAvailable, s->Available ); - - return; -} -// - -int main() -{ - IPHostEntry^ localHost = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( localHost->AddressList[ 0 ], 11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - s->Bind( endPoint ); - - s->Listen( 1 ); - Console::WriteLine( "Waiting to receive messages from client..." ); - Socket^ client = s->Accept(); - - // Creates a byte buffer to receive the message. - array^ buffer = gcnew array(256); - String^ message; - - for ( ; ; ) - { - Thread::Sleep( 10000 ); - DisplayPendingByteCount( client ); - client->Receive( buffer ); - message = Encoding::UTF8->GetString( buffer ); - - // Displays the information received to the screen - Console::WriteLine( " Server received the following message : {0}", - message ); - - // Look for "" to end session. - if ( message->IndexOf( "" ) != -1 ) - { - break; - } - } - client->Close(); - s->Close(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp deleted file mode 100644 index b3fabcf3081..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -// -void DisplayPendingByteCount( Socket^ s ) -{ - array^ outValue = BitConverter::GetBytes( 0 ); - - // Check how many bytes have been received. - s->IOControl( IOControlCode::DataToRead, nullptr, outValue ); - - UInt32 bytesAvailable = BitConverter::ToUInt32( outValue, 0 ); - Console::Write( "server has {0} bytes pending,", - bytesAvailable ); - Console::WriteLine( "Available property says {1}.", - s->Available ); - return; -} -// - -int main() -{ - IPHostEntry^ localHost = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( - localHost->AddressList[ 0 ],11000 ); - - // For the purposes of this example, we will send and - // receive on the same machine. - // - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, - SocketType::Stream, - ProtocolType::Tcp ); - - s->Bind( endPoint ); - - s->Listen( 1 ); - Console::WriteLine( - "Waiting to receive messages from client.." ); - Socket^ client = s->Accept(); - - // Creates a byte buffer to receive the message. - array^ buffer = gcnew array(256); - String^ message; - - for ( ; ; ) - { - Thread::Sleep( 10000 ); - DisplayPendingByteCount( client ); - client->Receive( buffer ); - message = Encoding::UTF8->GetString( buffer ); - - // Displays the information received to the screen - Console::WriteLine( - " Server received the following message: {0}", - message ); - - // Look for "" to end session. - if ( message->IndexOf( "" ) != -1 ) - { - break; - } - } - client->Close(); - s->Close(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp deleted file mode 100644 index 3a204ecc032..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; -int main() -{ - - // Create a client that will connect to a - // server listening on the contoso1 computer - // at port 11000. - TcpClient^ tcpClient = gcnew TcpClient; - tcpClient->Connect( "contosoServer", 11000 ); - - // Get the stream used to read the message sent by the server. - NetworkStream^ networkStream = tcpClient->GetStream(); - - // Set a 10 millisecond timeout for reading. - networkStream->ReadTimeout = 10; - - // Read the server message into a byte buffer. - array^bytes = gcnew array(1024); - networkStream->Read( bytes, 0, 1024 ); - - //Convert the server's message into a string and display it. - String^ data = Encoding::UTF8->GetString( bytes ); - Console::WriteLine( "Server sent message: {0}", data ); - networkStream->Close(); - tcpClient->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp deleted file mode 100644 index bbfd7a0afd9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; - -// -WebProxy^ CreateProxy() -{ - return gcnew WebProxy; -} -// - -// -WebProxy^ CreateProxyWithExampleAddress() -{ - return gcnew WebProxy( gcnew Uri( "http://contoso" ) ); -} -// - -// -WebProxy^ CreateProxyWithExampleAddress( bool bypassLocal ) -{ - return gcnew WebProxy( gcnew Uri( "http://contoso" ), bypassLocal ); -} -// - -// -WebProxy^ CreateProxyWithBypassList( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( gcnew Uri( "http://contoso" ), - bypassLocal, - bypassList ); -} -// - -// -WebProxy^ CreateProxyWithHost() -{ - return gcnew WebProxy( "http://contoso" ); -} -// - -// -WebProxy^ CreateProxyWithHostAndPort() -{ - return gcnew WebProxy( "contoso",80 ); -} -// - -// -WebProxy^ CreateProxyWithHostAddress( bool bypassLocal ) -{ - WebProxy^ proxy = gcnew WebProxy( "http://contoso",bypassLocal ); - Console::WriteLine( "Bypass proxy for local URIs?: {0}", - proxy->BypassProxyOnLocal ); - return proxy; -} -// - -// -WebProxy^ CreateProxyWithHostAndBypassList( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList ); -} -// - -// -WebProxy^ CreateProxyWithCredentials( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList, - CredentialCache::DefaultCredentials ); -} -// - -// -void DisplayDefaultProxy() -{ - WebProxy^ proxy = WebProxy::GetDefaultProxy(); - - Console::WriteLine( "Address: {0}", proxy->Address ); - - Console::WriteLine( "Bypass on local: {0}", - proxy->BypassProxyOnLocal ); - int count = proxy->BypassList->Length; - if ( count == 0 ) - { - Console::WriteLine( "The bypass list is empty." ); - return; - } - array^ bypass = proxy->BypassList; - Console::WriteLine( "The bypass list contents:" ); - - for ( int i = 0; i < count; i++ ) - { - Console::WriteLine( bypass[ i ] ); - } -} -// - -// -void CheckDefaultProxyForRequest( Uri^ resource ) -{ - WebProxy^ proxy = (WebProxy^)( WebProxy::GetDefaultProxy() ); - - // See what proxy is used for resource. - Uri^ resourceProxy = proxy->GetProxy( resource ); - - // Test to see whether a proxy was selected. - if ( resourceProxy == resource ) - { - Console::WriteLine( "No proxy for {0}", resource ); - } - else - { - Console::WriteLine( "Proxy for {0} is {1}", resource, - resourceProxy ); - } -} -// - -// -WebProxy^ CreateProxyAndCheckBypass( bool bypassLocal ) -{ - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - WebProxy^ proxy = gcnew WebProxy( "http://contoso", - bypassLocal, - bypassList ); - - // Test the bypass list. - if ( !proxy->IsBypassed( gcnew Uri( "http://www.Contoso.com" ) ) ) - { - Console::WriteLine( "Bypass not working!" ); - return nullptr; - } - else - { - Console::WriteLine( "Bypass is working." ); - return proxy; - } -} -// - -// -WebProxy^ CreateProxyWithCredentials2( bool bypassLocal ) -{ - - // Do not use the proxy server for Contoso.com URIs. - array^ bypassList = {";*.Contoso.com"}; - return gcnew WebProxy( gcnew Uri( "http://contoso" ), - bypassLocal, - bypassList, - CredentialCache::DefaultCredentials ); -} -// - -int main() -{ - Uri^ resource = gcnew Uri( "http://www.example.com" ); - - /* - CreateProxy(); - CreateProxyWithExampleAddress(); - CreateProxyWithExampleAddress(true); - CreateProxyWithBypassList(true); - CreateProxyWithHost(); - CreateProxyWithHostAndPort(); - CreateProxyWithHostAddress(true); - CreateProxyWithHostAndBypassList(true); - CreateProxyWithCredentials(true); - - DisplayDefaultProxy(); - */ - // CreateProxyAndCheckBypass(false); - CreateProxyWithCredentials2( false ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp b/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp deleted file mode 100644 index 51c732b4005..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; -int main() -{ - - // - // Create a request for the URL. - WebRequest^ request = WebRequest::Create( "http://www.contoso.com/default.html" ); - - // If required by the server, set the credentials. - request->Credentials = CredentialCache::DefaultCredentials; - - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - // - // Display the status. - Console::WriteLine( response->StatusDescription ); - - // Get the stream containing content returned by the server. - Stream^ dataStream = response->GetResponseStream(); - - // Open the stream using a StreamReader for easy access. - StreamReader^ reader = gcnew StreamReader( dataStream ); - - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - - // Display the content. - Console::WriteLine( responseFromServer ); - - // Cleanup the streams and the response. - reader->Close(); - dataStream->Close(); - response->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp deleted file mode 100644 index bdb99bf4675..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//The following sample initializes a CredentialCache with multiple security credentials -//and later uses NTLM credentials with SmtpClient - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; - -void main() -{ -// - SmtpClient^ client = gcnew SmtpClient("ContosoMail", 45); - MailAddress^ from = gcnew MailAddress("sender@SenderMailServerName.com", "Sender Name"); - MailAddress^ to = gcnew MailAddress("recepient@RecepientMailServerName.com", "Recepient Name"); - MailMessage^ message = gcnew MailMessage(from, to); - - message->Body = "This is a test email message sent by an application. "; - message->Subject = "Test Email using Credentials"; - - NetworkCredential^ myCreds = gcnew NetworkCredential("username", "password", "domain"); - CredentialCache^ myCredentialCache = gcnew CredentialCache(); - try - { - myCredentialCache->Add("ContoscoMail", 35, "Basic", myCreds); - myCredentialCache->Add("ContoscoMail", 45, "NTLM", myCreds); - - client->Credentials = myCredentialCache->GetCredential("ContosoMail", 45, "NTLM"); - client->Send(message); - Console::WriteLine("Goodbye."); - } - catch(Exception^ e) - { - Console::WriteLine("Exception is raised. "); - Console::WriteLine("Message: {0} ",e->Message); - } -// - -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp b/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp deleted file mode 100644 index af770e04406..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//NclMailASync - -// -#using -using namespace System; -using namespace System::Net; -using namespace System::Net::Mail; -using namespace System::Net::Mime; -using namespace System::Threading; -using namespace System::ComponentModel; - -static bool mailSent; - -static void SendCompletedCallback(Object^ sender, AsyncCompletedEventArgs^ e) -{ - // Get the unique identifier for this asynchronous - // operation. - String^ token = (String^) e->UserState; - - if (e->Cancelled) - { - Console::WriteLine("[{0}] Send canceled.", token); - } - if (e->Error != nullptr) - { - Console::WriteLine("[{0}] {1}", token, - e->Error->ToString()); - } else - { - Console::WriteLine("Message sent."); - } - mailSent = true; -} - -int main(array^ args) -{ - if (args->Length > 1) - { - // Command-line argument must be the SMTP host. - SmtpClient^ client = gcnew SmtpClient(args[1]); - // Specify the email sender. - // - // Create a mailing address that includes a UTF8 - // character in the display name. - MailAddress^ from = gcnew MailAddress("jane@contoso.com", - "Jane " + (wchar_t)0xD8 + " Clayton", - System::Text::Encoding::UTF8); - // - // Set destinations for the email message. - MailAddress^ to = gcnew MailAddress("ben@contoso.com"); - // Specify the message content. - // - MailMessage^ message = gcnew MailMessage(from, to); - message->Body = "This is a test email message sent" + - " by an application. "; - // Include some non-ASCII characters in body and - // subject. - String^ someArrows = gcnew String(gcnew array{L'\u2190', - L'\u2191', L'\u2192', L'\u2193'}); - message->Body += Environment::NewLine + someArrows; - message->BodyEncoding = System::Text::Encoding::UTF8; - message->Subject = "test message 1" + someArrows; - message->SubjectEncoding = System::Text::Encoding::UTF8; - // - // Set the method that is called back when the send - // operation ends. - client->SendCompleted += gcnew - SendCompletedEventHandler(SendCompletedCallback); - // The userState can be any object that allows your - // callback method to identify this send operation. - // For this example, the userToken is a string constant. - String^ userState = "test message1"; - client->SendAsync(message, userState); - Console::WriteLine("Sending message... press c to" + - " cancel mail. Press any other key to exit."); - String^ answer = Console::ReadLine(); - // If the user canceled the send, and mail hasn't been - // sent yet,then cancel the pending operation. - if (answer->ToLower()->StartsWith("c") && !mailSent) - { - client->SendAsyncCancel(); - } - // Clean up. - delete message; - delete client; - client = nullptr; - Console::WriteLine("Goodbye."); - } - else - { - Console::WriteLine("Please give SMTP server name!"); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp b/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp deleted file mode 100644 index ee93819179c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -void AddressChangedCallback( Object^ /*sender*/, EventArgs^ /*e*/ ) -{ - array^adapters = NetworkInterface::GetAllNetworkInterfaces(); - System::Collections::IEnumerator^ myEnum = adapters->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - NetworkInterface^ n = safe_cast(myEnum->Current); - Console::WriteLine( " {0} is {1}", n->Name, n->OperationalStatus ); - } -} - -int main() -{ - NetworkChange::NetworkAddressChanged += gcnew NetworkAddressChangedEventHandler( AddressChangedCallback ); - Console::WriteLine( "Listening for address changes. Press any key to exit." ); - Console::ReadLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp b/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp deleted file mode 100644 index 813df811c21..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -//NCLPingAsync -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::ComponentModel; -using namespace System::Threading; -void PingCompletedCallback( Object^ sender, PingCompletedEventArgs^ e ); -void DisplayReply( PingReply^ reply ); -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - throw gcnew ArgumentException( "Ping needs a host or IP Address." ); - - String^ who = args[ 1 ]; - AutoResetEvent^ waiter = gcnew AutoResetEvent( false ); - - // - Ping ^ pingSender = gcnew Ping; - - // When the PingCompleted event is raised, - // the PingCompletedCallback method is called. - pingSender->PingCompleted += gcnew PingCompletedEventHandler( PingCompletedCallback ); - - // - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - - // Wait 12 seconds for a reply. - int timeout = 12000; - - // - // Set options for transmission: - // The data can go through 64 gateways or routers - // before it is destroyed, and the data packet - // cannot be fragmented. - PingOptions ^ options = gcnew PingOptions( 64,true ); - Console::WriteLine( "Time to live: {0}", options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", options->DontFragment ); - - // - // Send the ping asynchronously. - // Use the waiter as the user token. - // When the callback completes, it can wake up this thread. - pingSender->SendAsync( who, timeout, buffer, options, waiter ); - - // Prevent this example application from ending. - // A real application should do something useful - // when possible. - waiter->WaitOne(); - Console::WriteLine( "Ping example completed." ); -} - - -// -void PingCompletedCallback( Object^ /*sender*/, PingCompletedEventArgs^ e ) -{ - - // If the operation was canceled, display a message to the user. - if ( e->Cancelled ) - { - Console::WriteLine( "Ping canceled." ); - - // Let the main thread resume. - // UserToken is the AutoResetEvent object that the main thread - // is waiting for. - (dynamic_cast(e->UserState))->Set(); - } - - - // If an error occurred, display the exception to the user. - if ( e->Error != nullptr ) - { - Console::WriteLine( "Ping failed:" ); - Console::WriteLine( e->Error->ToString() ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); - } - - PingReply ^ reply = e->Reply; - DisplayReply( reply ); - - // Let the main thread resume. - (dynamic_cast(e->UserState))->Set(); -} - - -// -// -void DisplayReply( PingReply ^ reply ) -{ - if ( reply == nullptr ) - return; - - Console::WriteLine( "ping status: {0}", reply->Status ); - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } -} - -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp b/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp deleted file mode 100644 index 49704c6adde..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -//NCLPingSync -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::NetworkInformation; -using namespace System::Text; - -// args[1] can be an IPaddress or host name. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // - // - Ping ^ pingSender = gcnew Ping; - PingOptions ^ options = gcnew PingOptions; - - // Use the default Ttl value which is 128, - // but change the fragmentation behavior. - options->DontFragment = true; - - // - // Create a buffer of 32 bytes of data to be transmitted. - String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - array^buffer = Encoding::ASCII->GetBytes( data ); - int timeout = 120; - PingReply ^ reply = pingSender->Send( args[ 1 ], timeout, buffer, options ); - - // - // - if ( reply->Status == IPStatus::Success ) - { - Console::WriteLine( "Address: {0}", reply->Address->ToString() ); - Console::WriteLine( "RoundTrip time: {0}", reply->RoundtripTime ); - Console::WriteLine( "Time to live: {0}", reply->Options->Ttl ); - Console::WriteLine( "Don't fragment: {0}", reply->Options->DontFragment ); - Console::WriteLine( "Buffer size: {0}", reply->Buffer->Length ); - } - - - // -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp b/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp deleted file mode 100644 index 3287346e00c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// NclSslClientSync -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -using namespace System::Net; -using namespace System::Net::Security; -using namespace System::Net::Sockets; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -namespace NlsClientSync -{ - public ref class SslTcpClient - { - private: - static Hashtable^ certificateErrors = gcnew Hashtable; - // - // Load a table of errors that might cause - // the certificate authentication to fail. - static void InitializeCertificateErrors() - { - certificateErrors->Add(0x800B0101, - "The certification has expired."); - certificateErrors->Add(0x800B0104, - "A path length constraint " - "in the certification chain has been violated."); - certificateErrors->Add(0x800B0105, - "A certificate contains an unknown extension " - "that is marked critical."); - certificateErrors->Add(0x800B0107, - "A parent of a given certificate in fact " - "did not issue that child certificate."); - certificateErrors->Add(0x800B0108, - "A certificate is missing or has an empty value " - "for a necessary field."); - certificateErrors->Add(0x800B0109, - "The certificate root is not trusted."); - certificateErrors->Add(0x800B010C, - "The certificate has been revoked."); - certificateErrors->Add(0x800B010F, - "The name in the certificate does not not match " - "the host name requested by the client."); - certificateErrors->Add(0x800B0111, - "The certificate was explicitly marked " - "as untrusted by the user."); - certificateErrors->Add(0x800B0112, - "A certification chain processed correctly, " - "but one of the CA certificates is not trusted."); - certificateErrors->Add(0x800B0113, - "The certificate has an invalid policy."); - certificateErrors->Add(0x800B0114, - "The certificate name is either not " - "in the permitted list or is explicitly excluded."); - certificateErrors->Add(0x80092012, - "The revocation function was unable to check " - "revocation for the certificate."); - certificateErrors->Add(0x80090327, - "An unknown error occurred while " - "processing the certificate."); - certificateErrors->Add(0x80096001, - "A system-level error occurred " - "while verifying trust."); - certificateErrors->Add(0x80096002, - "The certificate for the signer of the message " - "is invalid or not found."); - certificateErrors->Add(0x80096003, - "One of the counter signatures was invalid."); - certificateErrors->Add(0x80096004, - "The signature of the certificate " - "cannot be verified."); - certificateErrors->Add(0x80096005, - "The time stamp signature or certificate " - "could not be verified or is malformed."); - certificateErrors->Add(0x80096010, - "The digital signature of the object " - "was not verified."); - certificateErrors->Add(0x80096019, - "The basic constraint extension of a certificate " - "has not been observed."); - } - - static String^ CertificateErrorDescription(UInt32 problem) - { - // Initialize the error message dictionary - // if it is not yet available. - if (certificateErrors->Count == 0) - { - InitializeCertificateErrors(); - } - - String^ description = safe_cast( - certificateErrors[problem]); - if (description == nullptr) - { - description = String::Format( - CultureInfo::CurrentCulture, - "Unknown certificate error - 0x{0:x8}", - problem); - } - - return description; - } - - public: - // The following method is invoked - // by the CertificateValidationDelegate. - static bool ValidateServerCertificate( - Object^ sender, - X509Certificate^ certificate, - X509Chain^ chain, - SslPolicyErrors sslPolicyErrors) - { - - Console::WriteLine("Validating the server certificate."); - if (sslPolicyErrors == SslPolicyErrors::None) - return true; - - Console::WriteLine("Certificate error: {0}", sslPolicyErrors); - - // Do not allow this client to communicate with unauthenticated servers. - return false; - } - // - - // - static void RunClient(String^ machineName, String^ serverName) - { - - // - // - // Create a TCP/IP client socket. - // machineName is the host running the server application. - TcpClient^ client = gcnew TcpClient(machineName, 5000); - Console::WriteLine("Client connected."); - - // Create an SSL stream that will close - // the client's stream. - SslStream^ sslStream = gcnew SslStream( - client->GetStream(), false, - gcnew RemoteCertificateValidationCallback(ValidateServerCertificate), - nullptr); - - // The server name must match the name - // on the server certificate. - try - { - sslStream->AuthenticateAsClient(serverName); - } - catch (AuthenticationException^ ex) - { - Console::WriteLine("Exception: {0}", ex->Message); - if (ex->InnerException != nullptr) - { - Console::WriteLine("Inner exception: {0}", - ex->InnerException->Message); - } - - Console::WriteLine("Authentication failed - " - "closing the connection."); - sslStream->Close(); - client->Close(); - return; - } - // - // Encode a test message into a byte array. - // Signal the end of the message using the "". - array^ messsage = Encoding::UTF8->GetBytes( - "Hello from the client."); - - // Send hello message to the server. - sslStream->Write(messsage); - sslStream->Flush(); - // - // Read message from the server. - String^ serverMessage = ReadMessage(sslStream); - Console::WriteLine("Server says: {0}", serverMessage); - - // Close the client connection. - sslStream->Close(); - client->Close(); - Console::WriteLine("Client closed."); - } - // - // - private: - static String^ ReadMessage(SslStream^ sslStream) - { - - // Read the message sent by the server. - // The end of the message is signaled using the - // "" marker. - array^ buffer = gcnew array(2048); - StringBuilder^ messageData = gcnew StringBuilder; - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Encoding^ u8 = Encoding::UTF8; - Decoder^ decoder = u8->GetDecoder(); - - int bytes = -1; - do - { - bytes = sslStream->Read(buffer, 0, buffer->Length); - - array<__wchar_t>^ chars = gcnew array<__wchar_t>( - decoder->GetCharCount(buffer, 0, bytes)); - decoder->GetChars(buffer, 0, bytes, chars, 0); - messageData->Append(chars); - - // Check for EOF. - if (messageData->ToString()->IndexOf("") != -1) - { - break; - } - } - while (bytes != 0); - - return messageData->ToString(); - } - // - }; -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ serverCertificateName = nullptr; - String^ machineName = nullptr; - if (args == nullptr || args->Length < 2) - { - Console::WriteLine("To start the client specify:"); - Console::WriteLine("clientSync machineName [serverName]"); - return 1; - } - - // User can specify the machine name and server name. - // Server name must match the name on - // the server's certificate. - machineName = args[1]; - if (args->Length < 3) - { - serverCertificateName = machineName; - } - else - { - serverCertificateName = args[2]; - }; - - NlsClientSync::SslTcpClient::RunClient(machineName, - serverCertificateName); - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp b/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp deleted file mode 100644 index b49960ce769..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp +++ /dev/null @@ -1,265 +0,0 @@ - -// NclSslServerAsync -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::Security; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -// The following example demonstrates the server side of a -// client-server application that communicates using the -// SslStream, TcpListener, and TcpClient classes. -// After connecting to the server and authenticating, -// the server reads a message from the client, -// sends a message to the client, -// and then terminates. Messages sent to and from the client are terminated -// with ''. -// The ClientState class holds information shared -// by asynchronous calls. -// -public ref class ClientState -{ -internal: - SslStream^ stream; - TcpClient^ client; - StringBuilder^ readData; - array^buffer; - ClientState( SslStream^ stream, TcpClient^ client ) - { - this->stream = stream; - this->client = client; - readData = gcnew StringBuilder; - buffer = gcnew array(2048); - } - - void Close() - { - - // Close the SslStream. This will also close the - // NetworkStream allocated to the TcpClient. - stream->Close(); - - // Close the TcpClient. - client->Close(); - readData = nullptr; - buffer = nullptr; - Console::WriteLine( L"Client closed." ); - } - -}; - - -// -public ref class SslTcpListener -{ -public: - - // - // The following method is invoked by the CertificateValidationDelegate. - static bool ValidateCertificate( - Object^ sender, - X509Certificate^ certificate, - X509Chain^ chain, - SslPolicyErrors sslPolicyErrors) - { - if ( certificate == nullptr ) - { - - // Null certificate and no errors means that the client was not - // required to provide a certificate. - if ( sslPolicyErrors == SslPolicyErrors::None) - { - return true; - } - else - { - Console::WriteLine(L"Certificate error: {0}", sslPolicyErrors); - } - return false; - } - - Console::WriteLine( L"Server is validating certificate." ); - Console::WriteLine( L"Certificate was issued to {0} and is valid from {1} until {2}.", - certificate->Subject, - certificate->GetEffectiveDateString(), - certificate->GetExpirationDateString() ); - return true; - } - - - // - // - void AuthenticateCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - try - { - stream->EndAuthenticateAsServer( ar ); - Console::WriteLine( L"Authentication succeeded." ); - Console::WriteLine( L"Cipher: {0} strength {1}", stream->CipherAlgorithm, stream->CipherStrength ); - Console::WriteLine( L"Hash: {0} strength {1}", stream->HashAlgorithm, stream->HashStrength ); - Console::WriteLine( L"Key exchange: {0} strength {1}", stream->KeyExchangeAlgorithm, stream->KeyExchangeStrength ); - Console::WriteLine( L"Protocol: {0}", stream->SslProtocol ); - - // Asynchronously read a message from the client. - stream->BeginRead( state->buffer, 0, state->buffer->Length, gcnew AsyncCallback( this, &SslTcpListener::ReadCallback ), state ); - } - catch ( Exception^ authenticationException ) - { - Console::WriteLine( L"Authentication error: {0}", authenticationException->Message ); - if ( authenticationException->InnerException != nullptr ) - { - Console::WriteLine( L" Inner exception: {0}", authenticationException->InnerException->Message ); - } - state->Close(); - return; - } - - } - - - // - // - void WriteCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - try - { - Console::WriteLine( L"Writing data to the client." ); - stream->EndWrite( ar ); - } - catch ( Exception^ writeException ) - { - Console::WriteLine( L"Write error: {0}", writeException->Message ); - state->Close(); - return; - } - - Console::WriteLine( L"Finished with client." ); - state->Close(); - } - - - // - // - void ReadCallback( IAsyncResult^ ar ) - { - ClientState^ state = dynamic_cast(ar->AsyncState); - SslStream^ stream = state->stream; - - // Read the message sent by the client. - // The end of the message is signaled using the - // "" marker. - int byteCount = -1; - try - { - Console::WriteLine( L"Reading data from the client." ); - byteCount = stream->EndRead( ar ); - - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Decoder^ decoder = Encoding::UTF8->GetDecoder(); - array^chars = gcnew array(decoder->GetCharCount( state->buffer, 0, byteCount )); - decoder->GetChars( state->buffer, 0, byteCount, chars, 0 ); - state->readData->Append( chars ); - - // Check for EOF or an empty message. - if ( state->readData->ToString()->IndexOf( L"" ) == -1 && byteCount != 0 ) - { - - // We are not finished reading. - // Asynchronously read more message data from the client. - stream->BeginRead( state->buffer, 0, state->buffer->Length, gcnew AsyncCallback( this, &SslTcpListener::ReadCallback ), state ); - } - else - { - Console::WriteLine( L"Message from the client: {0}", state->readData ); - } - - // Encode a test message into a byte array. - // Signal the end of the message using "". - array^message = Encoding::UTF8->GetBytes( L"Hello from the server." ); - - // Asynchronously send the message to the client. - stream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( this, &SslTcpListener::WriteCallback ), state ); - } - catch ( Exception^ readException ) - { - Console::WriteLine( L"Read error: {0}", readException->Message ); - state->Close(); - return; - } - - } - - - // - // - void ProcessClient( ClientState^ state, X509Certificate^ serverCertificate ) - { - try - { - state->stream->BeginAuthenticateAsServer( - serverCertificate, true, SslProtocols::Tls, true, - gcnew AsyncCallback( this, &SslTcpListener::AuthenticateCallback ), state ); - } - catch ( Exception^ authenticationException ) - { - Console::WriteLine( L"Authentication error: {0}", authenticationException->Message ); - state->Close(); - return; - } - - } - - - // - // - int ServerSideTest() - { - array^args = Environment::GetCommandLineArgs(); - if ( args == nullptr || args->Length == 0 ) - { - Console::WriteLine( L"You must specify the server certificate file." ); - return 0; - } - - X509Certificate^ serverCertificate = X509Certificate::CreateFromCertFile( args[ 1 ] ); - - // Create a TCP/IP (IPv4) socket and listen for incoming connections. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,5000 ); - listener->Start(); - while ( true ) - { - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - TcpClient^ client = listener->AcceptTcpClient(); - Console::WriteLine( L"Client connected." ); - SslStream^ stream = gcnew SslStream( client->GetStream(),false, - gcnew RemoteCertificateValidationCallback( ValidateCertificate ) ); - ClientState^ state = gcnew ClientState( stream,client ); - SslTcpListener^ listenerWorker = gcnew SslTcpListener; - listenerWorker->ProcessClient( state, serverCertificate ); - } - } - - // -}; - -int main() -{ - SslTcpListener^ stl = gcnew SslTcpListener; - stl->ServerSideTest(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp b/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp deleted file mode 100644 index 1a659c12fe2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp +++ /dev/null @@ -1,235 +0,0 @@ - -// NclSslServerSync -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Net::Security; -using namespace System::Security::Authentication; -using namespace System::Text; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; -public ref class SslTcpServer sealed -{ -private: - static X509Certificate^ serverCertificate = nullptr; - -public: - - // The certificate parameter specifies the name of the file - // containing the machine certificate. - static void RunServer( String^ certificate ) - { - serverCertificate = X509Certificate::CreateFromCertFile( certificate ); - - // Create a TCP/IP (IPv4) socket and listen for incoming connections. - TcpListener^ listener = gcnew TcpListener( IPAddress::Any,5000 ); - listener->Start(); - - while (true) - { - Console::WriteLine( L"Waiting for a client to connect..." ); - - // Application blocks while waiting for an incoming connection. - // Type CNTL-C to terminate the server. - TcpClient^ client = listener->AcceptTcpClient(); - ProcessClient( client ); - - } - } - - - // - static void ProcessClient( TcpClient^ client ) - { - - // A client has connected. Create the - // SslStream using the client's network stream. - SslStream^ sslStream = gcnew SslStream( client->GetStream(),false ); - - // Authenticate the server but don't require the client to authenticate. - try - { - sslStream->AuthenticateAsServer( serverCertificate, false, true ); - // false == no client cert required; true == check cert revocation. - - // Display the properties and settings for the authenticated stream. - DisplaySecurityLevel( sslStream ); - DisplaySecurityServices( sslStream ); - DisplayCertificateInformation( sslStream ); - DisplayStreamProperties( sslStream ); - - // Set timeouts for the read and write to 5 seconds. - sslStream->ReadTimeout = 5000; - sslStream->WriteTimeout = 5000; - - // Read a message from the client. - Console::WriteLine( L"Waiting for client message..." ); - String^ messageData = ReadMessage( sslStream ); - Console::WriteLine( L"Received: {0}", messageData ); - - // Write a message to the client. - array^message = Encoding::UTF8->GetBytes( L"Hello from the server." ); - Console::WriteLine( L"Sending hello message." ); - sslStream->Write( message ); - } - catch ( AuthenticationException^ e ) - { - Console::WriteLine( L"Exception: {0}", e->Message ); - if ( e->InnerException != nullptr ) - { - Console::WriteLine( L"Inner exception: {0}", e->InnerException->Message ); - } - Console::WriteLine( L"Authentication failed - closing the connection." ); - sslStream->Close(); - client->Close(); - return; - } - finally - { - - // The client stream will be closed with the sslStream - // because we specified this behavior when creating - // the sslStream. - sslStream->Close(); - client->Close(); - } - - } - - - // - // - static String^ ReadMessage( SslStream^ sslStream ) - { - - // Read the message sent by the client. - // The client signals the end of the message using the - // "" marker. - array^buffer = gcnew array(2048); - StringBuilder^ messageData = gcnew StringBuilder; - int bytes = -1; - do - { - - // Read the client's test message. - bytes = sslStream->Read( buffer, 0, buffer->Length ); - - // Use Decoder class to convert from bytes to UTF8 - // in case a character spans two buffers. - Decoder^ decoder = Encoding::UTF8->GetDecoder(); - array^chars = gcnew array(decoder->GetCharCount( buffer, 0, bytes )); - decoder->GetChars( buffer, 0, bytes, chars, 0 ); - messageData->Append( chars ); - - // Check for EOF or an empty message. - if ( messageData->ToString()->IndexOf( L"" ) != -1 ) - { - break; - } - } - while ( bytes != 0 ); - - return messageData->ToString(); - } - - - // - // - static void DisplaySecurityLevel( SslStream^ stream ) - { - Console::WriteLine( L"Cipher: {0} strength {1}", stream->CipherAlgorithm, stream->CipherStrength ); - Console::WriteLine( L"Hash: {0} strength {1}", stream->HashAlgorithm, stream->HashStrength ); - Console::WriteLine( L"Key exchange: {0} strength {1}", stream->KeyExchangeAlgorithm, stream->KeyExchangeStrength ); - Console::WriteLine( L"Protocol: {0}", stream->SslProtocol ); - } - - - // - // - static void DisplaySecurityServices( SslStream^ stream ) - { - Console::WriteLine( L"Is authenticated: {0} as server? {1}", stream->IsAuthenticated, stream->IsServer ); - Console::WriteLine( L"IsSigned: {0}", stream->IsSigned ); - Console::WriteLine( L"Is Encrypted: {0}", stream->IsEncrypted ); - Console::WriteLine( L"Is mutually authenticated: {0}", stream->IsMutuallyAuthenticated ); - } - - - // - // - static void DisplayStreamProperties( SslStream^ stream ) - { - Console::WriteLine( L"Can read: {0}, write {1}", stream->CanRead, stream->CanWrite ); - Console::WriteLine( L"Can timeout: {0}", stream->CanTimeout ); - } - - - // - // - static void DisplayCertificateInformation( SslStream^ stream ) - { - Console::WriteLine( L"Certificate revocation list checked: {0}", stream->CheckCertRevocationStatus ); - X509Certificate^ localCertificate = stream->LocalCertificate; - if ( stream->LocalCertificate != nullptr ) - { - Console::WriteLine( L"Local cert was issued to {0} and is valid from {1} until {2}.", - localCertificate->Subject, - localCertificate->GetEffectiveDateString(), - localCertificate->GetExpirationDateString() ); - } - else - { - Console::WriteLine( L"Local certificate is null." ); - } - - X509Certificate^ remoteCertificate = stream->RemoteCertificate; - if ( stream->RemoteCertificate != nullptr ) - { - Console::WriteLine( L"Remote cert was issued to {0} and is valid from {1} until {2}.", - remoteCertificate->Subject, - remoteCertificate->GetEffectiveDateString(), - remoteCertificate->GetExpirationDateString() ); - } - else - { - Console::WriteLine( L"Remote certificate is null." ); - } - } - - -private: - - // - static void DisplayUsage() - { - Console::WriteLine( L"To start the server specify:" ); - Console::WriteLine( L"serverSync certificateFile.cer" ); - Environment::Exit( 1 ); - } - -public: - int RunServerASync() - { - array^args = Environment::GetCommandLineArgs(); - String^ certificate = nullptr; - if ( args == nullptr || args->Length < 2 ) - { - DisplayUsage(); - } - - certificate = args[ 1 ]; - SslTcpServer::RunServer( certificate ); - return 0; - } - -}; - -int main(){ - SslTcpServer^ sts = gcnew SslTcpServer(); - sts->RunServerASync(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp b/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp deleted file mode 100644 index 1cf6a399da6..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using -using namespace System; -using namespace System::Text; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - // Create the server side connection and - // start listening for clients. - TcpListener^ tcpListener = gcnew TcpListener(IPAddress::Any, 11000); - tcpListener->Start(); - Console::WriteLine("Waiting for a connection...."); - - // Accept the pending client connection. - TcpClient^ tcpClient = tcpListener->AcceptTcpClient(); - Console::WriteLine("Connection accepted."); - // Get the stream to write the message - // that will be sent to the client. - NetworkStream^ networkStream = tcpClient->GetStream(); - String^ responseString = "Hello."; - // Set the write timeout to 10 millseconds. - networkStream->WriteTimeout = 10; - // Convert the message to a byte array and sent it to the client. - array^ sendBytes = Encoding::UTF8->GetBytes(responseString); - networkStream->Write(sendBytes, 0, sendBytes->Length); - Console::WriteLine("Message Sent."); - // Close the connection to the client. - tcpClient->Close(); - // Stop listening for incoming connections - // and close the server. - tcpListener->Stop(); - - // Dispose allocated resources. - delete networkStream; - delete tcpClient; -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp b/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp deleted file mode 100644 index 91eb1c27dd6..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::NetworkCredential::NetworkCredential(String*, String*) - -/*This program demontrates the 'NetworkCredential(String*, String*)' constructor of 'NetworkCredential' class. -It takes an URL, username, password and domainname from console and forms a 'NetworkCredential' Object* with -these arguments.Then a 'WebRequest' Object* is created and the 'NetworkCredential' Object* is associated with -it.A message is displayed onto the console on successful reception of response otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ username, String^ passwd, String^ domain ) -{ - try - { -// - // Call the onstructor to create an instance of NetworkCredential with the - // specified user name and password. - NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd ); - - // Create a WebRequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myCredentials->Domain = domain; - myWebRequest->Credentials = myCredentials; - Console::WriteLine( "\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}", - myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response..." ); - - // Send the request and wait for a response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received successfully." ); - - // Release the resources of the response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 5 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_Constructor2 URLname username password domainname" ); - Console::WriteLine( "\nExample: NetworkCredential_Constructor2 http://www.microsoft.com/net/ george george123 microsoft" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter key' to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp b/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp deleted file mode 100644 index 4f1b295b678..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// System::Net::NetworkCredential::GetCredential -/*This program demontrates the 'GetCredential' of 'NetworkCredential' class. -It accepts an URL, username and password from console. Creates a 'NetworkCredential' Object* -using these parameters. A 'WebRequest' Object* is created to access the Uri S"http://www.microsoft.com" -and the 'NetworkCredential' Object* is assigned as it's Credentials. -A message is displayed onto the console on successful reception of response -otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; - -void GetPage( String^ url, String^ userName, String^ password ) -{ - try - { -// - // Create an empty instance of the NetworkCredential class. - NetworkCredential^ myCredentials = gcnew NetworkCredential( userName,password ); - - // Create a webrequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentials->GetCredential( gcnew Uri( url ), "" ); - Console::WriteLine( "\n\nUser Credentials:- UserName : {0} , Password : {1}", - myCredentials->UserName, myCredentials->Password ); - - // Send the request and wait for a response. - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response...Please wait ..." ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received successfully" ); - - // Release the resources of the response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as* command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_GetCredential URLname username password" ); - Console::WriteLine( "\nExample: NetworkCredential_GetCredential http://www.microsoft.com/net/ george george123" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter' to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp b/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp deleted file mode 100644 index 73e255c77fa..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// System::Net::NetworkCredential::Username;System::Net::NetworkCredential::Domain;System::Net::NetworkCredential::Password -/*This program demontrates the 'UserName', 'Domain', and 'Password' properties of the 'NetworkCredential' class. -It takes an URL, username, password, and domain name from console. An empty 'NetworkCredential' Object* -is created. The 'UserName', 'Password', and 'Domain' porperties of the 'NetworkCredential' class are initialized -with the respective values taken from console. Then a 'WebRequest' Object* is created and the 'NetworkCredential' -Object* is associated with it. A message is displayed onto the console on successful reception of response -otherwise an exception is thrown. -*/ - -#using - -using namespace System; -using namespace System::Net; -void GetPage( String^ url, String^ username, String^ passwd, String^ domain ) -{ - try - { -// -// -// - // Create an empty instance of the NetworkCredential class. - NetworkCredential^ myCredentials = gcnew NetworkCredential( "","","" ); - myCredentials->Domain = domain; - myCredentials->UserName = username; - myCredentials->Password = passwd; - - // Create a WebRequest with the specified URL. - WebRequest^ myWebRequest = WebRequest::Create( url ); - myWebRequest->Credentials = myCredentials; - Console::WriteLine( "\n\nUser Credentials:- Domain : {0} , UserName : {1} , Password : {2}", - myCredentials->Domain, myCredentials->UserName, myCredentials->Password ); - - // Send the request and wait for a response. - Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response...Please wait ..." ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response. - Console::WriteLine( "\nResponse received successfully" ); - - // Release the resources of the response object. - myWebResponse->Close(); -// -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException is raised. The Reason for failure is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following exception was raised : {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 5 ) - { - Console::WriteLine( "\nPlease enter a protected resource Url and other details as command line parameter as below:" ); - Console::WriteLine( "\nUsage: NetworkCredential_UserName_Password_Domain URLname username password domainname" ); - Console::WriteLine( "\nExample: NetworkCredential_UserName_Password_Domain http://www.microsoft.com/net/ george george123 microsoft" ); - } - else - { - GetPage( args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ] ); - } - - Console::WriteLine( "\n\nPress 'Enter key' to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp deleted file mode 100644 index 17f565e5d3c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -ref class MyNetworkStream_Sub_Class: public NetworkStream -{ -public: - MyNetworkStream_Sub_Class( System::Net::Sockets::Socket^ socket, bool ownsSocket ) - : NetworkStream( socket, ownsSocket ) - { - } - - property bool IsConnected - { - // You can use the Socket method to examine the underlying Socket. - bool get() - { - return this->Socket->Connected; - } - } - - property bool CanCommunicate - { - bool get() - { - if ( !this->Readable | !this->Writeable ) - { - return false; - } - else - { - return true; - } - } - } -// - - static void DoSomethingSignificant() - { - // Do something significant in here - } - -}; - -int main() -{ - MyNetworkStream_Sub_Class::DoSomethingSignificant(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp deleted file mode 100644 index 24eb36c07d2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// The following sample is intended to demonstrate how to use a -//NetworkStream for synchronous communcation with a remote host -//This class uses several NetworkStream members that would be useful -// in a synchronous communciation senario - -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -void MySample( bool networkStreamOwnsSocket ) -{ - // Create a socket and connect with a remote host. - IPHostEntry^ myIpHostEntry = Dns::GetHostEntry( "www.contoso.com" ); - IPEndPoint^ myIpEndPoint = gcnew IPEndPoint( myIpHostEntry->AddressList[ 0 ],1001 ); - - Socket^ mySocket = gcnew Socket( myIpEndPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - try - { - mySocket->Connect( myIpEndPoint ); - - NetworkStream^ myNetworkStream; - if ( networkStreamOwnsSocket ) - { - myNetworkStream = gcnew NetworkStream( mySocket,true ); - } - else - { - myNetworkStream = gcnew NetworkStream( mySocket ); - } - - // - // Examples for CanWrite, and CanWrite - // Check to see if this NetworkStream is writable. - if ( myNetworkStream->CanWrite ) - { - array^ myWriteBuffer = Encoding::ASCII->GetBytes( - "Are you receiving this message?" ); - myNetworkStream->Write( myWriteBuffer, 0, myWriteBuffer->Length ); - } - else - { - Console::WriteLine( "Sorry. You cannot write to this NetworkStream." ); - } - // - - // Examples for CanRead, Read, and DataAvailable. - // Check to see if this NetworkStream is readable. - if ( myNetworkStream->CanRead ) - { - array^ myReadBuffer = gcnew array(1024); - String^ myCompleteMessage = ""; - int numberOfBytesRead = 0; - - // Incoming message may be larger than the buffer size. - do - { - numberOfBytesRead = myNetworkStream->Read( myReadBuffer, 0, - myReadBuffer->Length ); - myCompleteMessage = String::Concat( myCompleteMessage, - Encoding::ASCII->GetString( myReadBuffer, 0, numberOfBytesRead ) ); - } - while ( myNetworkStream->DataAvailable ); - - // Print out the received message to the console. - Console::WriteLine( "You received the following message : {0}", - myCompleteMessage ); - } - else - { - Console::WriteLine( "Sorry. You cannot read from this NetworkStream." ); - } - - // - // Example for closing the NetworkStream. - // Close the NetworkStream - myNetworkStream->Close(); - // - - } - catch ( Exception^ exception ) - { - Console::WriteLine( "Exception Thrown: {0}", exception->ToString() ); - } -} - -int main( int argc, char *argv[] ) -{ - if ( "yes" == gcnew String(argv[1]) ) - { - MySample( true ); - } - else - if ( "no" == gcnew String(argv[1]) ) - { - MySample( false ); - } - else - { - Console::WriteLine( "Must use 'yes' to allow the NetworkStream to own the Socket or {0}", "\n 'no' to prohibit NetworkStream from owning the Socket." ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp deleted file mode 100644 index 13bca5b2a43..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; - -int main() -{ - - //Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = "GET / HTTP/1.1\r\nHost: www.contoso.com" + - "\r\nConnection: Close\r\n\r\n"; - array^ ByteGet = ASCII->GetBytes( Get ); - array^ RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - - // IPAddress and IPEndPoint represent the endpoint that will - // receive the request. - // Get first IPAddress in list return by DNS. - IPAddress^ hostadd = Dns::GetHostEntry( "www.contoso.com" )->AddressList[ 0 ]; - IPEndPoint^ EPhost = gcnew IPEndPoint( hostadd,80 ); - - // - //Creates the Socket for sending data over TCP. - Socket^ s = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp ); - - // Connects to host using IPEndPoint. - s->Connect( EPhost ); - if ( !s->Connected ) - { - strRetPage = "Unable to connect to host"; - } - // Use the SelectWrite enumeration to obtain Socket status. - if ( s->Poll( -1, SelectMode::SelectWrite ) ) - { - Console::WriteLine( "This Socket is writable." ); - } - else if ( s->Poll( -1, SelectMode::SelectRead ) ) - { - Console::WriteLine( "This Socket is readable." ); - } - else if ( s->Poll( -1, SelectMode::SelectError ) ) - { - Console::WriteLine( "This Socket has an error." ); - } - // - - // Sent the GET text to the host. - s->Send( ByteGet, ByteGet->Length, SocketFlags::None ); - - // Receives the page, loops until all bytes are received. - Int32 bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = "Default HTML page on www.contoso.com:\r\n"; - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - - while ( bytes > 0 ) - { - bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp b/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp deleted file mode 100644 index 9cc9a851cc9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -namespace SocketOptionExamples -{ - ref class SocketPropertyTester - { - // - static void ConfigureTcpSocket(Socket^ tcpSocket) - { - - // Don't allow another socket to bind to this port. - tcpSocket->ExclusiveAddressUse = true; - - // The socket will linger for 10 seconds after - // Socket.Close is called. - tcpSocket->LingerState = gcnew LingerOption(true, 10); - - // Disable the Nagle Algorithm for this tcp socket. - tcpSocket->NoDelay = true; - - // Set the receive buffer size to 8k - tcpSocket->ReceiveBufferSize = 8192; - - // Set the timeout for synchronous receive methods to - // 1 second (1000 milliseconds.) - tcpSocket->ReceiveTimeout = 1000; - - // Set the send buffer size to 8k. - tcpSocket->SendBufferSize = 8192; - - // Set the timeout for synchronous send methods - // to 1 second (1000 milliseconds.) - tcpSocket->SendTimeout = 1000; - - // Set the Time To Live (TTL) to 42 router hops. - tcpSocket->Ttl = 42; - Console::WriteLine("Tcp Socket configured:"); - Console::WriteLine(" ExclusiveAddressUse {0}", - tcpSocket->ExclusiveAddressUse); - Console::WriteLine(" LingerState {0}, {1}", - tcpSocket->LingerState->Enabled, - tcpSocket->LingerState->LingerTime); - Console::WriteLine(" NoDelay {0}", - tcpSocket->NoDelay); - Console::WriteLine(" ReceiveBufferSize {0}", - tcpSocket->ReceiveBufferSize); - Console::WriteLine(" ReceiveTimeout {0}", - tcpSocket->ReceiveTimeout); - Console::WriteLine(" SendBufferSize {0}", - tcpSocket->SendBufferSize); - Console::WriteLine(" SendTimeout {0}", - tcpSocket->SendTimeout); - Console::WriteLine(" Ttl {0}", - tcpSocket->Ttl); - Console::WriteLine(" IsBound {0}", - tcpSocket->IsBound); - Console::WriteLine(""); - } - // - // - static void ConfigureUdpSocket(Socket^ udpSocket) - { - - // Set the Don't Fragment flag. - udpSocket->DontFragment = true; - - // Enable broadcast. - udpSocket->EnableBroadcast = true; - - // Disable multicast loopback. - udpSocket->MulticastLoopback = false; - Console::WriteLine("Udp Socket configured:"); - Console::WriteLine(" DontFragment {0}", - udpSocket->DontFragment); - Console::WriteLine(" EnableBroadcast {0}", - udpSocket->EnableBroadcast); - Console::WriteLine(" MulticastLoopback {0}", - udpSocket->MulticastLoopback); - } - // - public: - static void Work() - { - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, - SocketType::Stream, ProtocolType::IP); - Socket^ udpSocket = gcnew Socket( - AddressFamily::InterNetwork, - SocketType::Dgram, ProtocolType::IP); - ConfigureTcpSocket(tcpSocket); - ConfigureUdpSocket(udpSocket); - } - }; -} - -int main() -{ - SocketOptionExamples::SocketPropertyTester::Work(); - return 0; -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp deleted file mode 100644 index d7441a3cbf9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -#using -#define NULL 0 - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Collections; -public ref class Sync_Send_Receive -{ -public: - - //Displays sending and receiving with a connected socket -- buffer only - static void SendReceive1() - { - - // - IPHostEntry^ lipa = Dns::Resolve( Dns::GetHostName() ); - - //Gets three separate local endpoints. - IPEndPoint^ lep1 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11000 ); - IPEndPoint^ lep2 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11001 ); - IPEndPoint^ lep3 = gcnew IPEndPoint( lipa->AddressList[ 0 ],11002 ); - - //creates an array of endpoints. - array^ipendpoints = gcnew array(3); - ipendpoints[ 0 ] = lep1; - ipendpoints[ 1 ] = lep2; - ipendpoints[ 2 ] = lep3; - - //Creates three separate sockets. - Socket^ s1 = gcnew Socket( lep1->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - Socket^ s2 = gcnew Socket( lep2->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - Socket^ s3 = gcnew Socket( lep3->Address->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - array^socketList = gcnew array(3); - socketList[ 0 ] = s1; - socketList[ 1 ] = s2; - socketList[ 2 ] = s3; - - //Binds and Listens on all sockets in the array of sockets. - for ( int i = 0; i < 3; i++ ) - { - socketList[ i ]->Bind( ipendpoints[ i ] ); - socketList[ i ]->Listen( 1000 ); - - } - - //Calls Select to determine which sockets are ready for reading. - Socket::Select( safe_cast(socketList), nullptr, nullptr, 1000 ); - - //Reads on the sockets returned by Select. - array^buffer = gcnew array(1024); - String^ outString; - for ( Int32 j = 0; j < (socketList->Length - 1); j++ ) - { - socketList[ j ]->Receive( buffer ); - outString = "Socket "; - outString->Concat( j.ToString(), " has the message", Encoding::ASCII->GetString( buffer ) ); - Console::WriteLine( outString ); - - } - } - -}; - -int main() -{ - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp deleted file mode 100644 index e799e953dee..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp +++ /dev/null @@ -1,128 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -String^ DoSocketGet( String^ server ) -{ - - //Set up variables and String to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = "GET / HTTP/1.1\r\nHost: "; - Get->Concat( server, "\r\nConnection: Close\r\n\r\n" ); - array^ByteGet = ASCII->GetBytes( Get ); - array^RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - - // IPAddress and IPEndPoint represent the endpoint that will - // receive the request. - // Get first IPAddress in list return by DNS. - try - { - - // Define those variables to be evaluated in the next for loop and - // then used to connect to the server. These variables are defined - // outside the for loop to make them accessible there after. - Socket^ s = nullptr; - IPEndPoint^ hostEndPoint; - IPAddress^ hostAddress = nullptr; - int conPort = 80; - - // Get DNS host information. - IPHostEntry^ hostInfo = Dns::Resolve( server ); - - // Get the DNS IP addresses associated with the host. - array^IPaddresses = hostInfo->AddressList; - - // Evaluate the socket and receiving host IPAddress and IPEndPoint. - for ( int index = 0; index < IPaddresses->Length; index++ ) - { - hostAddress = IPaddresses[ index ]; - hostEndPoint = gcnew IPEndPoint( hostAddress,conPort ); - - // - // Creates the Socket to send data over a TCP connection. - s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - // - // Connect to the host using its IPEndPoint. - s->Connect( hostEndPoint ); - if ( !s->Connected ) - { - - // Connection failed, try next IPaddress. - strRetPage = "Unable to connect to host"; - s = nullptr; - continue; - } - - - // - // Sent the GET request to the host. - s->Send( ByteGet, ByteGet->Length, SocketFlags::None ); - - // - - } - - // - // Receive the host home page content and loop until all the data is received. - Int32 bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage = "Default HTML page on "; - strRetPage->Concat( server, ":\r\n", ASCII->GetString( RecvBytes, 0, bytes ) ); - while ( bytes > 0 ) - { - bytes = s->Receive( RecvBytes, RecvBytes->Length, SocketFlags::None ); - strRetPage->Concat( ASCII->GetString( RecvBytes, 0, bytes ) ); - } - - - // - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNULLException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "NULLReferenceException caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::Write( "Source : " ); - Console::WriteLine( e->Source ); - Console::Write( "Message : " ); - Console::WriteLine( e->Message ); - } - - return strRetPage; -} - -int main() -{ - Console::WriteLine( DoSocketGet( "localhost" ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp deleted file mode 100644 index 11687431bce..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -public ref class Sync_Send_Receive -{ -public: - static void SetSocketOptions() - { - IPHostEntry^ lipa = Dns::Resolve("host.contoso.com"); - IPEndPoint^ lep = gcnew IPEndPoint(lipa->AddressList[0], 11000); - Socket^ s = gcnew Socket(lep->Address->AddressFamily, SocketType::Stream, ProtocolType::Tcp); - - // - // Specifies that send operations will time-out - // if confirmation is not received within 1000 milliseconds. - s->SetSocketOption(SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 1000); - // - - // - // Specifies that the Socket will linger for 10 seconds after Close is called. - LingerOption^ lingerOption = gcnew LingerOption(true, 10); - s->SetSocketOption(SocketOptionLevel::Socket, SocketOptionName::Linger, lingerOption); - // - - s->Connect(lep); - - array^ msg = Encoding::ASCII->GetBytes("This is a test"); - - // - Console::Write("This application will timeout if Send does not return within "); - Console::WriteLine(Encoding::ASCII->GetString(s->GetSocketOption(SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 4))); - - // Blocks until send returns. - int i = s->Send(msg); - - // Blocks until read returns. - array^ bytes = gcnew array(1024); - - s->Receive(bytes); - - // Displays to the screen. - Console::WriteLine(Encoding::ASCII->GetString(bytes)); - s->Shutdown(SocketShutdown::Both); - Console::Write("If data remains to be sent, this application will stay open for "); - Console::WriteLine(safe_cast(s->GetSocketOption(SocketOptionLevel::Socket, SocketOptionName::Linger))->LingerTime.ToString()); - s->Close(); - // - } - - static void CheckProperties() - { - IPHostEntry^ lipa = Dns::Resolve("host.contoso.com"); - IPEndPoint^ lep = gcnew IPEndPoint(lipa->AddressList[0], 11000); - - // - Socket^ s = gcnew Socket(lep->Address->AddressFamily, SocketType::Stream, ProtocolType::Tcp); - - // Uses the AddressFamily, SocketType, and ProtocolType properties. - Console::Write("I just set the following properties of socket: \n"); - Console::Write("Address Family = {0}", s->AddressFamily.ToString()); - Console::Write("\nSocketType = {0}", s->SocketType.ToString()); - Console::WriteLine("\nProtocolType = {0}", s->ProtocolType.ToString()); - // - - // - s->Connect(lep); - - // Uses the RemoteEndPoint property. - Console::WriteLine("I am connected to {0} on port number {1}", - IPAddress::Parse((((IPEndPoint^)(s->RemoteEndPoint))->Address)->ToString()), - ((IPEndPoint^)(s->RemoteEndPoint))->Port.ToString()); - - // Uses the LocalEndPoint property. - Console::Write("My local IpAddress is : {0}\nI am connected on port number {1}", - IPAddress::Parse((((IPEndPoint^)(s->LocalEndPoint))->Address)->ToString()), - ((IPEndPoint^)(s->LocalEndPoint))->Port.ToString()); - // - - // - // Uses low level method IOControl to set this socket to blocking mode. - int code = 0x8004667E; - array^ inBuf = gcnew array(4); - - inBuf[0] = 0; - - array^ outBuf = gcnew array(4); - - s->IOControl(code, inBuf, outBuf); - - // Checks to see that this worked. - if (s->Blocking) - { - Console::WriteLine("Socket was set to Blocking mode successfully"); - } - // - } -}; - -int main() {} diff --git a/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp deleted file mode 100644 index 847ace50a90..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp +++ /dev/null @@ -1,449 +0,0 @@ -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -// -// Displays sending with a connected socket -// using the overload that takes a buffer. -int SendReceiveTest1( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int byteCount = server->Send( msg ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return ( e->ErrorCode ); - } - return 0; -} -// - -// Displays receiving from a connected tcp socket -// using the overload that takes a buffer. -int ReceiveTest1( Socket^ client ) -{ - array^ bytes = gcnew array(256); - try - { - // It is usually preferable to use the overload - // that allows you to specify the maximum bytes returned. - if ( client->Available > 256 ) - { - throw gcnew ApplicationException( "This test socket only takes messages < 256 bytes." ); - } - // Blocks until read returns. - int byteCount = client->Receive( bytes ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - // Send reply to the client. - client->Send( Encoding::UTF8->GetBytes( "Bye." ) ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return ( e->ErrorCode ); - } - return 0; -} - -// -// Displays sending with a connected socket -// using the overload that takes a buffer and socket flags. -int SendReceiveTest2( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int byteCount = server->Send( msg, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes, SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -// -// Displays sending with a connected socket -// using the overload that takes a buffer, message size, and socket flags. -int SendReceiveTest3( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - // Blocks until send returns. - int i = server->Send( msg, msg->Length, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", i.ToString() ); - - // Get reply from the server. - int byteCount = server->Receive( bytes, server->Available, - SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -// -// Displays sending with a connected socket -// using the overload that takes a buffer, offset, message size, and socket flags. -int SendReceiveTest4( Socket^ server ) -{ - array^ msg = Encoding::UTF8->GetBytes( "This is a test" ); - array^ bytes = gcnew array(256); - try - { - - // Blocks until send returns. - int byteCount = server->Send( msg, 0, msg->Length, SocketFlags::None ); - Console::WriteLine( "Sent {0} bytes.", byteCount.ToString() ); - - // Get reply from the server. - byteCount = server->Receive( bytes, 0, server->Available, - SocketFlags::None ); - if ( byteCount > 0 ) - { - Console::WriteLine( Encoding::UTF8->GetString( bytes ) ); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() ); - return (e->ErrorCode); - } - return 0; -} -// - -public ref class NeedForDelegates -{ -public: - - // - static void SendTo1() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, endPoint ); - s->Close(); - } - // - - // - static void SendTo2() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // - static void SendTo3() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, msg->Length, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // - static void SendTo4() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - array^ msg = Encoding::ASCII->GetBytes( "This is a test" ); - Console::WriteLine( "Sending data." ); - // This call blocks. - s->SendTo( msg, 0, msg->Length, SocketFlags::None, endPoint ); - s->Close(); - } - // - - // The ReceiveFroms - // - static void ReceiveFrom1() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IPEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "Waiting to receive datagrams from client..." ); - - // This call blocks. - s->ReceiveFrom( msg, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom2() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IpEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "Waiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, SocketFlags::None, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom3() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IPEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "SWaiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, msg->Length, SocketFlags::None, senderRemote ); - s->Close(); - } - // - - // - static void ReceiveFrom4() - { - IPHostEntry^ hostEntry = Dns::Resolve( Dns::GetHostName() ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Dgram, - ProtocolType::Udp ); - - // Creates an IpEndPoint to capture the identity of the sending host. - IPEndPoint^ sender = gcnew IPEndPoint( IPAddress::Any,0 ); - EndPoint^ senderRemote = safe_cast(sender); - - // Binding is required with ReceiveFrom calls. - s->Bind( endPoint ); - - array^ msg = gcnew array(256); - Console::WriteLine( "SWaiting to receive datagrams from client..." ); - // This call blocks. - s->ReceiveFrom( msg, 0, msg->Length, SocketFlags::None, senderRemote ); - s->Close(); - } - // - // end NeedForDelegates -}; - -void RunUdpTests() -{ - // Test the upd versions. - - //NeedForDelegates^ n = new NeedForDelegates(); - ThreadStart^ myThreadDelegate = gcnew ThreadStart( &NeedForDelegates::ReceiveFrom1 ); - Thread^ myThread1 = gcnew Thread( myThreadDelegate ); - myThread1->Start(); - - while ( myThread1->IsAlive ) - { - NeedForDelegates::SendTo1(); - } - myThread1->Join(); - - Console::WriteLine( "UDP test2" ); - Thread^ myThread2 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom2 ) ); - myThread2->Start(); - while ( myThread2->IsAlive ) - { - NeedForDelegates::SendTo2(); - } - myThread2->Join(); - - Console::WriteLine( "UDP test3" ); - Thread^ myThread3 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom3 ) ); - myThread3->Start(); - while ( myThread3->IsAlive ) - { - NeedForDelegates::SendTo3(); - } - myThread3->Join(); - - Console::WriteLine( "UDP test4" ); - Thread^ myThread4 = gcnew Thread( gcnew ThreadStart( &NeedForDelegates::ReceiveFrom4 ) ); - myThread4->Start(); - while ( myThread4->IsAlive ) - { - NeedForDelegates::SendTo4(); - } - myThread4->Join(); -} - -//Main tests the snippets. -// To test tcp - run 2 instances source /s runs server, source /c runs client. -// To test Upd run source /u. -int main( int /*argc*/, char *args[] ) -{ - String^ host; - bool isServer; - - if ( args[ 1 ][ 1 ] == 'c' ) - { - isServer = false; - host = "127.0.0.1"; - } - else - if ( args[ 1 ][ 1 ] == 'u' ) - { - Console::WriteLine( "running udptests" ); - RunUdpTests(); - return 0; - } - else - { - host = "localhost"; - isServer = true; - } - - // Set up the endpoint and create the socket. - IPHostEntry^ hostEntry = Dns::Resolve( host ); - IPEndPoint^ endPoint = gcnew IPEndPoint( hostEntry->AddressList[ 0 ],11000 ); - - // Test the TCPIP snippets (Socket.Send and Socket.Receive) - - Socket^ s = gcnew Socket( endPoint->Address->AddressFamily, - SocketType::Stream, - ProtocolType::Tcp ); - - // Send or receive the test messages. - if ( isServer ) - { - Socket^ sender = nullptr; - s->Bind( endPoint ); - s->Listen( 1 ); - for ( ; ; ) - { - sender = s->Accept(); - // exchange messages with all clients tests - for ( int i = 0; i < 4; i++ ) - { - ReceiveTest1( sender ); - } - sender->Close(); - s->Close(); - Environment::Exit( 0 ); - } - } - // Its the client tcp tests. - else - { - s->Connect( endPoint ); - SendReceiveTest1( s ); - SendReceiveTest2( s ); - SendReceiveTest3( s ); - SendReceiveTest4( s ); - s->Close(); - } - - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp deleted file mode 100644 index 83b7a7e0a9d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp +++ /dev/null @@ -1,355 +0,0 @@ - - -// -// This program contains snippets applicable to the following: -// System::Net::AuthenticationManger (Snippet1); -// System::Net::AuthenticationManger::Register (Snippet2); -// System::Net::AuthenticationUnregister (Snippet2); -// System::Net::AuthenticationManger::RegisteredModules (Snippet8); -// System::Net::Authorization::Authorization (Snippet3); -// System::Net::Authorization::Message (Snippet5); -// System::Net::Authorization::Complete (Snippet5); -// System::Net::Authorization::GroupId (Snippet5); -// System::Net::IAuthenticationModule* (Snippet6); -// System::Net::IAuthenticationModule*.AuthenticationType (Snippet7); -// System::Net::IAuthenticationModule*.CanPreAuthenticate (Snippet7); -// System::Net::IAuthenticationModule*.Authenticate (Snippet3); -// System::Net::IAuthenticationModule*.PreAuthenticate (Snippet4); -// -// -// This program shows how to create a custom Basic authentication module, -// how to register it via the AuthenticationManager class and how to authorize -// users to access a Web site. -// Note: In order to run this program you must create a test Web site that performs -// Basic authentication. Also you must add to your server machine a user whose -// credentials are the same you use in this program. -// Attention: Basic authenticastion sends the user's credentials over HTTP. -// Passwords and user names are encoded using Base64 encoding. Although the -// user information is encoded, it is considered insecure due to the fact that it -// could be deciphered relatively easily. -// If you must use basic authentication you are strongly adviced to use strong -// security mechanisms, such as SSL, when transfering sensitive information on -// the wire. -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections; - -// The TestAuthentication class performs the following main tasks: -// 1) It obtains the user's credentials. -// 2) Unregisters the standard Basic authentication. -// 3) Registers the customized Basic authentication. -// 4) Reads the selected page and displays it on the console. -ref class TestAuthentication -{ -public: - static String^ username; - static String^ password; - static String^ domain; - static String^ uri; - - // Show how to use this program. - static void showusage() - { - Console::WriteLine( "Attempts to authenticate to a URL" ); - Console::WriteLine( "\r\nUse one of the following:" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password domain" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password" ); - Console::WriteLine( "\r\nExample:" ); - Console::WriteLine( "\tcustomBasicAuthentication http://ndpue/ncl/ basicuser basic.101 ndpue" ); - } - - - // - // Display registered authentication modules. - static void displayRegisteredModules() - { - - // The AuthenticationManager calls all authentication modules sequentially - // until one of them responds with an authorization instance. Show - // the current registered modules, for testing purposes. - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\r\nThe following authentication modules are now registered with the system" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\r \n Module : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } - } - - - // - // The getPage method accesses the selected page an displays its content - // on the console. - static void getPage( String^ url ) - { - try - { - - // Create the Web request object. - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( url )); - - // Define the request access method. - req->Method = "GET"; - - // Define the request credentials according to the user's input. - if ( String::Compare( domain, String::Empty ) == 0 ) - req->Credentials = gcnew NetworkCredential( username,password ); // If the user's specifies the Internet resource domain, this usually - else - req->Credentials = gcnew NetworkCredential( username,password,domain ); - - // is by default the name of the sever hosting the resource. - // Issue the request. - // req->GetResponse(); - HttpWebResponse^ result = dynamic_cast(req->GetResponse()); - Console::WriteLine( "\nAuthentication Succeeded:" ); - - // Store the response. - Stream^ sData = result->GetResponseStream(); - - // Display the response. - displayPageContent( sData ); - } - catch ( WebException^ e ) - { - - // Display the error, if any. In particular display protocol - // related error. - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - HttpWebResponse^ hresp = dynamic_cast(e->Response); - Console::WriteLine( "\nAuthentication Failed, {0}", hresp->StatusCode ); - Console::WriteLine( "Status Code: {0}", (int)hresp->StatusCode ); - Console::WriteLine( "Status Description: {0}", hresp->StatusDescription ); - return; - } - Console::WriteLine( "Caught Exception: {0}", e->Message ); - Console::WriteLine( "Stack: {0}", e->StackTrace ); - } - - } - - - // The displayPageContent method display the content of the - // selected page. - static void displayPageContent( Stream^ ReceiveStream ) - { - - // Create an ASCII encoding object. - Encoding^ ASCII = Encoding::ASCII; - - // Define the Byte array to temporary hold the current read bytes. - array^read = gcnew array(512); - Console::WriteLine( "\r\nPage Content...\r\n" ); - - // Read the page content and display it on the console. - // Read the first 512 bytes. - int bytes = ReceiveStream->Read( read, 0, 512 ); - while ( bytes > 0 ) - { - Console::Write( ASCII->GetString( read, 0, bytes ) ); - bytes = ReceiveStream->Read( read, 0, 512 ); - } - - Console::WriteLine( "" ); - } - -}; - - -// -// The CustomBasic class creates a custom Basic authentication by implementing the -// IAuthenticationModule interface. In particular it performs the following -// tasks: -// 1) Defines and initializes the required properties. -// 2) Impements the Authenticate method. -public ref class CustomBasic: public IAuthenticationModule -{ -private: - - // - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - - // The CustomBasic constructor initializes the properties of the customized - // authentication. - CustomBasic() - { - m_authenticationType = "Basic"; - m_canPreAuthenticate = false; - } - - - property String^ AuthenticationType - { - - // Define the authentication type. This type is then used to identify this - // custom authentication module. The default is set to Basic. - virtual String^ get() - { - return m_authenticationType; - } - - } - - property bool CanPreAuthenticate - { - - // Define the pre-authentication capabilities for the module. The default is set - // to false. - virtual bool get() - { - return m_canPreAuthenticate; - } - - } - - // - // The checkChallenge method checks if the challenge sent by the HttpWebRequest - // contains the correct type (Basic) and the correct domain name. - // Note: the challenge is in the form BASIC REALM=S"DOMAINNAME" - // and you must assure that the Internet Web site resides on a server whose - // domain name is equal to DOMAINAME. - bool checkChallenge( String^ Challenge, String^ domain ) - { - bool challengePasses = false; - String^ tempChallenge = Challenge->ToUpper(); - - // Verify that this is a Basic authorization request and the requested domain - // is correct. - // Note: When the domain is an empty string the following code only checks - // whether the authorization type is Basic. - if ( tempChallenge->IndexOf( "BASIC" ) != -1 ) - if ( String::Compare( domain, String::Empty ) != 0 ) - if ( tempChallenge->IndexOf( domain->ToUpper() ) != -1 ) - challengePasses = true; // The domain is not allowed and the authorization type is Basic. - else - challengePasses = false; - - else - challengePasses = true; - - - return challengePasses; - } - - - // - // The PreAuthenticate method specifies if the authentication implemented - // by this class allows pre-authentication. - // Even if you do not use it, this method must be implemented to obey to the rules - // of interface implemebtation. - // In this case it always returns null. - virtual Authorization^ PreAuthenticate( WebRequest^ request, ICredentials^ credentials ) - { - return nullptr; - } - - - // - // - // Authenticate is the core method for this custom authentication. - // When an internet resource requests authentication, the WebRequest::GetResponse - // method calls the AuthenticationManager::Authenticate method. This method, in - // turn, calls the Authenticate method on each of the registered authentication - // modules, in the order they were registered. When the authentication is - // complete an Authorization object is returned to the WebRequest, as - // shown by this routine's retun type. - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - Encoding^ ASCII = Encoding::ASCII; - - // Get the username and password from the credentials - NetworkCredential^ MyCreds = credentials->GetCredential( request->RequestUri, "Basic" ); - if ( PreAuthenticate( request, credentials ) == nullptr ) - Console::WriteLine( "\n Pre-authentication is not allowed." ); - else - Console::WriteLine( "\n Pre-authentication is allowed." ); - - - // Verify that the challenge satisfies the authorization requirements. - bool challengeOk = checkChallenge( challenge, MyCreds->Domain ); - if ( !challengeOk ) - return nullptr; - - - // - // Create the encrypted string according to the Basic authentication format as - // follows: - // a)Concatenate username and password separated by colon; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain the encoded - // authorization. - String^ BasicEncrypt = String::Concat( MyCreds->UserName, ":", MyCreds->Password ); - String^ BasicToken = String::Concat( "Basic ", Convert::ToBase64String( ASCII->GetBytes( BasicEncrypt ) ) ); - - // Create an Authorization object using the above encoded authorization. - Authorization^ resourceAuthorization = gcnew Authorization( BasicToken ); - - // Get the Message property which contains the authorization string that the - // client returns to the server when accessing protected resources - Console::WriteLine( "\n Authorization Message: {0}", resourceAuthorization->Message ); - - // Get the Complete property which is set to true when the authentication process - // between the client and the server is finished. - Console::WriteLine( "\n Authorization Complete: {0}", resourceAuthorization->Complete ); - - // - Console::WriteLine( "\n Authorization ConnectionGroupId: {0}", resourceAuthorization->ConnectionGroupId ); - return resourceAuthorization; - } - - // -}; - - -// -// This is the program entry point. It allows the user to enter -// her credentials and the Internet resource (Web page) to access. -// It also unregisters the standard and registers the customized basic -// authentication. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - TestAuthentication::showusage(); - else - { - - // Read the user's credentials. - TestAuthentication::uri = args[ 1 ]; - TestAuthentication::username = args[ 2 ]; - TestAuthentication::password = args[ 3 ]; - if ( args->Length == 4 ) - TestAuthentication::domain = String::Empty; // If the domain exists, store it. Usually the domain name - else - TestAuthentication::domain = args[ 4 ]; - - // is by default the name of the server hosting the Internet - // resource. - // Instantiate the custom Basic authentication module. - CustomBasic^ customBasicModule = gcnew CustomBasic; - - // Unregister the standard Basic authentication module. - AuthenticationManager::Unregister( "Basic" ); - - // Register the custom Basic authentication module. - AuthenticationManager::Register( customBasicModule ); - - // Display registered Authorization modules. - TestAuthentication::displayRegisteredModules(); - - // Read the specified page and display it on the console. - TestAuthentication::getPage( TestAuthentication::uri ); - } -} - -// -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp deleted file mode 100644 index 6c79604640f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -using namespace System::Collections; - -ref class DNSChanges -{ - -// -public: - static void DoGetHostEntry(String^ hostname) - { - IPHostEntry^ host = Dns::GetHostEntry(hostname); - - Console::WriteLine("GetHostEntry({0}) returns:", host->HostName); - - for (int i = 0; i < host->AddressList->Length; i++) - { - Console::WriteLine(" {0}", host->AddressList[i]->ToString()); - } - } -// - -// -public: - static void DoGetHostEntry(IPAddress^ address) - { - IPHostEntry^ host = Dns::GetHostEntry(address); - - Console::WriteLine("GetHostEntry({0}) returns HostName: {1}", address->ToString(), host->HostName); - } -// - -// - // Determine the Internet Protocol(IP) addresses for a host. -public: - static void DoGetHostAddress(String^ hostname) - { - array^ addresses; - addresses = Dns::GetHostAddresses(hostname); - - Console::WriteLine("GetHostAddresses({0}) returns:", hostname); - for each (IPAddress^ address in addresses) - { - Console::Write("{0} ", address); - } - Console::WriteLine(""); - } -// - -// - // Signals when the resolve has finished. -public: - static ManualResetEvent^ GetHostEntryFinished = - gcnew ManualResetEvent(false); - - // define the state object for the callback. - // use hostName to correlate calls with the proper result. - ref class ResolveState - { - public: - String^ hostName; - IPHostEntry^ resolvedIPs; - - ResolveState(String^ host) - { - hostName = host; - } - - property IPHostEntry^ IPs - { - IPHostEntry^ get() - { - return resolvedIPs; - } - - void set(IPHostEntry^ IPs) - { - resolvedIPs = IPs; - } - } - - property String^ host - { - String^ get() - { - return hostName; - } - - void set(String^ host) - { - hostName = host; - } - } - }; - - // Record the IPs in the state object for later use. - static void GetHostEntryCallback(IAsyncResult^ ar) - { - ResolveState^ ioContext = (ResolveState^)(ar->AsyncState); - - ioContext->IPs = Dns::EndGetHostEntry(ar); - GetHostEntryFinished->Set(); - } - - - // Determine the Internet Protocol(IP) addresses for this - // host asynchronously. -public: - static void DoGetHostEntryAsync(String^ hostName) - { - GetHostEntryFinished->Reset(); - ResolveState^ ioContext = gcnew ResolveState(hostName); - - Dns::BeginGetHostEntry(ioContext->host, - gcnew AsyncCallback(GetHostEntryCallback), ioContext); - // Wait here until the resolve completes - // (the callback calls .Set()) - GetHostEntryFinished->WaitOne(); - - Console::WriteLine("EndGetHostEntry({0}) returns:", ioContext->host); - - for (int i = 0; i < ioContext->IPs->AddressList->Length; i++) - { - Console::WriteLine(" {0}", ioContext->IPs->AddressList[i]->ToString()); - } - -// for each (IPAddress^ address in ioContext->IPs) -// { -// Console::WriteLine("{0} ", address); -// } - } -// -}; - -int main() -{ - DNSChanges::DoGetHostEntry("www.contoso.com"); - DNSChanges::DoGetHostEntry(IPAddress::Parse("127.0.0.1")); - DNSChanges::DoGetHostAddress("www.contoso.com"); - DNSChanges::DoGetHostEntryAsync(""); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp deleted file mode 100644 index 5896e74c960..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp +++ /dev/null @@ -1,120 +0,0 @@ - - -// -// This program contains examples for the following types and methods: -// System::Net::FileWebRequest::GetResponse; -// -// -// -// This program shows how to use the FileWebRequest::GetResponse method -// to read and display the content of a file passed by the user. -// Note. In order for this program to work, the folder containing the test file -// must be shared with its permissions set to allow read access. -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -ref class TestGetResponse -{ -private: - static FileWebResponse^ myFileWebResponse; - static void showUsage() - { - Console::WriteLine( "\nPlease enter file name:" ); - Console::WriteLine( "Usage: cs_getresponse //" ); - Console::WriteLine( "Example: cs_getresponse ndpue/temp/hello.txt" ); - } - - static bool makeFileRequest( String^ fileName ) - { - bool requestOk = false; - try - { - Uri^ myUrl = gcnew Uri( String::Format( "file://{0}", fileName ) ); - - // Create a Filewebrequest object using the passed Uri. - FileWebRequest^ myFileWebRequest = dynamic_cast(WebRequest::Create( myUrl )); - - // Get the FileWebResponse object. - myFileWebResponse = dynamic_cast(myFileWebRequest->GetResponse()); - requestOk = true; - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatWebException: {0}", e->Message ); - } - - return requestOk; - } - - static void readFile() - { - try - { - - // Create the file stream. - Stream^ receiveStream = myFileWebResponse->GetResponseStream(); - - // Create a reader object to read the file content. - StreamReader^ readStream = gcnew StreamReader( receiveStream ); - - // Create a local buffer for a temporary storage of the - // read data. - array^readBuffer = gcnew array(256); - - // Read the first up to 256 bytes. - int count = readStream->Read( readBuffer, 0, 256 ); - Console::WriteLine( "The file content is:" ); - Console::WriteLine( "" ); - - // Loop to read the remaining bytes in 256 blocks - // and display the data on the console. - while ( count > 0 ) - { - String^ str = gcnew String( readBuffer,0,count ); - Console::WriteLine( "{0}\n", str ); - count = readStream->Read( readBuffer, 0, 256 ); - } - readStream->Close(); - - // Release the response object resources. - myFileWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatException: {0}", e->Message ); - } - - } - - -public: - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - showUsage(); - else - { - if ( makeFileRequest( args[ 1 ] ) ) - readFile(); - } - } - -}; - -int main() -{ - TestGetResponse::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp deleted file mode 100644 index 0dc5fc9d3fe..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp +++ /dev/null @@ -1,134 +0,0 @@ - - -// -// This program contains examples for the following types and methods: -// System::Net::FileWebRequest (Snippet1); System::Net::FileWebRequest::Method (Snippet2); -// System::Net::FileWebRequest::Timeout (Snippet3); -// System::Net::FileWebRequest::ContentLength (Snippet4). -// System::Net::FileWebRequest::GetRequestStream (Snippet5); -// -// -// This program creates or open a text file in which it stores a string. -// Both file and string are passed by the user. -// Note. In order for this program to work, the folder containing the test file -// must be shared with its permissions set to allow write access. -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Net; -ref class TestGetRequestStream -{ -private: - static FileWebRequest^ myFileWebRequest; - static void showUsage() - { - Console::WriteLine( "\nPlease enter file name and timeout :" ); - Console::WriteLine( "Usage: cs_getrequeststream // timeout" ); - Console::WriteLine( "Example: cs_getrequeststream ndpue/temp/hello.txt 1000" ); - Console::WriteLine( "Small timeout values (for instance 3 or less) cause a timeout exception." ); - } - - static void makeFileRequest( String^ fileName, int timeout ) - { - try - { - - // - // - // Create a Uri object. - Uri^ myUrl = gcnew Uri( String::Format( "file://{0}", fileName ) ); - - // Create a FileWebRequest object. - myFileWebRequest = dynamic_cast(WebRequest::CreateDefault( myUrl )); - - // Set the timeout to the value selected by the user. - myFileWebRequest->Timeout = timeout; - - // - // Set the Method property to POST - myFileWebRequest->Method = "POST"; - - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "UriFormatWebException: {0}", e->Message ); - } - - } - - static void writeToFile() - { - try - { - - // - // Enter the string to write into the file. - Console::WriteLine( "Enter the string you want to write:" ); - String^ userInput = Console::ReadLine(); - - // Convert the string to Byte array. - ASCIIEncoding^ encoder = gcnew ASCIIEncoding; - array^byteArray = encoder->GetBytes( userInput ); - - // - // Set the ContentLength property. - myFileWebRequest->ContentLength = byteArray->Length; - String^ contentLength = myFileWebRequest->ContentLength.ToString(); - Console::WriteLine( "\nThe content length is {0}.", contentLength ); - - // - // Get the file stream handler to write into the file. - Stream^ readStream = myFileWebRequest->GetRequestStream(); - - // Write to the file stream. - // Note. In order for this to work the file must be accessible - // on the network. This can be accomplished by setting the property - // sharing of the folder containg the file. The permissions - // can be set so everyone can modify the file. - // FileWebRequest::Credentials property cannot be used for this purpose. - readStream->Write( byteArray, 0, userInput->Length ); - Console::WriteLine( "\nThe String you entered was successfully written into the file." ); - - // - readStream->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The WebException: {0}", e->Message ); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "The UriFormatWebException: {0}", e->Message ); - } - - } - - -public: - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 3 ) - showUsage(); - else - { - makeFileRequest( args[ 1 ], Int32::Parse( args[ 2 ] ) ); - writeToFile(); - } - } - -}; - -int main() -{ - TestGetRequestStream::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp deleted file mode 100644 index 826067e44c3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/** -* File name: ipaddress_none_any_loopback.cs -* Exercise the IPAddress IPv6None, IPv6Any, and IPv6Loopback properties. -* Usage: cs_nal.exe. -**/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// -// This method displays the value of the current host loopback address in -// standard compressed format. -void displayIPv6LoopBackAddress() -{ - try - { - // Get the loopback address. - IPAddress^ loopBack = IPAddress::IPv6Loopback; - - // Transform the loop-back address to a string using the overladed - // ToString() method. Note that the resulting string is in the compact - // form: "::1". - String^ ipv6LoopBack = loopBack->ToString(); - Console::WriteLine( "The IPv6 Loopback address is: {0}", ipv6LoopBack ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6LoopBackAddress] Exception: {0}", e ); - } -} -// - -// -// This method displays the value of the current host's Any address in -// standard compressed format. The Any address is used by the host to enable -// listening to client activities on all the interfaces for a given port. -void displayIPv6AnyAddress() -{ - try - { - // Get the Any address. - IPAddress^ any = IPAddress::IPv6Any; - - // Transform the Any address to a string using the overloaded - // ToString() method. Note that the resulting string is in the compact - // form: "::". - String^ ipv6Any = any->ToString(); - - // Display the Any address. - Console::WriteLine( "The IPv6 Any address is: {0}", ipv6Any ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6AnyAddress] Exception: {0}", e ); - } -} -// - -// -// This method displays the value of the current host's None address in -// standard compressed format. The None address is used by the host to disable -// listening to client activities on all the interfaces. -void displayIPv6NoneAddress() -{ - try - { - // Get the None address. - IPAddress^ none = IPAddress::IPv6None; - - // Transform the None address to a string using the overloaded - // ToString() method. Note that the resulting string is in the compact - // form: "::". - String^ ipv6None = none->ToString(); - - Console::WriteLine( "The IPv6 None address is: {0}", ipv6None ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6NoneAddress] Exception: {0}", e ); - } -} -// - -// -// This function checks whether the passed string represents a loop-back address. -void checkIPv6LoopBackAddress( String^ ipAddress ) -{ - try - { - // Parse the passed String* to obtain the internal address - // representation. - IPAddress^ loopBack = IPAddress::Parse( ipAddress ); - - // Verify that the address is a loopback address. - bool isLoopBack = IPAddress::IsLoopback( loopBack ); - - // Build the message. - String^ msg; - if ( isLoopBack ) - { - msg = " is a loop back address."; - } - else - { - msg = " is not a loop back address."; - } - - // Display the results. - Console::WriteLine( String::Concat( ipAddress, msg ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "->Item[displayIPv6LoopBackAddress] Exception: {0}", e ); - } -} -// - -int main() -{ - // Verify that the current host supports IPv6 and also call WSAStartup. - // If you do not use any IPv6 methods that call WSAStartup, you will get a - // SocketException when using IPv6Loopback, IPv6Any or IPv6None. - - bool ipv6Supported = Socket::SupportsIPv6; - - // Display current host Loopback address. - displayIPv6LoopBackAddress(); - - // Display the current host's Any address. - displayIPv6AnyAddress(); - - // Display the current host's None address. - displayIPv6NoneAddress(); - - // Check that this is a loopback address. - checkIPv6LoopBackAddress( "0::1" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp deleted file mode 100644 index 8c206f281c1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -/* -This program checks whether the specified address is a loopback address. -It invokes the IPAddress Parse method to translate the address -input String* into the correct internal format. -The IP address String* must be in dotted-quad notation for IPv4 or in -colon-hexadecimal notation for IPv6. -*/ -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; - -// This method calls the IPAddress::Parse method to check if the -// passed ipAddress parameter is in the correct format. -// Then it checks whether it represents a loopback address. -// Finally, it displays the results. -void parse( String^ ipAddress ) -{ - String^ loopBack = " is not a loopback address."; - try - { - - // Perform syntax check by parsing the address string entered by the user. - IPAddress^ address = IPAddress::Parse( ipAddress ); - - // Perform semantic check by verifying that the address is a valid IPv4 - // or IPv6 loopback address. - if ( IPAddress::IsLoopback( address ) && address->AddressFamily == AddressFamily::InterNetworkV6 ) - loopBack = String::Concat( " is an IPv6 loopback address whose internal format is: ", address, "." ); - else - if ( IPAddress::IsLoopback( address ) && address->AddressFamily == AddressFamily::InterNetwork ) - loopBack = String::Concat( " is an IPv4 loopback address whose internal format is: ", address, "." ); - - // Display the results. - Console::WriteLine( "Your input address: \" {0} \" {1}", ipAddress, loopBack ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length == 1 ) - { - - // No parameters entered. Display program usage. - Console::WriteLine( "Please enter an IP address." ); - Console::WriteLine( "Usage: >ipaddress_isloopback any IPv4 or IPv6 address." ); - Console::WriteLine( "Example: >ipaddress_isloopback 127.0.0.1" ); - Console::WriteLine( "Example: >ipaddress_isloopback 0:0:0:0:0:0:0:1" ); - } - else - parse( args[ 1 ] ); - - - // Parse the address string entered by the user. -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp deleted file mode 100644 index e6b401756d0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -/* -This program converts a String* containing an IP address, in dotted-quad notation for -IPv4 or in colon-hexadecimal for IPv6, into an instance of the IPAddress class. -Then it uses the overloaded IPAddress ToString method to display the address in -its standard notation. -*/ -// -#using - -using namespace System; -using namespace System::Net; - -// This method calls the IPAddress::Parse method to check the ipAddress -// input string. If the ipAddress argument represents a syntatically correct IPv4 or -// IPv6 address, the method displays the Parse output into quad-notation or -// colon-hexadecimal notation, respectively. Otherwise, it displays an -// error message. -void parse( String^ ipAddress ) -{ - try - { - - // Create an instance of IPAddress for the specified address string (in - // dotted-quad, or colon-hexadecimal notation). - IPAddress^ address = IPAddress::Parse( ipAddress ); - - // Display the address in standard notation. - Console::WriteLine( "Parsing your input string: \"{0}\" produces this address (shown in its standard notation): {1}", ipAddress, address ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( FormatException^ e ) - { - Console::WriteLine( "FormatException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ IPaddress; - if ( args->Length == 1 ) - { - Console::WriteLine( "Please enter an IP address." ); - Console::WriteLine( "Usage: >cs_parse any IPv4 or IPv6 address." ); - Console::WriteLine( "Example: >cs_parse 127.0.0.1" ); - Console::WriteLine( "Example: >cs_parse 0:0:0:0:0:0:0:1" ); - return 0; - } - else - IPaddress = args[ 1 ]; - - - // Get the list of the IPv6 addresses associated with the requested host. - parse( IPaddress ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp deleted file mode 100644 index 8aa6b94aeb4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp +++ /dev/null @@ -1,142 +0,0 @@ - - -// -// File name: ipaddress.cpp -// The snippets contained here apply to: -// 1) System.Net.IPAddress.AddressFamily, snippet3. -// 2) System.Net.IPAddess.ScopeId, snippet3. -// more -// -// -// This program shows how to use the IPAddress class to obtain a server -// IP addressess and related information. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text::RegularExpressions; - -/** -* The IPAddresses method obtains the selected server IP address information. -* It then displays the type of address family supported by the server and its -* IP address in standard and byte format. -**/ -void IPAddresses( String^ server ) -{ - try - { - System::Text::ASCIIEncoding^ ASCII = gcnew System::Text::ASCIIEncoding; - - // Get server related information. - IPHostEntry^ heserver = Dns::GetHostEntry( server ); - - // Loop on the AddressList - System::Collections::IEnumerator^ myEnum = heserver->AddressList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddress^ curAdd = safe_cast(myEnum->Current); - - // - // Display the type of address family supported by the server. If the - // server is IPv6-enabled this value is: InterNetworkV6. If the server - // is also IPv4-enabled there will be an additional value of InterNetwork. - Console::WriteLine( "AddressFamily: {0}", curAdd->AddressFamily ); - - // Display the ScopeId property in case of IPV6 addresses. - if ( curAdd->AddressFamily.ToString() == ProtocolFamily::InterNetworkV6.ToString() ) - Console::WriteLine( "Scope Id: {0}", curAdd->ScopeId ); - // - - // Display the server IP address in the standard format. In - // IPv4 the format will be dotted-quad notation, in IPv6 it will be - // in in colon-hexadecimal notation. - Console::WriteLine( "Address: {0}", curAdd ); - - // Display the server IP address in byte format. - Console::Write( "AddressBytes: " ); - - // - array^bytes = curAdd->GetAddressBytes(); - for ( int i = 0; i < bytes->Length; i++ ) - { - Console::Write( bytes[ i ] ); - - } - // - - Console::WriteLine( "\r\n" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "[DoResolve] Exception: {0}", e ); - } - -} - - -// This IPAddressAdditionalInfo displays additional server address information. -void IPAddressAdditionalInfo() -{ - try - { - // Display the flags that show if the server supports IPv4 or IPv6 - // address schemas. - Console::WriteLine( "\r\nSupportsIPv4: {0}", Socket::SupportsIPv4 ); - Console::WriteLine( "SupportsIPv6: {0}", Socket::SupportsIPv6 ); - if ( Socket::SupportsIPv6 ) - { - // Display the server Any address. This IP address indicates that the server - // should listen for client activity on all network interfaces. - Console::WriteLine( "\r\nIPv6Any: {0}", IPAddress::IPv6Any ); - - // Display the server loopback address. - Console::WriteLine( "IPv6Loopback: {0}", IPAddress::IPv6Loopback ); - - // Used during autoconfiguration first phase. - Console::WriteLine( "IPv6None: {0}", IPAddress::IPv6None ); - Console::WriteLine( "IsLoopback(IPv6Loopback): {0}", IPAddress::IsLoopback( IPAddress::IPv6Loopback ) ); - } - Console::WriteLine( "IsLoopback(Loopback): {0}", IPAddress::IsLoopback( IPAddress::Loopback ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "[IPAddresses] Exception: {0}", e ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ server = nullptr; - - // Define a regular expression to parse user's input. - // This is a security check. It allows only - // alphanumeric input string between 2 to 40 character long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - { - // If no server name is passed as an argument to this program, use the current - // server name as default. - server = Dns::GetHostName(); - Console::WriteLine( "Using current host: {0}", server ); - } - else - { - server = args[ 1 ]; - if ( !(rex->Match(server))->Success ) - { - Console::WriteLine( "Input string format not allowed." ); - return -1; - } - } - - // Get the list of the addresses associated with the requested server. - IPAddresses( server ); - - // Get additional address information. - IPAddressAdditionalInfo(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp deleted file mode 100644 index ddd7bf4588d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp +++ /dev/null @@ -1,230 +0,0 @@ - - -// File name:ipendpoint.cs. -// -// This program contains snippets applicable to the following: -// System.Net.IPEndPoint (Snippet1); -// System.Net.IPEndPoint.IPEndPoint(IPAddress, int) (Snippet2); -// System.Net.IPEndPoint.Address (Snippet3); -// System.Net.IPEndPoint.AddressFamily (Snippet3); -// System.Net.IPEndPoint.Port (Snippet3); -// System.Net.IPEndPoint.Serialize (Snippet4); -// System.Net.IPEndPoint.Create (Snippet5); -// -// -// This example uses the IPEndPoint class and its members to display the home page -// of the server selected by the user. -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text::RegularExpressions; - -// The getPage function gets the server's home page content by -// recreating the server's endpoint from the original serialized endpoint. -// Then it creates a new socket and connects it to the endpoint. -String^ getPage( String^ server, SocketAddress^ socketAddress ) -{ - //Set up variables and string to write to the server. - Encoding^ ASCII = Encoding::ASCII; - String^ Get = String::Format( "GET / HTTP/1.1\r\nHost: {0}\r\nConnection: Close\r\n\r\n", server ); - array^ByteGet = ASCII->GetBytes( Get ); - array^RecvBytes = gcnew array(256); - String^ strRetPage = nullptr; - Socket^ socket = nullptr; - - // - // Recreate the connection endpoint from the serialized information. - IPEndPoint^ endpoint = gcnew IPEndPoint( (__int64)0,0 ); - IPEndPoint^ clonedIPEndPoint = dynamic_cast(endpoint->Create( socketAddress )); - Console::WriteLine( "clonedIPEndPoint: {0}", clonedIPEndPoint ); - // - - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); - try - { - // Create a socket object to establish a connection with the server. - socket = gcnew Socket( endpoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - - // Connect to the cloned end point. - socket->Connect( clonedIPEndPoint ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - if ( socket == nullptr ) - return ("Connection to cloned endpoint failed"); - - // Send request to the server. - socket->Send( ByteGet, ByteGet->Length, static_cast(0) ); - - // Receive the server home page content. - Int32 bytes = socket->Receive( RecvBytes, RecvBytes->Length, static_cast(0) ); - - // Read the first 256 bytes. - strRetPage = String::Format( "Default HTML page on {0}:\r\n", server ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - while ( bytes > 0 ) - { - bytes = socket->Receive( RecvBytes, RecvBytes->Length, static_cast(0) ); - strRetPage = String::Concat( strRetPage, ASCII->GetString( RecvBytes, 0, bytes ) ); - } - - socket->Close(); - return strRetPage; -} - -// -// The serializeEndpoint function serializes the endpoint and returns the -// SocketAddress containing the serialized endpoint data. -SocketAddress^ serializeEndpoint( IPEndPoint^ endpoint ) -{ - // Serialize IPEndPoint details to a SocketAddress instance. - SocketAddress^ socketAddress = endpoint->Serialize(); - - // Display the serialized endpoint information. - Console::WriteLine( "Endpoint.Serialize() : {0}", socketAddress ); - Console::WriteLine( "Socket->Family : {0}", socketAddress->Family ); - Console::WriteLine( "Socket->Size : {0}", socketAddress->Size ); - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); - return socketAddress; -} -// - -// -void displayEndpointInfo( IPEndPoint^ endpoint ) -{ - Console::WriteLine( "Endpoint->Address : {0}", endpoint->Address ); - Console::WriteLine( "Endpoint->AddressFamily : {0}", endpoint->AddressFamily ); - Console::WriteLine( "Endpoint->Port : {0}", endpoint->Port ); - Console::WriteLine( "Endpoint.ToString() : {0}", endpoint ); - Console::WriteLine( "Press any key to continue." ); - Console::ReadLine(); -} -// - -// The serializeEndpoint function determines the server endpoint and then -// serializes it to obtain the related SocketAddress object. -// Note that in the for loop a temporary socket is created to ensure that -// the current IP address format matches the AddressFamily type. -// In fact, in the case of servers supporting both IPv4 and IPv6, an exception -// may arise if an IP address format does not match the address family type. -SocketAddress^ getSocketAddress( String^ server, int port ) -{ - Socket^ tempSocket = nullptr; - IPHostEntry^ host = nullptr; - SocketAddress^ serializedSocketAddress = nullptr; - try - { - // Get the object containing Internet host information. - host = Dns::Resolve( server ); - - // - // Obtain the IP address from the list of IP addresses associated with the server. - System::Collections::IEnumerator^ myEnum = host->AddressList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - IPAddress^ address = safe_cast(myEnum->Current); - IPEndPoint^ endpoint = gcnew IPEndPoint( address,port ); - tempSocket = gcnew Socket( endpoint->AddressFamily,SocketType::Stream,ProtocolType::Tcp ); - tempSocket->Connect( endpoint ); - if ( tempSocket->Connected ) - { - // Display the endpoint information. - displayEndpointInfo( endpoint ); - - // Serialize the endpoint to obtain a SocketAddress object. - serializedSocketAddress = serializeEndpoint( endpoint ); - break; - } - else - continue; - } - // - - // Close the temporary socket. - tempSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - - return serializedSocketAddress; -} - - -// The requestServerHomePage function obtains the server's home page and returns -// its content. -String^ requestServerHomePage( String^ server, int port ) -{ - String^ strRetPage = nullptr; - - // Get a socket address using the specified server and port. - SocketAddress^ socketAddress = getSocketAddress( server, port ); - if ( socketAddress == nullptr ) - strRetPage = "Connection failed"; // Obtain the server's home page content. - else - strRetPage = getPage( server, socketAddress ); - - return strRetPage; -} - - -// Show to the user how to use this program when wrong input parameters are entered. -void showUsage() -{ - Console::WriteLine( "Enter the server name as follows:" ); - Console::WriteLine( "\tcs_ipendpoint servername" ); -} - - -// This is the program entry point. It allows the user to enter -// a server name that is used to locate its current homepage. -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ host = nullptr; - int port = 80; - - // Define a regular expression to parse user's input. - // This is a security check. It allows only - // alphanumeric input string between 2 to 40 character long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - showUsage(); - else - { - String^ message = args[ 1 ]; - if ( (rex->Match(message))->Success ) - { - host = args[ 1 ]; - - // Get the specified server home_page and display its content. - String^ result = requestServerHomePage( host, port ); - Console::WriteLine( result ); - } - else - Console::WriteLine( "Input string format not allowed." ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp deleted file mode 100644 index 1adf2104e7e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp +++ /dev/null @@ -1,203 +0,0 @@ - - -// -// This example shows how to use the ServicePoint and ServicePointManager classes. -// The ServicePointManager class uses the ServicePoint class to manage connections -// to a remote host. The networking classes reuse service points for all -// requests to a given URI. In fact, the same ServicePoint object -// is used to issue requests to Internet resources identified by the same -// scheme identifier (for example, HTTP) and host fragment (for example, www.contoso.com). -// This should improve your application performance. -// Reusing service points in this way can help improve application performance. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Threading; -using namespace System::Text::RegularExpressions; -void ShowProperties( ServicePoint^ sp ) -{ - Console::WriteLine( "Done calling FindServicePoint()..." ); - - // - // Display the ServicePoint Internet resource address. - Console::WriteLine( "Address = {0}", sp->Address ); - - // - // - // Display the date and time that the ServicePoint was last - // connected to a host. - Console::WriteLine( "IdleSince = {0}", sp->IdleSince ); - - // Display the maximum length of time that the ServicePoint instance - // is allowed to maintain an idle connection to an Internet - // resource before it is recycled for use in another connection. - Console::WriteLine( "MaxIdleTime = {0}", sp->MaxIdleTime ); - - // - // - Console::WriteLine( "ConnectionName = {0}", sp->ConnectionName ); - - // Display the maximum number of connections allowed on this - // ServicePoint instance. - Console::WriteLine( "ConnectionLimit = {0}", sp->ConnectionLimit ); - - // Display the number of connections associated with this - // ServicePoint instance. - Console::WriteLine( "CurrentConnections = {0}", sp->CurrentConnections ); - - // - // - if ( sp->Certificate == nullptr ) - Console::WriteLine( "Certificate = (null)" ); - else - Console::WriteLine( "Certificate = {0}", sp->Certificate ); - - if ( sp->ClientCertificate == nullptr ) - Console::WriteLine( "Client Certificate = (null)" ); - else - Console::WriteLine( "Client Certificate = {0}", sp->ClientCertificate ); - - Console::WriteLine( "ProtocolVersion = {0}", sp->ProtocolVersion->ToString() ); - Console::WriteLine( "SupportsPipelining = {0}", sp->SupportsPipelining ); - - // - // - Console::WriteLine( "UseNagleAlgorithm = {0} ", sp->UseNagleAlgorithm.ToString() ); - Console::WriteLine( "Expect 100-continue = {0}", sp->Expect100Continue.ToString() ); - - // -} - - -// -void makeWebRequest( int hashCode, String^ Uri ) -{ - HttpWebResponse^ res = nullptr; - - // Make sure that the idle time has elapsed, so that a new - // ServicePoint instance is created. - Console::WriteLine( "Sleeping for 2 sec." ); - Thread::Sleep( 2000 ); - try - { - - // Create a request to the passed URI. - HttpWebRequest^ req = dynamic_cast(WebRequest::Create( Uri )); - Console::WriteLine( "\nConnecting to {0} ............", Uri ); - - // Get the response object. - res = dynamic_cast(req->GetResponse()); - Console::WriteLine( "Connected.\n" ); - ServicePoint^ currentServicePoint = req->ServicePoint; - - // Display new service point properties. - int currentHashCode = currentServicePoint->GetHashCode(); - Console::WriteLine( "New service point hashcode: {0}", currentHashCode ); - Console::WriteLine( "New service point max idle time: {0}", currentServicePoint->MaxIdleTime ); - Console::WriteLine( "New service point is idle since {0}", currentServicePoint->IdleSince ); - - // Check that a new ServicePoint instance has been created. - if ( hashCode == currentHashCode ) - Console::WriteLine( "Service point reused." ); - else - Console::WriteLine( "A new service point created." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - finally - { - if ( res != nullptr ) - res->Close(); - } - -} - - -// -// Show the user how to use this program when wrong inputs are entered. -void showUsage() -{ - Console::WriteLine( "Enter the proxy name as follows:" ); - Console::WriteLine( "\tcs_servicepoint proxyName" ); -} - - -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - int port = 80; - - // Define a regular expression to parse the user's input. - // This is a security check. It allows only - // alphanumeric input strings between 2 to 40 characters long. - Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" ); - if ( args->Length < 2 ) - { - showUsage(); - return -1; - } - - String^ proxy = args[ 1 ]; - if ( (!rex->Match(proxy))->Success) - { - Console::WriteLine( "Input string format not allowed." ); - return -1; - } - - String^ proxyAdd = String::Format( "http://{0}:{1}", proxy, port ); - - // Create a proxy object. - WebProxy^ DefaultProxy = gcnew WebProxy( proxyAdd,true ); - - // Set the proxy that all HttpWebRequest instances use. - WebRequest::DefaultWebProxy = DefaultProxy; - - // Get the base interface for proxy access for the - // WebRequest-based classes. - IWebProxy^ Iproxy = WebRequest::DefaultWebProxy; - - - // - // Set the maximum number of ServicePoint instances to - // maintain. If a ServicePoint instance for that host already - // exists when your application requests a connection to - // an Internet resource, the ServicePointManager object - // returns this existing ServicePoint instance. If none exists - // for that host, it creates a new ServicePoint instance. - ServicePointManager::MaxServicePoints = 4; - - // Set the maximum idle time of a ServicePoint instance to 10 seconds. - // After the idle time expires, the ServicePoint object is eligible for - // garbage collection and cannot be used by the ServicePointManager. - ServicePointManager::MaxServicePointIdleTime = 10000; - - // - // - ServicePointManager::UseNagleAlgorithm = true; - ServicePointManager::Expect100Continue = true; - ServicePointManager::CheckCertificateRevocationList = true; - ServicePointManager::DefaultConnectionLimit = ServicePointManager::DefaultPersistentConnectionLimit; - - // - // Create the Uri object for the resource you want to access. - Uri^ MS = gcnew Uri( "http://msdn.microsoft.com/" ); - - // Use the FindServicePoint method to find an existing - // ServicePoint object or to create a new one. - ServicePoint^ servicePoint = ServicePointManager::FindServicePoint( MS, Iproxy ); - ShowProperties( servicePoint ); - int hashCode = servicePoint->GetHashCode(); - Console::WriteLine( "Service point hashcode: {0}", hashCode ); - - // Make a request with the same scheme identifier and host fragment - // used to create the previous ServicePoint object. - makeWebRequest( hashCode, "http://msdn.microsoft.com/library/" ); -} - -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp deleted file mode 100644 index 71b43149394..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// This example shows how to use the ServicePoint and ServicePointManager classes. -// The ServicePointManager class uses the ServicePoint class to manage connections -// to a remote host. The networking classes reuse service points for all -// requests to a given URI. In fact, the same ServicePoint object -// is used to issue requests to Internet resources identified by the same -// scheme identifier (for example, HTTP) and host fragment (for example, www.contoso.com). -// This should improve your application performance. -// Reusing service points in this way can help improve application performance. -#using - -using namespace System; -using namespace System::Security; -using namespace System::Net; -using namespace System::Threading; -using namespace System::Text::RegularExpressions; - -void ShowProperties(ServicePoint^ service) -{ - Console::WriteLine("Done calling FindServicePoint()..."); - - // Display the ServicePoint Internet resource address. - Console::WriteLine("Address = {0} ", service->Address); - - // Display the date and time that the ServicePoint was last - // connected to a host. - Console::WriteLine("IdleSince = {0}", service->IdleSince); - - // Display the maximum length of time that the ServicePoint - // instance is allowed to maintain an idle connection to an - // Internet resource before it is recycled for use in another - // connection. - Console::WriteLine("MaxIdleTime = {0}", service->MaxIdleTime); - - Console::WriteLine("ConnectionName = {0}", - service->ConnectionName); - - // Display the maximum number of connections allowed on this - // ServicePoint instance. - Console::WriteLine("ConnectionLimit = {0}", - service->ConnectionLimit); - - // Display the number of connections associated with this - // ServicePoint instance. - Console::WriteLine("CurrentConnections = {0}", - service->CurrentConnections); - - if (service->Certificate == nullptr) - { - Console::WriteLine("Certificate = (null)"); - } - else - { - Console::WriteLine("Certificate = {0}", service->Certificate); - } - - if (service->ClientCertificate == nullptr) - { - Console::WriteLine("ClientCertificate = (null)"); - } - else - { - Console:: WriteLine("ClientCertificate = {0}", - service->ClientCertificate); - } - - Console::WriteLine("ProtocolVersion = {0}", - service->ProtocolVersion); - Console::WriteLine("SupportsPipelining = {0}", - service->SupportsPipelining); - - Console::WriteLine("UseNagleAlgorithm = {0}", - service->UseNagleAlgorithm.ToString()); - Console::WriteLine("Expect 100-continue = {0}", - service->Expect100Continue.ToString()); -} - -void MakeWebRequest(int hashCode, String^ requestedUri) -{ - HttpWebResponse^ response = nullptr; - - // Make sure that the idle time has elapsed, so that a new - // ServicePoint instance is created. - Console::WriteLine("Sleeping for 2 sec."); - Thread::Sleep(2000); - try - { - // Create a request to the passed URI. - HttpWebRequest^ request = - (HttpWebRequest^)WebRequest::Create(requestedUri); - - Console::WriteLine("\nConnecting to {0} ............", - requestedUri); - - // Get the response object. - response = (HttpWebResponse^) request->GetResponse(); - Console::WriteLine("Connected.\n"); - - ServicePoint^ currentServicePoint = request->ServicePoint; - - // Display new service point properties. - int currentHashCode = currentServicePoint->GetHashCode(); - - Console::WriteLine("New service point hashcode: {0}", - currentHashCode); - Console::WriteLine("New service point max idle time: {0}", - currentServicePoint->MaxIdleTime); - Console::WriteLine("New service point is idle since {0}", - currentServicePoint->IdleSince ); - - // Check that a new ServicePoint instance has been created. - if (hashCode == currentHashCode) - { - Console::WriteLine("Service point reused."); - } - else - { - Console::WriteLine("A new service point created.") ; - } - - } - catch (NotSupportedException^ ex) - { - Console::WriteLine( - "The request scheme specified in {0} has not been registered.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (SecurityException^ ex) - { - Console::WriteLine( - "You do not have permission to connect to {0}.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (UriFormatException^ ex) - { - Console::WriteLine( - "The URI specified in {0} is not a valid URI.", - requestedUri); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - catch (WebException^ ex) - { - Console::WriteLine("The proxy name could not be resolved."); - Console::WriteLine("Source : {0}", ex->Source); - Console::WriteLine("Message : {0}", ex->Message); - } - finally - { - if (response != nullptr) - { - response->Close(); - } - } -} - -// Show the user how to use this program when wrong inputs are entered. -void ShowUsage() -{ - Console::WriteLine("Enter the proxy name as follows:"); - Console::WriteLine("\tcs_servicepoint proxyName"); -} - - -int main(array^ args) -{ - int port = 80; - - // Define a regular expression to parse the user's input. - // This is a security check. It allows only - // alphanumeric input strings between 2 to 40 characters long. - Regex^ expression = gcnew Regex("^[a-zA-Z]\\w{1,39}$"); - - if (args->Length <= 1) - { - ShowUsage(); - return 0; - } - String^ proxy = args[1]; - - if (!(expression->Match(proxy))->Success) - { - Console::WriteLine("Input string format not allowed."); - return 0; - } - String^ proxyAddress = "http://" + proxy + ":" + port; - - // Create a proxy object. - WebProxy^ defaultProxy = gcnew WebProxy(proxyAddress, true); - - // Set the proxy that all HttpWebRequest instances use. - GlobalProxySelection::Select = (IWebProxy^)defaultProxy; - - // Get the base interface for proxy access for the - // WebRequest-based classes. - IWebProxy^ proxyInterface = GlobalProxySelection::Select; - - // Set the maximum number of ServicePoint instances to - // maintain. If a ServicePoint instance for that host already - // exists when your application requests a connection to - // an Internet resource, the ServicePointManager object - // returns this existing ServicePoint instance. If none exists - // for that host, it creates a new ServicePoint instance. - ServicePointManager::MaxServicePoints = 4; - - // Set the maximum idle time of a ServicePoint instance to 10 seconds. - // After the idle time expires, the ServicePoint object is eligible for - // garbage collection and cannot be used by the ServicePointManager object. - ServicePointManager::MaxServicePointIdleTime = 10000; - - // - ServicePointManager::UseNagleAlgorithm = true; - ServicePointManager::Expect100Continue = true; - ServicePointManager::CheckCertificateRevocationList = true; - ServicePointManager::DefaultConnectionLimit = - ServicePointManager::DefaultPersistentConnectionLimit; - ServicePointManager::EnableDnsRoundRobin = true; - ServicePointManager::DnsRefreshTimeout = 4*60*1000; // 4 minutes - // - // Create the Uri object for the resource you want to access. - Uri^ msdn = gcnew Uri("http://msdn.microsoft.com/"); - - // Use the FindServicePoint method to find an existing - // ServicePoint object or to create a new one. - ServicePoint^ servicePoint = ServicePointManager::FindServicePoint( - msdn, proxyInterface); - - ShowProperties(servicePoint); - - int hashCode = servicePoint->GetHashCode(); - - Console::WriteLine("Service point hashcode: {0}", hashCode); - - // Make a request with the same scheme identifier and host fragment - // used to create the previous ServicePoint object. - MakeWebRequest(hashCode, "http://msdn.microsoft.com/library/"); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp deleted file mode 100644 index b9d8ca6d7bb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp +++ /dev/null @@ -1,344 +0,0 @@ - - -// This program shows how to create your own Basic authentication module, -// register it via the AuthenticationManager class and authorize allowed -// users to access a page on a Web site. -// Note: In order to run this program you must create a test Web site that performs -// Basic authentication. Also you must add to your server machine a user whose -// credentials are the same you plan to use for this example. -// CAVEAT: Basic authenticastion sends the user's credentials over HTTP. Passwords and -// user names are encoded using Base64 encoding. Although the password is encoded, it -// is considered insecure due its ability to be deciphered relatively easily. -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Collections; - -// -// The CustomBasic class creates a custom Basic authentication by implementing the -// IAuthenticationModule interface. In particular it performs the following -// tasks: -// 1) Defines and intializes the required properties. -// 2) Impements the Authenticate and PreAuthenticate methods. -public ref class CustomBasic: public IAuthenticationModule -{ -private: - - // - String^ m_authenticationType; - bool m_canPreAuthenticate; - -public: - - // The CustomBasic constructor initializes the properties of the customized - // authentication. - CustomBasic() - { - m_authenticationType = "Basic"; - m_canPreAuthenticate = false; - } - - - property String^ AuthenticationType - { - - // Define the authentication type. This type is then used to identify this - // custom authentication module. The default is set to Basic. - virtual String^ get() - { - return m_authenticationType; - } - - } - - property bool CanPreAuthenticate - { - - // Define the pre-authentication capabilities for the module. The default is set - // to false. - virtual bool get() - { - return m_canPreAuthenticate; - } - - } - - // - // The checkChallenge method checks if the challenge sent by the HttpWebRequest - // contains the correct type (Basic) and the correct domain name. - // Note: the challenge is in the form BASIC REALM="DOMAINNAME" - // and you must assure that the Internet Web site resides on a server whose - // domain name is equal to DOMAINAME. - bool checkChallenge( String^ Challenge, String^ domain ) - { - bool challengePasses = false; - String^ tempChallenge = Challenge->ToUpper(); - - // Verify that this is a Basic authorization request and the requested domain - // is correct. - // Note: When the domain is an empty string the following code only checks - // whether the authorization type is Basic. - if ( tempChallenge->IndexOf( "BASIC" ) != -1 ) - if ( domain != String::Empty ) - if ( tempChallenge->IndexOf( domain->ToUpper() ) != -1 ) - challengePasses = true; // The domain is not allowed and the authorization type is Basic. - else - challengePasses = false; - - else - challengePasses = true; - - - return challengePasses; - } - - - // - // The PreAuthenticate method specifies if the authentication implemented - // by this class allows pre-authentication. - // Even if you do not use it, this method must be implemented to obey to the rules - // of interface implemebtation. - // In this case it always returns false. - virtual Authorization^ PreAuthenticate( WebRequest^ /*request*/, ICredentials^ /*credentials*/ ) - { - return nullptr; - } - - - // - // - // Authenticate is the core method for this custom authentication. - // When an internet resource requests authentication, the WebRequest.GetResponse - // method calls the AuthenticationManager.Authenticate method. This method, in - // turn, calls the Authenticate method on each of the registered authentication - // modules, in the order they were registered. When the authentication is - // complete an Authorization object is returned to the WebRequest, as the - // retunr type of the following routine shows. - virtual Authorization^ Authenticate( String^ challenge, WebRequest^ request, ICredentials^ credentials ) - { - Encoding^ ASCII = Encoding::ASCII; - - // Get the username and password from the credentials - NetworkCredential^ MyCreds = credentials->GetCredential( request->RequestUri, "Basic" ); - if ( PreAuthenticate( request, credentials ) == nullptr ) - Console::WriteLine( "\n Pre-authentication is not allowed." ); - else - Console::WriteLine( "\n Pre-authentication is allowed." ); - - - // Verify that the challenge satisfies the authorization requirements. - bool challengeOk = checkChallenge( challenge, MyCreds->Domain ); - if ( !challengeOk ) - return nullptr; - - - // - // Create the encrypted string according to the Basic authentication format as - // follows: - // a)Concatenate username and password seperated by colon; - // b)Apply ASCII encoding to obtain a stream of bytes; - // c)Apply Base64 Encoding to this array of bytes to obtain the encoded - // authorization. - String^ BasicEncrypt = String::Concat( MyCreds->UserName, ":", MyCreds->Password ); - String^ BasicToken = String::Format( "Basic {0}", Convert::ToBase64String( ASCII->GetBytes( BasicEncrypt ) ) ); - - // Create an Authorization object using the above encoded authorization. - Authorization^ resourceAuthorization = gcnew Authorization( BasicToken ); - - // Get the Message property which contains the authorization string that the - // client returns to the server when accessing protected resources. - Console::WriteLine( "\n Authorization Message:{0}", resourceAuthorization->Message ); - - // Get the Complete property which is set to true when the authentication process - // between the client and the server is finished. - Console::WriteLine( "\n Authorization Complete:{0}", resourceAuthorization->Complete ); - Console::WriteLine( "\n Authorization ConnectionGroupId:{0}", resourceAuthorization->ConnectionGroupId ); - - // - return resourceAuthorization; - } - - // -}; - - -// -// The ClientAuthentication performs the following main tasks: -// 1) It obtains the user's credentials. -// 2) Unregisters the standard Basic authentication. -// 3) Registers the customized Basic authentication. -// 4) Read the selected page and displays it on the console. -ref class ClientAuthentication -{ -private: - static String^ username; - static String^ password; - static String^ domain; - static String^ uri; - - // Show how to use this program. - static void showusage() - { - Console::WriteLine( "Attempts to authenticate to a URL" ); - Console::WriteLine( "\r\nUse one of the following:" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password domain" ); - Console::WriteLine( "\tcustomBasicAuthentication URL username password" ); - Console::WriteLine( "\r\nExample:" ); - Console::WriteLine( "\tcustomBasicAuthentication http://ndpue/ncl/ basicuser basic.101 ndpue" ); - } - - - // - // Display registered authentication modules. - static void displayRegisteredModules() - { - - // The AuthenticationManager calls all authentication modules sequentially - // until one of them responds with an authorization instance. Show - // the current registered modules, for testing purposes. - IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules; - Console::WriteLine( "\r\nThe following authentication modules are now registered with the system" ); - while ( registeredModules->MoveNext() ) - { - Console::WriteLine( "\r \n Module : {0}", registeredModules->Current ); - IAuthenticationModule^ currentAuthenticationModule = dynamic_cast(registeredModules->Current); - Console::WriteLine( "\t CanPreAuthenticate : {0}", currentAuthenticationModule->CanPreAuthenticate ); - } - } - - - // - // The getPage method accesses the selected page an displays its content - // on the console. - static void getPage( String^ url ) - { - try - { - - // Create the Web request object. - WebRequest^ req = dynamic_cast(WebRequest::Create( url )); - - // Define the request access method. - req->Method = "GET"; - - // Define the request credentials according to the user's input. - if ( domain == String::Empty ) - req->Credentials = gcnew NetworkCredential( username,password ); // If the user's specifies the Internet resource domain, this usually - else - req->Credentials = gcnew NetworkCredential( username,password,domain ); - - // is by default the name of the sever hosting the resource. - // Issue the request. - WebResponse^ result = req->GetResponse(); - Console::WriteLine( "\nAuthentication Succeeded:" ); - - // Store the response. - Stream^ sData = result->GetResponseStream(); - - // Display the response. - displayPageContent( sData ); - } - catch ( WebException^ e ) - { - - // Display the error, if any. In particular display protocol - // related error. - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - HttpWebResponse^ hresp = dynamic_cast(e->Response); - Console::WriteLine( "\nAuthentication Failed, {0}", hresp->StatusCode ); - Console::WriteLine( "Status Code: {0}", (int)hresp->StatusCode ); - Console::WriteLine( "Status Description: {0}", hresp->StatusDescription ); - return; - } - Console::WriteLine( "Caught Exception: {0}", e->Message ); - Console::WriteLine( "Stack: {0}", e->StackTrace ); - } - - } - - - // The displayPageContent method display the content of the - // selected page. - static void displayPageContent( Stream^ ReceiveStream ) - { - - // Create an ASCII encoding object. - Encoding^ ASCII = Encoding::ASCII; - - // Define the byte array to temporary hold the current read bytes. - array^read = gcnew array(512); - Console::WriteLine( "\r\nPage Content...\r\n" ); - - // Read the page content and display it on the console. - // Read the first 512 bytes. - int bytes = ReceiveStream->Read( read, 0, 512 ); - while ( bytes > 0 ) - { - Console::Write( ASCII->GetString( read, 0, bytes ) ); - bytes = ReceiveStream->Read( read, 0, 512 ); - } - - Console::WriteLine( "" ); - } - - -public: - - // - // This is the program entry point. It allows the user to enter - // her credentials and the Internet resource (Web page) to access. - // It also unregisters the standard and registers the customized basic - // authentication. - static void Main() - { - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 4 ) - showusage(); - else - { - - // Read the user's credentials. - uri = args[ 1 ]; - username = args[ 2 ]; - password = args[ 3 ]; - if ( args->Length == 4 ) - domain = String::Empty; // If the domain exists, store it. Usually the domain name - else - domain = args[ 4 ]; - - - // is by default the name of the server hosting the Internet - // resource. - // Unregister the standard Basic authentication module. - AuthenticationManager::Unregister( "Basic" ); - - // Instantiate the custom Basic authentication module. - CustomBasic^ customBasicModule = gcnew CustomBasic; - - // Register the custom Basic authentication module. - AuthenticationManager::Register( customBasicModule ); - - // Display registered Authorization modules. - displayRegisteredModules(); - - // Read the specified page and display it on the console. - getPage( uri ); - } - - return; - } - - // -}; - -int main() -{ - ClientAuthentication::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp deleted file mode 100644 index 344dc6ed2a9..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp +++ /dev/null @@ -1,130 +0,0 @@ - - -// -// This program contains snippets for the following members: -// 1) System::Net::Sockets::MulticastOption; -// 2) System::Net::Sockets::MulticastOption.MulticastOption(IPAddress, IPAddress); -// 3) System::Net::Sockets::MulticastOption.Group; -// 4) System::Net::Sockets::MulticastOption.LocalAddress; -// -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -// This program shows how to use the MultiCastOption type. In particular, -// it shows how to use the MultiCastOption(IPAddress, IPAddress) constructor, -// You need to use this constructor, in the case of multihomed host (i.e., -// a host with more than one network card). With the first parameter you -// specify the multicast group address, with the second you specify the -// local address of one of the network cards you want to use for the data -// exchange. -// You must run this program in conjunction with the sender program as -// follows: -// Open a console window and run the listener from the command line. -// In another console window run the sender. In both cases you must specify -// the local IPAddress to use. To obtain this address run the ipconfig from -// the command line. -// -public ref class TestMulticastOption -{ -private: - static IPAddress^ mcastAddress; - static int mcastPort; - static Socket^ mcastSocket; - static MulticastOption^ mcastOption; - - // - static void MulticastOptionProperties() - { - Console::WriteLine( "Current multicast group is: {0}", mcastOption->Group ); - Console::WriteLine( "Current multicast local address is: {0}", mcastOption->LocalAddress ); - } - - - // - static void StartMulticast() - { - try - { - mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp ); - Console::Write( "Enter the local IP Address: " ); - IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() ); - - //IPAddress localIP = IPAddress::Any; - EndPoint^ localEP = dynamic_cast(gcnew IPEndPoint( localIPAddr,mcastPort )); - mcastSocket->Bind( localEP ); - - // - // Define a MuticastOption object specifying the multicast group - // address and the local IPAddress. - // The multicast group address is the same one used by the server. - mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr ); - mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership, mcastOption ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - - } - - static void ReceiveBrodcastMessages() - { - bool done = false; - array^bytes = gcnew array(100); - IPEndPoint^ groupEP = gcnew IPEndPoint( mcastAddress,mcastPort ); - EndPoint^ remoteEP = dynamic_cast(gcnew IPEndPoint( IPAddress::Any,0 )); - try - { - while ( !done ) - { - Console::WriteLine( "Waiting for Multicast packets......." ); - Console::WriteLine( "Enter ^C to terminate." ); - mcastSocket->ReceiveFrom( bytes, remoteEP ); - Console::WriteLine( "Received broadcast from {0} :\n {1}\n", groupEP, Encoding::ASCII->GetString( bytes, 0, bytes->Length ) ); - } - mcastSocket->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - - } - - -public: - static void Main() - { - - // Initialize multicast address group and multicast port. - // Both address and port are selected from the allowed sets as - // defined in the related RFC documents. These are the same values - // used by the sender. - mcastAddress = IPAddress::Parse( "224.168.100.2" ); - mcastPort = 11000; - - // Start a multicast group. - StartMulticast(); - - // Display multicast option properties. - MulticastOptionProperties(); - - // Receive brodcast messages. - ReceiveBrodcastMessages(); - } - -}; - -int main() -{ - TestMulticastOption::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp deleted file mode 100644 index 9b92d3984aa..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -// This program contains snippets for the following members: -// 1) System::Net::Sockets::MulticastOption; -// -// -#using - -using namespace System; -using namespace System::Net::Sockets; -using namespace System::Net; -using namespace System::Text; - -// This is an auxiliary program to be used in conjunction with a listener -// program. -// You must run this program as follows: -// Open a console window and run the listener from the command line. -// In another console window run the sender. In both cases you must specify -// the local IPAddress to use. To obtain this address run the ipconfig -// from the command line. -// -ref class TestMulticastOption -{ -private: - static IPAddress^ mcastAddress; - static int mcastPort; - static Socket^ mcastSocket; - static void JoinMulticast() - { - try - { - - // Create multicast socket. - mcastSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp ); - - // Get the local IP address used by the listener and the sender to - // exchange data in a multicast fashion. - Console::Write( "\nEnter local IPAddress for sending multicast packets: " ); - IPAddress^ localIPAddr = IPAddress::Parse( Console::ReadLine() ); - - // Create an IPEndPoint Object*. - IPEndPoint^ IPlocal = gcnew IPEndPoint( localIPAddr,0 ); - - // Bind this end point to the multicast socket. - mcastSocket->Bind( IPlocal ); - - // Define a MuticastOption Object* specifying the multicast group - // address and the local IPAddress. - // The multicast group address is the same one used by the listener. - MulticastOption^ mcastOption; - mcastOption = gcnew MulticastOption( mcastAddress,localIPAddr ); - mcastSocket->SetSocketOption( SocketOptionLevel::IP, SocketOptionName::AddMembership, mcastOption ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n {0}", e ); - } - - } - - static void BrodcastMessage( String^ message ) - { - IPEndPoint^ endPoint; - try - { - - //Send multicast packets to the listener. - endPoint = gcnew IPEndPoint( mcastAddress,mcastPort ); - mcastSocket->SendTo( ASCIIEncoding::ASCII->GetBytes( message ), endPoint ); - Console::WriteLine( "Multicast data sent....." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n {0}", e ); - } - - mcastSocket->Close(); - } - - -public: - static void main() - { - - // Initialize multicast address group and multicast port. - // Both address and port are selected from the allowed sets as - // defined in the related RFC documents. These are the same values - // used by the sender. - mcastAddress = IPAddress::Parse( "224.168.100.2" ); - mcastPort = 11000; - - // Join the listener multicast group. - JoinMulticast(); - - // Broadcast message to the listener. - BrodcastMessage( "Hello multicast listener." ); - } - -}; - -int main() -{ - TestMulticastOption::main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp deleted file mode 100644 index 4b21fa80e2a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp +++ /dev/null @@ -1,128 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; -ref class ConnectTester -{ -public: - - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - - // handles the completion of the prior asynchronous - // connect call. the socket is passed via the objectState - // paramater of BeginConnect(). - static void ConnectCallback1( IAsyncResult^ ar ) - { - allDone->Set(); - Socket^ s = dynamic_cast(ar->AsyncState); - s->EndConnect( ar ); - } - - // Asynchronous connect using the host name, resolved via - // IPAddress - static void BeginConnect1( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( IPs[ 0 ], port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. - // The callback sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - // Asynchronous connect, using DNS.ResolveToAddresses - static void BeginConnect2( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( IPs, port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. The callback - // sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - // Asynchronous connect using host name (resolved by the - // BeginConnect call.) - static void BeginConnect3( String^ host, int port ) - { - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - allDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->BeginConnect( host, port, gcnew AsyncCallback( ConnectCallback1 ), s ); - - // wait here until the connect finishes. The callback - // sets allDone. - allDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - // - // Synchronous connect using IPAddress to resolve the - // host name. - static void Connect1( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( IPs[ 0 ], port ); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Synchronous connect using Dns.ResolveToAddresses to - // resolve the host name. - static void Connect2( String^ host, int port ) - { - array^IPs = Dns::GetHostAddresses( host ); - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( IPs, port ); - Console::WriteLine( "Connection established" ); - } - - - // - // - // Synchronous connect using host name (resolved by the - // Connect call.) - static void Connect3( String^ host, int port ) - { - Socket^ s = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - Console::WriteLine( "Establishing Connection to {0}", host ); - s->Connect( host, port ); - Console::WriteLine( "Connection established" ); - } - - // -}; - - -[STAThread] -int main() -{ - ConnectTester::BeginConnect1( "127.0.0.1", 80 ); - ConnectTester::BeginConnect2( "localhost", 80 ); - ConnectTester::BeginConnect3( "localhost", 80 ); - ConnectTester::Connect1( "127.0.0.1", 80 ); - ConnectTester::Connect2( "127.0.0.1", 80 ); - ConnectTester::Connect3( "localhost", 80 ); - Console::WriteLine( "hit any key" ); - Console::Read(); -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp deleted file mode 100644 index b06fa3e3760..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -namespace SocketExample -{ - ref class TestClass - { - public: - - static void SyncSendAndReceive(String^ host, int port) - { - // - Encoding^ asciiEncoding = Encoding::ASCII; - - // Create the TCP Socket. - IPHostEntry^ hostEntry = Dns::Resolve(host); - IPEndPoint^ endPoint = gcnew IPEndPoint( - hostEntry->AddressList[0], port); - - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp); - - tcpSocket->Connect(endPoint); - - // Build the buffers to be sent. - List >^ buffers = - gcnew List >(2); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - // Send the data. - tcpSocket->Send(buffers); - // - - // - - // Build the buffers for the receive. - List >^ receiveBuffers = - gcnew List >(2); - - array^ bigBuffer = gcnew array(1024); - - // Specify the first buffer segment (2 bytes, starting - // at the 4th element of bigBuffer) - receiveBuffers->Add(ArraySegment(bigBuffer, 4, 2)); - - // Specify the second buffer segment (500 bytes, starting - // at the 20th element of bigBuffer) - receiveBuffers->Add( - ArraySegment(bigBuffer, 20, 500)); - - tcpSocket->Receive(receiveBuffers); - - Console::WriteLine("{0}", - asciiEncoding->GetString(bigBuffer)); - // - } - - static void AsyncSendAndReceive(String^ host, int port) - { - // - Encoding^ asciiEncoding = Encoding::ASCII; - - // Create the TCP Socket. - IPHostEntry^ hostEntry = Dns::Resolve(host); - IPEndPoint^ endPoint = gcnew IPEndPoint( - hostEntry->AddressList[0], port); - - Socket^ tcpSocket = gcnew Socket( - AddressFamily::InterNetwork, SocketType::Stream, - ProtocolType::Tcp); - - tcpSocket->Connect(endPoint); - - // Build the buffers to be sent. - List >^ buffers = - gcnew List >(2); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - buffers->Add(ArraySegment( - asciiEncoding->GetBytes(""))); - - // Create delegate instance for the callback function - AsyncCallback^ sendCallback = - gcnew AsyncCallback(SendCallback); - - // Send the data. - allDone->Reset(); - tcpSocket->BeginSend(buffers, SocketFlags::None, - sendCallback, (Object^)tcpSocket); - allDone->WaitOne(); - - // done - Console::WriteLine("Data sent"); - // - - // - - // Build the buffers for the receive. - List >^ receiveBuffers = - gcnew List >(2); - - array^ bigBuffer = gcnew array(1024); - - // Specify the first buffer segment (2 bytes, starting - // at the 6th element of bigBuffer) - receiveBuffers->Add(ArraySegment(bigBuffer, 6, 2)); - - // Specify the second buffer segment (500 bytes, starting - // at the 10th element of bigBuffer) - receiveBuffers->Add( - ArraySegment(bigBuffer, 10, 500)); - - // Create delegate instance for the callback function - AsyncCallback^ receiveCallback = - gcnew AsyncCallback(ReceiveCallback); - - // Receive the data. - allDone->Reset(); - tcpSocket->BeginReceive( - receiveBuffers, SocketFlags::None, - receiveCallback, (Object^)tcpSocket); - - allDone->WaitOne(); - - Console::WriteLine("Data received:"); - Console::WriteLine("{0}", - asciiEncoding->GetString(bigBuffer)); - // - } - - private: - - static ManualResetEvent^ allDone = - gcnew ManualResetEvent(false); - - static void SendCallback(IAsyncResult^ result) - { - allDone->Set(); - Socket^ sendSocket = (Socket^)result->AsyncState; - sendSocket->EndSend(result); - } - - static void ReceiveCallback(IAsyncResult^ result) - { - allDone->Set(); - Socket^ receiveSocket = (Socket^)result->AsyncState; - receiveSocket->EndReceive(result); - } - }; -} - -int main() -{ - Console::WriteLine("starting synchronous test"); - SocketExample::TestClass::SyncSendAndReceive("localhost", 80); - Console::WriteLine("starting asynchronous test"); - SocketExample::TestClass::AsyncSendAndReceive("localhost", 80); - Console::WriteLine("ending tests"); - - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp deleted file mode 100644 index 93746826f75..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// System.Net.Sockets.TcpClient main functionality. - -/** -* This program shows how to use the TcpClient -* It creates a TcpClient that connects to a TcpServer listening on the specified port -* (13000). When connecting to the server it forwards a message, as specified in -* the input parameter. -* To run this program at the command line you enter: -* cs_tcpclient serverName S"My message" -* Where the serverName is the name on which the server is running. -* For this program to work you need to have the TcpServer running in another -* console window. -* To avoid permission settings you can run this console application and the related -* TcpServer from your hard disk and not from a shared location on the network. -**/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Security::Permissions; - -/** -* The following function creates a TcpClient that connects to a -* TcpServer listening on the specified port (13000). -* When connecting to the server it forwards a message, as specified in -* the input parameter. -**/ -// -void Connect( String^ server, String^ message ) -{ - TcpClient^ client = nullptr; - try - { - // Create a TcpClient. - // Note, for this client to work you need to have a TcpServer - // connected to the same address as specified by the server, port - // combination. - Int32 port = 13000; - client = gcnew TcpClient(server, port); - - // Translate the passed message into ASCII and store it as a Byte array. - array^data = Text::Encoding::ASCII->GetBytes( message ); - - // Get a client stream for reading and writing. - NetworkStream^ stream = client->GetStream(); - - // Send the message to the connected TcpServer. - stream->Write( data, 0, data->Length ); - - Console::WriteLine( "Sent: {0}", message ); - - // Receive the server response. - - // Buffer to store the response bytes. - data = gcnew array(256); - - // String to store the response ASCII representation. - String^ responseData = String::Empty; - - // Read the first batch of the TcpServer response bytes. - Int32 bytes = stream->Read( data, 0, data->Length ); - responseData = Text::Encoding::ASCII->GetString( data, 0, bytes ); - Console::WriteLine( "Received: {0}", responseData ); - - // Explicit close is not necessary since TcpClient::Dispose() will be - // called automatically in finally block. - // stream->Close(); - // client->Close(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e ); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - finally - { - if (client != nullptr) - delete client; - } - - Console::WriteLine( "\n Press Enter to continue..." ); - Console::Read(); -} -// - -void main( int argc, char *argv[] ) -{ - // Parse arguments - String^ server; - String^ message; - if ( argc < 3 ) - { - message = "This is a test!"; - if ( argc == 1 ) - { - server = "localhost"; - } - else - { - server = gcnew String(argv[ 1 ]); - } - } - else - { - message = gcnew String(argv[ 2 ]); - server = gcnew String(argv[ 1 ]); - } - - // Connect to server - Connect( server, message ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp deleted file mode 100644 index 86c17e2e7fd..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp +++ /dev/null @@ -1,125 +0,0 @@ - - -// This is the main project file for VC++ application project -// generated using an Application Wizard. -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -ref class TcpClientExamples -{ -public: - - // - static void GetAvailable( TcpClient^ t ) - { - // Find out how many bytes are ready to be read. - Console::WriteLine( "Available value is {0}", t->Available.ToString() ); - ; - } - // - - // - static void GetConnected( TcpClient^ t ) - { - // Find out whether the socket is connected to the remote - // host. - Console::WriteLine( "Connected value is {0}", t->Connected.ToString() ); - ; - } - // - - // - static void GetSetExclusiveAddressUse( TcpClient^ t ) - { - // Don't allow another process to bind to this port. - t->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", t->ExclusiveAddressUse.ToString() ); - ; - } - // - - // - static void DoConnect( String^ host, int port ) - { - // Connect to the specified host. - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - array^IPAddresses = Dns::GetHostAddresses( host ); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->Connect( IPAddresses, port ); - Console::WriteLine( "Connection established" ); - } - // - - // - static ManualResetEvent^ connectDone = gcnew ManualResetEvent( false ); - static void ConnectCallback( IAsyncResult^ ar ) - { - connectDone->Set(); - TcpClient^ t = safe_cast(ar->AsyncState); - t->EndConnect( ar ); - } - // - - static void DoBeginConnect1( String^ host, int port ) - { - // Connect asynchronously to the specifed host. - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); -// IPAddress^ remoteHost = gcnew IPAddress( host ); - array^ remoteHost = Dns::GetHostAddresses( host ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( remoteHost, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - // Connect asynchronously to the specifed host. - static void DoBeginConnect2( String^ host, int port ) - { - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - array^remoteHost = Dns::GetHostAddresses( host ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( remoteHost, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } - - // Connect asynchronously to the specifed host. - static void DoBeginConnect3( String^ host, int port ) - { - TcpClient^ t = gcnew TcpClient( AddressFamily::InterNetwork ); - connectDone->Reset(); - Console::WriteLine( "Establishing Connection to {0}", host ); - t->BeginConnect( host, port, gcnew AsyncCallback( &ConnectCallback ), t ); - - // Wait here until the callback processes the connection. - connectDone->WaitOne(); - Console::WriteLine( "Connection established" ); - } -}; - -int main() -{ - TcpClient^ t; - - // The TCP socket. - t = gcnew TcpClient( "localhost",80 ); - TcpClientExamples::GetConnected( t ); - TcpClientExamples::GetAvailable( t ); - TcpClientExamples::GetSetExclusiveAddressUse( t ); - TcpClientExamples::DoConnect( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect1( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect2( "127.0.0.1", 80 ); - TcpClientExamples::DoBeginConnect3( "127.0.0.1", 80 ); - Console::WriteLine( "enter to exit" ); - Console::Read(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp deleted file mode 100644 index 9687b62e453..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp +++ /dev/null @@ -1,226 +0,0 @@ - - -// System.Net.Sockets.TcpListener -/** -* This program shows how to use the TcpListener class. -* It creates a TcpListener that listen on the specified port (13000). -* To run this program at the command line you enter: -* cs_tcpserver -* Any TcpClient that wants to use this server -* has to explicitly connect to an address obtained by the combination of -* the sever on which this TcpServer is runnig and the port 13000. -* This TcpServer simply echoes back the message sent by the TcpClient, after -* translating it into uppercase. -* To avoid permission settings you can run this console application and the related -* TcpClient from your hard disk and not from a shared location on the network. -**/ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; -void main() -{ - try - { - - // Set the TcpListener on port 13000. - Int32 port = 13000; - IPAddress^ localAddr = IPAddress::Parse( "127.0.0.1" ); - - // TcpListener* server = new TcpListener(port); - TcpListener^ server = gcnew TcpListener( localAddr,port ); - - // Start listening for client requests. - server->Start(); - - // Buffer for reading data - array^bytes = gcnew array(256); - String^ data = nullptr; - - // Enter the listening loop. - while ( true ) - { - Console::Write( "Waiting for a connection... " ); - - // Perform a blocking call to accept requests. - // You could also use server.AcceptSocket() here. - TcpClient^ client = server->AcceptTcpClient(); - Console::WriteLine( "Connected!" ); - data = nullptr; - - // Get a stream Object* for reading and writing - NetworkStream^ stream = client->GetStream(); - Int32 i; - - // Loop to receive all the data sent by the client. - while ( i = stream->Read( bytes, 0, bytes->Length ) ) - { - - // Translate data bytes to a ASCII String*. - data = Text::Encoding::ASCII->GetString( bytes, 0, i ); - Console::WriteLine( "Received: {0}", data ); - - // Process the data sent by the client. - data = data->ToUpper(); - array^msg = Text::Encoding::ASCII->GetBytes( data ); - - // Send back a response. - stream->Write( msg, 0, msg->Length ); - Console::WriteLine( "Sent: {0}", data ); - } - - // Shutdown and end connection - client->Close(); - } - } - catch ( SocketException^ e ) - { - Console::WriteLine( "SocketException: {0}", e ); - } - - Console::WriteLine( "\nHit enter to continue..." ); - Console::Read(); -} - - -// -ref class tcplistener -{ -public: - - // - static void GetSetExclusiveAddressUse( TcpListener^ t ) - { - - // Set Exclusive Address Use for the underlying socket. - t->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", t->ExclusiveAddressUse ); - } - - - // - // - static void DoStart( TcpListener^ t, int backlog ) - { - - // Start listening for client connections with the specified - // backlog. - t->Start( backlog ); - Console::WriteLine( "started listening" ); - } - - - // - // - // Thread signal. - static ManualResetEvent^ clientConnected = gcnew ManualResetEvent( false ); - - // Accept one client connection asynchronously. - static void DoBeginAcceptSocket( TcpListener^ listener ) - { - - // Set the event to nonsignaled state. - clientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptSocket( gcnew AsyncCallback( &tcplistener::DoAcceptSocketCallback ), listener ); - - // Wait until a connection is made and processed before - // continuing. - clientConnected->WaitOne(); - } - - - // Process the client connection. - static void DoAcceptSocketCallback( IAsyncResult^ ar ) - { - - // Get the listener that handles the client request. - TcpListener^ listener = dynamic_cast(ar->AsyncState); - - // Get the client socket. - Socket^ clientSocket = listener->EndAcceptSocket( ar ); - - // Process the connection here. (Add the client to a server - // table, read data, etc.) - Console::WriteLine( "Client connected completed" ); - - // Signal the calling thread to continue. - clientConnected->Set(); - } - - - // - // - // Thread signal. - static ManualResetEvent^ tcpClientConnected = gcnew ManualResetEvent( false ); - - // Accept one client connection asynchronously. - static void DoBeginAcceptTcpClient( TcpListener^ listener ) - { - - // Set the event to nonsignaled state. - tcpClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine( "Waiting for a connection..." ); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptTcpClient( gcnew AsyncCallback( &tcplistener::DoAcceptTcpClientCallback ), listener ); - - // Wait until a connection is made and processed before - // continuing. - tcpClientConnected->WaitOne(); - } - - - // Process the client connection. - static void DoAcceptTcpClientCallback( IAsyncResult^ ar ) - { - - // Get the listener that handles the client request. - TcpListener^ listener = dynamic_cast(ar->AsyncState); - - // Get the new TcpClient. - TcpClient^ client = listener->EndAcceptTcpClient( ar ); - - // Process the connection here. (Add the client to a server - // table, read data, etc.) - Console::WriteLine( "Client connected completed" ); - - // Signal the calling thread to continue. - tcpClientConnected->Set(); - } - - // -}; - -/*int main() -{ - TcpListener* listener = new TcpListener( - Dns::GetLocalHostAddresses()[0], - 4242); - - tcplistener::GetSetExclusiveAddressUse(listener); - - // Start listening for client connections. - tcplistener::DoStart(listener, 20); - - // Accept client connections asynchronously - tcplistener::DoBeginAcceptSocket(listener); - tcplistener::DoBeginAcceptTcpClient(listener); - - Console::WriteLine("hit any key"); - Console::Read(); - return 0; -}*/ diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp deleted file mode 100644 index 0a8159bb679..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Threading; - -namespace TcpListenerExample -{ - public ref class TcpServer - { - // - public: - static void GetSetExclusiveAddressUse(TcpListener^ listener) - { - // Set Exclusive Address Use for the underlying socket. - listener->ExclusiveAddressUse = true; - Console::WriteLine("ExclusiveAddressUse value is {0}", - listener->ExclusiveAddressUse); - } - // - - // - public: - static void DoStart(TcpListener^ listener, int backlog) - { - // Start listening for client connections with the - // specified backlog. - listener->Start(backlog); - Console::WriteLine("Started listening"); - } - // - - // Thread signal. - public: - static ManualResetEvent^ ClientConnected; - - // Accept one client connection asynchronously. - public: - static void DoBeginAcceptSocket(TcpListener^ listener) - { - // Set the event to nonsignaled state. - ClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine("Waiting for a connection..."); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptSocket( - gcnew AsyncCallback(DoAcceptSocketCallback), listener); - // Wait until a connection is made and processed before - // continuing. - ClientConnected->WaitOne(); - } - - // Process the client connection. - public: - static void DoAcceptSocketCallback(IAsyncResult^ result) - { - // Get the listener that handles the client request. - TcpListener^ listener = (TcpListener^) result->AsyncState; - - // End the operation and display the received data on the - //console. - Socket^ clientSocket = listener->EndAcceptSocket(result); - - // Process the connection here. (Add the client to a - // server table, read data, etc.) - Console::WriteLine("Client connected completed"); - - // Signal the calling thread to continue. - ClientConnected->Set(); - } - - // Thread signal. - public: - static ManualResetEvent^ TcpClientConnected; - - // Accept one client connection asynchronously. - public: - static void DoBeginAcceptTcpClient(TcpListener^ listener) - { - // Set the event to nonsignaled state. - TcpClientConnected->Reset(); - - // Start to listen for connections from a client. - Console::WriteLine("Waiting for a connection..."); - - // Accept the connection. - // BeginAcceptSocket() creates the accepted socket. - listener->BeginAcceptTcpClient( - gcnew AsyncCallback(DoAcceptTcpClientCallback), - listener); - - // Wait until a connection is made and processed before - // continuing. - TcpClientConnected->WaitOne(); - } - - // Process the client connection. - public: - static void DoAcceptTcpClientCallback(IAsyncResult^ result) - { - // Get the listener that handles the client request. - TcpListener^ listener = (TcpListener^) result->AsyncState; - - // End the operation and display the received data on - // the console. - TcpClient^ client = listener->EndAcceptTcpClient(result); - - // Process the connection here. (Add the client to a - // server table, read data, etc.) - Console::WriteLine("Client connected completed"); - - // Signal the calling thread to continue. - TcpClientConnected->Set(); - - } - - public: - static void Main() - { - ClientConnected = gcnew ManualResetEvent(false); - - TcpClientConnected = gcnew ManualResetEvent(false); - - TcpListener^ listener = gcnew TcpListener( - Dns::GetHostAddresses(Dns::GetHostName())[0], 4242); - - GetSetExclusiveAddressUse(listener); - - // Start listening for client connections. - DoStart(listener, 20); - - // Accept one client connection asynchronously - DoBeginAcceptSocket(listener); - DoBeginAcceptTcpClient(listener); - - Console::WriteLine("Hit any key"); - Console::Read(); - } - }; -} - -[STAThread] -int main() -{ - TcpListenerExample::TcpServer::Main(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp deleted file mode 100644 index dd999947811..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp +++ /dev/null @@ -1,326 +0,0 @@ - - -// File name:multicastOperations.cs -// This example shows how to join a multicast group and perform a muticast -// data exchange. The OriginatorClient Object* starts the conversation while -// the TargetClient responds. The two helper objects Receive and Send -// perform the actual data exchange. -// Note. This program cannot be build with the current VS build version. -// Build it via command line. Rubuild it in VS when a suitable version is -// available. -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::IO; -using namespace System::Threading; - -// The following Receive class is used by both the ClientOriginator and -// the ClientTarget class to receive data from one another.. -public ref class Receive -{ -public: - - // The following static method performs the actual data - // exchange. In particular, it performs the following tasks: - // 1)Establishes a communication endpoint. - // 2)Receive data through this end point on behalf of the - // caller. - // 3) Returns the received data in ASCII format. - static String^ ReceiveUntilStop( UdpClient^ c ) - { - String^ strData = ""; - String^ Ret = ""; - ASCIIEncoding^ ASCII = gcnew ASCIIEncoding; - - // Establish the communication endpoint. - IPEndPoint^ endpoint = gcnew IPEndPoint( IPAddress::IPv6Any,50 ); - while ( !strData->Equals( "Over" ) ) - { - array^data = c->Receive( endpoint ); - strData = ASCII->GetString( data ); - Ret = String::Concat( Ret, strData, "\n" ); - } - - return Ret; - } - -}; - - -// The following Send class is used by both the ClientOriginator and -// ClientTarget classes to send data to one another. -public ref class Send -{ -private: - static array^greetings = {'H','e','l','l','o',' ','T','a','r','g','e','t','->'}; - static array^nice = {'H','a','v','e',' ','a',' ','n','i','c','e',' ','d','a','y','->'}; - static array^eom = {'O','v','e','r'}; - static array^tGreetings = {'H','e','l','l','o',' ','O','r','i','g','i','n','a','t','o','r','!'}; - static array^tNice = {'Y','o','u',' ','t','o','o','->'}; - -public: - - // The following static method sends data to the ClientTarget on - // behalf of the ClientOriginator. - static void OriginatorSendData( UdpClient^ c, IPEndPoint^ ep ) - { - Console::WriteLine( gcnew String( greetings ) ); - c->Send( GetByteArray( greetings ), greetings->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( nice ) ); - c->Send( GetByteArray( nice ), nice->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( eom ) ); - c->Send( GetByteArray( eom ), eom->Length, ep ); - } - - - // The following static method sends data to the ClientOriginator on - // behalf of the ClientTarget. - static void TargetSendData( UdpClient^ c, IPEndPoint^ ep ) - { - Console::WriteLine( gcnew String( tGreetings ) ); - c->Send( GetByteArray( tGreetings ), tGreetings->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( tNice ) ); - c->Send( GetByteArray( tNice ), tNice->Length, ep ); - Thread::Sleep( 1000 ); - Console::WriteLine( gcnew String( eom ) ); - c->Send( GetByteArray( eom ), eom->Length, ep ); - } - - -private: - - // Internal utility - static array^ GetByteArray( array^ChArray ) - { - array^Ret = gcnew array(ChArray->Length); - for ( int i = 0; i < ChArray->Length; i++ ) - Ret[ i ] = (Byte)ChArray[ i ]; - return Ret; - } - -}; - - -// The ClientTarget class is the receiver of the ClientOriginator -// messages. The StartMulticastConversation method contains the -// logic for exchanging data between the ClientTarget and its -// counterpart ClientOriginator in a multicast operation. -public ref class ClientTarget -{ -private: - static UdpClient^ m_ClientTarget; - static IPAddress^ m_GrpAddr; - -public: - - // The following StartMulticastConversation method connects the UDP - // ClientTarget with the ClientOriginator. - // It performs the following main tasks: - // 1)Creates a UDP client to receive data on a specific port and using - // IPv6 addresses. The port is the same one used by the ClientOriginator - // to define its communication endpoint. - // 2)Joins or creates a multicast group at the specified address. - // 3)Defines the endpoint port to send data to the ClientOriginator. - // 4)Receives data from the ClientOriginator until the end of the - // communication. - // 5)Sends data to the ClientOriginator. - // Note this method is the counterpart of the - // ClientOriginator::ConnectOriginatorAndTarget(). - static void StartMulticastConversation() - { - String^ Ret; - - // Bind and listen on port 1000. Specify the IPv6 address family type. - m_ClientTarget = gcnew UdpClient( 1000,AddressFamily::InterNetworkV6 ); - - // Join or create a multicast group - m_GrpAddr = IPAddress::Parse( "FF01::1" ); - - // Use the overloaded JoinMulticastGroup method. - // Refer to the ClientOriginator method to see how to use the other - // methods. - m_ClientTarget->JoinMulticastGroup( m_GrpAddr ); - - // Define the endpoint data port. Note that this port number - // must match the ClientOriginator UDP port number which is the - // port on which the ClientOriginator is receiving data. - IPEndPoint^ ClientOriginatordest = gcnew IPEndPoint( m_GrpAddr,2000 ); - - // Receive data from the ClientOriginator. - Ret = Receive::ReceiveUntilStop( m_ClientTarget ); - Console::WriteLine( "\nThe ClientTarget received: \n\n {0}\n", Ret ); - - // Done receiving, now respond to the ClientOriginator. - // Wait to make sure the ClientOriginator is ready to receive. - Thread::Sleep( 2000 ); - Console::WriteLine( "\nThe ClientTarget sent:\n" ); - Send::TargetSendData( m_ClientTarget, ClientOriginatordest ); - - // Exit the multicast conversation. - m_ClientTarget->DropMulticastGroup( m_GrpAddr ); - } - -}; - - -// The following ClientOriginator class starts the multicast conversation -// with the ClientTarget class.. -// It performs the following main tasks: -// 1)Creates a socket and binds it to the port on which to communicate. -// 2)Specifies that the connection must use an IPv6 address. -// 3)Joins or create a multicast group. -// Note that the multicast address ranges to use are specified -// in the RFC#2375. -// 4)Defines the endpoint to send the data to and starts the -// client target (ClientTarget) thread. -public ref class ClientOriginator -{ -private: - static UdpClient^ clientOriginator; - static IPAddress^ m_GrpAddr; - static IPEndPoint^ m_ClientTargetdest; - static Thread^ m_t; - -public: - - // The ConnectOriginatorAndTarget method connects the - // ClientOriginator with the ClientTarget. - // It performs the following main tasks: - // 1)Creates a UDP client to receive data on a specific port - // using IPv6 addresses. - // 2)Joins or create a multicast group at the specified address. - // 3)Defines the endpoint port to send data to on the ClientTarget. - // 4)Starts the ClientTarget thread that also creates the ClientTarget Object*. - // Note this method is the counterpart of the - // ClientTarget::StartMulticastConversation(). - static bool ConnectOriginatorAndTarget() - { - try - { - - // - // Bind and listen on port 2000. This constructor creates a socket - // and binds it to the port on which to receive data. The family - // parameter specifies that this connection uses an IPv6 address. - clientOriginator = gcnew UdpClient( 2000,AddressFamily::InterNetworkV6 ); - - // Join or create a multicast group. The multicast address ranges - // to use are specified in RFC#2375. You are free to use - // different addresses. - // Transform the String* address into the internal format. - m_GrpAddr = IPAddress::Parse( "FF01::1" ); - - // Display the multicast address used. - Console::WriteLine( "Multicast Address: [ {0}]", m_GrpAddr ); - - // - // Exercise the use of the IPv6MulticastOption. - Console::WriteLine( "Instantiate IPv6MulticastOption(IPAddress)" ); - - // Instantiate IPv6MulticastOption using one of the - // overloaded constructors. - IPv6MulticastOption^ ipv6MulticastOption = gcnew IPv6MulticastOption( m_GrpAddr ); - - // Store the IPAdress multicast options. - IPAddress^ group = ipv6MulticastOption->Group; - __int64 interfaceIndex = ipv6MulticastOption->InterfaceIndex; - - // Display IPv6MulticastOption properties. - Console::WriteLine( "IPv6MulticastOption::Group: [ {0}]", group ); - Console::WriteLine( "IPv6MulticastOption::InterfaceIndex: [ {0}]", interfaceIndex ); - - // - // - // Instantiate IPv6MulticastOption using another - // overloaded constructor. - IPv6MulticastOption^ ipv6MulticastOption2 = gcnew IPv6MulticastOption( group,interfaceIndex ); - - // Store the IPAdress multicast options. - group = ipv6MulticastOption2->Group; - interfaceIndex = ipv6MulticastOption2->InterfaceIndex; - - // Display the IPv6MulticastOption2 properties. - Console::WriteLine( "IPv6MulticastOption::Group: [ {0} ]", group ); - Console::WriteLine( "IPv6MulticastOption::InterfaceIndex: [ {0} ]", interfaceIndex ); - - // Join the specified multicast group using one of the - // JoinMulticastGroup overloaded methods. - clientOriginator->JoinMulticastGroup( (int)interfaceIndex, group ); - - // - // Define the endpoint data port. Note that this port number - // must match the ClientTarget UDP port number which is the - // port on which the ClientTarget is receiving data. - m_ClientTargetdest = gcnew IPEndPoint( m_GrpAddr,1000 ); - - // - // Start the ClientTarget thread so it is ready to receive. - m_t = gcnew Thread( gcnew ThreadStart( ClientTarget::StartMulticastConversation ) ); - m_t->Start(); - - // Make sure that the thread has started. - Thread::Sleep( 2000 ); - return true; - } - catch ( Exception^ e ) - { - Console::WriteLine( "[ClientOriginator::ConnectClients] Exception: {0}", e ); - return false; - } - - } - - - // The SendAndReceive performs the data exchange - // between the ClientOriginator and the ClientTarget classes. - static String^ SendAndReceive() - { - String^ Ret = ""; - - // - // Send data to ClientTarget. - Console::WriteLine( "\nThe ClientOriginator sent:\n" ); - Send::OriginatorSendData( clientOriginator, m_ClientTargetdest ); - - // Receive data from ClientTarget - Ret = Receive::ReceiveUntilStop( clientOriginator ); - - // Stop the ClientTarget thread - m_t->Abort(); - - // Abandon the multicast group. - clientOriginator->DropMulticastGroup( m_GrpAddr ); - - // - return Ret; - } - -}; - - -//This is the console application entry point. -int main() -{ - - // Join the multicast group. - if ( ClientOriginator::ConnectOriginatorAndTarget() ) - { - - // Perform a multicast conversation with the ClientTarget. - String^ Ret = ClientOriginator::SendAndReceive(); - Console::WriteLine( "\nThe ClientOriginator received: \n\n {0}", Ret ); - } - else - { - Console::WriteLine( "Unable to Join the multicast group" ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp deleted file mode 100644 index 30d3d0da5b0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -ref class UdpClientExamples -{ -public: - - // - static void GetAvailable( UdpClient^ u ) - { - // Get the number of bytes available for reading. - Console::WriteLine( "Available value is {0}", u->Available ); - } - // - - // - static void GetSetDontFragment( UdpClient^ u ) - { - // Set the don't fragment flag for packets emanating from - // this client. - u->DontFragment = true; - Console::WriteLine( "DontFragment value is {0}", u->DontFragment ); - } - // - - // - static void GetSetEnableBroadcast( UdpClient^ u ) - { - // Set the Broadcast flag for this client. - u->EnableBroadcast = true; - Console::WriteLine( "EnableBroadcast value is {0}", u->EnableBroadcast ); - } - // - - // - static void GetSetExclusiveAddressUse( UdpClient^ u ) - { - // Don't allow another client to bind to this port. - u->ExclusiveAddressUse = true; - Console::WriteLine( "ExclusiveAddressUse value is {0}", u->ExclusiveAddressUse ); - } - // - - // - static void GetSetTtl( UdpClient^ u ) - { - // Set the Time To Live (TTL) for this client. - u->Ttl = 42; - Console::WriteLine( "Ttl value is {0}", u->Ttl ); - } - // - - // - // Subscribe to a multicast group. - static void DoJoinMulticastGroup( UdpClient^ u, String^ mcast, String^ local ) - { - array^ multicastAddress = Dns::GetHostAddresses( mcast ); - - u->JoinMulticastGroup( multicastAddress[0] ); - Console::WriteLine( "Joined multicast Address {0}", multicastAddress ); - } - // - - // - static void GetSetMulticastLoopback( UdpClient^ u ) - { - // Deliver multicast packets back to the sending client. - u->MulticastLoopback = true; - Console::WriteLine( "MulticastLoopback value is {0}", u->MulticastLoopback ); - } - // -}; - -int main() -{ - UdpClient^ u = gcnew UdpClient( 4242 ); - UdpClientExamples::GetAvailable( u ); - UdpClientExamples::GetSetDontFragment( u ); - UdpClientExamples::GetSetEnableBroadcast( u ); - UdpClientExamples::GetSetExclusiveAddressUse( u ); - UdpClientExamples::GetSetTtl( u ); - UdpClientExamples::DoJoinMulticastGroup( u, "224.1.1.1", "172.30.186.134" ); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp b/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp deleted file mode 100644 index e6554acb196..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -public ref class UdpClientExample -{ - // -private: - static int listenPort = 13000; - -public: - value struct UdpState - { - public: - UdpClient^ udpClient; - IPEndPoint^ ipEndPoint; - }; - - static bool isMessageReceived; - - static void ReceiveCallback(IAsyncResult^ asyncResult) - { - UdpClient^ udpClient = - ((UdpState)(asyncResult->AsyncState)).udpClient; - IPEndPoint^ ipEndPoint = - ((UdpState)(asyncResult->AsyncState)).ipEndPoint; - - array^ receiveBytes = - udpClient->EndReceive(asyncResult, ipEndPoint); - String^ receiveString = - Encoding::ASCII->GetString(receiveBytes); - - Console::WriteLine("Received: {0}", receiveString); - isMessageReceived = true; - } - - static void ReceiveMessages() - { - // Receive a message and write it to the console. - IPEndPoint^ ipEndPoint = gcnew IPEndPoint(IPAddress::Any, listenPort); - UdpClient^ udpClient = gcnew UdpClient(ipEndPoint); - - UdpState^ udpState = gcnew UdpState(); - udpState->ipEndPoint = ipEndPoint; - udpState->udpClient = udpClient; - - Console::WriteLine("listening for messages"); - udpClient->BeginReceive(gcnew AsyncCallback(ReceiveCallback), - udpState); - - // Do some work while we wait for a message. For this example, - // we'll just sleep - while (!isMessageReceived) - { - Thread::Sleep(100); - } - } - // - - // -public: - static bool isMessageSent; - - static void SendCallback(IAsyncResult^ asyncResult) - { - UdpClient^ udpClient = (UdpClient^)asyncResult->AsyncState; - - Console::WriteLine("number of bytes sent: {0}", - udpClient->EndSend(asyncResult)); - isMessageSent = true; - } - // - - // -public: - static void SendMessage1(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - - udpClient->Connect(server, listenPort); - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // send the message - // the destination is defined by the call to .Connect() - udpClient->BeginSend(sendBytes, sendBytes->Length, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - - // -public: - static void SendMessage2(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // resolve the server name - IPHostEntry^ resolvedServer = Dns::GetHostEntry(server); - - IPEndPoint^ ipEndPoint = - gcnew IPEndPoint(resolvedServer->AddressList[0], listenPort); - - // send the message - // the destination is defined by the IPEndPoint - udpClient->BeginSend(sendBytes, sendBytes->Length, ipEndPoint, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - - // -public: - static void SendMessage3(String^ server, String^ message) - { - // create the udp socket - UdpClient^ udpClient = gcnew UdpClient(); - - array^ sendBytes = Encoding::ASCII->GetBytes(message); - - // send the message - // the destination is defined by the server name and port - udpClient->BeginSend(sendBytes, sendBytes->Length, server, listenPort, - gcnew AsyncCallback(SendCallback), udpClient); - - // Do some work while we wait for the send to complete. For - // this example, we'll just sleep - while (!isMessageSent) - { - Thread::Sleep(100); - } - } - // - -}; - -int main(array^ args) -{ - // Parse arguments - String^ server = ""; - String^ message = "This is a test!"; - bool isServer; - int sendMethod = 1; // n called SendMessagen - - if (args->Length == 0) - { - server = "localhost"; - isServer = false; - } - else if (args->Length == 1) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - } - else if (args->Length == 2) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - } - else if (args->Length == 3) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - message = args[2]; - } - else if (args->Length == 4) - { - if (args[0] == "s") - { - isServer = true; - } - else - { - isServer = false; - } - server = args[1]; - message = args[2]; - - try - { - sendMethod = Convert::ToInt32(args[3]); - } - catch (System::ArgumentNullException^ ex) - { - Console::WriteLine(ex->Message); - } - catch (System::FormatException^ ex) - { - Console::WriteLine(ex->Message); - } - catch (System::OverflowException^ ex) - { - Console::WriteLine(ex->Message); - } - } - else - { - Console::WriteLine( - "Usage: asyncudp [s|c] [host name] [message] [send method]"); - return 0; - } - - if (isServer) - { - UdpClientExample::ReceiveMessages(); - } - else - { - switch (sendMethod) - { - case 1: - UdpClientExample::SendMessage1(server, message); - break; - case 2: - UdpClientExample::SendMessage2(server, message); - break; - case 3: - UdpClientExample::SendMessage3(server, message); - break; - } - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp deleted file mode 100644 index a2417ed5c55..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::Threading; - -void main() -{ - const int portNumber = 13; - - // - try - { - // Use the Pending method to poll the underlying socket instance for client connection requests. - TcpListener^ tcpListener = gcnew TcpListener( portNumber ); - tcpListener->Start(); - - if ( !tcpListener->Pending() ) - { - Console::WriteLine( "Sorry, no connection requests have arrived" ); - } - else - { - //Accept the pending client connection and return a TcpClient object^ initialized for communication. - TcpClient^ tcpClient = tcpListener->AcceptTcpClient(); - - // Using the RemoteEndPoint property. - Console::WriteLine( "I am listening for connections on {0} on port number {1}", - IPAddress::Parse( ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Address->ToString() ), - ( (IPEndPoint^)(tcpListener->LocalEndpoint) )->Port ); - // - - //Close the tcpListener and tcpClient instances - tcpClient->Close(); - } - tcpListener->Stop(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp deleted file mode 100644 index fc78349bd84..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Net::WebException::WebException(); - -/* -This program demonstrates the 'WebException()' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with an invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown.In -the 'catch' block a new 'WebException' Object* is created and thrown to the caller. That exception -is caught in the calling method and the error message is displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( "http://www.contoso.com" ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - String^ exp = e->Message; - // Throw the WebException with no parameters. - throw gcnew WebException; - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "The Exception is: {0}", e->Message ); - Console::WriteLine( "The Exception is: Unable to Contact the server" ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp deleted file mode 100644 index bd7987a1db7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Net::WebException::WebException(String); - -/* -This program demonstrates the 'WebException(String)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown.In -the 'catch' block a new 'WebException' Object* is created with a message(specific to the present -situation) and thrown to the caller. That exception is caught in the calling method and the -error message is displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - - // Throw the 'WebException' object with a message string specific to the situation. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri." ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp deleted file mode 100644 index 8a6a84a5294..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// System::Net::WebException::WebException(String, WebExceptionStatus); - -/* -This program demonstrates the 'WebException(String, WebExceptionStatus)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown and -in the 'catch' block a new 'WebException' Object* is created and thrown. That exception is caught -in the calling method and the error message is displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( "http://www.contoso.com" ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - // Throw the 'WebException' object with a message string and message status specific to the situation. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri.", WebExceptionStatus::NameResolutionFailure ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - Console::WriteLine( "\nThe Status is : {0}", e->Status ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp deleted file mode 100644 index eb951370648..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// System::Net::WebException::WebException(String, InnerException); - -/* -This program demonstrates the 'WebException(String, InnerException)' constructor of 'WebException' class. -It creates a 'HttpConnect' Object* and calls the 'ConnectHttpServer' method with invalid 'URL'. -When the method tries to establish a socket connection to that address an exception is thrown and -in the 'catch' block a new 'WebException' Object* is created and thrown. That exception is caught -in the calling method and the error message is displayed on the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; - -public ref class HttpConnect -{ -public: - void ConnectHttpServer( String^ connectUri ) - { -// - try - { - // A 'Socket' object has been created. - Socket^ httpSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // The IPaddress of the unknown uri is resolved using the 'Dns::Resolve' method. - - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress, 80 ); - httpSocket->Connect( endPoint ); - Console::WriteLine( "Connection created successfully" ); - httpSocket->Close(); - } - catch ( SocketException^ e ) - { - Console::WriteLine( "\nException thrown.\nThe Original Message is: {0}", e->Message ); - // Throw the 'WebException' object with a message string specific to the situation; - // and the 'InnerException' that actually led to this exception. - throw gcnew WebException( "Unable to locate the Server with 'www.contoso.com' Uri.", e ); - } -// - } -}; - -int main() -{ - try - { - HttpConnect^ myHttpConnect = gcnew HttpConnect; - - // If the Uri is valid then 'ConnectHttpServer' method will connect to the server. - myHttpConnect->ConnectHttpServer( "www.contoso.com" ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe New Message is: {0}", e->Message ); - Console::WriteLine( "\nThe Inner Exception is : {0}", e->InnerException ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp deleted file mode 100644 index a128262f175..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// System::Net::WebException::WebException(String, InnerException, Status, WebResponse); - -/* -This program demonstrates the 'WebException(String, InnerException, Status, WebResponse)' constructor of -'WebException' class. -A 'HttpConnect' class is defined which extends the 'WebResponse' class. Then a 'HttpConnect' Object* is -created by taking an uri(intranet) from the user as input and 'ConnectHttpServer' method is called to connect -the InternetServer at the specified 'URL'. It asks for a file named 'nhjj.htm' , gets the response from the -InternetServer and checks the status of the response. If status is '404 File not Found' a 'WebResponse' Object* -is created and then a new 'WebException' Object* is created and thrown. That exception is caught in the calling -method and the error message along with the response obtained from the InternetServer is displayed to the -console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -using namespace System::Text; -using namespace System::IO; - -public ref class HttpConnect: public WebResponse -{ -public: - Stream^ getStream; - - // Default constructor. - HttpConnect() - { - getStream = nullptr; - } - - // Constructor accepting stream as a parameter. - HttpConnect( Stream^ getStream ) - { - this->getStream = getStream; - } - - // Override 'GetResponseStream' method of the 'WebResponse' class. - virtual Stream^ GetResponseStream() override - { - return getStream; - } - - void ConnectHttpServer( String^ connectUri ) - { -// - // Send the data. - Encoding^ ASCII = Encoding::ASCII; - String^ requestPage = String::Concat( "GET /nhjj.htm HTTP/1.1\r\nHost: ", connectUri, "\r\nConnection: Close\r\n\r\n" ); - array^ byteGet = ASCII->GetBytes( requestPage ); - array^ recvBytes = gcnew array(256); - - // Create an 'IPEndPoint' object. - - IPHostEntry^ hostEntry = Dns::Resolve( connectUri ); - IPAddress^ serverAddress = hostEntry->AddressList[ 0 ]; - IPEndPoint^ endPoint = gcnew IPEndPoint( serverAddress,80 ); - - // Create a 'Socket' object for sending data. - Socket^ connectSocket = gcnew Socket( AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp ); - - // Connect to host using 'IPEndPoint' object. - - connectSocket->Connect( endPoint ); - - // Sent the 'requestPage' text to the host. - connectSocket->Send( byteGet, byteGet->Length, (SocketFlags)(0) ); - - // Receive the information sent by the server. - Int32 bytesReceived = connectSocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)(0) ); - String^ headerString = ASCII->GetString( recvBytes, 0, bytesReceived ); - - // Check whether 'status 404' is there or not in the information sent by server. - if ( headerString->IndexOf( "404" ) != -1 ) - { - bytesReceived = connectSocket->Receive( recvBytes, recvBytes->Length, (SocketFlags)(0) ); - MemoryStream^ memoryStream = gcnew MemoryStream( recvBytes ); - getStream = (System::IO::Stream^)(memoryStream); - - // Create a 'WebResponse' object - WebResponse^ myWebResponse = (WebResponse^)(gcnew HttpConnect( getStream )); - Exception^ myException = gcnew Exception( "File Not found" ); - - // Throw the 'WebException' object with a message string, message status, InnerException and WebResponse - throw gcnew WebException( "The Requested page is not found.",myException,WebExceptionStatus::ProtocolError,myWebResponse ); - } - - connectSocket->Close(); -// - } -}; - -int main() -{ - try - { - Console::WriteLine( "Please give any Intranet Site Address (eg:manjeera.wipro.com)" ); - String^ uriConnect = Console::ReadLine(); - HttpConnect^ myHttpConnect = gcnew HttpConnect; - myHttpConnect->ConnectHttpServer( uriConnect ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nThe WebException is : {0}", e->Message ); - Console::WriteLine( "\nThe status of the WebException is : {0}", e->Status ); - Console::WriteLine( "\nThe Inner Exception is :' {0}'", e->InnerException ); - Console::WriteLine( "\nThe Web Response is:\n" ); - StreamReader^ readStream = gcnew StreamReader( e->Response->GetResponseStream() ); - Console::WriteLine( readStream->ReadToEnd() ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp b/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp deleted file mode 100644 index a74ca8330a1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This program demonstrates the S"Status" and the S"Response" property of S"WebException" class. -It tries to access an invalid site and displays the status code and status description of the -resultant exception that is raised. -*/ - -#using - -using namespace System; -using namespace System::Net; - -int main() -{ -// -// - try - { - // Create a web request for an unknown server (this raises the WebException). - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://unknown.unknown.com" )); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)(myHttpWebRequest->GetResponse()); - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "This program is expected to throw WebException on successful run." + - "\n\nException Message : " + e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code: {0}", ( (HttpWebResponse^)(e->Response) )->StatusCode ); - Console::WriteLine( "Status Description: {0}", ( (HttpWebResponse^)(e->Response) )->StatusDescription ); - } -// - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -// -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp b/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp deleted file mode 100644 index 69020651232..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -/* This program demonstrates the S"Add" method of S"WebHeaderCollection" class. -It uses the S"Add" method of S"WebHeaderCollection" class to add the 'Accept-Language' header in the request. -The 'Accept-Language' header is used in a request to specify the language preferences of the user. The server -can use the language preferences specified to generate output for that particular language. -*/ -#using - -using namespace System; -using namespace System::Net; -void printHeaders( WebHeaderCollection^ headers ) -{ - Console::WriteLine( "Printing Headers : " ); - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - //Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - //Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - Console::WriteLine( "Configuring Webrequest to accept Danish and English language using 'Add' method" ); - - //Add the Accept-Language header (for Danish) in the request. - myWebHeaderCollection->Add( "Accept-Language:da" ); - - //Include English in the Accept-Langauge header. - myWebHeaderCollection->Add( "Accept-Language:en;q=0.8" ); - - //Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - //Print the headers for the request. - printHeaders( myWebHeaderCollection ); - myHttpWebResponse->Close(); - } - //Catch exception if trying to add a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is thrown. \nMessage is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp b/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp deleted file mode 100644 index 096efbded87..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -/* -This program demonstrate's the 'GetValues(String*)' method of 'WebHeaderCollection' class. - -The program creates a 'HttpWebRequest' Object* from the specified URL and gets the response from it. The -headers of the response is assigned to a 'WeHeaderCollection' Object* and all the values associated with -the corresponding headers in the response are displayed to the console. -*/ -#using - -using namespace System; -using namespace System::Net; -int main() -{ - try - { - // - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - myHttpWebRequest->Timeout = 1000; - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Get the headers associated with the response. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers; - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - String^ header = myWebHeaderCollection->GetKey( i ); - array^values = myWebHeaderCollection->GetValues( header ); - if ( values->Length > 0 ) - { - Console::WriteLine( "The values of {0} header are : ", header ); - for ( int j = 0; j < values->Length; j++ ) - Console::WriteLine( "\t {0}", values[ j ] ); - } - else - Console::WriteLine( "There is no value associated with the header" ); - } - myHttpWebResponse->Close(); - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "\n Exception raised : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp b/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp deleted file mode 100644 index 842da2d6a21..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -/*This program demonstrates the S"IsRestricted" method of S"WebHeaderCollection". -It checks if the first header returned in the response is a restricted header or not. -*/ -#using - -using namespace System; -using namespace System::Net; -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Get the headers associated with the response. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebResponse->Headers; - for ( int i = 0; i < myWebHeaderCollection->Count; i++ ) - { - // Check if the first response header is restriced. - if ( WebHeaderCollection::IsRestricted( dynamic_cast(myWebHeaderCollection->AllKeys[ i ]) ) ) - Console::WriteLine( "' {0}' is a restricted header", myWebHeaderCollection->AllKeys[ i ] ); - else - Console::WriteLine( "' {0}' is not a restricted header", myWebHeaderCollection->AllKeys[ i ] ); - } - myHttpWebResponse->Close(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is thrown.\nMessage is: {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } -// -} - diff --git a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp b/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp deleted file mode 100644 index c8286d49cd4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -/* -This program demonstrates the S"Remove" method of S"WebHeaderCollection" class. -It uses the S"Remove" method of S"WebHeaderCollection" to remove the 'Cache-Control' header from the request. -The 'Cache-Control' header is used to specify the directive that must be followed by all caching mechanisms -in the Request-Response chain. The 'no-cache' directive indicates that the caching mechanism must not resend -the cached response for a previous request with->Item[Out] validating* from the origin server (HTTP version 1.1, RFC2616, -Sec 14.9) -*/ -#using - -using namespace System; -using namespace System::Net; -void printHeaders( WebHeaderCollection^ headers ) -{ - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - - // Set the Cache-Control header. - myWebHeaderCollection->Set( "Cache-Control", "no-cache" ); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Print the headers of the request to console. - Console::WriteLine( "Print request headers after adding Cache-Control for first request:" ); - printHeaders( myHttpWebRequest->Headers ); - - // Remove the Cache-Control header for the new request. - myWebHeaderCollection->Remove( "Cache-Control" ); - - // Get the response for the new request. - myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - - // Print the headers of the new request with->Item[Out] the* Cache-Control header. - Console::WriteLine( "Print request headers after removing Cache-Control for the new request:" ); - printHeaders( myHttpWebRequest->Headers ); - myHttpWebResponse->Close(); - } - // Catch exception if trying to remove a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( "Error : Trying to remove a restricted header" ); - Console::WriteLine( "ArgumentException is thrown. Message is : {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException is thrown. Message is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - - - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp b/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp deleted file mode 100644 index 08a56e07a73..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -/* This program demonstrates the S"Set" method of S"WebHeaderCollection" class. -It sets the value of the 'Cache-Control' header in the request to S"no-cache". The 'Cache-Control' header -is used to specify the directive that must be followed by all caching mechanisms in the Request-Response chain. -The 'no-cache' directive indicates that the caching mechanism must not resend the cached response for a -previous request with->Item[Out] validating* from the origin server (HTTP version 1.1, RFC2616, Sec 14.9). -*/ -#using - -using namespace System; -using namespace System::Net; -void PrintHeaders( WebHeaderCollection^ headers ) -{ - Console::WriteLine( "Printing Headers : " ); - if ( headers->Count == 0 ) - Console::WriteLine( "\tNo Headers to Display" ); - - for ( int i = 0; i < headers->Count; i++ ) - Console::WriteLine( "\t {0} : {1}", headers->AllKeys[ i ], headers[ i ] ); -} - -int main() -{ - // - try - { - // Create a web request for S"www.msn.com". - HttpWebRequest^ myHttpWebRequest = dynamic_cast(WebRequest::Create( "http://www.msn.com" )); - - // Get the headers associated with the request. - WebHeaderCollection^ myWebHeaderCollection = myHttpWebRequest->Headers; - - // Set the Cache-Control header in the request. - myWebHeaderCollection->Set( "Cache-Control", "no-cache" ); - - // Get the associated response for the above request. - HttpWebResponse^ myHttpWebResponse = dynamic_cast(myHttpWebRequest->GetResponse()); - Console::WriteLine( "Headers after 'Set' method is used on Cache-Control :" ); - - // Print the headers for the request. - PrintHeaders( myWebHeaderCollection ); - myHttpWebResponse->Close(); - } - // Catch exception if trying to set a restricted header. - catch ( ArgumentException^ e ) - { - Console::WriteLine( "ArgumentException is thrown. Message is : {0}", e->Message ); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException is thrown. Message is : {0}", e->Message ); - if ( e->Status == WebExceptionStatus::ProtocolError ) - { - Console::WriteLine( "Status Code : {0}", (dynamic_cast(e->Response))->StatusCode ); - Console::WriteLine( "Status Description : {0}", (dynamic_cast(e->Response))->StatusDescription ); - Console::WriteLine( "Server : {0}", (dynamic_cast(e->Response))->Server ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception is thrown. Message is : {0}", e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp deleted file mode 100644 index c6e380e0a44..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp +++ /dev/null @@ -1,92 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; -using namespace System::Threading; -public ref class RequestState -{ -public: - - // This class stores the request state of the request. - WebRequest^ request; - RequestState() - { - request = nullptr; - } - -}; - -ref class WebRequest_BeginGetRequeststream -{ -public: - static ManualResetEvent^ allDone = gcnew ManualResetEvent( false ); - static void ReadCallback( IAsyncResult^ asynchronousResult ) - { - RequestState^ myRequestState = dynamic_cast(asynchronousResult->AsyncState); - WebRequest^ myWebRequest = myRequestState->request; - - // End of the Asynchronus request. - Stream^ streamResponse = myWebRequest->EndGetRequestStream( asynchronousResult ); - - // Create a string that is to be posted to the uri. - Console::WriteLine( "Please enter a string to be posted:" ); - String^ postData = Console::ReadLine(); - - // Convert the string into a Byte array. - array^byteArray = Encoding::UTF8->GetBytes( postData ); - - // Write data to the stream. - streamResponse->Write( byteArray, 0, postData->Length ); - streamResponse->Close(); - allDone->Set(); - } - -}; - -int main() -{ - - // - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Create an instance of the RequestState and assign 'myWebRequest' to its request field. - RequestState^ myRequestState = gcnew RequestState; - myRequestState->request = myWebRequest; - myWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the 'Method' prperty to 'POST' to post data to a Uri. - myRequestState->request->Method = "POST"; - - // - // Start the Asynchronous 'BeginGetRequestStream' method call. - IAsyncResult^ r = dynamic_cast(myWebRequest->BeginGetRequestStream( gcnew AsyncCallback( WebRequest_BeginGetRequeststream::ReadCallback ), myRequestState )); - WebRequest_BeginGetRequeststream::allDone->WaitOne(); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - Console::WriteLine( "The String* entered has been posted." ); - Console::WriteLine( "Please wait for the response..." ); - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "The contents of the HTML page are " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myWebResponse->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp deleted file mode 100644 index ecac7b2e7b4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* System::Net::WebRequest::ContentType System::Net::WebRequest::ContentLength System::Net::WebRequest::GetRequestStream -This program demonstrates the 'GetRequestStream' method and the 'ContentLength' and 'ContentType' properties of - the 'WebRequest' class. -A new 'WebRequest' Object* is created and the method used for sending data is set to 'POST' method by setting -The 'Method' property to 'POST'. The 'ContentType' property is set to 'application/x-www-form-urlencoded'. -The 'ContentLength' property is set to the length of the Byte stream to be posted. A new 'Stream' Object* is -obtained from the 'GetRequestStream' method of the 'WebRequest' class. Data to be posted is requested from -the user and is posted using the stream Object*. The HTML contents of the page are then displayed to the -console after the Posted data is accepted by the URL. - -Note: This program POSTs data to the Uri: http://www20.Brinkster::com/codesnippets/next.asp -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// -// -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com " ); - - // Set the 'Method' property of the myWebrequest to POST. - myWebRequest->Method = "POST"; - - // Create a new string object to POST data to the above url. - Console::WriteLine( "\nThe value of 'ContentLength' property before sending the data is {0}", myWebRequest->ContentLength ); - Console::WriteLine( "\nPlease enter the data to be posted to (http://www.contoso.com/codesnippets/next.asp) Uri" ); - String^ inputData = Console::ReadLine(); - String^ postData = String::Concat( "firstone= ", inputData ); - ASCIIEncoding^ encoding = gcnew ASCIIEncoding; - array^ byteArray = encoding->GetBytes( postData ); - -// - // Set the 'ContentType' property of the WebRequest. - myWebRequest->ContentType = "application/x-www-form-urlencoded"; - - // Set the 'ContentLength' property of the WebRequest. - myWebRequest->ContentLength = byteArray->Length; - Stream^ newStream = myWebRequest->GetRequestStream(); - newStream->Write( byteArray, 0, byteArray->Length ); - - // Close the Stream object. - newStream->Close(); - - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// -// -// -// - - Console::WriteLine( "\nThe value of ContentLength property after sending the data is {0}", myWebRequest->ContentLength ); - Console::WriteLine( "\nThe String* entered has been successfully posted to the Uri." ); - Console::WriteLine( "\nPlease wait for the response......." ); - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - - // Release the resources of response Object*. - myWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "WebException raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp deleted file mode 100644 index ff1aa9ebfe6..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*System::Net::WebRequest::Create(Uri) - -This program demonstrates the 'Create(Uri)' method of the 'WebRequest' class. -A new 'Uri' object is created to the specified Uri. -A new 'WebRequest' object is created to the 'specified' Uri by passing the 'Uri' object as parameter. -The response is obtained . -The HTML contents of the page of the requested Uri are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new 'Uri' object with the specified string. - Uri^ myUri = gcnew Uri( "http://www.contoso.com" ); - // Create a new request to the above mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( myUri ); - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of HTML Page are : \n" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the WebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress 'Enter' key to continue................." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp deleted file mode 100644 index b4c440162f7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Headers/CPP/webrequest_headers.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*System::Net::WebRequest::Headers -* This program demonstrates the 'Headers' property of 'WebRequest' Class. -A new 'WebRequest' Object* is created. The (name, value) collection of the HTTP Headers are displayed to the -console. The contents of the HTML page of the requested URI are displayed to the console. */ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Release the resources of response object. - myWebResponse->Close(); - Console::WriteLine( "\nThe HttpHeaders are \n {0}", myWebRequest->Headers ); -// - - Console::WriteLine( "\nPress Enter Key to Continue........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "\n {0}", e->Message ); - Console::WriteLine( "\n {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised!" ); - Console::WriteLine( "Source : {0} ", e->Source ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp deleted file mode 100644 index 6781c2fe114..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Proxy/CPP/webrequest_proxy.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*System::Net::WebRequest::Proxy -This program demonstrates the 'Proxy' property of the 'WebRequest' class. -A WebRequest Object* is created and a new Proxy Object is created. -The Proxy Object is assigned the 'Proxy' Property of the WebRequest Object and then printed to the console, this is the default Proxy setting. -New Proxy address and the credentials are requested from the User. -A new Proxy Object* is then constructed from the inputs. -Then the 'Proxy' property of the request is associated with the new Proxy Object* constructed*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new request to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - WebProxy^ myProxy = gcnew WebProxy; - // Obtain the Proxy Prperty of the Default browser. - myProxy = (WebProxy^)(myWebRequest->Proxy); - - // Print myProxy address to the console. - Console::WriteLine( "\nThe actual default Proxy settings are {0}", myProxy->Address ); - try - { - Console::WriteLine( "\nPlease enter the new Proxy Address to be set " ); - Console::WriteLine( "The format of the address should be http://proxyUriAddress:portaddress" ); - Console::WriteLine( "Example:http://proxyadress.com:8080" ); - String^ proxyAddress; - proxyAddress = Console::ReadLine(); - - if ( proxyAddress->Length == 0 ) - { - myWebRequest->Proxy = myProxy; - } - else - { - Console::WriteLine( "\nPlease enter the Credentials" ); - Console::WriteLine( "Username:" ); - String^ username; - username = Console::ReadLine(); - Console::WriteLine( "\nPassword:" ); - String^ password; - password = Console::ReadLine(); - - // Create a new Uri object. - Uri^ newUri = gcnew Uri( proxyAddress ); - - // Associate the new Uri object to the myProxy object. - myProxy->Address = newUri; - - // Create a NetworkCredential object and is assign to the Credentials - // property of the Proxy object. - myProxy->Credentials = gcnew NetworkCredential( username,password ); - myWebRequest->Proxy = myProxy; - } - Console::WriteLine( "\nThe Address of the new Proxy settings are {0}", myProxy->Address ); - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html pages are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - - // Close the Stream object. - streamResponse->Close(); - streamRead->Close(); - - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress any key to continue........." ); - Console::Read(); - } - catch ( UriFormatException^ e ) - { - Console::WriteLine( "\nUriFormatException is thrown->Message is {0}", e->Message ); - Console::WriteLine( "\nThe format of the myProxy address you entered is invalid" ); - Console::WriteLine( "\nPress any key to continue........." ); - Console::Read(); - } -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised. " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp deleted file mode 100644 index f763b367eb0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*System::Net::WebRequest::RequestUri -* This program demonstrates the 'RequestUri' property of the 'WebRequest' Class -Here the 'RequestUri' property displays the request Uri name to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new WebRequest object to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - Console::WriteLine( "\nThe Uri requested is {0}", myWebRequest->RequestUri); - // Assign the response object of 'WebRequest' to a 'WebResponse' variable. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - // Get the stream containing content returned by the server. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - Console::WriteLine("\nThe Uri that responded to the request is '{0}'",myWebResponse->ResponseUri); - StreamReader^ reader = gcnew StreamReader(streamResponse); - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - // Display the content. - Console::WriteLine("\nThe HTML Contents received:"); - Console::WriteLine (responseFromServer); - // Cleanup the streams and the response. - reader->Close(); - streamResponse->Close(); - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine("\nWebException is raised. "); - Console::WriteLine("\nThe Error Message is {0} ", e->Message); - Console::WriteLine("\nStatus: {0}", e->Status); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp b/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp deleted file mode 100644 index 2c097ce1e40..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*System::Net::WebRequest::Time->Item[Out] ** This program demonstrates the 'Timeout' property of the WebRequest Class. -A new 'WebRequest' Object* is created. The default value of the 'Timeout' property is printed to the console. -It is then set to a value and displayed to the console. If the 'Timeout' property is set to a value less than -the time required to get the response an Exception is raised. The 'Timeout' property measures the time in -milliseconds. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; -using namespace System::Text; - -int main() -{ - try - { -// - // Create a new WebRequest Object to the mentioned URL. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - Console::WriteLine( "\nThe Timeout time of the request before setting is : {0} milliseconds", myWebRequest->Timeout ); - - // Set the 'Timeout' property in Milliseconds. - myWebRequest->Timeout = 10000; - - // This request will throw a WebException if it reaches the timeout limit - // before it is able to fetch the resource. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); -// - - // Print the Timeout time to the console. - Console::WriteLine( "\nThe Time->Item[Out] time* of the request after setting the time is : {0} milliseconds", myWebRequest->Timeout ); - Console::WriteLine( "\nPress any Key to Continue..........." ); - Console::Read(); - // Print the HTML contents of the page to the console. - Stream^ streamResponse = myWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuff = gcnew array(256); - int count = streamRead->Read( readBuff, 0, 256 ); - Console::WriteLine( "\nThe contents of the Html page of the requested Url are :" ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuff,0,count ); - Console::Write( outputData ); - count = streamRead->Read( readBuff, 0, 256 ); - } - streamResponse->Close(); - streamRead->Close(); - // Release the HttpWebResponse Resource. - myWebResponse->Close(); - Console::WriteLine( "\nPress any Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - Console::WriteLine( "\nStatus: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException is raised " ); - Console::WriteLine( "\nMessage: {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp b/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp deleted file mode 100644 index 5c7f5fadec3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Net::WebResponse::Close -/*This program demonstrates the 'Close' method of 'WebResponse' Class. -It takes an URL from console and creates a 'WebRequest' Object* for the Url::It then gets back -the response Object* from the Url. The response Object* can be processed as desired. -The program then closes the response Object* and releases resources associated with it. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Process the response here. - Console::WriteLine( "\nResponse Received::Trying to Close the response stream.." ); - // Release resources of response Object*. - myWebResponse->Close(); - Console::WriteLine( "\nResponse Stream successfully closed" ); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\r\nWebException Raised::Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_Close http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp b/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp deleted file mode 100644 index 3a0d57ce817..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Net::WebResponse::ContentLength;System::Net::WebResponse::ContentType - -/* This program demonstrates the 'ContentLength' and 'ContentType' property of 'WebResponse' class -It creates a web request and queries for a response. It then prints the content length and content type -of the entity body in the response onto the console */ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// -// - // Create a 'WebRequest' with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Display the content length and content type received as headers in the response object. - Console::WriteLine( "\nContent length : {0}, Content Type : {1}", myWebResponse->ContentLength, myWebResponse->ContentType ); - - // Release resources of response object. - myWebResponse->Close(); -// -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException raised. Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_ContentLength_Type http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp b/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp deleted file mode 100644 index 5c96bd1c1dd..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// System::Net::WebResponse::GetResponseStream - -/* This program demonstrates the 'GetResponseStream' method of the 'WebResponse' class. -It creates a web request and queries for a response. It then gets the response stream. This response stream -is piped to a higher level stream reader. The reader reads 256 characters at a time, writes them into a String* and then displays the String* in the console. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void getPage( String^ url ) -{ - try - { -// - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Obtain a 'Stream' object associated with the response object. - Stream^ ReceiveStream = myWebResponse->GetResponseStream(); - - Encoding^ encode = System::Text::Encoding::GetEncoding( "utf-8" ); - - // Pipe the stream to a higher level stream reader with the required encoding format. - StreamReader^ readStream = gcnew StreamReader( ReceiveStream,encode ); - Console::WriteLine( "\nResponse stream received" ); - array^ read = gcnew array(256); - - // Read 256 charcters at a time. - int count = readStream->Read( read, 0, 256 ); - Console::WriteLine( "HTML...\r\n" ); - - while ( count > 0 ) - { - // Dump the 256 characters on a string and display the string onto the console. - String^ str = gcnew String( read,0,count ); - Console::Write( str ); - count = readStream->Read( read, 0, 256 ); - } - - Console::WriteLine( "" ); - // Release the resources of stream object. - readStream->Close(); - - // Release the resources of response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised::Status is: {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease enter the Url as command line parameter:" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_GetResponseStream http://www.microsoft.com/net/" ); - } - else - { - getPage( args[ 1 ] ); - } - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp b/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp deleted file mode 100644 index 5ae94b10d17..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// System::Net::WebResponse::Headers -/* This program demonstrates the 'Headers' property of the 'WebResponse' class. -It creates a web request and queries for a response. It then prints out all the response -headers (name -value pairs) onto the console */ -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { - // - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Display all the Headers present in the response received from the URl. - Console::WriteLine( "\nThe following headers were received in the response" ); - - // Display each header and its key , associated with the response object. - for ( int i = 0; i < myWebResponse->Headers->Count; ++i ) - Console::WriteLine( "\nHeader Name: {0}, Header value : {1}", myWebResponse->Headers->Keys[ i ], myWebResponse->Headers[ i ] ); - - // Release resources of response object. - myWebResponse->Close(); - - // - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Raised::Status is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised.Message is : {0}", e->Message ); - } - -} - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_Headers http://www.microsoft.com/net/" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp b/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp deleted file mode 100644 index e54b2a6b212..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Net::WebResponse::ResponseUri - -/* This program demonstrates the 'ResponseUri' property of the 'WebResponse' class -It creates a web request and queries for a response. It then compares the ResponseUri value to the actual Url -value to see if the original request was redirected*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::IO; -using namespace System::Text; - -void GetPage( String^ url ) -{ - try - { -// - Uri^ ourUri = gcnew Uri( url ); - - // Create a 'WebRequest' object with the specified url. - WebRequest^ myWebRequest = WebRequest::Create( url ); - - // Send the 'WebRequest' and wait for response. - WebResponse^ myWebResponse = myWebRequest->GetResponse(); - - // Use "ResponseUri" property to get the actual Uri from where the response was attained. - if ( ourUri->Equals( myWebResponse->ResponseUri ) ) - { - Console::WriteLine( "\nRequest Url : {0} was not redirected", url ); - } - else - { - Console::WriteLine( "\nRequest Url : {0} was redirected to {1}", url, myWebResponse->ResponseUri ); - } - - // Release resources of response object. - myWebResponse->Close(); -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException is raised->Status is : {0}", e->Status ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nThe following Exception was raised->Message is: {0}", e->Message ); - } -} - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length < 2 ) - { - Console::WriteLine( "\nPlease type the Url as command line parameter" ); - Console::WriteLine( "Example:" ); - Console::WriteLine( "WebResponse_ResponseUri http://www.microsoft.com" ); - } - else - { - GetPage( args[ 1 ] ); - } - - Console::WriteLine( "Press any key to continue..." ); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp b/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp deleted file mode 100644 index a1d62acbb7b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -This program demonstrates the 'Intersect' and 'Union' methods of 'DnsPermission' class. -It creates a 'DnsPermission' instance that is the Union/Intersection of current permission -instance and specified permission instance. -*/ - -#using - -using namespace System; -using namespace System::Net; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Collections; - -public ref class DnsPermissionExample -{ -private: - DnsPermission^ dnsPermission1; - DnsPermission^ dnsPermission2; - - // -private: - void MyUnion() - { - // Create a DnsPermission instance that is the union of the current DnsPermission - // instance and the specified DnsPermission instance. - DnsPermission^ permission = dynamic_cast(dnsPermission1->Union( dnsPermission2 )); - // Print the attributes and the values of the union instance of DnsPermission. - PrintKeysAndValues( permission->ToXml()->Attributes ); - } - - // -public: - void useDns() - { - // Create a DnsPermission instance. - dnsPermission1 = gcnew DnsPermission( PermissionState::Unrestricted ); - dnsPermission2 = gcnew DnsPermission( PermissionState::None ); - // Check for permission. - dnsPermission1->Demand(); - dnsPermission2->Demand(); - Console::WriteLine( "Attributes and Values of first DnsPermission instance :" ); - PrintKeysAndValues( dnsPermission1->ToXml()->Attributes ); - Console::WriteLine( "Attributes and Values of second DnsPermission instance :" ); - PrintKeysAndValues( dnsPermission2->ToXml()->Attributes ); - Console::WriteLine( "Union of both instances : " ); - MyUnion(); - Console::WriteLine( "Intersection of both instances : " ); - MyIntersection(); - } - -private: - void PrintKeysAndValues( Hashtable^ myList ) - { - // Get the enumerator that can iterate through the hash tabble. - IDictionaryEnumerator^ myEnumerator = myList->GetEnumerator(); - Console::WriteLine( "\t-KEY-\t-VALUE-" ); - while ( myEnumerator->MoveNext() ) - { - Console::WriteLine( "\t {0}:\t {1}", myEnumerator->Key, myEnumerator->Value ); - } - Console::WriteLine(); - } - // - - // Create a DnsPermission instance that is the intersection of current - // DnsPermission instance and the specified DnsPermission instance. - void MyIntersection() - { - DnsPermission^ permission = dynamic_cast(dnsPermission1->Intersect( dnsPermission2 )); - // Print the attributes and the values of the intersection instance of - // DnsPermission. - PrintKeysAndValues( permission->ToXml()->Attributes ); - } - // -}; - -int main() -{ - try - { - DnsPermissionExample^ dnsPermissionExampleObj = gcnew DnsPermissionExample; - dnsPermissionExampleObj->useDns(); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught!!!" ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } -} diff --git a/xml/System.Net.Cache/HttpCacheAgeControl.xml b/xml/System.Net.Cache/HttpCacheAgeControl.xml index f7232a297f6..dfe7bf1d211 100644 --- a/xml/System.Net.Cache/HttpCacheAgeControl.xml +++ b/xml/System.Net.Cache/HttpCacheAgeControl.xml @@ -42,19 +42,18 @@ Specifies the meaning of time values that control caching behavior for resources obtained using objects. - class to configure the time values for cache policies. - - - -## Examples - The following code example creates a policy based on MaxAgeAndMinFresh. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet9"::: + class to configure the time values for cache policies. + + + +## Examples + The following code example creates a policy based on MaxAgeAndMinFresh. + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet9"::: + ]]> Cache Management for Network Applications diff --git a/xml/System.Net.Cache/HttpRequestCacheLevel.xml b/xml/System.Net.Cache/HttpRequestCacheLevel.xml index f44fff9d968..20f48b8b786 100644 --- a/xml/System.Net.Cache/HttpRequestCacheLevel.xml +++ b/xml/System.Net.Cache/HttpRequestCacheLevel.xml @@ -42,25 +42,24 @@ Specifies caching behavior for resources obtained using the Hypertext Transfer protocol (HTTP). - objects. - - This `BypassCache` value is the default cache behavior specified in the machine configuration file that ships with the .NET Framework. No entries are taken from caches, added to caches, or removed from caches between the client and server. - - The property is used to get or set the default cache policy for instances. The property is used to get or set the default cache policy for a instance. The property is used to get or set the cache policy for a specific request. - - A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. So another request for the same resource could use a cached copy, depending on the default cache policy level for this request. - - - -## Examples - The following code example sets the application domain's caching policy to Default. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet2"::: + objects. + + This `BypassCache` value is the default cache behavior specified in the machine configuration file that ships with the .NET Framework. No entries are taken from caches, added to caches, or removed from caches between the client and server. + + The property is used to get or set the default cache policy for instances. The property is used to get or set the default cache policy for a instance. The property is used to get or set the cache policy for a specific request. + + A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. So another request for the same resource could use a cached copy, depending on the default cache policy level for this request. + + + +## Examples + The following code example sets the application domain's caching policy to Default. + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet2"::: + ]]> diff --git a/xml/System.Net.Cache/HttpRequestCachePolicy.xml b/xml/System.Net.Cache/HttpRequestCachePolicy.xml index e7a28109bcd..8dbb1a6646a 100644 --- a/xml/System.Net.Cache/HttpRequestCachePolicy.xml +++ b/xml/System.Net.Cache/HttpRequestCachePolicy.xml @@ -43,23 +43,22 @@ Defines an application's caching requirements for resources obtained by using objects. - property or the application or machine configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). - - You can specify the cache policy for an individual request by using the property. - - Caching for Web services is not supported. - - - -## Examples - The following code example creates a default cache policy for the application domain, and overrides it for a request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet2"::: - + property or the application or machine configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). + + You can specify the cache policy for an individual request by using the property. + + Caching for Web services is not supported. + + + +## Examples + The following code example creates a default cache policy for the application domain, and overrides it for a request. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet2"::: + ]]> Cache Management for Network Applications @@ -115,19 +114,18 @@ Initializes a new instance of the class. - property to . - - - -## Examples - The following code example demonstrates setting the cache policy using this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: - + property to . + + + +## Examples + The following code example demonstrates setting the cache policy using this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: + ]]> @@ -170,21 +168,20 @@ A object that specifies the time when resources stored in the cache must be revalidated. Initializes a new instance of the class using the specified cache synchronization date. - property to . The property is initialized to `cacheSyncDate`. - - - -## Examples - The following code example demonstrates creating a cache policy based on a cache synchronization date. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet3"::: - + property to . The property is initialized to `cacheSyncDate`. + + + +## Examples + The following code example demonstrates creating a cache policy based on a cache synchronization date. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet3"::: + ]]> @@ -227,21 +224,20 @@ An value. Initializes a new instance of the class using the specified cache policy. - property to `level`. - - The value controls whether caching is enabled, and when the cache can be used. For additional information, see the documentation. - - - -## Examples - The following code example demonstrates creating a cache policy that allows resources found in the cache to be used from the cache. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet12"::: - + property to `level`. + + The value controls whether caching is enabled, and when the cache can be used. For additional information, see the documentation. + + + +## Examples + The following code example demonstrates creating a cache policy that allows resources found in the cache to be used from the cache. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet12"::: + ]]> @@ -286,21 +282,20 @@ A value that specifies an amount of time. Initializes a new instance of the class using the specified age control and time values. - , the property is set to the value of the `ageOrFreshOrStale` parameter. - - This constructor initializes the property to . - - - -## Examples - The following code example demonstrates creating a cache policy based on minimum freshness. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet5"::: - + , the property is set to the value of the `ageOrFreshOrStale` parameter. + + This constructor initializes the property to . + + + +## Examples + The following code example demonstrates creating a cache policy based on minimum freshness. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet5"::: + ]]> The value specified for the parameter cannot be used with this constructor. @@ -348,23 +343,22 @@ A value that specifies an amount of time. Initializes a new instance of the class using the specified maximum age, age control value, and time value. - , the property is set to the value of the `freshOrStale` parameter. When you specify , the property is set using the value of the `maxAge` parameter and the property is set using the value of the `freshOrStale` parameter. - - Note that unless you specify or , the property is not set. - - This constructor initializes the property to . - - - -## Examples - The following code example demonstrates creating a cache policy based on minimum freshness and maximum age. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet9"::: - + , the property is set to the value of the `freshOrStale` parameter. When you specify , the property is set using the value of the `maxAge` parameter and the property is set using the value of the `freshOrStale` parameter. + + Note that unless you specify or , the property is not set. + + This constructor initializes the property to . + + + +## Examples + The following code example demonstrates creating a cache policy based on minimum freshness and maximum age. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet9"::: + ]]> The value specified for the parameter is not valid. @@ -414,23 +408,22 @@ A object that specifies the time when resources stored in the cache must be revalidated. Initializes a new instance of the class using the specified maximum age, age control value, time value, and cache synchronization date. - , the property is set to the value of the `freshOrStale` parameter. When you specify , the property is set using the value of the `maxAge` parameter and the property is set using the value of the `freshOrStale` parameter. - - Note that unless you specify or , the property is not set. - - This constructor initializes the property to `cacheSyncDate`, and initializes the property to . - - - -## Examples - The following code example demonstrates creating a cache policy based on minimum freshness, maximum age, and a cache synchronization date. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet10"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet10"::: - + , the property is set to the value of the `freshOrStale` parameter. When you specify , the property is set using the value of the `maxAge` parameter and the property is set using the value of the `freshOrStale` parameter. + + Note that unless you specify or , the property is not set. + + This constructor initializes the property to `cacheSyncDate`, and initializes the property to . + + + +## Examples + The following code example demonstrates creating a cache policy based on minimum freshness, maximum age, and a cache synchronization date. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet10"::: + ]]> @@ -473,19 +466,18 @@ Gets the cache synchronization date for this instance. A value set to the date specified when this instance was created. If no date was specified, this property's value is DateTime.MinValue. - @@ -534,19 +526,18 @@ Gets the value that was specified when this instance was created. A value that specifies the cache behavior for resources that were obtained using objects. - as their cache policy level. The property, if not `null`, determines the cache policy in effect for a request. The default policy for the application domain can be set using the property or by settings in the machine or application configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). - - - -## Examples - The following code example demonstrates displaying the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: - + as their cache policy level. The property, if not `null`, determines the cache policy in effect for a request. The default policy for the application domain can be set using the property or by settings in the machine or application configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). + + + +## Examples + The following code example demonstrates displaying the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: + ]]> @@ -595,19 +586,18 @@ Gets the maximum age permitted for a resource returned from the cache. A value that is set to the maximum age value specified when this instance was created. If no date was specified, this property's value is DateTime.MinValue. - @@ -656,19 +646,18 @@ Gets the maximum staleness value that is permitted for a resource returned from the cache. A value that is set to the maximum staleness value specified when this instance was created. If no date was specified, this property's value is DateTime.MinValue. - @@ -717,19 +706,18 @@ Gets the minimum freshness that is permitted for a resource returned from the cache. A value that specifies the minimum freshness specified when this instance was created. If no date was specified, this property's value is DateTime.MinValue. - @@ -773,19 +761,18 @@ Returns a string representation of this instance. A value that contains the property values for this instance. - diff --git a/xml/System.Net.Cache/RequestCacheLevel.xml b/xml/System.Net.Cache/RequestCacheLevel.xml index 4afc7ee5e82..c5ced645580 100644 --- a/xml/System.Net.Cache/RequestCacheLevel.xml +++ b/xml/System.Net.Cache/RequestCacheLevel.xml @@ -42,25 +42,24 @@ Specifies caching behavior for resources obtained using and its derived classes. - objects. The current setting for a object is available in the property. - - This value is the default cache behavior specified in the machine configuration file that ships with the .NET Framework. No entries are taken from caches, added to caches, or removed from caches between the client and server. - - The property is used to get or set the default cache policy for instances. The property is used to get or set the default cache policy for a instances. The property is used to get or set the cache policy for a specific request. + objects. The current setting for a object is available in the property. -A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. So another request for the same resource could use a cached copy, depending on the default cache policy level for this request. - -## Examples - The following code example creates policy that returns a resource only if it is in the cache. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + This value is the default cache behavior specified in the machine configuration file that ships with the .NET Framework. No entries are taken from caches, added to caches, or removed from caches between the client and server. + + The property is used to get or set the default cache policy for instances. The property is used to get or set the default cache policy for a instances. The property is used to get or set the cache policy for a specific request. + +If the cache behavior is `CacheIfAvailable` or `Revalidate`, a copy of a requested resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. With `CacheIfAvailable`, subsequent requests for the same resource would use a cached copy. With `Revalidate`, subsequent requests for the same resource would use a cached copy if the timestamp for the cached resource is the same as the timestamp of the resource on the server. + +A copy of a resource is only added to the cache if the response stream for the resource is retrieved and read to the end of the stream. So another request for the same resource could use a cached copy, depending on the default cache policy level for this request. + +## Examples + The following code example creates policy that returns a resource only if it is in the cache. + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + ]]> diff --git a/xml/System.Net.Cache/RequestCachePolicy.xml b/xml/System.Net.Cache/RequestCachePolicy.xml index da0e12c62c6..0c9f5b0866e 100644 --- a/xml/System.Net.Cache/RequestCachePolicy.xml +++ b/xml/System.Net.Cache/RequestCachePolicy.xml @@ -43,23 +43,22 @@ Defines an application's caching requirements for resources obtained by using objects. - property or the application or machine configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). - - You can specify the cache policy for an individual request by using the property. - - Caching for Web services is not supported. - - - -## Examples - The following code example creates a policy with set to , and uses it to set the cache policy of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + property or the application or machine configuration files. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). + + You can specify the cache policy for an individual request by using the property. + + Caching for Web services is not supported. + + + +## Examples + The following code example creates a policy with set to , and uses it to set the cache policy of a . + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + ]]> Cache Management for Network Applications @@ -115,19 +114,18 @@ Initializes a new instance of the class. - property to . - - - -## Examples - The following example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: - + property to . + + + +## Examples + The following example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet11"::: + ]]> Cache Management for Network Applications @@ -171,21 +169,20 @@ A that specifies the cache behavior for resources obtained using objects. Initializes a new instance of the class. using the specified cache policy. - property to `level`. - - The value controls whether caching is enabled, and when the cache can be used. For additional information, see the documentation. - - - -## Examples - The following code example creates a policy with set to .and uses it to set the cache policy of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: - + property to `level`. + + The value controls whether caching is enabled, and when the cache can be used. For additional information, see the documentation. + + + +## Examples + The following code example creates a policy with set to .and uses it to set the cache policy of a . + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + ]]> level is not a valid .value. @@ -236,21 +233,20 @@ Gets the value specified when this instance was constructed. A value that specifies the cache behavior for resources obtained using objects. - as their cache policy level. Using the level, the effective cache policy is determined by the current cache policy and the age of the content in the cache. The property, if not `null`, determines the cache policy in effect for a request. - - The default policy for the application domain can be set using the or the application or machine configuration file. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). - - - -## Examples - The following code example creates a policy and sends a request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: - + as their cache policy level. Using the level, the effective cache policy is determined by the current cache policy and the age of the content in the cache. The property, if not `null`, determines the cache policy in effect for a request. + + The default policy for the application domain can be set using the or the application or machine configuration file. For more information, see [<requestCaching> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/requestcaching-element-network-settings). + + + +## Examples + The following code example creates a policy and sends a request. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet13"::: + ]]> Cache Management for Network Applications @@ -295,14 +291,13 @@ Returns a string representation of this instance. A containing the for this instance. - policy and sends a request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet14"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet14"::: - + policy and sends a request. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet14"::: + ]]> Cache Management for Network Applications diff --git a/xml/System.Net.Mail/Attachment.xml b/xml/System.Net.Mail/Attachment.xml index e27a6f16957..45c804fcebe 100644 --- a/xml/System.Net.Mail/Attachment.xml +++ b/xml/System.Net.Mail/Attachment.xml @@ -67,7 +67,6 @@ ## Examples The following code example demonstrates attaching a file to an email message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: ]]> @@ -137,7 +136,6 @@ ## Examples The following code example demonstrates how to call this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet13"::: ]]> @@ -200,7 +198,6 @@ ## Examples The following code example demonstrates how to call this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet14"::: ]]> @@ -273,7 +270,6 @@ ## Examples The following code example demonstrates how to call this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet15"::: ]]> @@ -386,7 +382,6 @@ ## Examples The following code example demonstrates how to call this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet12"::: ]]> @@ -459,7 +454,6 @@ ## Examples The following code example demonstrates how to call this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet16"::: ]]> @@ -519,7 +513,6 @@ ## Examples The following code example gets the for an attachment and displays its properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet11"::: ]]> @@ -764,7 +757,6 @@ ## Examples The following code example demonstrates how to display information about an attachment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet19"::: ]]> diff --git a/xml/System.Net.Mail/AttachmentCollection.xml b/xml/System.Net.Mail/AttachmentCollection.xml index 321b66cbb1c..7193fe5e23d 100644 --- a/xml/System.Net.Mail/AttachmentCollection.xml +++ b/xml/System.Net.Mail/AttachmentCollection.xml @@ -56,23 +56,22 @@ Stores attachments to be sent as part of an email message. - class are returned by the and properties. - - Use the property to specify copies of an email message in different formats. For example, if you send a message in HTML, you might also want provide a plain text version in case some of the recipients use email readers that cannot display HTML content. - - Use the collection returned by the property to add an attachment, such as a file or the contents of a to this . - - - -## Examples - The following code example demonstrates how to create and send an email message with an attachment. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + class are returned by the and properties. + + Use the property to specify copies of an email message in different formats. For example, if you send a message in HTML, you might also want provide a plain text version in case some of the recipients use email readers that cannot display HTML content. + + Use the collection returned by the property to add an attachment, such as a file or the contents of a to this . + + + +## Examples + The following code example demonstrates how to create and send an email message with an attachment. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -159,11 +158,11 @@ Releases all resources used by the . - method. You do not have to call it in your application. - + method. You do not have to call it in your application. + ]]> diff --git a/xml/System.Net.Mail/MailAddress.xml b/xml/System.Net.Mail/MailAddress.xml index 118959c5818..e2fada79d42 100644 --- a/xml/System.Net.Mail/MailAddress.xml +++ b/xml/System.Net.Mail/MailAddress.xml @@ -49,75 +49,64 @@ Represents the address of an electronic mail sender or recipient. - class is used by the and classes to store address information for email messages. - -A mail address is composed of a name, name and optionally, a . The can contain non-ASCII characters if you encode them. - + class is used by the and classes to store address information for email messages. + +A mail address is composed of a name, name and optionally, a . The can contain non-ASCII characters if you encode them. + The class supports the following mail address formats: - -- A simple address format of `user@host`. If a is not set, this is the mail address format generated. - -- A standard quoted display name format of `"display name" `. If a is set, this is the format generated. - - - Angle brackets are added around the name and name, if these are not included. For example, `"display name" user@host` is changed to `"display name" `. - - - Quotes are added around the , if these are not included. For example, `display name ` is changed to `"display name" `. - - - Unicode characters are supported in the property. - + +- A simple address format of `user@host`. If a is not set, this is the mail address format generated. +- A standard quoted display name format of `"display name" `. If a is set, this is the format generated. + + - Angle brackets are added around the name and name, if these are not included. For example, `"display name" user@host` is changed to `"display name" `. + - Quotes are added around the , if these are not included. For example, `display name ` is changed to `"display name" `. + - Unicode characters are supported in the property. + Within these two formats, the following elements are allowed: -- A name with quotes. For example, `"user name"@host`. - -- Consecutive and trailing dots in user names. For example, `user...name..@host`. - -- Bracketed domain literals. For example, ``. - -- Comments. For example, `(comment)"display name"(comment)<(comment)user(comment)@(comment)domain(comment)>(comment)`. Comments are removed before transmission. - +- A name with quotes. For example, `"user name"@host`. +- Consecutive and trailing dots in user names. For example, `user...name..@host`. +- Bracketed domain literals. For example, ``. +- Comments. For example, `(comment)"display name"(comment)<(comment)user(comment)@(comment)domain(comment)>(comment)`. Comments are removed before transmission. + A comma is used to separate elements in a list of mail addresses. As a result, a comma should not be used in unquoted display names in a list. The following mail addresses would be allowed: - -`"John, Doe" , "Bob, Smith" ` - -The following mail address would not be allowed: - -`John, Doe , Bob, Smith ` - + +`"John, Doe" , "Bob, Smith" ` + +The following mail address would not be allowed: + +`John, Doe , Bob, Smith ` + Quotes can be embedded in a quoted string, but they must be escaped. The following mail addresses would be allowed: - -`"John \"Jr\" Doe" ` - -`"\"John \\\"Jr\\\" Doe\" "` - -The following mail address would not be allowed: - -`"John "Jr" Doe" ` - + +`"John \"Jr\" Doe" ` + +`"\"John \\\"Jr\\\" Doe\" "` + +The following mail address would not be allowed: + +`"John "Jr" Doe" ` + When the username is not quoted, all text between the start of the string (or comma) and the address are considered part of the , including comments. For example: - + `(non comment) unquoted display (non comment) name (non comment) ` - -Although the class accepts a mail address as valid, other mail servers may not accept the mail address. - -The class does not support the following mail address formats: - + +Although the class accepts a mail address as valid, other mail servers may not accept the mail address. + +The class does not support the following mail address formats: + - Mixed quoted and unquoted display names. For example, `display "name" `. - -- Groups, as defined in RFC 2822 Section 3.4 published by the IETF. - +- Groups, as defined in RFC 2822 Section 3.4 published by the IETF. - The obsolete user name formats of `"user"."name"@host`, `user."name"@host` or `"user".name@host`. - - - -## Examples -The following code example demonstrates sending an email message by using the , , and classes. - -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet10"::: -:::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: - + +## Examples +The following code example demonstrates sending an email message by using the , , and classes. + +:::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: + ]]> @@ -176,32 +165,31 @@ The following code example demonstrates sending an email message by using the A that contains an email address. Initializes a new instance of the class using the specified address. - "` - - White space is permitted between the display name and the angle brackets. - - The following table shows the property values for a object constructed using the preceding example address. - -|Property|Value| -|--------------|-----------| -||`"Tom Smith"`| -||`"contoso.com"`| -||`"tsmith"`| -||`"tsmith@contoso.com"`| - - - -## Examples - The following code example uses this constructor to create a object for the recipient of an email message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: - + "` + + White space is permitted between the display name and the angle brackets. + + The following table shows the property values for a object constructed using the preceding example address. + +|Property|Value| +|--------------|-----------| +||`"Tom Smith"`| +||`"contoso.com"`| +||`"tsmith"`| +||`"tsmith@contoso.com"`| + + + +## Examples + The following code example uses this constructor to create a object for the recipient of an email message. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + ]]> @@ -266,23 +254,22 @@ The following code example demonstrates sending an email message by using the A that contains the display name associated with . This parameter can be . Initializes a new instance of the class using the specified address and display name. - , `displayName` overrides the value specified in `address`. - - - -## Examples - The following code example uses this constructor to create instances for the sender and recipient of an email message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: - + , `displayName` overrides the value specified in `address`. + + + +## Examples + The following code example uses this constructor to create instances for the sender and recipient of an email message. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + ]]> @@ -290,10 +277,10 @@ The following code example demonstrates sending an email message by using the is (""). - is not in a recognized format. - - -or- - + is not in a recognized format. + + -or- + contains non-ASCII characters. @@ -347,45 +334,44 @@ The following code example demonstrates sending an email message by using the The that defines the character set used for . Initializes a new instance of the class using the specified address, display name, and encoding. - , `displayName` overrides the value specified in `address`. - - The method does not check if the `displayName` parameter is valid. This method removes surrounding quotes not displayed by the property. Quotes will be added before transmission, except where or is specified in the `displayNameEncoding` parameter. The encoding specified in the `displayNameEncoding` parameter will be applied to the property before transmission or is specified in the `displayNameEncoding` parameter. is the default encoding if none is specified. - - For more information on supported mail address formats, see . - - - -## Examples - The following code example uses this constructor to create instances for the sender of an email message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet2"::: + , `displayName` overrides the value specified in `address`. + + The method does not check if the `displayName` parameter is valid. This method removes surrounding quotes not displayed by the property. Quotes will be added before transmission, except where or is specified in the `displayNameEncoding` parameter. The encoding specified in the `displayNameEncoding` parameter will be applied to the property before transmission or is specified in the `displayNameEncoding` parameter. is the default encoding if none is specified. + + For more information on supported mail address formats, see . + + + +## Examples + The following code example uses this constructor to create instances for the sender of an email message. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet2"::: + ]]> - is . - - -or- - + is . + + -or- + is . - is (""). - - -or- - + is (""). + + -or- + is (""). - is not in a recognized format. - - -or- - + is not in a recognized format. + + -or- + contains non-ASCII characters. @@ -427,19 +413,18 @@ The following code example demonstrates sending an email message by using the Gets the email address specified when this instance was created.
A that contains the email address. - information. - - - -## Examples - The following code example displays the address for an email message recipient. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet10"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: - + information. + + + +## Examples + The following code example displays the address for an email message recipient. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: + ]]>
@@ -488,21 +473,20 @@ The following code example demonstrates sending an email message by using the Gets the display name composed from the display name and address information specified when this instance was created.
A that contains the display name; otherwise, ("") if no display name information was specified when this instance was created. - method to get the encoded form of the . - - Some software programs that are used to read email display the property value instead of, or in addition to, the email address. - - - -## Examples - The following code example displays the for the recipient of an email message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: - + method to get the encoded form of the . + + Some software programs that are used to read email display the property value instead of, or in addition to, the email address. + + + +## Examples + The following code example displays the for the recipient of an email message. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + ]]>
@@ -599,11 +583,11 @@ The following code example demonstrates sending an email message by using the Returns a hash value for a mail address.
An integer hash value. - method returns a hash code of the mail address. This value can be used as a key in hash tables. - + method returns a hash code of the mail address. This value can be used as a key in hash tables. + ]]>
@@ -652,19 +636,18 @@ The following code example demonstrates sending an email message by using the Gets the host portion of the address specified when this instance was created.
A that contains the name of the host computer that accepts email for the property. -
@@ -708,23 +691,22 @@ The following code example demonstrates sending an email message by using the Returns a string representation of this instance.
A that contains the contents of this . - property is not `null` and not equal to (""), returns a string composed using the following syntax: - - \<@> - - If is `null` or is equal to , returns the value of the property. - - - -## Examples - The following code example displays the destination of an email message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet7"::: - + property is not `null` and not equal to (""), returns a string composed using the following syntax: + + \<@> + + If is `null` or is equal to , returns the value of the property. + + + +## Examples + The following code example displays the destination of an email message. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet7"::: + ]]>
@@ -932,19 +914,18 @@ The following code example demonstrates sending an email message by using the Gets the user information from the address specified when this instance was created.
A that contains the user name portion of the . -
diff --git a/xml/System.Net.Mail/MailAddressCollection.xml b/xml/System.Net.Mail/MailAddressCollection.xml index 3b30f2dd8f5..8e8d9462c38 100644 --- a/xml/System.Net.Mail/MailAddressCollection.xml +++ b/xml/System.Net.Mail/MailAddressCollection.xml @@ -52,21 +52,20 @@ Store email addresses that are associated with an email message. - , , and properties return instances of this class that are used to hold the respective email addresses. - - For details on the mail address formats supported by the class, see the class. - - - -## Examples - The following example adds an email address to the that is returned by the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + , , and properties return instances of this class that are used to hold the respective email addresses. + + For details on the mail address formats supported by the class, see the class. + + + +## Examples + The following example adds an email address to the that is returned by the property. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + ]]> @@ -155,11 +154,11 @@ The email addresses to add to the . Multiple email addresses must be separated with a comma character (","). Add a list of email addresses to the collection. - exception is raised. - + exception is raised. + ]]> The parameter is null. @@ -298,19 +297,18 @@ Returns a string representation of the email addresses in this object. A containing the email addresses in this collection. - that are returned by the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: - + that are returned by the property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: + ]]> diff --git a/xml/System.Net.Mail/MailMessage.xml b/xml/System.Net.Mail/MailMessage.xml index fcafa90398b..b9803064ad1 100644 --- a/xml/System.Net.Mail/MailMessage.xml +++ b/xml/System.Net.Mail/MailMessage.xml @@ -80,35 +80,21 @@ If some mail headers are malformed, they could cause the email message to become corrupted. So any mail header in the headers collection that can be set using a property on the class should only be set using the class property or as a parameter passed when a initializes a object. The following list of mail headers should not be added using the property and any values set for these headers using the property will be discarded or overwritten when the message is sent: -- Bcc - -- Cc - -- Content-ID - -- Content-Location - -- Content-Transfer-Encoding - -- Content-Type - -- Date - -- From - -- Importance - -- MIME-Version - -- Priority - -- Reply-To - -- Sender - -- To - -- X-Priority +- Bcc +- Cc +- Content-ID +- Content-Location +- Content-Transfer-Encoding +- Content-Type +- Date +- From +- Importance +- MIME-Version +- Priority +- Reply-To +- Sender +- To +- X-Priority If the application does not specify an X-Sender header using the property, the class will create one when the message is sent. @@ -123,7 +109,6 @@ ## Examples The following code example demonstrates creating and sending an email message that includes an attachment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet6"::: @@ -229,12 +214,9 @@ ## Remarks The property is initialized using `from` and the property is initialized using `to`. - - ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet4"::: @@ -300,7 +282,6 @@ ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet2"::: @@ -400,7 +381,6 @@ ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet3"::: @@ -472,7 +452,6 @@ ## Examples The following code example demonstrates creating and sending an email message with a plain text and an HTML alternate view. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet5"::: @@ -530,7 +509,6 @@ ## Examples The following code example demonstrates creating and sending an email message with an attachment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet6"::: @@ -588,7 +566,6 @@ ## Examples The following code example demonstrates adding an address to the address collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet9"::: @@ -646,7 +623,6 @@ ## Examples The following code example demonstrates setting the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet2"::: @@ -719,7 +695,6 @@ ## Examples The following code example demonstrates creating a mail message that uses UTF8 encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet3"::: @@ -818,7 +793,6 @@ ## Examples The following code example demonstrates adding an address to the address collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet10"::: @@ -1060,7 +1034,6 @@ ## Examples The following code example demonstrates setting a value for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet10"::: @@ -1113,35 +1086,35 @@ If some mail headers are malformed, they could cause the email message to become corrupted. So any mail header in the headers collection that can be set using a property on the class should only be set using the class property or as a parameter passed when a initializes a object. The following list of mail headers should not be added using the property and any values set for these headers using the property will be discarded or overwritten when the message is sent: -- Bcc +- Bcc -- Cc +- Cc -- Content-ID +- Content-ID -- Content-Location +- Content-Location -- Content-Transfer-Encoding +- Content-Transfer-Encoding -- Content-Type +- Content-Type -- Date +- Date -- From +- From -- Importance +- Importance -- MIME-Version +- MIME-Version -- Priority +- Priority -- Reply-To +- Reply-To -- Sender +- Sender -- To +- To -- X-Priority +- X-Priority If the application does not specify an X-Sender header using the property, the class will create one when the message is sent. @@ -1168,7 +1141,6 @@ ## Examples The following code example demonstrates displaying the headers for a mail message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet24"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet24"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet24"::: @@ -1542,7 +1514,6 @@ ## Examples The following code example demonstrates setting the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet2"::: @@ -1605,7 +1576,6 @@ ## Examples The following code example demonstrates setting the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet3"::: @@ -1665,7 +1635,6 @@ ## Examples The following code example demonstrates setting the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLMailSync/vb/mail.vb" id="Snippet7"::: diff --git a/xml/System.Net.Mail/SendCompletedEventHandler.xml b/xml/System.Net.Mail/SendCompletedEventHandler.xml index fccd470ac3f..b297ef22eaa 100644 --- a/xml/System.Net.Mail/SendCompletedEventHandler.xml +++ b/xml/System.Net.Mail/SendCompletedEventHandler.xml @@ -51,20 +51,19 @@ An containing event data. Represents the method that will handle the event. - delegate is used to handle events that occur when the class finishes asynchronously sending an email message using the method. + + + +## Examples + The following code example demonstrates sending an email message asynchronously. It uses a to invoke the `SendCompletedCallback` method to handle events. -## Remarks - The delegate is used to handle events that occur when the class finishes asynchronously sending an email message using the method. - - - -## Examples - The following code example demonstrates sending an email message asynchronously. It uses a to invoke the `SendCompletedCallback` method to handle events. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Mail/SmtpAccess.xml b/xml/System.Net.Mail/SmtpAccess.xml index 7ca1e320b81..3636041ec4b 100644 --- a/xml/System.Net.Mail/SmtpAccess.xml +++ b/xml/System.Net.Mail/SmtpAccess.xml @@ -36,19 +36,18 @@ Specifies the level of access allowed to a Simple Mail Transport Protocol (SMTP) server. - enumeration is used by the and classes to specify a level of access to an SMTP host computer. The class demands an when sending electronic mail to the SMTP host for delivery. - - - -## Examples - The following code example uses the enumeration to create a permission object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailPerms/CPP/mailpermissions.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet1"::: + enumeration is used by the and classes to specify a level of access to an SMTP host computer. The class demands an when sending electronic mail to the SMTP host for delivery. + + + +## Examples + The following code example uses the enumeration to create a permission object. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/SmtpAccess/Overview/mailpermissions.cs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Mail/SmtpClient.xml b/xml/System.Net.Mail/SmtpClient.xml index 1d0b33a7ad7..9a4c5ffe2ff 100644 --- a/xml/System.Net.Mail/SmtpClient.xml +++ b/xml/System.Net.Mail/SmtpClient.xml @@ -114,7 +114,6 @@ To include an attachment with an email message, first create the attachment by u The following code example demonstrates sending an email message asynchronously. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: @@ -181,7 +180,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates sending an email message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet4"::: For an example of the \ node in the application or machine configuration file, see [<mailSettings> Element (Network Settings)](/dotnet/framework/configure-apps/file-schema/network/mailsettings-element-network-settings). @@ -241,7 +239,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet3"::: ]]>
@@ -301,7 +298,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet1"::: ]]> @@ -428,7 +424,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates setting the credentials used to send an email. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet1"::: ]]> @@ -830,7 +825,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates sending an email message by using the host and port specified in an application configuration file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet7"::: ]]> @@ -1020,7 +1014,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates sending an email message by using the host and port specified in an application configuration file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet7"::: ]]> @@ -1108,7 +1101,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates using this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet2"::: ]]> @@ -1375,7 +1367,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates calling this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: @@ -1619,7 +1610,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates sending an email message asynchronously. The user has the option to cancel the mail if it has not been sent. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: @@ -1679,7 +1669,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates sending an email message asynchronously. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclMailASync/cpp/mailasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/MailAddress/.ctor/mailasync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclMailASync/vb/mailasync.vb" id="Snippet1"::: @@ -2294,7 +2283,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates getting and setting the time-out value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet3"::: ]]> @@ -2359,7 +2347,6 @@ The following code example demonstrates sending an email message asynchronously. ## Examples The following code example demonstrates using this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet2"::: ]]> diff --git a/xml/System.Net.Mail/SmtpException.xml b/xml/System.Net.Mail/SmtpException.xml index 8a32b477a61..f1cb0df0a5f 100644 --- a/xml/System.Net.Mail/SmtpException.xml +++ b/xml/System.Net.Mail/SmtpException.xml @@ -60,19 +60,18 @@ Represents the exception that is thrown when the is not able to complete a or operation. - property contains the status code returned by the SMTP server. - - - -## Examples - The following code example displays an error message when the exception is thrown. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet27"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet27"::: - + property contains the status code returned by the SMTP server. + + + +## Examples + The following code example displays an error message when the exception is thrown. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet27"::: + ]]> @@ -127,19 +126,18 @@ Initializes a new instance of the class. - property set to . - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet28"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet28"::: - + property set to . + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet28"::: + ]]> @@ -182,19 +180,18 @@ An value. Initializes a new instance of the class with the specified status code. - property. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet30"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet30"::: - + property. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet30"::: + ]]> @@ -238,19 +235,18 @@ A that describes the error that occurred. Initializes a new instance of the class with the specified error message. - property. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet29"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet29"::: - + property. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet29"::: + ]]> @@ -296,19 +292,18 @@ A that describes the error that occurred. Initializes a new instance of the class with the specified status code and error message. - property and uses the `message` parameter to initialize the property. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet31"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet31"::: - + property and uses the `message` parameter to initialize the property. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet31"::: + ]]> @@ -363,11 +358,11 @@ A that contains the source and destination of the serialized stream associated with the new instance. Initializes a new instance of the class from the specified instances of the and classes. - interface for the class. - + interface for the class. + ]]> @@ -413,21 +408,20 @@ The exception that is the cause of the current exception. Initializes a new instance of the class with the specified error message and inner exception. - property and the `innerException` parameter to initialize the property. - - If `innerException` is not `null`, the current exception is raised in a catch block that handles `innerException`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet32"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet32"::: - + property and the `innerException` parameter to initialize the property. + + If `innerException` is not `null`, the current exception is raised in a catch block that handles `innerException`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet32"::: + ]]> @@ -485,11 +479,11 @@ A that specifies the destination for this serialization. Populates a instance with the data needed to serialize the . - are automatically tracked and serialized by the formatter. - + are automatically tracked and serialized by the formatter. + ]]> @@ -542,14 +536,13 @@ Gets the status code returned by an SMTP server when an email message is transmitted. An value that indicates the error that occurred. - diff --git a/xml/System.Net.Mail/SmtpFailedRecipientsException.xml b/xml/System.Net.Mail/SmtpFailedRecipientsException.xml index bb259a3a8bb..3b4a692f4bf 100644 --- a/xml/System.Net.Mail/SmtpFailedRecipientsException.xml +++ b/xml/System.Net.Mail/SmtpFailedRecipientsException.xml @@ -60,19 +60,18 @@ The exception that is thrown when email is sent using an and cannot be delivered to all recipients. - property contains the exceptions received while attempting to send email. The email might have been successfully delivered to some of the recipients. - - - -## Examples - The following code example resends an email message that was not delivered because a mailbox was busy or unavailable. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet27"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet27"::: + property contains the exceptions received while attempting to send email. The email might have been successfully delivered to some of the recipients. + + + +## Examples + The following code example resends an email message that was not delivered because a mailbox was busy or unavailable. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet27"::: + ]]> @@ -217,11 +216,11 @@ A that contains the source of the serialized stream that is associated with the new instance. Initializes a new instance of the class from the specified instances of the and classes. - interface for the class. - + interface for the class. + ]]> @@ -468,11 +467,11 @@ A that contains the source of the serialized stream that is associated with the new . Initializes a new instance of the class from the specified and instances. - interface for the class. - + interface for the class. + ]]> diff --git a/xml/System.Net.Mail/SmtpStatusCode.xml b/xml/System.Net.Mail/SmtpStatusCode.xml index 2303f84f3a0..561eee48d7f 100644 --- a/xml/System.Net.Mail/SmtpStatusCode.xml +++ b/xml/System.Net.Mail/SmtpStatusCode.xml @@ -54,7 +54,6 @@ ## Examples The following code example displays an error message to the console when an is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet23"::: ]]> diff --git a/xml/System.Net.Mime/ContentDisposition.xml b/xml/System.Net.Mime/ContentDisposition.xml index 1a42f309af9..88858524da0 100644 --- a/xml/System.Net.Mime/ContentDisposition.xml +++ b/xml/System.Net.Mime/ContentDisposition.xml @@ -50,27 +50,26 @@ Represents a MIME protocol Content-Disposition header. - class accompanies an email message that contains attachments when the email message is sent to its destination. The information in can be used by software that displays email to present the email attachments in the manner intended by the sender. - - Email messages are created using instances of the class. Instances of the class are used to add attachments to email messages. To modify the for an attachment, get the instance from the property. - - Content to be displayed as part of the message body has the disposition type of . Content that is not displayed but is attached in a separate file has the disposition type of . Use the property to control the disposition type for the attachment associated with an instance of . - - For file attachments, you can use the properties of the to set the file size, as well as the date the file was created, last read, and last modified. For all attachments, you can set a recommended file name in the event that the attachment is stored on the receiving computer. - - The method returns the Content-Disposition header. The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example creates an email message with an attachment to be displayed inline. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet12"::: - + class accompanies an email message that contains attachments when the email message is sent to its destination. The information in can be used by software that displays email to present the email attachments in the manner intended by the sender. + + Email messages are created using instances of the class. Instances of the class are used to add attachments to email messages. To modify the for an attachment, get the instance from the property. + + Content to be displayed as part of the message body has the disposition type of . Content that is not displayed but is attached in a separate file has the disposition type of . Use the property to control the disposition type for the attachment associated with an instance of . + + For file attachments, you can use the properties of the to set the file size, as well as the date the file was created, last read, and last modified. For all attachments, you can set a recommended file name in the event that the attachment is stored on the receiving computer. + + The method returns the Content-Disposition header. The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example creates an email message with an attachment to be displayed inline. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet12"::: + ]]> @@ -119,19 +118,18 @@ Initializes a new instance of the class with a of . - property set to . - - - -## Examples - The following code example demonstrates how to call this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet33"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet33"::: - + property set to . + + + +## Examples + The following code example demonstrates how to call this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet33"::: + ]]> @@ -174,14 +172,13 @@ A value that contains the disposition. Initializes a new instance of the class with the specified disposition information. - @@ -232,23 +229,22 @@ Gets or sets the creation date for a file attachment. A value that indicates the file creation date; otherwise, DateTime.MinValue if no date was specified. - property is used to send time stamp information with a file being sent in an email message. This value sets the Creation-Date parameter in the Content-Disposition header sent with the email. - - The class is used to compose an email message. The class is used to attach a file to an email message. To set , get the for the attachment from the property. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + property is used to send time stamp information with a file being sent in an email message. This value sets the Creation-Date parameter in the Content-Disposition header sent with the email. + + The class is used to compose an email message. The class is used to attach a file to an email message. To set , get the for the attachment from the property. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -297,21 +293,20 @@ Gets or sets the disposition type for an email attachment. A that contains the disposition type. The value is not restricted but is typically one of the values. - property value can be used by software that displays email to determine the correct way to present the email attachments. attachments are usually displayed when the user opens the email. attachments are usually not opened until the user performs some action, such as clicking an icon that represents the attachment. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet24"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet24"::: - + property value can be used by software that displays email to determine the correct way to present the email attachments. attachments are usually displayed when the user opens the email. attachments are usually not opened until the user performs some action, such as clicking an icon that represents the attachment. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet24"::: + ]]> The value specified for a set operation is . @@ -416,23 +411,22 @@ Gets or sets the suggested file name for an email attachment. A that contains the file name. - property allows the sender to suggest the name to be used to store an email attachment on the recipient's computer. This name is a suggestion only; the receiving system can ignore it. The name must not include path information; any such information is ignored by the receiving computer. - - To remove file name information, you can set this property to `null` or the empty string (""). - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet11"::: - + property allows the sender to suggest the name to be used to store an email attachment on the recipient's computer. This name is a suggestion only; the receiving system can ignore it. The name must not include path information; any such information is ignored by the receiving computer. + + To remove file name information, you can set this property to `null` or the empty string (""). + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet11"::: + ]]> @@ -517,21 +511,20 @@ if content in the attachment is presented inline as part of the email body; otherwise, . - property sets the disposition type in the Content-Disposition header sent with the email message. The disposition type can be used by software that displays email to determine the correct way to present the email attachments. Attachments with a disposition type of are usually displayed when the user opens the email. Attachments with a disposition type of are usually not opened until the user performs some additional action, such as clicking an icon that represents the attachment. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet12"::: - + property sets the disposition type in the Content-Disposition header sent with the email message. The disposition type can be used by software that displays email to determine the correct way to present the email attachments. Attachments with a disposition type of are usually displayed when the user opens the email. Attachments with a disposition type of are usually not opened until the user performs some additional action, such as clicking an icon that represents the attachment. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet12"::: + ]]> @@ -580,23 +573,22 @@ Gets or sets the modification date for a file attachment. A value that indicates the file modification date; otherwise, DateTime.MinValue if no date was specified. - property is used to send time stamp information with a file being sent in an email message. This value sets the Modification-Date parameter in the Content-Disposition header sent with the email message. - - The class is used to compose an email message. The class is used to attach a file to an email message. To set the property, get the for the attachment using the property. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + property is used to send time stamp information with a file being sent in an email message. This value sets the Modification-Date parameter in the Content-Disposition header sent with the email message. + + The class is used to compose an email message. The class is used to attach a file to an email message. To set the property, get the for the attachment using the property. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -639,21 +631,20 @@ Gets the parameters included in the Content-Disposition header represented by this instance. A writable that contains parameter name/value pairs. - property. - - The Content-Disposition header is described in RFC 2183, available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays the parameters that are sent to the Content-Disposition header. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + property. + + The Content-Disposition header is described in RFC 2183, available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays the parameters that are sent to the Content-Disposition header. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -702,23 +693,22 @@ Gets or sets the read date for a file attachment. A value that indicates the file read date; otherwise, DateTime.MinValue if no date was specified. - property is used to send time stamp information with a file being sent in an email message. This value sets the Read-Date parameter in the Content-Disposition header sent with the email message. - - The class is used to compose an email message. The class is used to attach a file to an email message. To set , get the for the attachment by using the property. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to set this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + property is used to send time stamp information with a file being sent in an email message. This value sets the Read-Date parameter in the Content-Disposition header sent with the email message. + + The class is used to compose an email message. The class is used to attach a file to an email message. To set , get the for the attachment by using the property. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to set this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -761,21 +751,20 @@ Gets or sets the size of a file attachment. A that specifies the number of bytes in the file attachment. The default value is -1, which indicates that the file size is unknown. - property is used to send time stamp information with a file being sent in an email message. The class is used to compose the message. The class is used to attach a file to an email message. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates how to get this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + property is used to send time stamp information with a file being sent in an email message. The class is used to compose the message. The class is used to attach a file to an email message. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates how to get this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -819,21 +808,20 @@ Returns a representation of this instance. A that contains the property values for this instance. - method is the Content-Disposition header. - - The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example demonstrates calling this method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + method is the Content-Disposition header. + + The Content-Disposition header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example demonstrates calling this method. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> diff --git a/xml/System.Net.Mime/ContentType.xml b/xml/System.Net.Mime/ContentType.xml index 9e4f465ed76..c0f29383d14 100644 --- a/xml/System.Net.Mime/ContentType.xml +++ b/xml/System.Net.Mime/ContentType.xml @@ -49,21 +49,20 @@ Represents a MIME protocol Content-Type header. - class is used to describe the data contained in an email message in such a way that software that displays email can present the content in an appropriate manner. is used with the class to specify the type of content in the attachment. - - The syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information about MIME media types and their parameters. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example sends an email message with an attachment and displays the properties for the attachment. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: - + class is used to describe the data contained in an email message in such a way that software that displays email can present the content in an appropriate manner. is used with the class to specify the type of content in the attachment. + + The syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information about MIME media types and their parameters. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example sends an email message with an attachment and displays the properties for the attachment. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet6"::: + ]]> @@ -114,19 +113,18 @@ Initializes a new default instance of the class. - property to `"application/octet-stream"`. - - - -## Examples - The following code example demonstrates how to call this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet15"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet15"::: - + property to `"application/octet-stream"`. + + + +## Examples + The following code example demonstrates how to call this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet15"::: + ]]> @@ -169,19 +167,18 @@ A , for example, "text/plain; charset=us-ascii", that contains the MIME media type, subtype, and optional parameters. Initializes a new instance of the class using the specified string. - @@ -237,25 +234,24 @@ Gets or sets the value of the boundary parameter included in the Content-Type header represented by this instance. A that contains the value associated with the boundary parameter. - parameter is "`-----boundary---0`". - - `content-type: multipart/mixed; boundary=-----boundary---0` - - Set this property to `null` or to remove the boundary information from the header. - - The syntax of the Content-Type header is described in RFC 2045 Section 5.1. An in-depth discussion of the boundary parameter is contained in RFC 2046 Section 5.1.1. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays the value of the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: - + parameter is "`-----boundary---0`". + + `content-type: multipart/mixed; boundary=-----boundary---0` + + Set this property to `null` or to remove the boundary information from the header. + + The syntax of the Content-Type header is described in RFC 2045 Section 5.1. An in-depth discussion of the boundary parameter is contained in RFC 2046 Section 5.1.1. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays the value of the property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: + ]]> @@ -305,25 +301,24 @@ Gets or sets the value of the charset parameter included in the Content-Type header represented by this instance. A that contains the value associated with the charset parameter. - property is "`us-ascii`". - - `content-type: application/x-myType; charset=us-ascii` - - Set this property to `null` or to remove the charset information from the header. - - A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1. An in-depth discussion of the charset parameter is contained in RFC 2046 Section 4.1.2. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays the value of the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: - + property is "`us-ascii`". + + `content-type: application/x-myType; charset=us-ascii` + + Set this property to `null` or to remove the charset information from the header. + + A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1. An in-depth discussion of the charset parameter is contained in RFC 2046 Section 4.1.2. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays the value of the property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: + ]]> @@ -460,25 +455,24 @@ Gets or sets the media type value included in the Content-Type header represented by this instance. A that contains the media type and subtype value. This value does not include the semicolon (;) separator that follows the subtype. - property is `"application/x-myType"`. - - `content-type: application/x-myType; name=data.xyz` - - Set this property to `null` or to remove the name information from the header. - - The syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information on MIME media types. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example sets the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet13"::: - + property is `"application/x-myType"`. + + `content-type: application/x-myType; name=data.xyz` + + Set this property to `null` or to remove the name information from the header. + + The syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information on MIME media types. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example sets the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet13"::: + ]]> The value specified for a set operation is . @@ -524,25 +518,24 @@ Gets or sets the value of the name parameter included in the Content-Type header represented by this instance. A that contains the value associated with the name parameter. - property is `"data.xyz"`. - - `content-type: application/x-myType; name=data.xyz` - - A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1, available at [https://www.ietf.org](https://www.ietf.org/). - - When specifying content for a as a or , you can use to set the name of the file that stores the content on the recipient's system. - - - -## Examples - The following code example sets the value of the property to specify a name for a file being attached as a stream. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet15"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet15"::: - + property is `"data.xyz"`. + + `content-type: application/x-myType; name=data.xyz` + + A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1, available at [https://www.ietf.org](https://www.ietf.org/). + + When specifying content for a as a or , you can use to set the name of the file that stores the content on the recipient's system. + + + +## Examples + The following code example sets the value of the property to specify a name for a file being attached as a stream. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet15"::: + ]]> @@ -585,23 +578,22 @@ Gets the dictionary that contains the parameters included in the Content-Type header represented by this instance. A writable that contains name and value pairs. - object or you can add parameters to the returned by the property. - - When adding a parameter entry to the dictionary, the name of the parameter is the entry's key and the value of the parameter is the entry's value. - - A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information on MIME media types and their associated parameters. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays the values in the dictionary returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: - + object or you can add parameters to the returned by the property. + + When adding a parameter entry to the dictionary, the name of the parameter is the entry's key and the value of the parameter is the entry's value. + + A grammar that details the syntax of the Content-Type header is described in RFC 2045 Section 5.1. RFC 2046 provides detailed information on MIME media types and their associated parameters. These RFCs are available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays the values in the dictionary returned by this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet5"::: + ]]> @@ -645,21 +637,20 @@ Returns a string representation of this object. A that contains the current settings for this . - method contains the string used to create this , if one was specified and no property values have been changed. If no string was specified, or one or more property values have changed since this was created, the value of is a string in the format of a Content-Type header that is composed using the current property values. The string does not include the `"Content-type:"` prefix. - - The syntax of the Content-Type header is described in RFC 2045 Section 5.1, available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays the string representation of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet13"::: - + method contains the string used to create this , if one was specified and no property values have been changed. If no string was specified, or one or more property values have changed since this was created, the value of is a string in the format of a Content-Type header that is composed using the current property values. The string does not include the `"Content-type:"` prefix. + + The syntax of the Content-Type header is described in RFC 2045 Section 5.1, available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays the string representation of a . + + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet13"::: + ]]> diff --git a/xml/System.Net.Mime/DispositionTypeNames.xml b/xml/System.Net.Mime/DispositionTypeNames.xml index 267897aa286..c818f55a24f 100644 --- a/xml/System.Net.Mime/DispositionTypeNames.xml +++ b/xml/System.Net.Mime/DispositionTypeNames.xml @@ -49,19 +49,18 @@ Supplies the strings used to specify the disposition type for an email attachment. - property for an email attachment. The information in the class represents the MIME Content-Disposition header. This header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example sets the disposition type for an attachment. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet26"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet26"::: + property for an email attachment. The information in the class represents the MIME Content-Disposition header. This header is described in RFC 2183 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example sets the disposition type for an attachment. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet26"::: + ]]> @@ -107,14 +106,13 @@ Specifies that the attachment is to be displayed as a file attached to the email message. - @@ -160,14 +158,13 @@ Specifies that the attachment is to be displayed as part of the email message body. - diff --git a/xml/System.Net.Mime/TransferEncoding.xml b/xml/System.Net.Mime/TransferEncoding.xml index 51097199c5e..2e5097b8d2e 100644 --- a/xml/System.Net.Mime/TransferEncoding.xml +++ b/xml/System.Net.Mime/TransferEncoding.xml @@ -42,23 +42,22 @@ Specifies the Content-Transfer-Encoding header information for an email message attachment. - enumeration are used with the property. - - The Content-Transfer-Encoding header specifies the encoding of the associated message body so that it meets SMTP requirements. SMTP requires data for transport to be in 7-bit US-ASCII characters with lines no longer than 1000 characters. - - Content-Transfer-Encoding values are described in detail in RFC 2045 Section 6, available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example displays used by an attachment. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLMailSync/CPP/NclMailSync.cpp" id="Snippet21"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet21"::: + enumeration are used with the property. + + The Content-Transfer-Encoding header specifies the encoding of the associated message body so that it meets SMTP requirements. SMTP requires data for transport to be in 7-bit US-ASCII characters with lines no longer than 1000 characters. + + Content-Transfer-Encoding values are described in detail in RFC 2045 Section 6, available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example displays used by an attachment. + :::code language="csharp" source="~/snippets/csharp/System.Net.Mail/Attachment/Overview/mail.cs" id="Snippet21"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/DuplicateAddressDetectionState.xml b/xml/System.Net.NetworkInformation/DuplicateAddressDetectionState.xml index 30c54703a30..bf6aba9bab5 100644 --- a/xml/System.Net.NetworkInformation/DuplicateAddressDetectionState.xml +++ b/xml/System.Net.NetworkInformation/DuplicateAddressDetectionState.xml @@ -43,22 +43,21 @@ Specifies the current state of an IP address. - and classes. Instances of this class are returned when you retrieve the unicast address information for a object. + + + +## Examples + The following code example determines unicast address information. -## Remarks - To help ensure that all interfaces on a network have a unique address, the interface host is responsible for running a "duplicate address detection" algorithm on unicast addresses. The purpose of this algorithm is to attempt to prevent non-unique addresses on the network. This process is defined in IETF RFC 1971. - - This enumeration is used by the and classes. Instances of this class are returned when you retrieve the unicast address information for a object. - - - -## Examples - The following code example determines unicast address information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet45"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet45"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/IPAddressInformation.xml b/xml/System.Net.NetworkInformation/IPAddressInformation.xml index e5b907ba255..de763f31e0d 100644 --- a/xml/System.Net.NetworkInformation/IPAddressInformation.xml +++ b/xml/System.Net.NetworkInformation/IPAddressInformation.xml @@ -50,20 +50,19 @@ Provides information about a network interface address. - class. + + + +## Examples + The following code example displays the Domain Name Service (DNS) addresses for the network interfaces on the local computer. -## Remarks - You do not create instances of this class; instances are returned by methods in the class. - - - -## Examples - The following code example displays the Domain Name Service (DNS) addresses for the network interfaces on the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet42"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet42"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet42"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet42"::: + ]]> @@ -109,11 +108,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -157,20 +156,19 @@ Gets the Internet Protocol (IP) address. An instance that contains the IP address of an interface. - @@ -221,20 +219,19 @@ if the address can appear in a DNS database; otherwise, . - @@ -285,11 +282,11 @@ if the address is transient; otherwise, . - diff --git a/xml/System.Net.NetworkInformation/IPGlobalProperties.xml b/xml/System.Net.NetworkInformation/IPGlobalProperties.xml index 734a58f9379..b33df8c1977 100644 --- a/xml/System.Net.NetworkInformation/IPGlobalProperties.xml +++ b/xml/System.Net.NetworkInformation/IPGlobalProperties.xml @@ -50,20 +50,19 @@ Provides information about the network connectivity of the local computer. - @@ -109,11 +108,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -168,15 +167,15 @@ Begins an asynchronous request to retrieve the stable unicast IP address table on the local computer. An that references the asynchronous request. - method allows an application to asynchronously retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. - - The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. - + method allows an application to asynchronously retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. + + The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. + ]]> This method is not implemented on the platform. This method uses the native function that is supported on Windows Vista and later. @@ -231,19 +230,18 @@ Gets the Dynamic Host Configuration Protocol (DHCP) scope name. A instance that contains the computer's DHCP scope name. - A Win32 function call failed. @@ -288,14 +286,13 @@ Gets the domain in which the local computer is registered. A instance that contains the computer's domain name. If the computer does not belong to a domain, returns . - A Win32 function call failed. @@ -342,17 +339,17 @@ Ends a pending asynchronous request to retrieve the stable unicast IP address table on the local computer. An that stores state information and any user defined data for this asynchronous operation. - method allows an application to asynchronously retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. - - The method ends a pending asynchronous request to retrieve the stable unicast IP address table. - - The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. - + method allows an application to asynchronously retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. + + The method ends a pending asynchronous request to retrieve the stable unicast IP address table. + + The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. + ]]> The call to the native function failed. @@ -409,21 +406,20 @@ Returns information about the Internet Protocol version 4 (IPv4) and IPv6 Transmission Control Protocol (TCP) connections on the local computer. A array that contains objects that describe the active TCP connections, or an empty array if no active TCP connections are detected. - state. You can check the state of a connection by calling . - - The TCP protocol is defined in IETF RFC 793. Note that the objects returned by this method reflect the connections as of the time the array is created. This information is not updated dynamically. - - - -## Examples - The following example displays endpoint information for active TCP connections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet17"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet17"::: - + state. You can check the state of a connection by calling . + + The TCP protocol is defined in IETF RFC 793. Note that the objects returned by this method reflect the connections as of the time the array is created. This information is not updated dynamically. + + + +## Examples + The following example displays endpoint information for active TCP connections. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet17"::: + ]]> The Win32 function failed. @@ -475,21 +471,20 @@ Returns endpoint information about the Internet Protocol version 4 (IPv4) and IPv6 Transmission Control Protocol (TCP) listeners on the local computer. A array that contains objects that describe the active TCP listeners, or an empty array, if no active TCP listeners are detected. - state. - - The TCP protocol is defined in IETF RFC 793. Note that the objects returned by this method reflect the connections as of the time the array is created. This information is not updated dynamically. - - - -## Examples - The following code example displays endpoint information for active TCP listeners. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet18"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet18"::: - + state. + + The TCP protocol is defined in IETF RFC 793. Note that the objects returned by this method reflect the connections as of the time the array is created. This information is not updated dynamically. + + + +## Examples + The following code example displays endpoint information for active TCP listeners. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet18"::: + ]]> The Win32 function failed. @@ -541,21 +536,20 @@ Returns information about the Internet Protocol version 4 (IPv4) and IPv6 User Datagram Protocol (UDP) listeners on the local computer. An array that contains objects that describe the UDP listeners, or an empty array if no UDP listeners are detected. - The call to the Win32 function failed. @@ -607,21 +601,20 @@ Provides Internet Control Message Protocol (ICMP) version 4 statistical data for the local computer. An object that provides ICMP version 4 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the current ICMPv4 statistics. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet6"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the current ICMPv4 statistics. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet6"::: + ]]> The Win32 function failed. @@ -673,23 +666,22 @@ Provides Internet Control Message Protocol (ICMP) version 6 statistical data for the local computer. An object that provides ICMP version 6 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the current ICMPv6 statistics. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet7"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the current ICMPv6 statistics. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet7"::: + ]]> The Win32 function failed. @@ -746,19 +738,18 @@ Gets an object that provides information about the local computer's network connectivity and traffic statistics. A object that contains information about the local computer. - class. - - - -## Examples - The following code example displays information about the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet15"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet15"::: - + class. + + + +## Examples + The following code example displays information about the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet15"::: + ]]> @@ -803,21 +794,20 @@ Provides Internet Protocol version 4 (IPv4) statistical data for the local computer. An object that provides IPv4 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following code example displays IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following code example displays IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: + ]]> The call to the Win32 function failed. @@ -881,21 +871,20 @@ Provides Internet Protocol version 6 (IPv6) statistical data for the local computer. An object that provides IPv6 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following code example displays IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following code example displays IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: + ]]> The call to the Win32 function failed. @@ -948,21 +937,20 @@ Provides Transmission Control Protocol/Internet Protocol version 4 (TCP/IPv4) statistical data for the local computer. A object that provides TCP/IPv4 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the TCP/IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the TCP/IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: + ]]> The call to the Win32 function failed. @@ -1014,21 +1002,20 @@ Provides Transmission Control Protocol/Internet Protocol version 6 (TCP/IPv6) statistical data for the local computer. A object that provides TCP/IPv6 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the TCP/IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the TCP/IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: + ]]> The call to the Win32 function failed. @@ -1081,21 +1068,20 @@ Provides User Datagram Protocol/Internet Protocol version 4 (UDP/IPv4) statistical data for the local computer. A object that provides UDP/IPv4 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the UDP/IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the UDP/IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> The call to the Win32 function GetUdpStatistics failed. @@ -1147,21 +1133,20 @@ Provides User Datagram Protocol/Internet Protocol version 6 (UDP/IPv6) statistical data for the local computer. A object that provides UDP/IPv6 traffic statistics for the local computer. - class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. - - - -## Examples - The following example displays the UDP/IP statistics for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: - + class documentation. Note that the object returned by this method reflects the statistics as of the time the object is created. This information is not updated dynamically. + + + +## Examples + The following example displays the UDP/IP statistics for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> The call to the Win32 function failed. @@ -1206,15 +1191,15 @@ Retrieves the stable unicast IP address table on the local computer. A that contains a list of stable unicast IP addresses on the local computer. - method will allow an application to retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. - - The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. - + method will allow an application to retrieve the list of stable unicast IP addresses. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. + + The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. + ]]> The call to the native function failed. @@ -1266,15 +1251,15 @@ Retrieves the stable unicast IP address table on the local computer as an asynchronous operation. The task object representing the asynchronous operation. - method will allow an application to retrieve the list of stable unicast IP addresses as asynchronous operation. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. - - The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. - + method will allow an application to retrieve the list of stable unicast IP addresses as asynchronous operation. The property can be used to determine if an IP address is an IPv6 Teredo address with the prefix of 2001::/32. + + The method also returns non-Teredo addresses and provides a more convenient way to obtain the unicast IP addresses for a system than enumerating all the objects on a local computer and querying the associated IP addresses. + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -1327,21 +1312,20 @@ Gets the host name for the local computer. A instance that contains the computer's NetBIOS name. - A Win32 function call failed. @@ -1393,19 +1377,18 @@ if the local computer is a WINS proxy; otherwise, . - A Win32 function call failed. @@ -1450,19 +1433,18 @@ Gets the Network Basic Input/Output System (NetBIOS) node type of the local computer. A value. - class overview. - - - -## Examples - The following code example displays network information for the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet15"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet15"::: - + class overview. + + + +## Examples + The following code example displays network information for the local computer. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet15"::: + ]]> A Win32 function call failed. diff --git a/xml/System.Net.NetworkInformation/IPGlobalStatistics.xml b/xml/System.Net.NetworkInformation/IPGlobalStatistics.xml index 746e8456739..57dd4a535de 100644 --- a/xml/System.Net.NetworkInformation/IPGlobalStatistics.xml +++ b/xml/System.Net.NetworkInformation/IPGlobalStatistics.xml @@ -44,23 +44,22 @@ Provides Internet Protocol (IP) statistical data. - and methods to return IP traffic information. - - The Internet protocol is used to move IP packets from a source computer to a destination computer. IP also handles dividing a packet that is too large into multiple packets that are small enough for transport, in a process known as fragmentation. - - The properties in this class correlate to the Management Information Base objects for IP defined in IETF RFC 2011. - - - -## Examples - The following code example displays IP statistics. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: - + and methods to return IP traffic information. + + The Internet protocol is used to move IP packets from a source computer to a destination computer. IP also handles dividing a packet that is too large into multiple packets that are small enough for transport, in a process known as fragmentation. + + The properties in this class correlate to the Management Information Base objects for IP defined in IETF RFC 2011. + + + +## Examples + The following code example displays IP statistics. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet1"::: + ]]> @@ -106,11 +105,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -160,20 +159,19 @@ Gets the default time-to-live (TTL) value for Internet Protocol (IP) packets. An value that specifies the TTL. - @@ -223,20 +221,19 @@ Gets a value that specifies whether Internet Protocol (IP) packet forwarding is enabled. A value that specifies whether packet forwarding is enabled. - @@ -280,13 +277,13 @@ Gets the number of network interfaces. An value containing the number of network interfaces for the address family used to obtain this instance. - @@ -330,13 +327,13 @@ Gets the number of Internet Protocol (IP) addresses assigned to the local computer. An value that indicates the number of IP addresses assigned to the address family (Internet Protocol version 4 or Internet Protocol version 6) described by this object. - , this property returns the number of IPv4 addresses assigned to the local computer. Similarly, if this instance was obtained by calling , this property returns the number of IPv6 addresses assigned to the local computer. - + , this property returns the number of IPv4 addresses assigned to the local computer. Similarly, if this instance was obtained by calling , this property returns the number of IPv6 addresses assigned to the local computer. + ]]> @@ -433,20 +430,19 @@ Gets the number of outbound Internet Protocol (IP) packets. An value that specifies the total number of outgoing packets. - @@ -496,20 +492,19 @@ Gets the number of routes that have been discarded from the routing table. An value that specifies the total number of valid routes that have been discarded. - @@ -559,20 +554,19 @@ Gets the number of transmitted Internet Protocol (IP) packets that have been discarded. An value that specifies the total number of outgoing packets that have been discarded. - @@ -622,20 +616,19 @@ Gets the number of Internet Protocol (IP) packets for which the local computer could not determine a route to the destination address. An value that specifies the number of packets that could not be sent because a route could not be found. - @@ -685,20 +678,19 @@ Gets the number of Internet Protocol (IP) packets that could not be fragmented. An value that specifies the total number of packets that required fragmentation but had the "Don't Fragment" bit set. - @@ -748,20 +740,19 @@ Gets the number of Internet Protocol (IP) packets that required reassembly. An value that specifies the total number of packet reassemblies required. - @@ -811,20 +802,19 @@ Gets the number of Internet Protocol (IP) packets that were not successfully reassembled. An value that specifies the total number of packets that could not be reassembled. - @@ -874,20 +864,19 @@ Gets the maximum amount of time within which all fragments of an Internet Protocol (IP) packet must arrive. An value that specifies the maximum number of milliseconds within which all fragments of a packet must arrive to avoid being discarded. - @@ -937,20 +926,19 @@ Gets the number of Internet Protocol (IP) packets fragmented. An value that specifies the total number of fragmented packets. - @@ -1000,20 +988,19 @@ Gets the number of Internet Protocol (IP) packets reassembled. An value that specifies the total number of fragmented packets that have been successfully reassembled. - @@ -1063,20 +1050,19 @@ Gets the number of Internet Protocol (IP) packets received. An value that specifies the total number of IP packets received. - @@ -1126,20 +1112,19 @@ Gets the number of Internet Protocol (IP) packets delivered. An value that specifies the total number of IP packets delivered. - @@ -1189,20 +1174,19 @@ Gets the number of Internet Protocol (IP) packets that have been received and discarded. An value that specifies the total number of incoming packets that have been discarded. - @@ -1252,20 +1236,19 @@ Gets the number of Internet Protocol (IP) packets forwarded. An value that specifies the total number of forwarded packets. - @@ -1315,20 +1298,19 @@ Gets the number of Internet Protocol (IP) packets with address errors that were received. An value that specifies the total number of IP packets received with errors in the address portion of the header. - @@ -1378,20 +1360,19 @@ Gets the number of Internet Protocol (IP) packets with header errors that were received. An value that specifies the total number of IP packets received and discarded due to errors in the header. - @@ -1441,20 +1422,19 @@ Gets the number of Internet Protocol (IP) packets received on the local machine with an unknown protocol in the header. An value that indicates the total number of IP packets received with an unknown protocol. - diff --git a/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml b/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml index d85efc8d377..76beac4f75e 100644 --- a/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml +++ b/xml/System.Net.NetworkInformation/IPInterfaceProperties.xml @@ -50,21 +50,20 @@ Provides information about network interfaces that support Internet Protocol version 4 (IPv4) or Internet Protocol version 6 (IPv6). - method. - - To access IPv4-specific properties, use the object returned by the method. To access IPv6-specific properties, use the object returned by the method. - - - -## Examples - The following code example displays address information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet8"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet8"::: + method. + + To access IPv4-specific properties, use the object returned by the method. To access IPv6-specific properties, use the object returned by the method. + + + +## Examples + The following code example displays address information. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet8"::: + ]]> @@ -110,11 +109,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -164,20 +163,19 @@ Gets the anycast IP addresses assigned to this interface. An that contains the anycast addresses for this interface. - @@ -243,20 +241,19 @@ Gets the addresses of Dynamic Host Configuration Protocol (DHCP) servers for this interface. An that contains the address information for DHCP servers, or an empty array if no servers are found. - @@ -306,20 +303,19 @@ Gets the addresses of Domain Name System (DNS) servers for this interface. A that contains the DNS server addresses. - @@ -369,20 +365,19 @@ Gets the Domain Name System (DNS) suffix associated with this interface. A that contains the DNS suffix for this interface, or if there is no DNS suffix for the interface. - , and must resolve the unqualified host name "www", the FQDN to query is "www.contoso.com". - - - -## Examples - The following code example displays the DNS suffix. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet41"::: + , and must resolve the unqualified host name "www", the FQDN to query is "www.contoso.com". + + + +## Examples + The following code example displays the DNS suffix. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet41"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet41"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet41"::: + ]]> @@ -432,20 +427,19 @@ Gets the IPv4 network gateway addresses for this interface. An that contains the address information for network gateways, or an empty array if no gateways are found. - @@ -490,10 +484,10 @@ Provides Internet Protocol version 4 (IPv4) configuration data for this network interface. An object that contains IPv4 configuration data. - class documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. + class documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. A is thrown if the interface does not support the IPv4 protocol, therefore it's recommended to check IPv4 support calling on the originating instance before querying the IPv4 properties. ]]> @@ -541,12 +535,12 @@ Provides Internet Protocol version 6 (IPv6) configuration data for this network interface. An object that contains IPv6 configuration data. - documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. + documentation. Note that the object returned by the method reflects the configuration as of the time the object is created. This information is not updated dynamically. A is thrown if the interface does not support the IPv6 protocol, therefore it's recommended to check IPv6 support calling on the originating instance before querying the IPv6 properties. - + ]]> The interface does not support the IPv6 protocol. @@ -614,20 +608,19 @@ if NetBt is configured to use DNS name resolution on this interface; otherwise, . - @@ -678,20 +671,19 @@ if this interface is configured to automatically register a mapping between its dynamic IP address and static domain names; otherwise, . - @@ -735,20 +727,19 @@ Gets the multicast addresses assigned to this interface. An that contains the multicast addresses for this interface. - @@ -792,20 +783,19 @@ Gets the unicast addresses assigned to this interface. An that contains the unicast addresses for this interface. - @@ -871,11 +861,11 @@ Gets the addresses of Windows Internet Name Service (WINS) servers. An that contains the address information for WINS servers, or an empty array if no servers are found. - diff --git a/xml/System.Net.NetworkInformation/IPStatus.xml b/xml/System.Net.NetworkInformation/IPStatus.xml index 45ca0e8b967..564e5fb03a5 100644 --- a/xml/System.Net.NetworkInformation/IPStatus.xml +++ b/xml/System.Net.NetworkInformation/IPStatus.xml @@ -43,23 +43,22 @@ Reports the status of sending an Internet Control Message Protocol (ICMP) echo message to a computer. - class uses the values in this enumeration to set the property. The class returns objects when you call the or methods to check whether you can reach a computer across the network. - + class uses the values in this enumeration to set the property. The class returns objects when you call the or methods to check whether you can reach a computer across the network. + > [!WARNING] -> The DestinationProhibited and DestinationProtocolUnreachable enumeration values have the same numeric value. This is possible because DestinationProhibited applies only to IPv6 and DestinationProtocolUnreachable applies only to IPv4. - - - -## Examples - The following code example sends an ICMP echo message and checks the status. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: - :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: +> The DestinationProhibited and DestinationProtocolUnreachable enumeration values have the same numeric value. This is possible because DestinationProhibited applies only to IPv6 and DestinationProtocolUnreachable applies only to IPv4. + + + +## Examples + The following code example sends an ICMP echo message and checks the status. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/IPv4InterfaceProperties.xml b/xml/System.Net.NetworkInformation/IPv4InterfaceProperties.xml index 328c80eb628..54dd3029ea4 100644 --- a/xml/System.Net.NetworkInformation/IPv4InterfaceProperties.xml +++ b/xml/System.Net.NetworkInformation/IPv4InterfaceProperties.xml @@ -44,22 +44,21 @@ Provides information about network interfaces that support Internet Protocol version 4 (IPv4). - method. + + For IPV6 properties, see . + + + +## Examples + The following code example gets an object and displays its data. -## Remarks - This class provides access to configuration and address information for network interfaces that support IPv4. You do not create instances of this class; they are returned by the method. - - For IPV6 properties, see . - - - -## Examples - The following code example gets an object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -105,11 +104,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -153,20 +152,19 @@ Gets the index of the network interface associated with the Internet Protocol version 4 (IPv4) address. An that contains the index of the IPv4 interface. - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -217,20 +215,19 @@ if the interface uses an APIPA address; otherwise, . - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -281,20 +278,19 @@ if the interface uses APIPA; otherwise, . - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -345,20 +341,19 @@ if the interface is configured to obtain an IP address from a DHCP server; otherwise, . - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -413,20 +408,19 @@ if this interface routes packets; otherwise . - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -470,20 +464,19 @@ Gets the maximum transmission unit (MTU) for this network interface. An value that specifies the MTU. - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> @@ -538,20 +531,19 @@ if the interface uses WINS; otherwise, . - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/IPv6InterfaceProperties.xml b/xml/System.Net.NetworkInformation/IPv6InterfaceProperties.xml index 6d3cb7bec78..74d16e7de5c 100644 --- a/xml/System.Net.NetworkInformation/IPv6InterfaceProperties.xml +++ b/xml/System.Net.NetworkInformation/IPv6InterfaceProperties.xml @@ -44,22 +44,21 @@ Provides information about network interfaces that support Internet Protocol version 6 (IPv6). - method. - - For IPV4 properties, see . - - - -## Examples - The following code example gets an object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet49"::: + method. + + For IPV4 properties, see . + + + +## Examples + The following code example gets an object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet49"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: + ]]> @@ -105,11 +104,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -215,20 +214,19 @@ Gets the index of the network interface associated with an Internet Protocol version 6 (IPv6) address. An value that contains the index of the network interface for IPv6 address. - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet49"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet49"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: + ]]> @@ -272,20 +270,19 @@ Gets the maximum transmission unit (MTU) for this network interface. An value that specifies the MTU. - object and displays its data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet49"::: + object and displays its data. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet49"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet49"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/IcmpV4Statistics.xml b/xml/System.Net.NetworkInformation/IcmpV4Statistics.xml index 4b4dfd5e5e7..4a4358c1d81 100644 --- a/xml/System.Net.NetworkInformation/IcmpV4Statistics.xml +++ b/xml/System.Net.NetworkInformation/IcmpV4Statistics.xml @@ -44,21 +44,20 @@ Provides Internet Control Message Protocol for IPv4 (ICMPv4) statistical data for the local computer. - method to return ICMPv4 traffic information. - - - -## Examples - The following example displays the current ICMPv4 statistics. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet6"::: - + method to return ICMPv4 traffic information. + + + +## Examples + The following example displays the current ICMPv4 statistics. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet6"::: + ]]> @@ -104,11 +103,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -152,20 +151,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Address Mask Reply messages that were received. An value that specifies the total number of Address Mask Reply messages that were received. - @@ -209,20 +207,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Address Mask Reply messages that were sent. An value that specifies the total number of Address Mask Reply messages that were sent. - @@ -266,20 +263,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Address Mask Request messages that were received. An value that specifies the total number of Address Mask Request messages that were received. - @@ -323,20 +319,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Address Mask Request messages that were sent. An value that specifies the total number of Address Mask Request messages that were sent. - @@ -380,28 +375,27 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) messages that were received because of a packet having an unreachable address in its destination. An value that specifies the total number of Destination Unreachable messages that were received. - @@ -445,26 +439,25 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) messages that were sent because of a packet having an unreachable address in its destination. An value that specifies the total number of Destination Unreachable messages sent. - @@ -508,20 +501,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Echo Reply messages that were received. An value that specifies the total number of number of ICMP Echo Reply messages that were received. - @@ -565,20 +557,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Echo Reply messages that were sent. An value that specifies the total number of number of ICMP Echo Reply messages that were sent. - @@ -622,20 +613,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Echo Request messages that were received. An value that specifies the total number of number of ICMP Echo Request messages that were received. - @@ -679,20 +669,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Echo Request messages that were sent. An value that specifies the total number of number of ICMP Echo Request messages that were sent. - @@ -754,15 +743,14 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) error messages that were received. An value that specifies the total number of ICMP error messages that were received. - @@ -824,15 +812,14 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) error messages that were sent. An value that specifies the total number of number of ICMP error messages that were sent. - @@ -894,20 +881,19 @@ Gets the number of Internet Control Message Protocol messages that were received. An value that specifies the total number of ICMPv4 messages that were received. - @@ -969,20 +955,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) messages that were sent. An value that specifies the total number of ICMPv4 messages that were sent. - @@ -1026,20 +1011,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Parameter Problem messages that were received. An value that specifies the total number of ICMP Parameter Problem messages that were received. - @@ -1083,20 +1067,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Parameter Problem messages that were sent. An value that specifies the total number of ICMP Parameter Problem messages that were sent. - @@ -1140,20 +1123,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Redirect messages that were received. An value that specifies the total number of ICMP Redirect messages that were received. - @@ -1197,20 +1179,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Redirect messages that were sent. An value that specifies the total number of ICMP Redirect messages that were sent. - @@ -1254,20 +1235,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Source Quench messages that were received. An value that specifies the total number of Source Quench messages that were received. - @@ -1311,20 +1291,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Source Quench messages that were sent. An value that specifies the total number of Source Quench messages that were sent. - @@ -1368,20 +1347,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Time Exceeded messages that were received. An value that specifies the total number of ICMP Time Exceeded messages that were received. - @@ -1425,20 +1403,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Time Exceeded messages that were sent. An value that specifies the total number of ICMP Time Exceeded messages that were sent. - @@ -1482,20 +1459,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Timestamp Reply messages that were received. An value that specifies the total number of Timestamp Reply messages that were received. - @@ -1539,20 +1515,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Timestamp Reply messages that were sent. An value that specifies the total number of Timestamp Reply messages that were sent. - @@ -1596,20 +1571,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Timestamp Request messages that were received. An value that specifies the total number of Timestamp Request messages that were received. - @@ -1653,20 +1627,19 @@ Gets the number of Internet Control Message Protocol version 4 (ICMPv4) Timestamp Request messages that were sent. An value that specifies the total number of Timestamp Request messages that were sent. - diff --git a/xml/System.Net.NetworkInformation/IcmpV6Statistics.xml b/xml/System.Net.NetworkInformation/IcmpV6Statistics.xml index 08c6ec3d62d..bb8634a70c6 100644 --- a/xml/System.Net.NetworkInformation/IcmpV6Statistics.xml +++ b/xml/System.Net.NetworkInformation/IcmpV6Statistics.xml @@ -44,21 +44,20 @@ Provides Internet Control Message Protocol for Internet Protocol version 6 (ICMPv6) statistical data for the local computer. - method to return ICMPV6 traffic information. - - The properties in this class correlate to the Management Information Base objects for ICMPv6 defined in IETF RFC 2466. ICMPv6 is defined in RFC 2463. - - - -## Examples - The following example displays the current ICMPv6 statistics. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet7"::: - + method to return ICMPV6 traffic information. + + The properties in this class correlate to the Management Information Base objects for ICMPv6 defined in IETF RFC 2466. ICMPv6 is defined in RFC 2463. + + + +## Examples + The following example displays the current ICMPv6 statistics. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet7"::: + ]]> @@ -104,11 +103,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -152,28 +151,27 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) messages received because of a packet having an unreachable address in its destination. An value that specifies the total number of Destination Unreachable messages received. - @@ -217,28 +215,27 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) messages sent because of a packet having an unreachable address in its destination. An value that specifies the total number of Destination Unreachable messages sent. - @@ -282,20 +279,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Echo Reply messages received. An value that specifies the total number of number of ICMP Echo Reply messages received. - @@ -339,20 +335,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Echo Reply messages sent. An value that specifies the total number of number of ICMP Echo Reply messages sent. - @@ -396,20 +391,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Echo Request messages received. An value that specifies the total number of number of ICMP Echo Request messages received. - @@ -453,20 +447,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Echo Request messages sent. An value that specifies the total number of number of ICMP Echo Request messages sent. - @@ -528,15 +521,14 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) error messages received. An value that specifies the total number of ICMP error messages received. - @@ -598,15 +590,14 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) error messages sent. An value that specifies the total number of ICMP error messages sent. - @@ -650,20 +641,19 @@ Gets the number of Internet Group management Protocol (IGMP) Group Membership Query messages received. An value that specifies the total number of Group Membership Query messages received. - @@ -707,20 +697,19 @@ Gets the number of Internet Group management Protocol (IGMP) Group Membership Query messages sent. An value that specifies the total number of Group Membership Query messages sent. - @@ -764,20 +753,19 @@ Gets the number of Internet Group Management Protocol (IGMP) Group Membership Reduction messages received. An value that specifies the total number of Group Membership Reduction messages received. - @@ -821,20 +809,19 @@ Gets the number of Internet Group Management Protocol (IGMP) Group Membership Reduction messages sent. An value that specifies the total number of Group Membership Reduction messages sent. - @@ -878,20 +865,19 @@ Gets the number of Internet Group Management Protocol (IGMP) Group Membership Report messages received. An value that specifies the total number of Group Membership Report messages received. - @@ -935,20 +921,19 @@ Gets the number of Internet Group Management Protocol (IGMP) Group Membership Report messages sent. An value that specifies the total number of Group Membership Report messages sent. - @@ -1010,20 +995,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) messages received. An value that specifies the total number of ICMPv6 messages received. - @@ -1085,20 +1069,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) messages sent. An value that specifies the total number of ICMPv6 messages sent. - @@ -1142,20 +1125,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Neighbor Advertisement messages received. An value that specifies the total number of ICMP Neighbor Advertisement messages received. - @@ -1199,20 +1181,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Neighbor Advertisement messages sent. An value that specifies the total number of Neighbor Advertisement messages sent. - @@ -1256,20 +1237,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Neighbor Solicitation messages received. An value that specifies the total number of Neighbor Solicitation messages received. - @@ -1313,20 +1293,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Neighbor Solicitation messages sent. An value that specifies the total number of Neighbor Solicitation messages sent. - @@ -1370,20 +1349,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Packet Too Big messages received. An value that specifies the total number of ICMP Packet Too Big messages received. - @@ -1427,20 +1405,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Packet Too Big messages sent. An value that specifies the total number of ICMP Packet Too Big messages sent. - @@ -1484,20 +1461,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Parameter Problem messages received. An value that specifies the total number of ICMP Parameter Problem messages received. - @@ -1541,20 +1517,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Parameter Problem messages sent. An value that specifies the total number of ICMP Parameter Problem messages sent. - @@ -1598,20 +1573,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Redirect messages received. An value that specifies the total number of ICMP Redirect messages received. - @@ -1655,20 +1629,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Redirect messages sent. An value that specifies the total number of ICMP Redirect messages sent. - @@ -1712,20 +1685,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Router Advertisement messages received. An value that specifies the total number of Router Advertisement messages received. - @@ -1769,20 +1741,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Router Advertisement messages sent. An value that specifies the total number of Router Advertisement messages sent. - @@ -1826,20 +1797,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Router Solicitation messages received. An value that specifies the total number of Router Solicitation messages received. - @@ -1883,20 +1853,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Router Solicitation messages sent. An value that specifies the total number of Router Solicitation messages sent. - @@ -1940,20 +1909,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Time Exceeded messages received. An value that specifies the total number of ICMP Time Exceeded messages received. - @@ -1997,20 +1965,19 @@ Gets the number of Internet Control Message Protocol version 6 (ICMPv6) Time Exceeded messages sent. An value that specifies the total number of ICMP Time Exceeded messages sent. - diff --git a/xml/System.Net.NetworkInformation/NetworkChange.xml b/xml/System.Net.NetworkInformation/NetworkChange.xml index d6767ccbaff..644b5592ef3 100644 --- a/xml/System.Net.NetworkInformation/NetworkChange.xml +++ b/xml/System.Net.NetworkInformation/NetworkChange.xml @@ -64,22 +64,21 @@ Allows applications to receive notification when the Internet Protocol (IP) address of a network interface, also called a network card or adapter, changes. - class provides address change notification by raising events. An interface address can change for many reasons, such as a disconnected network cable, moving out of range of a wireless Local Area Network, or hardware failure. + + To receive notification, you must identify your application's event handlers, which are one or more methods that perform your application-specific tasks each time the event is raised. To have a object call your event-handling methods when a event occurs, you must associate the methods with a delegate, and add this delegate to the event. + + + +## Examples + The following code example listens for address changes and displays the status of network interfaces when a event occurs. -## Remarks - The class provides address change notification by raising events. An interface address can change for many reasons, such as a disconnected network cable, moving out of range of a wireless Local Area Network, or hardware failure. - - To receive notification, you must identify your application's event handlers, which are one or more methods that perform your application-specific tasks each time the event is raised. To have a object call your event-handling methods when a event occurs, you must associate the methods with a delegate, and add this delegate to the event. - - - -## Examples - The following code example listens for address changes and displays the status of network interfaces when a event occurs. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkChange/Overview/changed.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetAddressChanged1/VB/changed.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetAddressChanged1/VB/changed.vb" id="Snippet1"::: + ]]> @@ -183,20 +182,19 @@ Occurs when the IP address of a network interface changes. - class raises events when the address of a network interface, also called a network card or adapter, changes. - - To have a object call an event-handling method when a event occurs, you must associate the method with a delegate, and add this delegate to this event. - -## Examples - The following code example listens for address changes and displays the status of network interfaces when a event occurs. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetAddressChanged1/CPP/changed.cpp" id="Snippet1"::: + class raises events when the address of a network interface, also called a network card or adapter, changes. + + To have a object call an event-handling method when a event occurs, you must associate the method with a delegate, and add this delegate to this event. + +## Examples + The following code example listens for address changes and displays the status of network interfaces when a event occurs. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkChange/Overview/changed.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetAddressChanged1/VB/changed.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetAddressChanged1/VB/changed.vb" id="Snippet1"::: + ]]> @@ -252,13 +250,13 @@ Occurs when the availability of the network changes. - class raises events when the availability of the network changes. The network is available when at least one network interface is marked "up" and is not a tunnel or loopback interface. - - To have a object call an event-handling method when a event occurs, you must associate the method with a delegate, and add this delegate to this event. - + class raises events when the availability of the network changes. The network is available when at least one network interface is marked "up" and is not a tunnel or loopback interface. + + To have a object call an event-handling method when a event occurs, you must associate the method with a delegate, and add this delegate to this event. + ]]> diff --git a/xml/System.Net.NetworkInformation/NetworkInformationAccess.xml b/xml/System.Net.NetworkInformation/NetworkInformationAccess.xml index 525cd613424..9ed99aff52d 100644 --- a/xml/System.Net.NetworkInformation/NetworkInformationAccess.xml +++ b/xml/System.Net.NetworkInformation/NetworkInformationAccess.xml @@ -38,20 +38,19 @@ Specifies permission to access information about network interfaces and traffic statistics. - class to specify the level of access to information that the permission object controls. + + + +## Examples + The following code example creates a permission that controls Read access to network information. -## Remarks - This enumeration is used with the class to specify the level of access to information that the permission object controls. - - - -## Examples - The following code example creates a permission that controls Read access to network information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclNetworkInfoPerms/CPP/NclNetworkInfoPerms.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/NetworkInformationAccess/Overview/permissionexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclNetworkInfoPerms/VB/permissionexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/NetworkInterface.xml b/xml/System.Net.NetworkInformation/NetworkInterface.xml index a129824fea6..bffc6dfc1fd 100644 --- a/xml/System.Net.NetworkInformation/NetworkInterface.xml +++ b/xml/System.Net.NetworkInformation/NetworkInterface.xml @@ -71,7 +71,6 @@ ## Examples The following code example displays information about interfaces. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet12"::: ]]> @@ -186,7 +185,6 @@ ## Examples The following code example displays a summary for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet16"::: ]]> @@ -256,7 +254,6 @@ ## Examples The following code example displays Domain Name Service (DNS) configuration information for the local computer's network adapters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet41"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet41"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet41"::: @@ -322,7 +319,6 @@ ## Examples The following code example displays information for the local computer's network adapters that support IPv4. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: @@ -555,7 +551,6 @@ ## Examples The following code example displays the physical addresses of all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet51"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet51"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet51"::: @@ -722,7 +717,6 @@ ## Examples The following code example displays a summary for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet51"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet51"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet51"::: @@ -846,7 +840,6 @@ ## Examples The following code example displays a summary for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet16"::: ]]> @@ -912,7 +905,6 @@ ## Examples The following example displays type information for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet51"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet51"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet51"::: @@ -975,7 +967,6 @@ ## Examples The following code example displays a summary for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet16"::: ]]> @@ -1037,7 +1028,6 @@ ## Examples The following code example demonstrates displaying the speed of interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet13"::: @@ -1101,7 +1091,6 @@ ## Examples The following code example displays statistics for IPV4 interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: @@ -1165,7 +1154,6 @@ ## Examples The following code example displays a summary for all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet51"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet51"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet51"::: diff --git a/xml/System.Net.NetworkInformation/NetworkInterfaceComponent.xml b/xml/System.Net.NetworkInformation/NetworkInterfaceComponent.xml index 1eb0c008bc4..874cb069e08 100644 --- a/xml/System.Net.NetworkInformation/NetworkInterfaceComponent.xml +++ b/xml/System.Net.NetworkInformation/NetworkInterfaceComponent.xml @@ -43,20 +43,19 @@ Specifies the Internet Protocol versions that are supported by a network interface. - method to specify the Internet Protocol version supported by a network interface. + + + +## Examples + The following code example checks whether a network interface supports IPv4. -## Remarks - The values in this enumeration are used by the method to specify the Internet Protocol version supported by a network interface. - - - -## Examples - The following code example checks whether a network interface supports IPv4. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet48"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet48"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/OperationalStatus.xml b/xml/System.Net.NetworkInformation/OperationalStatus.xml index 53e0cd95945..f084598bffe 100644 --- a/xml/System.Net.NetworkInformation/OperationalStatus.xml +++ b/xml/System.Net.NetworkInformation/OperationalStatus.xml @@ -43,19 +43,18 @@ Specifies the operational state of a network interface. - property. - - - -## Examples - The following code example displays a summary for all interfaces on the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet16"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet16"::: + property. + + + +## Examples + The following code example displays a summary for all interfaces on the local computer. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet16"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/PhysicalAddress.xml b/xml/System.Net.NetworkInformation/PhysicalAddress.xml index 9ece14df547..8348e2499c0 100644 --- a/xml/System.Net.NetworkInformation/PhysicalAddress.xml +++ b/xml/System.Net.NetworkInformation/PhysicalAddress.xml @@ -62,7 +62,6 @@ ## Examples The following code example displays the physical addresses of all interfaces on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet2"::: ]]> @@ -120,7 +119,6 @@ ## Examples The following code example creates a new object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet4"::: ]]> @@ -184,7 +182,6 @@ ## Examples The following code example compares two instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet3"::: ]]> @@ -236,7 +233,6 @@ ## Examples The following code example calls this method to retrieve the address of a and formats the address for display. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet2"::: ]]> @@ -333,7 +329,6 @@ ## Examples The following code example demonstrates using this field to test the result of parsing an address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet5"::: ]]> @@ -487,7 +482,6 @@ In .NET Framework and .NET Core 3.1 and earlier, an address that contains `f0-e1 ## Examples The following code example creates a instance by calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet5"::: ]]> @@ -541,7 +535,6 @@ In .NET Framework and .NET Core 3.1 and earlier, an address that contains `f0-e1 ## Examples The following code example demonstrates displaying the address in a instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPhysicalAddress/CPP/NCLPhysicalAddress.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/PhysicalAddress/Overview/physaddresstester.cs" id="Snippet3"::: ]]> diff --git a/xml/System.Net.NetworkInformation/Ping.xml b/xml/System.Net.NetworkInformation/Ping.xml index 0193f17021a..9f403805f34 100644 --- a/xml/System.Net.NetworkInformation/Ping.xml +++ b/xml/System.Net.NetworkInformation/Ping.xml @@ -108,13 +108,11 @@ ## Examples The following code example demonstrates using the class synchronously. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: The following code example demonstrates using the class asynchronously. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: ]]> @@ -165,7 +163,6 @@ ## Examples The following code example demonstrates creating a instance. The complete example is available in the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet2"::: ]]> @@ -371,7 +368,6 @@ ## Examples The following code example demonstrates specifying a callback method for the event. The complete example is available in the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet2"::: ]]> @@ -450,7 +446,6 @@ ## Examples The following code example demonstrates calling this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet3"::: ]]> @@ -516,7 +511,6 @@ ## Examples The following code example demonstrates calling this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet2"::: ]]> @@ -739,7 +733,6 @@ ## Examples The following code example demonstrates how to call this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet6"::: ]]> @@ -914,7 +907,6 @@ ## Examples The following code example demonstrates how to call this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet5"::: ]]> @@ -1063,7 +1055,6 @@ ## Examples The following code example demonstrates how to call this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet4"::: ]]> @@ -1779,12 +1770,10 @@ The following code example requires the following namespaces: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet0"::: The following code example sends an ICMP echo message asynchronously. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet7"::: ]]> @@ -1887,7 +1876,6 @@ ## Examples The following code example demonstrates how to call this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: ]]> diff --git a/xml/System.Net.NetworkInformation/PingCompletedEventArgs.xml b/xml/System.Net.NetworkInformation/PingCompletedEventArgs.xml index 8e16baff8b3..62b4785447d 100644 --- a/xml/System.Net.NetworkInformation/PingCompletedEventArgs.xml +++ b/xml/System.Net.NetworkInformation/PingCompletedEventArgs.xml @@ -49,19 +49,18 @@ Provides data for the event. - method that is called when a call completes. The methods send an Internet Control Message Protocol (ICMP) echo request asynchronously and wait for a corresponding ICMP echo reply message. The property contains the results of the ICMP echo request. - - - -## Examples - The following code example demonstrates sending an ICMP echo request asynchronously. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: + method that is called when a call completes. The methods send an Internet Control Message Protocol (ICMP) echo request asynchronously and wait for a corresponding ICMP echo reply message. The property contains the results of the ICMP echo request. + + + +## Examples + The following code example demonstrates sending an ICMP echo request asynchronously. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: + ]]> @@ -111,19 +110,18 @@ Gets an object that contains data that describes an attempt to send an Internet Control Message Protocol (ICMP) echo request message and receive a corresponding ICMP echo reply message. A object that describes the results of the ICMP echo request. - is not , you should not use the values that are returned by the , , and properties. The and properties will return zero, and the property will return `null`. - - - -## Examples - The following code example implements a method that is used to respond to a event. For the complete example, see the class overview. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet4"::: - + is not , you should not use the values that are returned by the , , and properties. The and properties will return zero, and the property will return `null`. + + + +## Examples + The following code example implements a method that is used to respond to a event. For the complete example, see the class overview. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet4"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/PingCompletedEventHandler.xml b/xml/System.Net.NetworkInformation/PingCompletedEventHandler.xml index 312088a3583..ca6dbed4f61 100644 --- a/xml/System.Net.NetworkInformation/PingCompletedEventHandler.xml +++ b/xml/System.Net.NetworkInformation/PingCompletedEventHandler.xml @@ -51,19 +51,18 @@ A object that contains the event data. Represents the method that will handle the event of a object. - call is available to the method invoked by this delegate in the property. - - - -## Examples - The following code example demonstrates specifying a to respond to a event. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: + call is available to the method invoked by this delegate in the property. + + + +## Examples + The following code example demonstrates specifying a to respond to a event. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/PingOptions.xml b/xml/System.Net.NetworkInformation/PingOptions.xml index c080292c1ae..b9d24f7b5c4 100644 --- a/xml/System.Net.NetworkInformation/PingOptions.xml +++ b/xml/System.Net.NetworkInformation/PingOptions.xml @@ -44,28 +44,27 @@ Used to control how data packets are transmitted. - class provides the and properties to control how Internet Control Message Protocol (ICMP) echo request packets are transmitted. - - The property specifies the Time to Live for packets sent by the class. This value indicates the number of routing nodes that can forward a packet before it is discarded. Setting this option is useful if you want to test the number of forwards, also known as hops, are required to send a packet from a source computer to a destination computer. - - The property controls whether data sent to a remote host can be divided into multiple packets. This option is useful if you want to test the maximum transmission unit (MTU) of the routers and gateways used to transmit the packet. - - Instances of the class are passed to the and methods, and the class returns instances of via the property. - - For a list of initial property values for an instance of , see the constructor. - - - -## Examples - The following code example uses the , and classes to send an ICMP echo request to the host specified on the command line. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: - :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: + class provides the and properties to control how Internet Control Message Protocol (ICMP) echo request packets are transmitted. + + The property specifies the Time to Live for packets sent by the class. This value indicates the number of routing nodes that can forward a packet before it is discarded. Setting this option is useful if you want to test the number of forwards, also known as hops, are required to send a packet from a source computer to a destination computer. + + The property controls whether data sent to a remote host can be divided into multiple packets. This option is useful if you want to test the maximum transmission unit (MTU) of the routers and gateways used to transmit the packet. + + Instances of the class are passed to the and methods, and the class returns instances of via the property. + + For a list of initial property values for an instance of , see the constructor. + + + +## Examples + The following code example uses the , and classes to send an ICMP echo request to the host specified on the command line. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: + ]]> @@ -115,27 +114,26 @@ Initializes a new instance of the class. - . - -|Property|Initial Value| -|--------------|-------------------| -||128| -||`false`| - - You can set the properties to new values before calling or . - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet2"::: - :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet2"::: - + . + +|Property|Initial Value| +|--------------|-------------------| +||128| +||`false`| + + You can set the properties to new values before calling or . + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet2"::: + ]]> @@ -182,19 +180,18 @@ to prevent data sent to the remote host from being fragmented; otherwise, . Initializes a new instance of the class and sets the Time to Live and fragmentation values. - @@ -251,19 +248,18 @@ if the data cannot be sent in multiple packets; otherwise . The default is . - class can be divided into multiple packets. This option is useful if you want to test the maximum transmission unit (MTU) of the routers and gateways used to transmit the packet. If this property is `true` and the data sent to the remote host is larger then the MTU of a gateway or router between the sender and the remote host, the ping operation fails with status . - - - -## Examples - The following code example demonstrates setting the value of this property using a constructor, and then displaying the value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet3"::: - + class can be divided into multiple packets. This option is useful if you want to test the maximum transmission unit (MTU) of the routers and gateways used to transmit the packet. If this property is `true` and the data sent to the remote host is larger then the MTU of a gateway or router between the sender and the remote host, the ping operation fails with status . + + + +## Examples + The following code example demonstrates setting the value of this property using a constructor, and then displaying the value. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet3"::: + ]]> @@ -313,19 +309,18 @@ Gets or sets the number of routing nodes that can forward the data before it is discarded. An value that specifies the number of times the data packets can be forwarded. The default is 128. - constructor, and then displaying the value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingAsync/CPP/asyncping.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet3"::: - + constructor, and then displaying the value. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Overview/asyncping.cs" id="Snippet3"::: + ]]> The value specified for a set operation is less than or equal to zero. diff --git a/xml/System.Net.NetworkInformation/PingReply.xml b/xml/System.Net.NetworkInformation/PingReply.xml index 2b1cec646a7..4601e5052f6 100644 --- a/xml/System.Net.NetworkInformation/PingReply.xml +++ b/xml/System.Net.NetworkInformation/PingReply.xml @@ -50,24 +50,23 @@ Provides information about the status and data resulting from a or operation. - class attempts to send an Internet Control Message Protocol (ICMP) echo request to a remote computer and receive information back from the computer via an ICMP echo reply message. The class uses instances of the class to return information about the operation, such as its status and the time taken to send the request and receive the reply. - - The methods return instances of the class directly. The methods return a in the method's parameter. The is accessed through the property. - - If the value of is not , you should not use the values returned by the , or properties. The property will return zero, the property will return an empty array, and the property will return `null`. - - - -## Examples - The following code example demonstrates using class to send an ICMP echo request synchronously and display the response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: - :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: - + class attempts to send an Internet Control Message Protocol (ICMP) echo request to a remote computer and receive information back from the computer via an ICMP echo reply message. The class uses instances of the class to return information about the operation, such as its status and the time taken to send the request and receive the reply. + + The methods return instances of the class directly. The methods return a in the method's parameter. The is accessed through the property. + + If the value of is not , you should not use the values returned by the , or properties. The property will return zero, the property will return an empty array, and the property will return `null`. + + + +## Examples + The following code example demonstrates using class to send an ICMP echo request synchronously and display the response. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: + ]]> @@ -117,19 +116,18 @@ Gets the address of the host that sends the Internet Control Message Protocol (ICMP) echo reply. An containing the destination for the ICMP echo message. - returned by any of the overloads can originate from a malicious remote computer. Do not connect to the remote computer using this address. Use DNS to determine the IP address of the machine to which you want to connect. - - - -## Examples - The following code example sends an ICMP echo request synchronously and displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet2"::: - + returned by any of the overloads can originate from a malicious remote computer. Do not connect to the remote computer using this address. Use DNS to determine the IP address of the machine to which you want to connect. + + + +## Examples + The following code example sends an ICMP echo request synchronously and displays the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet2"::: + ]]> @@ -179,21 +177,20 @@ Gets the buffer of data received in an Internet Control Message Protocol (ICMP) echo reply message. A array containing the data received in an ICMP echo reply message, or an empty array, if no reply was received. - option, can be used to discover the maximum transmission unit for the network path between the source and destination computers. For additional information, see "Traceroute" in RFC 1574, Section 3.2, available at [https://www.ietf.org](https://www.ietf.org). - - The default buffer used with and contains 32 bytes of data. - - - -## Examples - The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet4"::: - + option, can be used to discover the maximum transmission unit for the network path between the source and destination computers. For additional information, see "Traceroute" in RFC 1574, Section 3.2, available at [https://www.ietf.org](https://www.ietf.org). + + The default buffer used with and contains 32 bytes of data. + + + +## Examples + The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet4"::: + ]]> @@ -244,21 +241,20 @@ Gets the options used to transmit the reply to an Internet Control Message Protocol (ICMP) echo request. A object that contains the Time to Live (TTL) and the fragmentation directive used for transmitting the reply if is ; otherwise, . - value specified in the ICMP echo request controls packet fragmentation. If is `true` and the packet size exceeds the maximum transmission unit of the network path taken by the packet, the packet is discarded and the error is returned. - - - -## Examples - The following code example sends an ICMP echo request synchronously and displays the values stored in the object returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet3"::: - + value specified in the ICMP echo request controls packet fragmentation. If is `true` and the packet size exceeds the maximum transmission unit of the network path taken by the packet, the packet is discarded and the error is returned. + + + +## Examples + The following code example sends an ICMP echo request synchronously and displays the values stored in the object returned by this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet3"::: + ]]> @@ -308,19 +304,18 @@ Gets the number of milliseconds taken to send an Internet Control Message Protocol (ICMP) echo request and receive the corresponding ICMP echo reply message. An that specifies the round trip time, in milliseconds. - time is reported as 0, which is also a valid value when the request succeeds. You must check the to determine whether the value returned by this property should be ignored. - - - -## Examples - The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLPingSampler/CPP/pingtest.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet4"::: - + time is reported as 0, which is also a valid value when the request succeeds. You must check the to determine whether the value returned by this property should be ignored. + + + +## Examples + The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/Ping/Send/pingtest.cs" id="Snippet4"::: + ]]> @@ -370,20 +365,19 @@ Gets the status of an attempt to send an Internet Control Message Protocol (ICMP) echo request and receive the corresponding ICMP echo reply message. An value indicating the result of the request. - is not , you should not use the values returned by the , or properties. The and properties will return zero, and the property will return `null`. - - - -## Examples - The following code example demonstrates using class to send an ICMP echo request synchronously and display the response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclPingSync/CPP/syncping.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: - :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: - + is not , you should not use the values returned by the , or properties. The and properties will return zero, and the property will return `null`. + + + +## Examples + The following code example demonstrates using class to send an ICMP echo request synchronously and display the response. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.Net.NetworkInformation/IPStatus/Overview/syncping.fs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/PrefixOrigin.xml b/xml/System.Net.NetworkInformation/PrefixOrigin.xml index 0d21b77166b..bcba9bb5455 100644 --- a/xml/System.Net.NetworkInformation/PrefixOrigin.xml +++ b/xml/System.Net.NetworkInformation/PrefixOrigin.xml @@ -43,22 +43,21 @@ Specifies how an IP address network prefix was located. - and classes. Instances of this class are returned when you retrieve the address information for a object. + + + +## Examples + The following code example displays prefix and suffix information for unicast addresses. -## Remarks - IP addresses are divided into two parts: the prefix and the suffix. The address prefix identifies the network portion of an IP address, and the address suffix identifies the host portion. Prefixes are assigned by global authorities, and suffixes are assigned by local system administrators. - - This enumeration is used by the and classes. Instances of this class are returned when you retrieve the address information for a object. - - - -## Examples - The following code example displays prefix and suffix information for unicast addresses. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet45"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet45"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/SuffixOrigin.xml b/xml/System.Net.NetworkInformation/SuffixOrigin.xml index bffe64a9cb8..029adada13a 100644 --- a/xml/System.Net.NetworkInformation/SuffixOrigin.xml +++ b/xml/System.Net.NetworkInformation/SuffixOrigin.xml @@ -43,22 +43,21 @@ Specifies how an IP address host suffix was located. - class. Instances of this class are returned when you retrieve the unicast address information for a object. + + + +## Examples + The following code example displays prefix and suffix information for unicast addresses. -## Remarks - IP addresses are divided into two parts: the prefix and the suffix. The address prefix identifies the network portion of an IP address, and the address suffix identifies the host portion. Prefixes are assigned by global authorities, and suffixes are assigned by local system administrators. - - This enumeration is used by the class. Instances of this class are returned when you retrieve the unicast address information for a object. - - - -## Examples - The following code example displays prefix and suffix information for unicast addresses. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet45"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet45"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet45"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/TcpConnectionInformation.xml b/xml/System.Net.NetworkInformation/TcpConnectionInformation.xml index c154cfe36f5..58c0123612a 100644 --- a/xml/System.Net.NetworkInformation/TcpConnectionInformation.xml +++ b/xml/System.Net.NetworkInformation/TcpConnectionInformation.xml @@ -50,20 +50,19 @@ Provides information about the Transmission Control Protocol (TCP) connections on the local computer. - @@ -109,11 +108,11 @@ Initializes a new instance of the class. - class. - + class. + ]]> @@ -157,15 +156,14 @@ Gets the local endpoint of a Transmission Control Protocol (TCP) connection. An instance that contains the IP address and port on the local computer. - @@ -209,11 +207,11 @@ Gets the remote endpoint of a Transmission Control Protocol (TCP) connection. An instance that contains the IP address and port on the remote computer. - of this connection is , the remote endpoint is not established, and has all zeros for its IP address. - + of this connection is , the remote endpoint is not established, and has all zeros for its IP address. + ]]> @@ -257,11 +255,11 @@ Gets the state of this Transmission Control Protocol (TCP) connection. One of the enumeration values. - enumeration documentation. - + enumeration documentation. + ]]> diff --git a/xml/System.Net.NetworkInformation/TcpState.xml b/xml/System.Net.NetworkInformation/TcpState.xml index 36c85e45e26..9b1b0f3a044 100644 --- a/xml/System.Net.NetworkInformation/TcpState.xml +++ b/xml/System.Net.NetworkInformation/TcpState.xml @@ -43,20 +43,19 @@ Specifies the states of a Transmission Control Protocol (TCP) connection. - property. TCP is a transport layer protocol responsible for reliably sending and receiving data packets. The TCP states in this enumeration are defined in IETF RFC 793 available at [https://www.ietf.org](https://www.ietf.org/). + + + +## Examples + The following code example counts the established TCP connections. -## Remarks - This enumeration defines valid values for the property. TCP is a transport layer protocol responsible for reliably sending and receiving data packets. The TCP states in this enumeration are defined in IETF RFC 793 available at [https://www.ietf.org](https://www.ietf.org/). - - - -## Examples - The following code example counts the established TCP connections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Net.NetworkInformation/TcpStatistics.xml b/xml/System.Net.NetworkInformation/TcpStatistics.xml index 4bb31bc0091..b8eabbd36de 100644 --- a/xml/System.Net.NetworkInformation/TcpStatistics.xml +++ b/xml/System.Net.NetworkInformation/TcpStatistics.xml @@ -44,21 +44,20 @@ Provides Transmission Control Protocol (TCP) statistical data. - and methods, to give applications access to TCP traffic information. - - The information in this class correlates to the management information objects described in [https://www.ietf.org/rfc/rfc2012.txt](https://www.ietf.org/rfc/rfc2012.txt). - - - -## Examples - The following code example displays the TCP statistics for the specified address family. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: - + and methods, to give applications access to TCP traffic information. + + The information in this class correlates to the management information objects described in [https://www.ietf.org/rfc/rfc2012.txt](https://www.ietf.org/rfc/rfc2012.txt). + + + +## Examples + The following code example displays the TCP statistics for the specified address family. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet2"::: + ]]> @@ -104,11 +103,11 @@ Initializes a new instance of the class. - class. - + class. + ]]> @@ -152,20 +151,19 @@ Gets the number of accepted Transmission Control Protocol (TCP) connection requests. An value that specifies the total number of TCP connection requests accepted. - @@ -209,20 +207,19 @@ Gets the number of Transmission Control Protocol (TCP) connection requests made by clients. An value that specifies the total number of TCP connections initiated by clients. - @@ -266,15 +263,14 @@ Specifies the total number of Transmission Control Protocol (TCP) connections established. An value that specifies the total number of connections established. - @@ -318,20 +314,19 @@ Gets the number of current Transmission Control Protocol (TCP) connections. An value that specifies the total number of current TCP connections. - @@ -375,15 +370,14 @@ Gets the number of Transmission Control Protocol (TCP) errors received. An value that specifies the total number of TCP errors received. - @@ -427,20 +421,19 @@ Gets the number of failed Transmission Control Protocol (TCP) connection attempts. An value that specifies the total number of failed TCP connection attempts. - @@ -484,20 +477,19 @@ Gets the maximum number of supported Transmission Control Protocol (TCP) connections. An value that specifies the total number of TCP connections that can be supported. - @@ -541,20 +533,19 @@ Gets the maximum retransmission time-out value for Transmission Control Protocol (TCP) segments. An value that specifies the maximum number of milliseconds permitted by a TCP implementation for the retransmission time-out value. - value and the value. - - - -## Examples - The following code example displays time-out and maximum connection information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet5"::: + value and the value. + + + +## Examples + The following code example displays time-out and maximum connection information. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet5"::: + ]]> @@ -598,20 +589,19 @@ Gets the minimum retransmission time-out value for Transmission Control Protocol (TCP) segments. An value that specifies the minimum number of milliseconds permitted by a TCP implementation for the retransmission time-out value. - value and the value. - - - -## Examples - The following code example displays time-out and maximum connection information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp" id="Snippet5"::: + value and the value. + + + +## Examples + The following code example displays time-out and maximum connection information. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/DuplicateAddressDetectionState/Overview/networkexamples.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb" id="Snippet5"::: + ]]> @@ -655,20 +645,19 @@ Gets the number of RST packets received by Transmission Control Protocol (TCP) connections. An value that specifies the total number of reset TCP connections. - @@ -712,20 +701,19 @@ Gets the number of Transmission Control Protocol (TCP) segments sent with the reset flag set. An value that specifies the total number of TCP segments sent with the reset flag set. - @@ -769,20 +757,19 @@ Gets the number of Transmission Control Protocol (TCP) segments received. An value that specifies the total number of TCP segments received. - @@ -826,20 +813,19 @@ Gets the number of Transmission Control Protocol (TCP) segments re-sent. An value that specifies the total number of TCP segments retransmitted. - @@ -883,20 +869,19 @@ Gets the number of Transmission Control Protocol (TCP) segments sent. An value that specifies the total number of TCP segments sent. - diff --git a/xml/System.Net.NetworkInformation/UdpStatistics.xml b/xml/System.Net.NetworkInformation/UdpStatistics.xml index 223c7515be3..96f7d814bb6 100644 --- a/xml/System.Net.NetworkInformation/UdpStatistics.xml +++ b/xml/System.Net.NetworkInformation/UdpStatistics.xml @@ -44,21 +44,20 @@ Provides User Datagram Protocol (UDP) statistical data. - and methods to give applications access to UDP traffic information. - - The information in this class correlates to the management information objects described in [https://www.ietf.org/rfc/rfc2013.txt](https://www.ietf.org/rfc/rfc2013.txt). - - - -## Examples - The following code example displays the UDP statistics for the specified address family. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + and methods to give applications access to UDP traffic information. + + The information in this class correlates to the management information objects described in [https://www.ietf.org/rfc/rfc2013.txt](https://www.ietf.org/rfc/rfc2013.txt). + + + +## Examples + The following code example displays the UDP statistics for the specified address family. + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> @@ -104,11 +103,11 @@ Initializes a new instance of the class. - . - + . + ]]> @@ -152,19 +151,18 @@ Gets the number of User Datagram Protocol (UDP) datagrams that were received. An value that specifies the total number of datagrams that were delivered to UDP users. - @@ -208,14 +206,13 @@ Gets the number of User Datagram Protocol (UDP) datagrams that were sent. An value that specifies the total number of datagrams that were sent. - @@ -259,19 +256,18 @@ Gets the number of User Datagram Protocol (UDP) datagrams that were received and discarded because of port errors. An value that specifies the total number of received UDP datagrams that were discarded because there was no listening application at the destination port. - property. - - - -## Examples - The following code example displays the UDP statistics for the specified Internet Protocol version. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: - + property. + + + +## Examples + The following code example displays the UDP statistics for the specified Internet Protocol version. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> @@ -315,19 +311,18 @@ Gets the number of User Datagram Protocol (UDP) datagrams that were received and discarded because of errors other than bad port information. An value that specifies the total number of received UDP datagrams that could not be delivered for reasons other than the lack of an application at the destination port. - property. - - - -## Examples - The following code example displays the UDP statistics for the specified Internet Protocol version. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: - + property. + + + +## Examples + The following code example displays the UDP statistics for the specified Internet Protocol version. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> @@ -371,19 +366,18 @@ Gets the number of local endpoints that are listening for User Datagram Protocol (UDP) datagrams. An value that specifies the total number of sockets that are listening for UDP datagrams. - and classes to create UDP listener applications. - - - -## Examples - The following code example displays the UDP statistics for the specified Internet Protocol version. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLNetInfoReport/CPP/netinfo.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: - + and classes to create UDP listener applications. + + + +## Examples + The following code example displays the UDP statistics for the specified Internet Protocol version. + + :::code language="csharp" source="~/snippets/csharp/System.Net.NetworkInformation/IcmpV4Statistics/Overview/netinfo.cs" id="Snippet3"::: + ]]> diff --git a/xml/System.Net.Security/AuthenticationLevel.xml b/xml/System.Net.Security/AuthenticationLevel.xml index e4dc8572ae5..30645c854fa 100644 --- a/xml/System.Net.Security/AuthenticationLevel.xml +++ b/xml/System.Net.Security/AuthenticationLevel.xml @@ -43,22 +43,21 @@ Specifies client requirements for authentication and impersonation when using the class and derived classes to request a resource. - property. - + property. + > [!NOTE] -> The MutualAuthRequired and MutualAuthRequested values are relevant for Kerberos authentication. Kerberos authentication can be supported directly, or can be used if the Negotiate security protocol is used to select the actual security protocol. For more information about authentication protocols, see [Internet Authentication](/dotnet/framework/network-programming/internet-authentication). - - - -## Examples - The following code example demonstrates setting the authentication flags for a request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet1"::: +> The MutualAuthRequired and MutualAuthRequested values are relevant for Kerberos authentication. Kerberos authentication can be supported directly, or can be used if the Negotiate security protocol is used to select the actual security protocol. For more information about authentication protocols, see [Internet Authentication](/dotnet/framework/network-programming/internet-authentication). + + + +## Examples + The following code example demonstrates setting the authentication flags for a request. + :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Security/LocalCertificateSelectionCallback.xml b/xml/System.Net.Security/LocalCertificateSelectionCallback.xml index c23a0bca54c..fc74d63a05f 100644 --- a/xml/System.Net.Security/LocalCertificateSelectionCallback.xml +++ b/xml/System.Net.Security/LocalCertificateSelectionCallback.xml @@ -74,24 +74,22 @@ Selects the local Secure Sockets Layer (SSL) certificate used for authentication. An used for establishing an SSL connection. - class. The class is used to help secure information exchanged between a client and server. The client and server use this delegate to select a certificate to be used for authentication. - - - -## Examples - The following code example demonstrates a method implementation for this delegate. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet2"::: - - The following code example demonstrates creating an instance of this delegate. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet6"::: + class. The class is used to help secure information exchanged between a client and server. The client and server use this delegate to select a certificate to be used for authentication. + + + +## Examples + The following code example demonstrates a method implementation for this delegate. + :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet2"::: + + The following code example demonstrates creating an instance of this delegate. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet6"::: + ]]> diff --git a/xml/System.Net.Security/RemoteCertificateValidationCallback.xml b/xml/System.Net.Security/RemoteCertificateValidationCallback.xml index 1d100bccf0b..1b50332b90a 100644 --- a/xml/System.Net.Security/RemoteCertificateValidationCallback.xml +++ b/xml/System.Net.Security/RemoteCertificateValidationCallback.xml @@ -65,26 +65,24 @@ Verifies the remote Secure Sockets Layer (SSL) certificate used for authentication. A value that determines whether the specified certificate is accepted for authentication. - value returned by the method invoked by this delegate determines whether the authentication is allowed to succeed. - - This delegate is used with the class. - - - -## Examples - The following code example implements a method that is invoked by an instance of the class. If there are validation errors, this method displays them and returns `false`, which prevents communication with the unauthenticated server. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet1"::: - - The following code example creates the delegate using the method defined in the preceding code example. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet4"::: - + value returned by the method invoked by this delegate determines whether the authentication is allowed to succeed. + + This delegate is used with the class. + + + +## Examples + The following code example implements a method that's invoked by an instance of the class. If there are validation errors, this method displays them and returns `false`, which prevents communication with the unauthenticated server. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet1"::: + + The following code example creates the delegate using the method defined in the preceding code example. + + :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet4"::: + ]]> diff --git a/xml/System.Net.Security/SslStream.xml b/xml/System.Net.Security/SslStream.xml index c66e2cf4fdc..97c1624af16 100644 --- a/xml/System.Net.Security/SslStream.xml +++ b/xml/System.Net.Security/SslStream.xml @@ -98,13 +98,11 @@ ## Examples The following code example demonstrates creating an that uses the class to communicate with clients. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet0"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet0"::: The following code example demonstrates creating a that uses the class to communicate with a server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet0"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientSync/VB/clientsync.vb" id="Snippet0"::: @@ -262,7 +260,6 @@ ## Examples The following code example demonstrates calling this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet1"::: @@ -363,7 +360,6 @@ ## Examples The following code example creates an and initiates the client portion of the authentication. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientSync/VB/clientsync.vb" id="Snippet4"::: @@ -464,7 +460,6 @@ ## Examples The following code example demonstrates calling this constructor. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientAsync/VB/clientasync.vb" id="Snippet6"::: @@ -2487,18 +2482,15 @@ ## Examples The following code example demonstrates starting an asynchronous read operation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientAsync/VB/clientasync.vb" id="Snippet8"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientAsync/VB/clientasync.vb" id="Snippet4"::: The following method is called when the read completes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientAsync/VB/clientasync.vb" id="Snippet5"::: @@ -2596,7 +2588,6 @@ ## Examples The following code example demonstrates calling this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/BeginWrite/serverasync.cs" id="Snippet5"::: ]]> @@ -2671,7 +2662,6 @@ ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet5"::: @@ -2783,7 +2773,6 @@ ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet5"::: @@ -2843,7 +2832,6 @@ ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet5"::: @@ -2901,7 +2889,6 @@ ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet5"::: @@ -2966,7 +2953,6 @@ ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -3048,7 +3034,6 @@ ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -3335,7 +3320,6 @@ ## Examples The following code example demonstrates ending an asynchronous read operation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientAsync/VB/clientasync.vb" id="Snippet5"::: @@ -3408,7 +3392,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates ending an asynchronous write operation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerAsync/CPP/NclSslServerAsync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/BeginWrite/serverasync.cs" id="Snippet4"::: ]]> @@ -3512,7 +3495,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates calling this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientSync/VB/clientsync.vb" id="Snippet5"::: @@ -3622,7 +3604,6 @@ Authentication has not occurred. ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -3686,7 +3667,6 @@ Authentication has not occurred. ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -3744,7 +3724,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet4"::: @@ -3802,7 +3781,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet4"::: @@ -3860,7 +3838,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet4"::: @@ -3922,7 +3899,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet4"::: @@ -3980,7 +3956,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet4"::: @@ -4045,7 +4020,6 @@ Authentication has not occurred. ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -4118,7 +4092,6 @@ Authentication has not occurred. ## Examples The following code example displays the cryptography settings for the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -4226,7 +4199,6 @@ Authentication has not occurred. ## Examples The following code example demonstrates displaying the certificate returned by this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet6"::: @@ -4473,7 +4445,6 @@ This property gets the cipher suite that is going to be used in the communicatio ## Examples The following code example demonstrates reading from an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientSync/CPP/clientsync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/RemoteCertificateValidationCallback/Overview/clientsync.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslClientSync/VB/clientsync.vb" id="Snippet6"::: @@ -4719,7 +4690,6 @@ This property gets the cipher suite that is going to be used in the communicatio ## Examples The following code example demonstrates setting the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet1"::: @@ -4779,7 +4749,6 @@ If the property is accessed, the remote certificate will not be disposed when th ## Examples The following code example demonstrates displaying the certificate returned by this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet6"::: @@ -4982,7 +4951,6 @@ If the property is accessed, the remote certificate will not be disposed when th ## Examples The following example displays the security properties of the specified stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet3"::: @@ -5128,7 +5096,6 @@ If the property is accessed, the remote certificate will not be disposed when th ## Examples The following code example demonstrates writing to an authenticated . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet1"::: @@ -5389,7 +5356,6 @@ The class does not support multiple simulta ## Examples The following code example demonstrates setting the value of this property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslServerSync/CPP/NclSslServerSync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Security/SslStream/Overview/serversync.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NclSslServerSync/VB/serversync.vb" id="Snippet1"::: diff --git a/xml/System.Net.Sockets/AddressFamily.xml b/xml/System.Net.Sockets/AddressFamily.xml index 90afd8f909c..b67cdb2bf89 100644 --- a/xml/System.Net.Sockets/AddressFamily.xml +++ b/xml/System.Net.Sockets/AddressFamily.xml @@ -48,20 +48,19 @@ Specifies the addressing scheme that an instance of the class can use. - member specifies the addressing scheme that a will use to resolve an address. For example, InterNetwork indicates that an IP version 4 address is expected when a connects to an endpoint. + + + +## Examples + The following example creates a using the InterNetwork . -## Remarks - An member specifies the addressing scheme that a will use to resolve an address. For example, InterNetwork indicates that an IP version 4 address is expected when a connects to an endpoint. - - - -## Examples - The following example creates a using the InterNetwork . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/AddressFamily/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Send_Receive/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Send_Receive/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/IOControlCode.xml b/xml/System.Net.Sockets/IOControlCode.xml index 6f84473c5dc..5956ff4d3c4 100644 --- a/xml/System.Net.Sockets/IOControlCode.xml +++ b/xml/System.Net.Sockets/IOControlCode.xml @@ -43,19 +43,18 @@ Specifies the IO control codes supported by the method. - enumeration provides named values for specifying socket operational modes. These values are the control codes passed to the Windows Sockets 2 (Winsock 2) `WSAIoctl` function. - - - -## Examples - The following code example calls the method with a DataToRead parameter value and compares the result with accessing the. property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IOControlCode/Overview/iocontrolcode.cs" id="Snippet1"::: + enumeration provides named values for specifying socket operational modes. These values are the control codes passed to the Windows Sockets 2 (Winsock 2) `WSAIoctl` function. + + + +## Examples + The following code example calls the method with a DataToRead parameter value and compares the result with accessing the. property. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IOControlCode/Overview/iocontrolcode.cs" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/IPv6MulticastOption.xml b/xml/System.Net.Sockets/IPv6MulticastOption.xml index 88ee31bea94..d7ee73dad0a 100644 --- a/xml/System.Net.Sockets/IPv6MulticastOption.xml +++ b/xml/System.Net.Sockets/IPv6MulticastOption.xml @@ -56,7 +56,6 @@ ## Examples The following example creates an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet4"::: @@ -119,7 +118,6 @@ ## Examples The following example creates an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet4"::: @@ -181,7 +179,6 @@ ## Examples The following example creates an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet5"::: @@ -248,7 +245,6 @@ ## Examples The following example creates an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet4"::: @@ -314,7 +310,6 @@ ## Examples The following example creates an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet4"::: diff --git a/xml/System.Net.Sockets/LingerOption.xml b/xml/System.Net.Sockets/LingerOption.xml index 17a9720e2c7..5fc7c54d04f 100644 --- a/xml/System.Net.Sockets/LingerOption.xml +++ b/xml/System.Net.Sockets/LingerOption.xml @@ -45,22 +45,21 @@ Specifies whether a will remain connected after a call to the or methods and the length of time it will remain connected, if data remains to be sent. - or method. If you want to specify the amount of time that the will attempt to transmit unsent data after closing, create a with the `enable` parameter set to `true`, and the `seconds` parameter set to the desired amount of time. The `seconds` parameter is used to indicate how long you would like the to remain connected before timing out. If you do not want the to stay connected for any length of time after closing, create a instance with the `enable` parameter set to `true` and the `seconds` parameter set to zero. In this case, the will close immediately and any unsent data will be lost. Once created, pass the to the method. If you are sending and receiving data with a , then set the instance in the property. + + The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a when the property is not set and for a when the property is not set. + + + +## Examples + The following example sets a previously created to linger one second after calling the method. -## Remarks - There may still be data available in the outgoing network buffer after an application calls the or method. If you want to specify the amount of time that the will attempt to transmit unsent data after closing, create a with the `enable` parameter set to `true`, and the `seconds` parameter set to the desired amount of time. The `seconds` parameter is used to indicate how long you would like the to remain connected before timing out. If you do not want the to stay connected for any length of time after closing, create a instance with the `enable` parameter set to `true` and the `seconds` parameter set to zero. In this case, the will close immediately and any unsent data will be lost. Once created, pass the to the method. If you are sending and receiving data with a , then set the instance in the property. - - The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a when the property is not set and for a when the property is not set. - - - -## Examples - The following example sets a previously created to linger one second after calling the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -108,32 +107,31 @@ The number of seconds to remain connected after the method is called. Initializes a new instance of the class. - . Use the `enable` parameter to specify whether you would like the to continue transmitting unsent data after the close method is called. Use the `seconds` parameter to indicate how long you would like the to attempt transferring unsent data before timing out. If you specify `true` for the `enable` parameter and 0 for the `seconds` parameter, the will attempt to send data until there is no data left in the outgoing network buffer. If you specify `false` for the `enable` parameter, the will close immediately and any unsent data will be lost. - - The following table describes the behavior on the and methods based on the possible values of the `enable` and `seconds` parameters when an T:System.Net.Sockets.LingerOption instance is created and set in the or property. - -|`enable`|`seconds`|Behavior| -|--------------|---------------|--------------| -|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| -|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| -|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| - - The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. - - When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. - - - -## Examples - The following example sets a previously created to linger one second after calling the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic LingerOption Example/CPP/source.cpp" id="Snippet1"::: + . Use the `enable` parameter to specify whether you would like the to continue transmitting unsent data after the close method is called. Use the `seconds` parameter to indicate how long you would like the to attempt transferring unsent data before timing out. If you specify `true` for the `enable` parameter and 0 for the `seconds` parameter, the will attempt to send data until there is no data left in the outgoing network buffer. If you specify `false` for the `enable` parameter, the will close immediately and any unsent data will be lost. + + The following table describes the behavior on the and methods based on the possible values of the `enable` and `seconds` parameters when an T:System.Net.Sockets.LingerOption instance is created and set in the or property. + +|`enable`|`seconds`|Behavior| +|--------------|---------------|--------------| +|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| +|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| +|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| + + The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. + + When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. + + + +## Examples + The following example sets a previously created to linger one second after calling the method. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic LingerOption Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -189,23 +187,23 @@ if the should linger after is called; otherwise, . - property to determine whether the will linger after closing. Change this value to `true` or `false` and pass the altered to the method or set the or property.to disable or enable lingering. - - The following table describes the behavior for the possible values of the property and the property stored in the property. - -|`enable`|`seconds`|Behavior| -|--------------|---------------|--------------| -|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| -|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| -|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| - - The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. - - When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. - + property to determine whether the will linger after closing. Change this value to `true` or `false` and pass the altered to the method or set the or property.to disable or enable lingering. + + The following table describes the behavior for the possible values of the property and the property stored in the property. + +|`enable`|`seconds`|Behavior| +|--------------|---------------|--------------| +|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| +|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| +|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| + + The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. + + When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. + ]]> @@ -318,34 +316,33 @@ Gets or sets the amount of time to remain connected after calling the method if data remains to be sent. The amount of time, in seconds, to remain connected after calling . - will attempt to transfer unsent data before timing out. You can also set this value to the desired time-out period, in seconds. - - If the property is `true`, and you set to 0, the discards any pending data to send in the outgoing network buffer. If you change this value, you must pass the altered instance to the method or set the or property. - - The following table describes the behavior for the possible values of the property and the property stored in the property. - -|`enable`|`seconds`|Behavior| -|--------------|---------------|--------------| -|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| -|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| -|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| - - The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. - - When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. - - - -## Examples - The following example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet2"::: + will attempt to transfer unsent data before timing out. You can also set this value to the desired time-out period, in seconds. + + If the property is `true`, and you set to 0, the discards any pending data to send in the outgoing network buffer. If you change this value, you must pass the altered instance to the method or set the or property. + + The following table describes the behavior for the possible values of the property and the property stored in the property. + +|`enable`|`seconds`|Behavior| +|--------------|---------------|--------------| +|`false` (disabled), the default value|The time-out is not applicable, (default).|Attempts to send pending data for a connection-oriented socket (TCP, for example) until the default IP protocol time-out expires.| +|`true` (enabled)|A nonzero time-out|Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection.| +|`true` (enabled)|A zero timeout.|Discards any pending data. For connection-oriented socket (TCP, for example), Winsock resets the connection.| + + The IP stack computes the default IP protocol time-out period to use based on the round trip time of the connection. In most cases, the time-out computed by the stack is more relevant than one defined by an application. This is the default behavior for a socket when the property is not set. + + When the property stored in the property is set greater than the default IP protocol time-out, the default IP protocol time-out will still apply and override. + + + +## Examples + The following example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Net.Sockets/MulticastOption.xml b/xml/System.Net.Sockets/MulticastOption.xml index 3a5519e2fc2..6c542d6192c 100644 --- a/xml/System.Net.Sockets/MulticastOption.xml +++ b/xml/System.Net.Sockets/MulticastOption.xml @@ -67,11 +67,9 @@ ## Examples The following examples join the default IP interface to an IP multicast group. They assume the IP multicast group address in the range 224.0.0.0 to 239.255.255.255. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/MulticastOption/Overview/listener.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/VB/listener.vb" id="Snippet1"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/CPP/sender.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/MulticastOption/Overview/sender.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionSender/VB/sender.vb" id="Snippet1"::: @@ -233,7 +231,6 @@ ## Examples The following example creates a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/MulticastOption/Overview/listener.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/VB/listener.vb" id="Snippet2"::: @@ -305,7 +302,6 @@ ## Examples The following example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/MulticastOption/Overview/listener.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/VB/listener.vb" id="Snippet3"::: @@ -421,7 +417,6 @@ ## Examples The following example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/CPP/listener.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/MulticastOption/Overview/listener.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.MulticastOptionListener/VB/listener.vb" id="Snippet3"::: diff --git a/xml/System.Net.Sockets/NetworkStream.xml b/xml/System.Net.Sockets/NetworkStream.xml index 0ff7743e677..33bee7908ed 100644 --- a/xml/System.Net.Sockets/NetworkStream.xml +++ b/xml/System.Net.Sockets/NetworkStream.xml @@ -1674,7 +1674,6 @@ There is a failure reading from the network. ## Examples In the following code example, the `CanCommunicate` property checks the property to determine if the is readable. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/Readable/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkStream_Protected_Members/VB/source.vb" id="Snippet1"::: @@ -2083,7 +2082,6 @@ There is a failure reading from the network. ## Examples The following code example retrieves the underlying to verify an active connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/Readable/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkStream_Protected_Members/VB/source.vb" id="Snippet1"::: @@ -2256,7 +2254,6 @@ This method starts at the specified `offset` and sends `count` bytes from the co ## Examples The following code example checks to see whether the is writable. If it is, then is used to write a small message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkStream_Synch_SendAndReceive/VB/source.vb" id="Snippet3"::: @@ -2349,7 +2346,6 @@ There was a failure while writing to the network. ## Examples In the following code example, the `CanCommunicate` property checks the property to determine if the is writable. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkStream_Protected_Members/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/Readable/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkStream_Protected_Members/VB/source.vb" id="Snippet1"::: @@ -2607,7 +2603,6 @@ There was a failure while writing to the network. ## Examples The following code example sets the write time-out for a network stream to 10 milliseconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclTcpServerSync/cpp/tcplistener.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/WriteTimeout/tcplistener.cs" id="Snippet0"::: ]]> diff --git a/xml/System.Net.Sockets/SelectMode.xml b/xml/System.Net.Sockets/SelectMode.xml index 884fb1f4871..45e01bd067e 100644 --- a/xml/System.Net.Sockets/SelectMode.xml +++ b/xml/System.Net.Sockets/SelectMode.xml @@ -44,20 +44,19 @@ Defines the polling modes for the method. - enumeration defines the polling modes that can be passed to the method. Use the SelectRead value to determine if a listening has incoming connection requests. Use the SelectWrite value to determine if a is writeable. Use the SelectError value to determine if there is an error condition present on the . For explanations of writeability, readability, and the presence of error conditions, see the method. + + + +## Examples + The following example checks the status of a using all three enumeration values. A call to using the SelectWrite enumerated value should return `true`. -## Remarks - The enumeration defines the polling modes that can be passed to the method. Use the SelectRead value to determine if a listening has incoming connection requests. Use the SelectWrite value to determine if a is writeable. Use the SelectError value to determine if there is an error condition present on the . For explanations of writeability, readability, and the presence of error conditions, see the method. - - - -## Examples - The following example checks the status of a using all three enumeration values. A call to using the SelectWrite enumerated value should return `true`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/SelectMode/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SelectModeExample/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SelectModeExample/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/Socket.xml b/xml/System.Net.Sockets/Socket.xml index 2785c34b69f..72c02214c2a 100644 --- a/xml/System.Net.Sockets/Socket.xml +++ b/xml/System.Net.Sockets/Socket.xml @@ -334,7 +334,6 @@ This method populates the instance with data ga ## Examples The following code example demonstrates how to create an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/AddressFamily/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Send_Receive/VB/source.vb" id="Snippet1"::: @@ -411,7 +410,6 @@ This method populates the instance with data ga ## Examples The following code example accepts a simple connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Accept Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Accept/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Accept Example/VB/source.vb" id="Snippet1"::: @@ -771,7 +769,6 @@ This method populates the instance with data ga ## Examples The following code example displays the , , and to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet3"::: @@ -838,7 +835,6 @@ This method populates the instance with data ga ## Examples The following code example compares the results of calling IOControl with FIONREAD and the Available property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl/CPP/iocontrolserver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Available/iocontrolserver.cs" id="Snippet1"::: ]]> @@ -3337,7 +3333,6 @@ This method populates the instance with data ga ## Examples The following code example binds a using the specified local endpoint. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Bind Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Bind/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Bind Example/VB/source.vb" id="Snippet1"::: @@ -3554,7 +3549,6 @@ This method populates the instance with data ga ## Examples The following code example closes a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Close Example/VB/source.vb" id="Snippet1"::: @@ -3628,7 +3622,6 @@ This method populates the instance with data ga ## Examples The following code example demonstrates how to close a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Close Example/VB/source.vb" id="Snippet1"::: @@ -3717,7 +3710,6 @@ This method populates the instance with data ga ## Examples The following code example connects to a remote endpoint and then verifies the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Connect/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Connect Example/VB/source.vb" id="Snippet1"::: @@ -3807,7 +3799,6 @@ This method populates the instance with data ga ## Examples The following code example connects to a remote endpoint and then verifies the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginConnect/beginconnect.cs" id="Snippet4"::: ]]> @@ -3890,7 +3881,6 @@ This method populates the instance with data ga ## Examples The following code example connects to a remote endpoint and then verifies the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginConnect/beginconnect.cs" id="Snippet5"::: ]]> @@ -3975,7 +3965,6 @@ This method populates the instance with data ga ## Examples The following code example connects to a remote endpoint and then verifies the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socket.BeginConnect/CPP/beginconnect.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginConnect/beginconnect.cs" id="Snippet6"::: ]]> @@ -4666,7 +4655,6 @@ This method populates the instance with data ga ## Examples The following code example connects to a remote endpoint, checks the property, and checks the current state of the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Connect Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Connect/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Connect Example/VB/source.vb" id="Snippet1"::: @@ -4739,7 +4727,6 @@ This method populates the instance with data ga ## Examples The following code example creates a socket for synchronous communication and sends some data to a remote host. It then calls , to stop the send and receive activity, and , to close the socket connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginAccept/nclsocketenhancements.cs" id="Snippet12"::: ]]> @@ -5044,7 +5031,6 @@ This method populates the instance with data ga ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet2"::: ]]> @@ -5230,7 +5216,6 @@ Duplication of the socket reference failed. ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet2"::: ]]> @@ -6395,7 +6380,6 @@ Duplication of the socket reference failed. ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -6628,7 +6612,6 @@ In general, the `GetSocketOption` method should be used whenever getting a and time-out values and displays them to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2"::: @@ -6710,7 +6693,6 @@ In general, the `GetSocketOption` method should be used whenever getting a and time-out values and displays them to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2"::: @@ -6794,7 +6776,6 @@ In general, the `GetSocketOption` method should be used whenever getting a and time-out values and displays them to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet2"::: @@ -6933,7 +6914,6 @@ In general, the `GetSocketOption` method should be used whenever getting a @@ -7011,7 +6991,6 @@ In general, the `GetSocketOption` method should be used whenever getting a with and the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketIoControl1/CPP/iocontrolcode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IOControlCode/Overview/iocontrolcode.cs" id="Snippet1"::: ]]> @@ -7074,7 +7053,6 @@ In general, the `GetSocketOption` method should be used whenever getting a property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -7162,7 +7140,6 @@ In general, the `GetSocketOption` method should be used whenever getting a property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -7282,7 +7259,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example uses to listen for incoming connections. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Listen Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Listen/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Listen Example/VB/source.vb" id="Snippet1"::: @@ -7364,7 +7340,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example retrieves and displays the local and remote endpoints. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet4"::: @@ -7430,7 +7405,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet2"::: ]]> @@ -7498,7 +7472,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -7717,7 +7690,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example creates a socket, connects to a server, and uses to check the status of the socket. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/SelectMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SelectModeExample/VB/source.vb" id="Snippet1"::: @@ -7834,7 +7806,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example displays the , , and to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet3"::: @@ -7925,7 +7896,6 @@ The maximum length of the pending connections queue is determined automatically. ## Examples The following code example receives data on a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet1"::: @@ -8177,7 +8147,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example specifies a data buffer, and for receiving data on a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet2"::: @@ -8276,7 +8245,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example demonstrates how to receive data on a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Socketgenerics/CPP/sendgeneric.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/sendgeneric.cs" id="Snippet2"::: ]]> @@ -8454,7 +8422,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following receives the data found into `buffer`, and specifies for . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Send_Receive/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/AddressFamily/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Send_Receive/VB/source.vb" id="Snippet4"::: @@ -8724,7 +8691,6 @@ If you're using a connectionless , . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet4"::: @@ -9284,7 +9250,6 @@ If you're using a connectionless , property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -9385,7 +9350,6 @@ If you're using a connectionless , , are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet10"::: @@ -9756,7 +9719,6 @@ If you're using a connectionless , are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet11"::: @@ -9876,7 +9838,6 @@ If you're using a connectionless , are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet12"::: @@ -10811,7 +10772,6 @@ You must call the Bind method before performing this operation. ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -10887,7 +10847,6 @@ You must call the Bind method before performing this operation. ## Examples The following code example retrieves and displays the local and remote endpoints. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet4"::: @@ -11024,7 +10983,6 @@ You must call the Bind method before performing this operation. ## Examples The following code example uses to determine which listening sockets have a connection request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Select/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Select/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Select/VB/source.vb" id="Snippet1"::: @@ -11171,7 +11129,6 @@ You must call the Bind method before performing this operation. ## Examples The following code example demonstrates sending data on a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet1"::: @@ -11427,7 +11384,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example demonstrates sending data on a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet2"::: @@ -11667,7 +11623,6 @@ This member outputs trace information when you enable network tracing in your ap The following code example sends the data found in buffer, and specifies for . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet3"::: @@ -11935,7 +11890,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example specifies the data buffer, an offset, a size, and for sending data to a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet4"::: @@ -12053,7 +12007,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example specifies the data buffer, an offset, a size, and for sending data to a connected . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet4"::: @@ -12508,7 +12461,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -12595,7 +12547,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example creates and connects a socket and then sends a file to the remote host. The file "test.txt" is located in the root directory of the local machine. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginAccept/nclsocketenhancements.cs" id="Snippet3"::: ]]> @@ -12682,7 +12633,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example creates and connects a socket. The file "test.txt" is located in the root directory of the local machine. In this example, we create a prebuffer and postbuffer of data and send them to the remote host with the file. The default are used. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginAccept/nclsocketenhancements.cs" id="Snippet4"::: ]]> @@ -12996,7 +12946,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example demonstrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> @@ -13087,7 +13036,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example sends a connectionless datagram to the specified remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet5"::: @@ -13233,7 +13181,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example sends a connectionless datagram to the specified remote host. are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet6"::: @@ -13440,7 +13387,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example sends a connectionless datagram to the specified remote host. The size and are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet7"::: @@ -13540,7 +13486,6 @@ This member outputs trace information when you enable network tracing in your ap ## Examples The following code example sends a connectionless datagram to the specified remote host. The offset, size, and are passed to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Sync_Send_Receive/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Receive/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Sync_Send_Receive/VB/source.vb" id="Snippet8"::: @@ -14180,7 +14125,6 @@ The @@ -14253,7 +14197,6 @@ The and time-out values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: @@ -14396,7 +14339,6 @@ The and time-out values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet0"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet0"::: @@ -14470,7 +14412,6 @@ The and time out values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: @@ -14568,7 +14509,6 @@ The to disable the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Socket.Close Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Socket.Close Example/VB/source.vb" id="Snippet1"::: @@ -14637,7 +14577,6 @@ The , , and to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet3"::: @@ -14883,7 +14822,6 @@ Call IDisposable.Dispose when you are finished using the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SocketPropertyTester/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/DontFragment/class1.cs" id="Snippet1"::: ]]> diff --git a/xml/System.Net.Sockets/SocketFlags.xml b/xml/System.Net.Sockets/SocketFlags.xml index d13a8be3d98..67205df41c8 100644 --- a/xml/System.Net.Sockets/SocketFlags.xml +++ b/xml/System.Net.Sockets/SocketFlags.xml @@ -50,15 +50,14 @@ Specifies socket send and receive behaviors. - diff --git a/xml/System.Net.Sockets/SocketOptionLevel.xml b/xml/System.Net.Sockets/SocketOptionLevel.xml index 16789e6c848..79c48091ec8 100644 --- a/xml/System.Net.Sockets/SocketOptionLevel.xml +++ b/xml/System.Net.Sockets/SocketOptionLevel.xml @@ -44,22 +44,21 @@ Defines socket option levels for the and methods. - enumeration defines the socket option levels that can be passed to the and methods. enumerated values are grouped by . + + **Note** To use IPv6 on Windows XP, install Advance Networking Pack for Windows XP. + + + +## Examples + The following example uses this enumeration to set socket options. -## Remarks - The enumeration defines the socket option levels that can be passed to the and methods. enumerated values are grouped by . - - **Note** To use IPv6 on Windows XP, install Advance Networking Pack for Windows XP. - - - -## Examples - The following example uses this enumeration to set socket options. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/SocketOptionName.xml b/xml/System.Net.Sockets/SocketOptionName.xml index 1f22cc68d9c..31bf4944d3c 100644 --- a/xml/System.Net.Sockets/SocketOptionName.xml +++ b/xml/System.Net.Sockets/SocketOptionName.xml @@ -44,20 +44,19 @@ Defines configuration option names. - enumeration defines the name of each configuration option. Sockets can be configured with the method. + + + +## Examples + The following code example uses this enumeration to set socket options. -## Remarks - The enumeration defines the name of each configuration option. Sockets can be configured with the method. - - - -## Examples - The following code example uses this enumeration to set socket options. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Socket_Socket_Options/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/LingerOption/LingerTime/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Socket_Socket_Options/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/SocketType.xml b/xml/System.Net.Sockets/SocketType.xml index a859939a659..b63ac46cc65 100644 --- a/xml/System.Net.Sockets/SocketType.xml +++ b/xml/System.Net.Sockets/SocketType.xml @@ -49,23 +49,22 @@ Specifies the type of socket that an instance of the class represents. - can send and receive data, it must first be created using an , a , and a . The enumeration provides several options for defining the type of that you intend to open. - + can send and receive data, it must first be created using an , a , and a . The enumeration provides several options for defining the type of that you intend to open. + > [!NOTE] -> sometimes implicitly indicates which is used within an . For example, when the is , the is always . When the is , the is always . If you try to create a with an incompatible combination, throws a . - - +> sometimes implicitly indicates which is used within an . For example, when the is , the is always . When the is , the is always . If you try to create a with an incompatible combination, throws a . + + + +## Examples + The following example uses as a parameter to the constructor. -## Examples - The following example uses as a parameter to the constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SelectModeExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/SelectMode/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SelectModeExample/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SelectModeExample/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net.Sockets/TcpClient.xml b/xml/System.Net.Sockets/TcpClient.xml index 3b06e968c43..fcee1a20104 100644 --- a/xml/System.Net.Sockets/TcpClient.xml +++ b/xml/System.Net.Sockets/TcpClient.xml @@ -74,7 +74,6 @@ ## Examples The following code example establishes a `TcpClient` connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/CPP/tcpclient.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Overview/tcpclient.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpClient/VB/tcpclient.vb" id="Snippet1"::: @@ -156,7 +155,6 @@ ## Examples The following code example demonstrates how to use the parameterless constructor to create a new . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet4"::: @@ -219,7 +217,6 @@ ## Examples The following code example demonstrates how to create an instance of the class using a local endpoint. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet2"::: @@ -282,7 +279,6 @@ ## Examples The following code example demonstrates how to create an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet15"::: @@ -354,7 +350,6 @@ ## Examples The following code example demonstrates how to create an instance of the class using a host name and port number. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet3"::: @@ -480,7 +475,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example shows the use of the `Available` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet1"::: ]]> @@ -876,7 +870,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example demonstrates closing a by calling the `Close` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLTcpClientSync/CPP/tcpclient.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/NetworkStream/ReadTimeout/tcpclient.cs" id="Snippet1"::: ]]> @@ -952,7 +945,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example uses an to connect with a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet7"::: @@ -1027,7 +1019,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example uses an IP Address and port number to connect with a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet6"::: @@ -1102,7 +1093,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example uses an IP Address and port number to connect with a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet8"::: ]]> @@ -1178,7 +1168,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example uses the host name and port number to connect with a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet5"::: @@ -1772,7 +1761,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example connects to a remote endpoint and then verifies the connection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet2"::: ]]> @@ -1995,7 +1983,6 @@ The `Available` property is a way to determine whether data is queued for readin ## Examples The following code example creates a and gets and sets the value of the `ExclusiveAddressUse` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpClient1/CPP/newtcpclient.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/Available/newtcpclient.cs" id="Snippet3"::: ]]> @@ -2118,7 +2105,6 @@ The `GetStream` method returns a that yo ## Examples The following code example uses `GetStream` to obtain the underlying . After obtaining the , it sends and receives using its and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet14"::: @@ -2207,7 +2193,6 @@ The `GetStream` method returns a that yo ## Examples The following code example sets and gets the sockets linger time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet12"::: @@ -2269,7 +2254,6 @@ The `GetStream` method returns a that yo ## Examples The following code example disables the delay. It then checks the value of `NoDelay` to verify that the property was successfully set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet13"::: @@ -2337,7 +2321,6 @@ The `GetStream` method returns a that yo ## Examples The following code example sets and gets the receive buffer size. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet8"::: @@ -2408,7 +2391,6 @@ The `GetStream` method returns a that yo ## Examples The following code example sets and gets the receive time out. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet10"::: @@ -2478,7 +2460,6 @@ The `GetStream` method returns a that yo ## Examples The following code example sets and gets the send buffer size. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet9"::: @@ -2546,7 +2527,6 @@ The `GetStream` method returns a that yo ## Examples The following code example sets and gets the `SendTimeout` value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpClient/.ctor/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ClassicTcpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet11"::: diff --git a/xml/System.Net.Sockets/TcpListener.xml b/xml/System.Net.Sockets/TcpListener.xml index 8ad677a7659..c5a1c8549d9 100644 --- a/xml/System.Net.Sockets/TcpListener.xml +++ b/xml/System.Net.Sockets/TcpListener.xml @@ -60,29 +60,28 @@ Listens for connections from TCP network clients. - class provides simple methods that listen for and accept incoming connection requests in blocking synchronous mode. You can use either a or a to connect with a . Create a using an , a Local IP address and port number, or just a port number. Specify for the local IP address and 0 for the local port number if you want the underlying service provider to assign those values for you. If you choose to do this, you can use the property to identify the assigned information, after the socket has connected. - - Use the method to begin listening for incoming connection requests. will queue incoming connections until you either call the method or it has queued . Use either or to pull a connection from the incoming connection request queue. These two methods will block. If you want to avoid blocking, you can use the method first to determine if connection requests are available in the queue. - - Call the method to close the . - + class provides simple methods that listen for and accept incoming connection requests in blocking synchronous mode. You can use either a or a to connect with a . Create a using an , a Local IP address and port number, or just a port number. Specify for the local IP address and 0 for the local port number if you want the underlying service provider to assign those values for you. If you choose to do this, you can use the property to identify the assigned information, after the socket has connected. + + Use the method to begin listening for incoming connection requests. will queue incoming connections until you either call the method or it has queued . Use either or to pull a connection from the incoming connection request queue. These two methods will block. If you want to avoid blocking, you can use the method first to determine if connection requests are available in the queue. + + Call the method to close the . + > [!NOTE] -> The method does not close any accepted connections. You are responsible for closing these separately. - - - -## Examples - The following code example creates a . +> The method does not close any accepted connections. You are responsible for closing these separately. + + + +## Examples + The following code example creates a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/Overview/tcpserver.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/VB/tcpserver.vb" id="Snippet1"::: - - See for a client example. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/VB/tcpserver.vb" id="Snippet1"::: + + See for a client example. + ]]> @@ -155,24 +154,23 @@ The port on which to listen for incoming connection attempts. Initializes a new instance of the class that listens on the specified port. - or constructors. - - This constructor allows you to specify the port number on which to listen for incoming connection attempts. With this constructor, the underlying service provider assigns the most appropriate network address. If you do not care which local port is used, you can specify 0 for the port number. In this case, the service provider will assign an available ephemeral port number. If you use this approach, you can discover what local network address and port number has been assigned by using the property. - - Call the method to begin listening for incoming connection attempts. - - - -## Examples - The following code example creates a using a local port number. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet3"::: + or constructors. + + This constructor allows you to specify the port number on which to listen for incoming connection attempts. With this constructor, the underlying service provider assigns the most appropriate network address. If you do not care which local port is used, you can specify 0 for the port number. In this case, the service provider will assign an available ephemeral port number. If you use this approach, you can discover what local network address and port number has been assigned by using the property. + + Call the method to begin listening for incoming connection attempts. + + + +## Examples + The following code example creates a using a local port number. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/.ctor/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet3"::: + ]]> @@ -220,27 +218,26 @@ An that represents the local endpoint to which to bind the listener . Initializes a new instance of the class with the specified local endpoint. - using the desired local IP address and port number. Pass this to the constructor as the `localEP` parameter. - - If you do not care which local address is assigned, you can create an using as the address parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces. If you do not care which local port is used, you can create an using 0 for the port number. In this case, the service provider will assign an available ephemeral port number. If you use this approach, you can discover what local network address and port number has been assigned by using the property. - - Call the method to begin listening for incoming connection attempts. - + using the desired local IP address and port number. Pass this to the constructor as the `localEP` parameter. + + If you do not care which local address is assigned, you can create an using as the address parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces. If you do not care which local port is used, you can create an using 0 for the port number. In this case, the service provider will assign an available ephemeral port number. If you use this approach, you can discover what local network address and port number has been assigned by using the property. + + Call the method to begin listening for incoming connection attempts. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example creates an instance of the class using the local endpoint. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet1"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example creates an instance of the class using the local endpoint. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet1"::: + ]]> @@ -291,25 +288,24 @@ The port on which to listen for incoming connection attempts. Initializes a new instance of the class that listens for incoming connection attempts on the specified local IP address and port number. - using the desired local address. Pass this to the constructor as the `localaddr` parameter. If you do not care which local address is assigned, specify for the `localaddr` parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces. If you do not care which local port is used, you can specify 0 for the port number. In this case, the service provider will assign an available port number between 1024 and 65535. If you use this approach, you can discover what local network address and port number has been assigned by using the property. - - Call the method to begin listening for incoming connection attempts. - + using the desired local address. Pass this to the constructor as the `localaddr` parameter. If you do not care which local address is assigned, specify for the `localaddr` parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces. If you do not care which local port is used, you can specify 0 for the port number. In this case, the service provider will assign an available port number between 1024 and 65535. If you use this approach, you can discover what local network address and port number has been assigned by using the property. + + Call the method to begin listening for incoming connection attempts. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example creates an instance of the class using a local IP address and port number. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet2"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example creates an instance of the class using a local IP address and port number. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/.ctor/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -360,25 +356,24 @@ Accepts a pending connection request. A used to send and receive data. - is a blocking method that returns a that you can use to send and receive data. If you want to avoid blocking, use the method to determine if connection requests are available in the incoming connection queue. - - The returned is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. - + is a blocking method that returns a that you can use to send and receive data. If you want to avoid blocking, use the method to determine if connection requests are available in the incoming connection queue. + + The returned is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - In the following code example, the method is used to return a . This is used to communicate with the newly connected client. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet4"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + In the following code example, the method is used to return a . This is used to communicate with the newly connected client. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/.ctor/source.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListener.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet4"::: + ]]> The listener has not been started with a call to . @@ -426,16 +421,16 @@ Accepts a pending connection request as an asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns a used to send and receive data. - object will complete after the socket connection has been accepted. - - The returned in is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. - + object will complete after the socket connection has been accepted. + + The returned in is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -482,16 +477,16 @@ Accepts a pending connection request as a cancellable asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns a used to send and receive data. - object will complete after the socket connection has been accepted. - - The returned in is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. - + object will complete after the socket connection has been accepted. + + The returned in is initialized with the IP address and port number of the remote host. You can use any of the and methods available in the class to communicate with the remote host. When you are finished using the , be sure to call its method. If your application is relatively simple, consider using the method rather than the method. provides you with simple methods for sending and receiving data over a network in blocking synchronous mode. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -539,25 +534,24 @@ Accepts a pending connection request. A used to send and receive data. - is a blocking method that returns a that you can use to send and receive data. Use the method to determine if connection requests are available in the incoming connection queue if you want to avoid blocking. - - Use the method to obtain the underlying of the returned . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using . - + is a blocking method that returns a that you can use to send and receive data. Use the method to determine if connection requests are available in the incoming connection queue if you want to avoid blocking. + + Use the method to obtain the underlying of the returned . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using . + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - In the following code example, the method is used to return a . This is used to communicate with the newly connected client. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic TcpListenerExample/CPP/source.cpp" id="Snippet1"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + In the following code example, the method is used to return a . This is used to communicate with the newly connected client. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/AcceptTcpClient/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListenerExample/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic TcpListenerExample/VB/source.vb" id="Snippet1"::: + ]]> The listener has not been started with a call to . @@ -607,16 +601,16 @@ Accepts a pending connection request as an asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns a used to send and receive data. - object will complete after the TCP connection has been accepted. - - Use the method to obtain the underlying of the returned in the . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using or . - + object will complete after the TCP connection has been accepted. + + Use the method to obtain the underlying of the returned in the . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using or . + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -665,16 +659,16 @@ Accepts a pending connection request as a cancellable asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns a used to send and receive data. - object will complete after the TCP connection has been accepted. - - Use the method to obtain the underlying of the returned in the . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using or . - + object will complete after the TCP connection has been accepted. + + Use the method to obtain the underlying of the returned in the . The will provide you with methods for sending and receiving with the remote host. When you are through with the , be sure to call its method. If you want greater flexibility than a offers, consider using or . + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -729,11 +723,11 @@ if is actively listening; otherwise, . - can use this property to determine if the is currently listening for incoming connection attempts. The property can be used to avoid redundant attempts. - + can use this property to determine if the is currently listening for incoming connection attempts. The property can be used to avoid redundant attempts. + ]]> @@ -785,19 +779,19 @@ A Boolean value that specifies whether to enable or disable NAT traversal. Enables or disables Network Address Translation (NAT) traversal on a instance. - method is used to enable or disable NAT traversal for a instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel. - - When the `allowed` parameter is false, the option on the associated socket is set to . This explicitly disables NAT traversal for a instance. - - When the `allowed` parameter is true, the option on the associated socket is set to . This may allow NAT traversal for a depending on firewall rules in place on the system. - - The method must be invoked prior to calling the method to begin listening for incoming connection requests (before the socket is bound). If method is called after the method, then an will be thrown. - - A Teredo address is an IPv6 address with the prefix of 2001::/32. Teredo addresses can be returned through normal DNS name resolution or enumerated as an IPv6 address assigned to a local interface. - + method is used to enable or disable NAT traversal for a instance. NAT traversal may be provided using Teredo, 6to4, or an ISATAP tunnel. + + When the `allowed` parameter is false, the option on the associated socket is set to . This explicitly disables NAT traversal for a instance. + + When the `allowed` parameter is true, the option on the associated socket is set to . This may allow NAT traversal for a depending on firewall rules in place on the system. + + The method must be invoked prior to calling the method to begin listening for incoming connection requests (before the socket is bound). If method is called after the method, then an will be thrown. + + A Teredo address is an IPv6 address with the prefix of 2001::/32. Teredo addresses can be returned through normal DNS name resolution or enumerated as an IPv6 address assigned to a local interface. + ]]> The method was called after calling the method @@ -859,23 +853,23 @@ Begins an asynchronous operation to accept an incoming connection attempt. An that references the asynchronous creation of the . - operation must be completed by calling the method. Typically, the method is invoked by the `callback` delegate. - - This method does not block until the operation completes. To block until the operation completes, use the method. - - For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - + operation must be completed by calling the method. Typically, the method is invoked by the `callback` delegate. + + This method does not block until the operation completes. To block until the operation completes, use the method. + + For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). + > [!NOTE] -> You can call the property of the returned to identify the remote host's network address and port number. - +> You can call the property of the returned to identify the remote host's network address and port number. + > [!NOTE] -> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. - +> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). ]]> @@ -934,21 +928,21 @@ Begins an asynchronous operation to accept an incoming connection attempt. An that references the asynchronous creation of the . - operation must be completed by calling the method. Typically, the method is invoked by the `callback` delegate. - - This method does not block until the operation completes. To block until the operation completes, use the method. - - For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - + operation must be completed by calling the method. Typically, the method is invoked by the `callback` delegate. + + This method does not block until the operation completes. To block until the operation completes, use the method. + + For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). + > [!NOTE] -> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. - +> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> An error occurred while attempting to access the socket. @@ -1067,23 +1061,23 @@ An returned by a call to the method. Asynchronously accepts an incoming connection attempt and creates a new to handle remote host communication. - A . - + A . + The used to send and receive data. - method. - + method. + > [!NOTE] -> You can call the property of the returned to identify the remote host's network address and port number. - +> You can call the property of the returned to identify the remote host's network address and port number. + > [!NOTE] -> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. - +> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). ]]> @@ -1134,24 +1128,24 @@ An returned by a call to the method. Asynchronously accepts an incoming connection attempt and creates a new to handle remote host communication. - A . - + A . + The used to send and receive data. - method. - + method. + > [!NOTE] -> You can call the property of the underlying socket () to identify the remote host's network address and port number. - +> You can call the property of the underlying socket () to identify the remote host's network address and port number. + > [!NOTE] -> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. - +> If you receive a , use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -1197,22 +1191,21 @@ if the allows only one to listen to a specific port; otherwise, . The default is for Windows Server 2003 and Windows XP Service Pack 2 and later, and for all other versions. - property to prevent multiple listeners from listening to a specific port. - - Set this property before calling , or call the method and then set this property. - - - -## Examples - The following code example gets and sets the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet2"::: + property to prevent multiple listeners from listening to a specific port. + + Set this property before calling , or call the method and then set this property. + + + +## Examples + The following code example gets and sets the property. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet2"::: + ]]> The has been started. Call the method and then set the property. @@ -1247,7 +1240,7 @@ class finalizer free resources associated with the instance. ]]> @@ -1294,20 +1287,19 @@ The class finalizer free resources associa Gets the underlying of the current . The to which the is bound. - property to identify the local network interface and port number being used to listen for incoming client connection requests, after a socket connection has been made. You must first cast this to an . You can then call the property to retrieve the local IP address, and the property to retrieve the local port number. - - - -## Examples - The following code example displays the local IP address and port number on which the is listening for incoming connection requests. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp" id="Snippet1"::: + property to identify the local network interface and port number being used to listen for incoming client connection requests, after a socket connection has been made. You must first cast this to an . You can then call the property to retrieve the local IP address, and the property to retrieve the local port number. + + + +## Examples + The following code example displays the local IP address and port number on which the is listening for incoming connection requests. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/LocalEndpoint/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/VB/source.vb" id="Snippet1"::: + ]]> @@ -1356,20 +1348,19 @@ The class finalizer free resources associa if connections are pending; otherwise, . - and methods block execution until the method has queued an incoming connection request, the method can be used to determine if connections are available before attempting to accept them. - - - -## Examples - The following code example checks the method. If a connection request is waiting to be accepted, then a call to the method is made. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/CPP/source.cpp" id="Snippet1"::: + and methods block execution until the method has queued an incoming connection request, the method can be used to determine if connections are available before attempting to accept them. + + + +## Examples + The following code example checks the method. If a connection request is waiting to be accepted, then a call to the method is made. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/LocalEndpoint/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListener_Pending_LocalEndPoint/VB/source.vb" id="Snippet1"::: + ]]> The listener has not been started with a call to . @@ -1427,22 +1418,22 @@ The class finalizer free resources associa Gets the underlying network . The underlying . - creates a to listen for incoming client connection requests. Classes deriving from can use this property to get this . Use the underlying returned by the property if you require access beyond that which provides. - + creates a to listen for incoming client connection requests. Classes deriving from can use this property to get this . Use the underlying returned by the property if you require access beyond that which provides. + > [!NOTE] -> The property only returns the used to listen for incoming client connection requests. Use the method to accept a pending connection request and obtain a for sending and receiving data. You can also use the method to accept a pending connection request and obtain a for sending and receiving data. - - - -## Examples - The following code example demonstrates the use of the property. The underlying is retrieved and the option is configured to time out after 10 seconds if data still remains in the network buffer after the connection is closed. - +> The property only returns the used to listen for incoming client connection requests. Use the method to accept a pending connection request and obtain a for sending and receiving data. You can also use the method to accept a pending connection request and obtain a for sending and receiving data. + + + +## Examples + The following code example demonstrates the use of the property. The underlying is retrieved and the option is configured to time out after 10 seconds if data still remains in the network buffer after the connection is closed. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/Server/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListenerProtectedMembers1/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/TcpListenerProtectedMembers1/VB/source.vb" id="Snippet1"::: + ]]> @@ -1506,27 +1497,26 @@ The class finalizer free resources associa Starts listening for incoming connection requests. - method initializes the underlying , binds it to a local endpoint, and listens for incoming connection attempts. If a connection request is received, the method will queue the request and continue listening for additional requests until you call the method. If receives a connection request after it has already queued the maximum number of connections, it will throw a on the client. - - To remove a connection from the incoming connection queue, use either the method or the method. The method will remove a connection from the queue and return a that you can use to send and receive data. The method will return a that you can use to do the same. If your application only requires synchronous I/O, use . For more detailed behavioral control, use . Both of these methods block until a connection request is available in the queue. - - Use the method to close the and stop listening. You are responsible for closing your accepted connections separately. - + method initializes the underlying , binds it to a local endpoint, and listens for incoming connection attempts. If a connection request is received, the method will queue the request and continue listening for additional requests until you call the method. If receives a connection request after it has already queued the maximum number of connections, it will throw a on the client. + + To remove a connection from the incoming connection queue, use either the method or the method. The method will remove a connection from the queue and return a that you can use to send and receive data. The method will return a that you can use to do the same. If your application only requires synchronous I/O, use . For more detailed behavioral control, use . Both of these methods block until a connection request is available in the queue. + + Use the method to close the and stop listening. You are responsible for closing your accepted connections separately. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example demonstrates how is used to listen for incoming client connection attempts. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet3"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example demonstrates how is used to listen for incoming client connection attempts. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet3"::: + ]]> Use the property to obtain the specific error code. When you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error. @@ -1578,30 +1568,29 @@ The class finalizer free resources associa The maximum length of the pending connections queue. Starts listening for incoming connection requests with a maximum number of pending connection. - method initializes the underlying , binds it to a local endpoint, and listens for incoming connection attempts. If a connection request is received, will queue the request and continue listening for additional requests until you call the method. If receives a connection request after it has already queued the maximum number of connections it will throw a on the client. - - To remove a connection from the incoming connection queue, use either the method or the method. The method will remove a connection from the queue and return a that you can use to send and receive data. The method will return a that you can use to do the same. If your application only requires synchronous I/O, use the . For more detailed behavioral control, use method. Both of these methods block until a connection request is available in the queue. - - Use the method to close the and stop listening. You are responsible for closing your accepted connections separately. - + method initializes the underlying , binds it to a local endpoint, and listens for incoming connection attempts. If a connection request is received, will queue the request and continue listening for additional requests until you call the method. If receives a connection request after it has already queued the maximum number of connections it will throw a on the client. + + To remove a connection from the incoming connection queue, use either the method or the method. The method will remove a connection from the queue and return a that you can use to send and receive data. The method will return a that you can use to do the same. If your application only requires synchronous I/O, use the . For more detailed behavioral control, use method. Both of these methods block until a connection request is available in the queue. + + Use the method to close the and stop listening. You are responsible for closing your accepted connections separately. + > [!NOTE] -> Use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. - +> Use the property to obtain the specific error code and refer to the [Windows Sockets version 2 API error code](/windows/desktop/winsock/windows-sockets-error-codes-2) documentation for a detailed description of the error. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example demonstrates how is used to listen for incoming client connection attempts. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/cpp/tcpserver.cpp" id="Snippet3"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example demonstrates how is used to listen for incoming client connection attempts. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/BeginAcceptSocket/tcpserver.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener1/VB/tcpserver.vb" id="Snippet3"::: + ]]> An error occurred while accessing the socket. @@ -1654,23 +1643,22 @@ The class finalizer free resources associa Closes the listener. - closes the listener. Any unaccepted connection requests in the queue will be lost. Remote hosts waiting for a connection to be accepted will throw a . You are responsible for closing your accepted connections separately. - + closes the listener. Any unaccepted connection requests in the queue will be lost. Remote hosts waiting for a connection to be accepted will throw a . You are responsible for closing your accepted connections separately. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example demonstrates using the method to close the underlying . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/CPP/tcpserver.cpp" id="Snippet1"::: +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example demonstrates using the method to close the underlying . + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/TcpListener/Overview/tcpserver.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/VB/tcpserver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.TcpListener/VB/tcpserver.vb" id="Snippet1"::: + ]]> Use the property to obtain the specific error code. When you have obtained this code, you can refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error. diff --git a/xml/System.Net.Sockets/TransmitFileOptions.xml b/xml/System.Net.Sockets/TransmitFileOptions.xml index 9a0853da63e..f3e6584a86f 100644 --- a/xml/System.Net.Sockets/TransmitFileOptions.xml +++ b/xml/System.Net.Sockets/TransmitFileOptions.xml @@ -48,21 +48,20 @@ The enumeration defines values used in file transfer requests. - [!NOTE] -> The flags `Disconnect` and `ReuseSocket` return the socket to a disconnected, reusable state after the file has been transmitted. These flags should not be used on a socket where quality of service (QOS) has been requested, because the service provider might immediately delete any quality of service associated with the socket before the file transfer has completed. The best approach for a QOS-enabled socket is to call when the file transfer has completed, rather than relying on these flags. - - - -## Examples - The following example demonstrates the use of `TransmitFileOptions` in a call to . The file "test.txt" is located in the root directory of the local machine. In this example, a prebuffer and postbuffer of data are created and sent to the remote host with the file. To use the system's default thread, `UseDefaultWorkerThread` is specified. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSocketEnhancements/CPP/nclsocketenhancements.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginAccept/nclsocketenhancements.cs" id="Snippet4"::: +> The flags `Disconnect` and `ReuseSocket` return the socket to a disconnected, reusable state after the file has been transmitted. These flags should not be used on a socket where quality of service (QOS) has been requested, because the service provider might immediately delete any quality of service associated with the socket before the file transfer has completed. The best approach for a QOS-enabled socket is to call when the file transfer has completed, rather than relying on these flags. + + + +## Examples + The following example demonstrates the use of `TransmitFileOptions` in a call to . The file "test.txt" is located in the root directory of the local machine. In this example, a prebuffer and postbuffer of data are created and sent to the remote host with the file. To use the system's default thread, `UseDefaultWorkerThread` is specified. + :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/Socket/BeginAccept/nclsocketenhancements.cs" id="Snippet4"::: + ]]> diff --git a/xml/System.Net.Sockets/UdpClient.xml b/xml/System.Net.Sockets/UdpClient.xml index ca542f5502e..c7827046ae9 100644 --- a/xml/System.Net.Sockets/UdpClient.xml +++ b/xml/System.Net.Sockets/UdpClient.xml @@ -76,7 +76,6 @@ ## Examples The following example establishes a connection using the host name `www.contoso.com` on port 11000. A small string message is sent to two separate remote host machines. The method blocks execution until a message is received. Using the passed to , the identity of the responding host is revealed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClientExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClientExample/VB/source.vb" id="Snippet1"::: @@ -153,7 +152,6 @@ ## Examples The following example demonstrates how to use the parameterless constructor to create an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet4"::: @@ -223,7 +221,6 @@ ## Examples The following example demonstrates using a local port number to create an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet1"::: @@ -288,7 +285,6 @@ ## Examples The following example demonstrates how to create an instance of the class using a local endpoint. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet2"::: @@ -418,7 +414,6 @@ ## Examples The following code example shows how to create a UDP client to use in a multicast group. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet3"::: @@ -485,7 +480,6 @@ ## Examples The following example demonstrates how to create an instance of the class using a host name and port number. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet3"::: @@ -683,7 +677,6 @@ ## Examples The following code example shows the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet1"::: ]]> @@ -757,7 +750,6 @@ ## Examples The following code example uses to asynchronously receive a server response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet1"::: ]]> @@ -857,10 +849,8 @@ ## Examples The following code example uses to asynchronously send a server request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet2"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet3"::: ]]> @@ -945,10 +935,8 @@ ## Examples The following code example uses to asynchronously send a server request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet2"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet4"::: ]]> @@ -1035,10 +1023,8 @@ ## Examples The following code example uses to asynchronously send a server request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet2"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet5"::: ]]> @@ -1108,7 +1094,6 @@ ## Examples The following example demonstrates the use of the property. In this example, broadcasting is enabled for the underlying . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Client/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.ProtectedMethodsAndPropertiesExample/VB/source.vb" id="Snippet1"::: @@ -1175,7 +1160,6 @@ ## Examples The following example demonstrates closing a by calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet15"::: @@ -1256,7 +1240,6 @@ ## Examples The following example uses an to establish a default remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet7"::: @@ -1334,7 +1317,6 @@ ## Examples The following example uses an IP address and port number to connect with a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet6"::: @@ -1417,7 +1399,6 @@ ## Examples The following example uses the host name and port number to connect to a remote host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet5"::: @@ -1585,7 +1566,6 @@ ## Examples The following code example shows the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet2"::: ]]> @@ -1659,7 +1639,6 @@ ## Examples The following example demonstrates how to drop a multicast group by providing a multicast address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet2"::: @@ -1731,7 +1710,6 @@ ## Examples The following code example demonstrates how to drop a multicast group by providing a multicast address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet2"::: @@ -1795,7 +1773,6 @@ ## Examples The following code example shows the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet3"::: ]]> @@ -1866,7 +1843,6 @@ ## Examples The following code example uses to complete an asynchronous receive of a server response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet1"::: ]]> @@ -1935,7 +1911,6 @@ ## Examples The following code example uses to complete an asynchronous send of a server request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient1/cpp/asyncudp.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/BeginReceive/asyncudp.cs" id="Snippet2"::: ]]> @@ -2002,7 +1977,6 @@ ## Examples The following code example creates a , and gets and sets the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet4"::: ]]> @@ -2087,7 +2061,6 @@ ## Examples The following code example demonstrates how to join a multicast group by providing a multicast address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet1"::: @@ -2160,7 +2133,6 @@ ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/CPP/joinmulticastgroup.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/IPv6MulticastOption/Overview/joinmulticastgroup.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.UdpClient.JoinMulticastGroup/VB/joinmulticastgroup.vb" id="Snippet5"::: @@ -2235,7 +2207,6 @@ ## Examples The following example demonstrates how to join a multicast group by providing two parameters, a multicast address, and a number that represents the TTL. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet13"::: @@ -2310,7 +2281,6 @@ ## Examples The following code example shows the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet6"::: ]]> @@ -2369,7 +2339,6 @@ ## Examples The following code example shows the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet7"::: ]]> @@ -2448,7 +2417,6 @@ ## Examples The following example demonstrates the method. The method blocks execution until it receives a message. Using the passed to , the identity of the responding host is revealed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet11"::: @@ -2656,7 +2624,6 @@ ## Examples The following example demonstrates the method. You must establish a default remote host prior to using this overload. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet10"::: @@ -2786,7 +2753,6 @@ ## Examples The following example demonstrates the method. This example uses an to specify the target host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet8"::: @@ -2923,7 +2889,6 @@ ## Examples The following example demonstrates the method. This example uses a host name and a port number to identify the target host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/CPP/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/.ctor/source.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UdpClient.PublicMethodsAndPropertiesExample/VB/source.vb" id="Snippet9"::: @@ -3393,7 +3358,6 @@ Call IDisposable.Dispose when you are finished using the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.UdpClient/CPP/newudpclient.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net.Sockets/UdpClient/Available/newudpclient.cs" id="Snippet5"::: ]]> diff --git a/xml/System.Net/AuthenticationManager.xml b/xml/System.Net/AuthenticationManager.xml index d445b8a1f66..f00a7a3c59f 100644 --- a/xml/System.Net/AuthenticationManager.xml +++ b/xml/System.Net/AuthenticationManager.xml @@ -54,20 +54,19 @@ Manages the authentication modules called during the client authentication process. - is a static class that manages the authentication modules that an application uses. When a request is made to protected resources, the calls the method to get an instance to use in subsequent requests. - - The queries each registered authentication module by calling the method for each module. The first authentication module to return an instance is used to authenticate the request. - + is a static class that manages the authentication modules that an application uses. When a request is made to protected resources, the calls the method to get an instance to use in subsequent requests. + + The queries each registered authentication module by calling the method for each module. The first authentication module to return an instance is used to authenticate the request. + Modules that provide the basic, digest, negotiate, NTLM, and Kerberos authentication types are registered with the by default. Additional authentication modules that implement the interface can be added using the method. Authentication modules are called in the order in which they were added to the list. - + ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet1"::: + ]]> Changes to NTLM authentication for HTTPWebRequest in Version 3.5 SP1 @@ -133,27 +132,27 @@ Calls each registered authentication module to find the first module that can respond to the authentication request. An instance of the class containing the result of the authorization attempt. If there is no authentication module to respond to the challenge, this method returns . - method calls the method on each registered authentication module until one of the module responds with an instance. - - The first instance returned is used to authenticate the request. If no authentication module can authenticate the request, the method returns `null`. - - Authentication modules are called in the order in which they are registered with the . - + method calls the method on each registered authentication module until one of the module responds with an instance. + + The first instance returned is used to authenticate the request. If no authentication module can authenticate the request, the method returns `null`. + + Authentication modules are called in the order in which they are registered with the . + ]]> .NET Core and .NET 5+ only: In all cases. - is . - - -or- - - is . - - -or- - + is . + + -or- + + is . + + -or- + is . @@ -206,21 +205,20 @@ Gets or sets the credential policy to be used for resource requests made using the class. An object that implements the interface that determines whether credentials are sent with requests. The default value is . - object that specifies credentials. - - - -## Examples - The following code example demonstrates setting the credential policy. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet2"::: - + object that specifies credentials. + + + +## Examples + The following code example demonstrates setting the credential policy. + + :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet2"::: + ]]> @@ -269,31 +267,30 @@ Gets the dictionary that contains Service Principal Names (SPNs) that are used to identify hosts during Kerberos authentication for requests made using and its derived classes. A writable that contains the SPN values for keys composed of host information. - to in your request. - - When a requires mutual authentication, the SPN for the destination must be supplied by the client. If you know the SPN, you can add it to the before sending the request. If you have not added SPN information to this dictionary, the uses the method to compose the most likely SPN; however, this is a computed value and might be incorrect. If mutual authentication is attempted and fails, you can check the dictionary to determine the computed SPN. No SPN is entered into the dictionary if the authentication protocol does not support mutual authentication. - - To add an SPN value to this dictionary, use the of the as the key. Internally, the key is truncated to include the , , and the if it is not the default port. - + to in your request. + + When a requires mutual authentication, the SPN for the destination must be supplied by the client. If you know the SPN, you can add it to the before sending the request. If you have not added SPN information to this dictionary, the uses the method to compose the most likely SPN; however, this is a computed value and might be incorrect. If mutual authentication is attempted and fails, you can check the dictionary to determine the computed SPN. No SPN is entered into the dictionary if the authentication protocol does not support mutual authentication. + + To add an SPN value to this dictionary, use the of the as the key. Internally, the key is truncated to include the , , and the if it is not the default port. + > [!NOTE] -> Accessing the methods and properties of the requires unrestricted . - +> Accessing the methods and properties of the requires unrestricted . + > [!NOTE] -> When Kerberos authentication is performed through a proxy, both the proxy and the ultimate host name need to be resolved to an SPN. The proxy name resolution is protected by a timeout. Resolution of the ultimate host name to a SPN requires a DNS lookup, and there is no timeout associated directly with this operation. Therefore synchronous operations may take longer to timeout. To overcome this, add the ultimate host's URI prefix to the SPN cache prior to making requests to it. - - Version 3.5 SP1 now defaults to specifying the host name used in the request URL in the SPN in the NTLM (NT LAN Manager) authentication exchange when the property is not set. The host name used in the request URL may be different from the Host header specified in the in the client request. The host name used in the request URL may be different from the actual host name of the server, the machine name of the server, the computer's IP address, or the loopback address. In these cases, Windows will fail the authentication request. To address the issue, you may need to notify Windows that the host name used in the request URL in the client request ("contoso", for example) is actually an alternate name for the local computer. - - - -## Examples - The following code example demonstrates displaying the contents of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet5"::: - +> When Kerberos authentication is performed through a proxy, both the proxy and the ultimate host name need to be resolved to an SPN. The proxy name resolution is protected by a timeout. Resolution of the ultimate host name to a SPN requires a DNS lookup, and there is no timeout associated directly with this operation. Therefore synchronous operations may take longer to timeout. To overcome this, add the ultimate host's URI prefix to the SPN cache prior to making requests to it. + + Version 3.5 SP1 now defaults to specifying the host name used in the request URL in the SPN in the NTLM (NT LAN Manager) authentication exchange when the property is not set. The host name used in the request URL may be different from the Host header specified in the in the client request. The host name used in the request URL may be different from the actual host name of the server, the machine name of the server, the computer's IP address, or the loopback address. In these cases, Windows will fail the authentication request. To address the issue, you may need to notify Windows that the host name used in the request URL in the client request ("contoso", for example) is actually an alternate name for the local computer. + + + +## Examples + The following code example demonstrates displaying the contents of the . + + :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet5"::: + ]]> Changes to NTLM authentication for HTTPWebRequest in Version 3.5 SP1 @@ -357,13 +354,13 @@ Preauthenticates a request. An instance of the class if the request can be preauthenticated; otherwise, . If is , this method returns . - method returns an Authentication instance and sends the authorization information to the server preemptively instead of waiting for the resource to issue a challenge. This behavior is outlined in section 3.3 of RFC 2617 (HTTP Authentication: Basic and Digest Access Authentication). Authentication modules that support preauthentication allow clients to improve server efficiency by avoiding extra round trips caused by authentication challenges. - - Authorization modules that can preauthenticate requests set the property to `true`. - + method returns an Authentication instance and sends the authorization information to the server preemptively instead of waiting for the resource to issue a challenge. This behavior is outlined in section 3.3 of RFC 2617 (HTTP Authentication: Basic and Digest Access Authentication). Authentication modules that support preauthentication allow clients to improve server efficiency by avoiding extra round trips caused by authentication challenges. + + Authorization modules that can preauthenticate requests set the property to `true`. + ]]> .NET Core and .NET 5+ only: In all cases. @@ -413,20 +410,19 @@ The to register with the authentication manager. Registers an authentication module with the authentication manager. - method adds authentication modules to the end of the list of modules called by the method. Authentication modules are called in the order in which they were added to the list. If a module with the same is already registered, this method removes the registered module and adds `authenticationModule` to the end of the list. - - - -## Examples - The following example registers an authentication module with the authentication manager. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp" id="Snippet2"::: + method adds authentication modules to the end of the list of modules called by the method. Authentication modules are called in the order in which they were added to the list. If a module with the same is already registered, this method removes the registered module and adds `authenticationModule` to the end of the list. + + + +## Examples + The following example registers an authentication module with the authentication manager. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Register/custombasicauthentication.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.Authentication/VB/custombasicauthentication.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.Authentication/VB/custombasicauthentication.vb" id="Snippet2"::: + ]]> @@ -472,20 +468,19 @@ Gets a list of authentication modules that are registered with the authentication manager. An that enables the registered authentication modules to be read. - property provides an instance that enables the list of registered authentication modules to be read. The method adds modules to the list, and the method removes modules from it. - - - -## Examples - The following example uses the property to get a list of authentication modules that are registered with the authentication manager. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet8"::: + property provides an instance that enables the list of registered authentication modules to be read. The method adds modules to the list, and the method removes modules from it. + + + +## Examples + The following example uses the property to get a list of authentication modules that are registered with the authentication manager. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet8"::: + ]]> @@ -542,20 +537,19 @@ The to remove from the list of registered modules. Removes the specified authentication module from the list of registered modules. - method removes the specified authentication module from the list of authentication modules called by the method. The module must have been added to the list using the method before it can be removed from the list. - - - -## Examples - The following example uses the method to remove the specified authentication module from the list of registered modules. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Sockets.Authentication/CPP/custombasicauthentication.cpp" id="Snippet2"::: + method removes the specified authentication module from the list of authentication modules called by the method. The module must have been added to the list using the method before it can be removed from the list. + + + +## Examples + The following example uses the method to remove the specified authentication module from the list of registered modules. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Register/custombasicauthentication.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.Authentication/VB/custombasicauthentication.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Sockets.Authentication/VB/custombasicauthentication.vb" id="Snippet2"::: + ]]> @@ -605,20 +599,19 @@ The authentication scheme of the module to remove. Removes authentication modules with the specified authentication scheme from the list of registered modules. - method removes the authentication module with the specified authentication scheme from the list of authentication modules called by the method. The module must have been added to the list using the method before it can be removed from the list. - - - -## Examples - The following example uses the method to remove an authentication module with the specified authentication scheme from the list of registered modules. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/CPP/authenticationmanager_unregister2.cpp" id="Snippet2"::: + method removes the authentication module with the specified authentication scheme from the list of authentication modules called by the method. The module must have been added to the list using the method before it can be removed from the list. + + + +## Examples + The following example uses the method to remove an authentication module with the specified authentication scheme from the list of registered modules. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Unregister/authenticationmanager_unregister2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/VB/authenticationmanager_unregister2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/AuthenticationManager_UnRegister2/VB/authenticationmanager_unregister2.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Net/Authorization.xml b/xml/System.Net/Authorization.xml index 1ce646ce2cf..2238ac0fa81 100644 --- a/xml/System.Net/Authorization.xml +++ b/xml/System.Net/Authorization.xml @@ -50,13 +50,13 @@ Contains an authentication message for an Internet server. - returns an instance of the class that contains an authentication message. This message is sent to the Internet server to indicate that the client (such as or one of its descendants) is authorized to access the server. - - The instance is created by the authentication module that the designates to handle the request. - + returns an instance of the class that contains an authentication message. This message is sent to the Internet server to indicate that the client (such as or one of its descendants) is authorized to access the server. + + The instance is created by the authentication module that the designates to handle the request. + ]]> @@ -112,20 +112,19 @@ The encrypted authorization message expected by the server. Creates a new instance of the class with the specified authorization message. - instance is created with the property set to `token` and the property set to `true`. - - + instance is created with the property set to `token` and the property set to `true`. + + + +## Examples + The following code example shows how to create an object. For a complete example, refer to the class. -## Examples - The following code example shows how to create an object. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet3"::: + ]]> @@ -172,20 +171,19 @@ The completion status of the authorization attempt. if the authorization attempt is complete; otherwise, . Creates a new instance of the class with the specified authorization message and completion status. - instance is created with the property set to `token` and the property set to `finished`. - - - -## Examples - The following code example creates a new instance of the class with the specified authorization message and completion status. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp" id="Snippet1"::: + instance is created with the property set to `token` and the property set to `finished`. + + + +## Examples + The following code example creates a new instance of the class with the specified authorization message and completion status. + :::code language="csharp" source="~/snippets/csharp/System.Net/Authorization/.ctor/authorization_protectionrealm.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_ProtectionRealm/VB/authorization_protectionrealm.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_ProtectionRealm/VB/authorization_protectionrealm.vb" id="Snippet1"::: + ]]> @@ -240,15 +238,14 @@ A unique identifier that can be used to create private client-server connections that are bound only to this authentication scheme. Creates a new instance of the class with the specified authorization message, completion status, and connection group identifier. - class with the specified authorization message, completion status, and connection group identifier. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Authorization_Constructor3/CPP/authorization_constructor3.cpp" id="Snippet1"::: + class with the specified authorization message, completion status, and connection group identifier. + :::code language="csharp" source="~/snippets/csharp/System.Net/Authorization/.ctor/authorization_constructor3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_Constructor3/VB/authorization_constructor3.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_Constructor3/VB/authorization_constructor3.vb" id="Snippet1"::: + ]]> @@ -299,20 +296,19 @@ if the authentication process is complete; otherwise, . - property is set to `true` when the authentication process between the client and the server is finished. Some authentication modules, such as the Kerberos module, use multiple round trips between the client and server to complete the authentication process. To keep the or descendant that initiated the authentication process from interrupting while authorization is taking place, the authentication module sets the property to `false`. - - - -## Examples - The following code example uses the property to get the completion status of the authorization. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet5"::: + property is set to `true` when the authentication process between the client and the server is finished. Some authentication modules, such as the Kerberos module, use multiple round trips between the client and server to complete the authentication process. To keep the or descendant that initiated the authentication process from interrupting while authorization is taking place, the authentication module sets the property to `false`. + + + +## Examples + The following code example uses the property to get the completion status of the authorization. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: + ]]> @@ -364,20 +360,19 @@ Gets a unique identifier for user-specific connections. A unique string that associates a connection with an authenticating entity. - property is a unique string that associates a connection with a specific authenticating entity. For example, the NTLM authorization module ties the authentication credential information to a specific connection to prevent invalid reuse of the connection. - - - -## Examples - The following code example uses the property to get the group identifier returned by the server. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet5"::: + property is a unique string that associates a connection with a specific authenticating entity. For example, the NTLM authorization module ties the authentication credential information to a specific connection to prevent invalid reuse of the connection. + + + +## Examples + The following code example uses the property to get the group identifier returned by the server. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: + ]]> @@ -428,22 +423,21 @@ Gets the message returned to the server in response to an authentication challenge. The message that will be returned to the server in response to an authentication challenge. - property contains the authorization string that the client will return to the server when accessing protected resources. The actual contents of the message are defined by the authentication type the client and server are using. Basic HTTP authentication, for example, uses a different message than Kerberos authentication. - - When an authentication module supports preauthentication, the property is sent with the initial request. - - - -## Examples - The following code example uses the property to get the message returned to the server in response to an authentication challenge. For a complete example, refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet5"::: + property contains the authorization string that the client will return to the server when accessing protected resources. The actual contents of the message are defined by the authentication type the client and server are using. Basic HTTP authentication, for example, uses a different message than Kerberos authentication. + + When an authentication module supports preauthentication, the property is sent with the initial request. + + + +## Examples + The following code example uses the property to get the message returned to the server in response to an authentication challenge. For a complete example, refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet5"::: + ]]> @@ -494,11 +488,11 @@ if both client and server were authenticated; otherwise, . - @@ -553,20 +547,19 @@ Gets or sets the prefix for Uniform Resource Identifiers (URIs) that can be authenticated with the property. An array of strings that contains URI prefixes. - property contains a list of URI prefixes that the property can be used to authenticate. and its descendants compare a URI to this list to determine if the is valid for a particular URI. - - - -## Examples - The following code example gets or sets the prefix for URIs that can be authenticated with the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Authorization_ProtectionRealm/CPP/authorization_protectionrealm.cpp" id="Snippet1"::: + property contains a list of URI prefixes that the property can be used to authenticate. and its descendants compare a URI to this list to determine if the is valid for a particular URI. + + + +## Examples + The following code example gets or sets the prefix for URIs that can be authenticated with the property. + :::code language="csharp" source="~/snippets/csharp/System.Net/Authorization/.ctor/authorization_protectionrealm.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_ProtectionRealm/VB/authorization_protectionrealm.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Authorization_ProtectionRealm/VB/authorization_protectionrealm.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/Cookie.xml b/xml/System.Net/Cookie.xml index d130760752c..8cbbd1a0869 100644 --- a/xml/System.Net/Cookie.xml +++ b/xml/System.Net/Cookie.xml @@ -76,7 +76,6 @@ ## Examples The following example sends a request to a URL and displays the cookies returned in the response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet1"::: @@ -520,7 +519,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -601,7 +599,6 @@ ## Examples The following example displays the properties of cookies that are returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -678,7 +675,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -750,7 +746,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -879,7 +874,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -957,7 +951,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1147,7 +1140,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1224,7 +1216,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1296,7 +1287,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1374,7 +1364,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1446,7 +1435,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1513,7 +1501,6 @@ ## Examples The following example displays the string value of a cookie returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet4"::: @@ -1584,7 +1571,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: @@ -1658,7 +1644,6 @@ ## Examples The following example displays the properties of cookies returned in a response. For the complete example, see the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet3"::: diff --git a/xml/System.Net/CookieCollection.xml b/xml/System.Net/CookieCollection.xml index c2db57f5ed1..eb1c1ceae42 100644 --- a/xml/System.Net/CookieCollection.xml +++ b/xml/System.Net/CookieCollection.xml @@ -832,7 +832,6 @@ The comparison for is case-sensitive. ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_2/CPP/CookieCollection_Item_2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CookieCollection/Item/cookiecollection_item_2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CookieCollection_Item_2/VB/cookiecollection_item_2.vb" id="Snippet1"::: @@ -909,7 +908,6 @@ The comparison for is case-sensitive. ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CookieCollection_Item_1/CPP/CookieCollection_Item_1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CookieCollection/Item/cookiecollection_item_1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CookieCollection_Item_1/VB/cookiecollection_item_1.vb" id="Snippet1"::: diff --git a/xml/System.Net/CredentialCache.xml b/xml/System.Net/CredentialCache.xml index 85cc3b1e34b..06ae1e29522 100644 --- a/xml/System.Net/CredentialCache.xml +++ b/xml/System.Net/CredentialCache.xml @@ -81,7 +81,6 @@ ## Examples The following code example initializes a with multiple security credentials and uses those credentials with a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic CredentialCache.Add Example/VB/source.vb" id="Snippet1"::: @@ -138,7 +137,6 @@ ## Examples The following code example initializes a with multiple security credentials and uses those credentials with a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic CredentialCache.Add Example/VB/source.vb" id="Snippet1"::: @@ -213,7 +211,6 @@ ## Examples The following code example initializes a with multiple security credentials and uses those credentials with a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic CredentialCache.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic CredentialCache.Add Example/VB/source.vb" id="Snippet1"::: @@ -289,7 +286,6 @@ ## Examples The following code example initializes a with multiple security credentials for use with SMTP and uses one of those credentials with a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCL_Credential.Cache.Add_SMTP/VB/source.vb" id="Snippet1"::: @@ -363,7 +359,6 @@ ## Examples The following code example uses the property to get the system credentials of the application. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/CPP/credentialcache_defaultcredentials.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/DefaultCredentials/credentialcache_defaultcredentials.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CredentialCache_DefaultCredentials/VB/credentialcache_defaultcredentials.vb" id="Snippet1"::: @@ -500,7 +495,6 @@ ## Examples The following code example uses the method to return the instance associated with the specified URI and authentication type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetCredential/CPP/credentialcache_getcredential.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/GetCredential/credentialcache_getcredential.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CredentialCache_GetCredential/VB/credentialcache_getcredential.vb" id="Snippet1"::: @@ -637,7 +631,6 @@ ## Examples The following code example uses the method to return an enumerator that can iterate through the instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CredentialCache_GetEnumerator/CPP/credentialcache_getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/GetEnumerator/credentialcache_getenumerator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CredentialCache_GetEnumerator/VB/credentialcache_getenumerator.vb" id="Snippet1"::: @@ -713,7 +706,6 @@ ## Examples The following code example uses this method to delete a instance from the cache. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/CredentialCache_Add_Remove/CPP/credentialcache_add_remove.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/CredentialCache/Remove/credentialcache_add_remove.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/CredentialCache_Add_Remove/VB/credentialcache_add_remove.vb" id="Snippet3"::: diff --git a/xml/System.Net/Dns.xml b/xml/System.Net/Dns.xml index 9fd9eb73494..23314b1d64e 100644 --- a/xml/System.Net/Dns.xml +++ b/xml/System.Net/Dns.xml @@ -55,22 +55,21 @@ Provides simple domain name resolution functionality. - class is a static class that retrieves information about a specific host from the Internet Domain Name System (DNS). - - The host information from the DNS query is returned in an instance of the class. If the specified host has more than one entry in the DNS database, contains multiple IP addresses and aliases. - - - -## Examples - The following example queries the DNS database for information on the host `www.contoso.com`. + class is a static class that retrieves information about a specific host from the Internet Domain Name System (DNS). + + The host information from the DNS query is returned in an instance of the class. If the specified host has more than one entry in the DNS database, contains multiple IP addresses and aliases. + + + +## Examples + The following example queries the DNS database for information on the host `www.contoso.com`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Dns Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Dns Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -136,22 +135,22 @@ Asynchronously returns the Internet Protocol (IP) addresses for the specified host. An instance that references the asynchronous request. - method asynchronously queries a DNS server for the IP addresses that are associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. - + method asynchronously queries a DNS server for the IP addresses that are associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + If an empty string is passed as the `hostNameOrAddress` argument, then this method returns the IPv4 and IPv6 addresses of the local host. - - The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. - - This method does not block until the operation is complete. To block until the operation is complete, use the method. - - For more information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously) - + + The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. + + This method does not block until the operation is complete. To block until the operation is complete, use the method. + + For more information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously) + ]]> @@ -238,18 +237,18 @@ Begins an asynchronous request for information about the specified DNS host name. An instance that references the asynchronous request. - operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. - - This method does not block until the operation is complete. To block until the operation is complete, use the method. - - For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - + operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. + + This method does not block until the operation is complete. To block until the operation is complete, use the method. + + For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -329,28 +328,27 @@ Asynchronously resolves an IP address to an instance. An instance that references the asynchronous request. - method asynchronously queries a DNS server for the IP addresses and aliases associated with an IP address. - - **Note** This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. - - This method does not block until the operation is complete. To block until the operation is complete, use the method. - - For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously) - - - -## Examples - The following code example uses the method to resolve an IP address to an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp" id="Snippet2"::: + method asynchronously queries a DNS server for the IP addresses and aliases associated with an IP address. + + **Note** This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. + + This method does not block until the operation is complete. To block until the operation is complete, use the method. + + For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously) + + + +## Examples + The following code example uses the method to resolve an IP address to an instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginGetHostEntry/dnsnewmethods.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet2"::: + ]]> @@ -421,28 +419,27 @@ Asynchronously resolves a host name or IP address to an instance. An instance that references the asynchronous request. - method queries a DNS server for the IP address that is associated with a host name or IP address. - - **Note** This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. - - This method does not block until the operation is complete. To block until the operation is complete, use the method. - - For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - - - -## Examples - The following code example uses the method to resolve an IP address to an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp" id="Snippet2"::: + method queries a DNS server for the IP address that is associated with a host name or IP address. + + **Note** This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. + + This method does not block until the operation is complete. To block until the operation is complete, use the method. + + For detailed information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). + + + +## Examples + The following code example uses the method to resolve an IP address to an instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginGetHostEntry/dnsnewmethods.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet2"::: + ]]> @@ -529,27 +526,26 @@ Begins an asynchronous request to resolve a DNS host name or IP address to an instance. An instance that references the asynchronous request. - operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. - - This method does not block until the operation is complete. To block until the operation is complete, use the method. - - For more information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - + operation must be completed by calling the method. Typically, the method is invoked by the `requestCallback` delegate. + + This method does not block until the operation is complete. To block until the operation is complete, use the method. + + For more information about using the asynchronous programming model, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example uses to resolve a DNS host name to an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example uses to resolve a DNS host name to an . + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginResolve/dns_begin_endresolve.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Begin_EndResolve/VB/dns_begin_endresolve.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Begin_EndResolve/VB/dns_begin_endresolve.vb" id="Snippet1"::: + ]]> @@ -600,16 +596,16 @@ Ends an asynchronous request for DNS information. An array of type that holds the IP addresses for the host specified by the parameter of . - method queries a DNS server for the IP addresses associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. - + method queries a DNS server for the IP addresses associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. + If an empty string is passed as the `hostNameOrAddress` argument, then this method returns the IPv4 and IPv6 addresses of the local host. - + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -671,18 +667,18 @@ Ends an asynchronous request for DNS information. An object that contains DNS information about a host. - method. - - If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. - + method. + + If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -732,18 +728,18 @@ Ends an asynchronous request for DNS information. An instance that contains address information about the host. - property of the instance returned is not populated by this method and will always be empty. - - To perform this operation synchronously, use a method. - + property of the instance returned is not populated by this method and will always be empty. + + To perform this operation synchronously, use a method. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -807,27 +803,26 @@ Ends an asynchronous request for DNS information. An object that contains DNS information about a host. - is set to `true`, the property of the instance returned is not populated by this method and will always be empty. - - To perform this operation synchronously, use the method. - + is set to `true`, the property of the instance returned is not populated by this method and will always be empty. + + To perform this operation synchronously, use the method. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example ends an asynchronous request for DNS host information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_Begin_EndResolve/CPP/dns_begin_endresolve.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example ends an asynchronous request for DNS host information. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginResolve/dns_begin_endresolve.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Begin_EndResolve/VB/dns_begin_endresolve.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Begin_EndResolve/VB/dns_begin_endresolve.vb" id="Snippet1"::: + ]]> @@ -877,29 +872,28 @@ Returns the Internet Protocol (IP) addresses for the specified host. An array of type that holds the IP addresses for the host that is specified by the parameter. - method queries the DNS subsystem for the IP addresses associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. - + If an empty string is passed as the `hostNameOrAddress` argument, then this method returns the IPv4 and IPv6 addresses of the local host. - - IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results were available for the `hostNameOrAddress` parameter. - + + IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results were available for the `hostNameOrAddress` parameter. + This method is implemented using the underlying operating system's name resolution APIs (such as the Win32 API getaddrinfo on Windows, and equivalent APIs on other platforms). If a host is described in the `hosts` file, the IP address or addresses there will be returned without querying the DNS server. > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example uses the method to resolve an IP address to an array of type . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp" id="Snippet3"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example uses the method to resolve an IP address to an array of type . + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginGetHostEntry/dnsnewmethods.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet3"::: + ]]> @@ -986,13 +980,13 @@ Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns an array of type that holds the IP addresses for the host that is specified by the parameter. - object will complete after the `hostNameOrAddress` has been resolved. - - This method queries a DNS server for the IP addresses associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. - + object will complete after the `hostNameOrAddress` has been resolved. + + This method queries a DNS server for the IP addresses associated with a host name. If `hostNameOrAddress` is an IP address, this address is returned without querying the DNS server. + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -1143,22 +1137,21 @@ Creates an instance from the specified . An instance. - [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example creates a from an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/CPP/dns_gethostbyaddress_ipaddress.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example creates a from an . + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/GetHostByAddress/dns_gethostbyaddress_ipaddress.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/VB/dns_gethostbyaddress_ipaddress.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostByAddress_IPAddress/VB/dns_gethostbyaddress_ipaddress.vb" id="Snippet1"::: + ]]> @@ -1223,13 +1216,13 @@ Creates an instance from an IP address. An instance. - [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -1296,27 +1289,26 @@ Gets the DNS information for the specified DNS host name. An object that contains host information for the address specified in . - method queries the Internet DNS server for host information. If you pass an empty string as the host name, this method retrieves the standard host name for the local computer. - - For asynchronous access to DNS information, use the and methods. - - If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. - + method queries the Internet DNS server for host information. If you pass an empty string as the host name, this method retrieves the standard host name for the local computer. + + For asynchronous access to DNS information, use the and methods. + + If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example uses the method to get the DNS information for the specified DNS host name. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostByName/CPP/dns_gethostbyname.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example uses the method to get the DNS information for the specified DNS host name. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/GetHostByName/dns_gethostbyname.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostByName/VB/dns_gethostbyname.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostByName/VB/dns_gethostbyname.vb" id="Snippet1"::: + ]]> @@ -1377,25 +1369,24 @@ Resolves an IP address to an instance. An instance that contains address information about the host specified in . - method queries a DNS server for the IP addresses and aliases associated with an IP address. - - IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results were available for the `address` parameter. - - The property of the instance returned is not populated by this method and will always be empty. - + method queries a DNS server for the IP addresses and aliases associated with an IP address. + + IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results were available for the `address` parameter. + + The property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + +## Examples + The following code example uses the method to resolve an IP address to an instance. -## Examples - The following code example uses the method to resolve an IP address to an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginGetHostEntry/dnsnewmethods.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet4"::: + ]]> @@ -1447,47 +1438,46 @@ Resolves a host name or IP address to an instance. An instance that contains address information about the host specified in . - method queries a DNS server for the IP address that is associated with a host name or IP address. - + method queries a DNS server for the IP address that is associated with a host name or IP address. + If an empty string is passed as the `hostNameOrAddress` argument, then this method returns the IPv4 and IPv6 addresses of the local host. - - If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried. - - The exception is also returned if the `hostNameOrAddress` parameter contains or . - - The method assumes that if an IP literal string is passed in the `hostNameOrAddress` parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of the method exhibits the following behavior when an IP string literal is passed: - -1. The method tries to parse the address. If the `hostNameOrAddress` parameter contains a legal IP string literal, then the first phase succeeds. - -2. A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property. - -3. The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property. - - For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address). - - For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property. - - The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup. - - IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `hostNameOrAddress`.parameter. - - The property of the instance returned is not populated by this method and will always be empty. - + + If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried. + + The exception is also returned if the `hostNameOrAddress` parameter contains or . + + The method assumes that if an IP literal string is passed in the `hostNameOrAddress` parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of the method exhibits the following behavior when an IP string literal is passed: + +1. The method tries to parse the address. If the `hostNameOrAddress` parameter contains a legal IP string literal, then the first phase succeeds. + +2. A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property. + +3. The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property. + + For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address). + + For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property. + + The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup. + + IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `hostNameOrAddress`.parameter. + + The property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example uses the method to resolve an IP address to an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Dns/CPP/dnsnewmethods.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example uses the method to resolve an IP address to an instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/BeginGetHostEntry/dnsnewmethods.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Dns/vb/dnsnewmethods.vb" id="Snippet1"::: + ]]> The parameter is . @@ -1582,20 +1572,20 @@ Resolves an IP address to an instance as an asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns an instance that contains address information about the host specified in . - object will complete after the `address` has been resolved. - - This method queries a DNS server for the IP addresses and aliases associated with an IP address. - - IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `address` parameter. - - The property of the instance returned is not populated by this method and will always be empty. - + object will complete after the `address` has been resolved. + + This method queries a DNS server for the IP addresses and aliases associated with an IP address. + + IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `address` parameter. + + The property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -1649,42 +1639,42 @@ Resolves a host name or IP address to an instance as an asynchronous operation. The task object representing the asynchronous operation. The property on the task object returns an instance that contains address information about the host specified in . - object will complete after the `hostNameOrAddress` has been resolved. - - This method queries a DNS server for the IP address that is associated with a host name or IP address. - + object will complete after the `hostNameOrAddress` has been resolved. + + This method queries a DNS server for the IP address that is associated with a host name or IP address. + If an empty string is passed as the `hostNameOrAddress` argument, then this method returns the IPv4 and IPv6 addresses of the local host. - - If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried. - - The exception is also returned if the `hostNameOrAddress` parameter contains or . - - This method assumes that if an IP literal string is passed in the `hostNameOrAddress` parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of this method exhibits the following behavior when an IP string literal is passed: - -1. The method tries to parse the address. If the `hostNameOrAddress` parameter contains a legal IP string literal, then the first phase succeeds. - -2. A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property. - -3. The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property. - - For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address). - - For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property. - - The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup. - - IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `hostNameOrAddress`.parameter. - - The property of the instance returned is not populated by this method and will always be empty. + + If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried. + + The exception is also returned if the `hostNameOrAddress` parameter contains or . + + This method assumes that if an IP literal string is passed in the `hostNameOrAddress` parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of this method exhibits the following behavior when an IP string literal is passed: + +1. The method tries to parse the address. If the `hostNameOrAddress` parameter contains a legal IP string literal, then the first phase succeeds. + +2. A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property. + +3. The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property. + + For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address). + + For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property. + + The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup. + + IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the `hostNameOrAddress`.parameter. + + The property of the instance returned is not populated by this method and will always be empty. This method is implemented using the underlying operating system's name resolution APIs (such as the Win32 API getaddrinfo on Windows, and equivalent APIs on other platforms). If a host is described in the `hosts` file, the IP address or addresses there will be returned without querying the DNS server. - + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . ]]> @@ -1807,15 +1797,14 @@ Gets the host name of the local computer. A string that contains the DNS host name of the local computer. - method to obtain the host name of the local computer. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_GetHostName/CPP/dns_gethostname.cpp" id="Snippet1"::: + method to obtain the host name of the local computer. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/GetHostName/dns_gethostname.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostName/VB/dns_gethostname.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_GetHostName/VB/dns_gethostname.vb" id="Snippet1"::: + ]]> An error is encountered when resolving the local host name. @@ -1878,27 +1867,26 @@ Resolves a DNS host name or IP address to an instance. An instance that contains address information about the host specified in . - method queries a DNS server for the IP address associated with a host name or IP address. - - When `hostName` is a DNS-style host name associated with multiple IP addresses, only the first IP address that resolves to that host name is returned. - - If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. - + method queries a DNS server for the IP address associated with a host name or IP address. + + When `hostName` is a DNS-style host name associated with multiple IP addresses, only the first IP address that resolves to that host name is returned. + + If the property is set to `true`, the property of the instance returned is not populated by this method and will always be empty. + > [!NOTE] -> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following example uses the method to resolve an IP address to an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Dns_Resolve/CPP/dns_resolve.cpp" id="Snippet1"::: +> This member emits trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following example uses the method to resolve an IP address to an instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/Resolve/dns_resolve.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Resolve/VB/dns_resolve.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Dns_Resolve/VB/dns_resolve.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/DnsPermission.xml b/xml/System.Net/DnsPermission.xml index d7654dc6714..ee8d1019c87 100644 --- a/xml/System.Net/DnsPermission.xml +++ b/xml/System.Net/DnsPermission.xml @@ -48,14 +48,14 @@ Controls rights to access Domain Name System (DNS) servers on the network. - @@ -93,20 +93,19 @@ One of the values. Creates a new instance of the class that either allows unrestricted DNS access or disallows DNS access. - , the instance passes all demands. If `state` contains any other value, the instance fails all demands. - - - -## Examples - The following example creates an instance of the class. + , the instance passes all demands. If `state` contains any other value, the instance fails all demands. + + + +## Examples + The following example creates an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: + ]]> @@ -146,20 +145,19 @@ Creates an identical copy of the current permission instance. A new instance of the class that is an identical copy of the current instance. - instance provides the same access to DNS servers as the original permission instance. - - - -## Examples - The following example creates an identical copy of an existing instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Copy/CPP/dnspermission_copy.cpp" id="Snippet1"::: + instance provides the same access to DNS servers as the original permission instance. + + + +## Examples + The following example creates an identical copy of an existing instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Copy/dnspermission_copy.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Copy/VB/dnspermission_copy.vb" id="Snippet1"::: + ]]> @@ -199,22 +197,21 @@ The XML encoding to use to reconstruct the instance. Reconstructs a instance from an XML encoding. - method reconstructs a instance from an XML encoding defined by the class. - - Use the method to XML-encode the instance, including state information. - - - -## Examples - The following example reconstructs a instance from an XML encoding. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_FromXml/CPP/dnspermission_fromxml.cpp" id="Snippet1"::: + method reconstructs a instance from an XML encoding defined by the class. + + Use the method to XML-encode the instance, including state information. + + + +## Examples + The following example reconstructs a instance from an XML encoding. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/FromXml/dnspermission_fromxml.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_FromXml/VB/dnspermission_fromxml.vb" id="Snippet1"::: + ]]> @@ -260,20 +257,19 @@ Creates a permission instance that is the intersection of the current permission instance and the specified permission instance. A instance that represents the intersection of the current instance with the specified instance, or if the intersection is empty. If both the current instance and are unrestricted, this method returns a new instance that is unrestricted; otherwise, it returns . - method returns a instance that allows the access defined by both the current instance and the specified instance. Any demand must pass both permissions to pass their intersection. - - - -## Examples - The following example creates a permission instance that is the intersection of the current permission instance and the specified permission instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp" id="Snippet2"::: + method returns a instance that allows the access defined by both the current instance and the specified instance. Any demand must pass both permissions to pass their intersection. + + + +## Examples + The following example creates a permission instance that is the intersection of the current permission instance and the specified permission instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet2"::: + ]]> @@ -317,22 +313,21 @@ if the current instance is unrestricted and is either or unrestricted; otherwise, . - instance is a subset of the specified instance if the current instance specifies a set of operations that is wholly contained by the specified instance. - - If the method returns `true`, the current instance allows no more access to DNS servers than does the specified instance. - - - -## Examples - The following example uses the method to determine whether the current permission instance is a subset of the specified permission instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/CPP/dnspermission_issubsetof.cpp" id="Snippet1"::: + instance is a subset of the specified instance if the current instance specifies a set of operations that is wholly contained by the specified instance. + + If the method returns `true`, the current instance allows no more access to DNS servers than does the specified instance. + + + +## Examples + The following example uses the method to determine whether the current permission instance is a subset of the specified permission instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/IsSubsetOf/dnspermission_issubsetof.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsSubsetOf/VB/dnspermission_issubsetof.vb" id="Snippet1"::: + ]]> @@ -376,15 +371,14 @@ if the instance was created with ; otherwise, . - method to check the overall permission state of the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/CPP/dnspermission_isunrestricted.cpp" id="Snippet1"::: + method to check the overall permission state of the object. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/IsUnrestricted/dnspermission_isunrestricted.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_IsUnrestricted/VB/dnspermission_isunrestricted.vb" id="Snippet1"::: + ]]> @@ -422,22 +416,21 @@ Creates an XML encoding of a instance and its current state. A instance that contains an XML-encoded representation of the security object, including state information. - method creates a instance to XML-encode a representation of the instance, including state information. - - Use the method to restore the state information from a instance. - - - -## Examples - The following example creates an XML encoding of a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/DnsPermission_Constructor/CPP/dnspermission_constructor.cpp" id="Snippet1"::: + method creates a instance to XML-encode a representation of the instance, including state information. + + Use the method to restore the state information from a instance. + + + +## Examples + The following example creates an XML encoding of a instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/.ctor/dnspermission_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/DnsPermission_Constructor/VB/dnspermission_constructor.vb" id="Snippet1"::: + ]]> @@ -478,20 +471,19 @@ Creates a permission instance that is the union of the current permission instance and the specified permission instance. A instance that represents the union of the current instance with the specified instance. If is , this method returns a copy of the current instance. If the current instance or is unrestricted, this method returns a instance that is unrestricted; otherwise, it returns a instance that is restricted. - method returns a instance that allows the access defined by either the current instance or the specified instance. Any demand that passes either permission passes their union. - - - -## Examples - The following example creates a permission instance that is the union of the current permission instance and the specified permission instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/dnspermission_union_intersect/CPP/dnspermission_union_intersect.cpp" id="Snippet1"::: + method returns a instance that allows the access defined by either the current instance or the specified instance. Any demand that passes either permission passes their union. + + + +## Examples + The following example creates a permission instance that is the union of the current permission instance and the specified permission instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/DnsPermission/Intersect/dnspermission_union_intersect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/dnspermission_union_intersect/VB/dnspermission_union_intersect.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/DownloadDataCompletedEventArgs.xml b/xml/System.Net/DownloadDataCompletedEventArgs.xml index 40ee166e858..3230f68c07d 100644 --- a/xml/System.Net/DownloadDataCompletedEventArgs.xml +++ b/xml/System.Net/DownloadDataCompletedEventArgs.xml @@ -49,26 +49,24 @@ Provides data for the event. - . + + + +## Examples + The following code example demonstrates downloading a user-specified resource. -## Remarks - Instances of this class are passed to the . - - - -## Examples - The following code example demonstrates downloading a user-specified resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet21"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet21"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet22"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet21"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet22"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: + ]]> @@ -111,20 +109,19 @@ Gets the data that is downloaded by a method. A array that contains the downloaded data. - and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet22"::: + and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet22"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: + ]]> diff --git a/xml/System.Net/DownloadDataCompletedEventHandler.xml b/xml/System.Net/DownloadDataCompletedEventHandler.xml index 60c41089185..9df0fede7ba 100644 --- a/xml/System.Net/DownloadDataCompletedEventHandler.xml +++ b/xml/System.Net/DownloadDataCompletedEventHandler.xml @@ -51,26 +51,24 @@ A containing event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates downloading a user-specified resource. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates downloading a user-specified resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet21"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet21"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet22"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet21"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet22"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet22"::: + ]]> diff --git a/xml/System.Net/DownloadProgressChangedEventArgs.xml b/xml/System.Net/DownloadProgressChangedEventArgs.xml index 16e6ceb3439..ea50d6d0216 100644 --- a/xml/System.Net/DownloadProgressChangedEventArgs.xml +++ b/xml/System.Net/DownloadProgressChangedEventArgs.xml @@ -57,7 +57,6 @@ Instances of this class are passed to the event. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="SnippetDownloadProgressChanged"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="SnippetDownloadProgressChanged"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="SnippetDownloadProgressChanged"::: @@ -120,7 +119,6 @@ The following code example demonstrates setting an event handler for the event. The method displays the value of the `BytesReceived` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet42"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet42"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet42"::: @@ -185,7 +183,6 @@ The following code example demonstrates setting an event handler for the event. The method displays the value of the `TotalBytesToReceive` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet42"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet42"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet42"::: diff --git a/xml/System.Net/DownloadProgressChangedEventHandler.xml b/xml/System.Net/DownloadProgressChangedEventHandler.xml index aee25613f99..756d4949fed 100644 --- a/xml/System.Net/DownloadProgressChangedEventHandler.xml +++ b/xml/System.Net/DownloadProgressChangedEventHandler.xml @@ -67,7 +67,6 @@ The following code example demonstrates setting an event handler for the event. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="SnippetDownloadProgressChanged"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="SnippetDownloadProgressChanged"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="SnippetDownloadProgressChanged"::: diff --git a/xml/System.Net/DownloadStringCompletedEventArgs.xml b/xml/System.Net/DownloadStringCompletedEventArgs.xml index 01e443135b4..168208e46fc 100644 --- a/xml/System.Net/DownloadStringCompletedEventArgs.xml +++ b/xml/System.Net/DownloadStringCompletedEventArgs.xml @@ -53,26 +53,24 @@ Provides data for the event. - . + + + +## Examples + The following code example demonstrates downloading a string asynchronously. -## Remarks - Instances of this class are passed to the . - - - -## Examples - The following code example demonstrates downloading a string asynchronously. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet28"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet28"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet28"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet29"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet28"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet29"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: + ]]> @@ -118,20 +116,19 @@ Gets the data that is downloaded by a method. A that contains the downloaded data. - and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet29"::: + and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet29"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: + ]]> diff --git a/xml/System.Net/DownloadStringCompletedEventHandler.xml b/xml/System.Net/DownloadStringCompletedEventHandler.xml index 6d3da8adef3..3a7542bb799 100644 --- a/xml/System.Net/DownloadStringCompletedEventHandler.xml +++ b/xml/System.Net/DownloadStringCompletedEventHandler.xml @@ -55,26 +55,24 @@ A that contains event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates downloading a string asynchronously. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates downloading a string asynchronously. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet28"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet28"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet28"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet29"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet28"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet29"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet29"::: + ]]> diff --git a/xml/System.Net/FileWebRequest.xml b/xml/System.Net/FileWebRequest.xml index 3090fb2f311..83fde77cc61 100644 --- a/xml/System.Net/FileWebRequest.xml +++ b/xml/System.Net/FileWebRequest.xml @@ -62,28 +62,27 @@ Provides a file system implementation of the class. - class implements the `abstract` base class for Uniform Resource Identifiers (URIs) that use the `file://` scheme to request local files. - - Do not use the constructor. Use the method to initialize new instances of the class. If the URI scheme is `file://`, the method returns a object. - - The method makes a synchronous request for the file specified in the property and returns a object that contains the response. You can make an asynchronous request for the file using the and methods. - - When you want to write data to a file, the method returns a instance to write to. The and methods provide asynchronous access to the write data stream. - - The class relies on the class for error handling and code access security. - - - -## Examples - The following code example uses the class to access a file system resource. + class implements the `abstract` base class for Uniform Resource Identifiers (URIs) that use the `file://` scheme to request local files. + + Do not use the constructor. Use the method to initialize new instances of the class. If the URI scheme is `file://`, the method returns a object. + + The method makes a synchronous request for the file specified in the property and returns a object that contains the response. You can make an asynchronous request for the file using the and methods. + + When you want to write data to a file, the method returns a instance to write to. The and methods provide asynchronous access to the write data stream. + + The class relies on the class for error handling and code access security. + + + +## Examples + The following code example uses the class to access a file system resource. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/Overview/getrequeststream.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet1"::: + ]]> @@ -148,11 +147,11 @@ A object that contains the source of the serialized stream that is associated with the new object. Initializes a new instance of the class from the specified instances of the and classes. - interface for the class. - + interface for the class. + ]]> XML and SOAP Serialization @@ -196,13 +195,13 @@ Cancels a request to an Internet resource. - method cancels a request to a resource. After a request is canceled, calling the , , , , , or method causes a with the property set to . - - **Note** This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - + method cancels a request to a resource. After a request is canceled, calling the , , , , , or method causes a with the property set to . + + **Note** This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + ]]> @@ -259,20 +258,19 @@ Begins an asynchronous request for a object to use to write data. An that references the asynchronous request. - method starts an asynchronous request for a stream used to send data to a file system resource. The callback method that implements the delegate uses the method to return the request stream. - - - -## Examples - The following code example uses to make an asynchronous request for a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp" id="Snippet2"::: + method starts an asynchronous request for a stream used to send data to a file system resource. The callback method that implements the delegate uses the method to return the request stream. + + + +## Examples + The following code example uses to make an asynchronous request for a object. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/BeginGetRequestStream/filewebrequest_reqbeginend.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/VB/filewebrequest_reqbeginend.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/VB/filewebrequest_reqbeginend.vb" id="Snippet2"::: + ]]> The property is GET and the application writes to the stream. @@ -336,20 +334,19 @@ Begins an asynchronous request for a file system resource. An that references the asynchronous request. - delegate uses the method to return the actual . - - - -## Examples - The following code example uses the method to asynchronously access a file system resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp" id="Snippet2"::: + delegate uses the method to return the actual . + + + +## Examples + The following code example uses the method to asynchronously access a file system resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/BeginGetResponse/filewebrequest_resbeginend.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/VB/filewebrequest_resbeginend.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/VB/filewebrequest_resbeginend.vb" id="Snippet2"::: + ]]> The stream is already in use by a previous call to . @@ -413,11 +410,11 @@ Gets or sets the name of the connection group for the request. This property is reserved for future use. The name of the connection group for the request. - property is currently not used by the class. - + property is currently not used by the class. + ]]> @@ -467,15 +464,14 @@ Gets or sets the content length of the data being sent. The number of bytes of request data being sent. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp" id="Snippet4"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/Overview/getrequeststream.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet4"::: + ]]> @@ -528,11 +524,11 @@ Gets or sets the content type of the data being sent. This property is reserved for future use. The content type of the data being sent. - property contains the media type of the data being sent. This is typically the MIME encoding of the content. The property is currently not used by the class. - + property contains the media type of the data being sent. This is typically the MIME encoding of the content. The property is currently not used by the class. + ]]> @@ -591,11 +587,11 @@ Gets or sets the credentials that are associated with this request. This property is reserved for future use. An that contains the authentication credentials that are associated with this request. The default is . - class does not authenticate requests for files from the local file system, it ignores the contents, if any, of the property. Authentication for is handled by the access control lists for the file resource in the underlying file system. - + class does not authenticate requests for files from the local file system, it ignores the contents, if any, of the property. Authentication for is handled by the access control lists for the file resource in the underlying file system. + ]]> @@ -643,23 +639,22 @@ Ends an asynchronous request for a instance that the application uses to write data. A object that the application uses to write data. - method completes an asynchronous stream request that was started by the method. - + method completes an asynchronous stream request that was started by the method. + > [!NOTE] -> To avoid timing issues with garbage collection, be sure to close the response stream by calling the method on the stream returned by the method after calling the method. - - - -## Examples - The following example uses the method to end the asynchronous request for a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/CPP/filewebrequest_reqbeginend.cpp" id="Snippet2"::: +> To avoid timing issues with garbage collection, be sure to close the response stream by calling the method on the stream returned by the method after calling the method. + + + +## Examples + The following example uses the method to end the asynchronous request for a object. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/BeginGetRequestStream/filewebrequest_reqbeginend.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/VB/filewebrequest_reqbeginend.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ReqBeginEnd/VB/filewebrequest_reqbeginend.vb" id="Snippet2"::: + ]]> @@ -712,20 +707,19 @@ Ends an asynchronous request for a file system resource. A that contains the response from the file system resource. - method completes an asynchronous request for a file system resource that was started with the method. - - - -## Examples - The following code example uses the method to end an asynchronous request for a file system resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/CPP/filewebrequest_resbeginend.cpp" id="Snippet2"::: + method completes an asynchronous request for a file system resource that was started with the method. + + + +## Examples + The following code example uses the method to end an asynchronous request for a file system resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/BeginGetResponse/filewebrequest_resbeginend.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/VB/filewebrequest_resbeginend.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ResBeginEnd/VB/filewebrequest_resbeginend.vb" id="Snippet2"::: + ]]> @@ -784,11 +778,11 @@ A that specifies the destination for this serialization. Populates a with the data needed to serialize the target object. - are automatically tracked and serialized by the formatter. - + are automatically tracked and serialized by the formatter. + ]]> @@ -833,20 +827,19 @@ Returns a object for writing data to the file system resource. A for writing data to the file system resource. - method provides synchronous access to the . For asynchronous access, use the and methods. - - - -## Examples - The following code example uses the method to obtain a stream instance used to write to the file. Refer to the complete example in the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp" id="Snippet5"::: + method provides synchronous access to the . For asynchronous access, use the and methods. + + + +## Examples + The following code example uses the method to obtain a stream instance used to write to the file. Refer to the complete example in the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/Overview/getrequeststream.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet5"::: + ]]> The request times out. @@ -884,9 +877,9 @@ Returns a stream for writing data to the file system resource as an asynchronous operation. The task object representing the asynchronous operation. - [!NOTE] > In the case of asynchronous requests, the client application is responsible for implementing its own time-out mechanism. @@ -944,22 +937,21 @@ The stream already received a response previous to your request. Returns a response to a file system request. A that contains the response from the file system resource. - method returns a object that contains the response from the file system resource. - - The method provides synchronous access to the . For asynchronous access, use the and methods. - - - -## Examples - The following code example uses the method to return a file system request response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/CPP/getresponse.cpp" id="Snippet1"::: + method returns a object that contains the response from the file system resource. + + The method provides synchronous access to the . For asynchronous access, use the and methods. + + + +## Examples + The following code example uses the method to return a file system request response. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/GetResponse/getresponse.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/VB/getresponse.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest.GetResponse/VB/getresponse.vb" id="Snippet1"::: + ]]> The request timed out. @@ -996,9 +988,9 @@ The stream already received a response previous to your request. Returns a response to a file system request as an asynchronous operation. The task object representing the asynchronous operation. - [!NOTE] > In the case of asynchronous requests, the client application is responsible for implementing its own time-out mechanism. @@ -1056,11 +1048,11 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets a collection of the name/value pairs that are associated with the request. This property is reserved for future use. A that contains header name/value pairs associated with this request. - property is currently not used by the class. - + property is currently not used by the class. + ]]> @@ -1110,30 +1102,29 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the protocol method used for the request. This property is reserved for future use. The protocol method to use in this request. - property is currently not used by the class. - - - -## Examples - The following code example sets the protocol method used for the request. Refer to the complete example in the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp" id="Snippet2"::: + property is currently not used by the class. + + + +## Examples + The following code example sets the protocol method used for the request. Refer to the complete example in the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/Overview/getrequeststream.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet2"::: + ]]> - The method is invalid. - + The method is invalid. + -or- - - The method is not supported. - + + The method is not supported. + -or- - + Multiple methods were specified. @@ -1183,11 +1174,11 @@ This method stores in the task it returns all non-usage exceptions that the meth to preauthenticate; otherwise, . - property is currently not used by the class. - + property is currently not used by the class. + ]]> @@ -1246,11 +1237,11 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the network proxy to use for this request. This property is reserved for future use. An that indicates the network proxy to use for this request. - property is currently not used by the class. - + property is currently not used by the class. + ]]> @@ -1300,15 +1291,14 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets the Uniform Resource Identifier (URI) of the request. A that contains the URI of the request. - property to get the URI of the request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebRequest_ContentLength/CPP/filewebrequest_contentlength.cpp" id="Snippet2"::: + property to get the URI of the request. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/RequestUri/filewebrequest_contentlength.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ContentLength/VB/filewebrequest_contentlength.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebRequest_ContentLength/VB/filewebrequest_contentlength.vb" id="Snippet2"::: + ]]> @@ -1413,20 +1403,19 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the length of time until the request times out. The time, in milliseconds, until the request times out, or the value to indicate that the request does not time out. - to a value less than 15 seconds, it may take 15 seconds or more before a is thrown to indicate a time-out on your request. - - - -## Examples - The following code example sets the property. Refer to the complete example in the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.FileWebRequest/CPP/getrequeststream.cpp" id="Snippet3"::: + to a value less than 15 seconds, it may take 15 seconds or more before a is thrown to indicate a time-out on your request. + + + +## Examples + The following code example sets the property. Refer to the complete example in the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebRequest/Overview/getrequeststream.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.FileWebRequest/VB/getrequeststream.vb" id="Snippet3"::: + ]]> The value specified is less than or equal to zero and is not . @@ -1470,11 +1459,11 @@ This method stores in the task it returns all non-usage exceptions that the meth Always throws a . Always throws a . - property is provided only for compatibility with other implementations of the and classes. There is no reason to use . - + property is provided only for compatibility with other implementations of the and classes. There is no reason to use . + ]]> Default credentials are not supported for file Uniform Resource Identifiers (URIs). diff --git a/xml/System.Net/FileWebResponse.xml b/xml/System.Net/FileWebResponse.xml index b4788f653e9..8516fdf3500 100644 --- a/xml/System.Net/FileWebResponse.xml +++ b/xml/System.Net/FileWebResponse.xml @@ -70,17 +70,17 @@ Provides a file system implementation of the class. - class implements the `abstract` base class to return file system resources for the class. - - Client applications do not create instances directly; instead, they are created by calling the method on a instance. - - The method returns a instance that provides read-only access to a file system resource. - - The class relies on the class for error handling and code access security. - + class implements the `abstract` base class to return file system resources for the class. + + Client applications do not create instances directly; instead, they are created by calling the method on a instance. + + The method returns a instance that provides read-only access to a file system resource. + + The class relies on the class for error handling and code access security. + ]]> @@ -144,11 +144,11 @@ An instance of the class that contains the source of the serialized stream associated with the new instance. Initializes a new instance of the class from the specified instances of the and classes. - interface for the class. - + interface for the class. + ]]> XML and SOAP Serialization @@ -193,23 +193,22 @@ Closes the response stream. - method cleans up the resources used by a and closes the response stream by calling the method. - + method cleans up the resources used by a and closes the response stream by calling the method. + > [!NOTE] -> The response stream must be closed to avoid running out of system resources. You can closes the response stream by calling either or - - - -## Examples - The following example uses the method to close the response stream. +> The response stream must be closed to avoid running out of system resources. You can closes the response stream by calling either or + + + +## Examples + The following example uses the method to close the response stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Close/CPP/filewebresponse_close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/Close/filewebresponse_close.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_Close/VB/filewebresponse_close.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_Close/VB/filewebresponse_close.vb" id="Snippet1"::: + ]]> @@ -253,20 +252,19 @@ Gets the length of the content in the file system resource. The number of bytes returned from the file system resource. - property contains the length, in bytes, of the file system resource. - - - -## Examples - The following example uses the property to obtain the content length of the file system resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp" id="Snippet1"::: + property contains the length, in bytes, of the file system resource. + + + +## Examples + The following example uses the property to obtain the content length of the file system resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/ContentLength/filewebresponse_contentlength_contenttype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/VB/filewebresponse_contentlength_contenttype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/VB/filewebresponse_contentlength_contenttype.vb" id="Snippet1"::: + ]]> @@ -310,20 +308,19 @@ Gets the content type of the file system resource. The value "binary/octet-stream". - property contains the content type of the file system resource. The value of is always "binary/octet-stream". - - - -## Examples - The following example uses the property to obtain the content type of the file system resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/CPP/filewebresponse_contentlength_contenttype.cpp" id="Snippet1"::: + property contains the content type of the file system resource. The value of is always "binary/octet-stream". + + + +## Examples + The following example uses the property to obtain the content type of the file system resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/ContentLength/filewebresponse_contentlength_contenttype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/VB/filewebresponse_contentlength_contenttype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ContentLength_ContentType/VB/filewebresponse_contentlength_contenttype.vb" id="Snippet1"::: + ]]> @@ -408,11 +405,11 @@ A that specifies the destination for this serialization. Populates a with the data needed to serialize the target object. - are automatically tracked and serialized by the formatter. - + are automatically tracked and serialized by the formatter. + ]]> @@ -457,23 +454,22 @@ Returns the data stream from the file system resource. A for reading data from the file system resource. - method returns the data stream from the file system resource. - + method returns the data stream from the file system resource. + > [!NOTE] -> The response stream must be closed to avoid running out of system resources. The response stream can be closed by calling or - - - -## Examples - The following example uses the method to return the data stream from the file system resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/CPP/filewebresponse_getresponsestream.cpp" id="Snippet1"::: +> The response stream must be closed to avoid running out of system resources. The response stream can be closed by calling or + + + +## Examples + The following example uses the method to return the data stream from the file system resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/GetResponseStream/filewebresponse_getresponsestream.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/VB/filewebresponse_getresponsestream.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_GetResponseStream/VB/filewebresponse_getresponsestream.vb" id="Snippet1"::: + ]]> @@ -517,20 +513,19 @@ Gets a collection of header name/value pairs associated with the response. A that contains the header name/value pairs associated with the response. - property contains two name/value pairs, one for content length and one for content type, both of which are also exposed as properties, and . - - - -## Examples - The following example uses the property to retrieve the name/value pairs associated with the response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_Headers/CPP/filewebresponse_headers.cpp" id="Snippet1"::: + property contains two name/value pairs, one for content length and one for content type, both of which are also exposed as properties, and . + + + +## Examples + The following example uses the property to retrieve the name/value pairs associated with the response. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/Headers/filewebresponse_headers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_Headers/VB/filewebresponse_headers.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_Headers/VB/filewebresponse_headers.vb" id="Snippet1"::: + ]]> @@ -574,20 +569,19 @@ Gets the URI of the file system resource that provided the response. A that contains the URI of the file system resource that provided the response. - property contains the URI of the file system resource that provided the response. This is always the file system resource that was requested. - - - -## Examples - The following example uses the to retrieve the URI of the file system resource that provided the response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/FileWebResponse_ResponseUri/CPP/filewebresponse_responseuri.cpp" id="Snippet1"::: + property contains the URI of the file system resource that provided the response. This is always the file system resource that was requested. + + + +## Examples + The following example uses the to retrieve the URI of the file system resource that provided the response. + :::code language="csharp" source="~/snippets/csharp/System.Net/FileWebResponse/ResponseUri/filewebresponse_responseuri.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ResponseUri/VB/filewebresponse_responseuri.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/FileWebResponse_ResponseUri/VB/filewebresponse_responseuri.vb" id="Snippet1"::: + ]]> @@ -630,11 +624,11 @@ if the property is supported by the instance; otherwise, . - @@ -669,12 +663,12 @@ . The Dispose() method leaves the in an unusable state. After calling Dispose(), you must release all references to the so the garbage collector can reclaim the memory that the was occupying. For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). > [!NOTE] -> Always call Dispose() before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. +> Always call Dispose() before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. ]]> diff --git a/xml/System.Net/FtpStatusCode.xml b/xml/System.Net/FtpStatusCode.xml index 92ea938b1c3..a379405d94e 100644 --- a/xml/System.Net/FtpStatusCode.xml +++ b/xml/System.Net/FtpStatusCode.xml @@ -42,21 +42,20 @@ Specifies the status codes returned for a File Transfer Protocol (FTP) operation. - enumeration defines the values returned in the property. - - For additional information about FTP server status codes, see [RFC 959: "File Transfer Protocol", Section 4.2: "FTP Replies"](https://www.ietf.org/rfc/rfc959.txt). - - - -## Examples - The following code example sends an FTP request to make a new directory on an FTP server and checks the status code returned in the response. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet22"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet22"::: + enumeration defines the values returned in the property. + + For additional information about FTP server status codes, see [RFC 959: "File Transfer Protocol", Section 4.2: "FTP Replies"](https://www.ietf.org/rfc/rfc959.txt). + + + +## Examples + The following code example sends an FTP request to make a new directory on an FTP server and checks the status code returned in the response. + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet22"::: + ]]> diff --git a/xml/System.Net/FtpWebRequest.xml b/xml/System.Net/FtpWebRequest.xml index fea37dafdc1..66294ced204 100644 --- a/xml/System.Net/FtpWebRequest.xml +++ b/xml/System.Net/FtpWebRequest.xml @@ -90,17 +90,14 @@ ## Examples The following code example demonstrates deleting a file from an FTP server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: The following code example demonstrates downloading a file from an FTP server by using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet5"::: The following code example demonstrates using asynchronous operations to upload a file to an FTP server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpWebRequest/Overview/async.cs" id="Snippet1"::: ]]> @@ -164,7 +161,6 @@ ## Examples The following code example demonstrates how the user can terminate an asynchronous upload of a file from the local directory to the server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet10"::: ]]> @@ -245,7 +241,6 @@ ## Examples The following code example demonstrates beginning an asynchronous operation to get a request's stream. This code example is part of a larger example provided for the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpWebRequest/Overview/async.cs" id="Snippet4"::: ]]> @@ -336,7 +331,6 @@ ## Examples The following code example demonstrates ending an asynchronous operation to get a request's stream, and then starting a request to get the response. This code example is part of a larger example provided for the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpWebRequest/Overview/async.cs" id="Snippet5"::: ]]> @@ -476,7 +470,6 @@ ## Examples The following code example retrieves the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet16"::: ]]> @@ -606,7 +599,6 @@ ## Examples The following code example demonstrates downloading part of a file from a server and appending the downloaded data to a local file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet7"::: ]]> @@ -730,7 +722,6 @@ ## Examples The following code example retrieves the value of this property and uses it to display the user name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet14"::: ]]> @@ -869,7 +860,6 @@ ## Examples The following code example uses an encrypted connection to download the directory listing from an FTP server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet8"::: ]]> @@ -940,7 +930,6 @@ ## Examples The following code example demonstrates ending an asynchronous operation to get a request's stream. This code example is part of a larger example provided for the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpWebRequest/Overview/async.cs" id="Snippet5"::: ]]> @@ -1015,7 +1004,6 @@ ## Examples The following code example demonstrates ending an asynchronous operation to get a response. This code example is part of a larger example provided for the class overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpAsync/CPP/async.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpWebRequest/Overview/async.cs" id="Snippet6"::: ]]> @@ -1094,7 +1082,6 @@ ## Examples The following code example demonstrates copying a file to a request's data stream and sending a request to the server to upload the data and append it to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet3"::: ]]> @@ -1178,7 +1165,6 @@ ## Examples The following code example demonstrates copying a file to a request's data stream and sending a request to append data to a file to the server. The example calls to send the request and block until the response is returned by the server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet3"::: ]]> @@ -1316,7 +1302,6 @@ ## Examples The following code example retrieves and displays property values for a specified object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet15"::: ]]> @@ -1390,7 +1375,6 @@ ## Examples The following code example sets this property to . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: ]]> @@ -1511,7 +1495,6 @@ For more information about this API, see [Supplemental API remarks for System.Ne @@ -1693,7 +1676,6 @@ The following code example displays this property value. ## Examples The following code example displays this property value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet14"::: ]]> @@ -1760,7 +1742,6 @@ The following code example displays this property value. ## Examples The following code example retrieves the service point from a request and sets the maximum number of connections to one. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet1"::: ]]> @@ -1833,7 +1814,6 @@ The following code example displays this property value. ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet23"::: ]]> @@ -1905,7 +1885,6 @@ The following code example displays this property value. ## Examples The following code example retrieves and displays property values for a specified object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet15"::: ]]> @@ -2028,7 +2007,6 @@ The following code example displays this property value. ## Examples The following code example retrieves and displays property values for a specified object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet6"::: ]]> diff --git a/xml/System.Net/FtpWebResponse.xml b/xml/System.Net/FtpWebResponse.xml index eaa5486c285..229bbdcc094 100644 --- a/xml/System.Net/FtpWebResponse.xml +++ b/xml/System.Net/FtpWebResponse.xml @@ -56,23 +56,22 @@ Encapsulates a File Transfer Protocol (FTP) server's response to a request. - are obtained by calling the method. The returned object must be cast to an . When your application no longer needs the object, call the method to free the resources held by the . - - The property contains the status code returned by the server, and the property returns the status code and a message that describes the status. The values returned by these properties change as the messages are returned by the server. - - Any data returned by the request, such as the list of file names returned for a request, is available in the stream returned by the method. The length of the stream data can be obtained from the property. - - - -## Examples - The following code example sends a request to delete a file on an FTP server and displays the status message from the server's response to the request. For additional examples, see the members of the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: + are obtained by calling the method. The returned object must be cast to an . When your application no longer needs the object, call the method to free the resources held by the . + + The property contains the status code returned by the server, and the property returns the status code and a message that describes the status. The values returned by these properties change as the messages are returned by the server. + + Any data returned by the request, such as the list of file names returned for a request, is available in the stream returned by the method. The length of the stream data can be obtained from the property. + + + +## Examples + The following code example sends a request to delete a file on an FTP server and displays the status message from the server's response to the request. For additional examples, see the members of the and classes. + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: + ]]> @@ -128,14 +127,13 @@ Gets the message sent by the FTP server when a connection is established prior to logon. A that contains the banner message sent by the server; otherwise, if no message is sent. - @@ -184,22 +182,21 @@ Frees the resources held by the response. - method closes the data stream returned by the method if the property is `false`. During the close, data might be sent to the server on the control connection. - + method closes the data stream returned by the method if the property is `false`. During the close, data might be sent to the server on the control connection. + > [!NOTE] -> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). - - - -## Examples - The following code example downloads data from a server, reads the data from the response stream, and then closes it. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: - +> This member outputs trace information when you enable network tracing in your application. For more information, see [Network Tracing in the .NET Framework](/dotnet/framework/network-programming/network-tracing). + + + +## Examples + The following code example downloads data from a server, reads the data from the response stream, and then closes it. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: + ]]> @@ -248,21 +245,20 @@ Gets the length of the data received from the FTP server. An value that contains the number of bytes of data received from the FTP server. - property contains the number of bytes in the stream. returns −1 if no data was returned in the response or if the server did not send content length information. The return value is greater than or equal to zero if data was or should have been returned. For example, for requests that use the field, the property always returns −1. For requests that use the method, the property is always zero. For requests that use the method, the property is greater than zero if the downloaded file contained data and is zero if it was empty. - - For requests that use the method, returns the size of the specified file on the server. - - - -## Examples - The following code example downloads a file from on the specified FTP server. This property contains the number of bytes in the downloaded file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: - + property contains the number of bytes in the stream. returns −1 if no data was returned in the response or if the server did not send content length information. The return value is greater than or equal to zero if data was or should have been returned. For example, for requests that use the field, the property always returns −1. For requests that use the method, the property is always zero. For requests that use the method, the property is greater than zero if the downloaded file contained data and is zero if it was empty. + + For requests that use the method, returns the size of the specified file on the server. + + + +## Examples + The following code example downloads a file from on the specified FTP server. This property contains the number of bytes in the downloaded file. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: + ]]> @@ -301,12 +297,12 @@ Throws a in all cases. Throws a in all cases. - and classes. - + ]]> In all cases. @@ -357,19 +353,18 @@ This property is provided only for compatibility with other implementations of t Gets the message sent by the server when the FTP session is ending. A that contains the exit message sent by the server; otherwise, if no message is sent. - property is not available until the connection to the server is closed or reused. If the property is `true`, the connection used by this request is not closed, which prevents the server from sending an exit message. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet17"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet17"::: - + property is not available until the connection to the server is closed or reused. If the property is `true`, the connection used by this request is not closed, which prevents the server from sending an exit message. + + + +## Examples + The following code example displays the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet17"::: + ]]> @@ -421,21 +416,20 @@ This property is provided only for compatibility with other implementations of t Retrieves the stream that contains response data sent from an FTP server. A readable instance that contains data returned with the response; otherwise, if no response data was returned by the server. - object that contains it. - - An exception is thrown unless the request method is or . - - - -## Examples - The following code example demonstrates getting the response stream for a request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet1"::: - + object that contains it. + + An exception is thrown unless the request method is or . + + + +## Examples + The following code example demonstrates getting the response stream for a request. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet1"::: + ]]> The response did not return a data stream. @@ -492,11 +486,11 @@ This property is provided only for compatibility with other implementations of t Gets an empty object. An empty object. - property is provided only for compatibility with other implementations of the and classes. - + property is provided only for compatibility with other implementations of the and classes. + ]]> @@ -545,19 +539,18 @@ This property is provided only for compatibility with other implementations of t Gets the date and time that a file on an FTP server was last modified. A that contains the last modified date and time for a file. - property returns the data requested by the method. For requests sent using any other method, returns . - - - -## Examples - The following code example displays the date and time that a file on an FTP server was last modified. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet21"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet21"::: - + property returns the data requested by the method. For requests sent using any other method, returns . + + + +## Examples + The following code example displays the date and time that a file on an FTP server was last modified. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet21"::: + ]]> @@ -612,21 +605,20 @@ This property is provided only for compatibility with other implementations of t Gets the URI that sent the response to the request. A instance that identifies the resource associated with this response. - property is not always the same as the value returned by the property. - - For requests that use the method, returns the name of the file on the server. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: - + property is not always the same as the value returned by the property. + + For requests that use the method, returns the name of the file on the server. + + + +## Examples + The following code example displays the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet9"::: + ]]> @@ -675,19 +667,18 @@ This property is provided only for compatibility with other implementations of t Gets the most recent status code sent from the FTP server. An value that indicates the most recent status code returned with this response. - property is included in the property. When you are downloading data, the value of changes as status codes are returned by the FTP server. After you call the method, contains an intermediate status code. When you call the method, contains the final status. - - - -## Examples - The following code example uploads a file to a server and displays the status. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet2"::: - + property is included in the property. When you are downloading data, the value of changes as status codes are returned by the FTP server. After you call the method, contains an intermediate status code. When you call the method, contains the final status. + + + +## Examples + The following code example uploads a file to a server and displays the status. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet2"::: + ]]> @@ -737,19 +728,18 @@ This property is provided only for compatibility with other implementations of t Gets text that describes a status code sent from the FTP server. A instance that contains the status code and message returned with this response. - property includes the 3-digit property value. When downloading data, the value of changes as status codes are returned by the FTP server. After you call the method, contains an intermediate status code. When you call the method, contains the final status. - - - -## Examples - The following code example sends a request to delete a file on an FTP server and displays the status message from the server's response to the request. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: - + property includes the 3-digit property value. When downloading data, the value of changes as status codes are returned by the FTP server. After you call the method, contains an intermediate status code. When you call the method, contains the final status. + + + +## Examples + The following code example sends a request to delete a file on an FTP server and displays the status message from the server's response to the request. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet4"::: + ]]> @@ -795,15 +785,15 @@ This property is provided only for compatibility with other implementations of t Gets a value that indicates whether the property is supported by the instance. - Returns . - + Returns . + if the property is supported by the instance; otherwise, . - @@ -853,19 +843,18 @@ This property is provided only for compatibility with other implementations of t Gets the message sent by the FTP server when authentication is complete. A that contains the welcome message sent by the server; otherwise, if no message is sent. - property is set to `true`), the property returns the first welcome message received with the connection. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLFtpClient/CPP/ftptests.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet13"::: - + property is set to `true`), the property returns the first welcome message received with the connection. + + + +## Examples + The following code example displays the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/FtpStatusCode/Overview/ftptests.cs" id="Snippet13"::: + ]]> diff --git a/xml/System.Net/GlobalProxySelection.xml b/xml/System.Net/GlobalProxySelection.xml index 86c7382795c..9686a326319 100644 --- a/xml/System.Net/GlobalProxySelection.xml +++ b/xml/System.Net/GlobalProxySelection.xml @@ -62,24 +62,23 @@ Contains a global default proxy instance for all HTTP requests. - stores the proxy settings for the default proxy that instances use to contact Internet sites beyond the local network. The default proxy setting is initialized from the global or application configuration file, and can be overridden for individual requests or disabled by setting the property to the result of the method. - - The proxy settings stored in are used by any derived objects that support proxies and have their property value set to `null` (the default). Proxies are currently supported by , , and . - - **Note** Changes to the after a request is made are not reflected in a . - - - -## Examples - The following code example sets the for an HTTP proxy named "webproxy" on port 80. + stores the proxy settings for the default proxy that instances use to contact Internet sites beyond the local network. The default proxy setting is initialized from the global or application configuration file, and can be overridden for individual requests or disabled by setting the property to the result of the method. + + The proxy settings stored in are used by any derived objects that support proxies and have their property value set to `null` (the default). Proxies are currently supported by , , and . + + **Note** Changes to the after a request is made are not reflected in a . + + + +## Examples + The following code example sets the for an HTTP proxy named "webproxy" on port 80. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic GlobalProxySelection Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic GlobalProxySelection Example/VB/source.vb" id="Snippet1"::: + ]]> DefaultProxy Element (Network Settings) @@ -168,20 +167,19 @@ Returns an empty proxy instance. An that contains no information. - method returns a blank instance to indicate that no proxy is used to access an Internet resource. + method returns a blank instance to indicate that no proxy is used to access an Internet resource. + +Instead of calling the `GetEmptyWebProxy` method, you can assign `null` to members such as the property, which specifies the proxy that communicates with remote servers on behalf of the object. + +## Examples + The following code example creates a instance that does not use a proxy. + + :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: -Instead of calling the `GetEmptyWebProxy` method, you can assign `null` to members such as the property, which specifies the proxy that communicates with remote servers on behalf of the object. - -## Examples - The following code example creates a instance that does not use a proxy. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: - ]]> @@ -225,19 +223,18 @@ Instead of calling the `GetEmptyWebProxy` method, you can assign `null` to membe Gets or sets the global HTTP proxy. An that every call to uses. - property sets the proxy that all instances use if the request supports proxies and no proxy is set explicitly using the property. Proxies are currently supported by and . - - - -## Examples - The following code example sets the property to the empty proxy. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLEmptyWebProxy/CPP/test.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: - + property sets the proxy that all instances use if the request supports proxies and no proxy is set explicitly using the property. Proxies are currently supported by and . + + + +## Examples + The following code example sets the property to the empty proxy. + + :::code language="csharp" source="~/snippets/csharp/System.Net/GlobalProxySelection/GetEmptyWebProxy/test.cs" id="Snippet1"::: + ]]> The value specified for a set operation was . diff --git a/xml/System.Net/HttpVersion.xml b/xml/System.Net/HttpVersion.xml index 0d31dea4fa8..f3c597d5064 100644 --- a/xml/System.Net/HttpVersion.xml +++ b/xml/System.Net/HttpVersion.xml @@ -53,20 +53,19 @@ Defines the HTTP version numbers that are supported by the and classes. - class defines the HTTP versions that are supported by the class. The HTTP version number is used to control version-specific features of HTTP, such as pipelining and chunking. + + + +## Examples + The following example demonstrates the use of . - - -## Examples - The following example demonstrates the use of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpVersion_Version10/CPP/httpversion_version10.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpVersion/Overview/httpversion_version10.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpVersion_Version10/VB/httpversion_version10.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpVersion_Version10/VB/httpversion_version10.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/HttpWebRequest.xml b/xml/System.Net/HttpWebRequest.xml index 3d0fc1304af..e4f17446cee 100644 --- a/xml/System.Net/HttpWebRequest.xml +++ b/xml/System.Net/HttpWebRequest.xml @@ -119,16 +119,11 @@ > [!NOTE] > For security reasons, cookies are disabled by default. If you want to use cookies, use the property to enable cookies. - The .NET Framework 4.6 includes a new security feature that blocks insecure cipher and hashing algorithms for connections. Applications using TLS/SSL through APIs such as HttpClient, HttpWebRequest, FTPClient, SmtpClient, SslStream, etc. and targeting .NET Framework 4.6 get the more-secure behavior by default. - - Developers may want to opt out of this behavior in order to maintain interoperability with their existing SSL3 services OR TLS w/ RC4 services. [This article](https://support.microsoft.com/kb/3069494) explains how to modify your code so that the new behavior is disabled. - - +For apps that use TLS/SSL through APIs such as HttpClient, HttpWebRequest, FTPClient, SmtpClient, and SsStream, .NET blocks insecure cipher and hashing algorithms for connections by default. You might need to opt out of this behavior to maintain interoperability with existing SSL3 services OR TLS w/ RC4 services. [Cannot connect to a server by using the ServicePointManager or SslStream APIs after upgrade to the .NET Framework 4.6](https://support.microsoft.com/kb/3069494) explains how to modify your code to disable this behavior, if necessary. ## Examples The following code example creates an for the URI `http://www.contoso.com/`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic HttpWebRequest Example/VB/source.vb" id="Snippet1"::: @@ -416,7 +411,6 @@ Both constructors are obsolete and should not b ## Examples The following code example sets the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Accept/CPP/httpwebrequest_accept.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Accept/httpwebrequest_accept.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Accept/VB/httpwebrequest_accept.vb" id="Snippet1"::: @@ -528,7 +522,6 @@ Both constructors are obsolete and should not b ## Examples The following code example adds a range header to the request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/AddRange/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Misc/system.net.httpwebrequest.addrange/vb/source.vb" id="Snippet1"::: @@ -707,7 +700,6 @@ Both constructors are obsolete and should not b ## Examples The following code example adds a range header to the request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/AddRange/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/vb/source.vb" id="Snippet1"::: @@ -1253,7 +1245,6 @@ Both constructors are obsolete and should not b ## Examples The following code example checks to see if the object `req` was redirected to another location to fulfill the request, and sets the value of the `hasChanged` variable to `true` if the request was redirected; otherwise `hasChanged` is set to `false`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Address/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/VB/source.vb" id="Snippet1"::: @@ -1324,7 +1315,6 @@ Both constructors are obsolete and should not b ## Examples The following code example uses the property to allow the request to follow redirection responses. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/CPP/httpwebrequest_allowautoredirect.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/AllowAutoRedirect/httpwebrequest_allowautoredirect.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_AllowAutoRedirect/VB/httpwebrequest_allowautoredirect.vb" id="Snippet2"::: @@ -1433,7 +1423,6 @@ Both constructors are obsolete and should not b ## Examples The following code example uses the property to disable data buffering. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/CPP/httpwebrequest_allowwritestreambuffering.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/AllowWriteStreamBuffering/httpwebrequest_allowwritestreambuffering.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_AllowWriteStreamBuffering/VB/httpwebrequest_allowwritestreambuffering.vb" id="Snippet1"::: @@ -1567,7 +1556,6 @@ Both constructors are obsolete and should not b ## Examples The following code example uses the method to make an asynchronous request for a stream instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/BeginGetRequestStream/httpwebrequest_begingetrequeststream.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/VB/httpwebrequest_begingetrequeststream.vb" id="Snippet2"::: @@ -1842,7 +1830,6 @@ Both constructors are obsolete and should not b ## Examples The following code example uses the property to set the value of the Connection HTTP Header. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Connection/httpwebrequest_connection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Connection/VB/httpwebrequest_connection.vb" id="Snippet1"::: @@ -1990,7 +1977,6 @@ Both constructors are obsolete and should not b ## Examples The following code example sets the property to the length of the string being posted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ContentLength/httpwebrequest_contentlength.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_ContentLength/VB/httpwebrequest_contentlength.vb" id="Snippet4"::: @@ -2068,7 +2054,6 @@ Both constructors are obsolete and should not b ## Examples The following code example sets the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ContentLength/httpwebrequest_contentlength.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_ContentLength/VB/httpwebrequest_contentlength.vb" id="Snippet1"::: @@ -2272,7 +2257,6 @@ Both constructors are obsolete and should not b ## Examples The following code example sends a request to a URL and displays the cookies returned in the response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCookies/CPP/cookiessnippets.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Cookie/Overview/cookiessnippets.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLCookies/VB/cookiessnippets.vb" id="Snippet1"::: @@ -2359,7 +2343,6 @@ Both constructors are obsolete and should not b ## Examples The following code example sets the credentials for a request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLResponse1/VB/httpwebrequest1.vb" id="Snippet1"::: @@ -2685,7 +2668,6 @@ Both constructors are obsolete and should not b ## Examples The following code example uses the method to end an asynchronous request for a stream instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/CPP/httpwebrequest_begingetrequeststream.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/BeginGetRequestStream/httpwebrequest_begingetrequeststream.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_BeginGetRequestStream/VB/httpwebrequest_begingetrequeststream.vb" id="Snippet2"::: @@ -3119,7 +3101,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example uses the method to return a stream instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ContentLength/httpwebrequest_contentlength.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_ContentLength/VB/httpwebrequest_contentlength.vb" id="Snippet4"::: @@ -3332,7 +3313,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example gets the response for a request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLResponse1/VB/httpwebrequest1.vb" id="Snippet1"::: @@ -3424,7 +3404,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example checks the property to determine if a response has been received from an Internet resource. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/CPP/httpwebrequest_haveresponse.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/HaveResponse/httpwebrequest_haveresponse.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Httpwebrequest_HaveResponse/VB/httpwebrequest_haveresponse.vb" id="Snippet1"::: @@ -3519,7 +3498,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example uses the property to print the HTTP header name/value pairs to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Headers/CPP/httpwebrequest_headers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Headers/httpwebrequest_headers.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Headers/VB/httpwebrequest_headers.vb" id="Snippet1"::: @@ -3675,7 +3653,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example checks the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/CPP/httpwebrequest_ifmodifiedsince.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/IfModifiedSince/httpwebrequest_ifmodifiedsince.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_IfModifiedSince/VB/httpwebrequest_ifmodifiedsince.vb" id="Snippet1"::: @@ -3752,7 +3729,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the property to `false` to avoid establishing a persistent connection with the Internet resource. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Connection/CPP/httpwebrequest_connection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Connection/httpwebrequest_connection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Connection/VB/httpwebrequest_connection.vb" id="Snippet1"::: @@ -3821,7 +3797,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLResponse1/VB/httpwebrequest1.vb" id="Snippet1"::: @@ -3895,7 +3870,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLResponse1/CPP/httpwebrequest1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Credentials/httpwebrequest1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLResponse1/VB/httpwebrequest1.vb" id="Snippet1"::: @@ -4034,7 +4008,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the property to POST. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ContentLength/CPP/httpwebrequest_contentlength.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ContentLength/httpwebrequest_contentlength.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_ContentLength/VB/httpwebrequest_contentlength.vb" id="Snippet4"::: @@ -4115,7 +4088,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example prints the value of the property to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_PipeLined/CPP/httpwebrequest_pipelined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Pipelined/httpwebrequest_pipelined.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_PipeLined/VB/httpwebrequest_pipelined.vb" id="Snippet1"::: @@ -4312,7 +4284,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the Property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/CPP/httpwebrequest_protocolversion.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ProtocolVersion/httpwebrequest_protocolversion.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_ProtocolVersion/VB/httpwebrequest_protocolversion.vb" id="Snippet1"::: @@ -4389,7 +4360,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example uses the method to get the proxy information for the request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Httpwebrequest_proxy/CPP/httpwebrequest_proxy.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Proxy/httpwebrequest_proxy.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Httpwebrequest_proxy/VB/httpwebrequest_proxy.vb" id="Snippet1"::: @@ -4544,7 +4514,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Referer/CPP/httpwebrequest_referer.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Referer/httpwebrequest_referer.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Referer/VB/httpwebrequest_referer.vb" id="Snippet1"::: @@ -4620,7 +4589,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example checks to see if the object `req` was redirected to another location to fulfill the request, and sets the value of the `hasChanged` variable to `true` if the request was redirected; otherwise, `hasChanged` is set to `false`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Address/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic HttpWebRequest.RequestUri Example/VB/source.vb" id="Snippet1"::: @@ -4686,7 +4654,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the property to `true` so that data can be sent in segments to the Internet resource. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_SendChunked/CPP/httpwebrequest_sendchunked.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/SendChunked/httpwebrequest_sendchunked.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_SendChunked/VB/httpwebrequest_sendchunked.vb" id="Snippet2"::: @@ -4811,7 +4778,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet6"::: @@ -5010,7 +4976,6 @@ The GetHashCode method returns a hash code of the web request. This value can be ## Examples The following code example sets the property of the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_Timeout/CPP/httpwebrequest_timeout.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/Timeout/httpwebrequest_timeout.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_Timeout/VB/httpwebrequest_timeout.vb" id="Snippet1"::: @@ -5273,7 +5238,6 @@ The value for this property is stored in . ## Examples The following code example sets the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebRequest_UserAgent/CPP/httpwebrequest_useragent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/UserAgent/httpwebrequest_useragent.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebRequest_UserAgent/VB/httpwebrequest_useragent.vb" id="Snippet1"::: diff --git a/xml/System.Net/HttpWebResponse.xml b/xml/System.Net/HttpWebResponse.xml index 994d3e52340..2f540a64cdb 100644 --- a/xml/System.Net/HttpWebResponse.xml +++ b/xml/System.Net/HttpWebResponse.xml @@ -108,7 +108,6 @@ The contents of the response from the Internet resource are returned as a from an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic HttpWebResponse Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic HttpWebResponse Example/VB/source.vb" id="Snippet1"::: @@ -316,7 +315,6 @@ The contents of the response from the Internet resource are returned as a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Close/CPP/httpwebresponse_close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Close/httpwebresponse_close.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_Close/VB/httpwebresponse_close.vb" id="Snippet1"::: @@ -445,7 +442,6 @@ The contents of the response from the Internet resource are returned as a property to obtain the value of the Content-Encoding header returned with the response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/CharacterSet/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_ContentEncoding_CharacterSet/VB/source.vb" id="Snippet1"::: @@ -507,7 +503,6 @@ The contents of the response from the Internet resource are returned as a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/CPP/httpwebresponse_getresponseheader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/GetResponseHeader/httpwebresponse_getresponseheader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_GetResponseHeader/VB/httpwebresponse_getresponseheader.vb" id="Snippet1"::: @@ -953,7 +945,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example demonstrates how to use to return the instance used to read the response from the server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/CPP/httpwebresponse_getresponsestream.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/GetResponseStream/httpwebresponse_getresponsestream.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_GetResponseStream/VB/httpwebresponse_getresponsestream.vb" id="Snippet1"::: @@ -1024,7 +1015,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example writes the contents of all of the response headers to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Headers/CPP/httpwebresponse_headers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Headers/httpwebresponse_headers.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_Headers/VB/httpwebresponse_headers.vb" id="Snippet1"::: @@ -1137,7 +1127,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples This example creates an and queries for a response. This example then checks whether the entity requested had been modified any time today. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_LastModified/CPP/httpwebresponse_lastmodified.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/LastModified/httpwebresponse_lastmodified.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_LastModified/VB/httpwebresponse_lastmodified.vb" id="Snippet1"::: @@ -1202,7 +1191,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example checks the string contained in , to determine the Http method invoked by the Web server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_Method_Server/VB/httpwebresponse_method_server.vb" id="Snippet1"::: @@ -1263,7 +1251,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples This example creates an and queries for an . The example then checks to see if the server is responding with the same version. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/CPP/httpwebresponse_protocolversion.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/ProtocolVersion/httpwebresponse_protocolversion.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_ProtocolVersion/VB/httpwebresponse_protocolversion.vb" id="Snippet1"::: @@ -1329,7 +1316,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples This example creates a and queries for an and then checks to see whether the original URI was redirected by the server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/CPP/httpwebresponse_responseuri.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/ResponseUri/httpwebresponse_responseuri.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_ResponseUri/VB/httpwebresponse_responseuri.vb" id="Snippet1"::: @@ -1390,7 +1376,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example uses the property to display the Web server's name to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_Method_Server/CPP/httpwebresponse_method_server.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/Method/httpwebresponse_method_server.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_Method_Server/VB/httpwebresponse_method_server.vb" id="Snippet2"::: @@ -1455,7 +1440,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example uses to verify that the status of the is OK. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/VB/httpwebresponse_statuscode_statusdescription.vb" id="Snippet1"::: @@ -1520,7 +1504,6 @@ The GetHashCode method returns a hash code of the web response instance. This va ## Examples The following example uses to verify that the status of the is OK. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/CPP/httpwebresponse_statuscode_statusdescription.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebResponse/StatusCode/httpwebresponse_statuscode_statusdescription.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/HttpWebResponse_StatusCode_StatusDescription/VB/httpwebresponse_statuscode_statusdescription.vb" id="Snippet2"::: diff --git a/xml/System.Net/IAuthenticationModule.xml b/xml/System.Net/IAuthenticationModule.xml index a40f693b940..f270ff9c46c 100644 --- a/xml/System.Net/IAuthenticationModule.xml +++ b/xml/System.Net/IAuthenticationModule.xml @@ -42,24 +42,23 @@ Provides the base authentication interface for Web client authentication modules. - interface defines the properties and methods that custom authentication modules must use. + + Authentication modules conduct the entire authentication process with a server, responding to an authentication challenge as appropriate. This process may consist of requests to an authentication server separate from the resource server, as well as any other activities required to properly authenticate a request for a URI. + + Custom authentication modules should implement the interface and then register with the method. Authentication modules are also registered at program initialization by reading the configuration file. + + + +## Examples + The following example creates a customized authentication class by implementing the interface. For a complete example refer to the class. -## Remarks - The interface defines the properties and methods that custom authentication modules must use. - - Authentication modules conduct the entire authentication process with a server, responding to an authentication challenge as appropriate. This process may consist of requests to an authentication server separate from the resource server, as well as any other activities required to properly authenticate a request for a URI. - - Custom authentication modules should implement the interface and then register with the method. Authentication modules are also registered at program initialization by reading the configuration file. - - - -## Examples - The following example creates a customized authentication class by implementing the interface. For a complete example refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet6"::: + ]]> @@ -119,20 +118,19 @@ Returns an instance of the class in response to an authentication challenge from a server. An instance containing the authorization message for the request, or if the challenge cannot be handled. - method conducts the authentication process with the server and returns an instance to the . - - - -## Examples - The following example shows how to use the method. For a complete example refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet3"::: + method conducts the authentication process with the server and returns an instance to the . + + + +## Examples + The following example shows how to use the method. For a complete example refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet3"::: + ]]> @@ -179,20 +177,19 @@ Gets the authentication type provided by this authentication module. A string indicating the authentication type provided by this authentication module. - property identifies the authentication type implemented by this authentication module. The property is used by the method to determine if the authentication module has been registered, and by the method to remove a registered authentication module. - - - -## Examples - The following example shows how to use the property. For a complete example refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet7"::: + property identifies the authentication type implemented by this authentication module. The property is used by the method to determine if the authentication module has been registered, and by the method to remove a registered authentication module. + + + +## Examples + The following example shows how to use the property. For a complete example refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet7"::: + ]]> @@ -237,20 +234,19 @@ if the authorization module supports preauthentication; otherwise . - property is set to `true` to indicate that the authentication module can respond with a valid instance when the method is called. - - - -## Examples - The following example shows how to use the property. For a complete example refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet7"::: + property is set to `true` to indicate that the authentication module can respond with a valid instance when the method is called. + + + +## Examples + The following example shows how to use the property. For a complete example refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet7"::: + ]]> @@ -310,20 +306,19 @@ Returns an instance of the class for an authentication request to a server. An instance containing the authorization message for the request. - property is `true`, the method will return an instance of the class containing an authentication message. - - - -## Examples - The following example shows how to use the method. For a complete example refer to the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.Authentication/CPP/custombasicauthentication.cpp" id="Snippet4"::: + property is `true`, the method will return an instance of the class containing an authentication message. + + + +## Examples + The following example shows how to use the method. For a complete example refer to the class. + :::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationManager/Overview/custombasicauthentication.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.Authentication/VB/custombasicauthentication.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Net/ICredentialPolicy.xml b/xml/System.Net/ICredentialPolicy.xml index 79944b1165c..17df9281f23 100644 --- a/xml/System.Net/ICredentialPolicy.xml +++ b/xml/System.Net/ICredentialPolicy.xml @@ -41,26 +41,25 @@ Defines the credential policy to be used for resource requests that are made using and its derived classes. - for a network resource, such as the content of a Web page. If credentials are sent, servers that require client authentication can attempt to authenticate the client when the request is received instead of sending a response that indicates that the client's credentials are required. While this saves a round trip to the server, this performance gain must be balanced against the security risk inherent in sending credentials across the network. When the destination server does not require client authentication, it is best not to send credentials. - + for a network resource, such as the content of a Web page. If credentials are sent, servers that require client authentication can attempt to authenticate the client when the request is received instead of sending a response that indicates that the client's credentials are required. While this saves a round trip to the server, this performance gain must be balanced against the security risk inherent in sending credentials across the network. When the destination server does not require client authentication, it is best not to send credentials. + > [!NOTE] -> policies are invoked only if the or the that is associated with the request has credentials that are not `null`. Setting this policy has no effect on requests that do not specify credentials. - - Use the property to set an policy. The that handles authentication for the request will invoke the method before performing the authentication. If the method returns `false`, authentication is not performed. - - An policy affects all instances of with non-null credentials in the current application domain. The policy cannot be overridden on individual requests. - - - -## Examples - The following code example shows an implementation of this interface that permits credentials to be sent only for requests that target specific hosts. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet3"::: +> policies are invoked only if the or the that is associated with the request has credentials that are not `null`. Setting this policy has no effect on requests that do not specify credentials. + + Use the property to set an policy. The that handles authentication for the request will invoke the method before performing the authentication. If the method returns `false`, authentication is not performed. + + An policy affects all instances of with non-null credentials in the current application domain. The policy cannot be overridden on individual requests. + + + +## Examples + The following code example shows an implementation of this interface that permits credentials to be sent only for requests that target specific hosts. + :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet3"::: + ]]> @@ -114,13 +113,13 @@ if the credentials are sent with the request; otherwise, . - policy has been specified by setting the property, the that handles authentication for a invokes the method before performing the authentication. If this method returns `false`, authentication is not performed. - - When the original request has been redirected or proxy authentication is required, the resource identified by `challengeUri` can be different from the requested resource that is specified in . In the case of redirection, `challengeUri` contains the actual destination . If proxy authentication is required, `challengeUri` contains the address of the proxy server that requires client authentication. - + policy has been specified by setting the property, the that handles authentication for a invokes the method before performing the authentication. If this method returns `false`, authentication is not performed. + + When the original request has been redirected or proxy authentication is required, the resource identified by `challengeUri` can be different from the requested resource that is specified in . In the case of redirection, `challengeUri` contains the actual destination . If proxy authentication is required, `challengeUri` contains the address of the proxy server that requires client authentication. + ]]> diff --git a/xml/System.Net/ICredentials.xml b/xml/System.Net/ICredentials.xml index b71cde3c212..605d0503c79 100644 --- a/xml/System.Net/ICredentials.xml +++ b/xml/System.Net/ICredentials.xml @@ -51,20 +51,19 @@ Provides the base authentication interface for retrieving credentials for Web client authentication. - interface provides the method to objects that supply network credentials to applications. + + + +## Examples + The following example illustrates how to use the interface. -## Remarks - The interface provides the method to objects that supply network credentials to applications. - - - -## Examples - The following example illustrates how to use the interface. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ICredentials/Overview/icredential.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ICredential/VB/icredential.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ICredential/VB/icredential.vb" id="Snippet1"::: + ]]> @@ -121,20 +120,19 @@ Returns a object that is associated with the specified URI, and authentication type. The that is associated with the specified URI and authentication type, or, if no credentials are available, . - method returns a instance that contains the credentials that are associated with the specified URI and authorization scheme. When no credentials are available, the method returns `null`. - - - -## Examples - The following uses to retrieve a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/ICredential/CPP/icredential.cpp" id="Snippet1"::: + method returns a instance that contains the credentials that are associated with the specified URI and authorization scheme. When no credentials are available, the method returns `null`. + + + +## Examples + The following uses to retrieve a instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/ICredentials/Overview/icredential.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ICredential/VB/icredential.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/ICredential/VB/icredential.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/IPAddress.xml b/xml/System.Net/IPAddress.xml index 08142724731..36197637e39 100644 --- a/xml/System.Net/IPAddress.xml +++ b/xml/System.Net/IPAddress.xml @@ -102,7 +102,6 @@ ## Examples The following code example shows how to query a server to obtain the family addresses and the IP addresses it supports. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Overview/ipaddress.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress/VB/ipaddress.vb" id="Snippet1"::: @@ -538,7 +537,6 @@ ## Examples Refer to the example in the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Overview/ipaddress.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress/VB/ipaddress.vb" id="Snippet3"::: @@ -663,7 +661,6 @@ ## Examples The following example prints the address to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Broadcast/ipaddress_broadcast_loopback.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/VB/ipaddress_broadcast_loopback.vb" id="Snippet2"::: @@ -791,7 +788,6 @@ ## Examples The following code example shows how to get a server IP address in byte format. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Overview/ipaddress.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress/VB/ipaddress.vb" id="Snippet2"::: @@ -1097,7 +1093,6 @@ ## Examples The following code example displays the value of the current host's Any address in standard compressed format. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/IPv6Any/noneanyloopback.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/VB/noneanyloopback.vb" id="Snippet2"::: @@ -1163,7 +1158,6 @@ ## Examples The following code example displays the value of the current host's loopback address in standard compressed format. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/IPv6Any/noneanyloopback.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/VB/noneanyloopback.vb" id="Snippet1"::: @@ -1229,7 +1223,6 @@ ## Examples The following code example displays the value of the current host's None address in standard compressed format. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/CPP/noneanyloopback.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/IPv6Any/noneanyloopback.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress.IPv6NoneAnyLoopback/VB/noneanyloopback.vb" id="Snippet3"::: @@ -1576,7 +1569,6 @@ ## Examples The following code example uses the method to determine whether the specified address is a loopback address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/CPP/isloopback.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/IsLoopback/isloopback.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress.IsLoopback/VB/isloopback.vb" id="Snippet1"::: @@ -1710,7 +1702,6 @@ ## Examples The following example prints the address to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/CPP/ipaddress_broadcast_loopback.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Broadcast/ipaddress_broadcast_loopback.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_Broadcast_Loopback/VB/ipaddress_broadcast_loopback.vb" id="Snippet1"::: @@ -1901,7 +1892,6 @@ ## Examples The following example uses the method to convert a short value from network byte order to host byte order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/NetworkToHostOrder/ipaddress_networktohost.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_NetworkToHost/VB/ipaddress_networktohost.vb" id="Snippet1"::: @@ -1975,7 +1965,6 @@ ## Examples The following example uses the method to convert an integer value from network byte order to host byte order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/NetworkToHostOrder/ipaddress_networktohost.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_NetworkToHost/VB/ipaddress_networktohost.vb" id="Snippet2"::: @@ -2049,7 +2038,6 @@ ## Examples The following example uses the method to convert a long value from network byte order to host byte order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_NetworkToHost/CPP/ipaddress_networktohost.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/NetworkToHostOrder/ipaddress_networktohost.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_NetworkToHost/VB/ipaddress_networktohost.vb" id="Snippet3"::: @@ -2116,7 +2104,6 @@ ## Examples The following example uses the property to indicate that no network interface should be used. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPAddress_None/CPP/ipaddress_none.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/None/ipaddress_none.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPAddress_None/VB/ipaddress_none.vb" id="Snippet1"::: @@ -2237,7 +2224,6 @@ ## Examples The following code converts a string that contains an IP address, in dotted-quad notation for IPv4 or in colon-hexadecimal notation for IPv6, into an instance of the class. Then it uses the overloaded method to display the address in standard notation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress.Parse/CPP/parse.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Parse/parse.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress.Parse/VB/parse.vb" id="Snippet1"::: @@ -2367,7 +2353,6 @@ The notation that is used to specify the `ScopeId` with an address is `Address%ScopeId`. For example, `FE80::5EFE:192.168.41.30%2.` ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPAddress/CPP/ipaddress.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPAddress/Overview/ipaddress.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPAddress/VB/ipaddress.vb" id="Snippet3"::: diff --git a/xml/System.Net/IPEndPoint.xml b/xml/System.Net/IPEndPoint.xml index affb87e4f9a..9abed0a45f2 100644 --- a/xml/System.Net/IPEndPoint.xml +++ b/xml/System.Net/IPEndPoint.xml @@ -60,18 +60,17 @@ Represents a network endpoint as an IP address and a port number. - class contains the host and local or remote port information needed by an application to connect to a service on a host. By combining the host's IP address and port number of a service, the class forms a connection point to a service. - - - + class contains the host and local or remote port information needed by an application to connect to a service on a host. By combining the host's IP address and port number of a service, the class forms a connection point to a service. + + + ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet1"::: + ]]> @@ -131,26 +130,25 @@ The port number associated with the , or 0 to specify any available port. is in host order. Initializes a new instance of the class with the specified address and port number. - . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp" id="Snippet4"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/.ctor/ipendpoint_properties.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: + ]]> - is less than . - - -or- - - is greater than . - - -or- - + is less than . + + -or- + + is greater than . + + -or- + is less than 0 or greater than 0x00000000FFFFFFFF. @@ -199,22 +197,21 @@ The port number associated with the , or 0 to specify any available port. is in host order. Initializes a new instance of the class with the specified address and port number. - is . - is less than . - - -or- - + is less than . + + -or- + is greater than . @@ -271,15 +268,14 @@ Gets or sets the IP address of the endpoint. An instance containing the IP address of the endpoint. - property using the specified. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet3"::: + property using the specified. + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: + ]]> @@ -327,15 +323,14 @@ Gets the Internet Protocol (IP) address family. Returns . - property to return the to which the belongs. In this case it is the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet3"::: + property to return the to which the belongs. In this case it is the . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: + ]]> @@ -388,21 +383,20 @@ Creates an endpoint from a socket address. An instance using the specified socket address. - to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet5"::: + to create an . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet5"::: + ]]> - The AddressFamily of is not equal to the AddressFamily of the current instance. - - -or- - + The AddressFamily of is not equal to the AddressFamily of the current instance. + + -or- + .Size < 8. @@ -511,11 +505,11 @@ Returns a hash value for a instance. An integer hash value. - method returns a hash code of the IP endpoint instance. This value can be used as a key in hash tables. - + method returns a hash code of the IP endpoint instance. This value can be used as a key in hash tables. + ]]> @@ -563,15 +557,14 @@ Specifies the maximum value that can be assigned to the property. The MaxPort value is set to 0x0000FFFF. This field is read-only. - property to print the maximum value that can be assigned to the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp" id="Snippet4"::: + property to print the maximum value that can be assigned to the property. + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/.ctor/ipendpoint_properties.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: + ]]> @@ -619,15 +612,14 @@ Specifies the minimum value that can be assigned to the property. This field is read-only. - property to print the minimum value that can be assigned to the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPEndPoint_Properties/CPP/ipendpoint_properties.cpp" id="Snippet4"::: + property to print the minimum value that can be assigned to the property. + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/.ctor/ipendpoint_properties.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPEndPoint_Properties/VB/ipendpoint_properties.vb" id="Snippet4"::: + ]]> @@ -636,22 +628,22 @@ To be added. - [!IMPORTANT] > Note that this method accepts as valid a value that can be parsed as an , and then treats that as the long value of an IP address in network byte order, similar to the way that the IPAddress constructor does. This means that this method returns true if the Int64 is parsed successfully, even if it represents an address that's not a valid IP address. For example, if s is "1", this method returns true even though "1" (or 0.0.0.1) is not a valid IP address and you might expect this method to return false. Fixing this bug would break existing apps, so the current behavior will not be changed. Your code can avoid this behavior by ensuring that it only uses this method to parse IP addresses in dotted-decimal format. - + Literal IPv6 addresses require to be enclosed in square brackets [] when passing an endpoint that specifies a port number; otherwise, square braces are not mandatory. ]]> @@ -803,15 +795,14 @@ Literal IPv6 addresses require to be enclosed in square brackets [] when passing Gets or sets the port number of the endpoint. An integer value in the range to indicating the port number of the endpoint. - property to set TCP port number of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet3"::: + property to set TCP port number of the . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: + ]]> The value that was specified for a set operation is less than or greater than . @@ -861,15 +852,14 @@ Literal IPv6 addresses require to be enclosed in square brackets [] when passing Serializes endpoint information into a instance. A instance containing the socket address for the endpoint. - method to serialize endpoint information into a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet4"::: + method to serialize endpoint information into a instance. + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet4"::: + ]]> @@ -919,15 +909,14 @@ Literal IPv6 addresses require to be enclosed in square brackets [] when passing Returns the IP address and port number of the specified endpoint. A string containing the IP address and the port number of the specified endpoint (for example, 192.168.1.2:80). - . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.IPEndPoint/CPP/ipendpoint.cpp" id="Snippet3"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPEndPoint/Overview/ipendpoint.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.IPEndPoint/VB/ipendpoint.vb" id="Snippet3"::: + ]]> @@ -936,21 +925,21 @@ Literal IPv6 addresses require to be enclosed in square brackets [] when passing To be added. - [!IMPORTANT] > Note that this method accepts as valid a value that can be parsed as an , and then treats that as the long value of an IP address in network byte order, similar to the way that the IPAddress constructor does. This means that this method returns true if the Int64 is parsed successfully, even if it represents an address that's not a valid IP address. For example, if s is "1", this method returns true even though "1" (or 0.0.0.1) is not a valid IP address and you might expect this method to return false. Fixing this bug would break existing apps, so the current behavior will not be changed. Your code can avoid this behavior by ensuring that it only uses this method to parse IP addresses in dotted-decimal format. - + Literal IPv6 addresses require to be enclosed in square brackets [] when passing an endpoint that specifies a port number; otherwise, square braces are not mandatory. ]]> diff --git a/xml/System.Net/IPHostEntry.xml b/xml/System.Net/IPHostEntry.xml index 215694fb6a8..00500ffc1a3 100644 --- a/xml/System.Net/IPHostEntry.xml +++ b/xml/System.Net/IPHostEntry.xml @@ -51,22 +51,21 @@ Provides a container class for Internet host address information. - class associates a Domain Name System (DNS) host name with an array of aliases and an array of matching IP addresses. + + The class is used as a helper class with the class. + + + +## Examples + The following example queries the DNS database for information on the host `www.contoso.com` and returns the information in an instance. -## Remarks - The class associates a Domain Name System (DNS) host name with an array of aliases and an array of matching IP addresses. - - The class is used as a helper class with the class. - - - -## Examples - The following example queries the DNS database for information on the host `www.contoso.com` and returns the information in an instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Dns Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/Dns/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Dns Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Dns Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -166,15 +165,14 @@ Gets or sets a list of IP addresses that are associated with a host. An array of type that contains IP addresses that resolve to the host names that are contained in the property. - property to access the IP addresses that are associated with the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp" id="Snippet1"::: + property to access the IP addresses that are associated with the . + :::code language="csharp" source="~/snippets/csharp/System.Net/IPHostEntry/AddressList/iphostentry_addresslist.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPHostEntry_AddressList/VB/iphostentry_addresslist.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPHostEntry_AddressList/VB/iphostentry_addresslist.vb" id="Snippet1"::: + ]]> @@ -281,20 +279,19 @@ Gets or sets the DNS name of the host. A string that contains the primary host name for the server. - property contains the primary host name for a server. If the DNS entry for the server defines additional aliases, they will be available in the property. - - - -## Examples - The following example uses the property to retrieve the primary host name. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IPHostEntry_AddressList/CPP/iphostentry_addresslist.cpp" id="Snippet1"::: + property contains the primary host name for a server. If the DNS entry for the server defines additional aliases, they will be available in the property. + + + +## Examples + The following example uses the property to retrieve the primary host name. + :::code language="csharp" source="~/snippets/csharp/System.Net/IPHostEntry/AddressList/iphostentry_addresslist.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPHostEntry_AddressList/VB/iphostentry_addresslist.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IPHostEntry_AddressList/VB/iphostentry_addresslist.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Net/IWebProxy.xml b/xml/System.Net/IWebProxy.xml index 76feba4c582..9d5a29167f7 100644 --- a/xml/System.Net/IWebProxy.xml +++ b/xml/System.Net/IWebProxy.xml @@ -45,13 +45,13 @@ Provides the base interface for implementation of proxy access for the class. - interface provides the methods and properties that are required by the class to access proxy servers. - - The class is the base implementation of the interface. - + + The class is the base implementation of the interface. + ]]> @@ -101,20 +101,19 @@ The credentials to submit to the proxy server for authentication. An instance that contains the credentials that are needed to authenticate a request to the proxy server. - property is an instance that contains the authorization credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code. - - + property is an instance that contains the authorization credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code. + + + +## Examples + The following example uses the property to set the credentials that will be submitted to the proxy server for authentication. -## Examples - The following example uses the property to set the credentials that will be submitted to the proxy server for authentication. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/IWebProxy/Credentials/iwebproxy_interface.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet1"::: + ]]> @@ -165,20 +164,19 @@ Returns the URI of a proxy. A instance that contains the URI of the proxy used to contact ; otherwise null or itself. - method returns the URI of the proxy server that handles requests to the Internet resource that is specified in the `destination` parameter. If the method returns null or `destination` itself, the proxy is not used to contact the host and the request is passed directly to the server. - - - -## Examples - The following example uses the method to return the URI that the uses to access the Internet resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp" id="Snippet4"::: + + + +## Examples + The following example uses the method to return the URI that the uses to access the Internet resource. + :::code language="csharp" source="~/snippets/csharp/System.Net/IWebProxy/Credentials/iwebproxy_interface.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet4"::: + ]]> @@ -229,20 +227,19 @@ if the proxy server should not be used for ; otherwise, . - method indicates whether to use the proxy server to access the host that is specified in the `host` parameter. If returns `true`, the proxy is not used to contact the host and the request is passed directly to the server. Getting `false` from does not guarantee that the URI is proxied; you still need to call the method to determine this. - - - -## Examples - The following example uses the property to determine whether the proxy server should be used for the specified host. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/IWebProxy_Interface/CPP/iwebproxy_interface.cpp" id="Snippet4"::: + + + +## Examples + The following example uses the property to determine whether the proxy server should be used for the specified host. + :::code language="csharp" source="~/snippets/csharp/System.Net/IWebProxy/Credentials/iwebproxy_interface.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/IWebProxy_Interface/VB/iwebproxy_interface.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Net/NetworkCredential.xml b/xml/System.Net/NetworkCredential.xml index d8108a864fb..5b7b56fdb9f 100644 --- a/xml/System.Net/NetworkCredential.xml +++ b/xml/System.Net/NetworkCredential.xml @@ -81,7 +81,7 @@ > On Unix platforms, use of NTLM authentication may require installing the NTLM plugin for the GSSAPI layer used by the implemention. On Ubuntu distributions, the package is called `gss-ntlmssp`. Alternatively, applications may opt in for a managed implementation of NTLM by setting the `_UseManagedNtlm` .csproj property (.NET 9+ only), or setting the `System.Net.Security.UseManagedNtlm` AppContext switch. > > On Windows, NTLM and Negotiate (Kerberos) authentication always depend on GSSAPI of the operating system. - + This class does not support public key-based authentication methods such as Secure Sockets Layer (SSL) client authentication. @@ -89,7 +89,6 @@ ## Examples The following code example associates a object with a set of Uniform Resource Identifiers (URIs) in a . It then passes the to a object, which uses it to authenticate requests to an Internet server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic NetworkCredential Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic NetworkCredential Example/VB/source.vb" id="Snippet1"::: @@ -286,7 +285,6 @@ ## Examples The following code example creates a object using the specified user name and password. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_Constructor2/CPP/networkcredential_constructor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/.ctor/networkcredential_constructor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkCredential_Constructor2/VB/networkcredential_constructor2.vb" id="Snippet1"::: @@ -473,7 +471,6 @@ ## Examples The following code example uses the property to set the domain associated with the credentials. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/Domain/networkcredential_username_password_domain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/VB/networkcredential_username_password_domain.vb" id="Snippet1"::: @@ -623,7 +620,6 @@ ## Examples The following code example uses the method to retrieve a object for the specified URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_GetCredential/CPP/networkcredential_getcredential.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/GetCredential/networkcredential_getcredential.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkCredential_GetCredential/VB/networkcredential_getcredential.vb" id="Snippet1"::: @@ -681,7 +677,6 @@ ## Examples The following code example uses the property to set the password associated with the credentials. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/Domain/networkcredential_username_password_domain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/VB/networkcredential_username_password_domain.vb" id="Snippet1"::: @@ -795,7 +790,6 @@ ## Examples The following code example uses the property to set the user name associated with the credentials. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/CPP/networkcredential_username_password_domain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/NetworkCredential/Domain/networkcredential_username_password_domain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NetworkCredential_UserName_Password_Domain/VB/networkcredential_username_password_domain.vb" id="Snippet1"::: diff --git a/xml/System.Net/OpenReadCompletedEventArgs.xml b/xml/System.Net/OpenReadCompletedEventArgs.xml index e60b3b5e5c5..c62237dce05 100644 --- a/xml/System.Net/OpenReadCompletedEventArgs.xml +++ b/xml/System.Net/OpenReadCompletedEventArgs.xml @@ -53,26 +53,24 @@ Provides data for the event. - methods. + + + +## Examples + The following code example demonstrates downloading a resource for reading. -## Remarks - Instances of this class are passed to methods. - - - -## Examples - The following code example demonstrates downloading a resource for reading. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet30"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet30"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet31"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet30"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet31"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: + ]]> @@ -118,20 +116,19 @@ Gets a readable stream that contains data downloaded by a method. A that contains the downloaded data. - and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example uses the stream returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet31"::: + and properties before using the data that is returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example uses the stream returned by this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet31"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: + ]]> diff --git a/xml/System.Net/OpenReadCompletedEventHandler.xml b/xml/System.Net/OpenReadCompletedEventHandler.xml index 8eff6f62285..feeb2b2652f 100644 --- a/xml/System.Net/OpenReadCompletedEventHandler.xml +++ b/xml/System.Net/OpenReadCompletedEventHandler.xml @@ -55,26 +55,24 @@ A containing event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. + + + +## Examples + The following code example demonstrates downloading a resource for reading. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. - - - -## Examples - The following code example demonstrates downloading a resource for reading. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet30"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet30"::: - - The following method is called when the download completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet31"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet30"::: + + The following method is called when the download completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet31"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet31"::: + ]]> diff --git a/xml/System.Net/OpenWriteCompletedEventArgs.xml b/xml/System.Net/OpenWriteCompletedEventArgs.xml index 6e14a9f7185..74cdd9d89f1 100644 --- a/xml/System.Net/OpenWriteCompletedEventArgs.xml +++ b/xml/System.Net/OpenWriteCompletedEventArgs.xml @@ -53,26 +53,24 @@ Provides data for the event. - methods. + + + +## Examples + The following code example demonstrates opening a stream to write data to be uploaded. -## Remarks - Instances of this class are passed to methods. - - - -## Examples - The following code example demonstrates opening a stream to write data to be uploaded. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet16"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet16"::: - - The following method is called when the stream is available. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet15"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet16"::: + + The following method is called when the stream is available. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: + ]]> @@ -118,20 +116,19 @@ Gets a writable stream that is used to send data to a server. A where you can write data to be uploaded. - and properties before using the stream returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example uses the stream returned by this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet15"::: + and properties before using the stream returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example uses the stream returned by this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: + ]]> diff --git a/xml/System.Net/OpenWriteCompletedEventHandler.xml b/xml/System.Net/OpenWriteCompletedEventHandler.xml index 41625615040..37a8ed22fb2 100644 --- a/xml/System.Net/OpenWriteCompletedEventHandler.xml +++ b/xml/System.Net/OpenWriteCompletedEventHandler.xml @@ -55,26 +55,24 @@ A containing event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. + + + +## Examples + The following code example demonstrates opening a stream to write data to be uploaded. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. - - - -## Examples - The following code example demonstrates opening a stream to write data to be uploaded. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet16"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet16"::: - - The following method is called when the stream is available. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet15"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet16"::: + + The following method is called when the stream is available. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet15"::: + ]]> diff --git a/xml/System.Net/ServicePoint.xml b/xml/System.Net/ServicePoint.xml index 50f17a4257d..1a4816115d6 100644 --- a/xml/System.Net/ServicePoint.xml +++ b/xml/System.Net/ServicePoint.xml @@ -76,7 +76,6 @@ ## Examples The following code example creates a object that connects to the URI `www.contoso.com`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet1"::: @@ -131,7 +130,6 @@ ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet2"::: @@ -270,7 +268,6 @@ Although a object can make multiple connections t ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet5"::: @@ -336,7 +333,6 @@ Although a object can make multiple connections t ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet5"::: @@ -470,7 +466,6 @@ Although a object can make multiple connections t ## Examples The following code example sets the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePoint/ConnectionLeaseTimeout/nclservicepoint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLServicePoint/VB/nclservicepoint.vb" id="Snippet1"::: @@ -539,7 +534,6 @@ Although a object can make multiple connections t ## Examples The following code example uses the property to check the maximum number of connections that the object can make to the specified Uniform Resource Identifier (URI). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet4"::: @@ -610,7 +604,6 @@ Although a object can make multiple connections t ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet4"::: @@ -675,7 +668,6 @@ Although a object can make multiple connections t ## Examples The following code example uses the property to determine the number of open Internet connections associated with this object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet2"::: @@ -758,7 +750,6 @@ Although a object can make multiple connections t ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet9"::: @@ -867,7 +858,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example uses the property to set and retrieve the date and time that the object was last connected to a host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet3"::: @@ -935,7 +925,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example uses the property to set and retrieve the idle time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet3"::: @@ -1001,7 +990,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet5"::: @@ -1070,7 +1058,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example sets the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLServicePoint/CPP/nclservicepoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePoint/ConnectionLeaseTimeout/nclservicepoint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLServicePoint/VB/nclservicepoint.vb" id="Snippet1"::: @@ -1214,7 +1201,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet5"::: @@ -1293,7 +1279,6 @@ The `GetHashCode` method returns a hash code of this instance. This value can be ## Examples The following code example displays the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet9"::: diff --git a/xml/System.Net/ServicePointManager.xml b/xml/System.Net/ServicePointManager.xml index e497283cc91..a615a7b1c1a 100644 --- a/xml/System.Net/ServicePointManager.xml +++ b/xml/System.Net/ServicePointManager.xml @@ -76,7 +76,6 @@ ## Examples The following code example creates a object for connections to the URI `www.contoso.com`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic ServicePoint Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePointManager/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic ServicePoint Example/VB/source.vb" id="Snippet1"::: @@ -137,7 +136,6 @@ ## Examples The following code example shows how to catch a certificate policy exception for a custom certificate policy. It assumes that the certificate policy object has been defined, that the Uniform Resource Identifier (URI) for the Web resource is contained in the variable `myUri`, and that there is a method named `ProcessResponse` that performs the work of the application. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePointManager/CertificatePolicy/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic ServicePointManager.CertificatePolicy Example/VB/source.vb" id="Snippet1"::: @@ -201,7 +199,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet10"::: @@ -275,7 +272,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet10"::: @@ -378,7 +374,6 @@ ## Examples The following code example sets the property using this field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet10"::: @@ -436,7 +431,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePointManager/DnsRefreshTimeout/servicepoint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/VB/servicepoint.vb" id="Snippet1"::: @@ -498,7 +492,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/cpp/servicepoint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/ServicePointManager/DnsRefreshTimeout/servicepoint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePointWhidbey/VB/servicepoint.vb" id="Snippet1"::: @@ -635,7 +628,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet10"::: @@ -795,7 +787,6 @@ ## Examples The following code example demonstrates calling this method to access a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet7"::: @@ -937,7 +928,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet8"::: @@ -1008,7 +998,6 @@ ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet8"::: @@ -1345,7 +1334,6 @@ Each callback returns a value that indicates whether the certificate is accepted ## Examples The following code example sets this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/System.Net.ServicePoint/CPP/servicepoint.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Net/HttpWebRequest/ServicePoint/servicepoint.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/System.Net.ServicePoint/VB/servicepoint.vb" id="Snippet10"::: diff --git a/xml/System.Net/SocketAddress.xml b/xml/System.Net/SocketAddress.xml index 3f20821df2f..a37402daa83 100644 --- a/xml/System.Net/SocketAddress.xml +++ b/xml/System.Net/SocketAddress.xml @@ -68,7 +68,6 @@ ## Examples The following example demonstrates how to use to serialize an instance of the class. After serialization, the underlying byte buffer of the contains all of the state information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic SocketAddressExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/SocketAddress/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic SocketAddressExample/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Net/UploadDataCompletedEventArgs.xml b/xml/System.Net/UploadDataCompletedEventArgs.xml index 086b20f96d7..6ef0fc92fe1 100644 --- a/xml/System.Net/UploadDataCompletedEventArgs.xml +++ b/xml/System.Net/UploadDataCompletedEventArgs.xml @@ -49,26 +49,24 @@ Provides data for the event. - . + + + +## Examples + The following code example demonstrates asynchronously uploading data. -## Remarks - Instances of this class are passed to the . - - - -## Examples - The following code example demonstrates asynchronously uploading data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet34"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet34"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet34"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet35"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet34"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet35"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: + ]]> @@ -111,20 +109,19 @@ Gets the server reply to a data upload operation started by calling an method. A array containing the server reply. - and properties before using the data returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet35"::: + and properties before using the data returned by this property. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet35"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: + ]]> diff --git a/xml/System.Net/UploadDataCompletedEventHandler.xml b/xml/System.Net/UploadDataCompletedEventHandler.xml index e210e67de7a..014507b9a79 100644 --- a/xml/System.Net/UploadDataCompletedEventHandler.xml +++ b/xml/System.Net/UploadDataCompletedEventHandler.xml @@ -51,26 +51,24 @@ A containing event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates asynchronously uploading data. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates asynchronously uploading data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet34"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet34"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet34"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet35"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet34"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet35"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet35"::: + ]]> diff --git a/xml/System.Net/UploadFileCompletedEventArgs.xml b/xml/System.Net/UploadFileCompletedEventArgs.xml index ec8a99f8235..83617fe377e 100644 --- a/xml/System.Net/UploadFileCompletedEventArgs.xml +++ b/xml/System.Net/UploadFileCompletedEventArgs.xml @@ -49,26 +49,24 @@ Provides data for the event. - . + + + +## Examples + The following code example demonstrates asynchronously uploading a file. -## Remarks - Instances of this class are passed to the . - - - -## Examples - The following code example demonstrates asynchronously uploading a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet4"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet4"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet5"::: + ]]> @@ -111,20 +109,19 @@ Gets the server reply to a data upload operation that is started by calling an method. A array that contains the server reply. - and properties to determine whether the upload completed. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet5"::: + and properties to determine whether the upload completed. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Net/UploadFileCompletedEventHandler.xml b/xml/System.Net/UploadFileCompletedEventHandler.xml index 8b438a368cc..c44d3c7a1e4 100644 --- a/xml/System.Net/UploadFileCompletedEventHandler.xml +++ b/xml/System.Net/UploadFileCompletedEventHandler.xml @@ -51,26 +51,24 @@ A that contains event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates asynchronously uploading a file. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates asynchronously uploading a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet6"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet7"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet6"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Net/UploadStringCompletedEventArgs.xml b/xml/System.Net/UploadStringCompletedEventArgs.xml index 655e684a51d..314f6399cb0 100644 --- a/xml/System.Net/UploadStringCompletedEventArgs.xml +++ b/xml/System.Net/UploadStringCompletedEventArgs.xml @@ -53,26 +53,24 @@ Provides data for the event. - . + + + +## Examples + The following code example demonstrates asynchronously uploading a string. -## Remarks - Instances of this class are passed to the . - - - -## Examples - The following code example demonstrates asynchronously uploading a string. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet38"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet38"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet38"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet38"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: + ]]> @@ -118,20 +116,19 @@ Gets the server reply to a string upload operation that is started by calling an method. A array that contains the server reply. - and properties to determine whether the upload completed. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. - - - -## Examples - The following code example displays the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet39"::: + and properties to determine whether the upload completed. If the property's value is an object or the property's value is `true`, the asynchronous operation did not complete correctly and the property's value will not be valid. + + + +## Examples + The following code example displays the value of this property. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: + ]]> diff --git a/xml/System.Net/UploadStringCompletedEventHandler.xml b/xml/System.Net/UploadStringCompletedEventHandler.xml index 22175d96c3c..2410b6b7dda 100644 --- a/xml/System.Net/UploadStringCompletedEventHandler.xml +++ b/xml/System.Net/UploadStringCompletedEventHandler.xml @@ -55,26 +55,24 @@ A containing event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates asynchronously uploading a string. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates asynchronously uploading a string. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet38"::: :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet38"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet38"::: - - The following method is called when the upload completes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebClientAsync/CPP/asyncmethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet38"::: + + The following method is called when the upload completes. + :::code language="csharp" source="~/snippets/csharp/System.Net/DownloadDataCompletedEventArgs/Overview/asyncmethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientAsync/VB/asyncmethods.vb" id="Snippet39"::: + ]]> diff --git a/xml/System.Net/WebException.xml b/xml/System.Net/WebException.xml index 4a917a9d8b7..e3f2d1e5a0f 100644 --- a/xml/System.Net/WebException.xml +++ b/xml/System.Net/WebException.xml @@ -150,7 +150,6 @@ ## Examples The following example throws a default . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor1/CPP/webexception_constructor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/.ctor/webexception_constructor1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Constructor1/VB/webexception_constructor1.vb" id="Snippet1"::: @@ -218,7 +217,6 @@ ## Examples The following example throws a by specifying an error message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor2/CPP/webexception_constructor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/.ctor/webexception_constructor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Constructor2/VB/webexception_constructor2.vb" id="Snippet1"::: @@ -353,7 +351,6 @@ ## Examples The following example throws a by specifying an error message and a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor3/CPP/webexception_constructor3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/.ctor/webexception_constructor3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Constructor3/VB/webexception_constructor3.vb" id="Snippet1"::: @@ -424,7 +421,6 @@ ## Examples The following example throws a by specifying an error message and nested exception. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor4/CPP/webexception_constructor4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/.ctor/webexception_constructor4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Constructor4/VB/webexception_constructor4.vb" id="Snippet1"::: @@ -506,7 +502,6 @@ ## Examples The following example throws a by specifying an error message and a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Constructor5/CPP/webexception_constructor5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/.ctor/webexception_constructor5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Constructor5/VB/webexception_constructor5.vb" id="Snippet1"::: @@ -632,7 +627,6 @@ ## Examples The following example checks the property and prints to the console the and of the underlying instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/Response/webexception_status_response.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Status_Response/VB/webexception_status_response.vb" id="Snippet1"::: @@ -704,7 +698,6 @@ ## Examples The following example checks the property and prints to the console the and of the underlying instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebException_Status_Response/CPP/webexception_status_response.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebException/Response/webexception_status_response.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebException_Status_Response/VB/webexception_status_response.vb" id="Snippet1"::: diff --git a/xml/System.Net/WebHeaderCollection.xml b/xml/System.Net/WebHeaderCollection.xml index 674da86a231..41aec5b138f 100644 --- a/xml/System.Net/WebHeaderCollection.xml +++ b/xml/System.Net/WebHeaderCollection.xml @@ -329,7 +329,6 @@ ## Examples The following example adds a name/value pair to a using the Method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/Add/webheadercollection_add.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_Add/VB/webheadercollection_add.vb" id="Snippet1"::: @@ -569,7 +568,6 @@ ## Examples The following example adds a name/value pair to a using the Method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Add/CPP/webheadercollection_add.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/Add/webheadercollection_add.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_Add/VB/webheadercollection_add.vb" id="Snippet1"::: @@ -1320,7 +1318,6 @@ ## Examples The following example uses the method to retrieve an array of values for each header in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/CPP/webheadercollection_getvalues_1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/GetValues/webheadercollection_getvalues_1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_GetValues_1/VB/webheadercollection_getvalues_1.vb" id="Snippet1"::: @@ -1430,7 +1427,6 @@ ## Examples The following example checks the property to see if any headers are prohibited from being set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/IsRestricted/webheadercollection_isrestricted.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/VB/webheadercollection_isrestricted.vb" id="Snippet1"::: @@ -1528,7 +1524,6 @@ ## Examples The following example checks the property to see if any request headers are prohibited from being set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/CPP/webheadercollection_isrestricted.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/IsRestricted/webheadercollection_isrestricted.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_IsRestricted/VB/webheadercollection_isrestricted.vb" id="Snippet1"::: @@ -2007,7 +2002,6 @@ ## Examples The following example uses the method to remove a header from the . After the header is removed, this example prints all existing headers to the screen to prove that it has been removed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Remove/CPP/webheadercollection_remove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/Remove/webheadercollection_remove.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_Remove/VB/webheadercollection_remove.vb" id="Snippet1"::: @@ -2239,7 +2233,6 @@ ## Examples The following example uses the method to set the value of an existing header. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebHeaderCollection_Set/CPP/webheadercollection_set.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebHeaderCollection/Set/webheadercollection_set.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebHeaderCollection_Set/VB/webheadercollection_set.vb" id="Snippet1"::: diff --git a/xml/System.Net/WebProxy.xml b/xml/System.Net/WebProxy.xml index 02a21166403..ddf467d9d3b 100644 --- a/xml/System.Net/WebProxy.xml +++ b/xml/System.Net/WebProxy.xml @@ -65,36 +65,33 @@ Contains HTTP proxy settings for the class. - class contains the proxy settings that instances use to determine whether a Web proxy is used to send requests. Global Web proxy settings can be specified in machine and application configuration files, and applications can use instances of the class to customize Web proxy use. The class is the base implementation of the interface. - - To obtain instances of the Web proxy class, you can use any of the following methods: - -- The constructor. - -- The method. - -- The method. - - These methods each supply a instance that you can further customize; the difference between them is how the instance is initialized before it is returned to your application. The constructor returns an instance of the class with the property set to `null`. When a request uses a instance in this state, no proxy is used to send the request. - - The method returns an instance of the class with the , , and properties set to the values used by the local computer. - - The method returns an instance of the class with it properties set according to a combination of Internet and configuration file settings. - - The class supports automatic detection and execution of proxy configuration scripts. This feature is also known as Web Proxy Auto-Discovery (WPAD). When using automatic proxy configuration, a configuration script, typically named Wpad.dat, must be located, downloaded, compiled, and run. If these operations are successful, the script returns the proxies that can be used for a request. - - - -## Examples - The following code example sets up an instance with a instance. The instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the class.) - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic WebProxy Example/CPP/source.cpp" id="Snippet1"::: + + To obtain instances of the Web proxy class, you can use any of the following methods: + +- The constructor. +- The method. +- The method. + + These methods each supply a instance that you can further customize; the difference between them is how the instance is initialized before it is returned to your application. The constructor returns an instance of the class with the property set to `null`. When a request uses a instance in this state, no proxy is used to send the request. + + The method returns an instance of the class with the , , and properties set to the values used by the local computer. + + The method returns an instance of the class with it properties set according to a combination of Internet and configuration file settings. + + The class supports automatic detection and execution of proxy configuration scripts. This feature is also known as Web Proxy Auto-Discovery (WPAD). When using automatic proxy configuration, a configuration script, typically named Wpad.dat, must be located, downloaded, compiled, and run. If these operations are successful, the script returns the proxies that can be used for a request. + + + +## Examples + The following code example sets up an instance with a instance. The instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the class.) + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic WebProxy Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic WebProxy Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -150,21 +147,20 @@ Initializes an empty instance of the class. - class with the property set to `null`. - - When the property is `null`, the method returns `true` and the method returns the destination address. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet1"::: - + class with the property set to `null`. + + When the property is `null`, the method returns `true` and the method returns the destination address. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet1"::: + ]]> @@ -209,19 +205,18 @@ The URI of the proxy server. Initializes a new instance of the class with the specified URI. - instance is initialized with the property set to a instance containing `Address`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet6"::: - + instance is initialized with the property set to a instance containing `Address`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet6"::: + ]]> @@ -274,19 +269,18 @@ A instance that contains the address of the proxy server. Initializes a new instance of the class from the specified instance. - instance is initialized with the property set to the `Address` parameter. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet2"::: - + instance is initialized with the property set to the `Address` parameter. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet2"::: + ]]> @@ -342,11 +336,11 @@ The context for the serialized data. Initializes an instance of the class using previously serialized content. - instance; applications do not call it. - + instance; applications do not call it. + ]]> @@ -394,19 +388,18 @@ to bypass the proxy for local addresses; otherwise, . Initializes a new instance of the class with the specified URI and bypass setting. - instance is initialized with the property set to a instance that contains `Address` and the property set to `BypassOnLocal`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet7"::: - + instance is initialized with the property set to a instance that contains `Address` and the property set to `BypassOnLocal`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet7"::: + ]]> @@ -455,19 +448,18 @@ The port number on to use. Initializes a new instance of the class with the specified host and port number. - instance is initialized with the property set to a instance of the form http:// `Host` : `Port`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet5"::: - + instance is initialized with the property set to a instance of the form http:// `Host` : `Port`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet5"::: + ]]> The URI formed by combining and is not a valid URI. @@ -522,19 +514,18 @@ to bypass the proxy for local addresses; otherwise, . Initializes a new instance of the class with the instance and bypass setting. - instance is initialized with the property set to `Address` and with the property set to `BypassOnLocal`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet3"::: - + instance is initialized with the property set to `Address` and with the property set to `BypassOnLocal`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet3"::: + ]]> @@ -595,19 +586,18 @@ An array of regular expression strings that contain the URIs of the servers to bypass. Initializes a new instance of the class with the specified URI, bypass setting, and list of URIs to bypass. - instance is initialized with the property set to a instance that contains `Address`, the property set to `BypassOnLocal`, and the property set to `BypassList`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet8"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet8"::: - + instance is initialized with the property set to a instance that contains `Address`, the property set to `BypassOnLocal`, and the property set to `BypassList`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet8"::: + ]]> @@ -678,19 +668,18 @@ An array of regular expression strings that contains the URIs of the servers to bypass. Initializes a new instance of the class with the specified instance, bypass setting, and list of URIs to bypass. - instance is initialized with the property set to `Address`, the property set to `BypassOnLocal`, and the property set to `BypassList`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet4"::: - + instance is initialized with the property set to `Address`, the property set to `BypassOnLocal`, and the property set to `BypassList`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet4"::: + ]]> @@ -753,19 +742,18 @@ An instance to submit to the proxy server for authentication. Initializes a new instance of the class with the specified URI, bypass setting, list of URIs to bypass, and credentials. - instance is initialized with the property set to a instance that contains `Address`, the property set to `BypassOnLocal`, the property set to `BypassList`, and the property set to `Credentials`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet9"::: - + instance is initialized with the property set to a instance that contains `Address`, the property set to `BypassOnLocal`, the property set to `BypassList`, and the property set to `Credentials`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet9"::: + ]]> @@ -832,19 +820,18 @@ An instance to submit to the proxy server for authentication. Initializes a new instance of the class with the specified instance, bypass setting, list of URIs to bypass, and credentials. - instance is initialized with the property set to `Address`, the property set to `BypassOnLocal`, the property set to `BypassList`, and the property set to `Credentials`. - - - -## Examples - The following code example demonstrates calling this constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet13"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet13"::: - + instance is initialized with the property set to `Address`, the property set to `BypassOnLocal`, the property set to `BypassList`, and the property set to `Credentials`. + + + +## Examples + The following code example demonstrates calling this constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet13"::: + ]]> @@ -889,21 +876,20 @@ Gets or sets the address of the proxy server. A instance that contains the address of the proxy server. - property contains the address of the proxy server. When automatic proxy detection is not enabled, and no automatic configuration script is specified, the property and determine the proxy used for a request. - - When the property is `null`, requests bypass the proxy and connect directly to the destination host. - - - -## Examples - The following code example displays the properties of a object, including its . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet1"::: - + property contains the address of the proxy server. When automatic proxy detection is not enabled, and no automatic configuration script is specified, the property and determine the proxy used for a request. + + When the property is `null`, requests bypass the proxy and connect directly to the destination host. + + + +## Examples + The following code example displays the properties of a object, including its . + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet1"::: + ]]> @@ -953,11 +939,11 @@ Gets a list of addresses that do not use the proxy server. An that contains a list of arrays that represents URIs that do not use the proxy server when accessed. - is an array list of regular expression strings that describe the URIs that are accessed directly instead of through the proxy server. - + is an array list of regular expression strings that describe the URIs that are accessed directly instead of through the proxy server. + ]]> @@ -1007,19 +993,18 @@ Gets or sets an array of addresses that do not use the proxy server. An array that contains a list of regular expressions that describe URIs that do not use the proxy server when accessed. - property contains an array of regular expressions that describe URIs that are accessed directly instead of through the proxy server. - - - -## Examples - The following code example displays the properties of a object, including its property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet1"::: - + property contains an array of regular expressions that describe URIs that are accessed directly instead of through the proxy server. + + + +## Examples + The following code example displays the properties of a object, including its property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet1"::: + ]]> @@ -1065,24 +1050,23 @@ to bypass the proxy server for local addresses; otherwise, . The default value is . - property determines whether to use the proxy server when accessing local Internet resources. - - If is `true`, requests to local Internet resources do not use the proxy server. Local requests are identified by the lack of a period (.) in the URI, as in `http://webserver/`, or access the local server, including `http://localhost`, `http://loopback`, or `http://127.0.0.1`. When is `false`, all Internet requests are made through the proxy server. - + property determines whether to use the proxy server when accessing local Internet resources. + + If is `true`, requests to local Internet resources do not use the proxy server. Local requests are identified by the lack of a period (.) in the URI, as in `http://webserver/`, or access the local server, including `http://localhost`, `http://loopback`, or `http://127.0.0.1`. When is `false`, all Internet requests are made through the proxy server. + > [!NOTE] -> Requests to a local host with a URI that contain a period use the proxy. To avoid using a proxy in these cases, create an entry for the host in the . - - - -## Examples - The following code example demonstrates calling a constructor that sets this property and getting the value of this property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet7"::: - +> Requests to a local host with a URI that contain a period use the proxy. To avoid using a proxy in these cases, create an entry for the host in the . + + + +## Examples + The following code example demonstrates calling a constructor that sets this property and getting the value of this property. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet7"::: + ]]> @@ -1140,14 +1124,14 @@ Gets or sets the credentials to submit to the proxy server for authentication. An instance that contains the credentials to submit to the proxy server for authentication. - property contains the authentication credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code. In most client scenarios, you should use the , which are the credentials of the currently logged on user. To do this, set the property to `true` instead of setting this property. - + property contains the authentication credentials to send to the proxy server in response to an HTTP 407 (proxy authorization) status code. In most client scenarios, you should use the , which are the credentials of the currently logged on user. To do this, set the property to `true` instead of setting this property. + > [!NOTE] -> If you set the property to credentials other than the , setting the property to `true` causes a . To prevent this, you must set the property to `null` before setting the property to `true`. Likewise, you cannot set this property to any value when is `true`. - +> If you set the property to credentials other than the , setting the property to `true` causes a . To prevent this, you must set the property to `null` before setting the property to `true`. Likewise, you cannot set this property to any value when is `true`. + ]]> You attempted to set this property when the property was set to . @@ -1207,24 +1191,23 @@ Reads the Internet options nondynamic proxy settings. A instance that contains the nondynamic proxy settings from Internet options. - method reads the nondynamic proxy settings from the computer's Internet options and creates a instance with those settings. - - The method does not pick up any dynamic settings that are generated from scripts run by Internet Explorer, from automatic configuration entries, or from DHCP or DNS lookups. - - Applications should use the property instead of the method. - + method reads the nondynamic proxy settings from the computer's Internet options and creates a instance with those settings. + + The method does not pick up any dynamic settings that are generated from scripts run by Internet Explorer, from automatic configuration entries, or from DHCP or DNS lookups. + + Applications should use the property instead of the method. + > [!NOTE] > This property is not supported on .NET Core. - -## Examples - The following code example demonstrates calling this method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet11"::: - + +## Examples + The following code example demonstrates calling this method. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet11"::: + ]]> On .NET Core. @@ -1273,11 +1256,11 @@ A that specifies the destination for this serialization. Populates a with the data that is needed to serialize the target object. - are automatically tracked and serialized by the formatter. - + are automatically tracked and serialized by the formatter. + ]]> @@ -1335,23 +1318,22 @@ Returns the proxied URI for a request. The instance of the Internet resource, if the resource is on the bypass list; otherwise, the instance of the proxy. - method returns the URI that the instance uses to access the Internet resource. - - compares `destination` with the contents of , using the method. If returns `true`, returns `destination` and the instance does not use the proxy server. - - If `destination` is not in , the instance uses the proxy server and the property is returned. - - - -## Examples - The following code example creates a object and calls this method to get the proxy that is selected for a resource. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLAutoProxy/CPP/proxy.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet2"::: - + method returns the URI that the instance uses to access the Internet resource. + + compares `destination` with the contents of , using the method. If returns `true`, returns `destination` and the instance does not use the proxy server. + + If `destination` is not in , the instance uses the proxy server and the property is returned. + + + +## Examples + The following code example creates a object and calls this method to get the proxy that is selected for a resource. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/Address/proxy.cs" id="Snippet2"::: + ]]> The parameter is . @@ -1404,31 +1386,30 @@ if the proxy server should not be used for ; otherwise, . - method is used to determine whether to bypass the proxy server when accessing an Internet resource. - - The and properties control the return value of the method. - - returns `true` under any of the following conditions: - -- If is `true` and `host` is a local URI. Local requests are identified by the lack of a period (.) in the URI, as in `http://webserver/`. - -- If `host` matches a regular expression in . - -- If is `null`. - - All other conditions return `false`. - - - -## Examples - The following code example creates a object and calls this method to check whether the bypass list is properly set. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebProxy/CPP/nclwebproxy.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet12"::: - + method is used to determine whether to bypass the proxy server when accessing an Internet resource. + + The and properties control the return value of the method. + + returns `true` under any of the following conditions: + +- If is `true` and `host` is a local URI. Local requests are identified by the lack of a period (.) in the URI, as in `http://webserver/`. + +- If `host` matches a regular expression in . + +- If is `null`. + + All other conditions return `false`. + + + +## Examples + The following code example creates a object and calls this method to check whether the bypass list is properly set. + + :::code language="csharp" source="~/snippets/csharp/System.Net/WebProxy/.ctor/nclwebproxy.cs" id="Snippet12"::: + ]]> The parameter is . @@ -1488,11 +1469,11 @@ A structure that indicates the destination for this serialization. Creates the serialization data and context that are used by the system to serialize a object. - @@ -1536,22 +1517,22 @@ if the default credentials are used; otherwise, . The default value is . - object should, if requested by the server, be authenticated using the credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios. For middle tier applications, such as ASP.NET applications, instead of using this property, you would typically set the property to the credentials of the client on whose behalf the request is made. - - The following table shows the effect of setting the value, based on the value of the property. - -| value| value|Effect| -|----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|------------| -||`true`|No effect.| -||`false`| is set to `null`.| -|`null`|`true`| is set to .| -|Any value other than or `null`|`true` or `false`|Setting throws an exception.| - - If is `false`, you can change the property to any credentials. If is `true`, changing the property from (the value that is set when the property is set to `true`) will throw an exception. - + object should, if requested by the server, be authenticated using the credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios. For middle tier applications, such as ASP.NET applications, instead of using this property, you would typically set the property to the credentials of the client on whose behalf the request is made. + + The following table shows the effect of setting the value, based on the value of the property. + +| value| value|Effect| +|----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|------------| +||`true`|No effect.| +||`false`| is set to `null`.| +|`null`|`true`| is set to .| +|Any value other than or `null`|`true` or `false`|Setting throws an exception.| + + If is `false`, you can change the property to any credentials. If is `true`, changing the property from (the value that is set when the property is set to `true`) will throw an exception. + ]]> You attempted to set this property when the property contains credentials other than the default credentials. diff --git a/xml/System.Net/WebRequest.xml b/xml/System.Net/WebRequest.xml index 16717bf0597..694bb8620a8 100644 --- a/xml/System.Net/WebRequest.xml +++ b/xml/System.Net/WebRequest.xml @@ -95,7 +95,6 @@ ## Examples The following example shows how to create a instance and return the response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/Overview/webrequestget.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebRequestSimple/VB/webrequestget.vb" id="Snippet1"::: @@ -173,7 +172,6 @@ ## Examples The following example shows how to create a instance by calling the method on the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic WebRequest.WebRequest Example/VB/source.vb" id="Snippet1"::: @@ -379,7 +377,6 @@ ## Examples The following code example sets the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet1"::: ]]> @@ -456,7 +453,6 @@ ## Examples The following example uses the to asynchronously obtain the request stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/BeginGetRequestStream/webrequest_begingetrequest.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetRequest/VB/webrequest_begingetrequest.vb" id="Snippet3"::: @@ -623,7 +619,6 @@ ## Examples The following code example demonstrates setting the cache policy for a Web request. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLSimpleCache/CPP/NCLSimpleCache.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/CachePolicy/example.cs" id="Snippet2"::: ]]> @@ -764,7 +759,6 @@ ## Examples The following example sets the property to the amount of bytes in the outgoing byte buffer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/ContentLength/webrequest_contenttype.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_ContentType/VB/webrequest_contenttype.vb" id="Snippet4"::: @@ -843,7 +837,6 @@ ## Examples The following example sets the property to the appropriate media type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/ContentLength/webrequest_contenttype.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_ContentType/VB/webrequest_contenttype.vb" id="Snippet4"::: @@ -946,7 +939,6 @@ ## Examples The following example uses to instantiate an instance. A string representing the target URL is used as the constructor parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/Create/webresponse_responseuri.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_ResponseUri/VB/webresponse_responseuri.vb" id="Snippet1"::: @@ -1048,7 +1040,6 @@ Note: In .NET for Win ## Examples The following example uses to instantiate an instance. A Uri representing the target URL is used as the constructor parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_Create/CPP/webrequest_create.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/Create/webrequest_create.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_Create/VB/webrequest_create.vb" id="Snippet1"::: @@ -1399,7 +1390,6 @@ This property allows an application to determine which property using the default credentials of the current user. When the request is made, credentials stored in this property are used to validate the client. This is identical to setting the property to `true`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLWebRequestSimple/CPP/webrequestget.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/Overview/webrequestget.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLWebRequestSimple/VB/webrequestget.vb" id="Snippet2"::: @@ -1480,7 +1470,6 @@ This property allows an application to determine which @@ -1627,7 +1616,6 @@ This property allows an application to determine which . The method completes the asynchronous call to . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/BeginGetRequestStream/webrequest_begingetrequest.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetRequest/VB/webrequest_begingetrequest.vb" id="Snippet3"::: @@ -1837,7 +1825,6 @@ This property allows an application to determine which method to obtain a stream and then writes data that stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_ContentType/CPP/webrequest_contenttype.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/ContentLength/webrequest_contenttype.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_ContentType/VB/webrequest_contenttype.vb" id="Snippet4"::: @@ -1970,7 +1957,6 @@ This property allows an application to determine which property to 10000 milliseconds. If the timeout period expires before the resource can be returned, a is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/GetResponse/webrequest_timeout.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_Timeout/VB/webrequest_timeout.vb" id="Snippet1"::: @@ -2155,7 +2141,6 @@ This property allows an application to determine which property to POST to indicate that the request will post data to the target host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_BeginGetRequest/CPP/webrequest_begingetrequest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/BeginGetRequestStream/webrequest_begingetrequest.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_BeginGetRequest/VB/webrequest_begingetrequest.vb" id="Snippet3"::: @@ -2430,7 +2414,6 @@ This property allows an application to determine which property to determine the site originally requested. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_RequestUri1/CPP/webrequest_requesturi.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/RequestUri/webrequest_requesturi.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_RequestUri1/VB/webrequest_requesturi.vb" id="Snippet1"::: @@ -2768,7 +2750,6 @@ This property allows an application to determine which property to 10000 milliseconds. If the timeout period expires before the resource can be returned, a is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebRequest_Timeout/CPP/webrequest_timeout.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/GetResponse/webrequest_timeout.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebRequest_Timeout/VB/webrequest_timeout.vb" id="Snippet1"::: diff --git a/xml/System.Net/WebResponse.xml b/xml/System.Net/WebResponse.xml index 725a079bf17..3f1f962cf09 100644 --- a/xml/System.Net/WebResponse.xml +++ b/xml/System.Net/WebResponse.xml @@ -88,7 +88,6 @@ ## Examples The following example creates a instance from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic WebRequest Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic WebRequest Example/VB/source.vb" id="Snippet1"::: @@ -292,7 +291,6 @@ ## Examples The following example uses the method to close the `WebResponse`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_Close/CPP/webresponse_close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/Close/webresponse_close.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_Close/VB/webresponse_close.vb" id="Snippet1"::: @@ -362,7 +360,6 @@ ## Examples The following example uses the property to obtain the Length of the resource returned. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/ContentLength/webresponse_contentlength_type.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_ContentLength_Type/VB/webresponse_contentlength_type.vb" id="Snippet1"::: @@ -432,7 +429,6 @@ ## Examples The following example uses the property to obtain the content type of the response. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_ContentLength_Type/CPP/webresponse_contentlength_type.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/ContentLength/webresponse_contentlength_type.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_ContentLength_Type/VB/webresponse_contentlength_type.vb" id="Snippet1"::: @@ -679,7 +675,6 @@ ## Examples The following example uses to return a instance. A small local buffer is used to read data from the and output it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_GetResponseStream/CPP/webresponse_getresponsestream.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/GetResponseStream/webresponse_getresponsestream.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_GetResponseStream/VB/webresponse_getresponsestream.vb" id="Snippet1"::: @@ -745,7 +740,6 @@ ## Examples The following example displays all of the header name-value pairs returned in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_Headers/CPP/webresponse_headers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebResponse/Headers/webresponse_headers.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_Headers/VB/webresponse_headers.vb" id="Snippet1"::: @@ -869,7 +863,6 @@ ## Examples The following code example checks the value of this property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLCredPolicy/CPP/NCLCredPolicy.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/IntranetZoneCredentialPolicy/Overview/websample.cs" id="Snippet1"::: ]]> @@ -935,7 +928,6 @@ ## Examples The following example uses the property to determine the location from which the originated. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebResponse_ResponseUri/CPP/webresponse_responseuri.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Net/WebRequest/Create/webresponse_responseuri.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/WebResponse_ResponseUri/VB/webresponse_responseuri.vb" id="Snippet1":::