Ejemplo n.º 1
0
		public CodeWriter AddChildNoIndent(string name)
		{
			this.Line(name);
			CodeWriter codeWriter = new CodeWriter();
			codeWriter.depth = this.depth + 1;
			this.children.Add(codeWriter);
			return codeWriter;
		}
Ejemplo n.º 2
0
 public CodeWriter AddChildNoIndent(string name)
 {
     Line(name);
     CodeWriter child =  new CodeWriter();
     child.depth = depth+1;
     children.Add(child);
     return child;
 }
 public CodeWriter AddChildNoIndent(string name)
 {
     this.Line(name);
     CodeWriter writer = new CodeWriter {
         depth = this.depth + 1
     };
     this.children.Add(writer);
     return writer;
 }
Ejemplo n.º 4
0
		public CodeWriter AddChild(CodeWriter snippet)
		{
			snippet.depth = this.depth;
			this.children.Add(snippet);
			return snippet;
		}
Ejemplo n.º 5
0
		public void RegisterAssemblySpecificSchema()
		{
			SecurityHelper.UnmanagedCode.Demand();
			Type[] instrumentedTypes = InstrumentedAttribute.GetInstrumentedTypes(this.assembly);
			StringCollection stringCollections = new StringCollection();
			StringCollection stringCollections1 = new StringCollection();
			StringCollection stringCollections2 = new StringCollection();
			string[] mofFormat = new string[(int)instrumentedTypes.Length];
			CodeWriter codeWriter = new CodeWriter();
			ReferencesCollection referencesCollection = new ReferencesCollection();
			codeWriter.AddChild(referencesCollection.UsingCode);
			referencesCollection.Add(typeof(object));
			referencesCollection.Add(typeof(ManagementClass));
			referencesCollection.Add(typeof(Marshal));
			referencesCollection.Add(typeof(SuppressUnmanagedCodeSecurityAttribute));
			referencesCollection.Add(typeof(FieldInfo));
			referencesCollection.Add(typeof(Hashtable));
			codeWriter.Line();
			CodeWriter codeWriter1 = codeWriter.AddChild("public class WMINET_Converter");
			codeWriter1.Line("public static Hashtable mapTypeToConverter = new Hashtable();");
			CodeWriter codeWriter2 = codeWriter1.AddChild("static WMINET_Converter()");
			Hashtable hashtables = new Hashtable();
			for (int i = 0; i < (int)instrumentedTypes.Length; i++)
			{
				hashtables[instrumentedTypes[i]] = string.Concat("ConvertClass_", i);
			}
			bool beCompared = this.IsSchemaToBeCompared();
			bool flag = false;
			if (!beCompared)
			{
				flag = !this.IsAssemblyRegistered();
			}
			for (int j = 0; j < (int)instrumentedTypes.Length; j++)
			{
				SchemaMapping schemaMapping = new SchemaMapping(instrumentedTypes[j], this, hashtables);
				codeWriter2.Line(string.Format("mapTypeToConverter[typeof({0})] = typeof({1});", schemaMapping.ClassType.FullName.Replace('+', '.'), schemaMapping.CodeClassName));
				if (beCompared && !this.IsClassAlreadyPresentInRepository(schemaMapping.NewClass))
				{
					flag = true;
				}
				SchemaNaming.ReplaceClassIfNecessary(schemaMapping.ClassPath, schemaMapping.NewClass);
				mofFormat[j] = SchemaNaming.GetMofFormat(schemaMapping.NewClass);
				codeWriter.AddChild(schemaMapping.Code);
				InstrumentationType instrumentationType = schemaMapping.InstrumentationType;
				switch (instrumentationType)
				{
					case InstrumentationType.Instance:
					{
						stringCollections1.Add(schemaMapping.ClassName);
						break;
					}
					case InstrumentationType.Event:
					{
						stringCollections.Add(schemaMapping.ClassName);
						break;
					}
					case InstrumentationType.Abstract:
					{
						stringCollections2.Add(schemaMapping.ClassName);
						break;
					}
				}
			}
			this.RegisterAssemblySpecificDecoupledProviderInstance();
			this.RegisterProviderAsEventProvider(stringCollections);
			this.RegisterProviderAsInstanceProvider();
			this.RegisterAssemblyAsInstrumented();
			Directory.CreateDirectory(this.DataDirectory);
			using (StreamWriter streamWriter = new StreamWriter(this.CodePath, false, Encoding.Unicode))
			{
				streamWriter.WriteLine(codeWriter);
				streamWriter.WriteLine(string.Concat("class IWOA\r\n{\r\nprotected const string DllName = \"wminet_utils.dll\";\r\nprotected const string EntryPointName = \"UFunc\";\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"GetPropertyHandle\")] public static extern int GetPropertyHandle_f27(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)]  string   wszPropertyName, [Out] out Int32 pType, [Out] out Int32 plHandle);\r\n//[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref Byte aData);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"ReadPropertyValue\")] public static extern int ReadPropertyValue_f29(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lBufferSize, [Out] out Int32 plNumBytes, [Out] out Byte aData);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"ReadDWORD\")] public static extern int ReadDWORD_f30(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [Out] out UInt32 pdw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteDWORD\")] public static extern int WriteDWORD_f31(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] UInt32 dw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"ReadQWORD\")] public static extern int ReadQWORD_f32(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [Out] out UInt64 pqw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteQWORD\")] public static extern int WriteQWORD_f33(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] UInt64 pw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"GetPropertyInfoByHandle\")] public static extern int GetPropertyInfoByHandle_f34(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [Out][MarshalAs(UnmanagedType.BStr)]  out string   pstrName, [Out] out Int32 pType);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"Lock\")] public static extern int Lock_f35(int vFunc, IntPtr pWbemClassObject, [In] Int32 lFlags);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"Unlock\")] public static extern int Unlock_f36(int vFunc, IntPtr pWbemClassObject, [In] Int32 lFlags);\r\n\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"Put\")] public static extern int Put_f5(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)]  string   wszName, [In] Int32 lFlags, [In] ref object pVal, [In] Int32 Type);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In][MarshalAs(UnmanagedType.LPWStr)] string str);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref Byte n);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref SByte n);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref Int16 n);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\")] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref UInt16 n);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WritePropertyValue\", CharSet=CharSet.Unicode)] public static extern int WritePropertyValue_f28(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 lNumBytes, [In] ref Char c);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteDWORD\")] public static extern int WriteDWORD_f31(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int32 dw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteSingle\")] public static extern int WriteDWORD_f31(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Single dw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteQWORD\")] public static extern int WriteQWORD_f33(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Int64 pw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"WriteDouble\")] public static extern int WriteQWORD_f33(int vFunc, IntPtr pWbemClassObject, [In] Int32 lHandle, [In] Double pw);\r\n[SuppressUnmanagedCodeSecurity, DllImport(DllName, EntryPoint=\"Clone\")] public static extern int Clone_f(int vFunc, IntPtr pWbemClassObject, [Out] out IntPtr ppCopy);\r\n}\r\ninterface IWmiConverter\r\n{\r\n    void ToWMI(object obj);\r\n    ManagementObject GetInstance();\r\n}\r\nclass SafeAssign\r\n{\r\n    public static UInt16 boolTrue = 0xffff;\r\n    public static UInt16 boolFalse = 0;\r\n    static Hashtable validTypes = new Hashtable();\r\n    static SafeAssign()\r\n    {\r\n        validTypes.Add(typeof(SByte), null);\r\n        validTypes.Add(typeof(Byte), null);\r\n        validTypes.Add(typeof(Int16), null);\r\n        validTypes.Add(typeof(UInt16), null);\r\n        validTypes.Add(typeof(Int32), null);\r\n        validTypes.Add(typeof(UInt32), null);\r\n        validTypes.Add(typeof(Int64), null);\r\n        validTypes.Add(typeof(UInt64), null);\r\n        validTypes.Add(typeof(Single), null);\r\n        validTypes.Add(typeof(Double), null);\r\n        validTypes.Add(typeof(Boolean), null);\r\n        validTypes.Add(typeof(String), null);\r\n        validTypes.Add(typeof(Char), null);\r\n        validTypes.Add(typeof(DateTime), null);\r\n        validTypes.Add(typeof(TimeSpan), null);\r\n        validTypes.Add(typeof(ManagementObject), null);\r\n        nullClass.SystemProperties [\"__CLASS\"].Value = \"nullInstance\";\r\n    }\r\n    public static object GetInstance(object o)\r\n    {\r\n        if(o is ManagementObject)\r\n            return o;\r\n        return null;\r\n    }\r\n    static ManagementClass nullClass = new ManagementClass(new ManagementPath(@\"", this.NamespaceName, "\"));\r\n    \r\n    public static ManagementObject GetManagementObject(object o)\r\n    {\r\n        if(o != null && o is ManagementObject)\r\n            return o as ManagementObject;\r\n        // Must return empty instance\r\n        return nullClass.CreateInstance();\r\n    }\r\n    public static object GetValue(object o)\r\n    {\r\n        Type t = o.GetType();\r\n        if(t.IsArray)\r\n            t = t.GetElementType();\r\n        if(validTypes.Contains(t))\r\n            return o;\r\n        return null;\r\n    }\r\n    public static string WMITimeToString(DateTime dt)\r\n    {\r\n        TimeSpan ts = dt.Subtract(dt.ToUniversalTime());\r\n        int diffUTC = (ts.Minutes + ts.Hours * 60);\r\n        if(diffUTC >= 0)\r\n            return String.Format(\"{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}.{6:D3}000+{7:D3}\", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, diffUTC);\r\n        return String.Format(\"{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}.{6:D3}000-{7:D3}\", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond, -diffUTC);\r\n    }\r\n    public static string WMITimeToString(TimeSpan ts)\r\n    {\r\n        return String.Format(\"{0:D8}{1:D2}{2:D2}{3:D2}.{4:D3}000:000\", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);\r\n    }\r\n    public static string[] WMITimeArrayToStringArray(DateTime[] dates)\r\n    {\r\n        string[] strings = new string[dates.Length];\r\n        for(int i=0;i<dates.Length;i++)\r\n            strings[i] = WMITimeToString(dates[i]);\r\n        return strings;\r\n    }\r\n    public static string[] WMITimeArrayToStringArray(TimeSpan[] timeSpans)\r\n    {\r\n        string[] strings = new string[timeSpans.Length];\r\n        for(int i=0;i<timeSpans.Length;i++)\r\n            strings[i] = WMITimeToString(timeSpans[i]);\r\n        return strings;\r\n    }\r\n}\r\n"));
			}
			using (StreamWriter streamWriter1 = new StreamWriter(this.MofPath, false, Encoding.Unicode))
			{
				streamWriter1.WriteLine(this.GenerateMof(mofFormat));
			}
			if (flag)
			{
				SchemaNaming.RegisterSchemaUsingMofcomp(this.MofPath);
			}
		}
Ejemplo n.º 6
0
		public void RegisterAssemblySpecificSchema()
		{
			SecurityHelper.UnmanagedCode.Demand(); // Bug#112640 - Close off any potential use from anything but fully trusted code

			Type[] types = InstrumentedAttribute.GetInstrumentedTypes(assembly);
			StringCollection events = new StringCollection();
			StringCollection instances = new StringCollection();
			StringCollection abstracts = new StringCollection();
			string[] mofs = new string[types.Length];
			CodeWriter code = new CodeWriter();
			ReferencesCollection references = new ReferencesCollection();

			// Add the node with all the 'using' statements at the top
			code.AddChild(references.UsingCode);
			references.Add(typeof(Object));
			references.Add(typeof(ManagementClass));
			references.Add(typeof(Marshal));
			references.Add(typeof(System.Security.SuppressUnmanagedCodeSecurityAttribute));
			references.Add(typeof(System.Reflection.FieldInfo));
			references.Add(typeof(Hashtable));

			// Add a blank line
			code.Line();

			// Add master converter class
			CodeWriter codeWMIConverter = code.AddChild("public class WMINET_Converter");
            
			// Add master map of types to converters
			codeWMIConverter.Line("public static Hashtable mapTypeToConverter = new Hashtable();");
          
			// Add master CCTOR
			CodeWriter codeCCTOR = codeWMIConverter.AddChild("static WMINET_Converter()");

			// Make mapping of types to converter class names
			Hashtable mapTypeToConverterClassName = new Hashtable();

			for(int i=0;i<types.Length;i++)
				mapTypeToConverterClassName[types[i]] = "ConvertClass_" + i;

			// [[....]] VSUQFE#2248 (VSWhidbey 231885)
			bool bSchemaToBeCompared = IsSchemaToBeCompared();
			bool bNewClassToCompile = false;

			// Mof compilation is dictated by, whether the assembly is registered as instrumented or not
			if (bSchemaToBeCompared == false)
			{
				bNewClassToCompile = !IsAssemblyRegistered();
			}

			for(int i=0;i<types.Length;i++)
			{
				SchemaMapping mapping = new SchemaMapping(types[i], this, mapTypeToConverterClassName);

				codeCCTOR.Line(String.Format("mapTypeToConverter[typeof({0})] = typeof({1});", mapping.ClassType.FullName.Replace('+', '.'), mapping.CodeClassName));  // bug#92918 - watch for nested classes
				// [[....]] VSUQFE#2248 (VSWhidbey 231885)
				if (bSchemaToBeCompared == true && IsClassAlreadyPresentInRepository(mapping.NewClass) == false)
				{
					bNewClassToCompile = true;
				}

				ReplaceClassIfNecessary(mapping.ClassPath, mapping.NewClass);

				mofs[i] = GetMofFormat(mapping.NewClass);
				code.AddChild(mapping.Code);
				switch(mapping.InstrumentationType)
				{
					case InstrumentationType.Event:
						events.Add(mapping.ClassName);
						break;

					case InstrumentationType.Instance:
						instances.Add(mapping.ClassName);
						break;

					case InstrumentationType.Abstract:
						abstracts.Add(mapping.ClassName);
						break;

					default:
						break;
				}
			}

			RegisterAssemblySpecificDecoupledProviderInstance();
			RegisterProviderAsEventProvider(events);
			RegisterProviderAsInstanceProvider();
			RegisterAssemblyAsInstrumented();
			Directory.CreateDirectory(DataDirectory);
			using(StreamWriter log = new StreamWriter(CodePath, false, Encoding.Unicode))
			{
				log.WriteLine(code);
				log.WriteLine(iwoaDef+"new ManagementPath(@\""+this.NamespaceName+"\")"+iwoaDefEnd);
			}

			// Always generate the MOF in unicode
			using(StreamWriter log = new StreamWriter(MofPath, false, Encoding.Unicode))
			{
				log.WriteLine(GenerateMof(mofs));
			}

			// [[....]] VSUQFE#2248 (VSWhidbey 231885)
			// Write the mof to a file and compile it only if there are any new classes , apart from
			// what is there in the repository
			if (bNewClassToCompile == true)
			{
			RegisterSchemaUsingMofcomp ( MofPath ) ;
			//WMICapabilities.AddAutorecoverMof(MofPath);
		}
		}
Ejemplo n.º 7
0
		public ReferencesCollection()
		{
			this.namespaces = new StringCollection();
			this.assemblies = new StringCollection();
			this.usingCode = new CodeWriter();
		}
Ejemplo n.º 8
0
		public SchemaMapping(Type type, SchemaNaming naming, Hashtable mapTypeToConverterClassName)
		{
			int num;
			bool flag;
			MemberInfo memberInfo;
			FieldInfo fieldInfo;
			PropertyInfo propertyInfo;
			MethodInfo getMethod;
			string memberName;
			Type propertyType;
			bool flag1;
			string str;
			string item;
			bool flag2;
			DictionaryEntry dictionaryEntry;
			string str1;
			string str2;
			CodeWriter codeWriter;
			CodeWriter codeWriter1;
			CodeWriter codeWriter2;
			CodeWriter codeWriter3;
			CodeWriter codeWriter4;
			CodeWriter codeWriter5;
			CodeWriter codeWriter6;
			CodeWriter codeWriter7;
			CodeWriter codeWriter8;
			CodeWriter codeWriter9;
			CodeWriter codeWriter10;
			CodeWriter codeWriter11;
			CodeWriter codeWriter12;
			CimType cimType;
			bool flag3;
			PropertyData propertyDatum;
			PropertyData item1;
			PropertyData propertyDatum1;
			MemberInfo[] members;
			int i;
			int num1;
			this.code = new CodeWriter();
			this.codeClassName = (string)mapTypeToConverterClassName[type];
			this.classType = type;
			bool flag4 = false;
			string baseClassName = ManagedNameAttribute.GetBaseClassName(type);
			this.className = ManagedNameAttribute.GetMemberName(type);
			this.instrumentationType = InstrumentationClassAttribute.GetAttribute(type).InstrumentationType;
			this.classPath = string.Concat(naming.NamespaceName, ":", this.className);
			if (baseClassName != null)
			{
				ManagementClass managementClass = new ManagementClass(string.Concat(naming.NamespaceName, ":", baseClassName));
				if (this.instrumentationType == InstrumentationType.Instance)
				{
					bool value = false;
					try
					{
						QualifierData qualifierDatum = managementClass.Qualifiers["abstract"];
						if (qualifierDatum.Value is bool)
						{
							value = (bool)qualifierDatum.Value;
						}
					}
					catch (ManagementException managementException1)
					{
						ManagementException managementException = managementException1;
						if (managementException.ErrorCode != ManagementStatus.NotFound)
						{
							throw;
						}
					}
					if (!value)
					{
						throw new Exception(RC.GetString("CLASSINST_EXCEPT"));
					}
				}
				this.newClass = managementClass.Derive(this.className);
			}
			else
			{
				this.newClass = new ManagementClass(naming.NamespaceName, "", null);
				this.newClass.SystemProperties["__CLASS"].Value = this.className;
			}
			CodeWriter codeWriter13 = this.code.AddChild(string.Concat("public class ", this.codeClassName, " : IWmiConverter"));
			CodeWriter codeWriter14 = codeWriter13.AddChild(new CodeWriter());
			codeWriter14.Line(string.Concat("static ManagementClass managementClass = new ManagementClass(@\"", this.classPath, "\");"));
			codeWriter14.Line("static IntPtr classWbemObjectIP;");
			codeWriter14.Line("static Guid iidIWbemObjectAccess = new Guid(\"49353C9A-516B-11D1-AEA6-00C04FB68820\");");
			codeWriter14.Line("internal ManagementObject instance = managementClass.CreateInstance();");
			codeWriter14.Line("object reflectionInfoTempObj = null ; ");
			codeWriter14.Line("FieldInfo reflectionIWbemClassObjectField = null ; ");
			codeWriter14.Line("IntPtr emptyWbemObject = IntPtr.Zero ; ");
			codeWriter14.Line("IntPtr originalObject = IntPtr.Zero ; ");
			codeWriter14.Line("bool toWmiCalled = false ; ");
			codeWriter14.Line("IntPtr theClone = IntPtr.Zero;");
			codeWriter14.Line("public static ManagementObject emptyInstance = managementClass.CreateInstance();");
			codeWriter14.Line("public IntPtr instWbemObjectAccessIP;");
			CodeWriter codeWriter15 = codeWriter13.AddChild(string.Concat("static ", this.codeClassName, "()"));
			codeWriter15.Line("classWbemObjectIP = (IntPtr)managementClass;");
			codeWriter15.Line("IntPtr wbemObjectAccessIP;");
			codeWriter15.Line("Marshal.QueryInterface(classWbemObjectIP, ref iidIWbemObjectAccess, out wbemObjectAccessIP);");
			codeWriter15.Line("int cimType;");
			CodeWriter codeWriter16 = codeWriter13.AddChild(string.Concat("public ", this.codeClassName, "()"));
			codeWriter16.Line("IntPtr wbemObjectIP = (IntPtr)instance;");
			codeWriter16.Line("originalObject = (IntPtr)instance;");
			codeWriter16.Line("Marshal.QueryInterface(wbemObjectIP, ref iidIWbemObjectAccess, out instWbemObjectAccessIP);");
			codeWriter16.Line("FieldInfo tempField = instance.GetType().GetField ( \"_wbemObject\", BindingFlags.Instance | BindingFlags.NonPublic );");
			codeWriter16.Line("if ( tempField == null )");
			codeWriter16.Line("{");
			codeWriter16.Line("   tempField = instance.GetType().GetField ( \"wbemObject\", BindingFlags.Instance | BindingFlags.NonPublic ) ;");
			codeWriter16.Line("}");
			codeWriter16.Line("reflectionInfoTempObj = tempField.GetValue (instance) ;");
			codeWriter16.Line("reflectionIWbemClassObjectField = reflectionInfoTempObj.GetType().GetField (\"pWbemClassObject\", BindingFlags.Instance | BindingFlags.NonPublic );");
			codeWriter16.Line("emptyWbemObject = (IntPtr) emptyInstance;");
			CodeWriter codeWriter17 = codeWriter13.AddChild(string.Concat("~", this.codeClassName, "()"));
			codeWriter17.AddChild("if(instWbemObjectAccessIP != IntPtr.Zero)").Line("Marshal.Release(instWbemObjectAccessIP);");
			codeWriter17.Line("if ( toWmiCalled == true )");
			codeWriter17.Line("{");
			codeWriter17.Line("\tMarshal.Release (originalObject);");
			codeWriter17.Line("}");
			CodeWriter codeWriter18 = codeWriter13.AddChild("public void ToWMI(object obj)");
			codeWriter18.Line("toWmiCalled = true ;");
			codeWriter18.Line("if(instWbemObjectAccessIP != IntPtr.Zero)");
			codeWriter18.Line("{");
			codeWriter18.Line("    Marshal.Release(instWbemObjectAccessIP);");
			codeWriter18.Line("    instWbemObjectAccessIP = IntPtr.Zero;");
			codeWriter18.Line("}");
			codeWriter18.Line("if(theClone != IntPtr.Zero)");
			codeWriter18.Line("{");
			codeWriter18.Line("    Marshal.Release(theClone);");
			codeWriter18.Line("    theClone = IntPtr.Zero;");
			codeWriter18.Line("}");
			codeWriter18.Line("IWOA.Clone_f(12, emptyWbemObject, out theClone) ;");
			codeWriter18.Line("Marshal.QueryInterface(theClone, ref iidIWbemObjectAccess, out instWbemObjectAccessIP) ;");
			codeWriter18.Line("reflectionIWbemClassObjectField.SetValue ( reflectionInfoTempObj, theClone ) ;");
			codeWriter18.Line(string.Format("{0} instNET = ({0})obj;", type.FullName.Replace('+', '.')));
			CodeWriter codeWriter19 = codeWriter13.AddChild(string.Concat("public static explicit operator IntPtr(", this.codeClassName, " obj)"));
			codeWriter19.Line("return obj.instWbemObjectAccessIP;");
			codeWriter14.Line("public ManagementObject GetInstance() {return instance;}");
			PropertyDataCollection properties = this.newClass.Properties;
			InstrumentationType instrumentationType = this.instrumentationType;
			switch (instrumentationType)
			{
				case InstrumentationType.Instance:
				{
					properties.Add("ProcessId", CimType.String, false);
					properties.Add("InstanceId", CimType.String, false);
					properties["ProcessId"].Qualifiers.Add("key", true);
					properties["InstanceId"].Qualifiers.Add("key", true);
					this.newClass.Qualifiers.Add("dynamic", true, false, false, false, true);
					this.newClass.Qualifiers.Add("provider", naming.DecoupledProviderInstanceName, false, false, false, true);
					num = 0;
					flag = false;
					members = type.GetMembers();
					for (i = 0; i < (int)members.Length; i++)
					{
						memberInfo = members[i];
						if ((memberInfo as FieldInfo != null || memberInfo as PropertyInfo != null) && (int)memberInfo.GetCustomAttributes(typeof(IgnoreMemberAttribute), false).Length <= 0)
						{
							if (memberInfo as FieldInfo == null)
							{
								if (memberInfo as PropertyInfo != null)
								{
									propertyInfo = memberInfo as PropertyInfo;
									if (!propertyInfo.CanRead)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									getMethod = propertyInfo.GetGetMethod();
									if (null == getMethod || getMethod.IsStatic)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									if ((int)getMethod.GetParameters().Length > 0)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
								}
							}
							else
							{
								fieldInfo = memberInfo as FieldInfo;
								if (fieldInfo.IsStatic)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
							}
							memberName = ManagedNameAttribute.GetMemberName(memberInfo);
							if (memberInfo as FieldInfo == null)
							{
								propertyType = (memberInfo as PropertyInfo).PropertyType;
							}
							else
							{
								propertyType = (memberInfo as FieldInfo).FieldType;
							}
							flag1 = false;
							if (propertyType.IsArray)
							{
								if (propertyType.GetArrayRank() != 1)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
								flag1 = true;
								propertyType = propertyType.GetElementType();
							}
							str = null;
							item = null;
							if (mapTypeToConverterClassName.Contains(propertyType))
							{
								item = (string)mapTypeToConverterClassName[propertyType];
								str = ManagedNameAttribute.GetMemberName(propertyType);
							}
							flag2 = false;
							if (propertyType == typeof(object))
							{
								flag2 = true;
								if (!flag4)
								{
									flag4 = true;
									codeWriter14.Line("static Hashtable mapTypeToConverter = new Hashtable();");
									foreach (DictionaryEntry dictionaryEntry1 in mapTypeToConverterClassName)
									{
										codeWriter15.Line(string.Format("mapTypeToConverter[typeof({0})] = typeof({1});", ((Type)dictionaryEntry1.Key).FullName.Replace('+', '.'), (string)dictionaryEntry1.Value));
									}
								}
							}
							str1 = string.Concat("prop_", (object)num);
							num1 = num;
							num = num1 + 1;
							str2 = string.Concat("handle_", (object)num1);
							codeWriter14.Line(string.Concat("static int ", str2, ";"));
							codeWriter15.Line(string.Format("IWOA.GetPropertyHandle_f27(27, wbemObjectAccessIP, \"{0}\", out cimType, out {1});", memberName, str2));
							codeWriter14.Line(string.Concat("PropertyData ", str1, ";"));
							codeWriter16.Line(string.Format("{0} = instance.Properties[\"{1}\"];", str1, memberName));
							if (!flag2)
							{
								if (str == null)
								{
									if (flag1)
									{
										if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
										{
											codeWriter18.AddChild(string.Format("if(null == instNET.{0})", memberInfo.Name)).Line(string.Format("{0}.Value = null;", str1));
											codeWriter18.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.WMITimeArrayToStringArray(instNET.{1});", str1, memberInfo.Name));
										}
										else
										{
											codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
										}
									}
									else
									{
										if (propertyType == typeof(byte) || propertyType == typeof(sbyte))
										{
											codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
											codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 1, ref instNET_{1});", str2, memberInfo.Name));
										}
										else
										{
											if (propertyType == typeof(short) || propertyType == typeof(ushort) || propertyType == typeof(char))
											{
												codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
												codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref instNET_{1});", str2, memberInfo.Name));
											}
											else
											{
												if (propertyType == typeof(uint) || propertyType == typeof(int) || propertyType == typeof(float))
												{
													codeWriter18.Line(string.Format("IWOA.WriteDWORD_f31(31, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
												}
												else
												{
													if (propertyType == typeof(ulong) || propertyType == typeof(long) || propertyType == typeof(double))
													{
														codeWriter18.Line(string.Format("IWOA.WriteQWORD_f33(33, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
													}
													else
													{
														if (propertyType != typeof(bool))
														{
															if (propertyType != typeof(string))
															{
																if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
																{
																	codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 52, SafeAssign.WMITimeToString(instNET.{1}));", str2, memberInfo.Name));
																}
																else
																{
																	codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
																}
															}
															else
															{
																codeWriter12 = codeWriter18.AddChild(string.Format("if(null != instNET.{0})", memberInfo.Name));
																codeWriter12.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, (instNET.{1}.Length+1)*2, instNET.{1});", str2, memberInfo.Name));
																codeWriter18.AddChild("else").Line(string.Format("IWOA.Put_f5(5, instWbemObjectAccessIP, \"{0}\", 0, ref nullObj, 8);", memberName));
																if (!flag)
																{
																	flag = true;
																	codeWriter14.Line("object nullObj = DBNull.Value;");
																}
															}
														}
														else
														{
															codeWriter18.Line(string.Format("if(instNET.{0})", memberInfo.Name));
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolTrue);", str2));
															codeWriter18.Line("else");
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolFalse);", str2));
														}
													}
												}
											}
										}
									}
								}
								else
								{
									if (!propertyType.IsValueType)
									{
										codeWriter5 = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
										codeWriter6 = codeWriter18.AddChild("else");
										codeWriter6.Line(string.Format("{0}.Value = null;", str1));
									}
									else
									{
										codeWriter5 = codeWriter18;
									}
									if (!flag1)
									{
										codeWriter14.Line(string.Format("{0} lazy_embeddedConverter_{1} = null;", item, str1));
										codeWriter9 = codeWriter13.AddChild(string.Format("{0} embeddedConverter_{1}", item, str1));
										codeWriter10 = codeWriter9.AddChild("get");
										codeWriter11 = codeWriter10.AddChild(string.Format("if(null == lazy_embeddedConverter_{0})", str1));
										codeWriter11.Line(string.Format("lazy_embeddedConverter_{0} = new {1}();", str1, item));
										codeWriter10.Line(string.Format("return lazy_embeddedConverter_{0};", str1));
										codeWriter5.Line(string.Format("embeddedConverter_{0}.ToWMI(instNET.{1});", str1, memberInfo.Name));
										codeWriter5.Line(string.Format("{0}.Value = embeddedConverter_{0}.instance;", str1));
									}
									else
									{
										codeWriter5.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
										codeWriter5.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
										codeWriter5.Line(string.Format("{0}[] embeddedConverters = new {0}[len];", item));
										codeWriter7 = codeWriter5.AddChild("for(int i=0;i<len;i++)");
										codeWriter7.Line(string.Format("embeddedConverters[i] = new {0}();", item));
										if (!propertyType.IsValueType)
										{
											codeWriter8 = codeWriter7.AddChild(string.Format("if(instNET.{0}[i] != null)", memberInfo.Name));
											codeWriter8.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										else
										{
											codeWriter7.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										codeWriter7.Line("embeddedObjects[i] = embeddedConverters[i].instance;");
										codeWriter5.Line(string.Format("{0}.Value = embeddedObjects;", str1));
									}
								}
							}
							else
							{
								codeWriter = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
								codeWriter1 = codeWriter18.AddChild("else");
								codeWriter1.Line(string.Format("{0}.Value = null;", str1));
								if (!flag1)
								{
									codeWriter4 = codeWriter.AddChild(string.Format("if(mapTypeToConverter.Contains(instNET.{0}.GetType()))", memberInfo.Name));
									codeWriter4.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}.GetType()];", memberInfo.Name));
									codeWriter4.Line("IWmiConverter converter = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter4.Line(string.Format("converter.ToWMI(instNET.{0});", memberInfo.Name));
									codeWriter4.Line(string.Format("{0}.Value = converter.GetInstance();", str1));
									codeWriter.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.GetInstance(instNET.{1});", str1, memberInfo.Name));
								}
								else
								{
									codeWriter.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
									codeWriter.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
									codeWriter.Line("IWmiConverter[] embeddedConverters = new IWmiConverter[len];");
									codeWriter2 = codeWriter.AddChild("for(int i=0;i<len;i++)");
									codeWriter3 = codeWriter2.AddChild(string.Format("if((instNET.{0}[i] != null) && mapTypeToConverter.Contains(instNET.{0}[i].GetType()))", memberInfo.Name));
									codeWriter3.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}[i].GetType()];", memberInfo.Name));
									codeWriter3.Line("embeddedConverters[i] = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter3.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
									codeWriter3.Line("embeddedObjects[i] = embeddedConverters[i].GetInstance();");
									codeWriter2.AddChild("else").Line(string.Format("embeddedObjects[i] = SafeAssign.GetManagementObject(instNET.{0}[i]);", memberInfo.Name));
									codeWriter.Line(string.Format("{0}.Value = embeddedObjects;", str1));
								}
							}
							cimType = CimType.String;
							if (memberInfo.DeclaringType == type)
							{
								flag3 = true;
								try
								{
									propertyDatum = this.newClass.Properties[memberName];
									CimType type1 = propertyDatum.Type;
									if (propertyDatum.IsLocal)
									{
										throw new ArgumentException(string.Format(RC.GetString("MEMBERCONFLILCT_EXCEPT"), memberInfo.Name), memberInfo.Name);
									}
								}
								catch (ManagementException managementException3)
								{
									ManagementException managementException2 = managementException3;
									if (managementException2.ErrorCode == ManagementStatus.NotFound)
									{
										flag3 = false;
									}
									else
									{
										throw;
									}
								}
								if (!flag3)
								{
									if (str == null)
									{
										if (!flag2)
										{
											if (propertyType != typeof(ManagementObject))
											{
												if (propertyType != typeof(sbyte))
												{
													if (propertyType != typeof(byte))
													{
														if (propertyType != typeof(short))
														{
															if (propertyType != typeof(ushort))
															{
																if (propertyType != typeof(int))
																{
																	if (propertyType != typeof(uint))
																	{
																		if (propertyType != typeof(long))
																		{
																			if (propertyType != typeof(ulong))
																			{
																				if (propertyType != typeof(float))
																				{
																					if (propertyType != typeof(double))
																					{
																						if (propertyType != typeof(bool))
																						{
																							if (propertyType != typeof(string))
																							{
																								if (propertyType != typeof(char))
																								{
																									if (propertyType != typeof(DateTime))
																									{
																										if (propertyType != typeof(TimeSpan))
																										{
																											SchemaMapping.ThrowUnsupportedMember(memberInfo);
																										}
																										else
																										{
																											cimType = CimType.DateTime;
																										}
																									}
																									else
																									{
																										cimType = CimType.DateTime;
																									}
																								}
																								else
																								{
																									cimType = CimType.Char16;
																								}
																							}
																							else
																							{
																								cimType = CimType.String;
																							}
																						}
																						else
																						{
																							cimType = CimType.Boolean;
																						}
																					}
																					else
																					{
																						cimType = CimType.Real64;
																					}
																				}
																				else
																				{
																					cimType = CimType.Real32;
																				}
																			}
																			else
																			{
																				cimType = CimType.UInt64;
																			}
																		}
																		else
																		{
																			cimType = CimType.SInt64;
																		}
																	}
																	else
																	{
																		cimType = CimType.UInt32;
																	}
																}
																else
																{
																	cimType = CimType.SInt32;
																}
															}
															else
															{
																cimType = CimType.UInt16;
															}
														}
														else
														{
															cimType = CimType.SInt16;
														}
													}
													else
													{
														cimType = CimType.UInt8;
													}
												}
												else
												{
													cimType = CimType.SInt8;
												}
											}
											else
											{
												cimType = CimType.Object;
											}
										}
										else
										{
											cimType = CimType.Object;
										}
									}
									else
									{
										cimType = CimType.Object;
									}
									try
									{
										properties.Add(memberName, cimType, flag1);
									}
									catch (ManagementException managementException5)
									{
										ManagementException managementException4 = managementException5;
										SchemaMapping.ThrowUnsupportedMember(memberInfo, managementException4);
									}
									if (propertyType == typeof(TimeSpan))
									{
										item1 = properties[memberName];
										item1.Qualifiers.Add("SubType", "interval", false, true, true, true);
									}
									if (str != null)
									{
										propertyDatum1 = properties[memberName];
										propertyDatum1.Qualifiers["CIMTYPE"].Value = string.Concat("object:", str);
									}
								}
							}
						}
					}
					codeWriter15.Line("Marshal.Release(wbemObjectAccessIP);");
					return;
				}
				case InstrumentationType.Event:
				{
					num = 0;
					flag = false;
					members = type.GetMembers();
					for (i = 0; i < (int)members.Length; i++)
					{
						memberInfo = members[i];
						if ((memberInfo as FieldInfo != null || memberInfo as PropertyInfo != null) && (int)memberInfo.GetCustomAttributes(typeof(IgnoreMemberAttribute), false).Length <= 0)
						{
							if (memberInfo as FieldInfo == null)
							{
								if (memberInfo as PropertyInfo != null)
								{
									propertyInfo = memberInfo as PropertyInfo;
									if (!propertyInfo.CanRead)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									getMethod = propertyInfo.GetGetMethod();
									if (null == getMethod || getMethod.IsStatic)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									if ((int)getMethod.GetParameters().Length > 0)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
								}
							}
							else
							{
								fieldInfo = memberInfo as FieldInfo;
								if (fieldInfo.IsStatic)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
							}
							memberName = ManagedNameAttribute.GetMemberName(memberInfo);
							if (memberInfo as FieldInfo == null)
							{
								propertyType = (memberInfo as PropertyInfo).PropertyType;
							}
							else
							{
								propertyType = (memberInfo as FieldInfo).FieldType;
							}
							flag1 = false;
							if (propertyType.IsArray)
							{
								if (propertyType.GetArrayRank() != 1)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
								flag1 = true;
								propertyType = propertyType.GetElementType();
							}
							str = null;
							item = null;
							if (mapTypeToConverterClassName.Contains(propertyType))
							{
								item = (string)mapTypeToConverterClassName[propertyType];
								str = ManagedNameAttribute.GetMemberName(propertyType);
							}
							flag2 = false;
							if (propertyType == typeof(object))
							{
								flag2 = true;
								if (!flag4)
								{
									flag4 = true;
									codeWriter14.Line("static Hashtable mapTypeToConverter = new Hashtable();");
									foreach (DictionaryEntry dictionaryEntry2 in mapTypeToConverterClassName)
									{
										codeWriter15.Line(string.Format("mapTypeToConverter[typeof({0})] = typeof({1});", ((Type)dictionaryEntry2.Key).FullName.Replace('+', '.'), (string)dictionaryEntry2.Value));
									}
								}
							}
							str1 = string.Concat("prop_", num);
							num1 = num;
							num = num1 + 1;
							str2 = string.Concat("handle_", num1);
							codeWriter14.Line(string.Concat("static int ", str2, ";"));
							codeWriter15.Line(string.Format("IWOA.GetPropertyHandle_f27(27, wbemObjectAccessIP, \"{0}\", out cimType, out {1});", memberName, str2));
							codeWriter14.Line(string.Concat("PropertyData ", str1, ";"));
							codeWriter16.Line(string.Format("{0} = instance.Properties[\"{1}\"];", str1, memberName));
							if (!flag2)
							{
								if (str == null)
								{
									if (flag1)
									{
										if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
										{
											codeWriter18.AddChild(string.Format("if(null == instNET.{0})", memberInfo.Name)).Line(string.Format("{0}.Value = null;", str1));
											codeWriter18.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.WMITimeArrayToStringArray(instNET.{1});", str1, memberInfo.Name));
										}
										else
										{
											codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
										}
									}
									else
									{
										if (propertyType == typeof(byte) || propertyType == typeof(sbyte))
										{
											codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
											codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 1, ref instNET_{1});", str2, memberInfo.Name));
										}
										else
										{
											if (propertyType == typeof(short) || propertyType == typeof(ushort) || propertyType == typeof(char))
											{
												codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
												codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref instNET_{1});", str2, memberInfo.Name));
											}
											else
											{
												if (propertyType == typeof(uint) || propertyType == typeof(int) || propertyType == typeof(float))
												{
													codeWriter18.Line(string.Format("IWOA.WriteDWORD_f31(31, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
												}
												else
												{
													if (propertyType == typeof(ulong) || propertyType == typeof(long) || propertyType == typeof(double))
													{
														codeWriter18.Line(string.Format("IWOA.WriteQWORD_f33(33, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
													}
													else
													{
														if (propertyType != typeof(bool))
														{
															if (propertyType != typeof(string))
															{
																if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
																{
																	codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 52, SafeAssign.WMITimeToString(instNET.{1}));", str2, memberInfo.Name));
																}
																else
																{
																	codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
																}
															}
															else
															{
																codeWriter12 = codeWriter18.AddChild(string.Format("if(null != instNET.{0})", memberInfo.Name));
																codeWriter12.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, (instNET.{1}.Length+1)*2, instNET.{1});", str2, memberInfo.Name));
																codeWriter18.AddChild("else").Line(string.Format("IWOA.Put_f5(5, instWbemObjectAccessIP, \"{0}\", 0, ref nullObj, 8);", memberName));
																if (!flag)
																{
																	flag = true;
																	codeWriter14.Line("object nullObj = DBNull.Value;");
																}
															}
														}
														else
														{
															codeWriter18.Line(string.Format("if(instNET.{0})", memberInfo.Name));
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolTrue);", str2));
															codeWriter18.Line("else");
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolFalse);", str2));
														}
													}
												}
											}
										}
									}
								}
								else
								{
									if (!propertyType.IsValueType)
									{
										codeWriter5 = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
										codeWriter6 = codeWriter18.AddChild("else");
										codeWriter6.Line(string.Format("{0}.Value = null;", str1));
									}
									else
									{
										codeWriter5 = codeWriter18;
									}
									if (!flag1)
									{
										codeWriter14.Line(string.Format("{0} lazy_embeddedConverter_{1} = null;", item, str1));
										codeWriter9 = codeWriter13.AddChild(string.Format("{0} embeddedConverter_{1}", item, str1));
										codeWriter10 = codeWriter9.AddChild("get");
										codeWriter11 = codeWriter10.AddChild(string.Format("if(null == lazy_embeddedConverter_{0})", str1));
										codeWriter11.Line(string.Format("lazy_embeddedConverter_{0} = new {1}();", str1, item));
										codeWriter10.Line(string.Format("return lazy_embeddedConverter_{0};", str1));
										codeWriter5.Line(string.Format("embeddedConverter_{0}.ToWMI(instNET.{1});", str1, memberInfo.Name));
										codeWriter5.Line(string.Format("{0}.Value = embeddedConverter_{0}.instance;", str1));
									}
									else
									{
										codeWriter5.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
										codeWriter5.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
										codeWriter5.Line(string.Format("{0}[] embeddedConverters = new {0}[len];", item));
										codeWriter7 = codeWriter5.AddChild("for(int i=0;i<len;i++)");
										codeWriter7.Line(string.Format("embeddedConverters[i] = new {0}();", item));
										if (!propertyType.IsValueType)
										{
											codeWriter8 = codeWriter7.AddChild(string.Format("if(instNET.{0}[i] != null)", memberInfo.Name));
											codeWriter8.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										else
										{
											codeWriter7.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										codeWriter7.Line("embeddedObjects[i] = embeddedConverters[i].instance;");
										codeWriter5.Line(string.Format("{0}.Value = embeddedObjects;", str1));
									}
								}
							}
							else
							{
								codeWriter = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
								codeWriter1 = codeWriter18.AddChild("else");
								codeWriter1.Line(string.Format("{0}.Value = null;", str1));
								if (!flag1)
								{
									codeWriter4 = codeWriter.AddChild(string.Format("if(mapTypeToConverter.Contains(instNET.{0}.GetType()))", memberInfo.Name));
									codeWriter4.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}.GetType()];", memberInfo.Name));
									codeWriter4.Line("IWmiConverter converter = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter4.Line(string.Format("converter.ToWMI(instNET.{0});", memberInfo.Name));
									codeWriter4.Line(string.Format("{0}.Value = converter.GetInstance();", str1));
									codeWriter.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.GetInstance(instNET.{1});", str1, memberInfo.Name));
								}
								else
								{
									codeWriter.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
									codeWriter.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
									codeWriter.Line("IWmiConverter[] embeddedConverters = new IWmiConverter[len];");
									codeWriter2 = codeWriter.AddChild("for(int i=0;i<len;i++)");
									codeWriter3 = codeWriter2.AddChild(string.Format("if((instNET.{0}[i] != null) && mapTypeToConverter.Contains(instNET.{0}[i].GetType()))", memberInfo.Name));
									codeWriter3.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}[i].GetType()];", memberInfo.Name));
									codeWriter3.Line("embeddedConverters[i] = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter3.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
									codeWriter3.Line("embeddedObjects[i] = embeddedConverters[i].GetInstance();");
									codeWriter2.AddChild("else").Line(string.Format("embeddedObjects[i] = SafeAssign.GetManagementObject(instNET.{0}[i]);", memberInfo.Name));
									codeWriter.Line(string.Format("{0}.Value = embeddedObjects;", str1));
								}
							}
							cimType = CimType.String;
							if (memberInfo.DeclaringType == type)
							{
								flag3 = true;
								try
								{
									propertyDatum = this.newClass.Properties[memberName];
									CimType type1 = propertyDatum.Type;
									if (propertyDatum.IsLocal)
									{
										throw new ArgumentException(string.Format(RC.GetString("MEMBERCONFLILCT_EXCEPT"), memberInfo.Name), memberInfo.Name);
									}
								}
								catch (ManagementException managementException3)
								{
									ManagementException managementException2 = managementException3;
									if (managementException2.ErrorCode == ManagementStatus.NotFound)
									{
										flag3 = false;
									}
									else
									{
										throw;
									}
								}
								if (!flag3)
								{
									if (str == null)
									{
										if (!flag2)
										{
											if (propertyType != typeof(ManagementObject))
											{
												if (propertyType != typeof(sbyte))
												{
													if (propertyType != typeof(byte))
													{
														if (propertyType != typeof(short))
														{
															if (propertyType != typeof(ushort))
															{
																if (propertyType != typeof(int))
																{
																	if (propertyType != typeof(uint))
																	{
																		if (propertyType != typeof(long))
																		{
																			if (propertyType != typeof(ulong))
																			{
																				if (propertyType != typeof(float))
																				{
																					if (propertyType != typeof(double))
																					{
																						if (propertyType != typeof(bool))
																						{
																							if (propertyType != typeof(string))
																							{
																								if (propertyType != typeof(char))
																								{
																									if (propertyType != typeof(DateTime))
																									{
																										if (propertyType != typeof(TimeSpan))
																										{
																											SchemaMapping.ThrowUnsupportedMember(memberInfo);
																										}
																										else
																										{
																											cimType = CimType.DateTime;
																										}
																									}
																									else
																									{
																										cimType = CimType.DateTime;
																									}
																								}
																								else
																								{
																									cimType = CimType.Char16;
																								}
																							}
																							else
																							{
																								cimType = CimType.String;
																							}
																						}
																						else
																						{
																							cimType = CimType.Boolean;
																						}
																					}
																					else
																					{
																						cimType = CimType.Real64;
																					}
																				}
																				else
																				{
																					cimType = CimType.Real32;
																				}
																			}
																			else
																			{
																				cimType = CimType.UInt64;
																			}
																		}
																		else
																		{
																			cimType = CimType.SInt64;
																		}
																	}
																	else
																	{
																		cimType = CimType.UInt32;
																	}
																}
																else
																{
																	cimType = CimType.SInt32;
																}
															}
															else
															{
																cimType = CimType.UInt16;
															}
														}
														else
														{
															cimType = CimType.SInt16;
														}
													}
													else
													{
														cimType = CimType.UInt8;
													}
												}
												else
												{
													cimType = CimType.SInt8;
												}
											}
											else
											{
												cimType = CimType.Object;
											}
										}
										else
										{
											cimType = CimType.Object;
										}
									}
									else
									{
										cimType = CimType.Object;
									}
									try
									{
										properties.Add(memberName, cimType, flag1);
									}
									catch (ManagementException managementException5)
									{
										ManagementException managementException4 = managementException5;
										SchemaMapping.ThrowUnsupportedMember(memberInfo, managementException4);
									}
									if (propertyType == typeof(TimeSpan))
									{
										item1 = properties[memberName];
										item1.Qualifiers.Add("SubType", "interval", false, true, true, true);
									}
									if (str != null)
									{
										propertyDatum1 = properties[memberName];
										propertyDatum1.Qualifiers["CIMTYPE"].Value = string.Concat("object:", str);
									}
								}
							}
						}
					}
					codeWriter15.Line("Marshal.Release(wbemObjectAccessIP);");
					return;
				}
				case InstrumentationType.Abstract:
				{
					this.newClass.Qualifiers.Add("abstract", true, false, false, false, true);
					num = 0;
					flag = false;
					members = type.GetMembers();
					for (i = 0; i < (int)members.Length; i++)
					{
						memberInfo = members[i];
						if ((memberInfo as FieldInfo != null || memberInfo as PropertyInfo != null) && (int)memberInfo.GetCustomAttributes(typeof(IgnoreMemberAttribute), false).Length <= 0)
						{
							if (memberInfo as FieldInfo == null)
							{
								if (memberInfo as PropertyInfo != null)
								{
									propertyInfo = memberInfo as PropertyInfo;
									if (!propertyInfo.CanRead)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									getMethod = propertyInfo.GetGetMethod();
									if (null == getMethod || getMethod.IsStatic)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									if ((int)getMethod.GetParameters().Length > 0)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
								}
							}
							else
							{
								fieldInfo = memberInfo as FieldInfo;
								if (fieldInfo.IsStatic)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
							}
							memberName = ManagedNameAttribute.GetMemberName(memberInfo);
							if (memberInfo as FieldInfo == null)
							{
								propertyType = (memberInfo as PropertyInfo).PropertyType;
							}
							else
							{
								propertyType = (memberInfo as FieldInfo).FieldType;
							}
							flag1 = false;
							if (propertyType.IsArray)
							{
								if (propertyType.GetArrayRank() != 1)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
								flag1 = true;
								propertyType = propertyType.GetElementType();
							}
							str = null;
							item = null;
							if (mapTypeToConverterClassName.Contains(propertyType))
							{
								item = (string)mapTypeToConverterClassName[propertyType];
								str = ManagedNameAttribute.GetMemberName(propertyType);
							}
							flag2 = false;
							if (propertyType == typeof(object))
							{
								flag2 = true;
								if (!flag4)
								{
									flag4 = true;
									codeWriter14.Line("static Hashtable mapTypeToConverter = new Hashtable();");
									foreach (DictionaryEntry dictionaryEntry3 in mapTypeToConverterClassName)
									{
										codeWriter15.Line(string.Format("mapTypeToConverter[typeof({0})] = typeof({1});", ((Type)dictionaryEntry3.Key).FullName.Replace('+', '.'), (string)dictionaryEntry3.Value));
									}
								}
							}
							str1 = string.Concat("prop_", (object)num);
							num1 = num;
							num = num1 + 1;
							str2 = string.Concat("handle_", (object)num1);
							codeWriter14.Line(string.Concat("static int ", str2, ";"));
							codeWriter15.Line(string.Format("IWOA.GetPropertyHandle_f27(27, wbemObjectAccessIP, \"{0}\", out cimType, out {1});", memberName, str2));
							codeWriter14.Line(string.Concat("PropertyData ", str1, ";"));
							codeWriter16.Line(string.Format("{0} = instance.Properties[\"{1}\"];", str1, memberName));
							if (!flag2)
							{
								if (str == null)
								{
									if (flag1)
									{
										if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
										{
											codeWriter18.AddChild(string.Format("if(null == instNET.{0})", memberInfo.Name)).Line(string.Format("{0}.Value = null;", str1));
											codeWriter18.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.WMITimeArrayToStringArray(instNET.{1});", str1, memberInfo.Name));
										}
										else
										{
											codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
										}
									}
									else
									{
										if (propertyType == typeof(byte) || propertyType == typeof(sbyte))
										{
											codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
											codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 1, ref instNET_{1});", str2, memberInfo.Name));
										}
										else
										{
											if (propertyType == typeof(short) || propertyType == typeof(ushort) || propertyType == typeof(char))
											{
												codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
												codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref instNET_{1});", str2, memberInfo.Name));
											}
											else
											{
												if (propertyType == typeof(uint) || propertyType == typeof(int) || propertyType == typeof(float))
												{
													codeWriter18.Line(string.Format("IWOA.WriteDWORD_f31(31, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
												}
												else
												{
													if (propertyType == typeof(ulong) || propertyType == typeof(long) || propertyType == typeof(double))
													{
														codeWriter18.Line(string.Format("IWOA.WriteQWORD_f33(33, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
													}
													else
													{
														if (propertyType != typeof(bool))
														{
															if (propertyType != typeof(string))
															{
																if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
																{
																	codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 52, SafeAssign.WMITimeToString(instNET.{1}));", str2, memberInfo.Name));
																}
																else
																{
																	codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
																}
															}
															else
															{
																codeWriter12 = codeWriter18.AddChild(string.Format("if(null != instNET.{0})", memberInfo.Name));
																codeWriter12.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, (instNET.{1}.Length+1)*2, instNET.{1});", str2, memberInfo.Name));
																codeWriter18.AddChild("else").Line(string.Format("IWOA.Put_f5(5, instWbemObjectAccessIP, \"{0}\", 0, ref nullObj, 8);", memberName));
																if (!flag)
																{
																	flag = true;
																	codeWriter14.Line("object nullObj = DBNull.Value;");
																}
															}
														}
														else
														{
															codeWriter18.Line(string.Format("if(instNET.{0})", memberInfo.Name));
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolTrue);", str2));
															codeWriter18.Line("else");
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolFalse);", str2));
														}
													}
												}
											}
										}
									}
								}
								else
								{
									if (!propertyType.IsValueType)
									{
										codeWriter5 = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
										codeWriter6 = codeWriter18.AddChild("else");
										codeWriter6.Line(string.Format("{0}.Value = null;", str1));
									}
									else
									{
										codeWriter5 = codeWriter18;
									}
									if (!flag1)
									{
										codeWriter14.Line(string.Format("{0} lazy_embeddedConverter_{1} = null;", item, str1));
										codeWriter9 = codeWriter13.AddChild(string.Format("{0} embeddedConverter_{1}", item, str1));
										codeWriter10 = codeWriter9.AddChild("get");
										codeWriter11 = codeWriter10.AddChild(string.Format("if(null == lazy_embeddedConverter_{0})", str1));
										codeWriter11.Line(string.Format("lazy_embeddedConverter_{0} = new {1}();", str1, item));
										codeWriter10.Line(string.Format("return lazy_embeddedConverter_{0};", str1));
										codeWriter5.Line(string.Format("embeddedConverter_{0}.ToWMI(instNET.{1});", str1, memberInfo.Name));
										codeWriter5.Line(string.Format("{0}.Value = embeddedConverter_{0}.instance;", str1));
									}
									else
									{
										codeWriter5.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
										codeWriter5.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
										codeWriter5.Line(string.Format("{0}[] embeddedConverters = new {0}[len];", item));
										codeWriter7 = codeWriter5.AddChild("for(int i=0;i<len;i++)");
										codeWriter7.Line(string.Format("embeddedConverters[i] = new {0}();", item));
										if (!propertyType.IsValueType)
										{
											codeWriter8 = codeWriter7.AddChild(string.Format("if(instNET.{0}[i] != null)", memberInfo.Name));
											codeWriter8.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										else
										{
											codeWriter7.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										codeWriter7.Line("embeddedObjects[i] = embeddedConverters[i].instance;");
										codeWriter5.Line(string.Format("{0}.Value = embeddedObjects;", str1));
									}
								}
							}
							else
							{
								codeWriter = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
								codeWriter1 = codeWriter18.AddChild("else");
								codeWriter1.Line(string.Format("{0}.Value = null;", str1));
								if (!flag1)
								{
									codeWriter4 = codeWriter.AddChild(string.Format("if(mapTypeToConverter.Contains(instNET.{0}.GetType()))", memberInfo.Name));
									codeWriter4.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}.GetType()];", memberInfo.Name));
									codeWriter4.Line("IWmiConverter converter = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter4.Line(string.Format("converter.ToWMI(instNET.{0});", memberInfo.Name));
									codeWriter4.Line(string.Format("{0}.Value = converter.GetInstance();", str1));
									codeWriter.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.GetInstance(instNET.{1});", str1, memberInfo.Name));
								}
								else
								{
									codeWriter.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
									codeWriter.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
									codeWriter.Line("IWmiConverter[] embeddedConverters = new IWmiConverter[len];");
									codeWriter2 = codeWriter.AddChild("for(int i=0;i<len;i++)");
									codeWriter3 = codeWriter2.AddChild(string.Format("if((instNET.{0}[i] != null) && mapTypeToConverter.Contains(instNET.{0}[i].GetType()))", memberInfo.Name));
									codeWriter3.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}[i].GetType()];", memberInfo.Name));
									codeWriter3.Line("embeddedConverters[i] = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter3.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
									codeWriter3.Line("embeddedObjects[i] = embeddedConverters[i].GetInstance();");
									codeWriter2.AddChild("else").Line(string.Format("embeddedObjects[i] = SafeAssign.GetManagementObject(instNET.{0}[i]);", memberInfo.Name));
									codeWriter.Line(string.Format("{0}.Value = embeddedObjects;", str1));
								}
							}
							cimType = CimType.String;
							if (memberInfo.DeclaringType == type)
							{
								flag3 = true;
								try
								{
									propertyDatum = this.newClass.Properties[memberName];
									CimType type1 = propertyDatum.Type;
									if (propertyDatum.IsLocal)
									{
										throw new ArgumentException(string.Format(RC.GetString("MEMBERCONFLILCT_EXCEPT"), memberInfo.Name), memberInfo.Name);
									}
								}
								catch (ManagementException managementException3)
								{
									ManagementException managementException2 = managementException3;
									if (managementException2.ErrorCode == ManagementStatus.NotFound)
									{
										flag3 = false;
									}
									else
									{
										throw;
									}
								}
								if (!flag3)
								{
									if (str == null)
									{
										if (!flag2)
										{
											if (propertyType != typeof(ManagementObject))
											{
												if (propertyType != typeof(sbyte))
												{
													if (propertyType != typeof(byte))
													{
														if (propertyType != typeof(short))
														{
															if (propertyType != typeof(ushort))
															{
																if (propertyType != typeof(int))
																{
																	if (propertyType != typeof(uint))
																	{
																		if (propertyType != typeof(long))
																		{
																			if (propertyType != typeof(ulong))
																			{
																				if (propertyType != typeof(float))
																				{
																					if (propertyType != typeof(double))
																					{
																						if (propertyType != typeof(bool))
																						{
																							if (propertyType != typeof(string))
																							{
																								if (propertyType != typeof(char))
																								{
																									if (propertyType != typeof(DateTime))
																									{
																										if (propertyType != typeof(TimeSpan))
																										{
																											SchemaMapping.ThrowUnsupportedMember(memberInfo);
																										}
																										else
																										{
																											cimType = CimType.DateTime;
																										}
																									}
																									else
																									{
																										cimType = CimType.DateTime;
																									}
																								}
																								else
																								{
																									cimType = CimType.Char16;
																								}
																							}
																							else
																							{
																								cimType = CimType.String;
																							}
																						}
																						else
																						{
																							cimType = CimType.Boolean;
																						}
																					}
																					else
																					{
																						cimType = CimType.Real64;
																					}
																				}
																				else
																				{
																					cimType = CimType.Real32;
																				}
																			}
																			else
																			{
																				cimType = CimType.UInt64;
																			}
																		}
																		else
																		{
																			cimType = CimType.SInt64;
																		}
																	}
																	else
																	{
																		cimType = CimType.UInt32;
																	}
																}
																else
																{
																	cimType = CimType.SInt32;
																}
															}
															else
															{
																cimType = CimType.UInt16;
															}
														}
														else
														{
															cimType = CimType.SInt16;
														}
													}
													else
													{
														cimType = CimType.UInt8;
													}
												}
												else
												{
													cimType = CimType.SInt8;
												}
											}
											else
											{
												cimType = CimType.Object;
											}
										}
										else
										{
											cimType = CimType.Object;
										}
									}
									else
									{
										cimType = CimType.Object;
									}
									try
									{
										properties.Add(memberName, cimType, flag1);
									}
									catch (ManagementException managementException5)
									{
										ManagementException managementException4 = managementException5;
										SchemaMapping.ThrowUnsupportedMember(memberInfo, managementException4);
									}
									if (propertyType == typeof(TimeSpan))
									{
										item1 = properties[memberName];
										item1.Qualifiers.Add("SubType", "interval", false, true, true, true);
									}
									if (str != null)
									{
										propertyDatum1 = properties[memberName];
										propertyDatum1.Qualifiers["CIMTYPE"].Value = string.Concat("object:", str);
									}
								}
							}
						}
					}
					codeWriter15.Line("Marshal.Release(wbemObjectAccessIP);");
					return;
				}
				default:
				{
					num = 0;
					flag = false;
					members = type.GetMembers();
					for (i = 0; i < (int)members.Length; i++)
					{
						memberInfo = members[i];
						if ((memberInfo as FieldInfo != null || memberInfo as PropertyInfo != null) && (int)memberInfo.GetCustomAttributes(typeof(IgnoreMemberAttribute), false).Length <= 0)
						{
							if (memberInfo as FieldInfo == null)
							{
								if (memberInfo as PropertyInfo != null)
								{
									propertyInfo = memberInfo as PropertyInfo;
									if (!propertyInfo.CanRead)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									getMethod = propertyInfo.GetGetMethod();
									if (null == getMethod || getMethod.IsStatic)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
									if ((int)getMethod.GetParameters().Length > 0)
									{
										SchemaMapping.ThrowUnsupportedMember(memberInfo);
									}
								}
							}
							else
							{
								fieldInfo = memberInfo as FieldInfo;
								if (fieldInfo.IsStatic)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
							}
							memberName = ManagedNameAttribute.GetMemberName(memberInfo);
							if (memberInfo as FieldInfo == null)
							{
								propertyType = (memberInfo as PropertyInfo).PropertyType;
							}
							else
							{
								propertyType = (memberInfo as FieldInfo).FieldType;
							}
							flag1 = false;
							if (propertyType.IsArray)
							{
								if (propertyType.GetArrayRank() != 1)
								{
									SchemaMapping.ThrowUnsupportedMember(memberInfo);
								}
								flag1 = true;
								propertyType = propertyType.GetElementType();
							}
							str = null;
							item = null;
							if (mapTypeToConverterClassName.Contains(propertyType))
							{
								item = (string)mapTypeToConverterClassName[propertyType];
								str = ManagedNameAttribute.GetMemberName(propertyType);
							}
							flag2 = false;
							if (propertyType == typeof(object))
							{
								flag2 = true;
								if (!flag4)
								{
									flag4 = true;
									codeWriter14.Line("static Hashtable mapTypeToConverter = new Hashtable();");
									foreach (DictionaryEntry dictionaryEntry4 in mapTypeToConverterClassName)
									{
										codeWriter15.Line(string.Format("mapTypeToConverter[typeof({0})] = typeof({1});", ((Type)dictionaryEntry4.Key).FullName.Replace('+', '.'), (string)dictionaryEntry4.Value));
									}
								}
							}
							str1 = string.Concat("prop_", (object)num);
							num1 = num;
							num = num1 + 1;
							str2 = string.Concat("handle_", (object)num1);
							codeWriter14.Line(string.Concat("static int ", str2, ";"));
							codeWriter15.Line(string.Format("IWOA.GetPropertyHandle_f27(27, wbemObjectAccessIP, \"{0}\", out cimType, out {1});", memberName, str2));
							codeWriter14.Line(string.Concat("PropertyData ", str1, ";"));
							codeWriter16.Line(string.Format("{0} = instance.Properties[\"{1}\"];", str1, memberName));
							if (!flag2)
							{
								if (str == null)
								{
									if (flag1)
									{
										if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
										{
											codeWriter18.AddChild(string.Format("if(null == instNET.{0})", memberInfo.Name)).Line(string.Format("{0}.Value = null;", str1));
											codeWriter18.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.WMITimeArrayToStringArray(instNET.{1});", str1, memberInfo.Name));
										}
										else
										{
											codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
										}
									}
									else
									{
										if (propertyType == typeof(byte) || propertyType == typeof(sbyte))
										{
											codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
											codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 1, ref instNET_{1});", str2, memberInfo.Name));
										}
										else
										{
											if (propertyType == typeof(short) || propertyType == typeof(ushort) || propertyType == typeof(char))
											{
												codeWriter18.Line(string.Format("{0} instNET_{1} = instNET.{1} ;", propertyType, memberInfo.Name));
												codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref instNET_{1});", str2, memberInfo.Name));
											}
											else
											{
												if (propertyType == typeof(uint) || propertyType == typeof(int) || propertyType == typeof(float))
												{
													codeWriter18.Line(string.Format("IWOA.WriteDWORD_f31(31, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
												}
												else
												{
													if (propertyType == typeof(ulong) || propertyType == typeof(long) || propertyType == typeof(double))
													{
														codeWriter18.Line(string.Format("IWOA.WriteQWORD_f33(33, instWbemObjectAccessIP, {0}, instNET.{1});", str2, memberInfo.Name));
													}
													else
													{
														if (propertyType != typeof(bool))
														{
															if (propertyType != typeof(string))
															{
																if (propertyType == typeof(DateTime) || propertyType == typeof(TimeSpan))
																{
																	codeWriter18.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 52, SafeAssign.WMITimeToString(instNET.{1}));", str2, memberInfo.Name));
																}
																else
																{
																	codeWriter18.Line(string.Format("{0}.Value = instNET.{1};", str1, memberInfo.Name));
																}
															}
															else
															{
																codeWriter12 = codeWriter18.AddChild(string.Format("if(null != instNET.{0})", memberInfo.Name));
																codeWriter12.Line(string.Format("IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, (instNET.{1}.Length+1)*2, instNET.{1});", str2, memberInfo.Name));
																codeWriter18.AddChild("else").Line(string.Format("IWOA.Put_f5(5, instWbemObjectAccessIP, \"{0}\", 0, ref nullObj, 8);", memberName));
																if (!flag)
																{
																	flag = true;
																	codeWriter14.Line("object nullObj = DBNull.Value;");
																}
															}
														}
														else
														{
															codeWriter18.Line(string.Format("if(instNET.{0})", memberInfo.Name));
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolTrue);", str2));
															codeWriter18.Line("else");
															codeWriter18.Line(string.Format("    IWOA.WritePropertyValue_f28(28, instWbemObjectAccessIP, {0}, 2, ref SafeAssign.boolFalse);", str2));
														}
													}
												}
											}
										}
									}
								}
								else
								{
									if (!propertyType.IsValueType)
									{
										codeWriter5 = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
										codeWriter6 = codeWriter18.AddChild("else");
										codeWriter6.Line(string.Format("{0}.Value = null;", str1));
									}
									else
									{
										codeWriter5 = codeWriter18;
									}
									if (!flag1)
									{
										codeWriter14.Line(string.Format("{0} lazy_embeddedConverter_{1} = null;", item, str1));
										codeWriter9 = codeWriter13.AddChild(string.Format("{0} embeddedConverter_{1}", item, str1));
										codeWriter10 = codeWriter9.AddChild("get");
										codeWriter11 = codeWriter10.AddChild(string.Format("if(null == lazy_embeddedConverter_{0})", str1));
										codeWriter11.Line(string.Format("lazy_embeddedConverter_{0} = new {1}();", str1, item));
										codeWriter10.Line(string.Format("return lazy_embeddedConverter_{0};", str1));
										codeWriter5.Line(string.Format("embeddedConverter_{0}.ToWMI(instNET.{1});", str1, memberInfo.Name));
										codeWriter5.Line(string.Format("{0}.Value = embeddedConverter_{0}.instance;", str1));
									}
									else
									{
										codeWriter5.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
										codeWriter5.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
										codeWriter5.Line(string.Format("{0}[] embeddedConverters = new {0}[len];", item));
										codeWriter7 = codeWriter5.AddChild("for(int i=0;i<len;i++)");
										codeWriter7.Line(string.Format("embeddedConverters[i] = new {0}();", item));
										if (!propertyType.IsValueType)
										{
											codeWriter8 = codeWriter7.AddChild(string.Format("if(instNET.{0}[i] != null)", memberInfo.Name));
											codeWriter8.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										else
										{
											codeWriter7.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
										}
										codeWriter7.Line("embeddedObjects[i] = embeddedConverters[i].instance;");
										codeWriter5.Line(string.Format("{0}.Value = embeddedObjects;", str1));
									}
								}
							}
							else
							{
								codeWriter = codeWriter18.AddChild(string.Format("if(instNET.{0} != null)", memberInfo.Name));
								codeWriter1 = codeWriter18.AddChild("else");
								codeWriter1.Line(string.Format("{0}.Value = null;", str1));
								if (!flag1)
								{
									codeWriter4 = codeWriter.AddChild(string.Format("if(mapTypeToConverter.Contains(instNET.{0}.GetType()))", memberInfo.Name));
									codeWriter4.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}.GetType()];", memberInfo.Name));
									codeWriter4.Line("IWmiConverter converter = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter4.Line(string.Format("converter.ToWMI(instNET.{0});", memberInfo.Name));
									codeWriter4.Line(string.Format("{0}.Value = converter.GetInstance();", str1));
									codeWriter.AddChild("else").Line(string.Format("{0}.Value = SafeAssign.GetInstance(instNET.{1});", str1, memberInfo.Name));
								}
								else
								{
									codeWriter.Line(string.Format("int len = instNET.{0}.Length;", memberInfo.Name));
									codeWriter.Line("ManagementObject[] embeddedObjects = new ManagementObject[len];");
									codeWriter.Line("IWmiConverter[] embeddedConverters = new IWmiConverter[len];");
									codeWriter2 = codeWriter.AddChild("for(int i=0;i<len;i++)");
									codeWriter3 = codeWriter2.AddChild(string.Format("if((instNET.{0}[i] != null) && mapTypeToConverter.Contains(instNET.{0}[i].GetType()))", memberInfo.Name));
									codeWriter3.Line(string.Format("Type type = (Type)mapTypeToConverter[instNET.{0}[i].GetType()];", memberInfo.Name));
									codeWriter3.Line("embeddedConverters[i] = (IWmiConverter)Activator.CreateInstance(type);");
									codeWriter3.Line(string.Format("embeddedConverters[i].ToWMI(instNET.{0}[i]);", memberInfo.Name));
									codeWriter3.Line("embeddedObjects[i] = embeddedConverters[i].GetInstance();");
									codeWriter2.AddChild("else").Line(string.Format("embeddedObjects[i] = SafeAssign.GetManagementObject(instNET.{0}[i]);", memberInfo.Name));
									codeWriter.Line(string.Format("{0}.Value = embeddedObjects;", str1));
								}
							}
							cimType = CimType.String;
							if (memberInfo.DeclaringType == type)
							{
								flag3 = true;
								try
								{
									propertyDatum = this.newClass.Properties[memberName];
									CimType type1 = propertyDatum.Type;
									if (propertyDatum.IsLocal)
									{
										throw new ArgumentException(string.Format(RC.GetString("MEMBERCONFLILCT_EXCEPT"), memberInfo.Name), memberInfo.Name);
									}
								}
								catch (ManagementException managementException3)
								{
									ManagementException managementException2 = managementException3;
									if (managementException2.ErrorCode == ManagementStatus.NotFound)
									{
										flag3 = false;
									}
									else
									{
										throw;
									}
								}
								if (!flag3)
								{
									if (str == null)
									{
										if (!flag2)
										{
											if (propertyType != typeof(ManagementObject))
											{
												if (propertyType != typeof(sbyte))
												{
													if (propertyType != typeof(byte))
													{
														if (propertyType != typeof(short))
														{
															if (propertyType != typeof(ushort))
															{
																if (propertyType != typeof(int))
																{
																	if (propertyType != typeof(uint))
																	{
																		if (propertyType != typeof(long))
																		{
																			if (propertyType != typeof(ulong))
																			{
																				if (propertyType != typeof(float))
																				{
																					if (propertyType != typeof(double))
																					{
																						if (propertyType != typeof(bool))
																						{
																							if (propertyType != typeof(string))
																							{
																								if (propertyType != typeof(char))
																								{
																									if (propertyType != typeof(DateTime))
																									{
																										if (propertyType != typeof(TimeSpan))
																										{
																											SchemaMapping.ThrowUnsupportedMember(memberInfo);
																										}
																										else
																										{
																											cimType = CimType.DateTime;
																										}
																									}
																									else
																									{
																										cimType = CimType.DateTime;
																									}
																								}
																								else
																								{
																									cimType = CimType.Char16;
																								}
																							}
																							else
																							{
																								cimType = CimType.String;
																							}
																						}
																						else
																						{
																							cimType = CimType.Boolean;
																						}
																					}
																					else
																					{
																						cimType = CimType.Real64;
																					}
																				}
																				else
																				{
																					cimType = CimType.Real32;
																				}
																			}
																			else
																			{
																				cimType = CimType.UInt64;
																			}
																		}
																		else
																		{
																			cimType = CimType.SInt64;
																		}
																	}
																	else
																	{
																		cimType = CimType.UInt32;
																	}
																}
																else
																{
																	cimType = CimType.SInt32;
																}
															}
															else
															{
																cimType = CimType.UInt16;
															}
														}
														else
														{
															cimType = CimType.SInt16;
														}
													}
													else
													{
														cimType = CimType.UInt8;
													}
												}
												else
												{
													cimType = CimType.SInt8;
												}
											}
											else
											{
												cimType = CimType.Object;
											}
										}
										else
										{
											cimType = CimType.Object;
										}
									}
									else
									{
										cimType = CimType.Object;
									}
									try
									{
										properties.Add(memberName, cimType, flag1);
									}
									catch (ManagementException managementException5)
									{
										ManagementException managementException4 = managementException5;
										SchemaMapping.ThrowUnsupportedMember(memberInfo, managementException4);
									}
									if (propertyType == typeof(TimeSpan))
									{
										item1 = properties[memberName];
										item1.Qualifiers.Add("SubType", "interval", false, true, true, true);
									}
									if (str != null)
									{
										propertyDatum1 = properties[memberName];
										propertyDatum1.Qualifiers["CIMTYPE"].Value = string.Concat("object:", str);
									}
								}
							}
						}
					}
					codeWriter15.Line("Marshal.Release(wbemObjectAccessIP);");
					return;
				}
			}
		}
        public void RegisterAssemblySpecificSchema()
        {
            SecurityHelper.UnmanagedCode.Demand();             // Bug#112640 - Close off any potential use from anything but fully trusted code
            Type[] types = InstrumentedAttribute.GetInstrumentedTypes(assembly);

            StringCollection events    = new StringCollection();
            StringCollection instances = new StringCollection();
            StringCollection abstracts = new StringCollection();

            string[]             mofs       = new string[types.Length];
            CodeWriter           code       = new CodeWriter();
            ReferencesCollection references = new ReferencesCollection();

            // Add the node with all the 'using' statements at the top
            code.AddChild(references.UsingCode);
            references.Add(typeof(Object));
            references.Add(typeof(ManagementClass));
            references.Add(typeof(Marshal));
            references.Add(typeof(System.Security.SuppressUnmanagedCodeSecurityAttribute));
            references.Add(typeof(System.Reflection.FieldInfo));
            references.Add(typeof(Hashtable));

            // Add a blank line
            code.Line();

            // Add master converter class
            CodeWriter codeWMIConverter = code.AddChild("public class WMINET_Converter");

            // Add master map of types to converters
            codeWMIConverter.Line("public static Hashtable mapTypeToConverter = new Hashtable();");

            // Add master CCTOR
            CodeWriter codeCCTOR = codeWMIConverter.AddChild("static WMINET_Converter()");

            // Make mapping of types to converter class names
            Hashtable mapTypeToConverterClassName = new Hashtable();

            for (int i = 0; i < types.Length; i++)
            {
                mapTypeToConverterClassName[types[i]] = "ConvertClass_" + i;
            }

            for (int i = 0; i < types.Length; i++)
            {
                SchemaMapping mapping = new SchemaMapping(types[i], this, mapTypeToConverterClassName);

                codeCCTOR.Line(String.Format("mapTypeToConverter[typeof({0})] = typeof({1});", mapping.ClassType.FullName.Replace('+', '.'), mapping.CodeClassName));  // bug#92918 - watch for nested classes

                ReplaceClassIfNecessary(mapping.ClassPath, mapping.NewClass);
                mofs[i] = GetMofFormat(mapping.NewClass);
                code.AddChild(mapping.Code);
                switch (mapping.InstrumentationType)
                {
                case InstrumentationType.Event:
                    events.Add(mapping.ClassName);
                    break;

                case InstrumentationType.Instance:
                    instances.Add(mapping.ClassName);
                    break;

                case InstrumentationType.Abstract:
                    abstracts.Add(mapping.ClassName);
                    break;

                default:
                    break;
                }
            }

            RegisterAssemblySpecificDecoupledProviderInstance();
            RegisterProviderAsEventProvider(events);
            RegisterProviderAsInstanceProvider();

            RegisterAssemblyAsInstrumented();

            Directory.CreateDirectory(DataDirectory);

            using (StreamWriter log = new StreamWriter(CodePath, false, Encoding.Unicode))
            {
                log.WriteLine(code);
                log.WriteLine(iwoaDef);
            }

            // Always generate the MOF in unicode
            using (StreamWriter log = new StreamWriter(MofPath, false, Encoding.Unicode))
            {
                log.WriteLine(GenerateMof(mofs));
            }
            RegisterSchemaUsingMofcomp(MofPath);
            //WMICapabilities.AddAutorecoverMof(MofPath);
        }
 public CodeWriter AddChild(CodeWriter snippet)
 {
     snippet.depth = this.depth;
     this.children.Add(snippet);
     return(snippet);
 }