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


C# IDesignerSerializationManager.GetInstance方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetExpression

		protected CodeExpression GetExpression (IDesignerSerializationManager manager, object instance)
		{
			if (manager == null)
				throw new ArgumentNullException ("manager");
			if (instance == null)
				throw new ArgumentNullException ("instance");

			CodeExpression expression = null;

			ExpressionTable expressions = manager.Context[typeof (ExpressionTable)] as ExpressionTable;
			if (expressions != null) // 1st try: ExpressionTable
				expression = expressions [instance] as CodeExpression;

			if (expression == null) { // 2nd try: RootContext
				RootContext context = manager.Context[typeof (RootContext)] as RootContext;
				if (context != null && context.Value == instance)
					expression = context.Expression;
			}

			if (expression == null) { // 3rd try: IReferenceService (instance.property.property.property
				string name = manager.GetName (instance);
				if (name == null || name.IndexOf (".") == -1) {
					IReferenceService service = manager.GetService (typeof (IReferenceService)) as IReferenceService;
					if (service != null) {
						name = service.GetName (instance);
						if (name != null && name.IndexOf (".") != -1) {
							string[] parts = name.Split (new char[] { ',' });
							instance = manager.GetInstance (parts[0]);
							if (instance != null) {
								expression = SerializeToExpression (manager, instance);
								if (expression != null) {
									for (int i=1; i < parts.Length; i++)
										expression = new CodePropertyReferenceExpression (expression, parts[i]);
								}
							}
						}
					}
				}
			}
			return expression;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:41,代码来源:CodeDomSerializerBase.cs

示例4: 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

示例5: ResolveNestedName

 private IComponent ResolveNestedName(IDesignerSerializationManager manager, string name, ref string outerComponent)
 {
     IComponent instance = null;
     if ((name != null) && (manager != null))
     {
         bool flag = true;
         int index = name.IndexOf('.', 0);
         outerComponent = name.Substring(0, index);
         instance = manager.GetInstance(outerComponent) as IComponent;
         int num2 = index;
         int length = name.IndexOf('.', index + 1);
         while (flag)
         {
             flag = length != -1;
             string str = flag ? name.Substring(num2 + 1, length) : name.Substring(num2 + 1);
             if ((instance != null) && (instance.Site != null))
             {
                 INestedContainer service = instance.Site.GetService(typeof(INestedContainer)) as INestedContainer;
                 if ((service != null) && !string.IsNullOrEmpty(str))
                 {
                     instance = service.Components[str];
                     goto Label_00B7;
                 }
             }
             return null;
         Label_00B7:
             if (flag)
             {
                 num2 = length;
                 length = name.IndexOf('.', length + 1);
             }
         }
     }
     return instance;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:CodeDomComponentSerializationService.cs

示例6: DeserializeEventResets

 private void DeserializeEventResets(IDesignerSerializationManager manager, string name, object state)
 {
     List<string> list = state as List<string>;
     if (((list != null) && (manager != null)) && !string.IsNullOrEmpty(name))
     {
         IEventBindingService service = manager.GetService(typeof(IEventBindingService)) as IEventBindingService;
         object instance = manager.GetInstance(name);
         if ((instance != null) && (service != null))
         {
             PropertyDescriptorCollection eventProperties = service.GetEventProperties(TypeDescriptor.GetEvents(instance));
             if (eventProperties != null)
             {
                 foreach (string str in list)
                 {
                     PropertyDescriptor descriptor = eventProperties[str];
                     if (descriptor != null)
                     {
                         descriptor.SetValue(instance, null);
                     }
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:CodeDomComponentSerializationService.cs

示例7: DeserializeModifier

 private static void DeserializeModifier(IDesignerSerializationManager manager, string name, object state)
 {
     object instance = manager.GetInstance(name);
     if (instance != null)
     {
         MemberAttributes attributes = (MemberAttributes) state;
         PropertyDescriptor descriptor = TypeDescriptor.GetProperties(instance)["Modifiers"];
         if (descriptor != null)
         {
             descriptor.SetValue(instance, attributes);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:CodeDomComponentSerializationService.cs

示例8: DeserializeDesignTimeProperties

 private void DeserializeDesignTimeProperties(IDesignerSerializationManager manager, string name, object state)
 {
     if (state != null)
     {
         object instance = manager.GetInstance(name);
         if (instance != null)
         {
             PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);
             foreach (DictionaryEntry entry in (IDictionary) state)
             {
                 PropertyDescriptor descriptor = properties[(string) entry.Key];
                 if (descriptor != null)
                 {
                     descriptor.SetValue(instance, entry.Value);
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:CodeDomComponentSerializationService.cs

示例9: DeserializeDefaultProperties

 private void DeserializeDefaultProperties(IDesignerSerializationManager manager, string name, object state)
 {
     if ((state != null) && this.applyDefaults)
     {
         object instance = manager.GetInstance(name);
         if (instance != null)
         {
             PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance);
             string[] strArray = (string[]) state;
             MemberRelationshipService service = manager.GetService(typeof(MemberRelationshipService)) as MemberRelationshipService;
             foreach (string str in strArray)
             {
                 PropertyDescriptor descriptor = properties[str];
                 if ((descriptor != null) && descriptor.CanResetValue(instance))
                 {
                     if ((service != null) && (service[instance, descriptor] != MemberRelationship.Empty))
                     {
                         service[instance, descriptor] = MemberRelationship.Empty;
                     }
                     descriptor.ResetValue(instance);
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:CodeDomComponentSerializationService.cs

示例10: 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

示例11: GetUniqueName

 protected string GetUniqueName(IDesignerSerializationManager manager, object value)
 {
     string str2;
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     string name = manager.GetName(value);
     if (name != null)
     {
         return name;
     }
     Type reflectionTypeHelper = GetReflectionTypeHelper(manager, value);
     INameCreationService service = manager.GetService(typeof(INameCreationService)) as INameCreationService;
     if (service != null)
     {
         str2 = service.CreateName(null, reflectionTypeHelper);
     }
     else
     {
         str2 = reflectionTypeHelper.Name.ToLower(CultureInfo.InvariantCulture);
     }
     int num = 1;
     ComponentCache cache = manager.Context[typeof(ComponentCache)] as ComponentCache;
     while (true)
     {
         name = string.Format(CultureInfo.CurrentCulture, "{0}{1}", new object[] { str2, num });
         if ((manager.GetInstance(name) == null) && ((cache == null) || !cache.ContainsLocalName(name)))
         {
             manager.SetName(value, name);
             ComponentCache.Entry entry = manager.Context[typeof(ComponentCache.Entry)] as ComponentCache.Entry;
             if (entry != null)
             {
                 entry.AddLocalName(name);
             }
             return name;
         }
         num++;
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:44,代码来源:CodeDomSerializerBase.cs

示例12: GetExpression

 protected CodeExpression GetExpression(IDesignerSerializationManager manager, object value)
 {
     CodeExpression expression = null;
     if (manager == null)
     {
         throw new ArgumentNullException("manager");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     ExpressionTable table = manager.Context[typeof(ExpressionTable)] as ExpressionTable;
     if (table != null)
     {
         expression = table.GetExpression(value);
     }
     if (expression == null)
     {
         RootContext context = manager.Context[typeof(RootContext)] as RootContext;
         if ((context != null) && object.ReferenceEquals(context.Value, value))
         {
             expression = context.Expression;
         }
     }
     if (expression == null)
     {
         string name = manager.GetName(value);
         if ((name == null) || (name.IndexOf('.') != -1))
         {
             IReferenceService service = manager.GetService(typeof(IReferenceService)) as IReferenceService;
             if (service != null)
             {
                 name = service.GetName(value);
                 if ((name != null) && (name.IndexOf('.') != -1))
                 {
                     string[] strArray = name.Split(new char[] { '.' });
                     object instance = manager.GetInstance(strArray[0]);
                     if (instance != null)
                     {
                         CodeExpression targetObject = this.SerializeToExpression(manager, instance);
                         if (targetObject != null)
                         {
                             for (int i = 1; i < strArray.Length; i++)
                             {
                                 targetObject = new CodePropertyReferenceExpression(targetObject, strArray[i]);
                             }
                             expression = targetObject;
                         }
                     }
                 }
             }
         }
     }
     if (expression == null)
     {
         ExpressionContext context2 = manager.Context[typeof(ExpressionContext)] as ExpressionContext;
         if ((context2 != null) && object.ReferenceEquals(context2.PresetValue, value))
         {
             expression = context2.Expression;
         }
     }
     if (expression != null)
     {
         ComponentCache.Entry entry = (ComponentCache.Entry) manager.Context[typeof(ComponentCache.Entry)];
         ComponentCache cache = (ComponentCache) manager.Context[typeof(ComponentCache)];
         if (((entry != null) && (entry.Component != value)) && (cache != null))
         {
             ComponentCache.Entry entryAll = null;
             entryAll = cache.GetEntryAll(value);
             if ((entryAll != null) && (entry.Component != null))
             {
                 entryAll.AddDependency(entry.Component);
             }
         }
     }
     return expression;
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:77,代码来源:CodeDomSerializerBase.cs


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