当前位置: 首页>>代码示例>>C#>>正文


C# IDesignerSerializationManager.GetType方法代码示例

本文整理汇总了C#中IDesignerSerializationManager.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IDesignerSerializationManager.GetType方法的具体用法?C# IDesignerSerializationManager.GetType怎么用?C# IDesignerSerializationManager.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDesignerSerializationManager的用法示例。


在下文中一共展示了IDesignerSerializationManager.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformLoad

		protected override void PerformLoad (IDesignerSerializationManager manager)
		{
			if (manager == null)
				throw new ArgumentNullException ("manager");

			CodeCompileUnit document = this.Parse ();
			if (document == null)
				throw new NotSupportedException ("The language did not provide a code parser for this file");

			string namespaceName = null;
			CodeTypeDeclaration rootDocument = ExtractFirstCodeTypeDecl (document, out namespaceName);
			if (rootDocument == null)
				throw new InvalidOperationException ("Cannot find a declaration in a namespace to load.");

			_rootSerializer = manager.GetSerializer (manager.GetType (rootDocument.Name), 
													 typeof (RootCodeDomSerializer)) as CodeDomSerializer;
			if (_rootSerializer == null)
				throw new InvalidOperationException ("Serialization not supported for this class");
			_rootSerializer.Deserialize (manager, rootDocument);

			base.SetBaseComponentClassName (namespaceName + "." + rootDocument.Name);
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:22,代码来源:CodeDomDesignerLoader.cs

示例2: Deserialize

 public virtual object Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (declaration == null)
     {
         throw new ArgumentNullException("declaration");
     }
     object obj2 = null;
     using (CodeDomSerializerBase.TraceScope("TypeCodeDomSerializer::Deserialize"))
     {
         bool caseInsensitive = false;
         CodeDomProvider service = manager.GetService(typeof(CodeDomProvider)) as CodeDomProvider;
         if (service != null)
         {
             caseInsensitive = (service.LanguageOptions & LanguageOptions.CaseInsensitive) != LanguageOptions.None;
         }
         Type type = null;
         string name = declaration.Name;
         foreach (CodeTypeReference reference in declaration.BaseTypes)
         {
             Type type2 = manager.GetType(CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, reference));
             name = reference.BaseType;
             if ((type2 != null) && !type2.IsInterface)
             {
                 type = type2;
                 break;
             }
         }
         if (type == null)
         {
             CodeDomSerializerBase.Error(manager, System.Design.SR.GetString("SerializerTypeNotFound", new object[] { name }), "SerializerTypeNotFound");
         }
         if (CodeDomSerializerBase.GetReflectionTypeFromTypeHelper(manager, type).IsAbstract)
         {
             CodeDomSerializerBase.Error(manager, System.Design.SR.GetString("SerializerTypeAbstract", new object[] { type.FullName }), "SerializerTypeAbstract");
         }
         ResolveNameEventHandler handler = new ResolveNameEventHandler(this.OnResolveName);
         manager.ResolveName += handler;
         obj2 = manager.CreateInstance(type, null, declaration.Name, true);
         int count = declaration.Members.Count;
         this._nameTable = new HybridDictionary(count, caseInsensitive);
         this._statementTable = new Dictionary<string, CodeDomSerializerBase.OrderedCodeStatementCollection>(count);
         Dictionary<string, string> names = new Dictionary<string, string>(count);
         RootContext context = new RootContext(new CodeThisReferenceExpression(), obj2);
         manager.Context.Push(context);
         try
         {
             StringComparison comparisonType = caseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
             foreach (CodeTypeMember member in declaration.Members)
             {
                 CodeMemberField field = member as CodeMemberField;
                 if ((field != null) && !string.Equals(field.Name, declaration.Name, comparisonType))
                 {
                     this._nameTable[field.Name] = field;
                     if ((field.Type != null) && !string.IsNullOrEmpty(field.Type.BaseType))
                     {
                         names[field.Name] = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, field.Type);
                     }
                 }
             }
             CodeMemberMethod[] initializeMethods = this.GetInitializeMethods(manager, declaration);
             if (initializeMethods == null)
             {
                 throw new InvalidOperationException();
             }
             foreach (CodeMemberMethod method in initializeMethods)
             {
                 foreach (CodeStatement statement in method.Statements)
                 {
                     CodeVariableDeclarationStatement statement2 = statement as CodeVariableDeclarationStatement;
                     if (statement2 != null)
                     {
                         this._nameTable[statement2.Name] = statement;
                     }
                 }
             }
             this._nameTable[declaration.Name] = context.Expression;
             foreach (CodeMemberMethod method2 in initializeMethods)
             {
                 CodeDomSerializerBase.FillStatementTable(manager, this._statementTable, names, method2.Statements, declaration.Name);
             }
             PropertyDescriptor descriptor = manager.Properties["SupportsStatementGeneration"];
             if (((descriptor != null) && (descriptor.PropertyType == typeof(bool))) && ((bool) descriptor.GetValue(manager)))
             {
                 foreach (string str2 in this._nameTable.Keys)
                 {
                     if (str2.Equals(declaration.Name) || !this._statementTable.ContainsKey(str2))
                     {
                         continue;
                     }
                     CodeStatementCollection statements = this._statementTable[str2];
                     bool flag2 = false;
                     foreach (CodeStatement statement3 in statements)
                     {
                         object obj3 = statement3.UserData["GeneratedStatement"];
                         if (((obj3 == null) || !(obj3 is bool)) || !((bool) obj3))
                         {
//.........这里部分代码省略.........
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:TypeCodeDomSerializer.cs

示例3: DeserializeName

 private object DeserializeName(IDesignerSerializationManager manager, string name, CodeStatementCollection statements)
 {
     object obj2 = null;
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::DeserializeName"))
     {
         obj2 = this._nameTable[name];
         CodeObject obj3 = obj2 as CodeObject;
         string typeName = null;
         CodeMemberField field = null;
         if (obj3 != null)
         {
             obj2 = null;
             this._nameTable[name] = null;
             CodeVariableDeclarationStatement statement = obj3 as CodeVariableDeclarationStatement;
             if (statement != null)
             {
                 typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, statement.Type);
             }
             else
             {
                 field = obj3 as CodeMemberField;
                 if (field != null)
                 {
                     typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, field.Type);
                 }
                 else
                 {
                     CodeExpression expression = obj3 as CodeExpression;
                     RootContext context = manager.Context[typeof(RootContext)] as RootContext;
                     if (((context != null) && (expression != null)) && (context.Expression == expression))
                     {
                         obj2 = context.Value;
                         typeName = TypeDescriptor.GetClassName(obj2);
                     }
                 }
             }
         }
         else if (obj2 == null)
         {
             IContainer service = (IContainer) manager.GetService(typeof(IContainer));
             if (service != null)
             {
                 IComponent component = service.Components[name];
                 if (component != null)
                 {
                     typeName = component.GetType().FullName;
                     this._nameTable[name] = component;
                 }
             }
         }
         if (typeName == null)
         {
             return obj2;
         }
         Type valueType = manager.GetType(typeName);
         if (valueType == null)
         {
             manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { typeName }), manager));
             return obj2;
         }
         if ((statements == null) && this._statementTable.ContainsKey(name))
         {
             statements = this._statementTable[name];
         }
         if ((statements == null) || (statements.Count <= 0))
         {
             return obj2;
         }
         CodeDomSerializer serializer = base.GetSerializer(manager, valueType);
         if (serializer == null)
         {
             manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { valueType.FullName }), manager));
             return obj2;
         }
         try
         {
             obj2 = serializer.Deserialize(manager, statements);
             if ((obj2 != null) && (field != null))
             {
                 PropertyDescriptor descriptor = TypeDescriptor.GetProperties(obj2)["Modifiers"];
                 if ((descriptor != null) && (descriptor.PropertyType == typeof(MemberAttributes)))
                 {
                     MemberAttributes attributes = field.Attributes & MemberAttributes.AccessMask;
                     descriptor.SetValue(obj2, attributes);
                 }
             }
             this._nameTable[name] = obj2;
         }
         catch (Exception exception)
         {
             manager.ReportError(exception);
         }
     }
     return obj2;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:95,代码来源:TypeCodeDomSerializer.cs

示例4: DeserializeExpression

		protected object DeserializeExpression (IDesignerSerializationManager manager, string name, CodeExpression expression) 
		{
			if (expression == null)
				throw new ArgumentNullException ("expression");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			bool errorOccurred = false;
			object deserialized = null;

			// CodeThisReferenceExpression
			//
			CodeThisReferenceExpression thisExpr = expression as CodeThisReferenceExpression;
			if (thisExpr != null) {
				RootContext context = manager.Context[typeof (RootContext)] as RootContext;
				if (context != null) {
					deserialized = context.Value;
				} else {
					IDesignerHost host = manager.GetService (typeof (IDesignerHost)) as IDesignerHost;
					if (host != null)
						deserialized = host.RootComponent;
				}
			}
			
			// CodeVariableReferenceExpression
			//
			CodeVariableReferenceExpression varRef = expression as CodeVariableReferenceExpression;
			if (deserialized == null && varRef != null) {
				deserialized = manager.GetInstance (varRef.VariableName);
				if (deserialized == null) {
					ReportError (manager, "Variable '" + varRef.VariableName + "' not initialized prior to reference");
					errorOccurred = true;
				}
			}

			// CodeFieldReferenceExpression (used for Enum references as well)
			//
			CodeFieldReferenceExpression fieldRef = expression as CodeFieldReferenceExpression;
			if (deserialized == null && fieldRef != null) {
				deserialized = manager.GetInstance (fieldRef.FieldName);
				if (deserialized == null) {
					object fieldHolder = DeserializeExpression (manager, null, fieldRef.TargetObject);
					FieldInfo field = null;
					if (fieldHolder is Type) // static field
						field = ((Type)fieldHolder).GetField (fieldRef.FieldName, 
										      BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
					else // instance field
						field = fieldHolder.GetType().GetField (fieldRef.FieldName, 
											BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
					if (field != null)
						deserialized = field.GetValue (fieldHolder);
				}
				if (deserialized == null)
					ReportError (manager, "Field '" + fieldRef.FieldName + "' not initialized prior to reference");
			}
				

			// CodePrimitiveExpression
			//
			CodePrimitiveExpression primitiveExp = expression as CodePrimitiveExpression;
			if (deserialized == null && primitiveExp != null)
				deserialized = primitiveExp.Value;

			// CodePropertyReferenceExpression
			//
			CodePropertyReferenceExpression propRef = expression as CodePropertyReferenceExpression;
			if (deserialized == null && propRef != null) {
				object target = DeserializeExpression (manager, null, propRef.TargetObject);
				if (target != null && target != _errorMarker) {
					bool found = false;
					if (target is Type) {
						PropertyInfo property = ((Type)target).GetProperty (propRef.PropertyName,
												    BindingFlags.GetProperty | 
												    BindingFlags.Public | BindingFlags.Static);
						if (property != null) {
							deserialized = property.GetValue (null, null);
							found = true;
						}

						// NRefactory seems to produce PropertyReferences to reference some fields and enums
						//
						FieldInfo field = ((Type)target).GetField (propRef.PropertyName,
											   BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
						if (field != null) {
							deserialized = field.GetValue (null);
							found = true;
						}
					} else {
						PropertyDescriptor property = TypeDescriptor.GetProperties (target)[propRef.PropertyName];
						if (property != null) {
							deserialized = property.GetValue (target);
							found = true;
						}

						FieldInfo field = target.GetType().GetField (propRef.PropertyName,
											     BindingFlags.GetField | BindingFlags.Public | BindingFlags.Instance);
						if (field != null) {
							deserialized = field.GetValue (null);
							found = true;
						}
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:CodeDomSerializerBase.cs

示例5: GetSerializer

		protected CodeDomSerializer GetSerializer (IDesignerSerializationManager manager, object instance)
		{
			DesignerSerializerAttribute attrInstance, attrType;
			attrType = attrInstance = null;

			CodeDomSerializer serializer = null;
			if (instance == null)
				serializer = this.GetSerializer (manager, null);
			else {		
				AttributeCollection attributes = TypeDescriptor.GetAttributes (instance);
				foreach (Attribute a in attributes) {
					DesignerSerializerAttribute designerAttr = a as DesignerSerializerAttribute;
					if (designerAttr != null && manager.GetType (designerAttr.SerializerBaseTypeName) == typeof (CodeDomSerializer)) {
						attrInstance = designerAttr;
						break;
					}
				}
	
				attributes = TypeDescriptor.GetAttributes (instance.GetType ());
				foreach (Attribute a in attributes) {
					DesignerSerializerAttribute designerAttr = a as DesignerSerializerAttribute;
					if (designerAttr != null && manager.GetType (designerAttr.SerializerBaseTypeName) == typeof (CodeDomSerializer)) {
						attrType = designerAttr;
						break;
					}
				}
	
				// if there is metadata modification in the instance then create the specified serializer instead of the one
				// in the Type.
				if (attrType != null && attrInstance != null && attrType.SerializerTypeName != attrInstance.SerializerTypeName)
					serializer = Activator.CreateInstance (manager.GetType (attrInstance.SerializerTypeName)) as CodeDomSerializer;
				else
					serializer = this.GetSerializer (manager, instance.GetType ());
			}

			return serializer;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:37,代码来源:CodeDomSerializerBase.cs

示例6: Deserialize

		public override object Deserialize (IDesignerSerializationManager manager, object codeObject)
		{
			CodeTypeDeclaration declaration = (CodeTypeDeclaration) codeObject;
			Type rootType = manager.GetType (declaration.BaseTypes[0].BaseType);
			object root = manager.CreateInstance (rootType, null, declaration.Name, true);

			CodeMemberMethod initComponentMethod = GetInitializeMethod (declaration);
			if (initComponentMethod == null)
				throw new InvalidOperationException ("InitializeComponent method is missing in: " + declaration.Name);

			foreach (CodeStatement statement in initComponentMethod.Statements)
				base.DeserializeStatement (manager, statement);

			return root;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:15,代码来源:RootCodeDomSerializer.cs

示例7: ExtractCtorStatement

		// Used to remove the ctor from the statement colletion in order for the ctor statement to be moved.
		//
		private CodeStatement ExtractCtorStatement (IDesignerSerializationManager manager, CodeStatementCollection statements, 
													object component)
		{
			CodeStatement result = null;
			CodeAssignStatement assignment = null;
			CodeObjectCreateExpression ctor = null;
			int toRemove = -1;

			for (int i=0; i < statements.Count; i++) {
				assignment = statements[i] as CodeAssignStatement;
				if (assignment != null) {
					ctor = assignment.Right as CodeObjectCreateExpression;
					if (ctor != null && manager.GetType (ctor.CreateType.BaseType) == component.GetType ()) {
						result = assignment;
						toRemove = i;
					}
				}
			}

			if (toRemove != -1)
				statements.RemoveAt (toRemove);

			return result;
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:26,代码来源:RootCodeDomSerializer.cs

示例8: Deserialize

 public override object Deserialize(IDesignerSerializationManager manager, object codeObject)
 {
     if ((manager == null) || (codeObject == null))
     {
         throw new ArgumentNullException((manager == null) ? "manager" : "codeObject");
     }
     object obj2 = null;
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::Deserialize"))
     {
         if (!(codeObject is CodeTypeDeclaration))
         {
             throw new ArgumentException(System.Design.SR.GetString("SerializerBadElementType", new object[] { typeof(CodeTypeDeclaration).FullName }));
         }
         bool caseInsensitive = false;
         CodeDomProvider service = manager.GetService(typeof(CodeDomProvider)) as CodeDomProvider;
         if (service != null)
         {
             caseInsensitive = (service.LanguageOptions & LanguageOptions.CaseInsensitive) != LanguageOptions.None;
         }
         CodeTypeDeclaration declaration = (CodeTypeDeclaration) codeObject;
         CodeTypeReference reference = null;
         Type type = null;
         foreach (CodeTypeReference reference2 in declaration.BaseTypes)
         {
             Type type2 = manager.GetType(CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, reference2));
             if ((type2 != null) && !type2.IsInterface)
             {
                 reference = reference2;
                 type = type2;
                 break;
             }
         }
         if (type == null)
         {
             Exception exception = new SerializationException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { reference.BaseType })) {
                 HelpLink = "SerializerTypeNotFound"
             };
             throw exception;
         }
         if (type.IsAbstract)
         {
             Exception exception2 = new SerializationException(System.Design.SR.GetString("SerializerTypeAbstract", new object[] { type.FullName })) {
                 HelpLink = "SerializerTypeAbstract"
             };
             throw exception2;
         }
         ResolveNameEventHandler handler = new ResolveNameEventHandler(this.OnResolveName);
         manager.ResolveName += handler;
         if (!(manager is DesignerSerializationManager))
         {
             manager.AddSerializationProvider(new CodeDomSerializationProvider());
         }
         obj2 = manager.CreateInstance(type, null, declaration.Name, true);
         this.nameTable = new HybridDictionary(declaration.Members.Count, caseInsensitive);
         this.statementTable = new HybridDictionary(declaration.Members.Count, caseInsensitive);
         this.initMethod = null;
         RootContext context = new RootContext(new CodeThisReferenceExpression(), obj2);
         manager.Context.Push(context);
         try
         {
             foreach (CodeTypeMember member in declaration.Members)
             {
                 if (member is CodeMemberField)
                 {
                     if (string.Compare(member.Name, declaration.Name, caseInsensitive, CultureInfo.InvariantCulture) != 0)
                     {
                         this.nameTable[member.Name] = member;
                     }
                 }
                 else if ((this.initMethod == null) && (member is CodeMemberMethod))
                 {
                     CodeMemberMethod method = (CodeMemberMethod) member;
                     if ((string.Compare(method.Name, this.InitMethodName, caseInsensitive, CultureInfo.InvariantCulture) == 0) && (method.Parameters.Count == 0))
                     {
                         this.initMethod = method;
                     }
                 }
             }
             if (this.initMethod != null)
             {
                 foreach (CodeStatement statement in this.initMethod.Statements)
                 {
                     CodeVariableDeclarationStatement statement2 = statement as CodeVariableDeclarationStatement;
                     if (statement2 != null)
                     {
                         this.nameTable[statement2.Name] = statement;
                     }
                 }
             }
             if (this.nameTable[declaration.Name] != null)
             {
                 this.nameTable[declaration.Name] = obj2;
             }
             if (this.initMethod != null)
             {
                 this.FillStatementTable(this.initMethod, declaration.Name);
             }
             PropertyDescriptor descriptor = manager.Properties["SupportsStatementGeneration"];
             if (((descriptor != null) && (descriptor.PropertyType == typeof(bool))) && ((bool) descriptor.GetValue(manager)))
             {
//.........这里部分代码省略.........
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:RootCodeDomSerializer.cs

示例9: DeserializeName

 private object DeserializeName(IDesignerSerializationManager manager, string name)
 {
     string typeName = null;
     Type objectType = null;
     object obj2 = this.nameTable[name];
     using (CodeDomSerializerBase.TraceScope("RootCodeDomSerializer::DeserializeName"))
     {
         CodeMemberField field = null;
         CodeObject obj3 = obj2 as CodeObject;
         if (obj3 != null)
         {
             obj2 = null;
             this.nameTable[name] = null;
             if (obj3 is CodeVariableDeclarationStatement)
             {
                 CodeVariableDeclarationStatement statement = (CodeVariableDeclarationStatement) obj3;
                 typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, statement.Type);
             }
             else if (obj3 is CodeMemberField)
             {
                 field = (CodeMemberField) obj3;
                 typeName = CodeDomSerializerBase.GetTypeNameFromCodeTypeReference(manager, field.Type);
             }
         }
         else
         {
             if (obj2 != null)
             {
                 return obj2;
             }
             IContainer service = (IContainer) manager.GetService(typeof(IContainer));
             if (service != null)
             {
                 IComponent component = service.Components[name];
                 if (component != null)
                 {
                     typeName = component.GetType().FullName;
                     this.nameTable[name] = component;
                 }
             }
         }
         if (name.Equals(this.ContainerName))
         {
             IContainer container2 = (IContainer) manager.GetService(typeof(IContainer));
             if (container2 != null)
             {
                 obj2 = container2;
             }
         }
         else if (typeName != null)
         {
             objectType = manager.GetType(typeName);
             if (objectType == null)
             {
                 manager.ReportError(new SerializationException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { typeName })));
             }
             else
             {
                 CodeStatementCollection codeObject = (CodeStatementCollection) this.statementTable[name];
                 if ((codeObject != null) && (codeObject.Count > 0))
                 {
                     CodeDomSerializer serializer = (CodeDomSerializer) manager.GetSerializer(objectType, typeof(CodeDomSerializer));
                     if (serializer == null)
                     {
                         manager.ReportError(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { objectType.FullName }));
                     }
                     else
                     {
                         try
                         {
                             obj2 = serializer.Deserialize(manager, codeObject);
                             if ((obj2 != null) && (field != null))
                             {
                                 PropertyDescriptor descriptor = TypeDescriptor.GetProperties(obj2)["Modifiers"];
                                 if ((descriptor != null) && (descriptor.PropertyType == typeof(MemberAttributes)))
                                 {
                                     MemberAttributes attributes = field.Attributes & MemberAttributes.AccessMask;
                                     descriptor.SetValue(obj2, attributes);
                                 }
                             }
                         }
                         catch (Exception exception)
                         {
                             manager.ReportError(exception);
                         }
                     }
                 }
             }
         }
         this.nameTable[name] = obj2;
     }
     return obj2;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:93,代码来源:RootCodeDomSerializer.cs

示例10: DeserializeExpression

		protected object DeserializeExpression (IDesignerSerializationManager manager, string name, CodeExpression expression) 
		{
			if (expression == null)
				throw new ArgumentNullException ("expression");
			if (manager == null)
				throw new ArgumentNullException ("manager");

			object deserialized = null;

			// CodeThisReferenceExpression
			//
			CodeThisReferenceExpression thisExpr = expression as CodeThisReferenceExpression;
			if (thisExpr != null) {
				RootContext context = manager.Context[typeof (RootContext)] as RootContext;
				if (context != null) {
					deserialized = context.Value;
				} else {
					IDesignerHost host = manager.GetService (typeof (IDesignerHost)) as IDesignerHost;
					if (host != null)
						deserialized = host.RootComponent;
				}
			}
			
			// CodeVariableReferenceExpression
			//

			CodeVariableReferenceExpression varRef = expression as CodeVariableReferenceExpression;
			if (deserialized == null && varRef != null)
					deserialized = manager.GetInstance (varRef.VariableName);

			// CodeFieldReferenceExpression
			//
			CodeFieldReferenceExpression fieldRef = expression as CodeFieldReferenceExpression;
			if (deserialized == null && fieldRef != null)
				deserialized = manager.GetInstance (fieldRef.FieldName);
				

			// CodePrimitiveExpression
			//
			CodePrimitiveExpression primitiveExp = expression as CodePrimitiveExpression;
			if (deserialized == null && primitiveExp != null)
				deserialized = primitiveExp.Value;

			// CodePropertyReferenceExpression
			//
			// Enum references are represented by a PropertyReferenceExpression, where 
			// PropertyName is the enum field name and the target object is a TypeReference
			// to the enum's type
			//
			CodePropertyReferenceExpression propRef = expression as CodePropertyReferenceExpression;
			if (deserialized == null && propRef != null) {
				object target = DeserializeExpression (manager, null, propRef.TargetObject);
				if (target != null) {
					if (target is Type) { // Enum reference
						FieldInfo field = ((Type)target).GetField (propRef.PropertyName,
																	BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);
						if (field != null)
							deserialized = field.GetValue (null);
					} else {
						PropertyDescriptor property = TypeDescriptor.GetProperties (target)[propRef.PropertyName];
						if (property != null)
							deserialized = property.GetValue (target);
					}
				}
			}

			// CodeObjectCreateExpression
			//
			CodeObjectCreateExpression createExpr = expression as CodeObjectCreateExpression;
			if (deserialized == null && createExpr != null) {
				Type type = manager.GetType (createExpr.CreateType.BaseType);
				object[] arguments = new object[createExpr.Parameters.Count];
				for (int i=0; i < createExpr.Parameters.Count; i++)
					arguments[i] = this.DeserializeExpression (manager, null, createExpr.Parameters[i]);
				bool addToContainer = false;
				if (typeof(IComponent).IsAssignableFrom (type))
					addToContainer = true;
				deserialized = this.DeserializeInstance (manager, type, arguments, name, addToContainer);
			}

			// CodeArrayCreateExpression
			//
			CodeArrayCreateExpression arrayCreateExpr = expression as CodeArrayCreateExpression;
			if (deserialized == null && arrayCreateExpr != null) {
				Type arrayType = manager.GetType (arrayCreateExpr.CreateType.BaseType);
				if (arrayType != null) {
					ArrayList initializers = new ArrayList ();
					foreach (CodeExpression initExpression in arrayCreateExpr.Initializers) {
						initializers.Add (this.DeserializeExpression (manager, null, initExpression));
					}
					deserialized = Array.CreateInstance (arrayType, initializers.Count);
					initializers.CopyTo ((Array)deserialized, 0);
				}
			}

			// CodeMethodInvokeExpression
			//
			CodeMethodInvokeExpression methodExpr = expression as CodeMethodInvokeExpression;
			if (deserialized == null && methodExpr != null) {
				object target = this.DeserializeExpression (manager, null, methodExpr.Method.TargetObject);
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:101,代码来源:CodeDomSerializerBase.cs

示例11: ResolveName

 private bool ResolveName(IDesignerSerializationManager manager, string name, bool canInvokeManager)
 {
     bool flag = false;
     CodeDomSerializerBase.OrderedCodeStatementCollection codeObject = this._statementsTable[name] as CodeDomSerializerBase.OrderedCodeStatementCollection;
     object[] objArray = (object[]) this._objectState[name];
     if (name.IndexOf('.') > 0)
     {
         string outerComponent = null;
         IComponent instance = this.ResolveNestedName(manager, name, ref outerComponent);
         if ((instance != null) && (outerComponent != null))
         {
             manager.SetName(instance, name);
             this.ResolveName(manager, outerComponent, canInvokeManager);
         }
     }
     if (codeObject == null)
     {
         flag = this._statementsTable[name] != null;
         if (!flag)
         {
             if (this._expressions.ContainsKey(name))
             {
                 ArrayList list2 = this._expressions[name];
                 foreach (CodeExpression expression2 in list2)
                 {
                     object obj3 = base.DeserializeExpression(manager, name, expression2);
                     if (((obj3 != null) && !flag) && (canInvokeManager && (manager.GetInstance(name) == null)))
                     {
                         manager.SetName(obj3, name);
                         flag = true;
                     }
                 }
             }
             if (!flag && canInvokeManager)
             {
                 flag = manager.GetInstance(name) != null;
             }
             if ((flag && (objArray != null)) && (objArray[2] != null))
             {
                 this.DeserializeDefaultProperties(manager, name, objArray[2]);
             }
             if ((flag && (objArray != null)) && (objArray[3] != null))
             {
                 this.DeserializeDesignTimeProperties(manager, name, objArray[3]);
             }
             if ((flag && (objArray != null)) && (objArray[4] != null))
             {
                 this.DeserializeEventResets(manager, name, objArray[4]);
             }
             if ((flag && (objArray != null)) && (objArray[5] != null))
             {
                 DeserializeModifier(manager, name, objArray[5]);
             }
         }
         if (!flag && (flag || canInvokeManager))
         {
             manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("CodeDomComponentSerializationServiceDeserializationError", new object[] { name }), manager));
         }
         return flag;
     }
     this._objectState[name] = null;
     this._statementsTable[name] = null;
     string typeName = null;
     foreach (CodeStatement statement in codeObject)
     {
         CodeVariableDeclarationStatement statement2 = statement as CodeVariableDeclarationStatement;
         if (statement2 != null)
         {
             typeName = statement2.Type.BaseType;
             break;
         }
     }
     if (typeName != null)
     {
         Type valueType = manager.GetType(typeName);
         if (valueType == null)
         {
             manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerTypeNotFound", new object[] { typeName }), manager));
             goto Label_01DA;
         }
         if ((codeObject == null) || (codeObject.Count <= 0))
         {
             goto Label_01DA;
         }
         CodeDomSerializer serializer = base.GetSerializer(manager, valueType);
         if (serializer == null)
         {
             manager.ReportError(new CodeDomSerializerException(System.Design.SR.GetString("SerializerNoSerializerForComponent", new object[] { valueType.FullName }), manager));
             goto Label_01DA;
         }
         try
         {
             object obj2 = serializer.Deserialize(manager, codeObject);
             flag = obj2 != null;
             if (flag)
             {
                 this._statementsTable[name] = obj2;
             }
             goto Label_01DA;
         }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:CodeDomComponentSerializationService.cs

示例12: DeserializeExpression

 protected object DeserializeExpression(IDesignerSerializationManager manager, string name, CodeExpression expression)
 {
     object instance = expression;
     using (TraceScope("CodeDomSerializerBase::DeserializeExpression"))
     {
         while (instance != null)
         {
             CodePrimitiveExpression expression2 = instance as CodePrimitiveExpression;
             if (expression2 != null)
             {
                 return expression2.Value;
             }
             CodePropertyReferenceExpression propertyReferenceEx = instance as CodePropertyReferenceExpression;
             if (propertyReferenceEx != null)
             {
                 return this.DeserializePropertyReferenceExpression(manager, propertyReferenceEx, true);
             }
             if (instance is CodeThisReferenceExpression)
             {
                 RootContext context = (RootContext) manager.Context[typeof(RootContext)];
                 if (context != null)
                 {
                     instance = context.Value;
                 }
                 else
                 {
                     IDesignerHost host = manager.GetService(typeof(IDesignerHost)) as IDesignerHost;
                     if (host != null)
                     {
                         instance = host.RootComponent;
                     }
                 }
                 if (instance == null)
                 {
                     Error(manager, System.Design.SR.GetString("SerializerNoRootExpression"), "SerializerNoRootExpression");
                 }
                 return instance;
             }
             CodeTypeReferenceExpression expression4 = instance as CodeTypeReferenceExpression;
             if (expression4 != null)
             {
                 return manager.GetType(GetTypeNameFromCodeTypeReference(manager, expression4.Type));
             }
             CodeObjectCreateExpression expression5 = instance as CodeObjectCreateExpression;
             if (expression5 != null)
             {
                 instance = null;
                 Type c = manager.GetType(GetTypeNameFromCodeTypeReference(manager, expression5.CreateType));
                 if (c != null)
                 {
                     object[] parameters = new object[expression5.Parameters.Count];
                     bool flag = true;
                     for (int i = 0; i < parameters.Length; i++)
                     {
                         parameters[i] = this.DeserializeExpression(manager, null, expression5.Parameters[i]);
                         if (parameters[i] is CodeExpression)
                         {
                             if ((typeof(Delegate).IsAssignableFrom(c) && (parameters.Length == 1)) && (parameters[i] is CodeMethodReferenceExpression))
                             {
                                 CodeMethodReferenceExpression expression19 = (CodeMethodReferenceExpression) parameters[i];
                                 if (!(expression19.TargetObject is CodeThisReferenceExpression))
                                 {
                                     object obj3 = this.DeserializeExpression(manager, null, expression19.TargetObject);
                                     if (!(obj3 is CodeExpression))
                                     {
                                         MethodInfo method = c.GetMethod("Invoke");
                                         if (method != null)
                                         {
                                             ParameterInfo[] infoArray = method.GetParameters();
                                             Type[] types = new Type[infoArray.Length];
                                             for (int j = 0; j < types.Length; j++)
                                             {
                                                 types[j] = infoArray[i].ParameterType;
                                             }
                                             if (GetReflectionTypeHelper(manager, obj3).GetMethod(expression19.MethodName, types) != null)
                                             {
                                                 MethodInfo info2 = obj3.GetType().GetMethod(expression19.MethodName, types);
                                                 instance = Activator.CreateInstance(c, new object[] { obj3, info2.MethodHandle.GetFunctionPointer() });
                                             }
                                         }
                                     }
                                 }
                             }
                             flag = false;
                             break;
                         }
                     }
                     if (flag)
                     {
                         instance = this.DeserializeInstance(manager, c, parameters, name, name != null);
                     }
                     return instance;
                 }
                 Error(manager, System.Design.SR.GetString("SerializerTypeNotFound", new object[] { expression5.CreateType.BaseType }), "SerializerTypeNotFound");
                 return instance;
             }
             CodeArgumentReferenceExpression expression6 = instance as CodeArgumentReferenceExpression;
             if (expression6 != null)
             {
                 instance = manager.GetInstance(expression6.ParameterName);
//.........这里部分代码省略.........
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:101,代码来源:CodeDomSerializerBase.cs

示例13: GetType

 internal static Type GetType(IDesignerSerializationManager manager, string name, Dictionary<string, string> names)
 {
     Type type = null;
     if ((names != null) && names.ContainsKey(name))
     {
         string str = names[name];
         if ((manager != null) && !string.IsNullOrEmpty(str))
         {
             type = manager.GetType(str);
         }
     }
     return type;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:13,代码来源:CodeDomSerializerBase.cs

示例14: GetTypeNameFromCodeTypeReferenceHelper

 private static string GetTypeNameFromCodeTypeReferenceHelper(IDesignerSerializationManager manager, CodeTypeReference typeref)
 {
     if ((typeref.TypeArguments == null) || (typeref.TypeArguments.Count == 0))
     {
         Type type = manager.GetType(typeref.BaseType);
         if (type != null)
         {
             return GetReflectionTypeFromTypeHelper(manager, type).AssemblyQualifiedName;
         }
         return typeref.BaseType;
     }
     StringBuilder builder = new StringBuilder(typeref.BaseType);
     if (!typeref.BaseType.Contains("`"))
     {
         builder.Append("`");
         builder.Append(typeref.TypeArguments.Count);
     }
     builder.Append("[");
     bool flag = true;
     foreach (CodeTypeReference reference in typeref.TypeArguments)
     {
         if (!flag)
         {
             builder.Append(",");
         }
         builder.Append("[");
         builder.Append(GetTypeNameFromCodeTypeReferenceHelper(manager, reference));
         builder.Append("]");
         flag = false;
     }
     builder.Append("]");
     return builder.ToString();
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:33,代码来源:CodeDomSerializerBase.cs

示例15: GetSerializer

 protected CodeDomSerializer GetSerializer(IDesignerSerializationManager manager, object value)
 {
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (value != null)
     {
         AttributeCollection attributesHelper = GetAttributesHelper(manager, value);
         AttributeCollection attributesFromTypeHelper = GetAttributesFromTypeHelper(manager, value.GetType());
         if (attributesHelper.Count != attributesFromTypeHelper.Count)
         {
             string typeName = null;
             Type type = typeof(CodeDomSerializer);
             DesignerSerializationManager manager2 = manager as DesignerSerializationManager;
             foreach (Attribute attribute in attributesHelper)
             {
                 DesignerSerializerAttribute attribute2 = attribute as DesignerSerializerAttribute;
                 if (attribute2 != null)
                 {
                     Type runtimeType;
                     if (manager2 != null)
                     {
                         runtimeType = manager2.GetRuntimeType(attribute2.SerializerBaseTypeName);
                     }
                     else
                     {
                         runtimeType = manager.GetType(attribute2.SerializerBaseTypeName);
                     }
                     if (runtimeType == type)
                     {
                         typeName = attribute2.SerializerTypeName;
                         break;
                     }
                 }
             }
             if (typeName != null)
             {
                 foreach (Attribute attribute3 in attributesFromTypeHelper)
                 {
                     DesignerSerializerAttribute attribute4 = attribute3 as DesignerSerializerAttribute;
                     if (attribute4 != null)
                     {
                         Type type3;
                         if (manager2 != null)
                         {
                             type3 = manager2.GetRuntimeType(attribute4.SerializerBaseTypeName);
                         }
                         else
                         {
                             type3 = manager.GetType(attribute4.SerializerBaseTypeName);
                         }
                         if (type3 == type)
                         {
                             if (typeName.Equals(attribute4.SerializerTypeName))
                             {
                                 typeName = null;
                             }
                             break;
                         }
                     }
                 }
             }
             if (typeName != null)
             {
                 Type c = (manager2 != null) ? manager2.GetRuntimeType(typeName) : manager.GetType(typeName);
                 if ((c != null) && type.IsAssignableFrom(c))
                 {
                     return (CodeDomSerializer) Activator.CreateInstance(c);
                 }
             }
         }
     }
     Type objectType = null;
     if (value != null)
     {
         objectType = value.GetType();
     }
     return (CodeDomSerializer) manager.GetSerializer(objectType, typeof(CodeDomSerializer));
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:80,代码来源:CodeDomSerializerBase.cs


注:本文中的IDesignerSerializationManager.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。